@esri/solutions-components 5.1.0-next.164 → 5.1.0-next.165

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (188) hide show
  1. package/dist/cdn/22BT2PBE.js +338 -0
  2. package/dist/cdn/{OZSFGLR6.js → 25HVM373.js} +1 -1
  3. package/dist/cdn/{44EC2SD3.js → 26LDC3OX.js} +1 -1
  4. package/dist/cdn/275IZ5I6.js +5 -0
  5. package/dist/cdn/{GUMEOBNQ.js → 2D6HFQD5.js} +1 -1
  6. package/dist/cdn/{QTFTJ4DQ.js → 2EXGHOIM.js} +1 -1
  7. package/dist/cdn/{F3A22NPP.js → 2NSMAAXL.js} +1 -1
  8. package/dist/cdn/{A2VP46QZ.js → 2R7Y2ZVX.js} +1 -1
  9. package/dist/cdn/{3KRXI2TQ.js → 2RL6H5TB.js} +1 -1
  10. package/dist/cdn/{A6VVARNG.js → 2TEBTKD4.js} +1 -1
  11. package/dist/cdn/354D2K6F.js +2 -0
  12. package/dist/cdn/{D4TEADUS.js → 37P3IMFV.js} +1 -1
  13. package/dist/cdn/{C5BQAX2M.js → 3A3CPQX4.js} +1 -1
  14. package/dist/cdn/{2V64PFN2.js → 3J5ZSELO.js} +1 -1
  15. package/dist/cdn/{Q4X6GXRI.js → 3JCHYXHA.js} +1 -1
  16. package/dist/cdn/{IXLVTSCY.js → 3SMHMC4L.js} +1 -1
  17. package/dist/cdn/{S4ZMJ42A.js → 3UCDO65S.js} +1 -1
  18. package/dist/cdn/{CPOZIWVH.js → 463CZQF6.js} +1 -1
  19. package/dist/cdn/{BQ7O62CG.js → 47FRMYZ4.js} +1 -1
  20. package/dist/cdn/4A77MNRM.js +2 -0
  21. package/dist/cdn/{H5KFQMYD.js → 4HRGPGDM.js} +1 -1
  22. package/dist/cdn/{U6DXEFHP.js → 4RCC4KA2.js} +1 -1
  23. package/dist/cdn/{WXM3KMEV.js → 4SORDX5Z.js} +1 -1
  24. package/dist/cdn/{EHSIODIO.js → 54A4C4RG.js} +1 -1
  25. package/dist/cdn/54TJQLYJ.js +69 -0
  26. package/dist/cdn/{D5JF7XQN.js → 56DNSWXG.js} +1 -1
  27. package/dist/cdn/{OMRM5EXN.js → 5FWKODDH.js} +1 -1
  28. package/dist/cdn/{G63OYQ7G.js → 5IDPOFIN.js} +1 -1
  29. package/dist/cdn/{TLRBE2TZ.js → 5LSNDSHW.js} +1 -1
  30. package/dist/cdn/{I4EEOB6Y.js → 5N4KGIIY.js} +1 -1
  31. package/dist/cdn/{QWGJAD3Z.js → 67CEWYTY.js} +1 -1
  32. package/dist/cdn/6FY64JKN.js +2 -0
  33. package/dist/cdn/{EYJQEBDF.js → 6HZBPFHA.js} +1 -1
  34. package/dist/cdn/{XEYYUNNX.js → 6PZSOVYB.js} +1 -1
  35. package/dist/cdn/{FZNRD2XJ.js → 6WNKGSHD.js} +1 -1
  36. package/dist/cdn/{NQBHAESW.js → 6WVYNWVR.js} +1 -1
  37. package/dist/cdn/{MBVY6OPY.js → 743J2ZUC.js} +1 -1
  38. package/dist/cdn/{7YJMTZFC.js → 77753TPX.js} +1 -1
  39. package/dist/cdn/{4G6CA64M.js → 7VY3RI7C.js} +1 -1
  40. package/dist/cdn/A2A3RFJ6.js +2 -0
  41. package/dist/cdn/{GABDTUB7.js → A6ZTIX3P.js} +1 -1
  42. package/dist/cdn/{R3PYC2H6.js → AAUM57XI.js} +1 -1
  43. package/dist/cdn/{Z226R5SF.js → ADURBGIK.js} +1 -1
  44. package/dist/cdn/{GVFCX2FF.js → APNDTPBA.js} +1 -1
  45. package/dist/cdn/{S47SVZPE.js → ARFBMFQW.js} +1 -1
  46. package/dist/cdn/ATEW4U4A.js +2 -0
  47. package/dist/cdn/{TSUSILGP.js → AYHTQTVS.js} +1 -1
  48. package/dist/cdn/{KU2LYW6K.js → BIX5DRQP.js} +1 -1
  49. package/dist/cdn/{G2RMWJ7R.js → BOFA5RH7.js} +1 -1
  50. package/dist/cdn/{P7LSYADG.js → BWWX52HV.js} +1 -1
  51. package/dist/cdn/{QPX33Y62.js → BXSBR2GT.js} +1 -1
  52. package/dist/cdn/{PN2P5EVA.js → CMCEF65U.js} +1 -1
  53. package/dist/cdn/CRDFUDM4.js +45 -0
  54. package/dist/cdn/{4AFANEZZ.js → CS5N3DOL.js} +1 -1
  55. package/dist/cdn/{CZ4A24AM.js → CU2JLCTZ.js} +1 -1
  56. package/dist/cdn/{KSAJFFJI.js → CV4B2O7J.js} +1 -1
  57. package/dist/cdn/{TTCTODAR.js → CVXDL2AT.js} +1 -1
  58. package/dist/cdn/{XHFFDKEQ.js → D22STVK5.js} +1 -1
  59. package/dist/cdn/{XF5N3NI5.js → DIBK4RSG.js} +1 -1
  60. package/dist/cdn/{JCQQIAIE.js → DQ47P6ES.js} +1 -1
  61. package/dist/cdn/{5NZT27OV.js → DVPYGOBV.js} +1 -1
  62. package/dist/cdn/E3F63VW4.js +2 -0
  63. package/dist/cdn/EL3OIP52.js +31 -0
  64. package/dist/cdn/{WQHJMFGP.js → ENXQ33P7.js} +1 -1
  65. package/dist/cdn/{Q6WCNWQE.js → ERLDQUNI.js} +1 -1
  66. package/dist/cdn/EUI6UDCN.js +43 -0
  67. package/dist/cdn/{RQIGAX6O.js → EWS72RFR.js} +1 -1
  68. package/dist/cdn/{4PNNKMNH.js → F4MS4NQL.js} +1 -1
  69. package/dist/cdn/{UA6XD7SQ.js → FFZ2XVRE.js} +1 -1
  70. package/dist/cdn/{YNCRTGYJ.js → FMPY32BG.js} +1 -1
  71. package/dist/cdn/{XKEKXTL2.js → FSF3T3OT.js} +1 -1
  72. package/dist/cdn/{JFLG3EKT.js → FYJMHXWV.js} +1 -1
  73. package/dist/cdn/{57SZHKM5.js → G4V4JPFI.js} +1 -1
  74. package/dist/cdn/GSCHQNQD.js +56 -0
  75. package/dist/cdn/{SHI2ULEO.js → GSR2GEY7.js} +1 -1
  76. package/dist/cdn/{2OCRSUSE.js → GUSPFJUQ.js} +1 -1
  77. package/dist/cdn/{LY3WRG7K.js → GVMTSUDH.js} +1 -1
  78. package/dist/cdn/{A62EWI7L.js → H4LZV33O.js} +1 -1
  79. package/dist/cdn/{OG4BNL2Z.js → HAMYUUYZ.js} +1 -1
  80. package/dist/cdn/{DVCYL5TO.js → HDMAFAEM.js} +1 -1
  81. package/dist/cdn/{X65HFYH4.js → HIB4BVGK.js} +1 -1
  82. package/dist/cdn/{2I5LGZNX.js → HIPZRG2Q.js} +1 -1
  83. package/dist/cdn/{LXGY2E55.js → HKFXHTYU.js} +1 -1
  84. package/dist/cdn/{EKK5FR2V.js → HM2QALUN.js} +1 -1
  85. package/dist/cdn/{MISU75DC.js → HQCHD3FH.js} +1 -1
  86. package/dist/cdn/HRQVJBRJ.js +2 -0
  87. package/dist/cdn/HXNARVYH.js +3 -0
  88. package/dist/cdn/{Q3MHT47G.js → I4PBOBUM.js} +1 -1
  89. package/dist/cdn/{V7WSQCQY.js → IAEFPE3L.js} +1 -1
  90. package/dist/cdn/INLWMPGE.js +2 -0
  91. package/dist/cdn/ITCC5G26.js +136 -0
  92. package/dist/cdn/IXPNZCW6.js +2 -0
  93. package/dist/cdn/{SMN3CVM5.js → IXRFWVBT.js} +1 -1
  94. package/dist/cdn/JFMNVOWH.js +2 -0
  95. package/dist/cdn/{AV2Q4PBA.js → JFPR5QIQ.js} +1 -1
  96. package/dist/cdn/{DF7TCZUS.js → KDDHPA54.js} +1 -1
  97. package/dist/cdn/{3IO2JXVB.js → KR2PPIBX.js} +1 -1
  98. package/dist/cdn/LGBRHJBY.js +109 -0
  99. package/dist/cdn/{5K5GHKON.js → LV5KMTCD.js} +1 -1
  100. package/dist/cdn/LVYAW6XF.js +2 -0
  101. package/dist/cdn/LWJF6EXD.js +85 -0
  102. package/dist/cdn/{55QBAVPE.js → M6AOD7GG.js} +1 -1
  103. package/dist/cdn/{J6CXULUZ.js → MFFM74RG.js} +1 -1
  104. package/dist/cdn/{XM3SRZWV.js → MIV34H66.js} +1 -1
  105. package/dist/cdn/{EF2TTWG5.js → MKSUYITL.js} +1 -1
  106. package/dist/cdn/{IXBI3PV7.js → MOSQBUUZ.js} +1 -1
  107. package/dist/cdn/MV7GEGP5.js +98 -0
  108. package/dist/cdn/{26QXT6ZT.js → O4DB2EXV.js} +1 -1
  109. package/dist/cdn/OAUHQK3Y.js +54 -0
  110. package/dist/cdn/{WGRSVQHE.js → OBCXHY24.js} +1 -1
  111. package/dist/cdn/{V5WXJLJN.js → ON4EBR25.js} +1 -1
  112. package/dist/cdn/{7RIJ2EMD.js → OUMIC7G7.js} +1 -1
  113. package/dist/cdn/{F5SUVMAE.js → OZ4IYASP.js} +1 -1
  114. package/dist/cdn/{X7WLU5YB.js → P666D4WT.js} +1 -1
  115. package/dist/cdn/PGTLLFW6.js +3 -0
  116. package/dist/cdn/{WCXR46D4.js → PLQEDCUG.js} +1 -1
  117. package/dist/cdn/PLXHBQBF.js +146 -0
  118. package/dist/cdn/{22BJ76LD.js → PM4EFNB2.js} +1 -1
  119. package/dist/cdn/PPFEO3UH.js +2 -0
  120. package/dist/cdn/{UBPOT5V3.js → QMAV4UTN.js} +1 -1
  121. package/dist/cdn/{MICWKD3Q.js → QYCERRRZ.js} +1 -1
  122. package/dist/cdn/{7JC52SFZ.js → QZ2ZMWIH.js} +1 -1
  123. package/dist/cdn/{CAYWD56D.js → R27S3IDW.js} +1 -1
  124. package/dist/cdn/RDJIKSXN.js +439 -0
  125. package/dist/cdn/{I2NTSKBD.js → RLSY4VUQ.js} +1 -1
  126. package/dist/cdn/{HVT2WBVC.js → S4GBMN37.js} +1 -1
  127. package/dist/cdn/{KTRKTBPS.js → SGFSVWTY.js} +1 -1
  128. package/dist/cdn/{3LZFERNW.js → SHEDDVHQ.js} +1 -1
  129. package/dist/cdn/{5F6KCXYP.js → SJLSYFK3.js} +1 -1
  130. package/dist/cdn/T3EPRHTT.js +4 -0
  131. package/dist/cdn/TLIIJ2QC.js +122 -0
  132. package/dist/cdn/{BM4VSEDV.js → TWJ6DAY5.js} +1 -1
  133. package/dist/cdn/{KKEERGX7.js → TZHRYPII.js} +1 -1
  134. package/dist/cdn/{I7MO6UJB.js → U27263JW.js} +1 -1
  135. package/dist/cdn/{DKXVDY6L.js → U2FC3BET.js} +1 -1
  136. package/dist/cdn/{FBGCV6YJ.js → UCYR537P.js} +1 -1
  137. package/dist/cdn/{SS6AENH6.js → UDPMO6YN.js} +1 -1
  138. package/dist/cdn/{DJYT367X.js → V5BIPD5T.js} +1 -1
  139. package/dist/cdn/{XXQVYXGC.js → VBJJQPZT.js} +1 -1
  140. package/dist/cdn/VDI7SDRK.js +5 -0
  141. package/dist/cdn/VDZT4UXB.js +36 -0
  142. package/dist/cdn/{24DOFCUH.js → VKHBBAXO.js} +1 -1
  143. package/dist/cdn/{O7VRD3Z3.js → VL2NVCIB.js} +1 -1
  144. package/dist/cdn/{RBSOCHJT.js → VN3AKGAY.js} +1 -1
  145. package/dist/cdn/{VTAQ6NBB.js → VUXNHQGR.js} +1 -1
  146. package/dist/cdn/{EFYLYWPE.js → W5TNQMAJ.js} +1 -1
  147. package/dist/cdn/{BATEZR3T.js → WNVC3PSY.js} +1 -1
  148. package/dist/cdn/WXDMML76.js +2 -0
  149. package/dist/cdn/{JEIP7CJK.js → XKFX43FE.js} +1 -1
  150. package/dist/cdn/{GLC7JVKG.js → XQ7SXIHI.js} +1 -1
  151. package/dist/cdn/{ISFTCFSJ.js → Y2AUIXNK.js} +1 -1
  152. package/dist/cdn/{L4BYLII5.js → Y3GFBLXF.js} +1 -1
  153. package/dist/cdn/{VCLTCEIQ.js → YEDC2OLI.js} +1 -1
  154. package/dist/cdn/{3QONPAFM.js → YLIWN2J2.js} +1 -1
  155. package/dist/cdn/YPDXQEUA.js +77 -0
  156. package/dist/cdn/{SXECIQ6Q.js → YSQDSGSF.js} +1 -1
  157. package/dist/cdn/{BEKMMPB7.js → YUI2MSOK.js} +1 -1
  158. package/dist/cdn/{ONARC6AZ.js → YUWXPLTE.js} +1 -1
  159. package/dist/cdn/{CKURBJFW.js → YW2WMW6B.js} +1 -1
  160. package/dist/cdn/{IEXNY45H.js → ZWASNOIQ.js} +1 -1
  161. package/dist/cdn/index.js +1 -1
  162. package/dist/chunks/classifyIntent.js +31 -44
  163. package/dist/chunks/solution-builder-assistant.js +11 -11
  164. package/dist/chunks/validators.js +4 -3
  165. package/dist/components/arcgis-solutions-assistant/customElement.js +1031 -792
  166. package/dist/docs/api.json +1 -1
  167. package/dist/docs/docs.json +1 -1
  168. package/dist/docs/web-types.json +1 -1
  169. package/dist/solutions-components_commit.txt +3 -3
  170. package/package.json +1 -1
  171. package/dist/cdn/5M3PCZM5.js +0 -2
  172. package/dist/cdn/7VD3Y4IF.js +0 -2
  173. package/dist/cdn/B5JYLQYP.js +0 -2
  174. package/dist/cdn/FE7HMUSZ.js +0 -2
  175. package/dist/cdn/FFF5HUPM.js +0 -4
  176. package/dist/cdn/FZUI77EG.js +0 -2
  177. package/dist/cdn/J6OVONBB.js +0 -2
  178. package/dist/cdn/JDI57IEI.js +0 -98
  179. package/dist/cdn/LDSV7DEV.js +0 -2
  180. package/dist/cdn/LHTDVWX2.js +0 -90
  181. package/dist/cdn/LQXIFBIM.js +0 -3
  182. package/dist/cdn/O4VFFJLQ.js +0 -2
  183. package/dist/cdn/TGMVIKID.js +0 -2
  184. package/dist/cdn/UHJVBWUV.js +0 -434
  185. package/dist/cdn/V4O3KYPD.js +0 -2
  186. package/dist/cdn/V4ZJH2HP.js +0 -2
  187. package/dist/cdn/VHYS3SP3.js +0 -2
  188. package/dist/cdn/WRQXYCRH.js +0 -2
@@ -1,434 +0,0 @@
1
- /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{b as Ma,c as Tn,d as zu}from"./EXBEKVP5.js";var TE=Ma((r8,Mg)=>{"use strict";var Z4=Object.prototype.hasOwnProperty,rr="~";function tl(){}Object.create&&(tl.prototype=Object.create(null),new tl().__proto__||(rr=!1));function H4(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function IE(e,t,r,i,n){if(typeof r!="function")throw new TypeError("The listener must be a function");var a=new H4(r,i||e,n),o=rr?rr+t:t;return e._events[o]?e._events[o].fn?e._events[o]=[e._events[o],a]:e._events[o].push(a):(e._events[o]=a,e._eventsCount++),e}function Md(e,t){--e._eventsCount===0?e._events=new tl:delete e._events[t]}function Dt(){this._events=new tl,this._eventsCount=0}Dt.prototype.eventNames=function(){var t=[],r,i;if(this._eventsCount===0)return t;for(i in r=this._events)Z4.call(r,i)&&t.push(rr?i.slice(1):i);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(r)):t};Dt.prototype.listeners=function(t){var r=rr?rr+t:t,i=this._events[r];if(!i)return[];if(i.fn)return[i.fn];for(var n=0,a=i.length,o=new Array(a);n<a;n++)o[n]=i[n].fn;return o};Dt.prototype.listenerCount=function(t){var r=rr?rr+t:t,i=this._events[r];return i?i.fn?1:i.length:0};Dt.prototype.emit=function(t,r,i,n,a,o){var s=rr?rr+t:t;if(!this._events[s])return!1;var c=this._events[s],l=arguments.length,u,d;if(c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,r),!0;case 3:return c.fn.call(c.context,r,i),!0;case 4:return c.fn.call(c.context,r,i,n),!0;case 5:return c.fn.call(c.context,r,i,n,a),!0;case 6:return c.fn.call(c.context,r,i,n,a,o),!0}for(d=1,u=new Array(l-1);d<l;d++)u[d-1]=arguments[d];c.fn.apply(c.context,u)}else{var f=c.length,p;for(d=0;d<f;d++)switch(c[d].once&&this.removeListener(t,c[d].fn,void 0,!0),l){case 1:c[d].fn.call(c[d].context);break;case 2:c[d].fn.call(c[d].context,r);break;case 3:c[d].fn.call(c[d].context,r,i);break;case 4:c[d].fn.call(c[d].context,r,i,n);break;default:if(!u)for(p=1,u=new Array(l-1);p<l;p++)u[p-1]=arguments[p];c[d].fn.apply(c[d].context,u)}}return!0};Dt.prototype.on=function(t,r,i){return IE(this,t,r,i,!1)};Dt.prototype.once=function(t,r,i){return IE(this,t,r,i,!0)};Dt.prototype.removeListener=function(t,r,i,n){var a=rr?rr+t:t;if(!this._events[a])return this;if(!r)return Md(this,a),this;var o=this._events[a];if(o.fn)o.fn===r&&(!n||o.once)&&(!i||o.context===i)&&Md(this,a);else{for(var s=0,c=[],l=o.length;s<l;s++)(o[s].fn!==r||n&&!o[s].once||i&&o[s].context!==i)&&c.push(o[s]);c.length?this._events[a]=c.length===1?c[0]:c:Md(this,a)}return this};Dt.prototype.removeAllListeners=function(t){var r;return t?(r=rr?rr+t:t,this._events[r]&&Md(this,r)):(this._events=new tl,this._eventsCount=0),this};Dt.prototype.off=Dt.prototype.removeListener;Dt.prototype.addListener=Dt.prototype.on;Dt.prefixed=rr;Dt.EventEmitter=Dt;typeof Mg<"u"&&(Mg.exports=Dt)});var AE=Ma((n8,CE)=>{"use strict";CE.exports=(e,t)=>(t=t||(()=>{}),e.then(r=>new Promise(i=>{i(t())}).then(()=>r),r=>new Promise(i=>{i(t())}).then(()=>{throw r})))});var PE=Ma((i8,zd)=>{"use strict";var G4=AE(),jd=class extends Error{constructor(t){super(t),this.name="TimeoutError"}},OE=(e,t,r)=>new Promise((i,n)=>{if(typeof t!="number"||t<0)throw new TypeError("Expected `milliseconds` to be a positive number");if(t===1/0){i(e);return}let a=setTimeout(()=>{if(typeof r=="function"){try{i(r())}catch(c){n(c)}return}let o=typeof r=="string"?r:`Promise timed out after ${t} milliseconds`,s=r instanceof Error?r:new jd(o);typeof e.cancel=="function"&&e.cancel(),n(s)},t);G4(e.then(i,n),()=>{clearTimeout(a)})});zd.exports=OE;zd.exports.default=OE;zd.exports.TimeoutError=jd});var NE=Ma(jg=>{"use strict";Object.defineProperty(jg,"__esModule",{value:!0});function W4(e,t,r){let i=0,n=e.length;for(;n>0;){let a=n/2|0,o=i+a;r(e[o],t)<=0?(i=++o,n-=a+1):n=a}return i}jg.default=W4});var RE=Ma(Dg=>{"use strict";Object.defineProperty(Dg,"__esModule",{value:!0});var J4=NE(),zg=class{constructor(){this._queue=[]}enqueue(t,r){r=Object.assign({priority:0},r);let i={priority:r.priority,run:t};if(this.size&&this._queue[this.size-1].priority>=r.priority){this._queue.push(i);return}let n=J4.default(this._queue,i,(a,o)=>o.priority-a.priority);this._queue.splice(n,0,i)}dequeue(){let t=this._queue.shift();return t?.run}filter(t){return this._queue.filter(r=>r.priority===t.priority).map(r=>r.run)}get size(){return this._queue.length}};Dg.default=zg});var Ud=Ma(Lg=>{"use strict";Object.defineProperty(Lg,"__esModule",{value:!0});var K4=TE(),ME=PE(),q4=RE(),Dd=()=>{},X4=new ME.TimeoutError,Ug=class extends K4{constructor(t){var r,i,n,a;if(super(),this._intervalCount=0,this._intervalEnd=0,this._pendingCount=0,this._resolveEmpty=Dd,this._resolveIdle=Dd,t=Object.assign({carryoverConcurrencyCount:!1,intervalCap:1/0,interval:0,concurrency:1/0,autoStart:!0,queueClass:q4.default},t),!(typeof t.intervalCap=="number"&&t.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${(i=(r=t.intervalCap)===null||r===void 0?void 0:r.toString())!==null&&i!==void 0?i:""}\` (${typeof t.intervalCap})`);if(t.interval===void 0||!(Number.isFinite(t.interval)&&t.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${(a=(n=t.interval)===null||n===void 0?void 0:n.toString())!==null&&a!==void 0?a:""}\` (${typeof t.interval})`);this._carryoverConcurrencyCount=t.carryoverConcurrencyCount,this._isIntervalIgnored=t.intervalCap===1/0||t.interval===0,this._intervalCap=t.intervalCap,this._interval=t.interval,this._queue=new t.queueClass,this._queueClass=t.queueClass,this.concurrency=t.concurrency,this._timeout=t.timeout,this._throwOnTimeout=t.throwOnTimeout===!0,this._isPaused=t.autoStart===!1}get _doesIntervalAllowAnother(){return this._isIntervalIgnored||this._intervalCount<this._intervalCap}get _doesConcurrentAllowAnother(){return this._pendingCount<this._concurrency}_next(){this._pendingCount--,this._tryToStartAnother(),this.emit("next")}_resolvePromises(){this._resolveEmpty(),this._resolveEmpty=Dd,this._pendingCount===0&&(this._resolveIdle(),this._resolveIdle=Dd,this.emit("idle"))}_onResumeInterval(){this._onInterval(),this._initializeIntervalIfNeeded(),this._timeoutId=void 0}_isIntervalPaused(){let t=Date.now();if(this._intervalId===void 0){let r=this._intervalEnd-t;if(r<0)this._intervalCount=this._carryoverConcurrencyCount?this._pendingCount:0;else return this._timeoutId===void 0&&(this._timeoutId=setTimeout(()=>{this._onResumeInterval()},r)),!0}return!1}_tryToStartAnother(){if(this._queue.size===0)return this._intervalId&&clearInterval(this._intervalId),this._intervalId=void 0,this._resolvePromises(),!1;if(!this._isPaused){let t=!this._isIntervalPaused();if(this._doesIntervalAllowAnother&&this._doesConcurrentAllowAnother){let r=this._queue.dequeue();return r?(this.emit("active"),r(),t&&this._initializeIntervalIfNeeded(),!0):!1}}return!1}_initializeIntervalIfNeeded(){this._isIntervalIgnored||this._intervalId!==void 0||(this._intervalId=setInterval(()=>{this._onInterval()},this._interval),this._intervalEnd=Date.now()+this._interval)}_onInterval(){this._intervalCount===0&&this._pendingCount===0&&this._intervalId&&(clearInterval(this._intervalId),this._intervalId=void 0),this._intervalCount=this._carryoverConcurrencyCount?this._pendingCount:0,this._processQueue()}_processQueue(){for(;this._tryToStartAnother(););}get concurrency(){return this._concurrency}set concurrency(t){if(!(typeof t=="number"&&t>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${t}\` (${typeof t})`);this._concurrency=t,this._processQueue()}async add(t,r={}){return new Promise((i,n)=>{let a=async()=>{this._pendingCount++,this._intervalCount++;try{let o=this._timeout===void 0&&r.timeout===void 0?t():ME.default(Promise.resolve(t()),r.timeout===void 0?this._timeout:r.timeout,()=>{(r.throwOnTimeout===void 0?this._throwOnTimeout:r.throwOnTimeout)&&n(X4)});i(await o)}catch(o){n(o)}this._next()};this._queue.enqueue(a,r),this._tryToStartAnother(),this.emit("add")})}async addAll(t,r){return Promise.all(t.map(async i=>this.add(i,r)))}start(){return this._isPaused?(this._isPaused=!1,this._processQueue(),this):this}pause(){this._isPaused=!0}clear(){this._queue=new this._queueClass}async onEmpty(){if(this._queue.size!==0)return new Promise(t=>{let r=this._resolveEmpty;this._resolveEmpty=()=>{r(),t()}})}async onIdle(){if(!(this._pendingCount===0&&this._queue.size===0))return new Promise(t=>{let r=this._resolveIdle;this._resolveIdle=()=>{r(),t()}})}get size(){return this._queue.size}sizeBy(t){return this._queue.filter(t).length}get pending(){return this._pendingCount}get isPaused(){return this._isPaused}get timeout(){return this._timeout}set timeout(t){this._timeout=t}};Lg.default=Ug});var TO=Ma(Lp=>{"use strict";Lp.byteLength=Y6;Lp.toByteArray=eF;Lp.fromByteArray=nF;var qn=[],Kr=[],X6=typeof Uint8Array<"u"?Uint8Array:Array,Rw="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Mo=0,EO=Rw.length;Mo<EO;++Mo)qn[Mo]=Rw[Mo],Kr[Rw.charCodeAt(Mo)]=Mo;var Mo,EO;Kr[45]=62;Kr[95]=63;function IO(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");r===-1&&(r=t);var i=r===t?0:4-r%4;return[r,i]}function Y6(e){var t=IO(e),r=t[0],i=t[1];return(r+i)*3/4-i}function Q6(e,t,r){return(t+r)*3/4-r}function eF(e){var t,r=IO(e),i=r[0],n=r[1],a=new X6(Q6(e,i,n)),o=0,s=n>0?i-4:i,c;for(c=0;c<s;c+=4)t=Kr[e.charCodeAt(c)]<<18|Kr[e.charCodeAt(c+1)]<<12|Kr[e.charCodeAt(c+2)]<<6|Kr[e.charCodeAt(c+3)],a[o++]=t>>16&255,a[o++]=t>>8&255,a[o++]=t&255;return n===2&&(t=Kr[e.charCodeAt(c)]<<2|Kr[e.charCodeAt(c+1)]>>4,a[o++]=t&255),n===1&&(t=Kr[e.charCodeAt(c)]<<10|Kr[e.charCodeAt(c+1)]<<4|Kr[e.charCodeAt(c+2)]>>2,a[o++]=t>>8&255,a[o++]=t&255),a}function tF(e){return qn[e>>18&63]+qn[e>>12&63]+qn[e>>6&63]+qn[e&63]}function rF(e,t,r){for(var i,n=[],a=t;a<r;a+=3)i=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(e[a+2]&255),n.push(tF(i));return n.join("")}function nF(e){for(var t,r=e.length,i=r%3,n=[],a=16383,o=0,s=r-i;o<s;o+=a)n.push(rF(e,o,o+a>s?s:o+a));return i===1?(t=e[r-1],n.push(qn[t>>2]+qn[t<<4&63]+"==")):i===2&&(t=(e[r-2]<<8)+e[r-1],n.push(qn[t>>10]+qn[t>>4&63]+qn[t<<2&63]+"=")),n.join("")}});function CS(e,t){if(e!=null){if(typeof e!="number"||Number.isNaN(e)||e<=0)throw new Error(`${t} must be greater than 0`);return e}}function Mi(e){if(e==null)return;let t=typeof e=="number"?{runTimeout:e}:e,r=t.refreshOn??"auto";if(r!=="auto"&&r!=="heartbeat")throw new Error('refreshOn must be "auto" or "heartbeat"');let i=CS(t.runTimeout,"runTimeout"),n=CS(t.idleTimeout,"idleTimeout");if(!(i===void 0&&n===void 0))return{runTimeout:i,idleTimeout:n,refreshOn:r}}var He="__start__",Je="__end__",An="__input__";var ji="__error__",Mc="__error_source_node__",Du="__pregel_ns_writes";function AS(){let e=typeof process<"u"?process.env?.LANGGRAPH_DELTA_MAX_SUPERSTEPS_SINCE_SNAPSHOT:void 0;if(e!==void 0&&e!==""){let t=Number.parseInt(e,10);if(Number.isFinite(t)&&t>0)return t}return 5e3}var Mt="__pregel_send",On="__pregel_call",jr="__pregel_read",zr="__pregel_checkpointer",za="__pregel_resuming",Wo="__pregel_task_id",jc="__pregel_stream",NM="__pregel_resume_value",Da="__pregel_resume_map",Kt="__pregel_scratchpad",zi="__pregel_previous",RM="__pregel_durability",Di="checkpoint_id",xr="checkpoint_ns",OS="__pregel_node_finished",zc="__pregel_node_error",jt="checkpoint_map",Uu="__pregel_replay_state",PS="__pregel_abort_signals",je="__interrupt__",qt="__resume__",Dc="__no_writes__",Ui="__return__",Li="__previous__",ut="langsmith:hidden";var Ah="__self__",Pn="__pregel_tasks",Xt="__pregel_push",Lu="__pregel_pull",Yt="00000000-0000-0000-0000-000000000000",NS=[ut,An,je,qt,ji,Mc,Dc,Mt,jr,zr,RM,jc,za,Wo,On,NM,Kt,zi,jt,xr,Di,Uu],Ch=Symbol.for("langgraph.command"),RS=class{[Ch];constructor(e){this[Ch]=e}};function Fu(e){let t=e;return t!=null&&typeof t.node=="string"&&t.args!==void 0}var ja=class{lg_name="Send";node;args;timeout;constructor(e,t,r){this.node=e,this.args=Rc(t),this.timeout=Mi(r?.timeout)}toJSON(){return{lg_name:this.lg_name,node:this.node,args:this.args,timeout:this.timeout}}};function ht(e){return e instanceof ja}var Cn="__overwrite__",MM=class{lg_name="Overwrite";[Cn];constructor(e){this[Cn]=e}get value(){return this[Cn]}toJSON(){return{[Cn]:this[Cn]}}static isInstance(e){return!e||typeof e!="object"?!1:"__overwrite__"in e||"lg_name"in e&&e.lg_name==="Overwrite"}};function tn(e){return typeof e=="object"&&e!==null&&"__overwrite__"in e?[!0,e[Cn]]:[!1,void 0]}function Bu(e){return tn(e)[0]}function Ua(e){return!e||typeof e!="object"||!("__interrupt__"in e)?!1:Array.isArray(e[je])}var dr=class extends RS{lg_name="Command";lc_direct_tool_output=!0;graph;update;resume;goto=[];static PARENT="__parent__";constructor(e){super(e),this.resume=e.resume,this.graph=e.graph,this.update=e.update,e.goto&&(this.goto=Array.isArray(e.goto)?Rc(e.goto):[Rc(e.goto)])}_updateAsTuples(){return this.update&&typeof this.update=="object"&&!Array.isArray(this.update)?Object.entries(this.update):Array.isArray(this.update)&&this.update.every(e=>Array.isArray(e)&&e.length===2&&typeof e[0]=="string")?this.update:[["__root__",this.update]]}toJSON(){let e;return typeof this.goto=="string"?e=this.goto:ht(this.goto)?e=this.goto.toJSON():e=this.goto?.map(t=>typeof t=="string"?t:t.toJSON()),{lg_name:this.lg_name,update:this.update,resume:this.resume,goto:e}}};function St(e){return typeof e!="object"||e==null?!1:"lg_name"in e&&e.lg_name==="Command"}function jM(e){let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function Rc(e,t=new Map){if(e!=null&&typeof e=="object"){if(t.has(e))return t.get(e);let r;if(Array.isArray(e))r=[],t.set(e,r),e.forEach((i,n)=>{r[n]=Rc(i,t)});else if(e instanceof dr||e instanceof ja||!jM(e))r=e,t.set(e,r);else if(St(e))r=new dr(e),t.set(e,r);else if(Fu(e))r=new ja(e.node,e.args,e.timeout!==void 0?{timeout:e.timeout}:void 0),t.set(e,r);else if("lc_serializable"in e&&e.lc_serializable)r=e,t.set(e,r);else{r={},t.set(e,r);for(let[i,n]of Object.entries(e))r[i]=Rc(n,t)}return r}return e}var Dr=class extends Error{lc_error_code;constructor(e,t){let r=e??"";t?.lc_error_code&&(r=`${r}
3
-
4
- Troubleshooting URL: https://docs.langchain.com/oss/javascript/langgraph/${t.lc_error_code}/
5
- `),super(r),this.lc_error_code=t?.lc_error_code}},Vu=class extends Dr{get is_bubble_up(){return!0}},Oh=class extends Dr{constructor(e,t){super(e,t),this.name="GraphRecursionError"}static get unminifiable_name(){return"GraphRecursionError"}},La=class extends Dr{constructor(e,t){super(e,t),this.name="GraphValueError"}static get unminifiable_name(){return"GraphValueError"}},Zu=class extends Vu{reason;constructor(e="shutdown",t){super(`Graph drained: ${e}`,t),this.name="GraphDrained",this.reason=e}static get unminifiable_name(){return"GraphDrained"}};function Hu(e){return e!==void 0&&e.name===Zu.unminifiable_name}var si=class extends Vu{interrupts;constructor(e,t){super(JSON.stringify(e,null,2),t),this.name="GraphInterrupt",this.interrupts=e??[]}static get unminifiable_name(){return"GraphInterrupt"}},Gu=class extends si{constructor(e,t){super([{value:e}],t),this.name="NodeInterrupt"}static get unminifiable_name(){return"NodeInterrupt"}},Wu=class{node;error;constructor(e,t){this.node=e,this.error=t}static get unminifiable_name(){return"NodeError"}};function zM(e){return e!=null&&typeof e=="object"&&e.constructor!=null&&e.constructor.unminifiable_name===Wu.unminifiable_name}var Ju=class extends Vu{command;constructor(e){super(),this.name="ParentCommand",this.command=e}static get unminifiable_name(){return"ParentCommand"}};function Ph(e){return e!==void 0&&e.name===Ju.unminifiable_name}function Fi(e){return e!==void 0&&e.is_bubble_up===!0}function ci(e){return e!==void 0&&[si.unminifiable_name,Gu.unminifiable_name].includes(e.name)}var Ku=class extends Dr{node;kind;timeout;elapsed;runTimeout;idleTimeout;constructor(e,t){let{node:r,elapsed:i,kind:n,runTimeout:a,idleTimeout:o}=e,s,c;if(n==="idle"){if(o===void 0)throw new Error("idleTimeout is required when kind='idle'");c=o,s=`Node "${r}" exceeded its idle timeout of ${o}ms without making progress (elapsed: ${i}ms).`}else{if(a===void 0)throw new Error("runTimeout is required when kind='run'");c=a,s=`Node "${r}" exceeded its run timeout of ${a}ms (elapsed: ${i}ms).`}super(s,t),this.name="NodeTimeoutError",this.node=r,this.kind=n,this.timeout=c,this.elapsed=i,this.runTimeout=a,this.idleTimeout=o}static get unminifiable_name(){return"NodeTimeoutError"}};function DM(e){return e!==void 0&&e.name===Ku.unminifiable_name}var qu=class extends Dr{constructor(e,t){super(e,t),this.name="EmptyInputError"}static get unminifiable_name(){return"EmptyInputError"}},Pe=class extends Dr{constructor(e,t){let r=Error.stackTraceLimit;Error.stackTraceLimit=0,super(e,t),Error.stackTraceLimit=r,this.name="EmptyChannelError"}static get unminifiable_name(){return"EmptyChannelError"}},_e=class extends Dr{constructor(e,t){super(e,t),this.name="InvalidUpdateError"}static get unminifiable_name(){return"InvalidUpdateError"}},UM=class extends Dr{constructor(e,t){super(e,t),this.name="MultipleSubgraphError"}static get unminifiable_name(){return"MultipleSubgraphError"}},Nh=class extends Dr{constructor(e,t){super(e,t),this.name="UnreachableNodeError"}static get unminifiable_name(){return"UnreachableNodeError"}},LM=class extends Dr{constructor(e,t){super(e,t),this.name="RemoteException"}static get unminifiable_name(){return"RemoteException"}},Uc=class extends Dr{constructor(e,t){super(e,t),this.name="StateGraphInputError",this.message="Invalid StateGraph input. Make sure to pass a valid StateDefinition, Annotation.Root, or Zod schema."}static get unminifiable_name(){return"StateGraphInputError"}},FM=()=>(globalThis[Symbol.for("LG_CHECKPOINT_SEEN_NS_SET")]===void 0&&(globalThis[Symbol.for("LG_CHECKPOINT_SEEN_NS_SET")]=new Set),globalThis[Symbol.for("LG_CHECKPOINT_SEEN_NS_SET")]);var MS=Object.defineProperty,T=(e,t)=>{let r={};for(var i in e)MS(r,i,{get:e[i],enumerable:!0});return t||MS(r,Symbol.toStringTag,{value:"Module"}),r};var jS="ffffffff-ffff-ffff-ffff-ffffffffffff";var zS="00000000-0000-0000-0000-000000000000";var DS=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;function Bi(e){return typeof e=="string"&&DS.test(e)}function Fa(e){if(!Bi(e))throw TypeError("Invalid UUID");let t;return Uint8Array.of((t=parseInt(e.slice(0,8),16))>>>24,t>>>16&255,t>>>8&255,t&255,(t=parseInt(e.slice(9,13),16))>>>8,t&255,(t=parseInt(e.slice(14,18),16))>>>8,t&255,(t=parseInt(e.slice(19,23),16))>>>8,t&255,(t=parseInt(e.slice(24,36),16))/1099511627776&255,t/4294967296&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255)}var Ct=[];for(let e=0;e<256;++e)Ct.push((e+256).toString(16).slice(1));function Sr(e,t=0){return(Ct[e[t+0]]+Ct[e[t+1]]+Ct[e[t+2]]+Ct[e[t+3]]+"-"+Ct[e[t+4]]+Ct[e[t+5]]+"-"+Ct[e[t+6]]+Ct[e[t+7]]+"-"+Ct[e[t+8]]+Ct[e[t+9]]+"-"+Ct[e[t+10]]+Ct[e[t+11]]+Ct[e[t+12]]+Ct[e[t+13]]+Ct[e[t+14]]+Ct[e[t+15]]).toLowerCase()}function US(e,t=0){let r=Sr(e,t);if(!Bi(r))throw TypeError("Stringified UUID is invalid");return r}var BM=new Uint8Array(16);function Vi(){return crypto.getRandomValues(BM)}var Lc={};function Xu(e,t,r){let i,n=e?._v6??!1;if(e){let a=Object.keys(e);a.length===1&&a[0]==="_v6"&&(e=void 0)}if(e)i=LS(e.random??e.rng?.()??Vi(),e.msecs,e.nsecs,e.clockseq,e.node,t,r);else{let a=Date.now(),o=Vi();VM(Lc,a,o),i=LS(o,Lc.msecs,Lc.nsecs,n?void 0:Lc.clockseq,n?void 0:Lc.node,t,r)}return t??Sr(i)}function VM(e,t,r){return e.msecs??=-1/0,e.nsecs??=0,t===e.msecs?(e.nsecs++,e.nsecs>=1e4&&(e.node=void 0,e.nsecs=0)):t>e.msecs?e.nsecs=0:t<e.msecs&&(e.node=void 0),e.node||(e.node=r.slice(10,16),e.node[0]|=1,e.clockseq=(r[8]<<8|r[9])&16383),e.msecs=t,e}function LS(e,t,r,i,n,a,o=0){if(e.length<16)throw new Error("Random bytes length must be >= 16");if(!a)a=new Uint8Array(16),o=0;else if(o<0||o+16>a.length)throw new RangeError(`UUID byte range ${o}:${o+15} is out of buffer bounds`);t??=Date.now(),r??=0,i??=(e[8]<<8|e[9])&16383,n??=e.slice(10,16),t+=122192928e5;let s=((t&268435455)*1e4+r)%4294967296;a[o++]=s>>>24&255,a[o++]=s>>>16&255,a[o++]=s>>>8&255,a[o++]=s&255;let c=t/4294967296*1e4&268435455;a[o++]=c>>>8&255,a[o++]=c&255,a[o++]=c>>>24&15|16,a[o++]=c>>>16&255,a[o++]=i>>>8|128,a[o++]=i&255;for(let l=0;l<6;++l)a[o++]=n[l];return a}function FS(e,t,r){return!t&&!e&&crypto.randomUUID?crypto.randomUUID():ZM(e,t,r)}function ZM(e,t,r){e=e||{};let i=e.random??e.rng?.()??Vi();if(i.length<16)throw new Error("Random bytes length must be >= 16");if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){if(r=r||0,r<0||r+16>t.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let n=0;n<16;++n)t[r+n]=i[n];return t}return Sr(i)}function HM(e,t,r,i){switch(e){case 0:return t&r^~t&i;case 1:return t^r^i;case 2:return t&r^t&i^r&i;case 3:return t^r^i}}function Rh(e,t){return e<<t|e>>>32-t}function BS(e){let t=[1518500249,1859775393,2400959708,3395469782],r=[1732584193,4023233417,2562383102,271733878,3285377520],i=new Uint8Array(e.length+1);i.set(e),i[e.length]=128,e=i;let n=e.length/4+2,a=Math.ceil(n/16),o=new Array(a);for(let s=0;s<a;++s){let c=new Uint32Array(16);for(let l=0;l<16;++l)c[l]=e[s*64+l*4]<<24|e[s*64+l*4+1]<<16|e[s*64+l*4+2]<<8|e[s*64+l*4+3];o[s]=c}o[a-1][14]=(e.length-1)*8/2**32,o[a-1][14]=Math.floor(o[a-1][14]),o[a-1][15]=(e.length-1)*8&4294967295;for(let s=0;s<a;++s){let c=new Uint32Array(80);for(let m=0;m<16;++m)c[m]=o[s][m];for(let m=16;m<80;++m)c[m]=Rh(c[m-3]^c[m-8]^c[m-14]^c[m-16],1);let l=r[0],u=r[1],d=r[2],f=r[3],p=r[4];for(let m=0;m<80;++m){let h=Math.floor(m/20),_=Rh(l,5)+HM(h,u,d,f)+p+t[h]+c[m]>>>0;p=f,f=d,d=Rh(u,30)>>>0,u=l,l=_}r[0]=r[0]+l>>>0,r[1]=r[1]+u>>>0,r[2]=r[2]+d>>>0,r[3]=r[3]+f>>>0,r[4]=r[4]+p>>>0}return Uint8Array.of(r[0]>>24,r[0]>>16,r[0]>>8,r[0],r[1]>>24,r[1]>>16,r[1]>>8,r[1],r[2]>>24,r[2]>>16,r[2]>>8,r[2],r[3]>>24,r[3]>>16,r[3]>>8,r[3],r[4]>>24,r[4]>>16,r[4]>>8,r[4])}function GM(e){e=unescape(encodeURIComponent(e));let t=new Uint8Array(e.length);for(let r=0;r<e.length;++r)t[r]=e.charCodeAt(r);return t}var VS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",ZS="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function HS(e,t,r,i,n,a){let o=typeof r=="string"?GM(r):r,s=typeof i=="string"?Fa(i):i;if(typeof i=="string"&&(i=Fa(i)),i?.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let c=new Uint8Array(16+o.length);if(c.set(s),c.set(o,s.length),c=t(c),c[6]=c[6]&15|e,c[8]=c[8]&63|128,n){if(a??=0,a<0||a+16>n.length)throw new RangeError(`UUID byte range ${a}:${a+15} is out of buffer bounds`);for(let l=0;l<16;++l)n[a+l]=c[l];return n}return Sr(c)}function Yu(e,t,r,i){return HS(80,BS,e,t,r,i)}Yu.DNS=VS;Yu.URL=ZS;function GS(e){let t=WM(typeof e=="string"?Fa(e):e);return typeof e=="string"?Sr(t):t}function WM(e){return Uint8Array.of((e[6]&15)<<4|e[7]>>4&15,(e[7]&15)<<4|(e[4]&240)>>4,(e[4]&15)<<4|(e[5]&240)>>4,(e[5]&15)<<4|(e[0]&240)>>4,(e[0]&15)<<4|(e[1]&240)>>4,(e[1]&15)<<4|(e[2]&240)>>4,96|e[2]&15,e[3],e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[15])}function WS(e,t,r){e??={},r??=0;let i=Xu({...e,_v6:!0},new Uint8Array(16));if(i=GS(i),t){if(r<0||r+16>t.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let n=0;n<16;n++)t[r+n]=i[n];return t}return Sr(i)}var Mh={};function KS(e,t,r){let i;if(e)i=JS(e.random??e.rng?.()??Vi(),e.msecs,e.seq,t,r);else{let n=Date.now(),a=Vi();JM(Mh,n,a),i=JS(a,Mh.msecs,Mh.seq,t,r)}return t??Sr(i)}function JM(e,t,r){return e.msecs??=-1/0,e.seq??=0,t>e.msecs?(e.seq=r[6]<<23|r[7]<<16|r[8]<<8|r[9],e.msecs=t):(e.seq=e.seq+1|0,e.seq===0&&e.msecs++),e}function JS(e,t,r,i,n=0){if(e.length<16)throw new Error("Random bytes length must be >= 16");if(!i)i=new Uint8Array(16),n=0;else if(n<0||n+16>i.length)throw new RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);return t??=Date.now(),r??=e[6]*127<<24|e[7]<<16|e[8]<<8|e[9],i[n++]=t/1099511627776&255,i[n++]=t/4294967296&255,i[n++]=t/16777216&255,i[n++]=t/65536&255,i[n++]=t/256&255,i[n++]=t&255,i[n++]=112|r>>>28&15,i[n++]=r>>>20&255,i[n++]=128|r>>>14&63,i[n++]=r>>>6&255,i[n++]=r<<2&255|e[10]&3,i[n++]=e[11],i[n++]=e[12],i[n++]=e[13],i[n++]=e[14],i[n++]=e[15],i}function qS(e){if(!Bi(e))throw TypeError("Invalid UUID");return parseInt(e.slice(14,15),16)}var XS=T({MAX:()=>KM,NIL:()=>qM,parse:()=>XM,stringify:()=>YM,v1:()=>QM,v4:()=>Zi,v5:()=>Jo,v6:()=>jh,v7:()=>Ur,validate:()=>li,version:()=>ej}),KM=jS,qM=zS,XM=Fa,YM=US,QM=Xu,Zi=FS,Jo=Yu,jh=WS,Ur=KS,li=Bi,ej=qS;var zh=0,Fc=0;function Bc(e){let t=Date.now();return t<=zh?(Fc+=1,Fc>=1e4&&(Fc=0,t=zh+1)):Fc=0,zh=t,jh({clockseq:e,msecs:t,nsecs:Fc})}function Nn(e,t){let r=t.replace(/-/g,"").match(/.{2}/g).map(i=>parseInt(i,16));return Jo(e,new Uint8Array(r))}var Vc="__pregel_tasks",Dh="__error__",Ba="__scheduled__",Uh="__interrupt__",Lh="__resume__",Ko=class{lg_name="DeltaSnapshot";value;constructor(e){this.value=e}};function Fh(e){return e!=null&&typeof e=="object"&&e.lg_name==="DeltaSnapshot"}var YS="[...]",tj="[Circular]",Qu=[],qo=[];function rj(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function QS(e,t,r,i){typeof i>"u"&&(i=rj()),Vh(e,"",0,[],void 0,0,i);var n;try{qo.length===0?n=JSON.stringify(e,t,r):n=JSON.stringify(e,nj(t),r)}catch{return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;Qu.length!==0;){var a=Qu.pop();a.length===4?Object.defineProperty(a[0],a[1],a[3]):a[0][a[1]]=a[2]}}return n}function Bh(e,t,r,i){var n=Object.getOwnPropertyDescriptor(i,r);n.get!==void 0?n.configurable?(Object.defineProperty(i,r,{value:e}),Qu.push([i,r,t,n])):qo.push([t,r,e]):(i[r]=e,Qu.push([i,r,t]))}function Vh(e,t,r,i,n,a,o){a+=1;var s;if(typeof e=="object"&&e!==null){for(s=0;s<i.length;s++)if(i[s]===e){Bh(tj,e,t,n);return}if(typeof o.depthLimit<"u"&&a>o.depthLimit){Bh(YS,e,t,n);return}if(typeof o.edgesLimit<"u"&&r+1>o.edgesLimit){Bh(YS,e,t,n);return}if(i.push(e),Array.isArray(e))for(s=0;s<e.length;s++)Vh(e[s],s,s,i,e,a,o);else{var c=Object.keys(e);for(s=0;s<c.length;s++){var l=c[s];Vh(e[l],l,s,i,e,a,o)}}i.pop()}}function nj(e){return e=typeof e<"u"?e:function(t,r){return r},function(t,r){if(qo.length>0)for(var i=0;i<qo.length;i++){var n=qo[i];if(n[1]===t&&n[0]===r){r=n[2],qo.splice(i,1);break}}return e.call(this,t,r)}}var ij=/([A-Z]+)([A-Z][a-z0-9]+)/g,aj=/([a-z0-9])([A-Z])/g,ek=/[-_\s]+/g;function oj(e){return e.replace(ij,"$1_$2").replace(aj,"$1_$2").replace(ek,"_").toLowerCase()}function sj(e){let t=e.trim();return/[-_\s]/.test(t)?t.replace(ek,"_").toLowerCase().replace(/_+([a-z0-9])/g,(r,i)=>i.toUpperCase()):t}function tk(e,t){return t?.[e]||oj(e)}function rk(e,t){return t?.[e]||sj(e)}function ed(e,t,r){let i={};for(let n in e)Object.hasOwn(e,n)&&(i[t(n,r)]=e[n]);return i}var nk="__lc_escaped__";function cj(e){return"lc"in e||Object.keys(e).length===1&&"__lc_escaped__"in e}function lj(e){return{[nk]:e}}function Zh(e){return Object.keys(e).length===1&&"__lc_escaped__"in e}function uj(e){return e!==null&&typeof e=="object"&&"lc_serializable"in e&&typeof e.toJSON=="function"}function dj(e){let t;return e!==null&&typeof e=="object"?"lc_id"in e&&Array.isArray(e.lc_id)?t=e.lc_id:t=[e.constructor?.name??"Object"]:t=[typeof e],{lc:1,type:"not_implemented",id:t}}function td(e,t=new WeakSet){if(e!==null&&typeof e=="object"&&!Array.isArray(e)){if(t.has(e))return dj(e);if(uj(e))return e;t.add(e);let r=e;if(cj(r))return t.delete(e),lj(r);let i={};for(let[n,a]of Object.entries(r))i[n]=td(a,t);return t.delete(e),i}return Array.isArray(e)?e.map(r=>td(r,t)):e}function rd(e){if(e!==null&&typeof e=="object"&&!Array.isArray(e)){let t=e;if(Zh(t))return t[nk];let r={};for(let[i,n]of Object.entries(t))r[i]=rd(n);return r}return Array.isArray(e)?e.map(t=>rd(t)):e}var ak=T({Serializable:()=>lt,get_lc_unique_name:()=>Xo});function ik(e){return Array.isArray(e)?[...e]:{...e}}function fj(e,t){let r=ik(e);for(let[i,n]of Object.entries(t)){let[a,...o]=i.split(".").reverse(),s=r;for(let c of o.reverse()){if(s[c]===void 0)break;s[c]=ik(s[c]),s=s[c]}s[a]!==void 0&&(s[a]={lc:1,type:"secret",id:[n]})}return r}function Xo(e){let t=Object.getPrototypeOf(e);return typeof e.lc_name=="function"&&(typeof t.lc_name!="function"||e.lc_name()!==t.lc_name())?e.lc_name():e.name}var lt=class ok{lc_serializable=!1;lc_kwargs;static lc_name(){return this.name}get lc_id(){return[...this.lc_namespace,Xo(this.constructor)]}get lc_secrets(){}get lc_attributes(){}get lc_aliases(){}get lc_serializable_keys(){}constructor(t,...r){this.lc_serializable_keys!==void 0?this.lc_kwargs=Object.fromEntries(Object.entries(t||{}).filter(([i])=>this.lc_serializable_keys?.includes(i))):this.lc_kwargs=t??{}}toJSON(){if(!this.lc_serializable)return this.toJSONNotImplemented();if(this.lc_kwargs instanceof ok||typeof this.lc_kwargs!="object"||Array.isArray(this.lc_kwargs))return this.toJSONNotImplemented();let t={},r={},i=Object.keys(this.lc_kwargs).reduce((s,c)=>(s[c]=c in this?this[c]:this.lc_kwargs[c],s),{});for(let s=Object.getPrototypeOf(this);s;s=Object.getPrototypeOf(s))Object.assign(t,Reflect.get(s,"lc_aliases",this)),Object.assign(r,Reflect.get(s,"lc_secrets",this)),Object.assign(i,Reflect.get(s,"lc_attributes",this));Object.keys(r).forEach(s=>{let c=this,l=i,[u,...d]=s.split(".").reverse();for(let f of d.reverse()){if(!(f in c)||c[f]===void 0)return;(!(f in l)||l[f]===void 0)&&(typeof c[f]=="object"&&c[f]!=null?l[f]={}:Array.isArray(c[f])&&(l[f]=[])),c=c[f],l=l[f]}u in c&&c[u]!==void 0&&(l[u]=l[u]||c[u])});let n={},a=new WeakSet;a.add(this);for(let[s,c]of Object.entries(i))n[s]=td(c,a);let o=ed(Object.keys(r).length?fj(n,r):n,tk,t);return{lc:1,type:"constructor",id:this.lc_id,kwargs:o}}toJSONNotImplemented(){return{lc:1,type:"not_implemented",id:this.lc_id}}};var sk=T({getEnv:()=>fk,getEnvironmentVariable:()=>Qt,getRuntimeEnvironment:()=>Gh,isBrowser:()=>ck,isDeno:()=>nd,isJsDom:()=>uk,isNode:()=>dk,isWebWorker:()=>lk}),ck=()=>typeof window<"u"&&typeof window.document<"u",lk=()=>typeof globalThis=="object"&&globalThis.constructor&&globalThis.constructor.name==="DedicatedWorkerGlobalScope",uk=()=>typeof window<"u"&&window.name==="nodejs"||typeof navigator<"u"&&navigator.userAgent.includes("jsdom"),nd=()=>typeof Deno<"u",dk=()=>typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"&&!nd(),fk=()=>{let e;return ck()?e="browser":dk()?e="node":lk()?e="webworker":uk()?e="jsdom":nd()?e="deno":e="other",e},Hh;function Gh(){return Hh===void 0&&(Hh={library:"langchain-js",runtime:fk()}),Hh}function Qt(e){try{return typeof process<"u"?process.env?.[e]:nd()?Deno?.env.get(e):void 0}catch{return}}var pk=[];var mk=T({});var hk=T({});var te="0123456789abcdef".split(""),pj=[-2147483648,8388608,32768,128],rn=[24,16,8,0],id=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],kt=[];function nn(e,t){t?(kt[0]=kt[16]=kt[1]=kt[2]=kt[3]=kt[4]=kt[5]=kt[6]=kt[7]=kt[8]=kt[9]=kt[10]=kt[11]=kt[12]=kt[13]=kt[14]=kt[15]=0,this.blocks=kt):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],e?(this.h0=3238371032,this.h1=914150663,this.h2=812702999,this.h3=4144912697,this.h4=4290775857,this.h5=1750603025,this.h6=1694076839,this.h7=3204075428):(this.h0=1779033703,this.h1=3144134277,this.h2=1013904242,this.h3=2773480762,this.h4=1359893119,this.h5=2600822924,this.h6=528734635,this.h7=1541459225),this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0,this.is224=e}nn.prototype.update=function(e){if(!this.finalized){var t,r=typeof e;if(r!=="string"){if(r==="object"){if(e===null)throw new Error(ERROR);if(ARRAY_BUFFER&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!Array.isArray(e)&&(!ARRAY_BUFFER||!ArrayBuffer.isView(e)))throw new Error(ERROR)}else throw new Error(ERROR);t=!0}for(var i,n=0,a,o=e.length,s=this.blocks;n<o;){if(this.hashed&&(this.hashed=!1,s[0]=this.block,this.block=s[16]=s[1]=s[2]=s[3]=s[4]=s[5]=s[6]=s[7]=s[8]=s[9]=s[10]=s[11]=s[12]=s[13]=s[14]=s[15]=0),t)for(a=this.start;n<o&&a<64;++n)s[a>>>2]|=e[n]<<rn[a++&3];else for(a=this.start;n<o&&a<64;++n)i=e.charCodeAt(n),i<128?s[a>>>2]|=i<<rn[a++&3]:i<2048?(s[a>>>2]|=(192|i>>>6)<<rn[a++&3],s[a>>>2]|=(128|i&63)<<rn[a++&3]):i<55296||i>=57344?(s[a>>>2]|=(224|i>>>12)<<rn[a++&3],s[a>>>2]|=(128|i>>>6&63)<<rn[a++&3],s[a>>>2]|=(128|i&63)<<rn[a++&3]):(i=65536+((i&1023)<<10|e.charCodeAt(++n)&1023),s[a>>>2]|=(240|i>>>18)<<rn[a++&3],s[a>>>2]|=(128|i>>>12&63)<<rn[a++&3],s[a>>>2]|=(128|i>>>6&63)<<rn[a++&3],s[a>>>2]|=(128|i&63)<<rn[a++&3]);this.lastByteIndex=a,this.bytes+=a-this.start,a>=64?(this.block=s[16],this.start=a-64,this.hash(),this.hashed=!0):this.start=a}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}};nn.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var e=this.blocks,t=this.lastByteIndex;e[16]=this.block,e[t>>>2]|=pj[t&3],this.block=e[16],t>=56&&(this.hashed||this.hash(),e[0]=this.block,e[16]=e[1]=e[2]=e[3]=e[4]=e[5]=e[6]=e[7]=e[8]=e[9]=e[10]=e[11]=e[12]=e[13]=e[14]=e[15]=0),e[14]=this.hBytes<<3|this.bytes>>>29,e[15]=this.bytes<<3,this.hash()}};nn.prototype.hash=function(){var e=this.h0,t=this.h1,r=this.h2,i=this.h3,n=this.h4,a=this.h5,o=this.h6,s=this.h7,c=this.blocks,l,u,d,f,p,m,h,_,b,w,S;for(l=16;l<64;++l)p=c[l-15],u=(p>>>7|p<<25)^(p>>>18|p<<14)^p>>>3,p=c[l-2],d=(p>>>17|p<<15)^(p>>>19|p<<13)^p>>>10,c[l]=c[l-16]+u+c[l-7]+d<<0;for(S=t&r,l=0;l<64;l+=4)this.first?(this.is224?(_=300032,p=c[0]-1413257819,s=p-150054599<<0,i=p+24177077<<0):(_=704751109,p=c[0]-210244248,s=p-1521486534<<0,i=p+143694565<<0),this.first=!1):(u=(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10),d=(n>>>6|n<<26)^(n>>>11|n<<21)^(n>>>25|n<<7),_=e&t,f=_^e&r^S,h=n&a^~n&o,p=s+d+h+id[l]+c[l],m=u+f,s=i+p<<0,i=p+m<<0),u=(i>>>2|i<<30)^(i>>>13|i<<19)^(i>>>22|i<<10),d=(s>>>6|s<<26)^(s>>>11|s<<21)^(s>>>25|s<<7),b=i&e,f=b^i&t^_,h=o&s^~o&n,p=a+d+h+id[l+1]+c[l+1],m=u+f,o=r+p<<0,r=p+m<<0,u=(r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10),d=(o>>>6|o<<26)^(o>>>11|o<<21)^(o>>>25|o<<7),w=r&i,f=w^r&e^b,h=a&o^~a&s,p=n+d+h+id[l+2]+c[l+2],m=u+f,a=t+p<<0,t=p+m<<0,u=(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10),d=(a>>>6|a<<26)^(a>>>11|a<<21)^(a>>>25|a<<7),S=t&r,f=S^t&i^w,h=a&o^~a&s,p=n+d+h+id[l+3]+c[l+3],m=u+f,n=e+p<<0,e=p+m<<0,this.chromeBugWorkAround=!0;this.h0=this.h0+e<<0,this.h1=this.h1+t<<0,this.h2=this.h2+r<<0,this.h3=this.h3+i<<0,this.h4=this.h4+n<<0,this.h5=this.h5+a<<0,this.h6=this.h6+o<<0,this.h7=this.h7+s<<0};nn.prototype.hex=function(){this.finalize();var e=this.h0,t=this.h1,r=this.h2,i=this.h3,n=this.h4,a=this.h5,o=this.h6,s=this.h7,c=te[e>>>28&15]+te[e>>>24&15]+te[e>>>20&15]+te[e>>>16&15]+te[e>>>12&15]+te[e>>>8&15]+te[e>>>4&15]+te[e&15]+te[t>>>28&15]+te[t>>>24&15]+te[t>>>20&15]+te[t>>>16&15]+te[t>>>12&15]+te[t>>>8&15]+te[t>>>4&15]+te[t&15]+te[r>>>28&15]+te[r>>>24&15]+te[r>>>20&15]+te[r>>>16&15]+te[r>>>12&15]+te[r>>>8&15]+te[r>>>4&15]+te[r&15]+te[i>>>28&15]+te[i>>>24&15]+te[i>>>20&15]+te[i>>>16&15]+te[i>>>12&15]+te[i>>>8&15]+te[i>>>4&15]+te[i&15]+te[n>>>28&15]+te[n>>>24&15]+te[n>>>20&15]+te[n>>>16&15]+te[n>>>12&15]+te[n>>>8&15]+te[n>>>4&15]+te[n&15]+te[a>>>28&15]+te[a>>>24&15]+te[a>>>20&15]+te[a>>>16&15]+te[a>>>12&15]+te[a>>>8&15]+te[a>>>4&15]+te[a&15]+te[o>>>28&15]+te[o>>>24&15]+te[o>>>20&15]+te[o>>>16&15]+te[o>>>12&15]+te[o>>>8&15]+te[o>>>4&15]+te[o&15];return this.is224||(c+=te[s>>>28&15]+te[s>>>24&15]+te[s>>>20&15]+te[s>>>16&15]+te[s>>>12&15]+te[s>>>8&15]+te[s>>>4&15]+te[s&15]),c};nn.prototype.toString=nn.prototype.hex;nn.prototype.digest=function(){this.finalize();var e=this.h0,t=this.h1,r=this.h2,i=this.h3,n=this.h4,a=this.h5,o=this.h6,s=this.h7,c=[e>>>24&255,e>>>16&255,e>>>8&255,e&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255,r>>>24&255,r>>>16&255,r>>>8&255,r&255,i>>>24&255,i>>>16&255,i>>>8&255,i&255,n>>>24&255,n>>>16&255,n>>>8&255,n&255,a>>>24&255,a>>>16&255,a>>>8&255,a&255,o>>>24&255,o>>>16&255,o>>>8&255,o&255];return this.is224||c.push(s>>>24&255,s>>>16&255,s>>>8&255,s&255),c};nn.prototype.array=nn.prototype.digest;nn.prototype.arrayBuffer=function(){this.finalize();var e=new ArrayBuffer(this.is224?28:32),t=new DataView(e);return t.setUint32(0,this.h0),t.setUint32(4,this.h1),t.setUint32(8,this.h2),t.setUint32(12,this.h3),t.setUint32(16,this.h4),t.setUint32(20,this.h5),t.setUint32(24,this.h6),this.is224||t.setUint32(28,this.h7),e};var Yo=(...e)=>new nn(!1,!0).update(e.join("")).hex();var gk=T({sha256:()=>Yo});function _k(e){let t=Symbol.for(e);return{brand(r,i){let n=i?Symbol.for(`${e}.${i}`):t;class a extends r{[n]=!0;constructor(...s){super(...s)}static isInstance(s){return typeof s=="object"&&s!==null&&n in s&&s[n]===!0}}return Object.defineProperty(a,"name",{value:r.name}),a},sub(r){return _k(`${e}.${r}`)},isInstance(r){return typeof r=="object"&&r!==null&&t in r&&r[t]===!0}}}var yk=_k("langchain");var vk=T({ContextOverflowError:()=>mj,LangChainError:()=>Wh,ModelAbortError:()=>od,addLangChainErrorFields:()=>ui,ns:()=>ad});function ui(e,t){return e.lc_error_code=t,e.message=`${e.message}
6
-
7
- Troubleshooting URL: https://docs.langchain.com/oss/javascript/langchain/errors/${t}/
8
- `,e}var ad=yk.sub("error"),Wh=class extends ad.brand(Error){name="LangChainError";constructor(e){super(e),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}},od=class extends ad.brand(Wh,"model-abort"){name="ModelAbortError";partialOutput;constructor(e,t){super(e),this.partialOutput=t}},mj=class bk extends ad.brand(Wh,"context-overflow"){name="ContextOverflowError";cause;constructor(t){super(t??"Input exceeded the model's context window.")}static fromError(t){let r=new bk(t.message);return r.cause=t,r}};function Rn(e){return typeof e=="object"&&e!==null&&"type"in e&&typeof e.type=="string"&&"source_type"in e&&(e.source_type==="url"||e.source_type==="base64"||e.source_type==="text"||e.source_type==="id")}function Qo(e){return Rn(e)&&e.source_type==="url"&&"url"in e&&typeof e.url=="string"}function es(e){return Rn(e)&&e.source_type==="base64"&&"data"in e&&typeof e.data=="string"}function wk(e){return Rn(e)&&e.source_type==="text"&&"text"in e&&typeof e.text=="string"}function sd(e){return Rn(e)&&e.source_type==="id"&&"id"in e&&typeof e.id=="string"}function cd(e){if(Rn(e)){if(e.source_type==="url")return{type:"image_url",image_url:{url:e.url}};if(e.source_type==="base64"){if(!e.mime_type)throw new Error("mime_type key is required for base64 data.");return{type:"image_url",image_url:{url:`data:${e.mime_type};base64,${e.data}`}}}}throw new Error("Unsupported source type. Only 'url' and 'base64' are supported.")}function xk(e){let t=e.split(";")[0].split("/");if(t.length!==2)throw new Error(`Invalid mime type: "${e}" - does not match type/subtype format.`);let r=t[0].trim(),i=t[1].trim();if(r===""||i==="")throw new Error(`Invalid mime type: "${e}" - type or subtype is empty.`);let n={};for(let a of e.split(";").slice(1)){let o=a.split("=");if(o.length!==2)throw new Error(`Invalid parameter syntax in mime type: "${e}".`);let s=o[0].trim(),c=o[1].trim();if(s==="")throw new Error(`Invalid parameter syntax in mime type: "${e}".`);n[s]=c}return{type:r,subtype:i,parameters:n}}function Zc({dataUrl:e,asTypedArray:t=!1}){let r=e.match(/^data:(\w+\/\w+);base64,([A-Za-z0-9+/]+=*)$/),i;if(r){i=r[1].toLowerCase();let n=t?Uint8Array.from(atob(r[2]),a=>a.charCodeAt(0)):r[2];return{mime_type:i,data:n}}}function Sk(e,t){if(e.type==="text"){if(!t.fromStandardTextBlock)throw new Error(`Converter for ${t.providerName} does not implement \`fromStandardTextBlock\` method.`);return t.fromStandardTextBlock(e)}if(e.type==="image"){if(!t.fromStandardImageBlock)throw new Error(`Converter for ${t.providerName} does not implement \`fromStandardImageBlock\` method.`);return t.fromStandardImageBlock(e)}if(e.type==="audio"){if(!t.fromStandardAudioBlock)throw new Error(`Converter for ${t.providerName} does not implement \`fromStandardAudioBlock\` method.`);return t.fromStandardAudioBlock(e)}if(e.type==="file"){if(!t.fromStandardFileBlock)throw new Error(`Converter for ${t.providerName} does not implement \`fromStandardFileBlock\` method.`);return t.fromStandardFileBlock(e)}throw new Error(`Unable to convert content block type '${e.type}' to provider-specific format: not recognized.`)}function K(e,t){return re(e)&&e.type===t}function re(e){return typeof e=="object"&&e!==null}function gt(e){return Array.isArray(e)}function O(e){return typeof e=="string"}function kr(e){return typeof e=="number"}function ld(e){return e instanceof Uint8Array}function Jh(e){try{return JSON.parse(e)}catch{return}}var $r=e=>e();function hj(e){if(e.type==="char_location"&&O(e.document_title)&&kr(e.start_char_index)&&kr(e.end_char_index)&&O(e.cited_text)){let{document_title:t,start_char_index:r,end_char_index:i,cited_text:n,...a}=e;return{...a,type:"citation",source:"char",title:t??void 0,startIndex:r,endIndex:i,citedText:n}}if(e.type==="page_location"&&O(e.document_title)&&kr(e.start_page_number)&&kr(e.end_page_number)&&O(e.cited_text)){let{document_title:t,start_page_number:r,end_page_number:i,cited_text:n,...a}=e;return{...a,type:"citation",source:"page",title:t??void 0,startIndex:r,endIndex:i,citedText:n}}if(e.type==="content_block_location"&&O(e.document_title)&&kr(e.start_block_index)&&kr(e.end_block_index)&&O(e.cited_text)){let{document_title:t,start_block_index:r,end_block_index:i,cited_text:n,...a}=e;return{...a,type:"citation",source:"block",title:t??void 0,startIndex:r,endIndex:i,citedText:n}}if(e.type==="web_search_result_location"&&O(e.url)&&O(e.title)&&O(e.encrypted_index)&&O(e.cited_text)){let{url:t,title:r,encrypted_index:i,cited_text:n,...a}=e;return{...a,type:"citation",source:"url",url:t,title:r,startIndex:Number(i),endIndex:Number(i),citedText:n}}if(e.type==="search_result_location"&&O(e.source)&&O(e.title)&&kr(e.start_block_index)&&kr(e.end_block_index)&&O(e.cited_text)){let{source:t,title:r,start_block_index:i,end_block_index:n,cited_text:a,...o}=e;return{...o,type:"citation",source:"search",url:t,title:r??void 0,startIndex:i,endIndex:n,citedText:a}}}function $k(e){if(K(e,"document")&&re(e.source)&&"type"in e.source){if(e.source.type==="base64"&&O(e.source.media_type)&&O(e.source.data))return{type:"file",mimeType:e.source.media_type,data:e.source.data};if(e.source.type==="url"&&O(e.source.url))return{type:"file",url:e.source.url};if(e.source.type==="file"&&O(e.source.file_id))return{type:"file",fileId:e.source.file_id};if(e.source.type==="text"&&O(e.source.data))return{type:"file",mimeType:String(e.source.media_type??"text/plain"),data:e.source.data}}else if(K(e,"image")&&re(e.source)&&"type"in e.source){if(e.source.type==="base64"&&O(e.source.media_type)&&O(e.source.data))return{type:"image",mimeType:e.source.media_type,data:e.source.data};if(e.source.type==="url"&&O(e.source.url))return{type:"image",url:e.source.url};if(e.source.type==="file"&&O(e.source.file_id))return{type:"image",fileId:e.source.file_id}}}function Ek(e){function*t(){for(let r of e){let i=$k(r);i?yield i:yield r}}return Array.from(t())}function kk(e){function*t(){let r=typeof e.content=="string"?[{type:"text",text:e.content}]:e.content;for(let i of r){if(K(i,"text")&&O(i.text)){let{text:n,citations:a,...o}=i;if(gt(a)&&a.length){let s=a.reduce((c,l)=>{let u=hj(l);return u?[...c,u]:c},[]);yield{...o,type:"text",text:n,annotations:s};continue}else{yield{...o,type:"text",text:n};continue}}else if(K(i,"thinking")&&O(i.thinking)){let{thinking:n,signature:a,...o}=i;yield{...o,type:"reasoning",reasoning:n,signature:a};continue}else if(K(i,"redacted_thinking")){yield{type:"non_standard",value:i};continue}else if(K(i,"tool_use")&&O(i.name)&&O(i.id)){yield{type:"tool_call",id:i.id,name:i.name,args:i.input};continue}else if(K(i,"input_json_delta")){if(gj(e)&&e.tool_call_chunks?.length){let n=e.tool_call_chunks[0];yield{type:"tool_call_chunk",id:n.id,name:n.name,args:n.args,index:n.index};continue}}else if(K(i,"server_tool_use")&&O(i.name)&&O(i.id)){let{name:n,id:a}=i;if(n==="web_search"){yield{id:a,type:"server_tool_call",name:"web_search",args:{query:$r(()=>{if(typeof i.input=="string")return i.input;if(re(i.input)&&O(i.input.query))return i.input.query;if(O(i.partial_json)){let o=Jh(i.partial_json);if(o?.query)return o.query}return""})}};continue}else if(i.name==="code_execution"){yield{id:a,type:"server_tool_call",name:"code_execution",args:{code:$r(()=>{if(typeof i.input=="string")return i.input;if(re(i.input)&&O(i.input.code))return i.input.code;if(O(i.partial_json)){let o=Jh(i.partial_json);if(o?.code)return o.code}return""})}};continue}}else if(K(i,"web_search_tool_result")&&O(i.tool_use_id)&&gt(i.content)){let{content:n,tool_use_id:a}=i;yield{type:"server_tool_call_result",name:"web_search",toolCallId:a,status:"success",output:{urls:n.reduce((o,s)=>K(s,"web_search_result")?[...o,s.url]:o,[])}};continue}else if(K(i,"code_execution_tool_result")&&O(i.tool_use_id)&&re(i.content)){yield{type:"server_tool_call_result",name:"code_execution",toolCallId:i.tool_use_id,status:"success",output:i.content};continue}else if(K(i,"mcp_tool_use")){yield{id:i.id,type:"server_tool_call",name:"mcp_tool_use",args:i.input};continue}else if(K(i,"mcp_tool_result")&&O(i.tool_use_id)&&re(i.content)){yield{type:"server_tool_call_result",name:"mcp_tool_use",toolCallId:i.tool_use_id,status:"success",output:i.content};continue}else if(K(i,"container_upload")){yield{type:"server_tool_call",name:"container_upload",args:i.input};continue}else if(K(i,"search_result")){yield{id:i.id,type:"non_standard",value:i};continue}else if(K(i,"tool_result")){yield{id:i.id,type:"non_standard",value:i};continue}else{let n=$k(i);if(n){yield n;continue}}yield{type:"non_standard",value:i}}}return Array.from(t())}var Ik={translateContent:kk,translateContentChunk:kk};function gj(e){return typeof e?._getType=="function"&&typeof e.concat=="function"&&e._getType()==="ai"}function _j(e){return Qo(e)?{type:e.type,mimeType:e.mime_type,url:e.url,metadata:e.metadata}:es(e)?{type:e.type,mimeType:e.mime_type??"application/octet-stream",data:e.data,metadata:e.metadata}:sd(e)?{type:e.type,mimeType:e.mime_type,fileId:e.id,metadata:e.metadata}:e}function Tk(e){return e.map(_j)}function Ck(e){return!!(K(e,"image_url")&&re(e.image_url)||K(e,"input_audio")&&re(e.input_audio)||K(e,"file")&&re(e.file))}function Ak(e){if(K(e,"image_url")&&re(e.image_url)&&O(e.image_url.url)){let t=Zc({dataUrl:e.image_url.url});return t?{type:"image",mimeType:t.mime_type,data:t.data}:{type:"image",url:e.image_url.url}}else{if(K(e,"input_audio")&&re(e.input_audio)&&O(e.input_audio.data)&&O(e.input_audio.format))return{type:"audio",data:e.input_audio.data,mimeType:`audio/${e.input_audio.format}`};if(K(e,"file")&&re(e.file)&&O(e.file.data)){let t=Zc({dataUrl:e.file.data});if(t)return{type:"file",data:t.data,mimeType:t.mime_type};if(O(e.file.file_id))return{type:"file",fileId:e.file.file_id}}}return e}function yj(e){let t=[];typeof e.content=="string"?e.content.length>0&&t.push({type:"text",text:e.content}):t.push(...ud(e.content));for(let r of e.tool_calls??[])t.push({type:"tool_call",id:r.id,name:r.name,args:r.args});return t}function vj(e){let t=[];typeof e.content=="string"?e.content.length>0&&t.push({type:"text",text:e.content}):t.push(...ud(e.content));for(let r of e.tool_calls??[])t.push({type:"tool_call",id:r.id,name:r.name,args:r.args});return t}function ud(e){let t=[];for(let r of e)Ck(r)?t.push(Ak(r)):t.push(r);return t}function bj(e){if(e.type==="url_citation"){let{url:t,title:r,start_index:i,end_index:n}=e;return{type:"citation",url:t,title:r,startIndex:i,endIndex:n}}if(e.type==="file_citation"){let{file_id:t,filename:r,index:i}=e;return{type:"citation",title:r,startIndex:i,endIndex:i,fileId:t}}return e}function Ok(e){function*t(){re(e.additional_kwargs?.reasoning)&&gt(e.additional_kwargs.reasoning.summary)&&(yield{type:"reasoning",reasoning:e.additional_kwargs.reasoning.summary.reduce((i,n)=>re(n)&&O(n.text)?`${i}${n.text}`:i,"")});let r=typeof e.content=="string"?[{type:"text",text:e.content}]:e.content;for(let i of r)if(K(i,"text")){let{text:n,annotations:a,phase:o,extras:s,...c}=i,l=re(s)?{...s}:{};O(o)&&(l.phase=o);let u=Object.keys(l).length>0?{extras:l}:{};Array.isArray(a)?yield{...c,...u,type:"text",text:String(n),annotations:a.map(bj)}:yield{...c,...u,type:"text",text:String(n)}}for(let i of e.tool_calls??[])yield{type:"tool_call",id:i.id,name:i.name,args:i.args};if(re(e.additional_kwargs)&&gt(e.additional_kwargs.tool_outputs))for(let i of e.additional_kwargs.tool_outputs){if(K(i,"web_search_call")){let n={};if(re(i.action)&&O(i.action.query)&&(n.query=i.action.query),yield{id:i.id,type:"server_tool_call",name:"web_search",args:n},i.status==="completed"||i.status==="failed"){let a={};re(i.action)&&(a.action=i.action),yield{type:"server_tool_call_result",toolCallId:O(i.id)?i.id:"",status:i.status==="completed"?"success":"error",output:a}}continue}else if(K(i,"file_search_call")){yield{id:i.id,type:"server_tool_call",name:"file_search",args:{queries:gt(i.queries)?i.queries:[]}},(i.status==="completed"||i.status==="failed")&&(yield{type:"server_tool_call_result",toolCallId:O(i.id)?i.id:"",status:i.status==="completed"?"success":"error",output:gt(i.results)?{results:i.results}:{}});continue}else if(K(i,"computer_call")){yield{type:"non_standard",value:i};continue}else if(K(i,"code_interpreter_call")){if(O(i.code)&&(yield{id:i.id,type:"server_tool_call",name:"code_interpreter",args:{code:i.code}}),gt(i.outputs)){let n=$r(()=>{if(i.status!=="in_progress"){if(i.status==="completed")return 0;if(i.status==="incomplete")return 127;if(i.status!=="interpreting"&&i.status==="failed")return 1}});for(let a of i.outputs)if(K(a,"logs")){yield{type:"server_tool_call_result",toolCallId:i.id??"",status:"success",output:{type:"code_interpreter_output",returnCode:n??0,stderr:[0,void 0].includes(n)?void 0:String(a.logs),stdout:[0,void 0].includes(n)?String(a.logs):void 0}};continue}}continue}else if(K(i,"mcp_call")){yield{id:i.id,type:"server_tool_call",name:"mcp_call",args:i.input};continue}else if(K(i,"mcp_list_tools")){yield{id:i.id,type:"server_tool_call",name:"mcp_list_tools",args:i.input};continue}else if(K(i,"mcp_approval_request")){yield{type:"non_standard",value:i};continue}else if(K(i,"tool_search_call")){let n={};re(i.arguments)&&Object.assign(n,i.arguments);let a={};O(i.execution)&&(a.execution=i.execution),O(i.status)&&(a.status=i.status),O(i.call_id)&&(a.call_id=i.call_id),yield{id:O(i.id)?i.id:"",type:"server_tool_call",name:"tool_search",args:n,...Object.keys(a).length>0?{extras:a}:{}};continue}else if(K(i,"tool_search_output")){let n={name:"tool_search"};O(i.execution)&&(n.execution=i.execution),yield{type:"server_tool_call_result",toolCallId:O(i.id)?i.id:"",status:i.status==="completed"?"success":i.status==="failed"?"error":"success",output:{tools:gt(i.tools)?i.tools:[]},extras:n};continue}else if(K(i,"image_generation_call")){O(i.result)&&(yield{type:"image",mimeType:"image/png",data:i.result,id:O(i.id)?i.id:void 0,metadata:{status:O(i.status)?i.status:void 0}}),yield{type:"non_standard",value:i};continue}re(i)&&(yield{type:"non_standard",value:i})}}return Array.from(t())}function wj(e){function*t(){yield*Ok(e);for(let r of e.tool_call_chunks??[])yield{type:"tool_call_chunk",id:r.id,name:r.name,args:r.args}}return Array.from(t())}var Pk={translateContent:e=>typeof e.content=="string"?yj(e):Ok(e),translateContentChunk:e=>typeof e.content=="string"?vj(e):wj(e)};function dd(e){return typeof e=="object"&&e!==null&&"type"in e&&"content"in e&&(typeof e.content=="string"||Array.isArray(e.content))}function Nk(e,t="pretty"){return t==="pretty"?xj(e):JSON.stringify(e)}function xj(e){let t=[],r=` ${e.type.charAt(0).toUpperCase()+e.type.slice(1)} Message `,i=Math.floor((80-r.length)/2),n="=".repeat(i),a=r.length%2===0?n:`${n}=`;if(t.push(`${n}${r}${a}`),e.type==="ai"){let o=e;if(o.tool_calls&&o.tool_calls.length>0){t.push("Tool Calls:");for(let s of o.tool_calls){t.push(` ${s.name} (${s.id})`),t.push(` Call ID: ${s.id}`),t.push(" Args:");for(let[c,l]of Object.entries(s.args))t.push(` ${c}: ${typeof l=="object"?JSON.stringify(l):l}`)}}}if(e.type==="tool"){let o=e;o.name&&t.push(`Name: ${o.name}`)}return typeof e.content=="string"&&e.content.trim()&&(t.length>1&&t.push(""),t.push(e.content)),t.join(`
9
- `)}var Kh=Symbol.for("langchain.message");function Rk(e){return Array.isArray(e)?e:typeof e=="string"?e===""?[]:[{type:"text",text:e}]:e==null?[]:[e]}function zt(e,t){if(typeof e=="string")return e===""?t:typeof t=="string"?e+t:Array.isArray(t)&&t.length===0?e:Array.isArray(t)&&t.some(r=>Rn(r))?[{type:"text",source_type:"text",text:e},...t]:[{type:"text",text:e},...t];if(Array.isArray(t)){let r=Rk(e);return Hi(r,t)??[...r,...t]}else return t===""?e:Array.isArray(e)&&e.some(r=>Rn(r))?[...e,{type:"file",source_type:"text",text:t}]:[...Rk(e),{type:"text",text:t}]}function fd(e,t){return e==="error"||t==="error"?"error":"success"}function Sj(e,t){function r(i,n){if(typeof i!="object"||i===null||i===void 0)return i;if(n>=t)return Array.isArray(i)?"[Array]":"[Object]";if(Array.isArray(i))return i.map(o=>r(o,n+1));let a={};for(let o of Object.keys(i))a[o]=r(i[o],n+1);return a}return JSON.stringify(r(e,0),null,2)}var Te=class extends lt{lc_namespace=["langchain_core","messages"];lc_serializable=!0;get lc_aliases(){return{additional_kwargs:"additional_kwargs",response_metadata:"response_metadata"}}[Kh]=!0;id;name;content;additional_kwargs;response_metadata;_getType(){return this.type}getType(){return this._getType()}constructor(e){let t=typeof e=="string"||Array.isArray(e)?{content:e}:e;t.additional_kwargs||(t.additional_kwargs={}),t.response_metadata||(t.response_metadata={}),super(t),this.name=t.name,t.content===void 0&&t.contentBlocks!==void 0?(this.content=t.contentBlocks,this.response_metadata={output_version:"v1",...t.response_metadata}):t.content!==void 0?(this.content=t.content??[],this.response_metadata=t.response_metadata):(this.content=[],this.response_metadata=t.response_metadata),this.additional_kwargs=t.additional_kwargs,this.id=t.id}get text(){return typeof this.content=="string"?this.content:Array.isArray(this.content)?this.content.map(e=>typeof e=="string"?e:e.type==="text"?e.text:"").join(""):""}get contentBlocks(){let e=typeof this.content=="string"?[{type:"text",text:this.content}]:this.content;return[Tk,ud,Ek].reduce((t,r)=>r(t),e)}toDict(){return{type:this.getType(),data:this.toJSON().kwargs}}static lc_name(){return"BaseMessage"}get _printableFields(){return{id:this.id,content:this.content,name:this.name,additional_kwargs:this.additional_kwargs,response_metadata:this.response_metadata}}static isInstance(e){return typeof e=="object"&&e!==null&&Kh in e&&e[Kh]===!0&&dd(e)}_updateId(e){this.id=e,this.lc_kwargs.id=e}get[Symbol.toStringTag](){return this.constructor.lc_name()}[Symbol.for("nodejs.util.inspect.custom")](e){if(e===null)return this;let t=Sj(this._printableFields,Math.max(4,e));return`${this.constructor.lc_name()} ${t}`}toFormattedString(e="pretty"){return Nk(this,e)}};function Dk(e){return Array.isArray(e)&&e.every(t=>typeof t.index=="number")}var qh=["index","created","timestamp"];function Ke(e,t,r){let i=r?.ignoreKeys??qh;if(e==null&&t==null)return;if(e==null||t==null)return e??t;let n={...e};for(let[a,o]of Object.entries(t))if(n[a]==null)n[a]=o;else{if(o==null)continue;if(typeof n[a]!=typeof o||Array.isArray(n[a])!==Array.isArray(o))throw new Error(`field[${a}] already exists in the message chunk, but with a different type.`);if(typeof n[a]=="string"){if(a==="type")continue;if(["id","name","output_version","model_provider"].includes(a))o&&(n[a]=o);else{if(i.includes(a))continue;n[a]+=o}}else if(typeof n[a]=="number"){if(i.includes(a))continue;n[a]=n[a]+o}else if(typeof n[a]=="object"&&!Array.isArray(n[a]))n[a]=Ke(n[a],o,r);else if(Array.isArray(n[a]))n[a]=Hi(n[a],o,r);else{if(n[a]===o)continue;console.warn(`field[${a}] already exists in this message chunk and value has unsupported type.`)}}return n}function kj(e){return typeof e=="number"||typeof e=="string"}function Mk(e){return typeof e!="object"||e===null||!("index"in e)?!1:kj(e.index)}function jk(e){if(typeof e!="object"||e===null||!("id"in e))return!1;let t=e.id;return t!=null&&t!==""}function zk(e){return e.endsWith("_delta")?e.slice(0,-6):e}function $j(e,t){return typeof e!="object"||e===null||typeof t!="object"||t===null||!("type"in e)||!("type"in t)?!1:typeof e.type=="string"&&typeof t.type=="string"&&zk(e.type)!==zk(t.type)}function Ej(e,t){let r=Mk(t),i=jk(t);return!r&&!i?-1:e.findIndex(n=>{let a=Mk(n),o=jk(n);return r&&a?n.index!==t.index||$j(n,t)?!1:o&&i?n.id===t.id:!0:!r&&!a&&i&&o?n.id===t.id:!1})}function Hi(e,t,r){if(!(e==null&&t==null)){if(e==null||t==null)return e||t;{let i=[...e];for(let n of t){let a=Ej(i,n);if(a!==-1)i[a]=Ke(i[a],n,r);else{if(typeof n=="object"&&n!==null&&"text"in n&&n.text==="")continue;i.push(n)}}return i}}}function pd(e,t,r){if(!(e==null&&t==null)){if(e==null||t==null)return e??t;if(typeof e!=typeof t)throw new Error(`Cannot merge objects of different types.
10
- Left ${typeof e}
11
- Right ${typeof t}`);if(typeof e=="string"&&typeof t=="string")return e+t;if(Array.isArray(e)&&Array.isArray(t))return Hi(e,t,r);if(typeof e=="object"&&typeof t=="object")return Ke(e,t,r);if(e===t)return e;throw new Error(`Can not merge objects of different types.
12
- Left ${e}
13
- Right ${t}`)}}var $t=class Uk extends Te{static isInstance(t){if(!super.isInstance(t))return!1;let r=Object.getPrototypeOf(t);for(;r!==null;){if(r===Uk.prototype)return!0;r=Object.getPrototypeOf(r)}return!1}};function md(e){return typeof e.role=="string"}function qe(e){return typeof e?._getType=="function"}function di(e){return $t.isInstance(e)}var Lk=T({ToolMessage:()=>_t,ToolMessageChunk:()=>ts,defaultToolCallParser:()=>Gc,isDirectToolOutput:()=>Hc,isToolMessage:()=>Wc,isToolMessageChunk:()=>Xh});function Hc(e){return e!=null&&typeof e=="object"&&"lc_direct_tool_output"in e&&e.lc_direct_tool_output===!0}var _t=class extends Te{static lc_name(){return"ToolMessage"}get lc_aliases(){return{tool_call_id:"tool_call_id"}}lc_direct_tool_output=!0;type="tool";status;tool_call_id;metadata;artifact;constructor(e,t,r){let i=typeof e=="string"||Array.isArray(e)?{content:e,name:r,tool_call_id:t}:e;super(i),this.tool_call_id=i.tool_call_id,this.artifact=i.artifact,this.status=i.status,this.metadata=i.metadata}static isInstance(e){return super.isInstance(e)&&e.type==="tool"}get _printableFields(){return{...super._printableFields,tool_call_id:this.tool_call_id,artifact:this.artifact}}},ts=class extends $t{type="tool";tool_call_id;status;artifact;constructor(e){super(e),this.tool_call_id=e.tool_call_id,this.artifact=e.artifact,this.status=e.status}static lc_name(){return"ToolMessageChunk"}concat(e){let t=this.constructor;return new t({content:zt(this.content,e.content),additional_kwargs:Ke(this.additional_kwargs,e.additional_kwargs),response_metadata:Ke(this.response_metadata,e.response_metadata),artifact:pd(this.artifact,e.artifact),tool_call_id:this.tool_call_id,id:this.id??e.id,status:fd(this.status,e.status)})}get _printableFields(){return{...super._printableFields,tool_call_id:this.tool_call_id,artifact:this.artifact}}};function Gc(e){let t=[],r=[];for(let i of e)if(i.function){let n=i.function.name;try{let a=JSON.parse(i.function.arguments);t.push({name:n||"",args:a||{},id:i.id})}catch{r.push({name:n,args:i.function.arguments,id:i.id,error:"Malformed args."})}}else continue;return[t,r]}function Wc(e){return typeof e=="object"&&e!==null&&"getType"in e&&typeof e.getType=="function"&&e.getType()==="tool"}function Xh(e){return e._getType()==="tool"}function Gi(e){return!!(e&&typeof e=="object"&&"type"in e&&e.type==="tool_call")}function Fk(e){return!!(e&&typeof e=="object"&&"toolCall"in e&&e.toolCall!=null&&typeof e.toolCall=="object"&&"id"in e.toolCall&&typeof e.toolCall.id=="string")}var rs=class extends Error{output;constructor(e,t){super(e),this.output=t}};function Va(e,t=Mn){e=e.trim();let r=e.indexOf("```");if(r===-1)return t(e);let i=e.substring(r+3);i.startsWith(`json
14
- `)?i=i.substring(5):i.startsWith("json")?i=i.substring(4):i.startsWith(`
15
- `)&&(i=i.substring(1));let n=i.indexOf("```"),a=i;return n!==-1&&(a=i.substring(0,n)),t(a.trim())}function Ij(e){try{return JSON.parse(e)}catch{}let t=e.trim();if(t.length===0)throw new Error("Unexpected end of JSON input");let r=0;function i(){for(;r<t.length&&/\s/.test(t[r]);)r+=1}function n(){if(t[r]!=='"')throw new Error(`Expected '"' at position ${r}, got '${t[r]}'`);r+=1;let u="",d=!1;for(;r<t.length;){let f=t[r];if(d){if(f==="n")u+=`
16
- `;else if(f==="t")u+=" ";else if(f==="r")u+="\r";else if(f==="\\")u+="\\";else if(f==='"')u+='"';else if(f==="b")u+="\b";else if(f==="f")u+="\f";else if(f==="/")u+="/";else if(f==="u"){let p=t.substring(r+1,r+5);if(/^[0-9A-Fa-f]{0,4}$/.test(p))p.length===4?u+=String.fromCharCode(Number.parseInt(p,16)):u+=`u${p}`,r+=p.length;else throw new Error(`Invalid unicode escape sequence '\\u${p}' at position ${r}`)}else throw new Error(`Invalid escape sequence '\\${f}' at position ${r}`);d=!1}else if(f==="\\")d=!0;else{if(f==='"')return r+=1,u;u+=f}r+=1}return d&&(u+="\\"),u}function a(){let u=r,d="";if(t[r]==="-"&&(d+="-",r+=1),r<t.length&&t[r]==="0"&&(d+="0",r+=1,t[r]>="0"&&t[r]<="9"))throw new Error(`Invalid number at position ${u}`);if(r<t.length&&t[r]>="1"&&t[r]<="9")for(;r<t.length&&t[r]>="0"&&t[r]<="9";)d+=t[r],r+=1;if(r<t.length&&t[r]===".")for(d+=".",r+=1;r<t.length&&t[r]>="0"&&t[r]<="9";)d+=t[r],r+=1;if(r<t.length&&(t[r]==="e"||t[r]==="E"))for(d+=t[r],r+=1,r<t.length&&(t[r]==="+"||t[r]==="-")&&(d+=t[r],r+=1);r<t.length&&t[r]>="0"&&t[r]<="9";)d+=t[r],r+=1;if(d==="-")return-0;let f=Number.parseFloat(d);if(Number.isNaN(f))throw r=u,new Error(`Invalid number '${d}' at position ${u}`);return f}function o(){if(i(),r>=t.length)throw new Error(`Unexpected end of input at position ${r}`);let u=t[r];if(u==="{")return c();if(u==="[")return s();if(u==='"')return n();if("null".startsWith(t.substring(r,r+4)))return r+=Math.min(4,t.length-r),null;if("true".startsWith(t.substring(r,r+4)))return r+=Math.min(4,t.length-r),!0;if("false".startsWith(t.substring(r,r+5)))return r+=Math.min(5,t.length-r),!1;if(u==="-"||u>="0"&&u<="9")return a();throw new Error(`Unexpected character '${u}' at position ${r}`)}function s(){if(t[r]!=="[")throw new Error(`Expected '[' at position ${r}, got '${t[r]}'`);let u=[];if(r+=1,i(),r>=t.length)return u;if(t[r]==="]")return r+=1,u;for(;r<t.length;){if(i(),r>=t.length||(u.push(o()),i(),r>=t.length))return u;if(t[r]==="]")return r+=1,u;if(t[r]===","){r+=1;continue}throw new Error(`Expected ',' or ']' at position ${r}, got '${t[r]}'`)}return u}function c(){if(t[r]!=="{")throw new Error(`Expected '{' at position ${r}, got '${t[r]}'`);let u={};if(r+=1,i(),r>=t.length)return u;if(t[r]==="}")return r+=1,u;for(;r<t.length;){if(i(),r>=t.length)return u;let d=n();if(i(),r>=t.length)return u;if(t[r]!==":")throw new Error(`Expected ':' at position ${r}, got '${t[r]}'`);if(r+=1,i(),r>=t.length||(u[d]=o(),i(),r>=t.length))return u;if(t[r]==="}")return r+=1,u;if(t[r]===","){r+=1;continue}throw new Error(`Expected ',' or '}' at position ${r}, got '${t[r]}'`)}return u}let l=o();if(i(),r<t.length)throw new Error(`Unexpected character '${t[r]}' at position ${r}`);return l}function Mn(e){try{return typeof e>"u"?null:Ij(e)}catch{return null}}function Yh(e){switch(e){case"csv":return"text/csv";case"doc":return"application/vnd.openxmlformats-officedocument.wordprocessingml.document";case"docx":return"application/vnd.openxmlformats-officedocument.wordprocessingml.document";case"html":return"text/html";case"md":return"text/markdown";case"pdf":return"application/pdf";case"txt":return"text/plain";case"xls":return"application/vnd.ms-excel";case"xlsx":return"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";case"gif":return"image/gif";case"jpeg":return"image/jpeg";case"jpg":return"image/jpeg";case"png":return"image/png";case"webp":return"image/webp";case"flv":return"video/flv";case"mkv":return"video/mkv";case"mov":return"video/mov";case"mp4":return"video/mp4";case"mpeg":return"video/mpeg";case"mpg":return"video/mpg";case"three_gp":return"video/three_gp";case"webm":return"video/webm";case"wmv":return"video/wmv";default:return"application/octet-stream"}}function Tj(e){if(re(e.document)&&re(e.document.source)){let t=Yh(re(e.document)&&O(e.document.format)?e.document.format:"");if(re(e.document.source)){if(re(e.document.source.s3Location)&&O(e.document.source.s3Location.uri))return{type:"file",mimeType:t,fileId:e.document.source.s3Location.uri};if(ld(e.document.source.bytes))return{type:"file",mimeType:t,data:e.document.source.bytes};if(O(e.document.source.text))return{type:"file",mimeType:t,data:Buffer.from(e.document.source.text).toString("base64")};if(gt(e.document.source.content))return{type:"file",mimeType:t,data:e.document.source.content.reduce((r,i)=>re(i)&&O(i.text)?r+i.text:r,"")}}}return{type:"non_standard",value:e}}function Cj(e){if(K(e,"image")&&re(e.image)){let t=Yh(re(e.image)&&O(e.image.format)?e.image.format:"");if(re(e.image.source)){if(re(e.image.source.s3Location)&&O(e.image.source.s3Location.uri))return{type:"image",mimeType:t,fileId:e.image.source.s3Location.uri};if(ld(e.image.source.bytes))return{type:"image",mimeType:t,data:e.image.source.bytes}}}return{type:"non_standard",value:e}}function Aj(e){if(K(e,"video")&&re(e.video)){let t=Yh(re(e.video)&&O(e.video.format)?e.video.format:"");if(re(e.video.source)){if(re(e.video.source.s3Location)&&O(e.video.source.s3Location.uri))return{type:"video",mimeType:t,fileId:e.video.source.s3Location.uri};if(ld(e.video.source.bytes))return{type:"video",mimeType:t,data:e.video.source.bytes}}}return{type:"non_standard",value:e}}function Bk(e){function*t(){let r=typeof e.content=="string"?[{type:"text",text:e.content}]:e.content;for(let i of r){if(K(i,"cache_point")){yield{type:"non_standard",value:i};continue}else if(K(i,"citations_content")&&re(i.citationsContent)){yield{type:"text",text:gt(i.citationsContent.content)?i.citationsContent.content.reduce((n,a)=>re(a)&&O(a.text)?n+a.text:n,""):"",annotations:gt(i.citationsContent.citations)?i.citationsContent.citations.reduce((n,a)=>{if(re(a)){let o=gt(a.sourceContent)?a.sourceContent.reduce((c,l)=>re(l)&&O(l.text)?c+l.text:c,""):"",s=$r(()=>{if(re(a.location)){let c=a.location.documentChar||a.location.documentPage||a.location.documentChunk;if(re(c))return{source:kr(c.documentIndex)?c.documentIndex.toString():void 0,startIndex:kr(c.start)?c.start:void 0,endIndex:kr(c.end)?c.end:void 0}}return{}});n.push({type:"citation",citedText:o,...s})}return n},[]):[]};continue}else if(K(i,"document")&&re(i.document)){yield Tj(i);continue}else if(K(i,"guard_content")){yield{type:"non_standard",value:i};continue}else if(K(i,"image")&&re(i.image)){yield Cj(i);continue}else if(K(i,"reasoning_content")&&O(i.reasoningText)){yield{type:"reasoning",reasoning:i.reasoningText};continue}else if(K(i,"text")&&O(i.text)){yield{type:"text",text:i.text};continue}else if(K(i,"tool_result")){yield{type:"non_standard",value:i};continue}else{if(K(i,"tool_call"))continue;if(K(i,"video")&&re(i.video)){yield Aj(i);continue}}yield{type:"non_standard",value:i}}}return Array.from(t())}var Vk={translateContent:Bk,translateContentChunk:Bk};function Zk(e){let t=[],r=e.additional_kwargs?.reasoning_content;if(O(r)&&r.length>0&&t.push({type:"reasoning",reasoning:r}),typeof e.content=="string")e.content.length>0&&t.push({type:"text",text:e.content});else for(let i of e.content)typeof i=="object"&&"type"in i&&i.type==="text"&&"text"in i&&O(i.text)&&t.push({type:"text",text:i.text});for(let i of e.tool_calls??[])t.push({type:"tool_call",id:i.id,name:i.name,args:i.args});return t}var Hk={translateContent:Zk,translateContentChunk:Zk};function Gk(e){function*t(){let r=typeof e.content=="string"?[{type:"text",text:e.content}]:e.content;for(let i of r){if(K(i,"text")&&O(i.text)){yield{type:"text",text:i.text};continue}else if(K(i,"thinking")&&O(i.thinking)){yield{type:"reasoning",reasoning:i.thinking,...i.signature?{signature:i.signature}:{}};continue}else if(K(i,"inlineData")&&re(i.inlineData)&&O(i.inlineData.mimeType)&&O(i.inlineData.data)){yield{type:"file",mimeType:i.inlineData.mimeType,data:i.inlineData.data};continue}else if(K(i,"functionCall")&&re(i.functionCall)&&O(i.functionCall.name)&&re(i.functionCall.args)){yield{type:"tool_call",id:e.id,name:i.functionCall.name,args:i.functionCall.args};continue}else if(K(i,"functionResponse")){yield{type:"non_standard",value:i};continue}else if(K(i,"fileData")&&re(i.fileData)&&O(i.fileData.mimeType)&&O(i.fileData.fileUri)){yield{type:"file",mimeType:i.fileData.mimeType,fileId:i.fileData.fileUri};continue}else if(K(i,"executableCode")){yield{type:"non_standard",value:i};continue}else if(K(i,"codeExecutionResult")){yield{type:"non_standard",value:i};continue}yield{type:"non_standard",value:i}}}return Array.from(t())}var Wk={translateContent:Gk,translateContentChunk:Gk};function Jk(e){function*t(){let r=typeof e.content=="string"?[{type:"text",text:e.content}]:e.content;for(let i of r){if(K(i,"reasoning")&&O(i.reasoning)){let n=$r(()=>{let a=r.indexOf(i);if(gt(e.additional_kwargs?.signatures)&&a>=0)return e.additional_kwargs.signatures.at(a)});O(n)?yield{type:"reasoning",reasoning:i.reasoning,signature:n}:yield{type:"reasoning",reasoning:i.reasoning};continue}else if(K(i,"thinking")&&O(i.thinking)){yield{type:"reasoning",reasoning:i.thinking,...i.signature?{signature:i.signature}:{}};continue}else if(K(i,"text")&&O(i.text)){yield{type:"text",text:i.text};continue}else if(K(i,"image_url")){if(O(i.image_url))if(i.image_url.startsWith("data:")){let n=i.image_url.match(/^data:([^;]+);base64,(.+)$/);n?yield{type:"image",data:n[2],mimeType:n[1]}:yield{type:"image",url:i.image_url}}else yield{type:"image",url:i.image_url};continue}else if(K(i,"media")&&O(i.mimeType)&&O(i.data)){yield{type:"file",mimeType:i.mimeType,data:i.data};continue}yield{type:"non_standard",value:i}}}return Array.from(t())}var Kk={translateContent:Jk,translateContentChunk:Jk};function qk(e){let t=[],r=e.additional_kwargs?.reasoning;if(O(r)&&r.length>0&&t.push({type:"reasoning",reasoning:r}),typeof e.content=="string"){let i=e.content,n=i.match(/<think>([\s\S]*?)<\/think>/);if(n){let a=n[1].trim();a.length>0&&t.push({type:"reasoning",reasoning:a}),i=i.replace(/<think>[\s\S]*?<\/think>/,"").trim()}i.length>0&&t.push({type:"text",text:i})}else for(let i of e.content)if(typeof i=="object"&&"type"in i&&i.type==="text"&&"text"in i&&O(i.text)){let n=i.text,a=n.match(/<think>([\s\S]*?)<\/think>/);if(a){let o=a[1].trim();o.length>0&&t.push({type:"reasoning",reasoning:o}),n=n.replace(/<think>[\s\S]*?<\/think>/,"").trim()}n.length>0&&t.push({type:"text",text:n})}for(let i of e.tool_calls??[])t.push({type:"tool_call",id:i.id,name:i.name,args:i.args});return t}var Xk={translateContent:qk,translateContentChunk:qk};function Yk(e){let t=[],r=e.additional_kwargs?.reasoning_content;if(O(r)&&r.length>0&&t.push({type:"reasoning",reasoning:r}),typeof e.content=="string")e.content.length>0&&t.push({type:"text",text:e.content});else for(let i of e.content)typeof i=="object"&&"type"in i&&i.type==="text"&&"text"in i&&O(i.text)&&t.push({type:"text",text:i.text});for(let i of e.tool_calls??[])t.push({type:"tool_call",id:i.id,name:i.name,args:i.args});return t}var Qk={translateContent:Yk,translateContentChunk:Yk};function e$(e){let t=[],r=e.additional_kwargs?.reasoning_details,i=!1;if(Array.isArray(r)&&r.length>0)for(let n of r){if(n==null||typeof n!="object")continue;let a=n.type;if(a==="reasoning.summary"){let o=n.summary;O(o)&&o.length>0&&(t.push({type:"reasoning",reasoning:o}),i=!0)}else if(a==="reasoning.text"){let o=n.text;O(o)&&o.length>0&&(t.push({type:"reasoning",reasoning:o}),i=!0)}}if(!i){let n=e.additional_kwargs?.reasoning_content;O(n)&&n.length>0&&t.push({type:"reasoning",reasoning:n})}if(typeof e.content=="string")e.content.length>0&&t.push({type:"text",text:e.content});else for(let n of e.content)typeof n=="object"&&"type"in n&&n.type==="text"&&"text"in n&&O(n.text)&&t.push({type:"text",text:n.text});for(let n of e.tool_calls??[])t.push({type:"tool_call",id:n.id,name:n.name,args:n.args});return t}var t$={translateContent:e$,translateContentChunk:e$};function r$(e){let t=[];if(re(e.additional_kwargs?.reasoning)){let i=e.additional_kwargs.reasoning;if(gt(i.summary)){let n=i.summary.reduce((a,o)=>re(o)&&O(o.text)?`${a}${o.text}`:a,"");n.length>0&&t.push({type:"reasoning",reasoning:n})}}let r=e.additional_kwargs?.reasoning_content;if(O(r)&&r.length>0&&t.push({type:"reasoning",reasoning:r}),typeof e.content=="string")e.content.length>0&&t.push({type:"text",text:e.content});else for(let i of e.content)typeof i=="object"&&"type"in i&&i.type==="text"&&"text"in i&&O(i.text)&&t.push({type:"text",text:i.text});for(let i of e.tool_calls??[])t.push({type:"tool_call",id:i.id,name:i.name,args:i.args});return t}var n$={translateContent:r$,translateContentChunk:r$};function i$(e){function*t(){let r=$r(()=>{if(typeof e.content=="string")return e.additional_kwargs.originalTextContentBlock?[{...e.additional_kwargs.originalTextContentBlock,type:"text"}]:[{type:"text",text:e.content}];{let i=e.additional_kwargs?.originalTextContentBlock;if(i?.thoughtSignature&&!e.content.some(n=>"thoughtSignature"in n)){let n=[...e.content];for(let a=n.length-1;a>=0;a--){let o=n[a];if(o.type==="text"&&!o.thought)return o.thoughtSignature=i.thoughtSignature,n}}return e.content}});for(let i of r){let n=$r(()=>K(i,"text")&&O(i.text)?{type:"text",text:i.text}:K(i,"inlineData")&&re(i.inlineData)&&O(i.inlineData.mimeType)&&O(i.inlineData.data)?{type:"file",mimeType:i.inlineData.mimeType,data:i.inlineData.data}:K(i,"functionCall")&&re(i.functionCall)&&O(i.functionCall.name)&&re(i.functionCall.args)?{type:"tool_call",id:e.id,name:i.functionCall.name,args:i.functionCall.args}:K(i,"functionResponse")?{type:"non_standard",value:i}:K(i,"fileData")&&re(i.fileData)&&O(i.fileData.mimeType)&&O(i.fileData.fileUri)?{type:"file",mimeType:i.fileData.mimeType,fileId:i.fileData.fileUri}:K(i,"executableCode")?{type:"non_standard",value:i}:K(i,"codeExecutionResult")?{type:"non_standard",value:i}:{type:"non_standard",value:i}),a=$r(()=>"thought"in i&&i.thought?{type:"reasoning",reasoning:n.type==="text"?n.text:"",reasoningContentBlock:n}:n),o={thought:i.thought,thoughtSignature:i.thoughtSignature,partMetadata:i.partMetadata,...a};for(let s in o)o[s]===void 0&&delete o[s];yield o}}return Array.from(t())}var a$={translateContent:i$,translateContentChunk:i$};globalThis.lc_block_translators_registry??=new Map([["anthropic",Ik],["bedrock-converse",Vk],["deepseek",Hk],["google",a$],["google-genai",Wk],["google-vertexai",Kk],["groq",Xk],["ollama",Qk],["openai",Pk],["openrouter",t$],["xai",n$]]);function Qh(e){return globalThis.lc_block_translators_registry.get(e)}function hd(e,t){return Ke(e,t)??{}}function o$(e,t){let r={};return(e?.audio!==void 0||t?.audio!==void 0)&&(r.audio=(e?.audio??0)+(t?.audio??0)),(e?.image!==void 0||t?.image!==void 0)&&(r.image=(e?.image??0)+(t?.image??0)),(e?.video!==void 0||t?.video!==void 0)&&(r.video=(e?.video??0)+(t?.video??0)),(e?.document!==void 0||t?.document!==void 0)&&(r.document=(e?.document??0)+(t?.document??0)),(e?.text!==void 0||t?.text!==void 0)&&(r.text=(e?.text??0)+(t?.text??0)),r}function Oj(e,t){let r={...o$(e,t)};return(e?.cache_read!==void 0||t?.cache_read!==void 0)&&(r.cache_read=(e?.cache_read??0)+(t?.cache_read??0)),(e?.cache_creation!==void 0||t?.cache_creation!==void 0)&&(r.cache_creation=(e?.cache_creation??0)+(t?.cache_creation??0)),r}function Pj(e,t){let r={...o$(e,t)};return(e?.reasoning!==void 0||t?.reasoning!==void 0)&&(r.reasoning=(e?.reasoning??0)+(t?.reasoning??0)),r}function ns(e,t){return{input_tokens:(e?.input_tokens??0)+(t?.input_tokens??0),output_tokens:(e?.output_tokens??0)+(t?.output_tokens??0),total_tokens:(e?.total_tokens??0)+(t?.total_tokens??0),input_token_details:Oj(e?.input_token_details,t?.input_token_details),output_token_details:Pj(e?.output_token_details,t?.output_token_details)}}var Ce=class extends Te{type="ai";tool_calls=[];invalid_tool_calls=[];usage_metadata;get lc_aliases(){return{...super.lc_aliases,tool_calls:"tool_calls",invalid_tool_calls:"invalid_tool_calls",usage_metadata:"usage_metadata"}}constructor(e){let t;if(typeof e=="string"||Array.isArray(e))t={content:e,tool_calls:[],invalid_tool_calls:[],additional_kwargs:{}};else{t=e;let r=t.additional_kwargs?.tool_calls,i=t.tool_calls;r!=null&&r.length>0&&(i===void 0||i.length===0)&&console.warn(["New LangChain packages are available that more efficiently handle",`tool calling.
17
-
18
- Please upgrade your packages to versions that set`,"message tool calls. e.g., `pnpm install @langchain/anthropic`,","pnpm install @langchain/openai`, etc."].join(" "));try{if(r!=null&&i===void 0){let[n,a]=Gc(r);t.tool_calls=n??[],t.invalid_tool_calls=a??[]}else t.tool_calls=t.tool_calls??[],t.invalid_tool_calls=t.invalid_tool_calls??[]}catch{t.tool_calls=[],t.invalid_tool_calls=[]}if(t.response_metadata!==void 0&&"output_version"in t.response_metadata&&t.response_metadata.output_version==="v1"&&(t.contentBlocks=t.content,t.content=void 0),t.contentBlocks!==void 0){if(t.tool_calls){let a=t.tool_calls.filter(o=>!t.contentBlocks?.some(s=>s.type==="tool_call"&&s.id===o.id&&s.name===o.name));t.contentBlocks.push(...a.map(o=>({type:"tool_call",id:o.id,name:o.name,args:o.args})))}let n=t.contentBlocks.filter(a=>a.type==="tool_call").filter(a=>!t.tool_calls?.some(o=>o.id===a.id&&o.name===a.name));n.length>0&&(t.tool_calls=[...t.tool_calls??[],...n.map(a=>({type:"tool_call",id:a.id,name:a.name,args:a.args}))])}}super(t),typeof t!="string"&&(this.tool_calls=t.tool_calls??this.tool_calls,this.invalid_tool_calls=t.invalid_tool_calls??this.invalid_tool_calls),this.usage_metadata=t.usage_metadata}static lc_name(){return"AIMessage"}get contentBlocks(){if(this.response_metadata&&"output_version"in this.response_metadata&&this.response_metadata.output_version==="v1")return this.content;if(this.response_metadata&&"model_provider"in this.response_metadata&&typeof this.response_metadata.model_provider=="string"){let t=Qh(this.response_metadata.model_provider);if(t)return t.translateContent(this)}let e=super.contentBlocks;if(this.tool_calls){let t=this.tool_calls.filter(r=>!e.some(i=>i.id===r.id&&i.name===r.name));e.push(...t.map(r=>({type:"tool_call",id:r.id,name:r.name,args:r.args})))}return e}get _printableFields(){return{...super._printableFields,tool_calls:this.tool_calls,invalid_tool_calls:this.invalid_tool_calls,usage_metadata:this.usage_metadata}}static isInstance(e){return super.isInstance(e)&&e.type==="ai"}};function is(e){return e._getType()==="ai"}function Jc(e){return e._getType()==="ai"}var Qe=class extends $t{type="ai";tool_calls=[];invalid_tool_calls=[];tool_call_chunks=[];usage_metadata;constructor(e){let t;if(typeof e=="string"||Array.isArray(e))t={content:e,tool_calls:[],invalid_tool_calls:[],tool_call_chunks:[]};else if(e.tool_call_chunks===void 0||e.tool_call_chunks.length===0)t={...e,tool_calls:e.tool_calls??[],invalid_tool_calls:[],tool_call_chunks:[],usage_metadata:e.usage_metadata!==void 0?e.usage_metadata:void 0};else{let r=gd(e.tool_call_chunks??[]);t={...e,tool_call_chunks:r.tool_call_chunks,tool_calls:r.tool_calls,invalid_tool_calls:r.invalid_tool_calls,usage_metadata:e.usage_metadata!==void 0?e.usage_metadata:void 0}}super(t),this.tool_call_chunks=t.tool_call_chunks??this.tool_call_chunks,this.tool_calls=t.tool_calls??this.tool_calls,this.invalid_tool_calls=t.invalid_tool_calls??this.invalid_tool_calls,this.usage_metadata=t.usage_metadata}get lc_aliases(){return{...super.lc_aliases,tool_calls:"tool_calls",invalid_tool_calls:"invalid_tool_calls",tool_call_chunks:"tool_call_chunks",usage_metadata:"usage_metadata"}}static lc_name(){return"AIMessageChunk"}get contentBlocks(){if(this.response_metadata&&"output_version"in this.response_metadata&&this.response_metadata.output_version==="v1")return this.content;if(this.response_metadata&&"model_provider"in this.response_metadata&&typeof this.response_metadata.model_provider=="string"){let t=Qh(this.response_metadata.model_provider);if(t)return t.translateContent(this)}let e=super.contentBlocks;if(this.tool_calls&&typeof this.content!="string"){let t=this.content.filter(r=>r.type==="tool_call").map(r=>r.id);for(let r of this.tool_calls)r.id&&!t.includes(r.id)&&e.push({...r,type:"tool_call",id:r.id,name:r.name,args:r.args})}return e}get _printableFields(){return{...super._printableFields,tool_calls:this.tool_calls,tool_call_chunks:this.tool_call_chunks,invalid_tool_calls:this.invalid_tool_calls,usage_metadata:this.usage_metadata}}concat(e){let t={content:zt(this.content,e.content),additional_kwargs:Ke(this.additional_kwargs,e.additional_kwargs),response_metadata:hd(this.response_metadata,e.response_metadata),tool_call_chunks:[],tool_calls:[],id:this.id??e.id};if(this.tool_call_chunks!==void 0||e.tool_call_chunks!==void 0){let i=Hi(this.tool_call_chunks,e.tool_call_chunks);i!==void 0&&i.length>0&&(t.tool_call_chunks=i)}if(this.tool_calls!==void 0||e.tool_calls!==void 0){let i=Hi(this.tool_calls,e.tool_calls);i!==void 0&&i.length>0&&(t.tool_calls=i)}(this.usage_metadata!==void 0||e.usage_metadata!==void 0)&&(t.usage_metadata=ns(this.usage_metadata,e.usage_metadata));let r=this.constructor;return new r(t)}static isInstance(e){return super.isInstance(e)&&e.type==="ai"}};var an=class s$ extends Te{static lc_name(){return"ChatMessage"}type="generic";role;static _chatMessageClass(){return s$}constructor(t,r){(typeof t=="string"||Array.isArray(t))&&(t={content:t,role:r}),super(t),this.role=t.role}static isInstance(t){return super.isInstance(t)&&t.type==="generic"}get _printableFields(){return{...super._printableFields,role:this.role}}},Za=class extends $t{static lc_name(){return"ChatMessageChunk"}type="generic";role;constructor(e,t){(typeof e=="string"||Array.isArray(e))&&(e={content:e,role:t}),super(e),this.role=e.role}concat(e){let t=this.constructor;return new t({content:zt(this.content,e.content),additional_kwargs:Ke(this.additional_kwargs,e.additional_kwargs),response_metadata:Ke(this.response_metadata,e.response_metadata),role:this.role,id:this.id??e.id})}static isInstance(e){return super.isInstance(e)&&e.type==="generic"}get _printableFields(){return{...super._printableFields,role:this.role}}};function c$(e){return e._getType()==="generic"}function l$(e){return e._getType()==="generic"}var Ha=class extends Te{static lc_name(){return"FunctionMessage"}type="function";name;constructor(e){super(e),this.name=e.name}},Ga=class extends $t{static lc_name(){return"FunctionMessageChunk"}type="function";concat(e){let t=this.constructor;return new t({content:zt(this.content,e.content),additional_kwargs:Ke(this.additional_kwargs,e.additional_kwargs),response_metadata:Ke(this.response_metadata,e.response_metadata),name:this.name??"",id:this.id??e.id})}};function u$(e){return e._getType()==="function"}function d$(e){return e._getType()==="function"}var rt=class extends Te{static lc_name(){return"HumanMessage"}type="human";constructor(e){super(e)}static isInstance(e){return super.isInstance(e)&&e.type==="human"}},Wa=class extends $t{static lc_name(){return"HumanMessageChunk"}type="human";constructor(e){super(e)}concat(e){let t=this.constructor;return new t({content:zt(this.content,e.content),additional_kwargs:Ke(this.additional_kwargs,e.additional_kwargs),response_metadata:Ke(this.response_metadata,e.response_metadata),id:this.id??e.id})}static isInstance(e){return super.isInstance(e)&&e.type==="human"}};function f$(e){return e.getType()==="human"}function p$(e){return e.getType()==="human"}var Lr=class extends Te{type="remove";id;constructor(e){super({...e,content:[]}),this.id=e.id}get _printableFields(){return{...super._printableFields,id:this.id}}static isInstance(e){return super.isInstance(e)&&e.type==="remove"}};var er=class _d extends Te{static lc_name(){return"SystemMessage"}type="system";constructor(t){super(t)}concat(t){if(typeof t=="string")return new _d({content:zt(this.content,t),additional_kwargs:this.additional_kwargs,response_metadata:this.response_metadata,id:this.id,name:this.name});if(_d.isInstance(t))return new _d({content:zt(this.content,t.content),additional_kwargs:{...this.additional_kwargs,...t.additional_kwargs},response_metadata:{...this.response_metadata,...t.response_metadata},id:this.id??t.id,name:this.name??t.name});throw new Error("Unexpected chunk type for system message")}static isInstance(t){return super.isInstance(t)&&t.type==="system"}},fi=class extends $t{static lc_name(){return"SystemMessageChunk"}type="system";constructor(e){super(e)}concat(e){let t=this.constructor;return new t({content:zt(this.content,e.content),additional_kwargs:Ke(this.additional_kwargs,e.additional_kwargs),response_metadata:Ke(this.response_metadata,e.response_metadata),id:this.id??e.id})}static isInstance(e){return super.isInstance(e)&&e.type==="system"}};function m$(e){return e._getType()==="system"}function h$(e){return e._getType()==="system"}function Nj(e){return e.isCustomTool===!0}var g$=e=>e();function Rj(e){return Gi(e)?e:typeof e.id=="string"&&e.type==="function"&&typeof e.function=="object"&&e.function!==null&&"arguments"in e.function&&typeof e.function.arguments=="string"&&"name"in e.function&&typeof e.function.name=="string"?{id:e.id,args:JSON.parse(e.function.arguments),name:e.function.name,type:"tool_call"}:e}function Mj(e){return typeof e=="object"&&e!=null&&e.lc===1&&Array.isArray(e.id)&&e.kwargs!=null&&typeof e.kwargs=="object"}function eg(e){let t,r;if(Mj(e)){let i=e.id.at(-1);i==="HumanMessage"||i==="HumanMessageChunk"?t="user":i==="AIMessage"||i==="AIMessageChunk"?t="assistant":i==="SystemMessage"||i==="SystemMessageChunk"?t="system":i==="FunctionMessage"||i==="FunctionMessageChunk"?t="function":i==="ToolMessage"||i==="ToolMessageChunk"?t="tool":t="unknown",r=e.kwargs}else{let{type:i,...n}=e;t=i,r=n}if(t==="human"||t==="user")return new rt(r);if(t==="ai"||t==="assistant"){let{tool_calls:i,...n}=r;if(!Array.isArray(i))return new Ce(r);let a=i.map(Rj);return new Ce({...n,tool_calls:a})}else{if(t==="system")return new er(r);if(t==="developer")return new er({...r,additional_kwargs:{...r.additional_kwargs,__openai_role__:"developer"}});if(t==="tool"&&"tool_call_id"in r)return new _t({...r,content:r.content,tool_call_id:r.tool_call_id,name:r.name});if(t==="remove"&&"id"in r&&typeof r.id=="string")return new Lr({...r,id:r.id});throw ui(new Error(`Unable to coerce message from array: only human, AI, system, developer, or tool message coercion is currently supported.
19
-
20
- Received: ${JSON.stringify(e,null,2)}`),"MESSAGE_COERCION_FAILURE")}}function yt(e){if(typeof e=="string")return new rt(e);if(qe(e))return e;if(Array.isArray(e)){let[t,r]=e;return eg({type:t,content:r})}else if(md(e)){let{role:t,...r}=e;return eg({...r,type:t})}else return eg(e)}function jj(e){if(typeof e=="string")return e;switch(e.type){case"text":return e.text??"";case"text-plain":return e.text??"[text-plain file]";case"image":case"image_url":return"[image]";case"audio":case"input_audio":return"[audio]";case"video":return"[video]";case"file":return"[file]";case"reasoning":case"tool_call":case"tool_call_chunk":case"invalid_tool_call":case"server_tool_call":case"server_tool_call_chunk":case"server_tool_call_result":case"non_standard":return"";default:return e.type?`[${e.type}]`:""}}function as(e,t="Human",r="AI"){let i=[];for(let n of e){let a;if(n.type==="human")a=t;else if(n.type==="ai")a=r;else if(n.type==="system")a="System";else if(n.type==="tool")a="Tool";else if(n.type==="generic")a=n.role;else throw new Error(`Got unsupported message type: ${n.type}`);let o=n.name?`${n.name}, `:"",s=typeof n.content=="string"?n.content:Array.isArray(n.content)?n.content.map(jj).filter(Boolean).join(""):"",c=`${a}: ${o}${s}`;if(n.type==="ai"){let l=n;l.tool_calls&&l.tool_calls.length>0?c+=JSON.stringify(l.tool_calls):l.additional_kwargs&&"function_call"in l.additional_kwargs&&(c+=JSON.stringify(l.additional_kwargs.function_call))}i.push(c)}return i.join(`
21
- `)}function zj(e){if(e.data!==void 0)return e;{let t=e;return{type:t.type,data:{content:t.text,role:t.role,name:void 0,tool_call_id:void 0}}}}function Kc(e){let t=zj(e);switch(t.type){case"human":return new rt(t.data);case"ai":return new Ce(t.data);case"system":return new er(t.data);case"function":if(t.data.name===void 0)throw new Error("Name must be defined for function messages");return new Ha(t.data);case"tool":if(t.data.tool_call_id===void 0)throw new Error("Tool call ID must be defined for tool messages");return new _t(t.data);case"generic":if(t.data.role===void 0)throw new Error("Role must be defined for chat messages");return new an(t.data);default:throw new Error(`Got unexpected type: ${t.type}`)}}function _$(e){return e.map(Kc)}function y$(e){return e.map(t=>t.toDict())}function Ja(e){let t=e._getType();if(t==="human")return new Wa({...e});if(t==="ai"){let r={...e};return"tool_calls"in r&&(r={...r,tool_call_chunks:r.tool_calls?.map(i=>({...i,type:"tool_call_chunk",index:void 0,args:JSON.stringify(i.args)}))}),new Qe({...r})}else{if(t==="system")return new fi({...e});if(t==="function")return new Ga({...e});if(an.isInstance(e))return new Za({...e});throw new Error("Unknown message type.")}}function gd(e){let t=e.reduce((n,a)=>{let o=n.findIndex(([s])=>"id"in a&&a.id&&"index"in a&&a.index!==void 0?a.id===s.id&&a.index===s.index:"id"in a&&a.id?a.id===s.id:"index"in a&&a.index!==void 0?a.index===s.index:!1);return o!==-1?n[o].push(a):n.push([a]),n},[]),r=[],i=[];for(let n of t){let a=null,o=n.some(Nj),s=n[0]?.name??"",c=n.map(f=>f.args||"").join(""),l=o?c:c.trim(),u=l.length?l:"{}",d=n.find(f=>f.id)?.id??n[0]?.id;if(o&&d){r.push({name:s,args:{input:l},id:d,type:"tool_call"});continue}try{if(a=Mn(u),!d||a===null||typeof a!="object"||Array.isArray(a))throw new Error("Malformed tool call chunk args.");r.push({name:s,args:a,id:d,type:"tool_call"})}catch{i.push({name:s,args:u,id:d,error:"Malformed args.",type:"invalid_tool_call"})}}return{tool_call_chunks:e,tool_calls:r,invalid_tool_calls:i}}var v$=T({BaseCache:()=>w$,InMemoryCache:()=>tg,defaultHashKeyEncoder:()=>b$,deserializeStoredGeneration:()=>Dj,serializeGeneration:()=>Uj}),b$=(...e)=>Yo(e.join("_"));function Dj(e){return e.message!==void 0?{text:e.text,message:Kc(e.message)}:{text:e.text}}function Uj(e){let t={text:e.text};return e.message!==void 0&&(t.message=e.message.toDict()),t}var w$=class{keyEncoder=b$;makeDefaultKeyEncoder(e){this.keyEncoder=e}},Lj=new Map,tg=class x$ extends w${cache;constructor(t){super(),this.cache=t??new Map}lookup(t,r){return Promise.resolve(this.cache.get(this.keyEncoder(t,r))??null)}async update(t,r,i){this.cache.set(this.keyEncoder(t,r),i)}static global(){return new x$(Lj)}};var S$=T({BaseCallbackHandler:()=>tr,callbackHandlerPrefersChatModelStreamEvents:()=>rg,callbackHandlerPrefersStreaming:()=>qc,isBaseCallbackHandler:()=>ng}),Fj=class{};function qc(e){return"lc_prefer_streaming"in e&&e.lc_prefer_streaming}function rg(e){return"lc_prefer_chat_model_stream_events"in e&&e.lc_prefer_chat_model_stream_events}var tr=class extends Fj{lc_serializable=!1;get lc_namespace(){return["langchain_core","callbacks",this.name]}get lc_secrets(){}get lc_attributes(){}get lc_aliases(){}get lc_serializable_keys(){}static lc_name(){return this.name}get lc_id(){return[...this.lc_namespace,Xo(this.constructor)]}lc_kwargs;ignoreLLM=!1;ignoreChain=!1;ignoreAgent=!1;ignoreRetriever=!1;ignoreCustomEvent=!1;raiseError=!1;awaitHandlers=Qt("LANGCHAIN_CALLBACKS_BACKGROUND")==="false";constructor(e){super(),this.lc_kwargs=e||{},e&&(this.ignoreLLM=e.ignoreLLM??this.ignoreLLM,this.ignoreChain=e.ignoreChain??this.ignoreChain,this.ignoreAgent=e.ignoreAgent??this.ignoreAgent,this.ignoreRetriever=e.ignoreRetriever??this.ignoreRetriever,this.ignoreCustomEvent=e.ignoreCustomEvent??this.ignoreCustomEvent,this.raiseError=e.raiseError??this.raiseError,this.awaitHandlers=this.raiseError||(e._awaitHandler??this.awaitHandlers))}copy(){return new this.constructor(this)}toJSON(){return lt.prototype.toJSON.call(this)}toJSONNotImplemented(){return lt.prototype.toJSONNotImplemented.call(this)}static fromMethods(e){class t extends tr{name=Ur();constructor(){super(),Object.assign(this,e)}}return new t}},ng=e=>{let t=e;return t!==void 0&&typeof t.copy=="function"&&typeof t.name=="string"&&typeof t.awaitHandlers=="boolean"};var k$=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;function Bj(e){return typeof e=="string"&&k$.test(e)}var Xc=Bj;function Vj(e){if(!Xc(e))throw TypeError("Invalid UUID");let t;return Uint8Array.of((t=parseInt(e.slice(0,8),16))>>>24,t>>>16&255,t>>>8&255,t&255,(t=parseInt(e.slice(9,13),16))>>>8,t&255,(t=parseInt(e.slice(14,18),16))>>>8,t&255,(t=parseInt(e.slice(19,23),16))>>>8,t&255,(t=parseInt(e.slice(24,36),16))/1099511627776&255,t/4294967296&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255)}var yd=Vj;var At=[];for(let e=0;e<256;++e)At.push((e+256).toString(16).slice(1));function os(e,t=0){return(At[e[t+0]]+At[e[t+1]]+At[e[t+2]]+At[e[t+3]]+"-"+At[e[t+4]]+At[e[t+5]]+"-"+At[e[t+6]]+At[e[t+7]]+"-"+At[e[t+8]]+At[e[t+9]]+"-"+At[e[t+10]]+At[e[t+11]]+At[e[t+12]]+At[e[t+13]]+At[e[t+14]]+At[e[t+15]]).toLowerCase()}var Zj=new Uint8Array(16);function ss(){return crypto.getRandomValues(Zj)}function Hj(e,t,r){return!t&&!e&&crypto.randomUUID?crypto.randomUUID():Gj(e,t,r)}function Gj(e,t,r){e=e||{};let i=e.random??e.rng?.()??ss();if(i.length<16)throw new Error("Random bytes length must be >= 16");if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){if(r=r||0,r<0||r+16>t.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let n=0;n<16;++n)t[r+n]=i[n];return t}return os(i)}var Ka=Hj;function Wj(e,t,r,i){switch(e){case 0:return t&r^~t&i;case 1:return t^r^i;case 2:return t&r^t&i^r&i;case 3:return t^r^i}}function ig(e,t){return e<<t|e>>>32-t}function Jj(e){let t=[1518500249,1859775393,2400959708,3395469782],r=[1732584193,4023233417,2562383102,271733878,3285377520],i=new Uint8Array(e.length+1);i.set(e),i[e.length]=128,e=i;let n=e.length/4+2,a=Math.ceil(n/16),o=new Array(a);for(let s=0;s<a;++s){let c=new Uint32Array(16);for(let l=0;l<16;++l)c[l]=e[s*64+l*4]<<24|e[s*64+l*4+1]<<16|e[s*64+l*4+2]<<8|e[s*64+l*4+3];o[s]=c}o[a-1][14]=(e.length-1)*8/2**32,o[a-1][14]=Math.floor(o[a-1][14]),o[a-1][15]=(e.length-1)*8&4294967295;for(let s=0;s<a;++s){let c=new Uint32Array(80);for(let m=0;m<16;++m)c[m]=o[s][m];for(let m=16;m<80;++m)c[m]=ig(c[m-3]^c[m-8]^c[m-14]^c[m-16],1);let l=r[0],u=r[1],d=r[2],f=r[3],p=r[4];for(let m=0;m<80;++m){let h=Math.floor(m/20),_=ig(l,5)+Wj(h,u,d,f)+p+t[h]+c[m]>>>0;p=f,f=d,d=ig(u,30)>>>0,u=l,l=_}r[0]=r[0]+l>>>0,r[1]=r[1]+u>>>0,r[2]=r[2]+d>>>0,r[3]=r[3]+f>>>0,r[4]=r[4]+p>>>0}return Uint8Array.of(r[0]>>24,r[0]>>16,r[0]>>8,r[0],r[1]>>24,r[1]>>16,r[1]>>8,r[1],r[2]>>24,r[2]>>16,r[2]>>8,r[2],r[3]>>24,r[3]>>16,r[3]>>8,r[3],r[4]>>24,r[4]>>16,r[4]>>8,r[4])}var $$=Jj;function Kj(e){e=unescape(encodeURIComponent(e));let t=new Uint8Array(e.length);for(let r=0;r<e.length;++r)t[r]=e.charCodeAt(r);return t}var ag="6ba7b810-9dad-11d1-80b4-00c04fd430c8",og="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function sg(e,t,r,i,n,a){let o=typeof r=="string"?Kj(r):r,s=typeof i=="string"?yd(i):i;if(typeof i=="string"&&(i=yd(i)),i?.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let c=new Uint8Array(16+o.length);if(c.set(s),c.set(o,s.length),c=t(c),c[6]=c[6]&15|e,c[8]=c[8]&63|128,n){if(a??=0,a<0||a+16>n.length)throw new RangeError(`UUID byte range ${a}:${a+15} is out of buffer bounds`);for(let l=0;l<16;++l)n[a+l]=c[l];return n}return os(c)}function cg(e,t,r,i){return sg(80,$$,e,t,r,i)}cg.DNS=ag;cg.URL=og;var lg=cg;var ug={};function qj(e,t,r){let i;if(e)i=E$(e.random??e.rng?.()??ss(),e.msecs,e.seq,t,r);else{let n=Date.now(),a=ss();Xj(ug,n,a),i=E$(a,ug.msecs,ug.seq,t,r)}return t??os(i)}function Xj(e,t,r){return e.msecs??=-1/0,e.seq??=0,t>e.msecs?(e.seq=r[6]<<23|r[7]<<16|r[8]<<8|r[9],e.msecs=t):(e.seq=e.seq+1|0,e.seq===0&&e.msecs++),e}function E$(e,t,r,i,n=0){if(e.length<16)throw new Error("Random bytes length must be >= 16");if(!i)i=new Uint8Array(16),n=0;else if(n<0||n+16>i.length)throw new RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);return t??=Date.now(),r??=e[6]*127<<24|e[7]<<16|e[8]<<8|e[9],i[n++]=t/1099511627776&255,i[n++]=t/4294967296&255,i[n++]=t/16777216&255,i[n++]=t/65536&255,i[n++]=t/256&255,i[n++]=t&255,i[n++]=112|r>>>28&15,i[n++]=r>>>20&255,i[n++]=128|r>>>14&63,i[n++]=r>>>6&255,i[n++]=r<<2&255|e[10]&3,i[n++]=e[11],i[n++]=e[12],i[n++]=e[13],i[n++]=e[14],i[n++]=e[15],i}var cs=qj;var I$="gen_ai.operation.name",T$="gen_ai.system",dg="gen_ai.request.model",C$="gen_ai.response.model",fg="gen_ai.usage.input_tokens",pg="gen_ai.usage.output_tokens",mg="gen_ai.usage.total_tokens",A$="gen_ai.request.max_tokens",O$="gen_ai.request.temperature",P$="gen_ai.request.top_p",N$="gen_ai.request.frequency_penalty",R$="gen_ai.request.presence_penalty",M$="gen_ai.response.finish_reasons",j$="gen_ai.prompt",z$="gen_ai.completion",D$="gen_ai.request.extra_query",U$="gen_ai.request.extra_body",L$="gen_ai.serialized.name",F$="gen_ai.serialized.signature",B$="gen_ai.serialized.doc",V$="gen_ai.response.id",Z$="gen_ai.response.service_tier",H$="gen_ai.response.system_fingerprint",G$="gen_ai.usage.input_token_details",W$="gen_ai.usage.output_token_details",J$="langsmith.trace.session_id",K$="langsmith.trace.session_name",q$="langsmith.span.kind",X$="langsmith.trace.name",Y$="langsmith.metadata",hg="langsmith.span.tags";var Q$="langsmith.request.streaming",eE="langsmith.request.headers";var gg="langsmith.usage_metadata";var e4=(...e)=>fetch(...e),t4,tE=Symbol.for("ls:fetch_implementation");var rE=()=>globalThis[tE]===void 0?!0:t4??!1,nE=e=>async(...t)=>{if(e||Fe("DEBUG")==="true"){let[i,n]=t;console.log(`\u2192 ${n?.method||"GET"} ${i}`)}let r=await(globalThis[tE]??e4)(...t);return(e||Fe("DEBUG")==="true")&&console.log(`\u2190 ${r.status} ${r.statusText} ${r.url}`),r};var Yc=()=>Fe("PROJECT")??Et("LANGCHAIN_SESSION")??"default";var iE={};function qa(e){iE[e]||(console.warn(e),iE[e]=!0)}var N=e=>BigInt(e),cE=N("0x9E3779B1"),lE=N("0x85EBCA77"),r4=N("0xC2B2AE3D"),Wi=N("0x9E3779B185EBCA87"),Xa=N("0xC2B2AE3D27D4EB4F"),uE=N("0x165667B19E3779F9"),bg=N("0x85EBCA77C2B2AE63"),n4=N("0x27D4EB2F165667C5"),i4=N("0x165667919E3779F9"),a4=N("0x9FB21C651E98DF25");function o4(e){let t=new Uint8Array(e.length/2);for(let r=0;r<e.length;r+=2)t[r/2]=parseInt(e.substring(r,r+2),16);return t}var jn=o4("b8fe6c3923a44bbe7c01812cf721ad1cded46de9839097db7240a4a4b7b3671fcb79e64eccc0e578825ad07dccff7221b8084674f743248ee03590e6813a264c3c2852bb91c300cb88d0658b1b532ea371644897a20df94e3819ef46a9deacd8a8fa763fe39c343ff9dcbbc7c70b4f1d8a51e04bcdb45931c89f7ec9d9787364eac5ac8334d3ebc3c581a0fffa1363eb170ddd51b7f0da49d316552629d4689e2b16be587d47a1fc8ff8b8d17ad031ce45cb3a8f95160428afd7fbcabb4b407e"),us=(N(1)<<N(128))-N(1),ye=(N(1)<<N(64))-N(1),xd=(N(1)<<N(32))-N(1),pi=64,dE=pi/8,s4=8,vd=4;function Be(e,t=0){return new Uint8Array(e.buffer,e.byteOffset+t,e.length-t)}function Ge(e,t=0){return new DataView(e.buffer,e.byteOffset+t).getBigUint64(0,!0)}function ls(e,t=0){return new DataView(e.buffer,e.byteOffset+t).getUint32(0,!0)}function _g(e,t=0){return e[t]}var c4=e=>(e&N(255))<<N(56)|(e&N(65280))<<N(40)|(e&N(16711680))<<N(24)|(e&N(4278190080))<<N(8)|(e&N(0xff00000000))>>N(8)|(e&N(0xff0000000000))>>N(24)|(e&N(0xff000000000000))>>N(40)|(e&N(0xff00000000000000))>>N(56),l4=e=>(e=(e&N(65535))<<N(16)|(e&N(4294901760))>>N(16),e=(e&N(16711935))<<N(8)|(e&N(4278255360))>>N(8),e),u4=(e,t)=>(e&xd)*(t&xd)&ye,ds=e=>{if(!e)throw new Error("Assert failed")};function d4(e,t){return(e<<t|e>>N(32)-t)&xd}function fE(e,t,r){for(let i=0;i<dE;i++){let n=Ge(t,i*8),a=n^Ge(r,i*8);e[i^1]+=n,e[i]+=u4(a,a>>N(32))}return e}function aE(e,t,r,i){for(let n=0;n<i;n++)fE(e,Be(t,n*pi),Be(r,n*8));return e}function f4(e,t){for(let r=0;r<dE;r++){let i=Ge(t,r*8),n=e[r];n=yg(n,N(47)),n^=i,n*=cE,e[r]=n&ye}return e}function bd(e,t){return pE(e[0]^Ge(t,0),e[1]^Ge(t,s4))}function oE(e,t,r){let i=r;return i+=bd(e.slice(0),Be(t,0*vd)),i+=bd(e.slice(2),Be(t,4*vd)),i+=bd(e.slice(4),Be(t,8*vd)),i+=bd(e.slice(6),Be(t,12*vd)),zn(i&ye)}function p4(e,t,r,i,n){let a=Math.floor((r.byteLength-pi)/8),o=pi*a,s=Math.floor((t.byteLength-1)/o);for(let c=0;c<s;c++)e=aE(e,Be(t,c*o),r,a),e=n(e,Be(r,r.byteLength-pi));{let c=Math.floor((t.byteLength-1-o*s)/pi);e=aE(e,Be(t,s*o),r,c),e=i(e,Be(t,t.byteLength-pi),Be(r,r.byteLength-pi-7))}return e}function m4(e,t,r){let i=new BigUint64Array([r4,Wi,Xa,uE,bg,lE,n4,cE]);ds(e.length>128),i=p4(i,e,t,fE,f4),ds(i.length*8==64);{let n=oE(i,Be(t,11),N(e.byteLength)*Wi&ye);return oE(i,Be(t,t.byteLength-pi-11),~(N(e.byteLength)*Xa)&ye)<<N(64)|n}}function pE(e,t){let r=e*t&us;return r&ye^r>>N(64)}function sE(e,t,r){return pE((Ge(e,0)^Ge(t,0)+r)&ye,(Ge(e,8)^Ge(t,8)-r)&ye)}function wd(e,t,r,i,n){let a=e&ye,o=e>>N(64)&ye;return a+=sE(t,i,n),a^=Ge(r,0)+Ge(r,8),a&=ye,o+=sE(r,Be(i,16),n),o^=Ge(t,0)+Ge(t,8),o&=ye,o<<N(64)|a}function zn(e){return e^=e>>N(37),e*=i4,e&=ye,e^=e>>N(32),e}function Sd(e){return e^=e>>N(33),e*=Xa,e&=ye,e^=e>>N(29),e*=uE,e&=ye,e^=e>>N(32),e}function h4(e,t,r){let i=e.byteLength;ds(i>0&&i<=3);let n=N(_g(e,i-1))|N(i<<8)|N(_g(e,0)<<16)|N(_g(e,i>>1)<<24),a=(N(ls(t,0))^N(ls(t,4)))+r,o=(n^a)&ye,s=(N(ls(t,8))^N(ls(t,12)))-r,c=(d4(l4(n),N(13))^s)&ye;return(Sd(c)&ye)<<N(64)|Sd(o)}function yg(e,t){return e^e>>t}function g4(e,t,r){let i=e.byteLength;ds(i>=4&&i<=8);{let n=ls(e,0),a=ls(e,i-4),o=N(n)|N(a)<<N(32),s=(Ge(t,16)^Ge(t,24))+r&ye,l=(o^s)*(Wi+(N(i)<<N(2)))&us;return l+=(l&ye)<<N(65),l&=us,l^=l>>N(67),yg(yg(l&ye,N(35))*a4&ye,N(28))|zn(l>>N(64))<<N(64)}}function _4(e,t,r){let i=e.byteLength;ds(i>=9&&i<=16);{let n=(Ge(t,32)^Ge(t,40))+r&ye,a=(Ge(t,48)^Ge(t,56))-r&ye,o=Ge(e),s=Ge(e,i-8),c=(o^s^n)*Wi,l=(c&ye)+(N(i-1)<<N(54));c=c&(us^ye)|l,s^=a,c+=s+(s&xd)*(lE-N(1))<<N(64),c&=us,c^=c4(c>>N(64));let u=(c&ye)*Xa;return u+=(c>>N(64))*Xa<<N(64),u&=us,zn(u&ye)|zn(u>>N(64))<<N(64)}}function y4(e,t){let r=e.byteLength;return ds(r<=16),r>8?_4(e,jn,t):r>=4?g4(e,jn,t):r>0?h4(e,jn,t):Sd(t^Ge(jn,64)^Ge(jn,72))|Sd(t^Ge(jn,80)^Ge(jn,88))<<N(64)}function vg(e){return~e+N(1)&ye}function v4(e,t,r){let i=N(e.byteLength)*Wi&ye,n=N(e.byteLength-1)/N(32);for(;n>=0;){let s=Number(n);i=wd(i,Be(e,16*s),Be(e,e.byteLength-16*(s+1)),Be(t,32*s),r),n--}let a=i+(i>>N(64))&ye;a=zn(a);let o=(i&ye)*Wi+(i>>N(64))*bg+(N(e.byteLength)-r&ye)*Xa;return o&=ye,o=vg(zn(o)),a|o<<N(64)}function b4(e,t,r){let i=N(e.byteLength)*Wi&ye;for(let o=32;o<160;o+=32)i=wd(i,Be(e,o-32),Be(e,o-16),Be(t,o-32),r);i=zn(i&ye)|zn(i>>N(64))<<N(64);for(let o=160;o<=e.byteLength;o+=32)i=wd(i,Be(e,o-32),Be(e,o-16),Be(t,3+o-160),r);i=wd(i,Be(e,e.byteLength-16),Be(e,e.byteLength-32),Be(t,103),vg(r));let n=i+(i>>N(64))&ye;n=zn(n);let a=(i&ye)*Wi+(i>>N(64))*bg+(N(e.byteLength)-r&ye)*Xa;return a&=ye,a=vg(zn(a)),n|a<<N(64)}function mE(e,t=N(0)){let r=e.byteLength;return r<=16?y4(e,t):r<=128?v4(e,jn,t):r<=240?b4(e,jn,t):m4(e,jn,t)}function hE(e){let t=new Uint8Array(16),r=new DataView(t.buffer),i=e&ye,n=e>>N(64);return r.setBigUint64(0,n,!1),r.setBigUint64(8,i,!1),t}var gE=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function pe(e,t){if(!gE.test(e)){let r=t!==void 0?`Invalid UUID for ${t}: ${e}`:`Invalid UUID: ${e}`;throw new Error(r)}return e}function kd(e){let t=typeof e=="string"?Date.parse(e):e;return cs({msecs:t,seq:0})}function w4(e){if(!gE.test(e))return null;let t=e[14];return parseInt(t,16)}function x4(e){let t=e.replace(/-/g,""),r=new Uint8Array(16);for(let i=0;i<16;i++)r[i]=parseInt(t.slice(i*2,i*2+2),16);return r}function S4(e){let t=Array.from(e).map(r=>r.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}var k4=new TextEncoder;function $4(e){let t=k4.encode(e),r=mE(t);return hE(r)}function Qc(e,t){let r=`${e}:${t}`,i=$4(r),n=new Uint8Array(16);if(w4(e)===7){let o=x4(e);n.set(o.slice(0,6),0)}else{let o=Date.now();n[0]=o/1099511627776&255,n[1]=o/4294967296&255,n[2]=o/16777216&255,n[3]=o/65536&255,n[4]=o/256&255,n[5]=o&255}return n[6]=112|i[0]&15,n[7]=i[1],n[8]=128|i[2]&63,n.set(i.slice(3,10),9),S4(n)}var on={join:(...e)=>e.join("/"),dirname:e=>e.split("/").slice(0,-1).join("/")};async function $d(e){}async function fs(e,t){}async function _E(e){return[]}async function yE(e){return{size:0}}function ps(e){return!1}function Ya(e){return""}async function vE(e){}async function Ed(e){}function E4(e,t){return t===null?!1:Date.now()-e.createdAt>t*1e3}var Id=class{constructor(t={}){Object.defineProperty(this,"cache",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ttlSeconds",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"refreshIntervalSeconds",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"refreshTimer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_metrics",{enumerable:!0,configurable:!0,writable:!0,value:{hits:0,misses:0,refreshes:0,refreshErrors:0}}),this.configure(t)}get metrics(){return{...this._metrics}}get totalRequests(){return this._metrics.hits+this._metrics.misses}get hitRate(){let t=this.totalRequests;return t>0?this._metrics.hits/t:0}resetMetrics(){this._metrics={hits:0,misses:0,refreshes:0,refreshErrors:0}}get(t,r){if(this.maxSize===0)return;let i=this.cache.get(t);if(!i){this._metrics.misses+=1;return}return this.cache.delete(t),this.cache.set(t,{...i,refreshFunc:r}),this._metrics.hits+=1,i.value}set(t,r,i){if(this.maxSize===0)return;if(this.refreshTimer===void 0&&this.startRefreshLoop(),!this.cache.has(t)&&this.cache.size>=this.maxSize){let a=this.cache.keys().next().value;a!==void 0&&this.cache.delete(a)}let n={value:r,createdAt:Date.now(),refreshFunc:i};this.cache.delete(t),this.cache.set(t,n)}invalidate(t){this.cache.delete(t)}clear(){this.cache.clear()}get size(){return this.cache.size}stop(){this.refreshTimer&&(clearInterval(this.refreshTimer),this.refreshTimer=void 0)}dump(t){let r={};for(let[a,o]of this.cache.entries())r[a]=o.value;let i=on.dirname(t);ps(i)||void 0;let n=`${t}.tmp`;try{JSON.stringify({entries:r},null,2)}catch(a){throw ps(n)&&void 0,a}}load(t){if(!ps(t))return 0;let r;try{let a=Ya(t);r=JSON.parse(a).entries??null}catch{return 0}if(!r)return 0;let i=0,n=Date.now();for(let[a,o]of Object.entries(r)){if(this.cache.size>=this.maxSize)break;let s={value:o,createdAt:n};this.cache.set(a,s),i+=1}return i}startRefreshLoop(){this.stop(),this.ttlSeconds!==null&&(this.refreshTimer=setInterval(()=>{this.refreshStaleEntries().catch(t=>{console.warn("Unexpected error in cache refresh loop:",t)})},this.refreshIntervalSeconds*1e3),this.refreshTimer.unref&&this.refreshTimer.unref())}getStaleEntries(){let t=[];for(let[r,i]of this.cache.entries())E4(i,this.ttlSeconds)&&t.push([r,i]);return t}async refreshStaleEntries(){let t=this.getStaleEntries();if(t.length!==0){for(let[r,i]of t)if(i.refreshFunc!==void 0)try{let n=await i.refreshFunc();this.set(r,n,i.refreshFunc),this._metrics.refreshes+=1}catch(n){this._metrics.refreshErrors+=1,console.warn(`Failed to refresh cache entry ${r}:`,n)}}}configure(t){this.stop(),this.refreshIntervalSeconds=t.refreshIntervalSeconds??60,this.maxSize=t.maxSize??100,this.ttlSeconds=t.ttlSeconds??300}},Td=new Id;var Cd="0.7.8";var Un,I4=()=>typeof window<"u"&&typeof window.document<"u",T4=()=>typeof globalThis=="object"&&globalThis.constructor&&globalThis.constructor.name==="DedicatedWorkerGlobalScope",C4=()=>typeof window<"u"&&window.name==="nodejs"||typeof navigator<"u"&&navigator.userAgent.includes("jsdom"),xE=()=>typeof Deno<"u",A4=()=>typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"&&!xE(),el=()=>Un||(typeof Bun<"u"?Un="bun":I4()?Un="browser":A4()?Un="node":T4()?Un="webworker":C4()?Un="jsdom":xE()?Un="deno":Un="other",Un),xg;function Ad(){if(xg===void 0){let e=el(),t=P4();xg={library:"langsmith",runtime:e,sdk:"langsmith-js",sdk_version:Cd,...t}}return xg}function kg(){let e=O4(),t={},r=["LANGCHAIN_API_KEY","LANGCHAIN_ENDPOINT","LANGCHAIN_TRACING_V2","LANGCHAIN_PROJECT","LANGCHAIN_SESSION","LANGSMITH_API_KEY","LANGSMITH_ENDPOINT","LANGSMITH_TRACING_V2","LANGSMITH_CONFIG_FILE","LANGSMITH_PROJECT","LANGSMITH_SESSION"];for(let[i,n]of Object.entries(e))typeof n=="string"&&!r.includes(i)&&!i.toLowerCase().includes("key")&&!i.toLowerCase().includes("secret")&&!i.toLowerCase().includes("token")&&(i==="LANGCHAIN_REVISION_ID"?t.revision_id=n:t[i]=n);return t}function O4(){let e={};try{if(typeof process<"u"&&process.env)for(let[t,r]of Object.entries(process.env))(t.startsWith("LANGCHAIN_")||t.startsWith("LANGSMITH_"))&&r!=null&&((t.toLowerCase().includes("key")||t.toLowerCase().includes("secret")||t.toLowerCase().includes("token"))&&typeof r=="string"?e[t]=r.slice(0,2)+"*".repeat(r.length-4)+r.slice(-2):e[t]=r)}catch{}return e}function Et(e){try{return typeof process<"u"?process.env?.[e]:void 0}catch{return}}function Fe(e){return Et(`LANGSMITH_${e}`)||Et(`LANGCHAIN_${e}`)}var Sg;function P4(){if(Sg!==void 0)return Sg;let e=["VERCEL_GIT_COMMIT_SHA","NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA","COMMIT_REF","RENDER_GIT_COMMIT","CI_COMMIT_SHA","CIRCLE_SHA1","CF_PAGES_COMMIT_SHA","REACT_APP_GIT_SHA","SOURCE_VERSION","GITHUB_SHA","TRAVIS_COMMIT","GIT_COMMIT","BUILD_VCS_NUMBER","bamboo_planRepository_revision","Build.SourceVersion","BITBUCKET_COMMIT","DRONE_COMMIT_SHA","SEMAPHORE_GIT_SHA","BUILDKITE_COMMIT"],t={};for(let r of e){let i=Et(r);i!==void 0&&(t[r]=i)}return Sg=t,t}function bE(){return Et("OTEL_ENABLED")==="true"||Fe("OTEL_ENABLED")==="true"}var wE=new Set(["langsmith","otel"]);function Od(e){if(e!==void 0)return e;let t=Fe("TRACING_MODE");if(t!==void 0&&t!==""){let r=t.toLowerCase();if(!wE.has(r))throw new Error(`Invalid LANGSMITH_TRACING_MODE=${JSON.stringify(t)}. Must be one of: ${[...wE].sort().join(", ")}`);return bE()&&console.warn("Both LANGSMITH_TRACING_MODE and the legacy OTEL_ENABLED / LANGSMITH_OTEL_ENABLED env vars are set. LANGSMITH_TRACING_MODE takes precedence."),r}return bE()?"otel":"langsmith"}var Ig=class{constructor(){Object.defineProperty(this,"hasWarned",{enumerable:!0,configurable:!0,writable:!0,value:!1})}startActiveSpan(t,...r){!this.hasWarned&&Od()==="otel"&&(console.warn('OTel tracing mode is active (via LANGSMITH_TRACING_MODE, OTEL_ENABLED, or LANGSMITH_OTEL_ENABLED), but the required OTEL instances have not been initialized. Please add:\n```\nimport { initializeOTEL } from "langsmith/experimental/otel/setup";\ninitializeOTEL();\n```\nat the beginning of your code.'),this.hasWarned=!0);let i;if(r.length===1&&typeof r[0]=="function"?i=r[0]:r.length===2&&typeof r[1]=="function"?i=r[1]:r.length===3&&typeof r[2]=="function"&&(i=r[2]),typeof i=="function")return i()}},Tg=class{constructor(){Object.defineProperty(this,"mockTracer",{enumerable:!0,configurable:!0,writable:!0,value:new Ig})}getTracer(t,r){return this.mockTracer}getActiveSpan(){}setSpan(t,r){return t}getSpan(t){}setSpanContext(t,r){return t}getTracerProvider(){}setGlobalTracerProvider(t){return!1}},Cg=class{active(){return{}}with(t,r){return r()}},$g=Symbol.for("ls:otel_trace"),Eg=Symbol.for("ls:otel_context"),SE=Symbol.for("ls:otel_get_default_otlp_tracer_provider"),N4=new Tg,R4=new Cg,Ag=class{getTraceInstance(){return globalThis[$g]??N4}getContextInstance(){return globalThis[Eg]??R4}initializeGlobalInstances(t){globalThis[$g]===void 0&&(globalThis[$g]=t.trace),globalThis[Eg]===void 0&&(globalThis[Eg]=t.context)}setDefaultOTLPTracerComponents(t){globalThis[SE]=t}getDefaultOTLPTracerComponents(){return globalThis[SE]??void 0}},Og=new Ag;function Pd(){return Og.getTraceInstance()}function kE(){return Og.getContextInstance()}function $E(){return Og.getDefaultOTLPTracerComponents()}var M4={llm:"chat",tool:"execute_tool",retriever:"embeddings",embedding:"embeddings",prompt:"chat"};function j4(e){return M4[e]||e}function z4(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"}var Nd=class{constructor(){Object.defineProperty(this,"spans",{enumerable:!0,configurable:!0,writable:!0,value:new Map})}exportBatch(t,r){for(let i of t)try{if(!i.run)continue;if(i.operation==="post"){let n=this.createSpanForRun(i,i.run,r.get(i.id));n&&!i.run.end_time&&this.spans.set(i.id,n)}else this.updateSpanForRun(i,i.run)}catch(n){console.error(`Error processing operation ${i.id}:`,n)}}createSpanForRun(t,r,i){let n=i&&Pd().getSpan(i);if(n)try{return this.finishSpanSetup(n,r,t)}catch(a){console.error(`Failed to create span for run ${t.id}:`,a);return}}finishSpanSetup(t,r,i){return this.setSpanAttributes(t,r,i),r.error?(t.setStatus({code:2}),t.recordException(new Error(r.error))):t.setStatus({code:1}),r.end_time&&t.end(new Date(r.end_time)),t}updateSpanForRun(t,r){try{let i=this.spans.get(t.id);if(!i){console.debug(`No span found for run ${t.id} during update`);return}this.setSpanAttributes(i,r,t),r.error?(i.setStatus({code:2}),i.recordException(new Error(r.error))):i.setStatus({code:1});let n=r.end_time;n&&(i.end(new Date(n)),this.spans.delete(t.id))}catch(i){console.error(`Failed to update span for run ${t.id}:`,i)}}extractModelName(t){if(t.extra?.metadata){let r=t.extra.metadata;if(r.ls_model_name)return r.ls_model_name;if(r.invocation_params){let i=r.invocation_params;if(i.model)return i.model;if(i.model_name)return i.model_name}}}setSpanAttributes(t,r,i){if("run_type"in r&&r.run_type){t.setAttribute(q$,r.run_type);let s=j4(r.run_type||"chain");t.setAttribute(I$,s)}"name"in r&&r.name&&t.setAttribute(X$,r.name),"session_id"in r&&r.session_id&&t.setAttribute(J$,r.session_id),"session_name"in r&&r.session_name&&t.setAttribute(K$,r.session_name),this.setGenAiSystem(t,r);let n=this.extractModelName(r);n&&t.setAttribute(dg,n),r.extra?.metadata?.usage_metadata&&typeof r.extra.metadata.usage_metadata=="object"&&t.setAttribute(gg,JSON.stringify(r.extra.metadata.usage_metadata)),"prompt_tokens"in r&&typeof r.prompt_tokens=="number"&&t.setAttribute(fg,r.prompt_tokens),"completion_tokens"in r&&typeof r.completion_tokens=="number"&&t.setAttribute(pg,r.completion_tokens),"total_tokens"in r&&typeof r.total_tokens=="number"&&t.setAttribute(mg,r.total_tokens),this.setInvocationParameters(t,r);let a=r.extra?.metadata||{};for(let[s,c]of Object.entries(a))c!=null&&t.setAttribute(`${Y$}.${s}`,z4(c)?String(c):JSON.stringify(c));let o=r.tags;if(o&&Array.isArray(o)?t.setAttribute(hg,o.join(", ")):o&&t.setAttribute(hg,String(o)),"serialized"in r&&typeof r.serialized=="object"){let s=r.serialized;s.name&&t.setAttribute(L$,String(s.name)),s.signature&&t.setAttribute(F$,String(s.signature)),s.doc&&t.setAttribute(B$,String(s.doc))}this.setIOAttributes(t,i)}setGenAiSystem(t,r){let i="langchain",n=this.extractModelName(r);if(n){let a=n.toLowerCase();a.includes("anthropic")||a.startsWith("claude")?i="anthropic":a.includes("bedrock")?i="aws.bedrock":a.includes("azure")&&a.includes("openai")?i="az.ai.openai":a.includes("azure")&&a.includes("inference")?i="az.ai.inference":a.includes("cohere")?i="cohere":a.includes("deepseek")?i="deepseek":a.includes("gemini")?i="gemini":a.includes("groq")?i="groq":a.includes("watson")||a.includes("ibm")?i="ibm.watsonx.ai":a.includes("mistral")?i="mistral_ai":a.includes("gpt")||a.includes("openai")?i="openai":a.includes("perplexity")||a.includes("sonar")?i="perplexity":a.includes("vertex")?i="vertex_ai":(a.includes("xai")||a.includes("grok"))&&(i="xai")}t.setAttribute(T$,i)}setInvocationParameters(t,r){if(!r.extra?.metadata?.invocation_params)return;let i=r.extra.metadata.invocation_params;i.max_tokens!==void 0&&t.setAttribute(A$,i.max_tokens),i.temperature!==void 0&&t.setAttribute(O$,i.temperature),i.top_p!==void 0&&t.setAttribute(P$,i.top_p),i.frequency_penalty!==void 0&&t.setAttribute(N$,i.frequency_penalty),i.presence_penalty!==void 0&&t.setAttribute(R$,i.presence_penalty)}setIOAttributes(t,r){if(r.run.inputs)try{let i=r.run.inputs;typeof i=="object"&&i!==null&&(i.model&&Array.isArray(i.messages)&&t.setAttribute(dg,i.model),i.stream!==void 0&&t.setAttribute(Q$,i.stream),i.extra_headers&&t.setAttribute(eE,JSON.stringify(i.extra_headers)),i.extra_query&&t.setAttribute(D$,JSON.stringify(i.extra_query)),i.extra_body&&t.setAttribute(U$,JSON.stringify(i.extra_body))),t.setAttribute(j$,JSON.stringify(i))}catch(i){console.debug(`Failed to process inputs for run ${r.id}`,i)}if(r.run.outputs)try{let i=r.run.outputs,n=this.getUnifiedRunTokens(i);if(n&&(t.setAttribute(fg,n[0]),t.setAttribute(pg,n[1]),t.setAttribute(mg,n[0]+n[1])),i&&typeof i=="object"){if(i.model&&t.setAttribute(C$,String(i.model)),i.id&&t.setAttribute(V$,i.id),i.choices&&Array.isArray(i.choices)){let a=i.choices.map(o=>o.finish_reason).filter(o=>o).map(String);a.length>0&&t.setAttribute(M$,a.join(", "))}if(i.service_tier&&t.setAttribute(Z$,i.service_tier),i.system_fingerprint&&t.setAttribute(H$,i.system_fingerprint),i.usage_metadata&&typeof i.usage_metadata=="object"){let a=i.usage_metadata;t.setAttribute(gg,JSON.stringify(a)),a.input_token_details&&t.setAttribute(G$,JSON.stringify(a.input_token_details)),a.output_token_details&&t.setAttribute(W$,JSON.stringify(a.output_token_details))}}t.setAttribute(z$,JSON.stringify(i))}catch(i){console.debug(`Failed to process outputs for run ${r.id}`,i)}}getUnifiedRunTokens(t){if(!t)return null;let r=this.extractUnifiedRunTokens(t.usage_metadata);if(r)return r;let i=Object.keys(t);for(let o of i){let s=t[o];if(!(!s||typeof s!="object")&&(r=this.extractUnifiedRunTokens(s.usage_metadata),r||s.lc===1&&s.kwargs&&typeof s.kwargs=="object"&&(r=this.extractUnifiedRunTokens(s.kwargs.usage_metadata),r)))return r}let n=t.generations||[];if(!Array.isArray(n))return null;let a=Array.isArray(n[0])?n.flat():n;for(let o of a)if(typeof o=="object"&&o.message&&typeof o.message=="object"&&o.message.kwargs&&typeof o.message.kwargs=="object"&&(r=this.extractUnifiedRunTokens(o.message.kwargs.usage_metadata),r))return r;return null}extractUnifiedRunTokens(t){return!t||typeof t!="object"||typeof t.input_tokens!="number"||typeof t.output_tokens!="number"?null:[t.input_tokens,t.output_tokens]}};var D4=Object.prototype.toString,U4=e=>D4.call(e)==="[object Error]",L4=new Set(["network error","Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed","fetch failed","terminated"," A network error occurred.","Network connection lost"]);function Pg(e){if(!(e&&U4(e)&&e.name==="TypeError"&&typeof e.message=="string"))return!1;let{message:r,stack:i}=e;return r==="Load failed"?i===void 0||"__sentry_captured__"in e:r.startsWith("error sending request for url")?!0:L4.has(r)}function F4(e){if(typeof e=="number"){if(e<0)throw new TypeError("Expected `retries` to be a non-negative number.");if(Number.isNaN(e))throw new TypeError("Expected `retries` to be a valid number or Infinity, got NaN.")}else if(e!==void 0)throw new TypeError("Expected `retries` to be a number or Infinity.")}function Rd(e,t,{min:r=0,allowInfinity:i=!1}={}){if(t!==void 0){if(typeof t!="number"||Number.isNaN(t))throw new TypeError(`Expected \`${e}\` to be a number${i?" or Infinity":""}.`);if(!i&&!Number.isFinite(t))throw new TypeError(`Expected \`${e}\` to be a finite number.`);if(t<r)throw new TypeError(`Expected \`${e}\` to be \u2265 ${r}.`)}}var Ng=class extends Error{constructor(t){super(),t instanceof Error?(this.originalError=t,{message:t}=t):(this.originalError=new Error(t),this.originalError.stack=this.stack),this.name="AbortError",this.message=t}};function B4(e,t){let r=Math.max(1,e+1),i=t.randomize?Math.random()+1:1,n=Math.round(i*t.minTimeout*t.factor**(r-1));return n=Math.min(n,t.maxTimeout),n}function EE(e,t){return Number.isFinite(t)?t-(performance.now()-e):t}async function V4({error:e,attemptNumber:t,retriesConsumed:r,startTime:i,options:n}){let a=e instanceof Error?e:new TypeError(`Non-error was thrown: "${e}". You should only throw errors.`);if(a instanceof Ng)throw a.originalError;let o=Number.isFinite(n.retries)?Math.max(0,n.retries-r):n.retries,s=n.maxRetryTime??Number.POSITIVE_INFINITY,c=Object.freeze({error:a,attemptNumber:t,retriesLeft:o,retriesConsumed:r});if(await n.onFailedAttempt(c),EE(i,s)<=0)throw a;let l=await n.shouldConsumeRetry(c),u=EE(i,s);if(u<=0||o<=0)throw a;if(a instanceof TypeError&&!Pg(a)){if(l)throw a;return n.signal?.throwIfAborted(),!1}if(!await n.shouldRetry(c))throw a;if(!l)return n.signal?.throwIfAborted(),!1;let d=B4(r,n),f=Math.min(d,u);return f>0&&await new Promise((p,m)=>{let h=()=>{clearTimeout(_),n.signal?.removeEventListener("abort",h),m(n.signal.reason)},_=setTimeout(()=>{n.signal?.removeEventListener("abort",h),p()},f);n.unref&&_.unref?.(),n.signal?.addEventListener("abort",h,{once:!0})}),n.signal?.throwIfAborted(),!0}async function Rg(e,t={}){if(t={...t},F4(t.retries),Object.hasOwn(t,"forever"))throw new Error("The `forever` option is no longer supported. For many use-cases, you can set `retries: Infinity` instead.");t.retries??=10,t.factor??=2,t.minTimeout??=1e3,t.maxTimeout??=Number.POSITIVE_INFINITY,t.maxRetryTime??=Number.POSITIVE_INFINITY,t.randomize??=!1,t.onFailedAttempt??=()=>{},t.shouldRetry??=()=>!0,t.shouldConsumeRetry??=()=>!0,Rd("factor",t.factor,{min:0,allowInfinity:!1}),Rd("minTimeout",t.minTimeout,{min:0,allowInfinity:!1}),Rd("maxTimeout",t.maxTimeout,{min:0,allowInfinity:!0}),Rd("maxRetryTime",t.maxRetryTime,{min:0,allowInfinity:!0}),t.factor>0||(t.factor=1),t.signal?.throwIfAborted();let r=0,i=0,n=performance.now();for(;!Number.isFinite(t.retries)||i<=t.retries;){r++;try{t.signal?.throwIfAborted();let a=await e(r);return t.signal?.throwIfAborted(),a}catch(a){await V4({error:a,attemptNumber:r,retriesConsumed:i,startTime:n,options:t})&&i++}}throw new Error("Retry attempts exhausted without throwing an error.")}var Ld=zu(Ud(),1),jE="default"in Ld.default?Ld.default.default:Ld.default;var Y4=[408,425,429,500,502,503,504],rl=class{constructor(t){Object.defineProperty(this,"maxConcurrency",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"maxRetries",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"maxQueueSizeBytes",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"queue",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onFailedResponseHook",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"queueSizeBytes",{enumerable:!0,configurable:!0,writable:!0,value:0}),this.maxConcurrency=t.maxConcurrency??1/0,this.maxRetries=t.maxRetries??6,this.maxQueueSizeBytes=t.maxQueueSizeBytes,this.queue=new jE({concurrency:this.maxConcurrency}),this.onFailedResponseHook=t?.onFailedResponseHook}call(t,...r){return this.callWithOptions({},t,...r)}callWithOptions(t,r,...i){let n=t.sizeBytes??0;if(this.maxQueueSizeBytes!==void 0&&n>0&&this.queueSizeBytes+n>this.maxQueueSizeBytes)return Promise.reject(new Error(`Queue size limit (${this.maxQueueSizeBytes} bytes) exceeded. Current queue size: ${this.queueSizeBytes} bytes, attempted addition: ${n} bytes.`));n>0&&(this.queueSizeBytes+=n);let a=this.onFailedResponseHook,o=this.queue.add(()=>Rg(()=>r(...i).catch(s=>{throw s instanceof Error?s:new Error(s)}),{async onFailedAttempt({error:s}){if(typeof s!="object"||s==null)throw s;let c="message"in s&&typeof s.message=="string"?s.message:void 0;if(c?.startsWith("Cancel")||c?.startsWith("TimeoutError")||c?.startsWith("AbortError")||"name"in s&&s.name==="TimeoutError"||"code"in s&&s.code==="ECONNABORTED")throw s;let l="response"in s?s.response:void 0;if(a&&await a(l))return;let u=l?.status??("status"in s?s.status:void 0);if(u!=null&&(typeof u=="number"||typeof u=="string")&&!Y4.includes(+u))throw s},retries:this.maxRetries,randomize:!0}),{throwOnTimeout:!0});return n>0&&(o=o.finally(()=>{this.queueSizeBytes-=n})),t.signal?Promise.race([o,new Promise((s,c)=>{t.signal?.addEventListener("abort",()=>{c(new Error("AbortError"))})})]):o}};function Fg(e){return typeof e?._getType=="function"}function Bg(e){let t={type:e._getType(),data:{content:e.content}};return e?.additional_kwargs&&Object.keys(e.additional_kwargs).length>0&&(t.data.additional_kwargs={...e.additional_kwargs}),t}function Bd(e){return`Invalid prompt identifier format: "${e}". Expected one of:
22
- - "prompt-name" (for private prompts)
23
- - "owner/prompt-name" (for prompts with explicit owner)
24
- - "prompt-name:commit-hash" (with commit reference)
25
- - "owner/prompt-name:commit-hash" (with owner and commit)`}var Vg=class extends Error{constructor(t){super(t),Object.defineProperty(this,"status",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name="LangSmithConflictError",this.status=409}},Zg=class extends Error{constructor(t){super(t),Object.defineProperty(this,"status",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name="LangSmithNotFoundError",this.status=404}};function Vd(e){return e!=null&&typeof e=="object"&&"name"in e&&e?.name==="LangSmithNotFoundError"}function zE(e){return e!=null&&typeof e=="object"&&"name"in e&&e?.name==="LangSmithConflictError"}async function Q(e,t,r){let i;if(e.ok){r&&(i=await e.text());return}if(e.status===403)try{(await e.json())?.error==="org_scoped_key_requires_workspace"&&(i="This API key is org-scoped and requires workspace specification. Please provide 'workspaceId' parameter, or set LANGSMITH_WORKSPACE_ID environment variable.")}catch{let s=new Error(`${e.status} ${e.statusText}`);throw s.status=e?.status,s}if(i===void 0)try{i=await e.text()}catch{i=""}let n=`Failed to ${t}. Received status [${e.status}]: ${e.statusText}. Message: ${i}`;if(e.status===404)throw new Zg(n);if(e.status===409)throw new Vg(n);let a=new Error(n);throw a.status=e.status,a}var DE="ERR_CONFLICTING_ENDPOINTS",Fd=class extends Error{constructor(){super("You cannot provide both LANGSMITH_ENDPOINT / LANGCHAIN_ENDPOINT and LANGSMITH_RUNS_ENDPOINTS."),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:DE}),this.name="ConflictingEndpointsError"}};function UE(e){return typeof e=="object"&&e!==null&&e.code===DE}function Ut(e){if(!e||e.split("/").length>2||e.startsWith("/")||e.endsWith("/")||e.split(":").length>2)throw new Error(Bd(e));let[t,r]=e.split(":"),i=r||"latest";if(t.includes("/")){let[n,a]=t.split("/",2);if(!n||!a)throw new Error(Bd(e));return[n,a,i]}else{if(!t)throw new Error(Bd(e));return["-",t,i]}}var Q4=10,ez=1e4,LE="created_at";function tz(e){return new Promise(t=>setTimeout(t,e))}function rz(e){return typeof e=="object"&&e!==null&&e.code==="EEXIST"}function FE(e){try{return Ya(on.join(e,LE)).split(`
26
- `)}catch{return}}function nz(e){let t=FE(e);if(t&&t[0]&&t[0].trim()){let r=Date.parse(t[0].trim());if(!Number.isNaN(r))return r}return void 0}function iz(e){let t=FE(e);if(t&&t.length>=2&&t[1].trim())return t[1].trim()}async function az(e){let t=nz(e);return t===void 0||Date.now()-t<=ez?!1:(await Ed(e),!0)}async function BE(e,t){let r=`${e}.oauth.lock.lock`,i=on.dirname(r);i&&await $d(i);let n=globalThis.crypto.randomUUID();for(;;){try{await vE(r)}catch(a){if(!rz(a))throw a;if(!await az(r)){if(Date.now()>=t)throw new Error("timed out acquiring OAuth refresh lock");await tz(Math.min(Q4,Math.max(0,t-Date.now())))}continue}try{await fs(on.join(r,LE),`${new Date().toISOString()}
27
- ${n}
28
- `)}catch(a){throw await Ed(r),a}break}return{async release(){iz(r)===n&&await Ed(r)}}}var Zd="https://api.smith.langchain.com",oz="langsmith-cli",sz=6e4,cz=1e4;function lz(){let e=el();return e==="browser"||e==="webworker"}function uz(){let e=Et("LANGSMITH_CONFIG_FILE");if(e)return e;let t=Et("HOME")??Et("USERPROFILE");if(t)return on.join(t,".langsmith","config.json")}function dz(e){let t=Et("LANGSMITH_PROFILE");if(t)return t;if(e.current_profile)return e.current_profile;if(e.profiles?.default)return"default"}function fz(){if(lz())return;let e=uz();if(!(!e||!ps(e)))try{let t=JSON.parse(Ya(e)),r=dz(t),i=r?t.profiles?.[r]:void 0;return!r||!i?void 0:{configPath:e,config:t,profileName:r,profile:i}}catch{return}}function Fr(e){return e!=null&&e.trim()!==""}function Ji(e){return e?.trim().replace(/^["']|["']$/g,"")}function VE(e){let t=e.oauth;if(!t?.refresh_token)return!1;if(!t.access_token)return!0;if(!t.expires_at)return!1;let r=Date.parse(t.expires_at);return Number.isNaN(r)?!1:r<=Date.now()+sz}function pz(e){let t=e;for(;t.endsWith("/");)t=t.slice(0,-1);let r="/api/v1";return t.endsWith(r)?t.slice(0,-r.length):t}function mz(e,t){e.oauth??={},t.access_token&&(e.oauth.access_token=t.access_token),t.refresh_token&&(e.oauth.refresh_token=t.refresh_token),typeof t.expires_in=="number"&&t.expires_in>0&&(e.oauth.expires_at=new Date(Date.now()+t.expires_in*1e3).toISOString())}function ZE(e){return e.reason??new Error("The operation was aborted.")}async function hz(e,t){if(!t)return e;if(t.aborted)throw ZE(t);let r,i=new Promise((n,a)=>{let o=()=>{a(ZE(t))};t.addEventListener("abort",o,{once:!0}),r=()=>{t.removeEventListener("abort",o)}});try{return await Promise.race([e,i])}finally{r?.()}}function HE(){let e=fz(),t=e?.profile;if(!e||!t)return{};let r=Ji(t.api_key),i=Ji(t.oauth?.access_token),n=Ji(t.oauth?.refresh_token);return{apiUrl:t.api_url,apiKey:r,workspaceId:t.workspace_id,oauthAccessToken:i,oauthRefreshToken:n,profileAuth:r||i||n?new Hg(e):void 0}}var Hg=class{constructor(t){Object.defineProperty(this,"state",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"refreshPromise",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"managedAuthorizationValue",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.rememberProfileAuthHeader(this.currentAuthHeader())}currentAuthHeader(){let t=gz(this.state.profile);return this.rememberProfileAuthHeader(t),t}async getAuthHeader(t,r){VE(this.state.profile)&&(this.refreshPromise||(this.refreshPromise=this.refreshOAuthToken(t).finally(()=>{this.refreshPromise=void 0})),await hz(this.refreshPromise,r));let i=GE(this.state.profile);return this.rememberProfileAuthHeader(i),i}isProfileAuthorizationHeader(t){return t===this.managedAuthorizationValue}reloadProfile(){try{let t=JSON.parse(Ya(this.state.configPath)),r=t.profiles?.[this.state.profileName];return r?(this.state.config=t,this.state.profile=r,r):void 0}catch{return}}async refreshOAuthToken(t){let r=this.state.profile.oauth?.refresh_token;if(!r)return;let i=Ji(this.state.profile.api_url)??Zd,n=Date.now()+cz,a;try{if(a=await BE(this.state.configPath,n),this.reloadProfile()&&!VE(this.state.profile))return;let s=new URLSearchParams({grant_type:"refresh_token",client_id:oz,refresh_token:this.state.profile.oauth?.refresh_token??r}),c=await t(`${pz(i)}/oauth/token`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s.toString(),signal:AbortSignal.timeout(Math.max(0,n-Date.now()))});if(!c.ok)return;let l=await c.json();if(!l.access_token)return;mz(this.state.profile,l),this.state.config.profiles??={},this.state.config.profiles[this.state.profileName]=this.state.profile,await fs(this.state.configPath,`${JSON.stringify(this.state.config,null,2)}
29
- `)}catch{return}finally{await a?.release()}}rememberProfileAuthHeader(t){this.managedAuthorizationValue=t?.name==="Authorization"?t.value:void 0}};function gz(e){let t=Ji(e.oauth?.access_token);if(t)return{name:"Authorization",value:`Bearer ${t}`};if(!Ji(e.oauth?.refresh_token))return GE(e)}function GE(e){let t=Ji(e.oauth?.access_token);if(t)return{name:"Authorization",value:`Bearer ${t}`};let r=Ji(e.api_key);if(r)return{name:"x-api-key",value:r}}var WE="[...]",_z={result:"[Circular]"},Gd=[],ms=[],yz=new TextEncoder;function vz(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function Hd(e){return yz.encode(e)}function JE(e){if(e&&typeof e=="object"&&e!==null){if(e instanceof Map)return Object.fromEntries(e);if(e instanceof Set)return Array.from(e);if(e instanceof Date)return e.toISOString();if(e instanceof RegExp)return e.toString();if(e instanceof Error)return{name:e.name,message:e.message}}else if(typeof e=="bigint")return e.toString();return e}function bz(e){return function(t,r){if(e){let i=e.call(this,t,r);if(i!==void 0)return i}return JE(r)}}function KE(e){try{let n=function(u){let d=i(u);return d>r&&(r=d),d+2},a=function(u){return u===0?2:2+u*4},o=function(u){return u===void 0||typeof u=="function"||typeof u=="symbol"},s=function(u){return u===void 0||typeof u=="function"||typeof u=="symbol"?4:c(u)},c=function(u){if(u===null)return 4;if(u===void 0)return 0;let d=typeof u;if(d==="boolean")return 5;if(d==="number")return Number.isFinite(u)?u.toString().length:4;if(d==="bigint")return u.toString().length+2;if(d==="string")return n(u);if(d==="function"||d==="symbol")return 0;let f=u;if(f instanceof Date)return 26;if(f instanceof RegExp)return i(f.toString())+2;if(f instanceof Error){let m=f.name??"",h=f.message??"";return 22+i(m)+i(h)}if(typeof Buffer<"u"&&f instanceof Buffer)return 28+a(f.byteLength);if(ArrayBuffer.isView(f)){if(f instanceof DataView)return 2;let m=f.length??0,_=f instanceof Float32Array||f instanceof Float64Array?30:12;return 2+m*_}if(f instanceof ArrayBuffer)return 2;if(t.has(f))return 24;if(typeof f.toJSON=="function"){let m;try{m=f.toJSON("")}catch{return 16}t.add(f);let h=c(m);return t.delete(f),h}t.add(f);let p;if(Array.isArray(f)){p=2;let m=f.length;for(let h=0;h<m;h++)p+=s(f[h]),h<m-1&&(p+=1)}else if(f instanceof Map){p=2;let m=0;for(let[h,_]of f){if(o(_))continue;m>0&&(p+=1);let b=typeof h=="string"?h:String(h);p+=i(b)+3,p+=c(_),m++}}else if(f instanceof Set){p=2;let m=0;for(let h of f)m>0&&(p+=1),p+=s(h),m++}else{p=2;let m=0,h=Object.keys(f);for(let _=0;_<h.length;_++){let b=h[_],w=f[b];o(w)||(m>0&&(p+=1),p+=i(b)+3,p+=c(w),m++)}}return t.delete(f),p},t=new Set,r=0,i=typeof Buffer<"u"&&typeof Buffer.byteLength=="function"?u=>Buffer.byteLength(u,"utf8"):u=>u.length;return{size:c(e),maxStringLen:r}}catch{return{size:Lt(e).length,maxStringLen:0}}}function Lt(e,t,r,i,n){try{let a=JSON.stringify(e,bz(r),i);return Hd(a)}catch(a){if(!a.message?.includes("Converting circular structure to JSON"))return console.warn(`[WARNING]: LangSmith received unserializable value.${t?`
30
- Context: ${t}`:""}`),Hd("[Unserializable]");Fe("SUPPRESS_CIRCULAR_JSON_WARNINGS")!=="true"&&console.warn(`[WARNING]: LangSmith received circular JSON. This will decrease tracer performance. ${t?`
31
- Context: ${t}`:""}`),typeof n>"u"&&(n=vz()),Wg(e,"",0,[],void 0,0,n);let o;try{ms.length===0?o=JSON.stringify(e,r,i):o=JSON.stringify(e,wz(r),i)}catch{return Hd("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;Gd.length!==0;){let s=Gd.pop();s.length===4?Object.defineProperty(s[0],s[1],s[3]):s[0][s[1]]=s[2]}}return Hd(o)}}function Gg(e,t,r,i){var n=Object.getOwnPropertyDescriptor(i,r);n.get!==void 0?n.configurable?(Object.defineProperty(i,r,{value:e}),Gd.push([i,r,t,n])):ms.push([t,r,e]):(i[r]=e,Gd.push([i,r,t]))}function Wg(e,t,r,i,n,a,o){a+=1;var s;if(typeof e=="object"&&e!==null){for(s=0;s<i.length;s++)if(i[s]===e){Gg(_z,e,t,n);return}if(typeof o.depthLimit<"u"&&a>o.depthLimit){Gg(WE,e,t,n);return}if(typeof o.edgesLimit<"u"&&r+1>o.edgesLimit){Gg(WE,e,t,n);return}if(i.push(e),Array.isArray(e))for(s=0;s<e.length;s++)Wg(e[s],s,s,i,e,a,o);else{e=JE(e);var c=Object.keys(e);for(s=0;s<c.length;s++){var l=c[s];Wg(e[l],l,s,i,e,a,o)}}i.pop()}}function wz(e){return e=typeof e<"u"?e:function(t,r){return r},function(t,r){if(ms.length>0)for(var i=0;i<ms.length;i++){var n=ms[i];if(n[1]===t&&n[0]===r){r=n[2],ms.splice(i,1);break}}return e.call(this,t,r)}}var Sz=`
32
- const { parentPort } = require("worker_threads");
33
-
34
- const CIRCULAR_REPLACE_NODE = { result: "[Circular]" };
35
-
36
- function serializeWellKnownTypes(val) {
37
- if (val && typeof val === "object") {
38
- if (val instanceof Map) return Object.fromEntries(val);
39
- if (val instanceof Set) return Array.from(val);
40
- if (val instanceof Date) return val.toISOString();
41
- if (val instanceof RegExp) return val.toString();
42
- if (val instanceof Error) return { name: val.name, message: val.message };
43
- } else if (typeof val === "bigint") {
44
- return val.toString();
45
- }
46
- return val;
47
- }
48
-
49
- function defaultReplacer(_key, val) {
50
- return serializeWellKnownTypes(val);
51
- }
52
-
53
- // Decirculate in-place: replace circular refs with { result: "[Circular]" }
54
- // then restore after stringify. Mirrors fast-safe-stringify's decirc().
55
- const restoreStack = [];
56
- function decirc(val, k, stack, parent) {
57
- if (typeof val === "object" && val !== null) {
58
- for (let i = 0; i < stack.length; i++) {
59
- if (stack[i] === val) {
60
- const orig = parent[k];
61
- parent[k] = CIRCULAR_REPLACE_NODE;
62
- restoreStack.push([parent, k, orig]);
63
- return;
64
- }
65
- }
66
- stack.push(val);
67
- if (Array.isArray(val)) {
68
- for (let i = 0; i < val.length; i++) decirc(val[i], i, stack, val);
69
- } else {
70
- const normalized = serializeWellKnownTypes(val);
71
- // Only recurse into normalized if it's still an object (arrays/objects),
72
- // else it was replaced with a primitive (e.g. Date -> string).
73
- if (normalized === val) {
74
- const keys = Object.keys(val);
75
- for (let i = 0; i < keys.length; i++) decirc(val[keys[i]], keys[i], stack, val);
76
- }
77
- }
78
- stack.pop();
79
- }
80
- }
81
-
82
- function serialize(obj) {
83
- try {
84
- return JSON.stringify(obj, defaultReplacer);
85
- } catch (e) {
86
- if (!String(e && e.message).includes("Converting circular structure to JSON")) {
87
- return "[Unserializable]";
88
- }
89
- decirc(obj, "", [], { "": obj });
90
- try {
91
- return JSON.stringify(obj, defaultReplacer);
92
- } catch (_) {
93
- return "[unable to serialize, circular reference is too complex to analyze]";
94
- } finally {
95
- while (restoreStack.length) {
96
- const [p, k, v] = restoreStack.pop();
97
- p[k] = v;
98
- }
99
- }
100
- }
101
- }
102
-
103
- parentPort.on("message", (msg) => {
104
- const { id, op, payload } = msg;
105
- try {
106
- if (op === "serialize") {
107
- const str = serialize(payload);
108
- const buf = Buffer.from(str, "utf8");
109
- // Slice into its own ArrayBuffer so we can transfer without dragging
110
- // unrelated bytes from any shared pool buffer.
111
- const ab = buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
112
- parentPort.postMessage({ id, bytes: ab, length: buf.byteLength }, [ab]);
113
- } else if (op === "ping") {
114
- parentPort.postMessage({ id });
115
- } else {
116
- parentPort.postMessage({ id, error: "unknown op: " + op });
117
- }
118
- } catch (e) {
119
- parentPort.postMessage({ id, error: String((e && e.message) || e) });
120
- }
121
- });
122
- `,Kg=class{constructor(){Object.defineProperty(this,"worker",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"nextId",{enumerable:!0,configurable:!0,writable:!0,value:1}),Object.defineProperty(this,"pending",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"disabled",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"startPromise",{enumerable:!0,configurable:!0,writable:!0,value:null})}async ensureStarted(){if(this.disabled)return!1;if(this.worker!==null)return!0;if(this.startPromise!==null)return this.startPromise;this.startPromise=this._start();try{return await this.startPromise}finally{this.startPromise=null}}async _start(){if(!!1||null===null)return this.disabled=!0,!1;try{let t=new null(Sz,{eval:!0});return t.on("message",r=>{let i=this.pending.get(r.id);i&&(this.pending.delete(r.id),r.error?i.reject(new Error(r.error)):r.bytes&&typeof r.length=="number"?i.resolve(new Uint8Array(r.bytes,0,r.length)):i.reject(new Error("worker returned malformed message")))}),t.on("error",r=>{for(let[,i]of this.pending)i.reject(r);this.pending.clear(),this.disabled=!0,this.worker=null}),t.on("exit",r=>{for(let[,i]of this.pending)i.reject(new Error(`worker exited with code ${r}`));this.pending.clear(),this.worker=null}),t.unref(),this.worker=t,!0}catch{return this.disabled=!0,!1}}async serialize(t){if(!await this.ensureStarted())return null;let i=this.nextId++;return new Promise((n,a)=>{this.pending.set(i,{resolve:n,reject:a});try{this.worker.postMessage({id:i,op:"serialize",payload:t})}catch(o){this.pending.delete(i),a(o)}})}async terminate(){this.worker&&(await this.worker.terminate(),this.worker=null);for(let[,t]of this.pending)t.reject(new Error("worker terminated"));this.pending.clear()}},Jg=null;function XE(){return Jg===null&&(Jg=new Kg),Jg}var kz=64*1024,$z=2048;function YE(e,t=kz,r=$z){if(e===null||typeof e!="object")return typeof e=="string"&&e.length>=t;let i=[e],n=new Set,a=0;for(;i.length>0;){if(a++>=r)return!1;let o=i.pop();if(o==null)continue;let s=typeof o;if(s==="string"){if(o.length>=t)return!0;continue}if(s!=="object")continue;let c=o;if(n.has(c)||(n.add(c),c instanceof Date||c instanceof RegExp||c instanceof Error||c instanceof ArrayBuffer||ArrayBuffer.isView(c)))continue;if(Array.isArray(c)){for(let u=c.length-1;u>=0;u--)i.push(c[u]);continue}if(c instanceof Map){for(let[,u]of c)i.push(u);continue}if(c instanceof Set){for(let u of c)i.push(u);continue}let l=Object.keys(c);for(let u=l.length-1;u>=0;u--)i.push(c[l[u]])}return!1}function Ez(e,t){let[r]=Ut(e);if(r!=="-"&&!t)throw new Error("Pulling a public prompt by owner/name is disabled by default because prompts may contain untrusted serialized LangChain objects. If you trust this prompt, set `dangerouslyPullPublicPrompt: true` to acknowledge the risk.")}function QE(e){return typeof e=="string"&&e.length>0&&!e.includes("Z")&&!e.includes("+")&&!e.includes("-",10)?e+"Z":e}function hs(e){return{...e,start_time:QE(e.start_time),end_time:QE(e.end_time)}}function eI(e,t,r){if(r)return e;let i=Ad(),n=t??kg(),a=e.extra??{},o=a.metadata;return e.extra={...a,runtime:{...i,...a?.runtime},metadata:{...n,...n.revision_id||"revision_id"in e&&e.revision_id?{revision_id:("revision_id"in e?e.revision_id:void 0)??n.revision_id}:{},...o}},e}var Iz=e=>{let t=e?.toString()??Fe("TRACING_SAMPLING_RATE");if(t===void 0)return;let r=parseFloat(t);if(r<0||r>1)throw new Error(`LANGSMITH_TRACING_SAMPLING_RATE must be between 0 and 1 if set. Got: ${r}`);return r},Tz=e=>{let r=e.replace("http://","").replace("https://","").split("/")[0].split(":")[0];return r==="localhost"||r==="127.0.0.1"||r==="::1"};async function Cz(e){let t=[];for await(let r of e)t.push(r);return t}function Wd(e){if(e!==void 0)return e.trim().replace(/^"(.*)"$/,"$1").replace(/^'(.*)'$/,"$1")}var Az=async e=>{if(e?.status===429){let t=parseInt(e.headers.get("retry-after")??"10",10)*1e3;if(t>0)return await new Promise(r=>setTimeout(r,t)),!0}return!1};function tI(e){return typeof e=="number"?Number(e.toFixed(4)):e}var Oz=24*1024*1024,nI=1024*1024*1024,Pz=1e4,Nz=100,qg=class{constructor(t){Object.defineProperty(this,"items",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"sizeBytes",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"maxSizeBytes",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSizeBytes=t??nI}peek(){return this.items[0]}push(t){let r,i=new Promise(a=>{r=a}),n=KE(t.item).size;return this.sizeBytes+n>this.maxSizeBytes&&this.items.length>0?(console.warn(`AutoBatchQueue size limit (${this.maxSizeBytes} bytes) exceeded. Dropping run with id: ${t.item.id}. Current queue size: ${this.sizeBytes} bytes, attempted addition: ${n} bytes.`),r(),i):(this.items.push({action:t.action,payload:t.item,otelContext:t.otelContext,apiKey:t.apiKey,apiUrl:t.apiUrl,itemPromiseResolve:r,itemPromise:i,size:n}),this.sizeBytes+=n,i)}pop({upToSizeBytes:t,upToSize:r}){if(t<1)throw new Error("Number of bytes to pop off may not be less than 1.");let i=[],n=0;for(;n+(this.peek()?.size??0)<t&&this.items.length>0&&i.length<r;){let a=this.items.shift();a&&(i.push(a),n+=a.size,this.sizeBytes-=a.size)}if(i.length===0&&this.items.length>0){let a=this.items.shift();i.push(a),n+=a.size,this.sizeBytes-=a.size}return[i.map(a=>({action:a.action,item:a.payload,otelContext:a.otelContext,apiKey:a.apiKey,apiUrl:a.apiUrl,size:a.size})),()=>i.forEach(a=>a.itemPromiseResolve())]}},Dn=class e{get tracingMode(){return this._tracingMode}get _fetch(){let t=this.fetchImplementation||nE(this.debug);return(async(r,i)=>{let n,a=this.getProfileManagedAuthorizationHeader(i);return this.apiKey!==void 0?n={name:"x-api-key",value:`${this.apiKey}`}:this.hasExplicitAuthHeader(i,a)||(n=await this.profileAuth?.getAuthHeader(t,i?.signal)),t(r,this.applyCurrentAuthHeaders(i,n,a))})}getProfileManagedAuthorizationHeader(t){if(!t?.headers||!this.profileAuth)return;let r=new Headers(t.headers).get("Authorization");if(Fr(r))return this.profileAuth.isProfileAuthorizationHeader(r??"")?r??void 0:void 0}isProfileManagedAuthorizationHeader(t,r){return t===r||this.profileAuth?.isProfileAuthorizationHeader(t)===!0}hasExplicitAuthHeader(t,r){if(!t?.headers)return!1;let i=new Headers(t.headers);if(Fr(i.get("x-api-key")))return!0;let n=i.get("Authorization");return Fr(n)?!this.isProfileManagedAuthorizationHeader(n??"",r):!1}applyCurrentAuthHeaders(t,r,i){if(!r)return t;let n=d=>{if(this.apiKey!==void 0&&r.name==="x-api-key")return d.delete("Authorization"),d.has("x-api-key")||d.set("x-api-key",r.value),d;if(r.name==="Authorization"){if(Fr(d.get("x-api-key")))return d;let p=d.get("Authorization");return Fr(p)&&!this.isProfileManagedAuthorizationHeader(p??"",i)||d.set("Authorization",r.value),d}let f=d.get("Authorization");return Fr(f)&&!this.isProfileManagedAuthorizationHeader(f??"",i)||(Fr(f)&&d.delete("Authorization"),d.has("x-api-key")||d.set("x-api-key",r.value)),d};if(!t)return{headers:{[r.name]:r.value}};if(t.headers instanceof Headers)return{...t,headers:n(new Headers(t.headers))};if(Array.isArray(t.headers))return{...t,headers:n(new Headers(t.headers))};let a={...t.headers??{}},o=d=>Object.keys(a).find(f=>f.toLowerCase()===d),s=d=>{let f=o(d);return f?a[f]:void 0},c=Fr(s("x-api-key")),l=s("authorization"),u=Fr(l)&&!this.isProfileManagedAuthorizationHeader(l??"",i);if(this.apiKey!==void 0&&r.name==="x-api-key"){let d=o("authorization");return d&&delete a[d],c||(a["x-api-key"]=r.value),{...t,headers:a}}if(r.name==="Authorization"){if(!c&&!u){let d=o("authorization");d&&d!=="Authorization"&&delete a[d],a.Authorization=r.value}return{...t,headers:a}}if(!u){let d=o("authorization");d&&delete a[d],c||(a["x-api-key"]=r.value)}return{...t,headers:a}}_trackDrain(t){this._pendingDrains.add(t),t.finally(()=>{this._pendingDrains.delete(t)})}async _serializeBody(t,r){if(this.manualFlushMode)return Lt(t,r);if(!YE(t))return Lt(t,r);if(this._serializeWorker===void 0&&(this._serializeWorker=XE()),this._serializeWorker===null)return Lt(t,r);try{let i=await this._serializeWorker.serialize(t);return i===null?(this._serializeWorker=null,Lt(t,r)):i}catch{return Lt(t,r)}}constructor(t={}){Object.defineProperty(this,"apiKey",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"apiUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"webUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"workspaceId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"caller",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"batchIngestCaller",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"timeout_ms",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_tenantId",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"hideInputs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"hideOutputs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"hideMetadata",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"omitTracedRuntimeInfo",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"tracingSampleRate",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"filteredPostUuids",{enumerable:!0,configurable:!0,writable:!0,value:new Set}),Object.defineProperty(this,"autoBatchTracing",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"autoBatchQueue",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"autoBatchTimeout",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"autoBatchAggregationDelayMs",{enumerable:!0,configurable:!0,writable:!0,value:250}),Object.defineProperty(this,"batchSizeBytesLimit",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"batchSizeLimit",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"fetchOptions",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"settings",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"blockOnRootRunFinalization",{enumerable:!0,configurable:!0,writable:!0,value:Et("LANGSMITH_TRACING_BACKGROUND")==="false"}),Object.defineProperty(this,"traceBatchConcurrency",{enumerable:!0,configurable:!0,writable:!0,value:5}),Object.defineProperty(this,"_serverInfo",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_getServerInfoPromise",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"manualFlushMode",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_serializeWorker",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_pendingDrains",{enumerable:!0,configurable:!0,writable:!0,value:new Set}),Object.defineProperty(this,"langSmithToOTELTranslator",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_tracingMode",{enumerable:!0,configurable:!0,writable:!0,value:"langsmith"}),Object.defineProperty(this,"fetchImplementation",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cachedLSEnvVarsForMetadata",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_promptCache",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"profileAuth",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"multipartStreamingDisabled",{enumerable:!0,configurable:!0,writable:!0,value:Fe("DISABLE_MULTIPART_STREAMING")==="true"}),Object.defineProperty(this,"_multipartDisabled",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_runCompressionDisabled",{enumerable:!0,configurable:!0,writable:!0,value:Fe("DISABLE_RUN_COMPRESSION")==="true"}),Object.defineProperty(this,"failedTracesDir",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"failedTracesMaxBytes",{enumerable:!0,configurable:!0,writable:!0,value:100*1024*1024}),Object.defineProperty(this,"_customHeaders",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"debug",{enumerable:!0,configurable:!0,writable:!0,value:Et("LANGSMITH_DEBUG")==="true"});let r=e.getDefaultClientConfig();this.tracingSampleRate=Iz(t.tracingSamplingRate),this.apiUrl=Wd(t.apiUrl??r.apiUrl)??"",this.apiUrl.endsWith("/")&&(this.apiUrl=this.apiUrl.slice(0,-1));let i=Wd(t.apiKey??r.apiKey);if(this.apiKey=Fr(i)?i:void 0,this.profileAuth=this.apiKey!==void 0?void 0:r.profileAuth,this.webUrl=Wd(t.webUrl??r.webUrl),this.webUrl?.endsWith("/")&&(this.webUrl=this.webUrl.slice(0,-1)),this.workspaceId=Wd(t.workspaceId??r.workspaceId),this.timeout_ms=t.timeout_ms??9e4,this.caller=new rl({...t.callerOptions??{},maxRetries:4,debug:t.debug??this.debug}),this.traceBatchConcurrency=t.traceBatchConcurrency??this.traceBatchConcurrency,this.traceBatchConcurrency<1)throw new Error("Trace batch concurrency must be positive.");this.debug=t.debug??this.debug,this.fetchImplementation=t.fetchImplementation,this.failedTracesDir=Fe("FAILED_TRACES_DIR")||void 0;let n=Fe("FAILED_TRACES_MAX_MB");if(n){let o=parseInt(n,10);Number.isFinite(o)&&o>0&&(this.failedTracesMaxBytes=o*1024*1024)}let a=t.maxIngestMemoryBytes??nI;this.batchIngestCaller=new rl({maxRetries:4,maxConcurrency:this.traceBatchConcurrency,maxQueueSizeBytes:a,...t.callerOptions??{},onFailedResponseHook:Az,debug:t.debug??this.debug}),this.hideInputs=t.hideInputs??t.anonymizer??r.hideInputs,this.hideOutputs=t.hideOutputs??t.anonymizer??r.hideOutputs,this.hideMetadata=t.hideMetadata??r.hideMetadata,this.omitTracedRuntimeInfo=t.omitTracedRuntimeInfo??!1,this.autoBatchTracing=t.autoBatchTracing??this.autoBatchTracing,this.autoBatchQueue=new qg(a),this.blockOnRootRunFinalization=t.blockOnRootRunFinalization??this.blockOnRootRunFinalization,this.batchSizeBytesLimit=t.batchSizeBytesLimit,this.batchSizeLimit=t.batchSizeLimit,this.fetchOptions=t.fetchOptions||{},this.manualFlushMode=t.manualFlushMode??this.manualFlushMode,this._tracingMode=Od(t.tracingMode),this._tracingMode==="otel"&&(this.langSmithToOTELTranslator=new Nd),this.cachedLSEnvVarsForMetadata=kg(),t.cache!==void 0&&t.disablePromptCache&&qa("Both 'cache' and 'disablePromptCache' were provided. The 'cache' parameter is deprecated and will be removed in a future version. Using 'cache' parameter value."),t.cache!==void 0?(qa("The 'cache' parameter is deprecated and will be removed in a future version. Use 'configureGlobalPromptCache()' to configure the global cache, or 'disablePromptCache: true' to disable caching for this client."),t.cache===!1?this._promptCache=void 0:t.cache===!0?this._promptCache=Td:this._promptCache=t.cache):t.disablePromptCache||(this._promptCache=Td),this._customHeaders=t.headers??{}}static getDefaultClientConfig(){let t=HE(),r=Fe("API_KEY"),i=Fe("ENDPOINT"),n=Fe("WORKSPACE_ID"),a=Fr(r),o=i??t.apiUrl??Zd,s=n??t.workspaceId,c=Fe("HIDE_INPUTS")==="true",l=Fe("HIDE_OUTPUTS")==="true",u=Fe("HIDE_METADATA")==="true";return{apiUrl:o,apiKey:r,webUrl:void 0,hideInputs:c,hideOutputs:l,hideMetadata:u,workspaceId:s,oauthAccessToken:a?void 0:t.oauthAccessToken,oauthRefreshToken:a?void 0:t.oauthRefreshToken,profileAuth:a?void 0:t.profileAuth}}getHostUrl(){return this.webUrl?this.webUrl:Tz(this.apiUrl)?(this.webUrl="http://localhost:3000",this.webUrl):this.apiUrl.endsWith("/api/v1")?(this.webUrl=this.apiUrl.replace("/api/v1",""),this.webUrl):this.apiUrl.includes("/api")&&!this.apiUrl.split(".",1)[0].endsWith("api")?(this.webUrl=this.apiUrl.replace("/api",""),this.webUrl):this.apiUrl.split(".",1)[0].includes("dev")?(this.webUrl="https://dev.smith.langchain.com",this.webUrl):this.apiUrl.split(".",1)[0].includes("eu")?(this.webUrl="https://eu.smith.langchain.com",this.webUrl):this.apiUrl.split(".",1)[0].includes("aws")?(this.webUrl="https://aws.smith.langchain.com",this.webUrl):this.apiUrl.split(".",1)[0].includes("apac")?(this.webUrl="https://apac.smith.langchain.com",this.webUrl):this.apiUrl.split(".",1)[0].includes("beta")?(this.webUrl="https://beta.smith.langchain.com",this.webUrl):(this.webUrl="https://smith.langchain.com",this.webUrl)}get _mergedHeaders(){let t={"User-Agent":`langsmith-js/${Cd}`,...this._customHeaders};if(this.apiKey!==void 0)t["x-api-key"]=`${this.apiKey}`;else{let r=this.profileAuth?.currentAuthHeader();r&&(t[r.name]=r.value)}return this.workspaceId&&(t["x-tenant-id"]=this.workspaceId),t}get headers(){return this._customHeaders}set headers(t){this._customHeaders=t??{}}_getPlatformEndpointPath(t){return this.apiUrl.slice(-3)!=="/v1"&&this.apiUrl.slice(-4)!=="/v1/"?`/v1/platform/${t}`:`/platform/${t}`}async processInputs(t){return this.hideInputs===!1?t:this.hideInputs===!0?{}:typeof this.hideInputs=="function"?this.hideInputs(t):t}async processOutputs(t){return this.hideOutputs===!1?t:this.hideOutputs===!0?{}:typeof this.hideOutputs=="function"?this.hideOutputs(t):t}async processMetadata(t){return this.hideMetadata===!1?t:this.hideMetadata===!0?{}:typeof this.hideMetadata=="function"?this.hideMetadata(t):t}_filterNewTokenEvents(t){return!t||t.length===0?t:t.map(r=>{if(r.name==="new_token"){let{kwargs:i,...n}=r;return n}return r})}async prepareRunCreateOrUpdateInputs(t){let r={...t};return r.inputs!==void 0&&(r.inputs=await this.processInputs(r.inputs)),r.outputs!==void 0&&(r.outputs=await this.processOutputs(r.outputs)),r.extra!=null&&"metadata"in r.extra&&(r.extra={...r.extra,metadata:await this.processMetadata(r.extra.metadata)}),r.events!==void 0&&(r.events=this._filterNewTokenEvents(r.events)),r}async _getResponse(t,r){let i=r?.toString()??"",n=`${this.apiUrl}${t}?${i}`;return await this.caller.call(async()=>{let o=await this._fetch(n,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Q(o,`fetch ${t}`),o})}async _get(t,r){return(await this._getResponse(t,r)).json()}async*_getPaginated(t,r=new URLSearchParams,i){let n=Number(r.get("offset"))||0,a=Number(r.get("limit"))||100;for(;;){r.set("offset",String(n)),r.set("limit",String(a));let o=`${this.apiUrl}${t}?${r}`,s=await this.caller.call(async()=>{let l=await this._fetch(o,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Q(l,`fetch ${t}`),l}),c=i?i(await s.json()):await s.json();if(c.length===0||(yield c,c.length<a))break;n+=c.length}}async*_getCursorPaginatedList(t,r=null,i="POST",n="runs"){let a=r?{...r}:{};for(;;){let o=JSON.stringify(a),c=await(await this.caller.call(async()=>{let u=await this._fetch(`${this.apiUrl}${t}`,{method:i,headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:o});return await Q(u,`fetch ${t}`),u})).json();if(!c||!c[n])break;yield c[n];let l=c.cursors;if(!l||!l.next)break;a.cursor=l.next}}_shouldSample(){return this.tracingSampleRate===void 0?!0:Math.random()<this.tracingSampleRate}_filterForSampling(t,r=!1){if(this.tracingSampleRate===void 0)return t;if(r){let i=[];for(let n of t)this.filteredPostUuids.has(n.trace_id)?n.id===n.trace_id&&this.filteredPostUuids.delete(n.trace_id):i.push(n);return i}else{let i=[];for(let n of t){let a=n.trace_id??n.id;this.filteredPostUuids.has(a)||(n.id===a?this._shouldSample()?i.push(n):this.filteredPostUuids.add(a):i.push(n))}return i}}async _getBatchSizeLimitBytes(){let t=await this._ensureServerInfo();return this.batchSizeBytesLimit??t?.batch_ingest_config?.size_limit_bytes??Oz}async _getBatchSizeLimit(){let t=await this._ensureServerInfo();return this.batchSizeLimit??t?.batch_ingest_config?.size_limit??Nz}async _getDatasetExamplesMultiPartSupport(){return(await this._ensureServerInfo()).instance_flags?.dataset_examples_multipart_enabled??!1}drainAutoBatchQueue({batchSizeLimitBytes:t,batchSizeLimit:r}){let i=[];for(;this.autoBatchQueue.items.length>0;){let[n,a]=this.autoBatchQueue.pop({upToSizeBytes:t,upToSize:r});if(!n.length){a();break}let o=n.reduce((l,u)=>{let d=u.apiUrl??this.apiUrl,f=u.apiKey??this.apiKey,m=u.apiKey===this.apiKey&&u.apiUrl===this.apiUrl?"default":`${d}|${f}`;return l[m]||(l[m]=[]),l[m].push(u),l},{}),s=[];for(let[l,u]of Object.entries(o)){let d=this._processBatch(u,{apiUrl:l==="default"?void 0:l.split("|")[0],apiKey:l==="default"?void 0:l.split("|")[1]});s.push(d)}let c=Promise.all(s).finally(a);i.push(c)}return Promise.all(i)}static async _writeTraceToFallbackDir(t,r,i,n,a){try{let o=typeof r=="string"?Buffer.from(r,"utf8"):Buffer.from(r),s=JSON.stringify({version:1,endpoint:n,headers:i,body_base64:o.toString("base64")}),c=`trace_${Date.now()}_${Ka().slice(0,8)}.json`,l=on.join(t,c);if(e._fallbackDirsCreated.has(t)||(await $d(t),e._fallbackDirsCreated.add(t)),a!==void 0&&a>0)try{let d=(await _E(t)).filter(p=>p.startsWith("trace_")&&p.endsWith(".json")),f=0;for(let p of d){let{size:m}=await yE(on.join(t,p));f+=m}if(f>=a){console.warn(`Could not write trace to fallback dir ${t} as it's already over size limit (${f} bytes >= ${a} bytes). Increase LANGSMITH_FAILED_TRACES_MAX_MB if possible.`);return}}catch{}await fs(l,s),console.warn(`LangSmith trace upload failed; data saved to ${l} for later replay.`)}catch(o){console.error(`LangSmith tracing error: could not write trace to fallback dir ${t}:`,o)}}async _processBatch(t,r){if(!t.length)return;let i=t.reduce((n,a)=>n+(a.size??0),0);try{if(this.langSmithToOTELTranslator!==void 0)this._sendBatchToOTELTranslator(t);else{let n={runCreates:t.filter(s=>s.action==="create").map(s=>s.item),runUpdates:t.filter(s=>s.action==="update").map(s=>s.item)},a=await this._ensureServerInfo();if(!this._multipartDisabled&&(a?.batch_ingest_config?.use_multipart_endpoint??!0)){let s=!this._runCompressionDisabled&&a?.instance_flags?.gzip_body_enabled;try{await this.multipartIngestRuns(n,{...r,useGzip:s,sizeBytes:i})}catch(c){if(Vd(c))this._multipartDisabled=!0,await this.batchIngestRuns(n,{...r,sizeBytes:i});else throw c}}else await this.batchIngestRuns(n,{...r,sizeBytes:i})}}catch(n){console.error("Error exporting batch:",n)}}_sendBatchToOTELTranslator(t){if(this.langSmithToOTELTranslator!==void 0){let r=new Map,i=[];for(let n of t)n.item.id&&n.otelContext&&(r.set(n.item.id,n.otelContext),n.action==="create"?i.push({operation:"post",id:n.item.id,trace_id:n.item.trace_id??n.item.id,run:n.item}):i.push({operation:"patch",id:n.item.id,trace_id:n.item.trace_id??n.item.id,run:n.item}));this.langSmithToOTELTranslator.exportBatch(i,r)}}async processRunOperation(t){clearTimeout(this.autoBatchTimeout),this.autoBatchTimeout=void 0,t.item=eI(t.item,this.cachedLSEnvVarsForMetadata,this.omitTracedRuntimeInfo);let r=this.autoBatchQueue.push(t);if(this.manualFlushMode)return r;let i=await this._getBatchSizeLimitBytes(),n=await this._getBatchSizeLimit();return(this.autoBatchQueue.sizeBytes>i||this.autoBatchQueue.items.length>n)&&this._trackDrain(this.drainAutoBatchQueue({batchSizeLimitBytes:i,batchSizeLimit:n})),this.autoBatchQueue.items.length>0&&(this.autoBatchTimeout=setTimeout(()=>{this.autoBatchTimeout=void 0,this._trackDrain(this.drainAutoBatchQueue({batchSizeLimitBytes:i,batchSizeLimit:n}))},this.autoBatchAggregationDelayMs)),r}async _getServerInfo(){let r=await(await this.caller.call(async()=>{let i=await this._fetch(`${this.apiUrl}/info`,{method:"GET",headers:{...this._mergedHeaders,Accept:"application/json"},signal:AbortSignal.timeout(Pz),...this.fetchOptions});return await Q(i,"get server info"),i})).json();return this.debug&&console.log(`
123
- === LangSmith Server Configuration ===
124
- `+JSON.stringify(r,null,2)+`
125
- `),r}async _ensureServerInfo(){return this._getServerInfoPromise===void 0&&(this._getServerInfoPromise=(async()=>{if(this._serverInfo===void 0)try{this._serverInfo=await this._getServerInfo()}catch(t){console.warn(`[LANGSMITH]: Failed to fetch info on supported operations. Falling back to batch operations and default limits. Info: ${t.status??"Unspecified status code"} ${t.message}`)}return this._serverInfo??{}})()),this._getServerInfoPromise.then(t=>(this._serverInfo===void 0&&(this._getServerInfoPromise=void 0),t))}async _getSettings(){return this.settings||(this.settings=this._get("/settings")),await this.settings}async flush(){let t=await this._getBatchSizeLimitBytes(),r=await this._getBatchSizeLimit();await this.drainAutoBatchQueue({batchSizeLimitBytes:t,batchSizeLimit:r})}_cloneCurrentOTELContext(){let t=Pd(),r=kE();if(this.langSmithToOTELTranslator!==void 0){let i=t.getActiveSpan();if(i)return t.setSpan(r.active(),i)}}async createRun(t,r){if(!this._filterForSampling([t]).length)return;let i={...this._mergedHeaders,"Content-Type":"application/json"},n=t.project_name;delete t.project_name;let a=await this.prepareRunCreateOrUpdateInputs({session_name:n,...t,start_time:t.start_time??Date.now()});if(this.autoBatchTracing&&a.trace_id!==void 0&&a.dotted_order!==void 0){let c=this._cloneCurrentOTELContext();this.processRunOperation({action:"create",item:a,otelContext:c,apiKey:r?.apiKey,apiUrl:r?.apiUrl}).catch(console.error);return}let o=eI(a,this.cachedLSEnvVarsForMetadata,this.omitTracedRuntimeInfo);r?.apiKey!==void 0&&(i["x-api-key"]=r.apiKey),r?.workspaceId!==void 0&&(i["x-tenant-id"]=r.workspaceId);let s=Lt(o,`Creating run with id: ${o.id}`);await this.caller.call(async()=>{let c=await this._fetch(`${r?.apiUrl??this.apiUrl}/runs`,{method:"POST",headers:i,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:s});return await Q(c,"create run",!0),c})}async batchIngestRuns({runCreates:t,runUpdates:r},i){if(t===void 0&&r===void 0)return;let n=await Promise.all(t?.map(c=>this.prepareRunCreateOrUpdateInputs(c))??[]),a=await Promise.all(r?.map(c=>this.prepareRunCreateOrUpdateInputs(c))??[]);if(n.length>0&&a.length>0){let c=n.reduce((u,d)=>(d.id&&(u[d.id]=d),u),{}),l=[];for(let u of a)u.id!==void 0&&c[u.id]?c[u.id]={...c[u.id],...u}:l.push(u);n=Object.values(c),a=l}let o={post:n,patch:a};if(!o.post.length&&!o.patch.length)return;let s={post:[],patch:[]};for(let c of["post","patch"]){let l=c,u=o[l].reverse(),d=u.pop();for(;d!==void 0;)s[l].push(d),d=u.pop()}if(s.post.length>0||s.patch.length>0){let c=s.post.map(l=>l.id).concat(s.patch.map(l=>l.id)).join(",");await this._postBatchIngestRuns(await this._serializeBody(s,`Ingesting runs with ids: ${c}`),i)}}async _postBatchIngestRuns(t,r){let i={...this._mergedHeaders,"Content-Type":"application/json",Accept:"application/json"};r?.apiKey!==void 0&&(i["x-api-key"]=r.apiKey),await this.batchIngestCaller.callWithOptions({sizeBytes:r?.sizeBytes},async()=>{let n=await this._fetch(`${r?.apiUrl??this.apiUrl}/runs/batch`,{method:"POST",headers:i,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:t});return await Q(n,"batch create run",!0),n})}async multipartIngestRuns({runCreates:t,runUpdates:r},i){if(t===void 0&&r===void 0)return;let n={},a=[];for(let d of t??[]){let f=await this.prepareRunCreateOrUpdateInputs(d);f.id!==void 0&&f.attachments!==void 0&&(n[f.id]=f.attachments),delete f.attachments,a.push(f)}let o=[];for(let d of r??[])o.push(await this.prepareRunCreateOrUpdateInputs(d));if(a.find(d=>d.trace_id===void 0||d.dotted_order===void 0)!==void 0)throw new Error('Multipart ingest requires "trace_id" and "dotted_order" to be set when creating a run');if(o.find(d=>d.trace_id===void 0||d.dotted_order===void 0)!==void 0)throw new Error('Multipart ingest requires "trace_id" and "dotted_order" to be set when updating a run');if(a.length>0&&o.length>0){let d=a.reduce((p,m)=>(m.id&&(p[m.id]=m),p),{}),f=[];for(let p of o)p.id!==void 0&&d[p.id]?d[p.id]={...d[p.id],...p}:f.push(p);a=Object.values(d),o=f}if(a.length===0&&o.length===0)return;let l=[],u=[];for(let[d,f]of[["post",a],["patch",o]])for(let p of f){let{inputs:m,outputs:h,events:_,extra:b,error:w,serialized:S,attachments:x,...E}=p,z={inputs:m,outputs:h,events:_,extra:b,error:w,serialized:S},C=await this._serializeBody(E,`Serializing for multipart ingestion of run with id: ${E.id}`);u.push({name:`${d}.${E.id}`,payload:new Blob([C],{type:`application/json; length=${C.length}`})});for(let[v,Z]of Object.entries(z)){if(Z===void 0)continue;let B=await this._serializeBody(Z,`Serializing ${v} for multipart ingestion of run with id: ${E.id}`);u.push({name:`${d}.${E.id}.${v}`,payload:new Blob([B],{type:`application/json; length=${B.length}`})})}if(E.id!==void 0){let v=n[E.id];if(v){delete n[E.id];for(let[Z,B]of Object.entries(v)){let A,L;if(Array.isArray(B)?[A,L]=B:(A=B.mimeType,L=B.data),Z.includes(".")){console.warn(`Skipping attachment '${Z}' for run ${E.id}: Invalid attachment name. Attachment names must not contain periods ('.'). Please rename the attachment and try again.`);continue}u.push({name:`attachment.${E.id}.${Z}`,payload:new Blob([L],{type:`${A}; length=${L.byteLength}`})})}}}l.push(`trace=${E.trace_id},id=${E.id}`)}await this._sendMultipartRequest(u,l.join("; "),i)}async _createNodeFetchBody(t,r){let i=[];for(let o of t)i.push(new Blob([`--${r}\r
126
- `])),i.push(new Blob([`Content-Disposition: form-data; name="${o.name}"\r
127
- `,`Content-Type: ${o.payload.type}\r
128
- \r
129
- `])),i.push(o.payload),i.push(new Blob([`\r
130
- `]));return i.push(new Blob([`--${r}--\r
131
- `])),await new Blob(i).arrayBuffer()}async _createMultipartStream(t,r){let i=new TextEncoder;return new ReadableStream({async start(a){let o=async s=>{typeof s=="string"?a.enqueue(i.encode(s)):a.enqueue(s)};for(let s of t){await o(`--${r}\r
132
- `),await o(`Content-Disposition: form-data; name="${s.name}"\r
133
- `),await o(`Content-Type: ${s.payload.type}\r
134
- \r
135
- `);let l=s.payload.stream().getReader();try{let u;for(;!(u=await l.read()).done;)a.enqueue(u.value)}finally{l.releaseLock()}await o(`\r
136
- `)}await o(`--${r}--\r
137
- `),a.close()}})}async _sendMultipartRequest(t,r,i){let n="----LangSmithFormBoundary"+Math.random().toString(36).slice(2),a=()=>this._createNodeFetchBody(t,n),o=()=>this._createMultipartStream(t,n),s=async c=>this.batchIngestCaller.callWithOptions({sizeBytes:i?.sizeBytes},async()=>{let l=await c(),u={...this._mergedHeaders,"Content-Type":`multipart/form-data; boundary=${n}`};i?.apiKey!==void 0&&(u["x-api-key"]=i.apiKey);let d=l;i?.useGzip&&typeof l=="object"&&"pipeThrough"in l&&(d=l.pipeThrough(new CompressionStream("gzip")),u["Content-Encoding"]="gzip");let f=await this._fetch(`${i?.apiUrl??this.apiUrl}/runs/multipart`,{method:"POST",headers:u,body:d,duplex:"half",signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Q(f,"Failed to send multipart request",!0),f});try{let c,l=!1;rE()&&!this.multipartStreamingDisabled&&el()!=="bun"?(l=!0,c=await s(o)):c=await s(a),(!this.multipartStreamingDisabled||l)&&c.status===422&&(i?.apiUrl??this.apiUrl)!==Zd&&(console.warn(`Streaming multipart upload to ${i?.apiUrl??this.apiUrl}/runs/multipart failed. This usually means the host does not support chunked uploads. Retrying with a buffered upload for operation "${r}".`),this.multipartStreamingDisabled=!0,c=await s(a))}catch(c){if(Vd(c))throw c;if(console.warn(`${c.message.trim()}
138
-
139
- Context: ${r}`),this.failedTracesDir){let l=await this._createNodeFetchBody(t,n).catch(()=>null);l&&await e._writeTraceToFallbackDir(this.failedTracesDir,l,{"Content-Type":`multipart/form-data; boundary=${n}`},"runs/multipart",this.failedTracesMaxBytes)}}}async updateRun(t,r,i){pe(t),r.inputs&&(r.inputs=await this.processInputs(r.inputs)),r.outputs&&(r.outputs=await this.processOutputs(r.outputs)),r.extra!=null&&"metadata"in r.extra&&(r.extra={...r.extra,metadata:await this.processMetadata(r.extra.metadata)}),r.events&&(r.events=this._filterNewTokenEvents(r.events));let n={...r,id:t};if(!this._filterForSampling([n],!0).length)return;if(this.autoBatchTracing&&n.trace_id!==void 0&&n.dotted_order!==void 0){let s=this._cloneCurrentOTELContext();if(r.end_time!==void 0&&n.parent_run_id===void 0&&this.blockOnRootRunFinalization&&!this.manualFlushMode){await this.processRunOperation({action:"update",item:n,otelContext:s,apiKey:i?.apiKey,apiUrl:i?.apiUrl}).catch(console.error);return}else this.processRunOperation({action:"update",item:n,otelContext:s,apiKey:i?.apiKey,apiUrl:i?.apiUrl}).catch(console.error);return}let a={...this._mergedHeaders,"Content-Type":"application/json"};i?.apiKey!==void 0&&(a["x-api-key"]=i.apiKey),i?.workspaceId!==void 0&&(a["x-tenant-id"]=i.workspaceId);let o=Lt(r,`Serializing payload to update run with id: ${t}`);await this.caller.call(async()=>{let s=await this._fetch(`${i?.apiUrl??this.apiUrl}/runs/${t}`,{method:"PATCH",headers:a,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:o});return await Q(s,"update run",!0),s})}async readRun(t,{loadChildRuns:r}={loadChildRuns:!1}){pe(t);let i=hs(await this._get(`/runs/${t}`));return r&&(i=await this._loadChildRuns(i)),i}async getRunUrl({runId:t,run:r,projectOpts:i}){if(r!==void 0){let n;r.session_id?n=r.session_id:i?.projectName?n=(await this.readProject({projectName:i?.projectName})).id:i?.projectId?n=i?.projectId:n=(await this.readProject({projectName:Fe("PROJECT")||"default"})).id;let a=await this._getTenantId();return`${this.getHostUrl()}/o/${a}/projects/p/${n}/r/${r.id}?poll=true`}else if(t!==void 0){let n=await this.readRun(t);if(!n.app_path)throw new Error(`Run ${t} has no app_path`);return`${this.getHostUrl()}${n.app_path}`}else throw new Error("Must provide either runId or run")}async _loadChildRuns(t){let r=await Cz(this.listRuns({isRoot:!1,projectId:t.session_id,traceId:t.trace_id})),i={},n={};r.sort((a,o)=>(a?.dotted_order??"").localeCompare(o?.dotted_order??""));for(let a of r){if(a.parent_run_id===null||a.parent_run_id===void 0)throw new Error(`Child run ${a.id} has no parent`);a.dotted_order?.startsWith(t.dotted_order??"")&&a.id!==t.id&&(a.parent_run_id in i||(i[a.parent_run_id]=[]),i[a.parent_run_id].push(a),n[a.id]=a)}t.child_runs=i[t.id]||[];for(let a in i)a!==t.id&&(n[a].child_runs=i[a]);return t}async*listRuns(t){let{projectId:r,projectName:i,parentRunId:n,traceId:a,referenceExampleId:o,startTime:s,executionOrder:c,isRoot:l,runType:u,error:d,id:f,query:p,filter:m,traceFilter:h,treeFilter:_,limit:b,select:w,order:S}=t,x=[];if(r&&(x=Array.isArray(r)?r:[r]),i){let v=Array.isArray(i)?i:[i],Z=await Promise.all(v.map(B=>this.readProject({projectName:B}).then(A=>A.id)));x.push(...Z)}let E=["app_path","completion_cost","completion_tokens","dotted_order","end_time","error","events","extra","feedback_stats","first_token_time","id","inputs","name","outputs","parent_run_id","parent_run_ids","prompt_cost","prompt_tokens","reference_example_id","run_type","session_id","start_time","status","tags","total_cost","total_tokens","trace_id"],z={session:x.length?x:null,run_type:u,reference_example:o,query:p,filter:m,trace_filter:h,tree_filter:_,execution_order:c,parent_run:n,start_time:s?s.toISOString():null,error:d,id:f,limit:b,trace:a,select:w||E,is_root:l,order:S};z.select.includes("child_run_ids")&&qa("Deprecated: 'child_run_ids' in the listRuns select parameter is deprecated and will be removed in a future version.");let C=0;for await(let v of this._getCursorPaginatedList("/runs/query",z)){let Z=v.map(hs);if(b){if(C>=b)break;if(Z.length+C>b){yield*Z.slice(0,b-C);break}C+=Z.length,yield*Z}else yield*Z}}async*listGroupRuns(t){let{projectId:r,projectName:i,groupBy:n,filter:a,startTime:o,endTime:s,limit:c,offset:l}=t,d={session_id:r||(await this.readProject({projectName:i})).id,group_by:n,filter:a,start_time:o?o.toISOString():null,end_time:s?s.toISOString():null,limit:Number(c)||100},f=Number(l)||0,p="/runs/group",m=`${this.apiUrl}${p}`;for(;;){let h={...d,offset:f},_=Object.fromEntries(Object.entries(h).filter(([z,C])=>C!==void 0)),b=JSON.stringify(_),S=await(await this.caller.call(async()=>{let z=await this._fetch(m,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:b});return await Q(z,`Failed to fetch ${p}`),z})).json(),{groups:x,total:E}=S;if(x.length===0)break;for(let z of x)yield z;if(f+=x.length,f>=E)break}}async*readThread(t){let{threadId:r,projectId:i,projectName:n,isRoot:a=!0,limit:o,filter:s,order:c="asc"}=t;if(!i&&!n)throw new Error("threadId requires projectId or projectName");let l=`eq(thread_id, ${JSON.stringify(r)})`,u=s?`and(${l}, ${s})`:l;yield*this.listRuns({projectId:i??void 0,projectName:n??void 0,isRoot:a,limit:o,filter:u,order:c})}async listThreads(t){let{projectId:r,projectName:i,limit:n,offset:a=0,filter:o,startTime:s,isRoot:c=!0}=t;if(!r&&!i)throw new Error("Either projectId or projectName must be provided");if(r&&i)throw new Error("Provide exactly one of projectId or projectName");let l=r??(await this.readProject({projectName:i})).id,u=s??new Date(Date.now()-1440*60*1e3),f={session:[l],is_root:c,limit:100,order:"desc",select:["id","name","status","start_time","end_time","thread_id","trace_id","run_type","error","tags","session_id","parent_run_id","total_tokens","total_cost","dotted_order","reference_example_id","feedback_stats","app_path","completion_cost","completion_tokens","prompt_cost","prompt_tokens","first_token_time"],start_time:u.toISOString()};o!=null&&(f.filter=o);let p=new Map;for await(let b of this._getCursorPaginatedList("/runs/query",f))for(let w of b){let S=hs(w),x=S.thread_id;if(x){let E=p.get(x)??[];E.push(S),p.set(x,E)}}let m=[];for(let[b,w]of p.entries()){w.sort((C,v)=>{let Z=C,B=v,A=Z.start_time??"",L=B.start_time??"";if(A!==L)return A.localeCompare(L);let G=Z.dotted_order??"",Y=B.dotted_order??"";return G.localeCompare(Y)});let x=[...w.map(C=>C.start_time).filter(Boolean)].sort(),E=x.length?x[0]:"",z=x.length?x[x.length-1]:"";m.push({thread_id:b,runs:w,count:w.length,filter:"",total_tokens:0,total_cost:null,min_start_time:E,max_start_time:z,latency_p50:0,latency_p99:0,feedback_stats:null,first_inputs:"",last_outputs:"",last_error:null})}m.sort((b,w)=>{let S=b.max_start_time??"";return(w.max_start_time??"").localeCompare(S)});let h=a>0?m.slice(a):m;return n!==void 0?h.slice(0,n):h}async getRunStats({id:t,trace:r,parentRun:i,runType:n,projectNames:a,projectIds:o,referenceExampleIds:s,startTime:c,endTime:l,error:u,query:d,filter:f,traceFilter:p,treeFilter:m,isRoot:h,dataSourceType:_}){let b=o||[];a&&(b=[...o||[],...await Promise.all(a.map(C=>this.readProject({projectName:C}).then(v=>v.id)))]);let S=Object.fromEntries(Object.entries({id:t,trace:r,parent_run:i,run_type:n,session:b,reference_example:s,start_time:c,end_time:l,error:u,query:d,filter:f,trace_filter:p,tree_filter:m,is_root:h,data_source_type:_}).filter(([C,v])=>v!==void 0)),x=JSON.stringify(S);return await(await this.caller.call(async()=>{let C=await this._fetch(`${this.apiUrl}/runs/stats`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:x});return await Q(C,"get run stats"),C})).json()}async shareRun(t,{shareId:r}={}){let i={run_id:t,share_token:r||Ka()};pe(t);let n=JSON.stringify(i),o=await(await this.caller.call(async()=>{let s=await this._fetch(`${this.apiUrl}/runs/${t}/share`,{method:"PUT",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:n});return await Q(s,"share run"),s})).json();if(o===null||!("share_token"in o))throw new Error("Invalid response from server");return`${this.getHostUrl()}/public/${o.share_token}/r`}async unshareRun(t){pe(t),await this.caller.call(async()=>{let r=await this._fetch(`${this.apiUrl}/runs/${t}/share`,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Q(r,"unshare run",!0),r})}async readRunSharedLink(t){pe(t);let i=await(await this.caller.call(async()=>{let n=await this._fetch(`${this.apiUrl}/runs/${t}/share`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Q(n,"read run shared link"),n})).json();if(!(i===null||!("share_token"in i)))return`${this.getHostUrl()}/public/${i.share_token}/r`}async listSharedRuns(t,{runIds:r}={}){let i=new URLSearchParams({share_token:t});if(r!==void 0)for(let o of r)i.append("id",o);return pe(t),(await(await this.caller.call(async()=>{let o=await this._fetch(`${this.apiUrl}/public/${t}/runs${i}`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Q(o,"list shared runs"),o})).json()).map(hs)}async readDatasetSharedSchema(t,r){if(!t&&!r)throw new Error("Either datasetId or datasetName must be given");t||(t=(await this.readDataset({datasetName:r})).id),pe(t);let n=await(await this.caller.call(async()=>{let a=await this._fetch(`${this.apiUrl}/datasets/${t}/share`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Q(a,"read dataset shared schema"),a})).json();return n.url=`${this.getHostUrl()}/public/${n.share_token}/d`,n}async shareDataset(t,r){if(!t&&!r)throw new Error("Either datasetId or datasetName must be given");t||(t=(await this.readDataset({datasetName:r})).id);let i={dataset_id:t};pe(t);let n=JSON.stringify(i),o=await(await this.caller.call(async()=>{let s=await this._fetch(`${this.apiUrl}/datasets/${t}/share`,{method:"PUT",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:n});return await Q(s,"share dataset"),s})).json();return o.url=`${this.getHostUrl()}/public/${o.share_token}/d`,o}async unshareDataset(t){pe(t),await this.caller.call(async()=>{let r=await this._fetch(`${this.apiUrl}/datasets/${t}/share`,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Q(r,"unshare dataset",!0),r})}async readSharedDataset(t){return pe(t),await(await this.caller.call(async()=>{let n=await this._fetch(`${this.apiUrl}/public/${t}/datasets`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Q(n,"read shared dataset"),n})).json()}async listSharedExamples(t,r){let i={};r?.exampleIds&&(i.id=r.exampleIds);let n=new URLSearchParams;Object.entries(i).forEach(([s,c])=>{Array.isArray(c)?c.forEach(l=>n.append(s,l)):n.append(s,c)});let a=await this.caller.call(async()=>{let s=await this._fetch(`${this.apiUrl}/public/${t}/examples?${n.toString()}`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Q(s,"list shared examples"),s}),o=await a.json();if(!a.ok)throw"detail"in o?new Error(`Failed to list shared examples.
140
- Status: ${a.status}
141
- Message: ${Array.isArray(o.detail)?o.detail.join(`
142
- `):"Unspecified error"}`):new Error(`Failed to list shared examples: ${a.status} ${a.statusText}`);return o.map(s=>({...s,_hostUrl:this.getHostUrl()}))}async createProject({projectName:t,description:r=null,metadata:i=null,upsert:n=!1,projectExtra:a=null,referenceDatasetId:o=null,numExamples:s=null,numRepetitions:c=null,evaluatorKeys:l=null}){let u=n?"?upsert=true":"",d=`${this.apiUrl}/sessions${u}`,f=a||{};i&&(f.metadata=i);let p={name:t,extra:f,description:r};o!==null&&(p.reference_dataset_id=o),s!=null&&(p.num_examples=s),c!=null&&(p.num_repetitions=c),l!=null&&l.length>0&&(p.evaluator_keys=l);let m=JSON.stringify(p);return await(await this.caller.call(async()=>{let b=await this._fetch(d,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:m});return await Q(b,"create project"),b})).json()}async updateProject(t,{name:r=null,description:i=null,metadata:n=null,projectExtra:a=null,endTime:o=null}){let s=`${this.apiUrl}/sessions/${t}`,c=a;n&&(c={...c||{},metadata:n});let l=JSON.stringify({name:r,extra:c,description:i,end_time:o?new Date(o).toISOString():null});return await(await this.caller.call(async()=>{let f=await this._fetch(s,{method:"PATCH",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:l});return await Q(f,"update project"),f})).json()}async hasProject({projectId:t,projectName:r}){let i="/sessions",n=new URLSearchParams;if(t!==void 0&&r!==void 0)throw new Error("Must provide either projectName or projectId, not both");if(t!==void 0)pe(t),i+=`/${t}`;else if(r!==void 0)n.append("name",r);else throw new Error("Must provide projectName or projectId");let a=await this.caller.call(async()=>{let o=await this._fetch(`${this.apiUrl}${i}?${n}`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Q(o,"has project"),o});try{let o=await a.json();return a.ok?Array.isArray(o)?o.length>0:!0:!1}catch{return!1}}async readProject({projectId:t,projectName:r,includeStats:i}){let n="/sessions",a=new URLSearchParams;if(t!==void 0&&r!==void 0)throw new Error("Must provide either projectName or projectId, not both");if(t!==void 0)pe(t),n+=`/${t}`;else if(r!==void 0)a.append("name",r);else throw new Error("Must provide projectName or projectId");i!==void 0&&a.append("include_stats",i.toString());let o=await this._get(n,a),s;if(Array.isArray(o)){if(o.length===0)throw new Error(`Project[id=${t}, name=${r}] not found`);s=o[0]}else s=o;return s}async getProjectUrl({projectId:t,projectName:r}){if(t===void 0&&r===void 0)throw new Error("Must provide either projectName or projectId");let i=await this.readProject({projectId:t,projectName:r}),n=await this._getTenantId();return`${this.getHostUrl()}/o/${n}/projects/p/${i.id}`}async getDatasetUrl({datasetId:t,datasetName:r}){if(t===void 0&&r===void 0)throw new Error("Must provide either datasetName or datasetId");let i=await this.readDataset({datasetId:t,datasetName:r}),n=await this._getTenantId();return`${this.getHostUrl()}/o/${n}/datasets/${i.id}`}async _getTenantId(){if(this._tenantId!==null)return this._tenantId;let t=new URLSearchParams({limit:"1"});for await(let r of this._getPaginated("/sessions",t))return this._tenantId=r[0].tenant_id,r[0].tenant_id;throw new Error("No projects found to resolve tenant.")}async*listProjects({projectIds:t,name:r,nameContains:i,referenceDatasetId:n,referenceDatasetName:a,includeStats:o,datasetVersion:s,referenceFree:c,metadata:l}={}){let u=new URLSearchParams;if(t!==void 0)for(let d of t)u.append("id",d);if(r!==void 0&&u.append("name",r),i!==void 0&&u.append("name_contains",i),n!==void 0)u.append("reference_dataset",n);else if(a!==void 0){let d=await this.readDataset({datasetName:a});u.append("reference_dataset",d.id)}o!==void 0&&u.append("include_stats",o.toString()),s!==void 0&&u.append("dataset_version",s),c!==void 0&&u.append("reference_free",c.toString()),l!==void 0&&u.append("metadata",JSON.stringify(l));for await(let d of this._getPaginated("/sessions",u))yield*d}async deleteProject({projectId:t,projectName:r}){let i;if(t===void 0&&r===void 0)throw new Error("Must provide projectName or projectId");if(t!==void 0&&r!==void 0)throw new Error("Must provide either projectName or projectId, not both");t===void 0?i=(await this.readProject({projectName:r})).id:i=t,pe(i),await this.caller.call(async()=>{let n=await this._fetch(`${this.apiUrl}/sessions/${i}`,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Q(n,`delete session ${i} (${r})`,!0),n})}async uploadCsv({csvFile:t,fileName:r,inputKeys:i,outputKeys:n,description:a,dataType:o,name:s}){let c=`${this.apiUrl}/datasets/upload`,l=new FormData,u=new Blob([t],{type:"text/csv"});return l.append("file",u,r),i.forEach(p=>{l.append("input_keys",p)}),n.forEach(p=>{l.append("output_keys",p)}),a&&l.append("description",a),o&&l.append("data_type",o),s&&l.append("name",s),await(await this.caller.call(async()=>{let p=await this._fetch(c,{method:"POST",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:l});return await Q(p,"upload CSV"),p})).json()}async createDataset(t,{description:r,dataType:i,inputsSchema:n,outputsSchema:a,metadata:o}={}){let s={name:t,description:r,extra:{source:"sdk",...o?{metadata:o}:{}}};i&&(s.data_type=i),n&&(s.inputs_schema_definition=n),a&&(s.outputs_schema_definition=a);let c=JSON.stringify(s);return await(await this.caller.call(async()=>{let d=await this._fetch(`${this.apiUrl}/datasets`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:c});return await Q(d,"create dataset"),d})).json()}async readDataset({datasetId:t,datasetName:r}){let i="/datasets",n=new URLSearchParams({limit:"1"});if(t&&r)throw new Error("Must provide either datasetName or datasetId, not both");if(t)pe(t),i+=`/${t}`;else if(r)n.append("name",r);else throw new Error("Must provide datasetName or datasetId");let a=await this._get(i,n),o;if(Array.isArray(a)){if(a.length===0)throw new Error(`Dataset[id=${t}, name=${r}] not found`);o=a[0]}else o=a;return o}async hasDataset({datasetId:t,datasetName:r}){try{return await this.readDataset({datasetId:t,datasetName:r}),!0}catch(i){if(i instanceof Error&&i.message.toLocaleLowerCase().includes("not found"))return!1;throw i}}async diffDatasetVersions({datasetId:t,datasetName:r,fromVersion:i,toVersion:n}){let a=t;if(a===void 0&&r===void 0)throw new Error("Must provide either datasetName or datasetId");if(a!==void 0&&r!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");a===void 0&&(a=(await this.readDataset({datasetName:r})).id);let o=new URLSearchParams({from_version:typeof i=="string"?i:i.toISOString(),to_version:typeof n=="string"?n:n.toISOString()});return await this._get(`/datasets/${a}/versions/diff`,o)}async readDatasetOpenaiFinetuning({datasetId:t,datasetName:r}){let i="/datasets";if(t===void 0)if(r!==void 0)t=(await this.readDataset({datasetName:r})).id;else throw new Error("Must provide either datasetName or datasetId");return(await(await this._getResponse(`${i}/${t}/openai_ft`)).text()).trim().split(`
143
- `).map(s=>JSON.parse(s))}async*listDatasets({limit:t=100,offset:r=0,datasetIds:i,datasetName:n,datasetNameContains:a,metadata:o}={}){let s="/datasets",c=new URLSearchParams({limit:t.toString(),offset:r.toString()});if(i!==void 0)for(let l of i)c.append("id",l);n!==void 0&&c.append("name",n),a!==void 0&&c.append("name_contains",a),o!==void 0&&c.append("metadata",JSON.stringify(o));for await(let l of this._getPaginated(s,c))yield*l}async updateDataset(t){let{datasetId:r,datasetName:i,...n}=t;if(!r&&!i)throw new Error("Must provide either datasetName or datasetId");let a=r??(await this.readDataset({datasetName:i})).id;pe(a);let o=JSON.stringify(n);return await(await this.caller.call(async()=>{let c=await this._fetch(`${this.apiUrl}/datasets/${a}`,{method:"PATCH",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:o});return await Q(c,"update dataset"),c})).json()}async updateDatasetTag(t){let{datasetId:r,datasetName:i,asOf:n,tag:a}=t;if(!r&&!i)throw new Error("Must provide either datasetName or datasetId");let o=r??(await this.readDataset({datasetName:i})).id;pe(o);let s=JSON.stringify({as_of:typeof n=="string"?n:n.toISOString(),tag:a});await this.caller.call(async()=>{let c=await this._fetch(`${this.apiUrl}/datasets/${o}/tags`,{method:"PUT",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:s});return await Q(c,"update dataset tags",!0),c})}async deleteDataset({datasetId:t,datasetName:r}){let i="/datasets",n=t;if(t!==void 0&&r!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");if(r!==void 0&&(n=(await this.readDataset({datasetName:r})).id),n!==void 0)pe(n),i+=`/${n}`;else throw new Error("Must provide datasetName or datasetId");await this.caller.call(async()=>{let a=await this._fetch(this.apiUrl+i,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Q(a,`delete ${i}`,!0),a})}async createExample(t,r,i){if(rI(t)&&(r!==void 0||i!==void 0))throw new Error("Cannot provide outputs or options when using ExampleCreate object");let n=r?i?.datasetId:t.dataset_id,a=r?i?.datasetName:t.dataset_name;if(n===void 0&&a===void 0)throw new Error("Must provide either datasetName or datasetId");if(n!==void 0&&a!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");n===void 0&&(n=(await this.readDataset({datasetName:a})).id);let o=(r?i?.createdAt:t.created_at)||new Date,s;rI(t)?s=t:s={inputs:t,outputs:r,created_at:o?.toISOString(),id:i?.exampleId,metadata:i?.metadata,split:i?.split,source_run_id:i?.sourceRunId,use_source_run_io:i?.useSourceRunIO,use_source_run_attachments:i?.useSourceRunAttachments,attachments:i?.attachments};let c=await this._uploadExamplesMultipart(n,[s]);return await this.readExample(c.example_ids?.[0]??Ka())}async createExamples(t){if(Array.isArray(t)){if(t.length===0)return[];let w=t,S=w[0].dataset_id,x=w[0].dataset_name;if(S===void 0&&x===void 0)throw new Error("Must provide either datasetName or datasetId");if(S!==void 0&&x!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");S===void 0&&(S=(await this.readDataset({datasetName:x})).id);let E=await this._uploadExamplesMultipart(S,w);return await Promise.all(E.example_ids.map(C=>this.readExample(C)))}let{inputs:r,outputs:i,metadata:n,splits:a,sourceRunIds:o,useSourceRunIOs:s,useSourceRunAttachments:c,attachments:l,exampleIds:u,datasetId:d,datasetName:f}=t;if(r===void 0)throw new Error("Must provide inputs when using legacy parameters");let p=d,m=f;if(p===void 0&&m===void 0)throw new Error("Must provide either datasetName or datasetId");if(p!==void 0&&m!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");p===void 0&&(p=(await this.readDataset({datasetName:m})).id);let h=r.map((w,S)=>({dataset_id:p,inputs:w,outputs:i?.[S],metadata:n?.[S],split:a?.[S],id:u?.[S],attachments:l?.[S],source_run_id:o?.[S],use_source_run_io:s?.[S],use_source_run_attachments:c?.[S]})),_=await this._uploadExamplesMultipart(p,h);return await Promise.all(_.example_ids.map(w=>this.readExample(w)))}async createLLMExample(t,r,i){return this.createExample({input:t},{output:r},i)}async createChatExample(t,r,i){let n=t.map(o=>Fg(o)?Bg(o):o),a=Fg(r)?Bg(r):r;return this.createExample({input:n},{output:a},i)}async readExample(t){pe(t);let r=`/examples/${t}`,i=await this._get(r),{attachment_urls:n,...a}=i,o=a;return n&&(o.attachments=Object.entries(n).reduce((s,[c,l])=>(s[c.slice(11)]={presigned_url:l.presigned_url,mime_type:l.mime_type},s),{})),o}async*listExamples({datasetId:t,datasetName:r,exampleIds:i,asOf:n,splits:a,inlineS3Urls:o,metadata:s,limit:c,offset:l,filter:u,includeAttachments:d}={}){let f;if(t!==void 0&&r!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");if(t!==void 0)f=t;else if(r!==void 0)f=(await this.readDataset({datasetName:r})).id;else throw new Error("Must provide a datasetName or datasetId");let p=new URLSearchParams({dataset:f}),m=n?typeof n=="string"?n:n?.toISOString():void 0;m&&p.append("as_of",m);let h=o??!0;if(p.append("inline_s3_urls",h.toString()),i!==void 0)for(let b of i)p.append("id",b);if(a!==void 0)for(let b of a)p.append("splits",b);if(s!==void 0){let b=JSON.stringify(s);p.append("metadata",b)}c!==void 0&&p.append("limit",c.toString()),l!==void 0&&p.append("offset",l.toString()),u!==void 0&&p.append("filter",u),d===!0&&["attachment_urls","outputs","metadata"].forEach(b=>p.append("select",b));let _=0;for await(let b of this._getPaginated("/examples",p)){for(let w of b){let{attachment_urls:S,...x}=w,E=x;S&&(E.attachments=Object.entries(S).reduce((z,[C,v])=>(z[C.slice(11)]={presigned_url:v.presigned_url,mime_type:v.mime_type||void 0},z),{})),yield E,_++}if(c!==void 0&&_>=c)break}}async deleteExample(t){pe(t);let r=`/examples/${t}`;await this.caller.call(async()=>{let i=await this._fetch(this.apiUrl+r,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Q(i,`delete ${r}`,!0),i})}async deleteExamples(t,r){if(t.forEach(i=>pe(i)),r?.hardDelete){let i=this._getPlatformEndpointPath("datasets/examples/delete");await this.caller.call(async()=>{let n=await this._fetch(`${this.apiUrl}${i}`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},body:JSON.stringify({example_ids:t,hard_delete:!0}),signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Q(n,"hard delete examples",!0),n})}else{let i=new URLSearchParams;t.forEach(n=>i.append("example_ids",n)),await this.caller.call(async()=>{let n=await this._fetch(`${this.apiUrl}/examples?${i.toString()}`,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Q(n,"delete examples",!0),n})}}async updateExample(t,r){let i;r?i=t:i=t.id,pe(i);let n;r?n={id:i,...r}:n=t;let a;return n.dataset_id!==void 0?a=n.dataset_id:a=(await this.readExample(i)).dataset_id,this._updateExamplesMultipart(a,[n])}async updateExamples(t){let r;return t[0].dataset_id===void 0?r=(await this.readExample(t[0].id)).dataset_id:r=t[0].dataset_id,this._updateExamplesMultipart(r,t)}async readDatasetVersion({datasetId:t,datasetName:r,asOf:i,tag:n}){let a;if(t?a=t:a=(await this.readDataset({datasetName:r})).id,pe(a),i&&n||!i&&!n)throw new Error("Exactly one of asOf and tag must be specified.");let o=new URLSearchParams;return i!==void 0&&o.append("as_of",typeof i=="string"?i:i.toISOString()),n!==void 0&&o.append("tag",n),await(await this.caller.call(async()=>{let c=await this._fetch(`${this.apiUrl}/datasets/${a}/version?${o.toString()}`,{method:"GET",headers:{...this._mergedHeaders},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Q(c,"read dataset version"),c})).json()}async listDatasetSplits({datasetId:t,datasetName:r,asOf:i}){let n;if(t===void 0&&r===void 0)throw new Error("Must provide dataset name or ID");if(t!==void 0&&r!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");t===void 0?n=(await this.readDataset({datasetName:r})).id:n=t,pe(n);let a=new URLSearchParams,o=i?typeof i=="string"?i:i?.toISOString():void 0;return o&&a.append("as_of",o),await this._get(`/datasets/${n}/splits`,a)}async updateDatasetSplits({datasetId:t,datasetName:r,splitName:i,exampleIds:n,remove:a=!1}){let o;if(t===void 0&&r===void 0)throw new Error("Must provide dataset name or ID");if(t!==void 0&&r!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");t===void 0?o=(await this.readDataset({datasetName:r})).id:o=t,pe(o);let s={split_name:i,examples:n.map(l=>(pe(l),l)),remove:a},c=JSON.stringify(s);await this.caller.call(async()=>{let l=await this._fetch(`${this.apiUrl}/datasets/${o}/splits`,{method:"PUT",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:c});return await Q(l,"update dataset splits",!0),l})}async createFeedback(t,r,{score:i,value:n,correction:a,comment:o,sourceInfo:s,feedbackSourceType:c="api",sourceRunId:l,feedbackId:u,feedbackConfig:d,projectId:f,comparativeExperimentId:p,sessionId:m,startTime:h}){if(!t&&!f)throw new Error("One of runId or projectId must be provided");if(t&&f)throw new Error("Only one of runId or projectId can be provided");let _={type:c??"api",metadata:s??{}};l!==void 0&&_?.metadata!==void 0&&!_.metadata.__run&&(_.metadata.__run={run_id:l}),_?.metadata!==void 0&&_.metadata.__run?.run_id!==void 0&&pe(_.metadata.__run.run_id);let b={id:u??cs(),run_id:t,key:r,score:tI(i),value:n,correction:a,comment:o,feedback_source:_,comparative_experiment_id:p,feedbackConfig:d,session_id:m??f,start_time:h},w=JSON.stringify(b),S=`${this.apiUrl}/feedback`;return await this.caller.call(async()=>{let x=await this._fetch(S,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:w});return await Q(x,"create feedback",!0),x}),b}async updateFeedback(t,{score:r,value:i,correction:n,comment:a}){let o={};r!=null&&(o.score=tI(r)),i!=null&&(o.value=i),n!=null&&(o.correction=n),a!=null&&(o.comment=a),pe(t);let s=JSON.stringify(o);await this.caller.call(async()=>{let c=await this._fetch(`${this.apiUrl}/feedback/${t}`,{method:"PATCH",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:s});return await Q(c,"update feedback",!0),c})}async readFeedback(t){pe(t);let r=`/feedback/${t}`;return await this._get(r)}async deleteFeedback(t){pe(t);let r=`/feedback/${t}`;await this.caller.call(async()=>{let i=await this._fetch(this.apiUrl+r,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Q(i,`delete ${r}`,!0),i})}async*listFeedback({runIds:t,feedbackKeys:r,feedbackSourceTypes:i}={}){let n=new URLSearchParams;if(t)for(let a of t)pe(a),n.append("run",a);if(r)for(let a of r)n.append("key",a);if(i)for(let a of i)n.append("source",a);for await(let a of this._getPaginated("/feedback",n))yield*a}async createPresignedFeedbackToken(t,r,{expiration:i,feedbackConfig:n}={}){let a={run_id:t,feedback_key:r,feedback_config:n};i?typeof i=="string"?a.expires_at=i:(i?.hours||i?.minutes||i?.days)&&(a.expires_in=i):a.expires_in={hours:3};let o=JSON.stringify(a);return await(await this.caller.call(async()=>{let c=await this._fetch(`${this.apiUrl}/feedback/tokens`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:o});return await Q(c,"create presigned feedback token"),c})).json()}async createComparativeExperiment({name:t,experimentIds:r,referenceDatasetId:i,createdAt:n,description:a,metadata:o,id:s}){if(r.length===0)throw new Error("At least one experiment is required");if(i||(i=(await this.readProject({projectId:r[0]})).reference_dataset_id),!i==null)throw new Error("A reference dataset is required");let c={id:s,name:t,experiment_ids:r,reference_dataset_id:i,description:a,created_at:(n??new Date)?.toISOString(),extra:{}};o&&(c.extra.metadata=o);let l=JSON.stringify(c);return(await this.caller.call(async()=>{let d=await this._fetch(`${this.apiUrl}/datasets/comparative`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:l});return await Q(d,"create comparative experiment"),d})).json()}async*listPresignedFeedbackTokens(t){pe(t);let r=new URLSearchParams({run_id:t});for await(let i of this._getPaginated("/feedback/tokens",r))yield*i}_selectEvalResults(t){let r;return"results"in t?r=t.results:Array.isArray(t)?r=t:r=[t],r}async _logEvaluationFeedback(t,r,i){let n=this._selectEvalResults(t),a=[];for(let o of n){let s=i||{};o.evaluatorInfo&&(s={...o.evaluatorInfo,...s});let c=null;o.targetRunId?c=o.targetRunId:r&&(c=r.id),a.push(await this.createFeedback(c,o.key,{score:o.score,value:o.value,comment:o.comment,correction:o.correction,sourceInfo:s,sourceRunId:o.sourceRunId,feedbackConfig:o.feedbackConfig,feedbackSourceType:"model",sessionId:r?.session_id,startTime:r?.start_time}))}return[n,a]}async logEvaluationFeedback(t,r,i){let[n]=await this._logEvaluationFeedback(t,r,i);return n}async createFeedbackConfig(t){let{feedbackKey:r,feedbackConfig:i,isLowerScoreBetter:n=!1}=t,a={feedback_key:r,feedback_config:i,is_lower_score_better:n};return(await this.caller.call(async()=>{let s=await this._fetch(`${this.apiUrl}/feedback-configs`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:JSON.stringify(a)});return await Q(s,"create feedback config"),s})).json()}async*listFeedbackConfigs(t={}){let{feedbackKeys:r,nameContains:i,limit:n}=t,a=new URLSearchParams;r&&r.forEach(s=>{a.append("key",s)}),i&&a.append("name_contains",i),a.append("limit",(n!==void 0?Math.min(n,100):100).toString());let o=0;for await(let s of this._getPaginated("/feedback-configs",a))if(yield*s,o+=s.length,n!==void 0&&o>=n)break}async updateFeedbackConfig(t,r={}){let{feedbackConfig:i,isLowerScoreBetter:n}=r,a={feedback_key:t};return i!==void 0&&(a.feedback_config=i),n!==void 0&&(a.is_lower_score_better=n),(await this.caller.call(async()=>{let s=await this._fetch(`${this.apiUrl}/feedback-configs`,{method:"PATCH",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:JSON.stringify(a)});return await Q(s,"update feedback config"),s})).json()}async deleteFeedbackConfig(t){let r=new URLSearchParams({feedback_key:t});await this.caller.call(async()=>{let i=await this._fetch(`${this.apiUrl}/feedback-configs?${r}`,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Q(i,"delete feedback config",!0),i})}async*listAnnotationQueues(t={}){let{queueIds:r,name:i,nameContains:n,limit:a}=t,o=new URLSearchParams;r&&r.forEach((c,l)=>{pe(c,`queueIds[${l}]`),o.append("ids",c)}),i&&o.append("name",i),n&&o.append("name_contains",n),o.append("limit",(a!==void 0?Math.min(a,100):100).toString());let s=0;for await(let c of this._getPaginated("/annotation-queues",o))if(yield*c,s++,a!==void 0&&s>=a)break}async createAnnotationQueue(t){let{name:r,description:i,queueId:n,rubricInstructions:a,rubricItems:o}=t,s={name:r,description:i,id:n||Ka(),rubric_instructions:a,rubric_items:o},c=JSON.stringify(Object.fromEntries(Object.entries(s).filter(([u,d])=>d!==void 0)));return(await this.caller.call(async()=>{let u=await this._fetch(`${this.apiUrl}/annotation-queues`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:c});return await Q(u,"create annotation queue"),u})).json()}async readAnnotationQueue(t){return(await this.caller.call(async()=>{let i=await this._fetch(`${this.apiUrl}/annotation-queues/${pe(t,"queueId")}`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Q(i,"read annotation queue"),i})).json()}async updateAnnotationQueue(t,r){let{name:i,description:n,rubricInstructions:a,rubricItems:o}=r,s={};i!==void 0&&(s.name=i),n!==void 0&&(s.description=n),a!==void 0&&(s.rubric_instructions=a),o!==void 0&&(s.rubric_items=o);let c=JSON.stringify(s);await this.caller.call(async()=>{let l=await this._fetch(`${this.apiUrl}/annotation-queues/${pe(t,"queueId")}`,{method:"PATCH",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:c});return await Q(l,"update annotation queue",!0),l})}async deleteAnnotationQueue(t){await this.caller.call(async()=>{let r=await this._fetch(`${this.apiUrl}/annotation-queues/${pe(t,"queueId")}`,{method:"DELETE",headers:{...this._mergedHeaders,Accept:"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Q(r,"delete annotation queue",!0),r})}async addRunsToAnnotationQueue(t,r){let i=JSON.stringify(r.map((n,a)=>pe(n,`runIds[${a}]`).toString()));await this.caller.call(async()=>{let n=await this._fetch(`${this.apiUrl}/annotation-queues/${pe(t,"queueId")}/runs`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:i});return await Q(n,"add runs to annotation queue",!0),n})}async getRunFromAnnotationQueue(t,r){let i=`/annotation-queues/${pe(t,"queueId")}/run`,a=await(await this.caller.call(async()=>{let o=await this._fetch(`${this.apiUrl}${i}/${r}`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Q(o,"get run from annotation queue"),o})).json();return hs(a)}async*listRunsFromAnnotationQueue(t,r={}){let{status:i,limit:n}=r,a=new URLSearchParams,o=n!==void 0&&Number.isFinite(n)?Math.min(n,100):100;i&&a.append("status",i),a.append("limit",o.toString());let s=0,c=`/annotation-queues/${pe(t,"queueId")}/runs`;for await(let l of this._getPaginated(c,a))for(let u of l)if(yield hs(u),s++,s>=o)return}async deleteRunFromAnnotationQueue(t,r){await this.caller.call(async()=>{let i=await this._fetch(`${this.apiUrl}/annotation-queues/${pe(t,"queueId")}/runs/${pe(r,"queueRunId")}`,{method:"DELETE",headers:{...this._mergedHeaders,Accept:"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Q(i,"delete run from annotation queue",!0),i})}async getSizeFromAnnotationQueue(t){return(await this.caller.call(async()=>{let i=await this._fetch(`${this.apiUrl}/annotation-queues/${pe(t,"queueId")}/size`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Q(i,"get size from annotation queue"),i})).json()}async _currentTenantIsOwner(t){let r=await this._getSettings();return t=="-"||r.tenant_handle===t}async _ownerConflictError(t,r){let i=await this._getSettings();return new Error(`Cannot ${t} for another tenant.
144
-
145
- Current tenant: ${i.tenant_handle}
146
-
147
- Requested tenant: ${r}`)}async _getLatestCommitHash(t){let i=await(await this.caller.call(async()=>{let n=await this._fetch(`${this.apiUrl}/commits/${t}/?limit=1&offset=0`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Q(n,"get latest commit hash"),n})).json();if(i.commits.length!==0)return i.commits[0].commit_hash}async _createCommitTags(t,r,i){let n=typeof i=="string"?[i]:i;await Promise.all(n.map(async a=>this.caller.call(async()=>{let o=await this._fetch(`${this.apiUrl}/repos/${t}/tags`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:JSON.stringify({tag_name:a,commit_id:r})});return await Q(o,"create commit tag"),o})))}async _likeOrUnlikePrompt(t,r){let[i,n,a]=Ut(t),o=JSON.stringify({like:r});return(await this.caller.call(async()=>{let c=await this._fetch(`${this.apiUrl}/likes/${i}/${n}`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:o});return await Q(c,`${r?"like":"unlike"} prompt`),c})).json()}async _getPromptUrl(t){let[r,i,n]=Ut(t);if(await this._currentTenantIsOwner(r)){let a=await this._getSettings();return n!=="latest"?`${this.getHostUrl()}/prompts/${i}/${n.substring(0,8)}?organizationId=${a.id}`:`${this.getHostUrl()}/prompts/${i}?organizationId=${a.id}`}else return n!=="latest"?`${this.getHostUrl()}/hub/${r}/${i}/${n.substring(0,8)}`:`${this.getHostUrl()}/hub/${r}/${i}`}async promptExists(t){return!!await this.getPrompt(t)}async likePrompt(t){return this._likeOrUnlikePrompt(t,!0)}async unlikePrompt(t){return this._likeOrUnlikePrompt(t,!1)}async*listCommits(t){let[r,i,n]=Ut(t);for await(let a of this._getPaginated(`/commits/${r}/${i}/`,new URLSearchParams,o=>o.commits))yield*a}async*listPrompts(t){let r=new URLSearchParams;r.append("sort_field",t?.sortField??"updated_at"),r.append("sort_direction","desc"),r.append("is_archived",(!!t?.isArchived).toString()),t?.isPublic!==void 0&&r.append("is_public",t.isPublic.toString()),t?.query&&r.append("query",t.query);for await(let i of this._getPaginated("/repos",r,n=>n.repos))yield*i}async getPrompt(t){let[r,i,n]=Ut(t),o=await(await this.caller.call(async()=>{let s=await this._fetch(`${this.apiUrl}/repos/${r}/${i}`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return s?.status===404?null:(await Q(s,"get prompt"),s)}))?.json();return o?.repo?o.repo:null}async createPrompt(t,r){let i=await this._getSettings();if(r?.isPublic&&!i.tenant_handle)throw new Error(`Cannot create a public prompt without first
148
-
149
- creating a LangChain Hub handle.
150
- You can add a handle by creating a public prompt at:
151
-
152
- https://smith.langchain.com/prompts`);let[n,a,o]=Ut(t);if(!await this._currentTenantIsOwner(n))throw await this._ownerConflictError("create a prompt",n);let s={repo_handle:a,...r?.description&&{description:r.description},...r?.readme&&{readme:r.readme},...r?.tags&&{tags:r.tags},is_public:!!r?.isPublic},c=JSON.stringify(s),l=await this.caller.call(async()=>{let d=await this._fetch(`${this.apiUrl}/repos/`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:c});return await Q(d,"create prompt"),d}),{repo:u}=await l.json();return u}async createCommit(t,r,i){if(!await this.promptExists(t))throw new Error("Prompt does not exist, you must create it first.");let[n,a,o]=Ut(t),s=i?.parentCommitHash==="latest"||!i?.parentCommitHash?await this._getLatestCommitHash(`${n}/${a}`):i?.parentCommitHash,c={manifest:JSON.parse(JSON.stringify(r)),parent_commit:s,...i?.description!==void 0&&{description:i.description}},l=JSON.stringify(c),d=await(await this.caller.call(async()=>{let p=await this._fetch(`${this.apiUrl}/commits/${n}/${a}`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:l});return await Q(p,"create commit"),p})).json(),f=d.commit??d;return i?.tags&&await this._createCommitTags(`${n}/${a}`,f.id,i.tags),this._getPromptUrl(`${n}/${a}${f.commit_hash?`:${f.commit_hash}`:""}`)}async updateExamplesMultipart(t,r=[]){return this._updateExamplesMultipart(t,r)}async _updateExamplesMultipart(t,r=[]){if(!await this._getDatasetExamplesMultiPartSupport())throw new Error("Your LangSmith deployment does not allow using the multipart examples endpoint, please upgrade your deployment to the latest version.");let i=new FormData;for(let o of r){let s=o.id,c={...o.metadata&&{metadata:o.metadata},...o.split&&{split:o.split}},l=Lt(c,`Serializing body for example with id: ${s}`),u=new Blob([l],{type:"application/json"});if(i.append(s,u),o.inputs){let d=Lt(o.inputs,`Serializing inputs for example with id: ${s}`),f=new Blob([d],{type:"application/json"});i.append(`${s}.inputs`,f)}if(o.outputs){let d=Lt(o.outputs,`Serializing outputs whle updating example with id: ${s}`),f=new Blob([d],{type:"application/json"});i.append(`${s}.outputs`,f)}if(o.attachments)for(let[d,f]of Object.entries(o.attachments)){let p,m;Array.isArray(f)?[p,m]=f:(p=f.mimeType,m=f.data);let h=new Blob([m],{type:`${p}; length=${m.byteLength}`});i.append(`${s}.attachment.${d}`,h)}if(o.attachments_operations){let d=Lt(o.attachments_operations,`Serializing attachments while updating example with id: ${s}`),f=new Blob([d],{type:"application/json"});i.append(`${s}.attachments_operations`,f)}}let n=t??r[0]?.dataset_id;return(await this.caller.call(async()=>{let o=await this._fetch(`${this.apiUrl}${this._getPlatformEndpointPath(`datasets/${n}/examples`)}`,{method:"PATCH",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:i});return await Q(o,"update examples"),o})).json()}async uploadExamplesMultipart(t,r=[]){return this._uploadExamplesMultipart(t,r)}async _uploadExamplesMultipart(t,r=[]){if(!await this._getDatasetExamplesMultiPartSupport())throw new Error("Your LangSmith deployment does not allow using the multipart examples endpoint, please upgrade your deployment to the latest version.");let i=new FormData;for(let a of r){let o=(a.id??Ka()).toString(),s={created_at:a.created_at,...a.metadata&&{metadata:a.metadata},...a.split&&{split:a.split},...a.source_run_id&&{source_run_id:a.source_run_id},...a.use_source_run_io&&{use_source_run_io:a.use_source_run_io},...a.use_source_run_attachments&&{use_source_run_attachments:a.use_source_run_attachments}},c=Lt(s,`Serializing body for uploaded example with id: ${o}`),l=new Blob([c],{type:"application/json"});if(i.append(o,l),a.inputs){let u=Lt(a.inputs,`Serializing inputs for uploaded example with id: ${o}`),d=new Blob([u],{type:"application/json"});i.append(`${o}.inputs`,d)}if(a.outputs){let u=Lt(a.outputs,`Serializing outputs for uploaded example with id: ${o}`),d=new Blob([u],{type:"application/json"});i.append(`${o}.outputs`,d)}if(a.attachments)for(let[u,d]of Object.entries(a.attachments)){let f,p;Array.isArray(d)?[f,p]=d:(f=d.mimeType,p=d.data);let m=new Blob([p],{type:`${f}; length=${p.byteLength}`});i.append(`${o}.attachment.${u}`,m)}}return(await this.caller.call(async()=>{let a=await this._fetch(`${this.apiUrl}${this._getPlatformEndpointPath(`datasets/${t}/examples`)}`,{method:"POST",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:i});return await Q(a,"upload examples"),a})).json()}async updatePrompt(t,r){if(!await this.promptExists(t))throw new Error("Prompt does not exist, you must create it first.");let[i,n]=Ut(t);if(!await this._currentTenantIsOwner(i))throw await this._ownerConflictError("update a prompt",i);let a={};if(r?.description!==void 0&&(a.description=r.description),r?.readme!==void 0&&(a.readme=r.readme),r?.tags!==void 0&&(a.tags=r.tags),r?.isPublic!==void 0&&(a.is_public=r.isPublic),r?.isArchived!==void 0&&(a.is_archived=r.isArchived),Object.keys(a).length===0)throw new Error("No valid update options provided");let o=JSON.stringify(a);return(await this.caller.call(async()=>{let c=await this._fetch(`${this.apiUrl}/repos/${i}/${n}`,{method:"PATCH",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:o});return await Q(c,"update prompt"),c})).json()}async deletePrompt(t){if(!await this.promptExists(t))throw new Error("Prompt does not exist, you must create it first.");let[r,i,n]=Ut(t);if(!await this._currentTenantIsOwner(r))throw await this._ownerConflictError("delete a prompt",r);return(await this.caller.call(async()=>{let o=await this._fetch(`${this.apiUrl}/repos/${r}/${i}`,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Q(o,"delete prompt"),o})).json()}_getPromptCacheKey(t,r){return`${t}${r?":with_model":""}`}async _fetchPromptFromApi(t,r){let[i,n,a]=Ut(t),s=await(await this.caller.call(async()=>{let c=await this._fetch(`${this.apiUrl}/commits/${i}/${n}/${a}${r?.includeModel?"?include_model=true":""}`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Q(c,"pull prompt commit"),c})).json();return{owner:i,repo:n,commit_hash:s.commit_hash,manifest:s.manifest,examples:s.examples,hub_model_config:s.model_config,hub_model_provider:s.model_provider}}async pullPromptCommit(t,r){Ez(t,r?.dangerouslyPullPublicPrompt);let i=this._fetchPromptFromApi.bind(this,t,r);if(!r?.skipCache&&this._promptCache){let n=this._getPromptCacheKey(t,r?.includeModel),a=this._promptCache.get(n,i);if(a)return a;let o=await i();return this._promptCache.set(n,o,i),o}return this._fetchPromptFromApi(t,r)}async _pullPrompt(t,r){let i=await this.pullPromptCommit(t,{includeModel:r?.includeModel,skipCache:r?.skipCache,dangerouslyPullPublicPrompt:r?.dangerouslyPullPublicPrompt});return JSON.stringify(i.manifest)}async pushPrompt(t,r){return await this.promptExists(t)?r&&["description","readme","tags","isPublic"].some(n=>r[n]!==void 0)&&await this.updatePrompt(t,{description:r?.description,readme:r?.readme,tags:r?.tags,isPublic:r?.isPublic}):await this.createPrompt(t,{description:r?.description,readme:r?.readme,tags:r?.tags,isPublic:r?.isPublic}),r?.object?await this.createCommit(t,r?.object,{parentCommitHash:r?.parentCommitHash,tags:r?.commitTags,description:r?.commitDescription}):await this._getPromptUrl(t)}async agentExists(t){let[r,i]=Ut(t);return this._repoExists(r,i)}async skillExists(t){let[r,i]=Ut(t);return this._repoExists(r,i)}async pullAgent(t,r){return await this._pullDirectory(t,"agent",r?.version)}async pullSkill(t,r){return await this._pullDirectory(t,"skill",r?.version)}async pushAgent(t,r){return this._pushDirectory(t,"agent",r)}async pushSkill(t,r){return this._pushDirectory(t,"skill",r)}async deleteAgent(t){return this._deleteDirectory(t)}async deleteSkill(t){return this._deleteDirectory(t)}async*listAgents(t){yield*this._listReposByType("agent",t)}async*listSkills(t){yield*this._listReposByType("skill",t)}async*_listReposByType(t,r){let i=new URLSearchParams;i.append("repo_type",t),i.append("is_archived",(!!r?.isArchived).toString()),r?.isPublic!==void 0&&i.append("is_public",r.isPublic.toString()),r?.query&&i.append("query",r.query);for await(let n of this._getPaginated("/repos",i,a=>a.repos))yield*n}async _pullDirectory(t,r,i){let[n,a,o]=Ut(t),s=i??(o!=="latest"?o:void 0),c=new URL(`${this.apiUrl}${this._getPlatformEndpointPath(`hub/repos/${n}/${a}/directories`)}`);return c.searchParams.set("repo_type",r),s&&c.searchParams.set("commit",s),await(await this.caller.call(async()=>{let u=await this._fetch(c.toString(),{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Q(u,"pull directory"),u})).json()}async _pushDirectory(t,r,i){if(i.parentCommit!==void 0&&(i.parentCommit.length<8||i.parentCommit.length>64))throw new Error("parent_commit must be 8-64 characters");let[n,a]=Ut(t);if(!await this._currentTenantIsOwner(n))throw await this._ownerConflictError(`push ${r}`,n);if(await this._repoExists(n,a))(i.description!==void 0||i.readme!==void 0||i.tags!==void 0||i.isPublic!==void 0)&&await this._updateRepoMetadata(n,a,i);else{let f=/^[a-z][a-z0-9-_]*$/;if(!f.test(a))throw new Error(`Invalid repo_handle ${JSON.stringify(a)}: must match ${f}`);await this._createRepo(a,r,i)}let o={files:i.files};i.parentCommit&&(o.parent_commit=i.parentCommit);let l=(await(await this.caller.call(async()=>{let f=await this._fetch(`${this.apiUrl}${this._getPlatformEndpointPath(`hub/repos/${n}/${a}/directories/commits`)}`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:JSON.stringify(o)});return await Q(f,`push ${r}`),f})).json()).commit.commit_hash,u=await this._getSettings(),d=new URLSearchParams({organizationId:u.id});return`${this.getHostUrl()}/context/${a}/${l.slice(0,8)}?${d.toString()}`}async _deleteDirectory(t){let[r,i]=Ut(t);if(!await this._currentTenantIsOwner(r))throw await this._ownerConflictError("delete",r);await this.caller.call(async()=>{let n=await this._fetch(`${this.apiUrl}${this._getPlatformEndpointPath(`hub/repos/${r}/${i}/directories`)}`,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Q(n,"delete directory"),n})}async _repoExists(t,r){try{return await this.caller.call(async()=>{let i=await this._fetch(`${this.apiUrl}/repos/${t}/${r}`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await Q(i,"check repo exists"),i}),!0}catch(i){if(Vd(i))return!1;throw i}}async _createRepo(t,r,i){let n={repo_handle:t,repo_type:r,is_public:!!i.isPublic};i.description!==void 0&&(n.description=i.description),i.readme!==void 0&&(n.readme=i.readme),i.tags!==void 0&&(n.tags=i.tags);try{await this.caller.call(async()=>{let a=await this._fetch(`${this.apiUrl}/repos/`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:JSON.stringify(n)});return await Q(a,`create ${r}`),a})}catch(a){if(zE(a))return;throw a}}async _updateRepoMetadata(t,r,i){let n={};i.description!==void 0&&(n.description=i.description),i.readme!==void 0&&(n.readme=i.readme),i.tags!==void 0&&(n.tags=i.tags),i.isPublic!==void 0&&(n.is_public=i.isPublic),Object.keys(n).length!==0&&await this.caller.call(async()=>{let a=await this._fetch(`${this.apiUrl}/repos/${t}/${r}`,{method:"PATCH",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:JSON.stringify(n)});return await Q(a,"update repo metadata"),a})}async clonePublicDataset(t,r={}){let{sourceApiUrl:i=this.apiUrl,datasetName:n}=r,[a,o]=this.parseTokenOrUrl(t,i),s=new e({apiUrl:a,apiKey:"placeholder"}),c=await s.readSharedDataset(o),l=n||c.name;try{if(await this.hasDataset({datasetId:l})){console.log(`Dataset ${l} already exists in your tenant. Skipping.`);return}}catch{}let u=await s.listSharedExamples(o),d=await this.createDataset(l,{description:c.description,dataType:c.data_type||"kv",inputsSchema:c.inputs_schema_definition??void 0,outputsSchema:c.outputs_schema_definition??void 0});try{await this.createExamples({inputs:u.map(f=>f.inputs),outputs:u.flatMap(f=>f.outputs?[f.outputs]:[]),datasetId:d.id})}catch(f){throw console.error(`An error occurred while creating dataset ${l}. You should delete it manually.`),f}}parseTokenOrUrl(t,r,i=2,n="dataset"){try{return pe(t),[r,t]}catch{}try{let o=new URL(t).pathname.split("/").filter(s=>s!=="");if(o.length>=i){let s=o[o.length-i];return[r,s]}else throw new Error(`Invalid public ${n} URL: ${t}`)}catch{throw new Error(`Invalid public ${n} URL or token: ${t}`)}}cleanup(){this._promptCache&&this._promptCache.stop()}async awaitPendingTraceBatches(){if(this.manualFlushMode)return console.warn("[WARNING]: When tracing in manual flush mode, you must call `await client.flush()` manually to submit trace batches."),Promise.resolve();for(await new Promise(t=>setTimeout(t,1));this._pendingDrains.size>0;)await Promise.all([...this._pendingDrains]);await Promise.all([...this.autoBatchQueue.items.map(({itemPromise:t})=>t),this.batchIngestCaller.queue.onIdle()]),this.langSmithToOTELTranslator!==void 0&&await $E()?.DEFAULT_LANGSMITH_SPAN_PROCESSOR?.forceFlush()}toString(){let t=[`apiUrl=${JSON.stringify(this.apiUrl)}`];return this.webUrl!==void 0&&t.push(`webUrl=${JSON.stringify(this.webUrl)}`),this.workspaceId!==void 0&&t.push(`workspaceId=${JSON.stringify(this.workspaceId)}`),`[LangSmithClient ${t.join(" ")}]`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}};Object.defineProperty(Dn,"_fallbackDirsCreated",{enumerable:!0,configurable:!0,writable:!0,value:new Set});function rI(e){return"dataset_id"in e||"dataset_name"in e}var iI=e=>e!==void 0?e:!!["TRACING_V2","TRACING"].find(r=>Fe(r)==="true");var Ln=Symbol.for("lc:context_variables");var Jd=Symbol.for("langsmith:replica_trace_roots");function Xg(e,t){if(Ln in e)return e[Ln][t]}function aI(e,t,r){let i=Ln in e?e[Ln]:{};i[t]=r,e[Ln]=i}var nl=36,Rz="6ba7b810-9dad-11d1-80b4-00c04fd430c8";function oI(e){let r=Object.keys(e).sort().map(i=>`${i}:${e[i]??""}`).join("|");return lg(r,Rz)}function Mz(e){return e.replace(/[-:.]/g,"")}function cI(e,t=1){let r=t.toFixed(0).slice(0,3).padStart(3,"0");return`${new Date(e).toISOString().slice(0,-1)}${r}Z`}function Yg(e,t,r=1){let i=cI(e,r);return{dottedOrder:Mz(i)+t,microsecondPrecisionDatestring:i}}var jz=new Set(["projectName","updates","reroot"]);function zz(e){let t={};for(let r of Object.keys(e))jz.has(r)&&(t[r]=e[r]);return t}var Kd=class e{constructor(t,r,i,n){Object.defineProperty(this,"metadata",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"tags",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"project_name",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"replicas",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.metadata=t,this.tags=r,this.project_name=i,this.replicas=n}static fromHeader(t){let r=t.split(","),i={},n=[],a,o;for(let s of r){let[c,l]=s.split("="),u=decodeURIComponent(l);c==="langsmith-metadata"?i=JSON.parse(u):c==="langsmith-tags"?n=u.split(","):c==="langsmith-project"?a=u:c==="langsmith-replicas"&&(o=JSON.parse(u).map(f=>Array.isArray(f)?f:zz(f)))}return new e(i,n,a,o)}toHeader(){let t=[];return this.metadata&&Object.keys(this.metadata).length>0&&t.push(`langsmith-metadata=${encodeURIComponent(JSON.stringify(this.metadata))}`),this.tags&&this.tags.length>0&&t.push(`langsmith-tags=${encodeURIComponent(this.tags.join(","))}`),this.project_name&&t.push(`langsmith-project=${encodeURIComponent(this.project_name)}`),t.join(",")}},sn=class e{constructor(t){if(Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"run_type",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"project_name",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"parent_run",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"parent_run_id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"child_runs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"start_time",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"end_time",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"extra",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"tags",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"error",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"serialized",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"inputs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"outputs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"reference_example_id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"client",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"events",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"trace_id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"dotted_order",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"tracingEnabled",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"execution_order",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"child_execution_order",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"attachments",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"replicas",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"distributedParentId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_serialized_start_time",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_awaitInputsOnPost",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),lI(t)){Object.assign(this,{...t});return}let r=e.getDefaultConfig(),{metadata:i,...n}=t,a=n.client??e.getSharedClient(),o={...i,...n?.extra?.metadata};if(n.extra={...n.extra,metadata:o},"id"in n&&n.id==null&&delete n.id,Object.assign(this,{...r,...n,client:a}),this.execution_order??=1,this.child_execution_order??=1,this.dotted_order||(this._serialized_start_time=cI(this.start_time,this.execution_order)),this.id||(this.id=kd(this._serialized_start_time??this.start_time)),this.trace_id||(this.parent_run?this.trace_id=this.parent_run.trace_id??this.id:this.trace_id=this.id),this.replicas=Fz(this.replicas),!this.dotted_order){let{dottedOrder:s}=Yg(this.start_time,this.id,this.execution_order);this.parent_run?this.dotted_order=this.parent_run.dotted_order+"."+s:this.dotted_order=s}}set metadata(t){this.extra={...this.extra,metadata:{...this.extra?.metadata,...t}}}get metadata(){return this.extra?.metadata}static getDefaultConfig(){let t=Date.now();return{run_type:"chain",project_name:Yc(),child_runs:[],api_url:Et("LANGCHAIN_ENDPOINT")??"http://localhost:1984",api_key:Et("LANGCHAIN_API_KEY"),caller_options:{},start_time:t,serialized:{},inputs:{},extra:{}}}static getSharedClient(){return e.sharedClient||(e.sharedClient=new Dn),e.sharedClient}createChild(t){let r=this.child_execution_order+1,i=this.replicas?.map(f=>{let{reroot:p,...m}=f;return m}),n=t.replicas??i,a=new e({...t,parent_run:this,project_name:this.project_name,replicas:n,client:this.client,tracingEnabled:this.tracingEnabled,execution_order:r,child_execution_order:r}),o=this.extra?.metadata??{},s=a.extra?.metadata??{};Object.keys(o).length>0&&(a.extra={...a.extra,metadata:{...o,...s}}),Ln in this&&(a[Ln]=this[Ln]);let c=Symbol.for("lc:child_config"),l=t.extra?.[c]??this.extra[c];if(Uz(l)){let f={...l},p=Dz(f.callbacks)?f.callbacks.copy?.():void 0;p&&(Object.assign(p,{_parentRunId:a.id}),p.handlers?.find(uI)?.updateFromRunTree?.(a),f.callbacks=p),a.extra[c]=f}let u=new Set,d=this;for(;d!=null&&!u.has(d.id);)u.add(d.id),d.child_execution_order=Math.max(d.child_execution_order,r),d=d.parent_run;return this.child_runs.push(a),a}async end(t,r,i=Date.now(),n){this.outputs=this.outputs??t,this.error=this.error??r,this.end_time=this.end_time??i,n&&Object.keys(n).length>0&&(this.extra=this.extra?{...this.extra,metadata:{...this.extra.metadata,...n}}:{metadata:n})}_convertToCreate(t,r,i=!0){let n=t.extra??{};if(n?.runtime?.library===void 0&&(n.runtime||(n.runtime={}),r))for(let[s,c]of Object.entries(r))n.runtime[s]||(n.runtime[s]=c);let a=t.parent_run?.id??t.parent_run_id,o;return i?o=[]:o=t.child_runs.map(s=>this._convertToCreate(s,r,i)),{id:t.id,name:t.name,start_time:t._serialized_start_time??t.start_time,end_time:t.end_time,run_type:t.run_type,reference_example_id:t.reference_example_id,extra:n,serialized:t.serialized,error:t.error,inputs:t.inputs,outputs:t.outputs,session_name:t.project_name,child_runs:o,parent_run_id:a,trace_id:t.trace_id,dotted_order:t.dotted_order,tags:t.tags,attachments:t.attachments,events:t.events}}_sliceParentId(t,r){if(r.dotted_order){let i=r.dotted_order.split("."),n=null;for(let a=0;a<i.length;a++)if(i[a].slice(-nl)===t){n=a;break}if(n!==null){let a=i.slice(n+1);r.dotted_order=a.join("."),a.length>0?r.trace_id=a[0].slice(-nl):r.trace_id=r.id}}r.parent_run_id===t&&(r.parent_run_id=void 0)}_setReplicaTraceRoot(t,r){let i=Xg(this,Jd)??{};i[t]=r,aI(this,Jd,i);for(let n of this.child_runs)n._setReplicaTraceRoot(t,r)}_remapForProject(t){let{projectName:r,runtimeEnv:i,excludeChildRuns:n=!0,reroot:a=!1,distributedParentId:o,apiUrl:s,apiKey:c,workspaceId:l}=t,u=this._convertToCreate(this,i,n);if(r===this.project_name)return{...u,session_name:r};if(a){if(o)this._sliceParentId(o,u);else if(u.parent_run_id=void 0,u.dotted_order){let w=u.dotted_order.split(".");w.length>0&&(u.dotted_order=w[w.length-1],u.trace_id=u.id)}let b=oI({projectName:r,apiUrl:s,apiKey:c,workspaceId:l});this._setReplicaTraceRoot(b,u.id)}let d;if(!a){let b=Xg(this,Jd)??{},w=oI({projectName:r,apiUrl:s,apiKey:c,workspaceId:l});if(d=b[w],d&&(u.trace_id=d,u.dotted_order)){let S=u.dotted_order.split("."),x=null;for(let E=0;E<S.length;E++)if(S[E].slice(-nl)===d){x=E;break}if(x!==null){let E=S.slice(x);u.dotted_order=E.join(".")}}}let f=u.id,p=Qc(f,r),m;u.trace_id?m=Qc(u.trace_id,r):m=p;let h;u.parent_run_id&&(h=Qc(u.parent_run_id,r));let _;return u.dotted_order&&(_=u.dotted_order.split(".").map(S=>{let x=S.slice(-nl),E=Qc(x,r);return S.slice(0,-nl)+E}).join(".")),{...u,id:p,trace_id:m,parent_run_id:h,dotted_order:_,session_name:r}}async postRun(t=!0){this._awaitInputsOnPost&&(this.inputs=await this.inputs);try{let r=Ad();if(this.replicas&&this.replicas.length>0)for(let{projectName:i,apiKey:n,apiUrl:a,workspaceId:o,reroot:s,client:c}of this.replicas){let l=this._remapForProject({projectName:i??this.project_name,runtimeEnv:r,excludeChildRuns:!0,reroot:s,distributedParentId:this.distributedParentId,apiUrl:a,apiKey:n,workspaceId:o});await(c??this.client).createRun(l,{apiKey:n,apiUrl:a,workspaceId:o})}else{let i=this._convertToCreate(this,r,t);await this.client.createRun(i)}if(!t){qa("Posting with excludeChildRuns=false is deprecated and will be removed in a future version.");for(let i of this.child_runs)await i.postRun(!1)}this.child_runs=[]}catch(r){console.error(`Error in postRun for run ${this.id}:`,r)}}async patchRun(t){if(this.replicas&&this.replicas.length>0)for(let{projectName:r,apiKey:i,apiUrl:n,workspaceId:a,updates:o,reroot:s,client:c}of this.replicas){let l=this._remapForProject({projectName:r??this.project_name,runtimeEnv:void 0,excludeChildRuns:!0,reroot:s,distributedParentId:this.distributedParentId,apiUrl:n,apiKey:i,workspaceId:a}),u={id:l.id,name:l.name,run_type:l.run_type,start_time:l.start_time,outputs:l.outputs,error:l.error,parent_run_id:l.parent_run_id,session_name:l.session_name,reference_example_id:l.reference_example_id,end_time:l.end_time,dotted_order:l.dotted_order,trace_id:l.trace_id,events:l.events,tags:l.tags,extra:l.extra,attachments:this.attachments,...o};t?.excludeInputs||(u.inputs=l.inputs),await(c??this.client).updateRun(l.id,u,{apiKey:i,apiUrl:n,workspaceId:a})}else try{let r={name:this.name,run_type:this.run_type,start_time:this._serialized_start_time??this.start_time,end_time:this.end_time,error:this.error,outputs:this.outputs,parent_run_id:this.parent_run?.id??this.parent_run_id,reference_example_id:this.reference_example_id,extra:this.extra,events:this.events,dotted_order:this.dotted_order,trace_id:this.trace_id,tags:this.tags,attachments:this.attachments,session_name:this.project_name};t?.excludeInputs||(r.inputs=this.inputs),await this.client.updateRun(this.id,r)}catch(r){console.error(`Error in patchRun for run ${this.id}`,r)}this.child_runs=[]}toJSON(){return this._convertToCreate(this,void 0,!1)}addEvent(t){this.events||(this.events=[]),typeof t=="string"?this.events.push({name:"event",time:new Date().toISOString(),message:t}):this.events.push({...t,time:t.time??new Date().toISOString()})}static fromRunnableConfig(t,r){let i=t?.callbacks,n,a,o,s=iI();if(i){let l=i?.getParentRunId?.()??"",u=i?.handlers?.find(d=>d?.name=="langchain_tracer");n=u?.getRun?.(l),a=u?.projectName,o=u?.client,s=s||!!u}return n?new e({name:n.name,id:n.id,trace_id:n.trace_id,dotted_order:n.dotted_order,client:o,tracingEnabled:s,project_name:a,tags:[...new Set((n?.tags??[]).concat(t?.tags??[]))],extra:{metadata:{...n?.extra?.metadata,...t?.metadata}}}).createChild(r):new e({...r,client:o,tracingEnabled:s,project_name:a})}static fromDottedOrder(t){return this.fromHeaders({"langsmith-trace":t})}static fromHeaders(t,r){let i="get"in t&&typeof t.get=="function"?{"langsmith-trace":t.get("langsmith-trace"),baggage:t.get("baggage")}:t,n=i["langsmith-trace"];if(!n||typeof n!="string")return;let a=n.trim(),o=a.split(".").map(u=>{let[d,f]=u.split("Z");return{strTime:d,time:Date.parse(d+"Z"),uuid:f}}),s=o[0].uuid,c={...r,name:r?.name??"parent",run_type:r?.run_type??"chain",start_time:r?.start_time??Date.now(),id:o.at(-1)?.uuid,trace_id:s,dotted_order:a};if(i.baggage&&typeof i.baggage=="string"){let u=Kd.fromHeader(i.baggage);c.metadata=u.metadata,c.tags=u.tags,c.project_name=u.project_name,c.replicas=u.replicas}let l=new e(c);return l.distributedParentId=l.id,l}toHeaders(t){let r={"langsmith-trace":this.dotted_order,baggage:new Kd(this.extra?.metadata,this.tags,this.project_name,this.replicas).toHeader()};if(t)for(let[i,n]of Object.entries(r))t.set(i,n);return r}};Object.defineProperty(sn,"sharedClient",{enumerable:!0,configurable:!0,writable:!0,value:null});function lI(e){return e!=null&&typeof e.createChild=="function"&&typeof e.postRun=="function"}function uI(e){return typeof e=="object"&&e!=null&&typeof e.name=="string"&&e.name==="langchain_tracer"}function sI(e){return Array.isArray(e)&&e.some(t=>uI(t))}function Dz(e){return typeof e=="object"&&e!=null&&Array.isArray(e.handlers)}function Uz(e){let t=e?.callbacks;return e!=null&&typeof t=="object"&&(sI(t?.handlers)||sI(t))}function Lz(){let e=Et("LANGSMITH_RUNS_ENDPOINTS");if(!e)return[];try{let t=JSON.parse(e);if(Array.isArray(t)){let r=[];for(let i of t){if(typeof i!="object"||i===null){console.warn(`Invalid item type in LANGSMITH_RUNS_ENDPOINTS: expected object, got ${typeof i}`);continue}if(typeof i.api_url!="string"){console.warn(`Invalid api_url type in LANGSMITH_RUNS_ENDPOINTS: expected string, got ${typeof i.api_url}`);continue}if(typeof i.api_key!="string"){console.warn(`Invalid api_key type in LANGSMITH_RUNS_ENDPOINTS: expected string, got ${typeof i.api_key}`);continue}r.push({apiUrl:i.api_url.replace(/\/$/,""),apiKey:i.api_key})}return r}else if(typeof t=="object"&&t!==null){Bz(t);let r=[];for(let[i,n]of Object.entries(t)){let a=i.replace(/\/$/,"");if(typeof n=="string")r.push({apiUrl:a,apiKey:n});else{console.warn(`Invalid value type in LANGSMITH_RUNS_ENDPOINTS for URL ${i}: expected string, got ${typeof n}`);continue}}return r}else return console.warn(`Invalid LANGSMITH_RUNS_ENDPOINTS \u2013 must be valid JSON array of objects with api_url and api_key properties, or object mapping url->apiKey, got ${typeof t}`),[]}catch(t){if(UE(t))throw t;return console.warn("Invalid LANGSMITH_RUNS_ENDPOINTS \u2013 must be valid JSON array of objects with api_url and api_key properties, or object mapping url->apiKey"),[]}}function Fz(e){return e?e.map(t=>Array.isArray(t)?{projectName:t[0],updates:t[1]}:t):Lz()}function Bz(e){if(Object.keys(e).length>0&&Fe("ENDPOINT"))throw new Fd}var dI=T({BaseTracer:()=>Ot,isBaseTracer:()=>Qa}),Vz=e=>{if(e)return e.events=e.events??[],e.child_runs=e.child_runs??[],e};function e_(e,t){if(e)return new sn({...e,start_time:e._serialized_start_time??e.start_time,parent_run:e_(t),child_runs:e.child_runs.map(r=>e_(r)).filter(r=>r!==void 0),extra:{...e.extra,runtime:Gh()},tracingEnabled:!1})}function Qg(e,t){return e&&!Array.isArray(e)&&typeof e=="object"?e:{[t]:e}}function Qa(e){return typeof e._addRunToRunMap=="function"}var Ot=class extends tr{runMap=new Map;runTreeMap=new Map;usesRunTreeMap=!1;constructor(e){super(...arguments)}copy(){return this}getRunById(e){if(e!==void 0)return this.usesRunTreeMap?Vz(this.runTreeMap.get(e)):this.runMap.get(e)}stringifyError(e){return e instanceof Error?e.message+(e?.stack?`
153
-
154
- ${e.stack}`:""):typeof e=="string"?e:`${e}`}_addChildRun(e,t){e.child_runs.push(t)}_addRunToRunMap(e){let{dottedOrder:t,microsecondPrecisionDatestring:r}=Yg(new Date(e.start_time).getTime(),e.id,e.execution_order),i={...e},n=this.getRunById(i.parent_run_id);if(i.parent_run_id!==void 0?n?(this._addChildRun(n,i),n.child_execution_order=Math.max(n.child_execution_order,i.child_execution_order),i.trace_id=n.trace_id,n.dotted_order!==void 0&&(i.dotted_order=[n.dotted_order,t].join("."),i._serialized_start_time=r)):i.parent_run_id=void 0:(i.trace_id=i.id,i.dotted_order=t,i._serialized_start_time=r),this.usesRunTreeMap){let a=e_(i,n);a!==void 0&&this.runTreeMap.set(i.id,a)}else this.runMap.set(i.id,i);return i}async _endTrace(e){let t=e.parent_run_id!==void 0&&this.getRunById(e.parent_run_id);t?t.child_execution_order=Math.max(t.child_execution_order,e.child_execution_order):await this.persistRun(e),await this.onRunUpdate?.(e),this.usesRunTreeMap?this.runTreeMap.delete(e.id):this.runMap.delete(e.id)}_getExecutionOrder(e){let t=e!==void 0&&this.getRunById(e);return t?t.child_execution_order+1:1}_createRunForLLMStart(e,t,r,i,n,a,o,s){let c=this._getExecutionOrder(i),l=Date.now(),u=o?{...n,metadata:o}:n,d={id:r,name:s??e.id[e.id.length-1],parent_run_id:i,start_time:l,serialized:e,events:[{name:"start",time:new Date(l).toISOString()}],inputs:{prompts:t},execution_order:c,child_runs:[],child_execution_order:c,run_type:"llm",extra:u??{},tags:a||[]};return this._addRunToRunMap(d)}async handleLLMStart(e,t,r,i,n,a,o,s){let c=this.getRunById(r)??this._createRunForLLMStart(e,t,r,i,n,a,o,s);return await this.onRunCreate?.(c),await this.onLLMStart?.(c),c}_createRunForChatModelStart(e,t,r,i,n,a,o,s){let c=this._getExecutionOrder(i),l=Date.now(),u=o?{...n,metadata:o}:n,d={id:r,name:s??e.id[e.id.length-1],parent_run_id:i,start_time:l,serialized:e,events:[{name:"start",time:new Date(l).toISOString()}],inputs:{messages:t},execution_order:c,child_runs:[],child_execution_order:c,run_type:"llm",extra:u??{},tags:a||[]};return this._addRunToRunMap(d)}async handleChatModelStart(e,t,r,i,n,a,o,s){let c=this.getRunById(r)??this._createRunForChatModelStart(e,t,r,i,n,a,o,s);return await this.onRunCreate?.(c),await this.onLLMStart?.(c),c}async handleLLMEnd(e,t,r,i,n){let a=this.getRunById(t);if(!a||a?.run_type!=="llm")throw new Error("No LLM run to end.");return a.end_time=Date.now(),a.outputs=e,a.events.push({name:"end",time:new Date(a.end_time).toISOString()}),a.extra={...a.extra,...n},await this.onLLMEnd?.(a),await this._endTrace(a),a}async handleLLMError(e,t,r,i,n){let a=this.getRunById(t);if(!a||a?.run_type!=="llm")throw new Error("No LLM run to end.");return a.end_time=Date.now(),a.error=this.stringifyError(e),a.events.push({name:"error",time:new Date(a.end_time).toISOString()}),a.extra={...a.extra,...n},await this.onLLMError?.(a),await this._endTrace(a),a}_createRunForChainStart(e,t,r,i,n,a,o,s,c){let l=this._getExecutionOrder(i),u=Date.now(),d={id:r,name:s??e.id[e.id.length-1],parent_run_id:i,start_time:u,serialized:e,events:[{name:"start",time:new Date(u).toISOString()}],inputs:t,execution_order:l,child_execution_order:l,run_type:o??"chain",child_runs:[],extra:a?{...c,metadata:a}:{...c},tags:n||[]};return this._addRunToRunMap(d)}async handleChainStart(e,t,r,i,n,a,o,s){let c=this.getRunById(r)??this._createRunForChainStart(e,t,r,i,n,a,o,s);return await this.onRunCreate?.(c),await this.onChainStart?.(c),c}async handleChainEnd(e,t,r,i,n){let a=this.getRunById(t);if(!a)throw new Error("No chain run to end.");return a.end_time=Date.now(),a.outputs=Qg(e,"output"),a.events.push({name:"end",time:new Date(a.end_time).toISOString()}),n?.inputs!==void 0&&(a.inputs=Qg(n.inputs,"input")),await this.onChainEnd?.(a),await this._endTrace(a),a}async handleChainError(e,t,r,i,n){let a=this.getRunById(t);if(!a)throw new Error("No chain run to end.");return a.end_time=Date.now(),a.error=this.stringifyError(e),a.events.push({name:"error",time:new Date(a.end_time).toISOString()}),n?.inputs!==void 0&&(a.inputs=Qg(n.inputs,"input")),await this.onChainError?.(a),await this._endTrace(a),a}_createRunForToolStart(e,t,r,i,n,a,o){let s=this._getExecutionOrder(i),c=Date.now(),l={id:r,name:o??e.id[e.id.length-1],parent_run_id:i,start_time:c,serialized:e,events:[{name:"start",time:new Date(c).toISOString()}],inputs:{input:t},execution_order:s,child_execution_order:s,run_type:"tool",child_runs:[],extra:a?{metadata:a}:{},tags:n||[]};return this._addRunToRunMap(l)}async handleToolStart(e,t,r,i,n,a,o){let s=this.getRunById(r)??this._createRunForToolStart(e,t,r,i,n,a,o);return await this.onRunCreate?.(s),await this.onToolStart?.(s),s}async handleToolEnd(e,t){let r=this.getRunById(t);if(!r||r?.run_type!=="tool")throw new Error("No tool run to end");return r.end_time=Date.now(),r.outputs={output:e},r.events.push({name:"end",time:new Date(r.end_time).toISOString()}),await this.onToolEnd?.(r),await this._endTrace(r),r}async handleToolError(e,t){let r=this.getRunById(t);if(!r||r?.run_type!=="tool")throw new Error("No tool run to end");return r.end_time=Date.now(),r.error=this.stringifyError(e),r.events.push({name:"error",time:new Date(r.end_time).toISOString()}),await this.onToolError?.(r),await this._endTrace(r),r}async handleAgentAction(e,t){let r=this.getRunById(t);if(!r||r?.run_type!=="chain")return;let i=r;i.actions=i.actions||[],i.actions.push(e),i.events.push({name:"agent_action",time:new Date().toISOString(),kwargs:{action:e}}),await this.onAgentAction?.(r)}async handleAgentEnd(e,t){let r=this.getRunById(t);!r||r?.run_type!=="chain"||(r.events.push({name:"agent_end",time:new Date().toISOString(),kwargs:{action:e}}),await this.onAgentEnd?.(r))}_createRunForRetrieverStart(e,t,r,i,n,a,o){let s=this._getExecutionOrder(i),c=Date.now(),l={id:r,name:o??e.id[e.id.length-1],parent_run_id:i,start_time:c,serialized:e,events:[{name:"start",time:new Date(c).toISOString()}],inputs:{query:t},execution_order:s,child_execution_order:s,run_type:"retriever",child_runs:[],extra:a?{metadata:a}:{},tags:n||[]};return this._addRunToRunMap(l)}async handleRetrieverStart(e,t,r,i,n,a,o){let s=this.getRunById(r)??this._createRunForRetrieverStart(e,t,r,i,n,a,o);return await this.onRunCreate?.(s),await this.onRetrieverStart?.(s),s}async handleRetrieverEnd(e,t){let r=this.getRunById(t);if(!r||r?.run_type!=="retriever")throw new Error("No retriever run to end");return r.end_time=Date.now(),r.outputs={documents:e},r.events.push({name:"end",time:new Date(r.end_time).toISOString()}),await this.onRetrieverEnd?.(r),await this._endTrace(r),r}async handleRetrieverError(e,t){let r=this.getRunById(t);if(!r||r?.run_type!=="retriever")throw new Error("No retriever run to end");return r.end_time=Date.now(),r.error=this.stringifyError(e),r.events.push({name:"error",time:new Date(r.end_time).toISOString()}),await this.onRetrieverError?.(r),await this._endTrace(r),r}async handleText(e,t){let r=this.getRunById(t);!r||r?.run_type!=="chain"||(r.events.push({name:"text",time:new Date().toISOString(),kwargs:{text:e}}),await this.onText?.(r))}async handleLLMNewToken(e,t,r,i,n,a){let o=this.getRunById(r);if(!o||o?.run_type!=="llm")throw new Error('Invalid "runId" provided to "handleLLMNewToken" callback.');return o.events.push({name:"new_token",time:new Date().toISOString(),kwargs:{token:e,idx:t,chunk:a?.chunk}}),await this.onLLMNewToken?.(o,e,{chunk:a?.chunk}),o}};var pI=T({ConsoleCallbackHandler:()=>qd}),mI={bold:{open:"\x1B[1m",close:"\x1B[22m"},color:{grey:{open:"\x1B[90m",close:"\x1B[39m"},green:{open:"\x1B[32m",close:"\x1B[39m"},cyan:{open:"\x1B[36m",close:"\x1B[39m"},red:{open:"\x1B[31m",close:"\x1B[39m"},blue:{open:"\x1B[34m",close:"\x1B[39m"}}};function nr(e,t){return`${e.open}${t}${e.close}`}function Br(e,t){try{return JSON.stringify(e,null,2)}catch{return t}}function fI(e){return typeof e=="string"?e.trim():e==null?e:Br(e,e.toString())}function Ki(e){if(!e.end_time)return"";let t=e.end_time-e.start_time;return t<1e3?`${t}ms`:`${(t/1e3).toFixed(2)}s`}var{color:fr}=mI,qd=class extends Ot{name="console_callback_handler";persistRun(e){return Promise.resolve()}getParents(e){let t=[],r=e;for(;r.parent_run_id;){let i=this.runMap.get(r.parent_run_id);if(i)t.push(i),r=i;else break}return t}getBreadcrumbs(e){let t=[...this.getParents(e).reverse(),e].map((r,i,n)=>{let a=`${r.execution_order}:${r.run_type}:${r.name}`;return i===n.length-1?nr(mI.bold,a):a}).join(" > ");return nr(fr.grey,t)}onChainStart(e){let t=this.getBreadcrumbs(e);console.log(`${nr(fr.green,"[chain/start]")} [${t}] Entering Chain run with input: ${Br(e.inputs,"[inputs]")}`)}onChainEnd(e){let t=this.getBreadcrumbs(e);console.log(`${nr(fr.cyan,"[chain/end]")} [${t}] [${Ki(e)}] Exiting Chain run with output: ${Br(e.outputs,"[outputs]")}`)}onChainError(e){let t=this.getBreadcrumbs(e);console.log(`${nr(fr.red,"[chain/error]")} [${t}] [${Ki(e)}] Chain run errored with error: ${Br(e.error,"[error]")}`)}onLLMStart(e){let t=this.getBreadcrumbs(e),r="prompts"in e.inputs?{prompts:e.inputs.prompts.map(i=>i.trim())}:e.inputs;console.log(`${nr(fr.green,"[llm/start]")} [${t}] Entering LLM run with input: ${Br(r,"[inputs]")}`)}onLLMEnd(e){let t=this.getBreadcrumbs(e);console.log(`${nr(fr.cyan,"[llm/end]")} [${t}] [${Ki(e)}] Exiting LLM run with output: ${Br(e.outputs,"[response]")}`)}onLLMError(e){let t=this.getBreadcrumbs(e);console.log(`${nr(fr.red,"[llm/error]")} [${t}] [${Ki(e)}] LLM run errored with error: ${Br(e.error,"[error]")}`)}onToolStart(e){let t=this.getBreadcrumbs(e);console.log(`${nr(fr.green,"[tool/start]")} [${t}] Entering Tool run with input: "${fI(e.inputs.input)}"`)}onToolEnd(e){let t=this.getBreadcrumbs(e);console.log(`${nr(fr.cyan,"[tool/end]")} [${t}] [${Ki(e)}] Exiting Tool run with output: "${fI(e.outputs?.output)}"`)}onToolError(e){let t=this.getBreadcrumbs(e);console.log(`${nr(fr.red,"[tool/error]")} [${t}] [${Ki(e)}] Tool run errored with error: ${Br(e.error,"[error]")}`)}onRetrieverStart(e){let t=this.getBreadcrumbs(e);console.log(`${nr(fr.green,"[retriever/start]")} [${t}] Entering Retriever run with input: ${Br(e.inputs,"[inputs]")}`)}onRetrieverEnd(e){let t=this.getBreadcrumbs(e);console.log(`${nr(fr.cyan,"[retriever/end]")} [${t}] [${Ki(e)}] Exiting Retriever run with output: ${Br(e.outputs,"[outputs]")}`)}onRetrieverError(e){let t=this.getBreadcrumbs(e);console.log(`${nr(fr.red,"[retriever/error]")} [${t}] [${Ki(e)}] Retriever run errored with error: ${Br(e.error,"[error]")}`)}onAgentAction(e){let t=e,r=this.getBreadcrumbs(e);console.log(`${nr(fr.blue,"[agent/action]")} [${r}] Agent selected action: ${Br(t.actions[t.actions.length-1],"[action]")}`)}};var t_,Xd=()=>(t_===void 0&&(t_=new Dn(Qt("LANGCHAIN_CALLBACKS_BACKGROUND")==="false"?{blockOnRootRunFinalization:!0}:{})),t_);var n_=class{getStore(){}run(t,r){return r()}},r_=Symbol.for("ls:tracing_async_local_storage"),Zz=new n_,i_=class{getInstance(){return globalThis[r_]??Zz}initializeGlobalInstance(t){globalThis[r_]===void 0&&(globalThis[r_]=t)}},Hz=new i_;function hI(e=!1){let t=Hz.getInstance().getStore();if(!e&&t===void 0)throw new Error(`Could not get the current run tree.
155
-
156
- Please make sure you are calling this method within a traceable function and that tracing is enabled.`);return t}function Yd(e){return typeof e=="function"&&"langsmith:traceable"in e}var _I=T({LangChainTracer:()=>gs,OVERRIDABLE_LANGSMITH_INHERITABLE_METADATA_KEYS:()=>o_}),o_=new Set(["ls_agent_type"]);function Gz(e){let t;for(let r of e)for(let i of r)Ce.isInstance(i.message)&&i.message.usage_metadata!==void 0&&(t=ns(t,i.message.usage_metadata));return t}var gs=class a_ extends Ot{name="langchain_tracer";projectName;exampleId;client;replicas;usesRunTreeMap=!0;tracingMetadata;tracingTags=[];constructor(t={}){super(t),this.fields=t;let{exampleId:r,projectName:i,client:n,replicas:a,metadata:o,tags:s}=t;this.projectName=i??Yc(),this.replicas=a,this.exampleId=r,this.client=n??Xd(),this.tracingMetadata=o?{...o}:void 0,this.tracingTags=s??[];let c=a_.getTraceableRunTree();c&&this.updateFromRunTree(c)}async persistRun(t){}async onRunCreate(t){gI(this,t),t.extra?.lc_defers_inputs||await this.getRunTreeWithTracingConfig(t.id)?.postRun()}async onRunUpdate(t){gI(this,t);let r=this.getRunTreeWithTracingConfig(t.id);t.extra?.lc_defers_inputs?await r?.postRun():await r?.patchRun()}onLLMEnd(t){let r=t.outputs;if(r?.generations){let i=Gz(r.generations);if(i!==void 0){t.extra=t.extra??{};let n=t.extra.metadata??{};n.usage_metadata=i,t.extra.metadata=n}}}copyWithTracingConfig({metadata:t,tags:r}){let i;if(t===void 0)i=this.tracingMetadata?{...this.tracingMetadata}:void 0;else if(this.tracingMetadata===void 0)i={...t};else{i={...this.tracingMetadata};for(let[o,s]of Object.entries(t))(!Object.prototype.hasOwnProperty.call(i,o)||o_.has(o))&&(i[o]=s)}let n=r?Array.from(new Set([...this.tracingTags,...r])):[...this.tracingTags],a=new a_({...this.fields,metadata:i,tags:n});return a.runMap=this.runMap,a.runTreeMap=this.runTreeMap,a}getRun(t){return this.runTreeMap.get(t)}updateFromRunTree(t){this.runTreeMap.set(t.id,t);let r=t,i=new Set;for(;r.parent_run&&!(i.has(r.id)||(i.add(r.id),!r.parent_run));)r=r.parent_run;i.clear();let n=[r];for(;n.length>0;){let a=n.shift();!a||i.has(a.id)||(i.add(a.id),this.runTreeMap.set(a.id,a),a.child_runs&&n.push(...a.child_runs))}this.client=t.client??this.client,this.replicas=t.replicas??this.replicas,this.projectName=t.project_name??this.projectName,this.exampleId=t.reference_example_id??this.exampleId,this.fields={...this.fields,client:this.client,replicas:this.replicas,projectName:this.projectName,exampleId:this.exampleId}}getRunTreeWithTracingConfig(t){let r=this.runTreeMap.get(t);if(r)return new sn({...r,client:this.client,project_name:this.projectName,replicas:this.replicas,reference_example_id:this.exampleId,tracingEnabled:!0})}static getTraceableRunTree(){try{return hI(!0)}catch{return}}static[Symbol.hasInstance](t){if(typeof t!="object"||t===null)return!1;let r=t;return"name"in r&&r.name==="langchain_tracer"&&"copyWithTracingConfig"in r&&typeof r.copyWithTracingConfig=="function"&&"getRunTreeWithTracingConfig"in r&&typeof r.getRunTreeWithTracingConfig=="function"}};function gI(e,t){if(e.tracingMetadata){t.extra??={};let r=t.extra.metadata??{},i=!1;for(let[n,a]of Object.entries(e.tracingMetadata))(!Object.prototype.hasOwnProperty.call(r,n)||o_.has(n))&&r[n]!==a&&(r[n]=a,i=!0);i&&(t.extra.metadata=r)}e.tracingTags.length>0&&(t.tags=Array.from(new Set([...t.tags??[],...e.tracingTags])))}var yI=Symbol.for("ls:tracing_async_local_storage"),qi=Symbol.for("lc:context_variables"),vI=e=>{globalThis[yI]=e},Xi=()=>globalThis[yI];var Qd=zu(Ud(),1),eo;function Wz(){return new("default"in Qd.default?Qd.default.default:Qd.default)({autoStart:!0,concurrency:1})}function Jz(){return typeof eo>"u"&&(eo=Wz()),eo}async function Xe(e,t){if(t===!0){let r=Xi();r!==void 0?await r.run(void 0,async()=>e()):await e()}else eo=Jz(),eo.add(async()=>{let r=Xi();r!==void 0?await r.run(void 0,async()=>e()):await e()})}async function bI(){let e=Xd();await Promise.allSettled([typeof eo<"u"?eo.onIdle():Promise.resolve(),e.awaitPendingTraceBatches()])}var wI=T({awaitAllCallbacks:()=>bI,consumeCallback:()=>Xe});var xI=e=>e!==void 0?e:!!["LANGSMITH_TRACING_V2","LANGCHAIN_TRACING_V2","LANGSMITH_TRACING","LANGCHAIN_TRACING"].find(t=>Qt(t)==="true");function s_(e){let t=Xi();if(t!==void 0)return t.getStore()?.[qi]?.[e]}var Kz=Symbol("lc:configure_hooks"),SI=()=>s_(Kz)||[];var kI=T({BaseCallbackManager:()=>$I,BaseRunManager:()=>al,CallbackManager:()=>et,CallbackManagerForChainRun:()=>II,CallbackManagerForLLMRun:()=>c_,CallbackManagerForRetrieverRun:()=>EI,CallbackManagerForToolRun:()=>TI,ensureHandler:()=>_s,parseCallbackConfigArg:()=>to});function to(e){return e?Array.isArray(e)||"name"in e?{callbacks:e}:e:{}}var $I=class{setHandler(e){return this.setHandlers([e])}},al=class{constructor(e,t,r,i,n,a,o,s){this.runId=e,this.handlers=t,this.inheritableHandlers=r,this.tags=i,this.inheritableTags=n,this.metadata=a,this.inheritableMetadata=o,this._parentRunId=s}get parentRunId(){return this._parentRunId}async handleText(e){await Promise.all(this.handlers.map(t=>Xe(async()=>{try{await t.handleText?.(e,this.runId,this._parentRunId,this.tags)}catch(r){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleText: ${r}`),t.raiseError)throw r}},t.awaitHandlers)))}async handleCustomEvent(e,t,r,i,n){await Promise.all(this.handlers.map(a=>Xe(async()=>{try{await a.handleCustomEvent?.(e,t,this.runId,this.tags,this.metadata)}catch(o){if((a.raiseError?console.error:console.warn)(`Error in handler ${a.constructor.name}, handleCustomEvent: ${o}`),a.raiseError)throw o}},a.awaitHandlers)))}},EI=class extends al{getChild(e){let t=new et(this.runId);return t.setHandlers(this.inheritableHandlers),t.addTags(this.inheritableTags),t.addMetadata(this.inheritableMetadata),e&&t.addTags([e],!1),t}async handleRetrieverEnd(e){await Promise.all(this.handlers.map(t=>Xe(async()=>{if(!t.ignoreRetriever)try{await t.handleRetrieverEnd?.(e,this.runId,this._parentRunId,this.tags)}catch(r){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleRetriever`),t.raiseError)throw r}},t.awaitHandlers)))}async handleRetrieverError(e){await Promise.all(this.handlers.map(t=>Xe(async()=>{if(!t.ignoreRetriever)try{await t.handleRetrieverError?.(e,this.runId,this._parentRunId,this.tags)}catch(r){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleRetrieverError: ${r}`),t.raiseError)throw e}},t.awaitHandlers)))}},c_=class extends al{async handleLLMNewToken(e,t,r,i,n,a){await Promise.all(this.handlers.map(o=>Xe(async()=>{if(!o.ignoreLLM)try{await o.handleLLMNewToken?.(e,t??{prompt:0,completion:0},this.runId,this._parentRunId,this.tags,a)}catch(s){if((o.raiseError?console.error:console.warn)(`Error in handler ${o.constructor.name}, handleLLMNewToken: ${s}`),o.raiseError)throw s}},o.awaitHandlers)))}async handleChatModelStreamEvent(e){await Promise.all(this.handlers.map(t=>Xe(async()=>{if(!t.ignoreLLM)try{await t.handleChatModelStreamEvent?.(e,this.runId,this._parentRunId,this.tags)}catch(r){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleChatModelStreamEvent: ${r}`),t.raiseError)throw r}},t.awaitHandlers)))}async handleLLMError(e,t,r,i,n){await Promise.all(this.handlers.map(a=>Xe(async()=>{if(!a.ignoreLLM)try{await a.handleLLMError?.(e,this.runId,this._parentRunId,this.tags,n)}catch(o){if((a.raiseError?console.error:console.warn)(`Error in handler ${a.constructor.name}, handleLLMError: ${o}`),a.raiseError)throw o}},a.awaitHandlers)))}async handleLLMEnd(e,t,r,i,n){await Promise.all(this.handlers.map(a=>Xe(async()=>{if(!a.ignoreLLM)try{await a.handleLLMEnd?.(e,this.runId,this._parentRunId,this.tags,n)}catch(o){if((a.raiseError?console.error:console.warn)(`Error in handler ${a.constructor.name}, handleLLMEnd: ${o}`),a.raiseError)throw o}},a.awaitHandlers)))}},II=class extends al{getChild(e){let t=new et(this.runId);return t.setHandlers(this.inheritableHandlers),t.addTags(this.inheritableTags),t.addMetadata(this.inheritableMetadata),e&&t.addTags([e],!1),t}async handleChainError(e,t,r,i,n){await Promise.all(this.handlers.map(a=>Xe(async()=>{if(!a.ignoreChain)try{await a.handleChainError?.(e,this.runId,this._parentRunId,this.tags,n)}catch(o){if((a.raiseError?console.error:console.warn)(`Error in handler ${a.constructor.name}, handleChainError: ${o}`),a.raiseError)throw o}},a.awaitHandlers)))}async handleChainEnd(e,t,r,i,n){await Promise.all(this.handlers.map(a=>Xe(async()=>{if(!a.ignoreChain)try{await a.handleChainEnd?.(e,this.runId,this._parentRunId,this.tags,n)}catch(o){if((a.raiseError?console.error:console.warn)(`Error in handler ${a.constructor.name}, handleChainEnd: ${o}`),a.raiseError)throw o}},a.awaitHandlers)))}async handleAgentAction(e){await Promise.all(this.handlers.map(t=>Xe(async()=>{if(!t.ignoreAgent)try{await t.handleAgentAction?.(e,this.runId,this._parentRunId,this.tags)}catch(r){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleAgentAction: ${r}`),t.raiseError)throw r}},t.awaitHandlers)))}async handleAgentEnd(e){await Promise.all(this.handlers.map(t=>Xe(async()=>{if(!t.ignoreAgent)try{await t.handleAgentEnd?.(e,this.runId,this._parentRunId,this.tags)}catch(r){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleAgentEnd: ${r}`),t.raiseError)throw r}},t.awaitHandlers)))}},TI=class extends al{getChild(e){let t=new et(this.runId);return t.setHandlers(this.inheritableHandlers),t.addTags(this.inheritableTags),t.addMetadata(this.inheritableMetadata),e&&t.addTags([e],!1),t}async handleToolError(e){await Promise.all(this.handlers.map(t=>Xe(async()=>{if(!t.ignoreAgent)try{await t.handleToolError?.(e,this.runId,this._parentRunId,this.tags)}catch(r){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleToolError: ${r}`),t.raiseError)throw r}},t.awaitHandlers)))}async handleToolEvent(e){await Promise.all(this.handlers.map(t=>Xe(async()=>{if(!t.ignoreAgent)try{await t.handleToolEvent?.(e,this.runId,this._parentRunId,this.tags)}catch(r){if(t.raiseError)throw r}},t.awaitHandlers)))}async handleToolEnd(e){await Promise.all(this.handlers.map(t=>Xe(async()=>{if(!t.ignoreAgent)try{await t.handleToolEnd?.(e,this.runId,this._parentRunId,this.tags)}catch(r){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleToolEnd: ${r}`),t.raiseError)throw r}},t.awaitHandlers)))}},et=class il extends $I{handlers=[];inheritableHandlers=[];tags=[];inheritableTags=[];metadata={};inheritableMetadata={};name="callback_manager";_parentRunId;constructor(t,r){super(),this.handlers=r?.handlers??this.handlers,this.inheritableHandlers=r?.inheritableHandlers??this.inheritableHandlers,this.tags=r?.tags??this.tags,this.inheritableTags=r?.inheritableTags??this.inheritableTags,this.metadata=r?.metadata??this.metadata,this.inheritableMetadata=r?.inheritableMetadata??this.inheritableMetadata,this._parentRunId=t}getParentRunId(){return this._parentRunId}async handleLLMStart(t,r,i=void 0,n=void 0,a=void 0,o=void 0,s=void 0,c=void 0){return Promise.all(r.map(async(l,u)=>{let d=u===0&&i?i:Ur();return await Promise.all(this.handlers.map(f=>{if(!f.ignoreLLM)return Qa(f)&&f._createRunForLLMStart(t,[l],d,this._parentRunId,a,this.tags,this.metadata,c),Xe(async()=>{try{await f.handleLLMStart?.(t,[l],d,this._parentRunId,a,this.tags,this.metadata,c)}catch(p){if((f.raiseError?console.error:console.warn)(`Error in handler ${f.constructor.name}, handleLLMStart: ${p}`),f.raiseError)throw p}},f.awaitHandlers)})),new c_(d,this.handlers,this.inheritableHandlers,this.tags,this.inheritableTags,this.metadata,this.inheritableMetadata,this._parentRunId)}))}async handleChatModelStart(t,r,i=void 0,n=void 0,a=void 0,o=void 0,s=void 0,c=void 0){return Promise.all(r.map(async(l,u)=>{let d=u===0&&i?i:Ur();return await Promise.all(this.handlers.map(f=>{if(!f.ignoreLLM)return Qa(f)&&f._createRunForChatModelStart(t,[l],d,this._parentRunId,a,this.tags,this.metadata,c),Xe(async()=>{try{if(f.handleChatModelStart)await f.handleChatModelStart?.(t,[l],d,this._parentRunId,a,this.tags,this.metadata,c);else if(f.handleLLMStart){let p=as(l);await f.handleLLMStart?.(t,[p],d,this._parentRunId,a,this.tags,this.metadata,c)}}catch(p){if((f.raiseError?console.error:console.warn)(`Error in handler ${f.constructor.name}, handleLLMStart: ${p}`),f.raiseError)throw p}},f.awaitHandlers)})),new c_(d,this.handlers,this.inheritableHandlers,this.tags,this.inheritableTags,this.metadata,this.inheritableMetadata,this._parentRunId)}))}async handleChainStart(t,r,i=Ur(),n=void 0,a=void 0,o=void 0,s=void 0,c=void 0,l=void 0){return await Promise.all(this.handlers.map(u=>{if(!u.ignoreChain)return Qa(u)&&u._createRunForChainStart(t,r,i,this._parentRunId,this.tags,this.metadata,n,s,l),Xe(async()=>{try{await u.handleChainStart?.(t,r,i,this._parentRunId,this.tags,this.metadata,n,s,l)}catch(d){if((u.raiseError?console.error:console.warn)(`Error in handler ${u.constructor.name}, handleChainStart: ${d}`),u.raiseError)throw d}},u.awaitHandlers)})),new II(i,this.handlers,this.inheritableHandlers,this.tags,this.inheritableTags,this.metadata,this.inheritableMetadata,this._parentRunId)}async handleToolStart(t,r,i=Ur(),n=void 0,a=void 0,o=void 0,s=void 0,c=void 0){return await Promise.all(this.handlers.map(l=>{if(!l.ignoreAgent)return Qa(l)&&l._createRunForToolStart(t,r,i,this._parentRunId,this.tags,this.metadata,s),Xe(async()=>{try{await l.handleToolStart?.(t,r,i,this._parentRunId,this.tags,this.metadata,s,c)}catch(u){if((l.raiseError?console.error:console.warn)(`Error in handler ${l.constructor.name}, handleToolStart: ${u}`),l.raiseError)throw u}},l.awaitHandlers)})),new TI(i,this.handlers,this.inheritableHandlers,this.tags,this.inheritableTags,this.metadata,this.inheritableMetadata,this._parentRunId)}async handleRetrieverStart(t,r,i=Ur(),n=void 0,a=void 0,o=void 0,s=void 0){return await Promise.all(this.handlers.map(c=>{if(!c.ignoreRetriever)return Qa(c)&&c._createRunForRetrieverStart(t,r,i,this._parentRunId,this.tags,this.metadata,s),Xe(async()=>{try{await c.handleRetrieverStart?.(t,r,i,this._parentRunId,this.tags,this.metadata,s)}catch(l){if((c.raiseError?console.error:console.warn)(`Error in handler ${c.constructor.name}, handleRetrieverStart: ${l}`),c.raiseError)throw l}},c.awaitHandlers)})),new EI(i,this.handlers,this.inheritableHandlers,this.tags,this.inheritableTags,this.metadata,this.inheritableMetadata,this._parentRunId)}async handleCustomEvent(t,r,i,n,a){await Promise.all(this.handlers.map(o=>Xe(async()=>{if(!o.ignoreCustomEvent)try{await o.handleCustomEvent?.(t,r,i,this.tags,this.metadata)}catch(s){if((o.raiseError?console.error:console.warn)(`Error in handler ${o.constructor.name}, handleCustomEvent: ${s}`),o.raiseError)throw s}},o.awaitHandlers)))}addHandler(t,r=!0){this.handlers.push(t),r&&this.inheritableHandlers.push(t)}removeHandler(t){this.handlers=this.handlers.filter(r=>r!==t),this.inheritableHandlers=this.inheritableHandlers.filter(r=>r!==t)}setHandlers(t,r=!0){this.handlers=[],this.inheritableHandlers=[];for(let i of t)this.addHandler(i,r)}addTags(t,r=!0){this.removeTags(t),this.tags.push(...t),r&&this.inheritableTags.push(...t)}removeTags(t){this.tags=this.tags.filter(r=>!t.includes(r)),this.inheritableTags=this.inheritableTags.filter(r=>!t.includes(r))}addMetadata(t,r=!0){this.metadata={...this.metadata,...t},r&&(this.inheritableMetadata={...this.inheritableMetadata,...t})}removeMetadata(t){for(let r of Object.keys(t))delete this.metadata[r],delete this.inheritableMetadata[r]}copy(t=[],r=!0){let i=new il(this._parentRunId);for(let n of this.handlers){let a=this.inheritableHandlers.includes(n);i.addHandler(n,a)}for(let n of this.tags){let a=this.inheritableTags.includes(n);i.addTags([n],a)}for(let n of Object.keys(this.metadata)){let a=Object.keys(this.inheritableMetadata).includes(n);i.addMetadata({[n]:this.metadata[n]},a)}for(let n of t)i.handlers.filter(a=>a.name==="console_callback_handler").some(a=>a.name===n.name)||i.addHandler(n,r);return i}static fromHandlers(t){class r extends tr{name=Ur();constructor(){super(),Object.assign(this,t)}}let i=new this;return i.addHandler(new r),i}static configure(t,r,i,n,a,o,s){return this._configureSync(t,r,i,n,a,o,s)}static _configureSync(t,r,i,n,a,o,s){let c;(t||r)&&(Array.isArray(t)||!t?(c=new il,c.setHandlers(t?.map(_s)??[],!0)):c=t,c=c.copy(Array.isArray(r)?r.map(_s):r?.handlers,!1));let l=Qt("LANGCHAIN_VERBOSE")==="true"||s?.verbose,u=gs.getTraceableRunTree(),d=u?.tracingEnabled??xI();if(u?.tracingEnabled===!1&&c){let h=c.handlers.filter(_=>_.name==="langchain_tracer");for(let _ of h)c.removeHandler(_)}let f=d||(Qt("LANGCHAIN_TRACING")??!1);if(l||f){if(c||(c=new il),l&&!c.handlers.some(h=>h.name===qd.prototype.name)){let h=new qd;c.addHandler(h,!0)}if(f&&!c.handlers.some(h=>h.name==="langchain_tracer")&&d){let h=new gs;c.addHandler(h,!0)}d&&u&&c._parentRunId===void 0&&(c._parentRunId=u.id,c.handlers.find(h=>h.name==="langchain_tracer")?.updateFromRunTree(u))}for(let{contextVar:h,inheritable:_=!0,handlerClass:b,envVar:w}of SI()){let S=w&&Qt(w)==="true"&&b,x,E=h!==void 0?s_(h):void 0;E&&ng(E)?x=E:S&&(x=new b({})),x!==void 0&&(c||(c=new il),c.handlers.some(z=>z.name===x.name)||c.addHandler(x,_))}(i||n)&&c&&(c.addTags(i??[]),c.addTags(n??[],!1)),(a||o)&&c&&(c.addMetadata(a??{}),c.addMetadata(o??{},!1));let p=s?.tracerInheritableMetadata,m=s?.tracerInheritableTags;return c&&(p||m)&&(c.handlers=c.handlers.map(h=>h instanceof gs?h.copyWithTracingConfig({metadata:p,tags:m}):h),c.inheritableHandlers=c.inheritableHandlers.map(h=>h instanceof gs?h.copyWithTracingConfig({metadata:p,tags:m}):h)),c}};function _s(e){return"name"in e?e:tr.fromMethods(e)}var l_=class{getStore(){}run(e,t){return t()}enterWith(e){}},qz=new l_,CI=Symbol.for("lc:child_config"),Xz=class{getInstance(){return Xi()??qz}getRunnableConfig(){return this.getInstance().getStore()?.extra?.[CI]}runWithConfig(e,t,r){let i=et._configureSync(e?.callbacks,void 0,e?.tags,void 0,e?.metadata),n=this.getInstance(),a=n.getStore(),o=i?.getParentRunId(),s=i?.handlers?.find(l=>l?.name==="langchain_tracer"),c;return s&&o?c=s.getRunTreeWithTracingConfig(o):r||(c=new sn({name:"<runnable_lambda>",tracingEnabled:!1})),c&&(c.extra={...c.extra,[CI]:e}),a!==void 0&&a[qi]!==void 0&&(c===void 0&&(c={}),c[qi]=a[qi]),n.run(c,t)}initializeGlobalInstance(e){Xi()===void 0&&vI(e)}},Ae=new Xz;var AI=T({AsyncLocalStorageProviderSingleton:()=>Ae,MockAsyncLocalStorage:()=>l_,_CONTEXT_VARIABLES_KEY:()=>qi});var Yz=new Set(["api_key"]),Qz=new Set(["string","number","boolean"]);function eD(e){let t=e.configurable??{},r=e.metadata??{},i={};for(let[n,a]of Object.entries(t))!n.startsWith("__")&&!Object.prototype.hasOwnProperty.call(r,n)&&!Yz.has(n)&&Qz.has(typeof a)&&(i[n]=a);return Object.keys(i).length>0?i:void 0}async function Ft(e){return et._configureSync(e?.callbacks,void 0,e?.tags,void 0,e?.metadata,void 0,{tracerInheritableMetadata:e?eD(e):void 0})}function vt(...e){let t={};for(let r of e.filter(i=>!!i))for(let i of Object.keys(r))if(i==="metadata")t[i]={...t[i],...r[i]};else if(i==="tags"){let n=t[i]??[];t[i]=[...new Set(n.concat(r[i]??[]))]}else if(i==="configurable")t[i]={...t[i],...r[i]};else if(i==="timeout")t.timeout===void 0?t.timeout=r.timeout:r.timeout!==void 0&&(t.timeout=Math.min(t.timeout,r.timeout));else if(i==="signal")t.signal===void 0?t.signal=r.signal:r.signal!==void 0&&("any"in AbortSignal?t.signal=AbortSignal.any([t.signal,r.signal]):t.signal=r.signal);else if(i==="callbacks"){let n=t.callbacks,a=r.callbacks;if(Array.isArray(a))if(!n)t.callbacks=a;else if(Array.isArray(n))t.callbacks=n.concat(a);else{let o=n.copy();for(let s of a)o.addHandler(_s(s),!0);t.callbacks=o}else if(a)if(!n)t.callbacks=a;else if(Array.isArray(n)){let o=a.copy();for(let s of n)o.addHandler(_s(s),!0);t.callbacks=o}else t.callbacks=new et(a._parentRunId,{handlers:n.handlers.concat(a.handlers),inheritableHandlers:n.inheritableHandlers.concat(a.inheritableHandlers),tags:Array.from(new Set(n.tags.concat(a.tags))),inheritableTags:Array.from(new Set(n.inheritableTags.concat(a.inheritableTags))),metadata:{...n.metadata,...a.metadata}})}else{let n=i;t[n]=r[n]??t[n]}return t}function we(e){let t=Ae.getRunnableConfig(),r={tags:[],metadata:{},recursionLimit:25,runId:void 0};if(t){let{runId:i,runName:n,...a}=t;r=Object.entries(a).reduce((o,[s,c])=>(c!==void 0&&(o[s]=c),o),r)}if(e&&(r=Object.entries(e).reduce((i,[n,a])=>(a!==void 0&&(i[n]=a),i),r)),r?.configurable&&typeof r.configurable.model=="string"&&r.metadata?.model===void 0&&(r.metadata||(r.metadata={}),r.metadata.model=r.configurable.model),r.timeout!==void 0){if(r.timeout<=0)throw new Error("Timeout must be a positive number");let i=r.timeout,n=AbortSignal.timeout(i);r.metadata||(r.metadata={}),r.metadata.timeoutMs===void 0&&(r.metadata.timeoutMs=i),r.signal!==void 0?"any"in AbortSignal&&(r.signal=AbortSignal.any([r.signal,n])):r.signal=n,delete r.timeout}return r}function Se(e={},{callbacks:t,maxConcurrency:r,recursionLimit:i,runName:n,configurable:a,runId:o}={}){let s=we(e);return t!==void 0&&(delete s.runName,s.callbacks=t),i!==void 0&&(s.recursionLimit=i),r!==void 0&&(s.maxConcurrency=r),n!==void 0&&(s.runName=n),a!==void 0&&(s.configurable={...s.configurable,...a}),o!==void 0&&delete s.runId,s}function pr(e){if(e)return{configurable:e.configurable,recursionLimit:e.recursionLimit,callbacks:e.callbacks,tags:e.tags,metadata:e.metadata,maxConcurrency:e.maxConcurrency,timeout:e.timeout,signal:e.signal,store:e.store}}async function Er(e,t){if(t===void 0)return e;let r;return Promise.race([e.catch(i=>{if(!t?.aborted)throw i}),new Promise((i,n)=>{r=()=>{n(Yi(t))},t.addEventListener("abort",r,{once:!0}),t.aborted&&n(Yi(t))})]).finally(()=>t.removeEventListener("abort",r))}function Yi(e){return e?.reason instanceof Error?e.reason:typeof e?.reason=="string"?new Error(e.reason):new Error("Aborted")}var OI=T({AsyncGeneratorWithSetup:()=>Qi,IterableReadableStream:()=>dt,atee:()=>ef,concat:()=>Ir,pipeGeneratorWithSetup:()=>d_}),dt=class u_ extends ReadableStream{reader;ensureReader(){this.reader||(this.reader=this.getReader())}async next(){this.ensureReader();try{let t=await this.reader.read();return t.done?(this.reader.releaseLock(),{done:!0,value:void 0}):{done:!1,value:t.value}}catch(t){throw this.reader.releaseLock(),t}}async return(){if(this.ensureReader(),this.locked){let t=this.reader.cancel();this.reader.releaseLock(),await t}return{done:!0,value:void 0}}async throw(t){if(this.ensureReader(),this.locked){let r=this.reader.cancel();this.reader.releaseLock(),await r}throw t}[Symbol.asyncIterator](){return this}async[Symbol.asyncDispose](){await this.return()}static fromReadableStream(t){let r=t.getReader();return new u_({start(i){return n();function n(){return r.read().then(({done:a,value:o})=>{if(a){i.close();return}return i.enqueue(o),n()})}},cancel(){r.releaseLock()}})}static fromAsyncGenerator(t){return new u_({async pull(r){let{value:i,done:n}=await t.next();n&&r.close(),r.enqueue(i)},async cancel(r){await t.return(r)}})}};function ef(e,t=2){let r=Array.from({length:t},()=>[]);return r.map(async function*(n){for(;;)if(n.length===0){let a=await e.next();for(let o of r)o.push(a)}else{if(n[0].done)return;yield n.shift().value}})}function Ir(e,t){if(Array.isArray(e)&&Array.isArray(t))return e.concat(t);if(typeof e=="string"&&typeof t=="string")return e+t;if(typeof e=="number"&&typeof t=="number")return e+t;if("concat"in e&&typeof e.concat=="function")return e.concat(t);if(typeof e=="object"&&typeof t=="object"){let r={...e};for(let[i,n]of Object.entries(t))i in r&&!Array.isArray(r[i])?r[i]=Ir(r[i],n):r[i]=n;return r}else throw new Error(`Cannot concat ${typeof e} and ${typeof t}`)}var Qi=class{generator;setup;config;signal;firstResult;firstResultUsed=!1;constructor(e){this.generator=e.generator,this.config=e.config,this.signal=e.signal??this.config?.signal,this.setup=new Promise((t,r)=>{Ae.runWithConfig(pr(e.config),async()=>{this.firstResult=this.signal?Er(e.generator.next(),this.signal):e.generator.next(),e.startSetup?this.firstResult.then(e.startSetup).then(t,r):this.firstResult.then(i=>t(void 0),r)},!0)})}async next(...e){return this.signal?.throwIfAborted(),this.firstResultUsed?Ae.runWithConfig(pr(this.config),this.signal?async()=>Er(this.generator.next(...e),this.signal):async()=>this.generator.next(...e),!0):(this.firstResultUsed=!0,this.firstResult)}async return(e){return this.generator.return(e)}async throw(e){return this.generator.throw(e)}[Symbol.asyncIterator](){return this}async[Symbol.asyncDispose](){await this.return()}};async function d_(e,t,r,i,...n){let a=new Qi({generator:t,startSetup:r,signal:i}),o=await a.setup;return{output:e(a,o,...n),setup:o}}var tD=Object.prototype.hasOwnProperty;function rf(e,t){return tD.call(e,t)}function nf(e){if(Array.isArray(e)){let r=new Array(e.length);for(let i=0;i<r.length;i++)r[i]=""+i;return r}if(Object.keys)return Object.keys(e);let t=[];for(let r in e)rf(e,r)&&t.push(r);return t}function Tr(e){switch(typeof e){case"object":return JSON.parse(JSON.stringify(e));case"undefined":return null;default:return e}}function af(e){let t=0,r=e.length,i;for(;t<r;){if(i=e.charCodeAt(t),i>=48&&i<=57){t++;continue}return!1}return!0}function ro(e){return e.indexOf("/")===-1&&e.indexOf("~")===-1?e:e.replace(/~/g,"~0").replace(/\//g,"~1")}function NI(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function tf(e){if(e===void 0)return!0;if(e){if(Array.isArray(e)){for(let r=0,i=e.length;r<i;r++)if(tf(e[r]))return!0}else if(typeof e=="object"){let r=nf(e),i=r.length;for(var t=0;t<i;t++)if(tf(e[r[t]]))return!0}}return!1}function PI(e,t){let r=[e];for(let i in t){let n=typeof t[i]=="object"?JSON.stringify(t[i],null,2):t[i];typeof n<"u"&&r.push(`${i}: ${n}`)}return r.join(`
157
- `)}var RI=class extends Error{constructor(e,t,r,i,n){super(PI(e,{name:t,index:r,operation:i,tree:n})),this.name=t,this.index=r,this.operation=i,this.tree=n,Object.setPrototypeOf(this,new.target.prototype),this.message=PI(e,{name:t,index:r,operation:i,tree:n})}};var MI=T({JsonPatchError:()=>nt,_areEquals:()=>ol,applyOperation:()=>no,applyPatch:()=>ea,applyReducer:()=>iD,deepClone:()=>rD,getValueByPointer:()=>of,validate:()=>jI,validator:()=>sf}),nt=RI,rD=Tr,ys={add:function(e,t,r){if(t==="__proto__"||t==="constructor")throw new TypeError("JSON-Patch: modifying `__proto__` or `constructor` prop is banned for security reasons");return e[t]=this.value,{newDocument:r}},remove:function(e,t,r){if(t==="__proto__"||t==="constructor")throw new TypeError("JSON-Patch: modifying `__proto__` or `constructor` prop is banned for security reasons");var i=e[t];return delete e[t],{newDocument:r,removed:i}},replace:function(e,t,r){if(t==="__proto__"||t==="constructor")throw new TypeError("JSON-Patch: modifying `__proto__` or `constructor` prop is banned for security reasons");var i=e[t];return e[t]=this.value,{newDocument:r,removed:i}},move:function(e,t,r){let i=of(r,this.path);i&&(i=Tr(i));let n=no(r,{op:"remove",path:this.from}).removed;return no(r,{op:"add",path:this.path,value:n}),{newDocument:r,removed:i}},copy:function(e,t,r){let i=of(r,this.from);return no(r,{op:"add",path:this.path,value:Tr(i)}),{newDocument:r}},test:function(e,t,r){return{newDocument:r,test:ol(e[t],this.value)}},_get:function(e,t,r){return this.value=e[t],{newDocument:r}}},nD={add:function(e,t,r){return af(t)?e.splice(t,0,this.value):e[t]=this.value,{newDocument:r,index:t}},remove:function(e,t,r){return{newDocument:r,removed:e.splice(t,1)[0]}},replace:function(e,t,r){var i=e[t];return e[t]=this.value,{newDocument:r,removed:i}},move:ys.move,copy:ys.copy,test:ys.test,_get:ys._get};function of(e,t){if(t=="")return e;var r={op:"_get",path:t};return no(e,r),r.value}function no(e,t,r=!1,i=!0,n=!0,a=0){if(r&&(typeof r=="function"?r(t,0,e,t.path):sf(t,0)),t.path===""){let o={newDocument:e};if(t.op==="add")return o.newDocument=t.value,o;if(t.op==="replace")return o.newDocument=t.value,o.removed=e,o;if(t.op==="move"||t.op==="copy")return o.newDocument=of(e,t.from),t.op==="move"&&(o.removed=e),o;if(t.op==="test"){if(o.test=ol(e,t.value),o.test===!1)throw new nt("Test operation failed","TEST_OPERATION_FAILED",a,t,e);return o.newDocument=e,o}else{if(t.op==="remove")return o.removed=e,o.newDocument=null,o;if(t.op==="_get")return t.value=e,o;if(r)throw new nt("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",a,t,e);return o}}else{i||(e=Tr(e));let o=(t.path||"").split("/"),s=e,c=1,l=o.length,u,d,f;for(typeof r=="function"?f=r:f=sf;;){if(d=o[c],d&&d.indexOf("~")!=-1&&(d=NI(d)),n&&(d=="__proto__"||d=="prototype"&&c>0&&o[c-1]=="constructor"))throw new TypeError("JSON-Patch: modifying `__proto__` or `constructor/prototype` prop is banned for security reasons, if this was on purpose, please set `banPrototypeModifications` flag false and pass it to this function. More info in fast-json-patch README");if(r&&u===void 0&&(s[d]===void 0?u=o.slice(0,c).join("/"):c==l-1&&(u=t.path),u!==void 0&&f(t,0,e,u)),c++,Array.isArray(s)){if(d==="-")d=s.length;else{if(r&&!af(d))throw new nt("Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index","OPERATION_PATH_ILLEGAL_ARRAY_INDEX",a,t,e);af(d)&&(d=~~d)}if(c>=l){if(r&&t.op==="add"&&d>s.length)throw new nt("The specified index MUST NOT be greater than the number of elements in the array","OPERATION_VALUE_OUT_OF_BOUNDS",a,t,e);let p=nD[t.op].call(t,s,d,e);if(p.test===!1)throw new nt("Test operation failed","TEST_OPERATION_FAILED",a,t,e);return p}}else if(c>=l){let p=ys[t.op].call(t,s,d,e);if(p.test===!1)throw new nt("Test operation failed","TEST_OPERATION_FAILED",a,t,e);return p}if(s=s[d],r&&c<l&&(!s||typeof s!="object"))throw new nt("Cannot perform operation at the desired path","OPERATION_PATH_UNRESOLVABLE",a,t,e)}}}function ea(e,t,r,i=!0,n=!0){if(r&&!Array.isArray(t))throw new nt("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");i||(e=Tr(e));let a=new Array(t.length);for(let o=0,s=t.length;o<s;o++)a[o]=no(e,t[o],r,!0,n,o),e=a[o].newDocument;return a.newDocument=e,a}function iD(e,t,r){let i=no(e,t);if(i.test===!1)throw new nt("Test operation failed","TEST_OPERATION_FAILED",r,t,e);return i.newDocument}function sf(e,t,r,i){if(typeof e!="object"||e===null||Array.isArray(e))throw new nt("Operation is not an object","OPERATION_NOT_AN_OBJECT",t,e,r);if(ys[e.op]){if(typeof e.path!="string")throw new nt("Operation `path` property is not a string","OPERATION_PATH_INVALID",t,e,r);if(e.path.indexOf("/")!==0&&e.path.length>0)throw new nt('Operation `path` property must start with "/"',"OPERATION_PATH_INVALID",t,e,r);if((e.op==="move"||e.op==="copy")&&typeof e.from!="string")throw new nt("Operation `from` property is not present (applicable in `move` and `copy` operations)","OPERATION_FROM_REQUIRED",t,e,r);if((e.op==="add"||e.op==="replace"||e.op==="test")&&e.value===void 0)throw new nt("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_REQUIRED",t,e,r);if((e.op==="add"||e.op==="replace"||e.op==="test")&&tf(e.value))throw new nt("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED",t,e,r);if(r){if(e.op=="add"){var n=e.path.split("/").length,a=i.split("/").length;if(n!==a+1&&n!==a)throw new nt("Cannot perform an `add` operation at the desired path","OPERATION_PATH_CANNOT_ADD",t,e,r)}else if(e.op==="replace"||e.op==="remove"||e.op==="_get"){if(e.path!==i)throw new nt("Cannot perform the operation at a path that does not exist","OPERATION_PATH_UNRESOLVABLE",t,e,r)}else if(e.op==="move"||e.op==="copy"){var o=jI([{op:"_get",path:e.from,value:void 0}],r);if(o&&o.name==="OPERATION_PATH_UNRESOLVABLE")throw new nt("Cannot perform the operation from a path that does not exist","OPERATION_FROM_UNRESOLVABLE",t,e,r)}}}else throw new nt("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",t,e,r)}function jI(e,t,r){try{if(!Array.isArray(e))throw new nt("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");if(t)ea(Tr(t),Tr(e),r||!0);else{r=r||sf;for(var i=0;i<e.length;i++)r(e[i],i,t,void 0)}}catch(n){if(n instanceof nt)return n;throw n}}function ol(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){var r=Array.isArray(e),i=Array.isArray(t),n,a,o;if(r&&i){if(a=e.length,a!=t.length)return!1;for(n=a;n--!==0;)if(!ol(e[n],t[n]))return!1;return!0}if(r!=i)return!1;var s=Object.keys(e);if(a=s.length,a!==Object.keys(t).length)return!1;for(n=a;n--!==0;)if(!t.hasOwnProperty(s[n]))return!1;for(n=a;n--!==0;)if(o=s[n],!ol(e[o],t[o]))return!1;return!0}return e!==e&&t!==t}function zI(e,t,r,i,n){if(t!==e){typeof t.toJSON=="function"&&(t=t.toJSON());for(var a=nf(t),o=nf(e),s=!1,c=o.length-1;c>=0;c--){var l=o[c],u=e[l];if(rf(t,l)&&!(t[l]===void 0&&u!==void 0&&Array.isArray(t)===!1)){var d=t[l];typeof u=="object"&&u!=null&&typeof d=="object"&&d!=null&&Array.isArray(u)===Array.isArray(d)?zI(u,d,r,i+"/"+ro(l),n):u!==d&&(n&&r.push({op:"test",path:i+"/"+ro(l),value:Tr(u)}),r.push({op:"replace",path:i+"/"+ro(l),value:Tr(d)}))}else Array.isArray(e)===Array.isArray(t)?(n&&r.push({op:"test",path:i+"/"+ro(l),value:Tr(u)}),r.push({op:"remove",path:i+"/"+ro(l)}),s=!0):(n&&r.push({op:"test",path:i,value:e}),r.push({op:"replace",path:i,value:t}))}if(!(!s&&a.length==o.length))for(var c=0;c<a.length;c++){var l=a[c];!rf(e,l)&&t[l]!==void 0&&r.push({op:"add",path:i+"/"+ro(l),value:Tr(t[l])})}}}function ta(e,t,r=!1){var i=[];return zI(e,t,i,"",r),i}({...MI});var LI=T({LogStreamCallbackHandler:()=>lf,RunLog:()=>cf,RunLogPatch:()=>Fn,isLogStreamHandler:()=>p_}),Fn=class{ops;constructor(e){this.ops=e.ops??[]}concat(e){let t=this.ops.concat(e.ops),r=ea({},t);return new cf({ops:t,state:r[r.length-1].newDocument})}},cf=class f_ extends Fn{state;constructor(t){super(t),this.state=t.state}concat(t){let r=this.ops.concat(t.ops),i=ea(this.state,t.ops);return new f_({ops:r,state:i[i.length-1].newDocument})}static fromRunLogPatch(t){let r=ea({},t.ops);return new f_({ops:t.ops,state:r[r.length-1].newDocument})}},p_=e=>e.name==="log_stream_tracer";async function DI(e,t){if(t==="original")throw new Error("Do not assign inputs with original schema drop the key for now. When inputs are added to streamLog they should be added with standardized schema for streaming events.");let{inputs:r}=e;if(["retriever","llm","prompt"].includes(e.run_type))return r;if(!(Object.keys(r).length===1&&r?.input===""))return r.input}async function UI(e,t){let{outputs:r}=e;return t==="original"||["retriever","llm","prompt"].includes(e.run_type)?r:r!==void 0&&Object.keys(r).length===1&&r?.output!==void 0?r.output:r}function aD(e){return e!==void 0&&e.message!==void 0}var lf=class extends Ot{autoClose=!0;includeNames;includeTypes;includeTags;excludeNames;excludeTypes;excludeTags;_schemaFormat="original";rootId;keyMapByRunId={};counterMapByRunName={};transformStream;writer;receiveStream;name="log_stream_tracer";lc_prefer_streaming=!0;constructor(e){super({_awaitHandler:!0,...e}),this.autoClose=e?.autoClose??!0,this.includeNames=e?.includeNames,this.includeTypes=e?.includeTypes,this.includeTags=e?.includeTags,this.excludeNames=e?.excludeNames,this.excludeTypes=e?.excludeTypes,this.excludeTags=e?.excludeTags,this._schemaFormat=e?._schemaFormat??this._schemaFormat,this.transformStream=new TransformStream,this.writer=this.transformStream.writable.getWriter(),this.receiveStream=dt.fromReadableStream(this.transformStream.readable)}[Symbol.asyncIterator](){return this.receiveStream}async persistRun(e){}_includeRun(e){if(e.id===this.rootId)return!1;let t=e.tags??[],r=this.includeNames===void 0&&this.includeTags===void 0&&this.includeTypes===void 0;return this.includeNames!==void 0&&(r=r||this.includeNames.includes(e.name)),this.includeTypes!==void 0&&(r=r||this.includeTypes.includes(e.run_type)),this.includeTags!==void 0&&(r=r||t.find(i=>this.includeTags?.includes(i))!==void 0),this.excludeNames!==void 0&&(r=r&&!this.excludeNames.includes(e.name)),this.excludeTypes!==void 0&&(r=r&&!this.excludeTypes.includes(e.run_type)),this.excludeTags!==void 0&&(r=r&&t.every(i=>!this.excludeTags?.includes(i))),r}async*tapOutputIterable(e,t){for await(let r of t){if(e!==this.rootId){let i=this.keyMapByRunId[e];i&&await this.writer.write(new Fn({ops:[{op:"add",path:`/logs/${i}/streamed_output/-`,value:r}]}))}yield r}}async onRunCreate(e){if(this.rootId===void 0&&(this.rootId=e.id,await this.writer.write(new Fn({ops:[{op:"replace",path:"",value:{id:e.id,name:e.name,type:e.run_type,streamed_output:[],final_output:void 0,logs:{}}}]}))),!this._includeRun(e))return;this.counterMapByRunName[e.name]===void 0&&(this.counterMapByRunName[e.name]=0),this.counterMapByRunName[e.name]+=1;let t=this.counterMapByRunName[e.name];this.keyMapByRunId[e.id]=t===1?e.name:`${e.name}:${t}`;let r={id:e.id,name:e.name,type:e.run_type,tags:e.tags??[],metadata:e.extra?.metadata??{},start_time:new Date(e.start_time).toISOString(),streamed_output:[],streamed_output_str:[],final_output:void 0,end_time:void 0};this._schemaFormat==="streaming_events"&&(r.inputs=await DI(e,this._schemaFormat)),await this.writer.write(new Fn({ops:[{op:"add",path:`/logs/${this.keyMapByRunId[e.id]}`,value:r}]}))}async onRunUpdate(e){try{let t=this.keyMapByRunId[e.id];if(t===void 0)return;let r=[];this._schemaFormat==="streaming_events"&&r.push({op:"replace",path:`/logs/${t}/inputs`,value:await DI(e,this._schemaFormat)}),r.push({op:"add",path:`/logs/${t}/final_output`,value:await UI(e,this._schemaFormat)}),e.end_time!==void 0&&r.push({op:"add",path:`/logs/${t}/end_time`,value:new Date(e.end_time).toISOString()});let i=new Fn({ops:r});await this.writer.write(i)}finally{if(e.id===this.rootId){let t=new Fn({ops:[{op:"replace",path:"/final_output",value:await UI(e,this._schemaFormat)}]});await this.writer.write(t),this.autoClose&&await this.writer.close()}}}async onLLMNewToken(e,t,r){let i=this.keyMapByRunId[e.id];if(i===void 0)return;let n=e.inputs.messages!==void 0,a;n?aD(r?.chunk)?a=r?.chunk:a=new Qe({id:`run-${e.id}`,content:t}):a=t;let o=new Fn({ops:[{op:"add",path:`/logs/${i}/streamed_output_str/-`,value:t},{op:"add",path:`/logs/${i}/streamed_output/-`,value:a}]});await this.writer.write(o)}};var FI=T({ChatGenerationChunk:()=>ra,GenerationChunk:()=>mi,RUN_KEY:()=>io}),io="__run",mi=class BI{text;generationInfo;constructor(t){this.text=t.text,this.generationInfo=t.generationInfo}concat(t){return new BI({text:this.text+t.text,generationInfo:{...this.generationInfo,...t.generationInfo}})}},ra=class VI extends mi{message;constructor(t){super(t),this.message=t.message}concat(t){return new VI({text:this.text+t.text,generationInfo:{...this.generationInfo,...t.generationInfo},message:this.message.concat(t.message)})}};var oD=Object.prototype.toString,sD=e=>oD.call(e)==="[object Error]",cD=new Set(["network error","Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed","fetch failed","terminated"," A network error occurred.","Network connection lost"]);function ZI(e){if(!(e&&sD(e)&&e.name==="TypeError"&&typeof e.message=="string"))return!1;let{message:t,stack:r}=e;return t==="Load failed"?r===void 0||"__sentry_captured__"in e:t.startsWith("error sending request for url")?!0:cD.has(t)}function lD(e){if(typeof e=="number"){if(e<0)throw new TypeError("Expected `retries` to be a non-negative number.");if(Number.isNaN(e))throw new TypeError("Expected `retries` to be a valid number or Infinity, got NaN.")}else if(e!==void 0)throw new TypeError("Expected `retries` to be a number or Infinity.")}function uf(e,t,{min:r=0,allowInfinity:i=!1}={}){if(t!==void 0){if(typeof t!="number"||Number.isNaN(t))throw new TypeError(`Expected \`${e}\` to be a number${i?" or Infinity":""}.`);if(!i&&!Number.isFinite(t))throw new TypeError(`Expected \`${e}\` to be a finite number.`);if(t<r)throw new TypeError(`Expected \`${e}\` to be \u2265 ${r}.`)}}var uD=class extends Error{constructor(e){super(),e instanceof Error?(this.originalError=e,{message:e}=e):(this.originalError=new Error(e),this.originalError.stack=this.stack),this.name="AbortError",this.message=e}};function dD(e,t){let r=Math.max(1,e+1),i=t.randomize?Math.random()+1:1,n=Math.round(i*t.minTimeout*t.factor**(r-1));return n=Math.min(n,t.maxTimeout),n}function HI(e,t){return Number.isFinite(t)?t-(performance.now()-e):t}async function fD({error:e,attemptNumber:t,retriesConsumed:r,startTime:i,options:n}){let a=e instanceof Error?e:new TypeError(`Non-error was thrown: "${e}". You should only throw errors.`);if(a instanceof uD)throw a.originalError;let o=Number.isFinite(n.retries)?Math.max(0,n.retries-r):n.retries,s=n.maxRetryTime??Number.POSITIVE_INFINITY,c=Object.freeze({error:a,attemptNumber:t,retriesLeft:o,retriesConsumed:r});if(await n.onFailedAttempt(c),HI(i,s)<=0)throw a;let l=await n.shouldConsumeRetry(c),u=HI(i,s);if(u<=0||o<=0)throw a;if(a instanceof TypeError&&!ZI(a)){if(l)throw a;return n.signal?.throwIfAborted(),!1}if(!await n.shouldRetry(c))throw a;if(!l)return n.signal?.throwIfAborted(),!1;let d=dD(r,n),f=Math.min(d,u);return f>0&&await new Promise((p,m)=>{let h=()=>{clearTimeout(_),n.signal?.removeEventListener("abort",h),m(n.signal.reason)},_=setTimeout(()=>{n.signal?.removeEventListener("abort",h),p()},f);n.unref&&_.unref?.(),n.signal?.addEventListener("abort",h,{once:!0})}),n.signal?.throwIfAborted(),!0}async function sl(e,t={}){if(t={...t},lD(t.retries),Object.hasOwn(t,"forever"))throw new Error("The `forever` option is no longer supported. For many use-cases, you can set `retries: Infinity` instead.");t.retries??=10,t.factor??=2,t.minTimeout??=1e3,t.maxTimeout??=Number.POSITIVE_INFINITY,t.maxRetryTime??=Number.POSITIVE_INFINITY,t.randomize??=!1,t.onFailedAttempt??=()=>{},t.shouldRetry??=()=>!0,t.shouldConsumeRetry??=()=>!0,uf("factor",t.factor,{min:0,allowInfinity:!1}),uf("minTimeout",t.minTimeout,{min:0,allowInfinity:!1}),uf("maxTimeout",t.maxTimeout,{min:0,allowInfinity:!0}),uf("maxRetryTime",t.maxRetryTime,{min:0,allowInfinity:!0}),t.factor>0||(t.factor=1),t.signal?.throwIfAborted();let r=0,i=0,n=performance.now();for(;!Number.isFinite(t.retries)||i<=t.retries;){r++;try{t.signal?.throwIfAborted();let a=await e(r);return t.signal?.throwIfAborted(),a}catch(a){await fD({error:a,attemptNumber:r,retriesConsumed:i,startTime:n,options:t})&&i++}}throw new Error("Retry attempts exhausted without throwing an error.")}var df=zu(Ud(),1),GI=T({AsyncCaller:()=>hi}),pD=[400,401,402,403,404,405,406,407,409],mD=e=>{if(typeof e!="object"||e===null)return;if("message"in e&&typeof e.message=="string"&&(e.message.startsWith("Cancel")||e.message.startsWith("AbortError"))||"name"in e&&typeof e.name=="string"&&e.name==="AbortError"||"code"in e&&typeof e.code=="string"&&e.code==="ECONNABORTED")throw e;let t="response"in e&&typeof e.response=="object"&&e.response!==null&&"status"in e.response&&typeof e.response.status=="number"?e.response.status:void 0,r="status"in e&&typeof e.status=="number"?e.status:void 0,i=t??r;if(i&&pD.includes(+i))throw e;if(("error"in e&&typeof e.error=="object"&&e.error!==null&&"code"in e.error&&typeof e.error.code=="string"?e.error.code:void 0)==="insufficient_quota"){let n=new Error("message"in e&&typeof e.message=="string"?e.message:"Insufficient quota");throw n.name="InsufficientQuotaError",n}},hi=class{maxConcurrency;maxRetries;onFailedAttempt;queue;constructor(e){this.maxConcurrency=e.maxConcurrency??1/0,this.maxRetries=e.maxRetries??6,this.onFailedAttempt=e.onFailedAttempt??mD;let t="default"in df.default?df.default.default:df.default;this.queue=new t({concurrency:this.maxConcurrency})}async call(e,...t){return this.queue.add(()=>sl(()=>e(...t).catch(r=>{throw r instanceof Error?r:new Error(r)}),{onFailedAttempt:({error:r})=>this.onFailedAttempt?.(r),retries:this.maxRetries,randomize:!0}),{throwOnTimeout:!0})}callWithOptions(e,t,...r){if(e.signal){let i;return Promise.race([this.call(t,...r),new Promise((n,a)=>{i=()=>{a(Yi(e.signal))},e.signal?.addEventListener("abort",i,{once:!0})})]).finally(()=>{e.signal&&i&&e.signal.removeEventListener("abort",i)})}return this.call(t,...r)}fetch(...e){return this.call(()=>fetch(...e).then(t=>t.ok?t:Promise.reject(t)))}};var WI=T({isSerializableSchema:()=>ao,isStandardJsonSchema:()=>ff,isStandardSchema:()=>JI});function JI(e){return(typeof e=="object"||typeof e=="function")&&e!==null&&"~standard"in e&&typeof e["~standard"]=="object"&&e["~standard"]!==null&&"validate"in e["~standard"]}function ff(e){return(typeof e=="object"||typeof e=="function")&&e!==null&&"~standard"in e&&typeof e["~standard"]=="object"&&e["~standard"]!==null&&"jsonSchema"in e["~standard"]}function ao(e){return JI(e)&&ff(e)}var yi={};Tn(yi,{$ZodAny:()=>nv,$ZodArray:()=>ov,$ZodAsyncError:()=>cn,$ZodBase64:()=>Wy,$ZodBase64URL:()=>Jy,$ZodBigInt:()=>Pf,$ZodBigIntFormat:()=>Qy,$ZodBoolean:()=>bl,$ZodCIDRv4:()=>Zy,$ZodCIDRv6:()=>Hy,$ZodCUID:()=>Py,$ZodCUID2:()=>Ny,$ZodCatch:()=>kv,$ZodCheck:()=>Le,$ZodCheckBigIntFormat:()=>cy,$ZodCheckEndsWith:()=>by,$ZodCheckGreaterThan:()=>Ef,$ZodCheckIncludes:()=>yy,$ZodCheckLengthEquals:()=>my,$ZodCheckLessThan:()=>$f,$ZodCheckLowerCase:()=>gy,$ZodCheckMaxLength:()=>fy,$ZodCheckMaxSize:()=>ly,$ZodCheckMimeType:()=>xy,$ZodCheckMinLength:()=>py,$ZodCheckMinSize:()=>uy,$ZodCheckMultipleOf:()=>oy,$ZodCheckNumberFormat:()=>sy,$ZodCheckOverwrite:()=>Sy,$ZodCheckProperty:()=>wy,$ZodCheckRegex:()=>hy,$ZodCheckSizeEquals:()=>dy,$ZodCheckStartsWith:()=>vy,$ZodCheckStringFormat:()=>Es,$ZodCheckUpperCase:()=>_y,$ZodCodec:()=>kl,$ZodCustom:()=>Pv,$ZodCustomStringFormat:()=>Xy,$ZodDate:()=>av,$ZodDefault:()=>bv,$ZodDiscriminatedUnion:()=>lv,$ZodE164:()=>Ky,$ZodEmail:()=>Ty,$ZodEmoji:()=>Ay,$ZodEncodeError:()=>na,$ZodEnum:()=>mv,$ZodError:()=>ml,$ZodExactOptional:()=>yv,$ZodFile:()=>gv,$ZodFunction:()=>Cv,$ZodGUID:()=>Ey,$ZodIPv4:()=>Fy,$ZodIPv6:()=>By,$ZodISODate:()=>Dy,$ZodISODateTime:()=>zy,$ZodISODuration:()=>Ly,$ZodISOTime:()=>Uy,$ZodIntersection:()=>uv,$ZodJWT:()=>qy,$ZodKSUID:()=>jy,$ZodLazy:()=>Ov,$ZodLiteral:()=>hv,$ZodMAC:()=>Vy,$ZodMap:()=>fv,$ZodNaN:()=>$v,$ZodNanoID:()=>Oy,$ZodNever:()=>xl,$ZodNonOptional:()=>xv,$ZodNull:()=>rv,$ZodNullable:()=>vv,$ZodNumber:()=>Of,$ZodNumberFormat:()=>Yy,$ZodObject:()=>$T,$ZodObjectJIT:()=>sv,$ZodOptional:()=>fo,$ZodPipe:()=>Rf,$ZodPrefault:()=>wv,$ZodPreprocess:()=>Ev,$ZodPromise:()=>Av,$ZodReadonly:()=>Iv,$ZodRealError:()=>hr,$ZodRecord:()=>dv,$ZodRegistry:()=>Df,$ZodSet:()=>pv,$ZodString:()=>uo,$ZodStringFormat:()=>ze,$ZodSuccess:()=>Sv,$ZodSymbol:()=>ev,$ZodTemplateLiteral:()=>Tv,$ZodTransform:()=>_v,$ZodTuple:()=>Nf,$ZodType:()=>de,$ZodULID:()=>Ry,$ZodURL:()=>Cy,$ZodUUID:()=>Iy,$ZodUndefined:()=>tv,$ZodUnion:()=>Sl,$ZodUnknown:()=>wl,$ZodVoid:()=>iv,$ZodXID:()=>My,$ZodXor:()=>cv,$brand:()=>h_,$constructor:()=>k,$input:()=>Rv,$output:()=>Nv,Doc:()=>vl,JSONSchema:()=>IC,JSONSchemaGenerator:()=>mp,NEVER:()=>m_,TimePrecision:()=>Dv,_any:()=>ab,_array:()=>ub,_base64:()=>rp,_base64url:()=>np,_bigint:()=>Yv,_boolean:()=>qv,_catch:()=>z2,_check:()=>EC,_cidrv4:()=>ep,_cidrv6:()=>tp,_coercedBigint:()=>Qv,_coercedBoolean:()=>Xv,_coercedDate:()=>cb,_coercedNumber:()=>Zv,_coercedString:()=>jv,_cuid:()=>Wf,_cuid2:()=>Jf,_custom:()=>fb,_date:()=>sb,_decode:()=>gf,_decodeAsync:()=>yf,_default:()=>R2,_discriminatedUnion:()=>x2,_e164:()=>ip,_email:()=>Lf,_emoji:()=>Hf,_encode:()=>hf,_encodeAsync:()=>_f,_endsWith:()=>Ns,_enum:()=>T2,_file:()=>db,_float32:()=>Gv,_float64:()=>Wv,_gt:()=>Vn,_gte:()=>ar,_guid:()=>Il,_includes:()=>Os,_int:()=>Hv,_int32:()=>Jv,_int64:()=>eb,_intersection:()=>S2,_ipv4:()=>Yf,_ipv6:()=>Qf,_isoDate:()=>Lv,_isoDateTime:()=>Uv,_isoDuration:()=>Bv,_isoTime:()=>Fv,_jwt:()=>ap,_ksuid:()=>Xf,_lazy:()=>F2,_length:()=>ho,_literal:()=>A2,_lowercase:()=>Cs,_lt:()=>Bn,_lte:()=>Ar,_mac:()=>zv,_map:()=>E2,_max:()=>Ar,_maxLength:()=>mo,_maxSize:()=>ua,_mime:()=>Rs,_min:()=>ar,_minLength:()=>_i,_minSize:()=>Zn,_multipleOf:()=>la,_nan:()=>lb,_nanoid:()=>Gf,_nativeEnum:()=>C2,_negative:()=>sp,_never:()=>Al,_nonnegative:()=>lp,_nonoptional:()=>M2,_nonpositive:()=>cp,_normalize:()=>Ms,_null:()=>ib,_nullable:()=>N2,_number:()=>Vv,_optional:()=>P2,_overwrite:()=>ln,_parse:()=>xs,_parseAsync:()=>Ss,_pipe:()=>D2,_positive:()=>op,_promise:()=>B2,_property:()=>up,_readonly:()=>U2,_record:()=>$2,_refine:()=>pb,_regex:()=>Ts,_safeDecode:()=>bf,_safeDecodeAsync:()=>xf,_safeEncode:()=>vf,_safeEncodeAsync:()=>wf,_safeParse:()=>ks,_safeParseAsync:()=>$s,_set:()=>I2,_size:()=>po,_slugify:()=>Us,_startsWith:()=>Ps,_string:()=>Mv,_stringFormat:()=>Ls,_stringbool:()=>_b,_success:()=>j2,_superRefine:()=>mb,_symbol:()=>rb,_templateLiteral:()=>L2,_toLowerCase:()=>zs,_toUpperCase:()=>Ds,_transform:()=>O2,_trim:()=>js,_tuple:()=>k2,_uint32:()=>Kv,_uint64:()=>tb,_ulid:()=>Kf,_undefined:()=>nb,_union:()=>b2,_unknown:()=>Cl,_uppercase:()=>As,_url:()=>Tl,_uuid:()=>Ff,_uuidv4:()=>Bf,_uuidv6:()=>Vf,_uuidv7:()=>Zf,_void:()=>ob,_xid:()=>qf,_xor:()=>w2,clone:()=>We,config:()=>it,createStandardJSONSchemaMethod:()=>Fs,createToJSONSchemaMethod:()=>yb,decode:()=>BD,decodeAsync:()=>ZD,describe:()=>hb,encode:()=>FD,encodeAsync:()=>VD,extractDefs:()=>fa,finalize:()=>pa,flattenError:()=>hl,formatError:()=>gl,globalConfig:()=>oo,globalRegistry:()=>Ne,initializeContext:()=>da,isValidBase64:()=>Gy,isValidBase64URL:()=>wT,isValidJWT:()=>xT,locales:()=>El,meta:()=>gb,parse:()=>ca,parseAsync:()=>co,prettifyError:()=>T_,process:()=>Re,regexes:()=>Cr,registry:()=>Uf,safeDecode:()=>GD,safeDecodeAsync:()=>JD,safeEncode:()=>HD,safeEncodeAsync:()=>WD,safeParse:()=>C_,safeParseAsync:()=>A_,toDotPath:()=>eT,toJSONSchema:()=>go,treeifyError:()=>I_,util:()=>j,version:()=>ky});var KI,m_=Object.freeze({status:"aborted"});function k(e,t,r){function i(s,c){if(s._zod||Object.defineProperty(s,"_zod",{value:{def:c,constr:o,traits:new Set},enumerable:!1}),s._zod.traits.has(e))return;s._zod.traits.add(e),t(s,c);let l=o.prototype,u=Object.keys(l);for(let d=0;d<u.length;d++){let f=u[d];f in s||(s[f]=l[f].bind(s))}}let n=r?.Parent??Object;class a extends n{}Object.defineProperty(a,"name",{value:e});function o(s){var c;let l=r?.Parent?new a:this;i(l,s),(c=l._zod).deferred??(c.deferred=[]);for(let u of l._zod.deferred)u();return l}return Object.defineProperty(o,"init",{value:i}),Object.defineProperty(o,Symbol.hasInstance,{value:s=>r?.Parent&&s instanceof r.Parent?!0:s?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var h_=Symbol("zod_brand"),cn=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},na=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}};(KI=globalThis).__zod_globalConfig??(KI.__zod_globalConfig={});var oo=globalThis.__zod_globalConfig;function it(e){return e&&Object.assign(oo,e),oo}var j={};Tn(j,{BIGINT_FORMAT_RANGES:()=>$_,Class:()=>__,NUMBER_FORMAT_RANGES:()=>k_,aborted:()=>sa,allowsEval:()=>b_,assert:()=>vD,assertEqual:()=>hD,assertIs:()=>_D,assertNever:()=>yD,assertNotEqual:()=>gD,assignProp:()=>aa,base64ToUint8Array:()=>XI,base64urlToUint8Array:()=>jD,cached:()=>bs,captureStackTrace:()=>mf,cleanEnum:()=>MD,cleanRegex:()=>ul,clone:()=>We,cloneDef:()=>wD,createTransparentProxy:()=>ID,defineLazy:()=>xe,esc:()=>pf,escapeRegex:()=>Vr,explicitlyAborted:()=>E_,extend:()=>AD,finalizeIssue:()=>ir,floatSafeRemainder:()=>y_,getElementAtPath:()=>xD,getEnumValues:()=>ll,getLengthableOrigin:()=>pl,getParsedType:()=>ED,getSizableOrigin:()=>fl,hexToUint8Array:()=>DD,isObject:()=>so,isPlainObject:()=>oa,issue:()=>ws,joinValues:()=>I,jsonStringifyReplacer:()=>vs,merge:()=>PD,mergeDefs:()=>gi,normalizeParams:()=>F,nullish:()=>ia,numKeys:()=>$D,objectClone:()=>bD,omit:()=>CD,optionalKeys:()=>S_,parsedType:()=>M,partial:()=>ND,pick:()=>TD,prefixIssues:()=>mr,primitiveTypes:()=>x_,promiseAllObject:()=>SD,propertyKeyTypes:()=>dl,randomString:()=>kD,required:()=>RD,safeExtend:()=>OD,shallowClone:()=>w_,slugify:()=>v_,stringifyPrimitive:()=>R,uint8ArrayToBase64:()=>YI,uint8ArrayToBase64url:()=>zD,uint8ArrayToHex:()=>UD,unwrapMessage:()=>cl});function hD(e){return e}function gD(e){return e}function _D(e){}function yD(e){throw new Error("Unexpected value in exhaustive check")}function vD(e){}function ll(e){let t=Object.values(e).filter(i=>typeof i=="number");return Object.entries(e).filter(([i,n])=>t.indexOf(+i)===-1).map(([i,n])=>n)}function I(e,t="|"){return e.map(r=>R(r)).join(t)}function vs(e,t){return typeof t=="bigint"?t.toString():t}function bs(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function ia(e){return e==null}function ul(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function y_(e,t){let r=e/t,i=Math.round(r),n=Number.EPSILON*Math.max(Math.abs(r),1);return Math.abs(r-i)<n?0:r-i}var qI=Symbol("evaluating");function xe(e,t,r){let i;Object.defineProperty(e,t,{get(){if(i!==qI)return i===void 0&&(i=qI,i=r()),i},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function bD(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function aa(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function gi(...e){let t={};for(let r of e){let i=Object.getOwnPropertyDescriptors(r);Object.assign(t,i)}return Object.defineProperties({},t)}function wD(e){return gi(e._zod.def)}function xD(e,t){return t?t.reduce((r,i)=>r?.[i],e):e}function SD(e){let t=Object.keys(e),r=t.map(i=>e[i]);return Promise.all(r).then(i=>{let n={};for(let a=0;a<t.length;a++)n[t[a]]=i[a];return n})}function kD(e=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let i=0;i<e;i++)r+=t[Math.floor(Math.random()*t.length)];return r}function pf(e){return JSON.stringify(e)}function v_(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var mf="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function so(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var b_=bs(()=>{if(oo.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function oa(e){if(so(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(so(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function w_(e){return oa(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function $D(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}var ED=e=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},dl=new Set(["string","number","symbol"]),x_=new Set(["string","number","bigint","boolean","symbol","undefined"]);function Vr(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function We(e,t,r){let i=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(i._zod.parent=e),i}function F(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function ID(e){let t;return new Proxy({},{get(r,i,n){return t??(t=e()),Reflect.get(t,i,n)},set(r,i,n,a){return t??(t=e()),Reflect.set(t,i,n,a)},has(r,i){return t??(t=e()),Reflect.has(t,i)},deleteProperty(r,i){return t??(t=e()),Reflect.deleteProperty(t,i)},ownKeys(r){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(r,i){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,i)},defineProperty(r,i,n){return t??(t=e()),Reflect.defineProperty(t,i,n)}})}function R(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function S_(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var k_={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},$_={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function TD(e,t){let r=e._zod.def,i=r.checks;if(i&&i.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let a=gi(e._zod.def,{get shape(){let o={};for(let s in t){if(!(s in r.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&(o[s]=r.shape[s])}return aa(this,"shape",o),o},checks:[]});return We(e,a)}function CD(e,t){let r=e._zod.def,i=r.checks;if(i&&i.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let a=gi(e._zod.def,{get shape(){let o={...e._zod.def.shape};for(let s in t){if(!(s in r.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&delete o[s]}return aa(this,"shape",o),o},checks:[]});return We(e,a)}function AD(e,t){if(!oa(t))throw new Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let a=e._zod.def.shape;for(let o in t)if(Object.getOwnPropertyDescriptor(a,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let n=gi(e._zod.def,{get shape(){let a={...e._zod.def.shape,...t};return aa(this,"shape",a),a}});return We(e,n)}function OD(e,t){if(!oa(t))throw new Error("Invalid input to safeExtend: expected a plain object");let r=gi(e._zod.def,{get shape(){let i={...e._zod.def.shape,...t};return aa(this,"shape",i),i}});return We(e,r)}function PD(e,t){if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r=gi(e._zod.def,{get shape(){let i={...e._zod.def.shape,...t._zod.def.shape};return aa(this,"shape",i),i},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return We(e,r)}function ND(e,t,r){let n=t._zod.def.checks;if(n&&n.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");let o=gi(t._zod.def,{get shape(){let s=t._zod.def.shape,c={...s};if(r)for(let l in r){if(!(l in s))throw new Error(`Unrecognized key: "${l}"`);r[l]&&(c[l]=e?new e({type:"optional",innerType:s[l]}):s[l])}else for(let l in s)c[l]=e?new e({type:"optional",innerType:s[l]}):s[l];return aa(this,"shape",c),c},checks:[]});return We(t,o)}function RD(e,t,r){let i=gi(t._zod.def,{get shape(){let n=t._zod.def.shape,a={...n};if(r)for(let o in r){if(!(o in a))throw new Error(`Unrecognized key: "${o}"`);r[o]&&(a[o]=new e({type:"nonoptional",innerType:n[o]}))}else for(let o in n)a[o]=new e({type:"nonoptional",innerType:n[o]});return aa(this,"shape",a),a}});return We(t,i)}function sa(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function E_(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function mr(e,t){return t.map(r=>{var i;return(i=r).path??(i.path=[]),r.path.unshift(e),r})}function cl(e){return typeof e=="string"?e:e?.message}function ir(e,t,r){let i=e.message?e.message:cl(e.inst?._zod.def?.error?.(e))??cl(t?.error?.(e))??cl(r.customError?.(e))??cl(r.localeError?.(e))??"Invalid input",{inst:n,continue:a,input:o,...s}=e;return s.path??(s.path=[]),s.message=i,t?.reportInput&&(s.input=o),s}function fl(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function pl(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function M(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let r=e;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return t}function ws(...e){let[t,r,i]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:i}:{...t}}function MD(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function XI(e){let t=atob(e),r=new Uint8Array(t.length);for(let i=0;i<t.length;i++)r[i]=t.charCodeAt(i);return r}function YI(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function jD(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return XI(t+r)}function zD(e){return YI(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function DD(e){let t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");let r=new Uint8Array(t.length/2);for(let i=0;i<t.length;i+=2)r[i/2]=Number.parseInt(t.slice(i,i+2),16);return r}function UD(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var __=class{constructor(...t){}};var QI=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,vs,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},ml=k("$ZodError",QI),hr=k("$ZodError",QI,{Parent:Error});function hl(e,t=r=>r.message){let r={},i=[];for(let n of e.issues)n.path.length>0?(r[n.path[0]]=r[n.path[0]]||[],r[n.path[0]].push(t(n))):i.push(t(n));return{formErrors:i,fieldErrors:r}}function gl(e,t=r=>r.message){let r={_errors:[]},i=(n,a=[])=>{for(let o of n.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map(s=>i({issues:s},[...a,...o.path]));else if(o.code==="invalid_key")i({issues:o.issues},[...a,...o.path]);else if(o.code==="invalid_element")i({issues:o.issues},[...a,...o.path]);else{let s=[...a,...o.path];if(s.length===0)r._errors.push(t(o));else{let c=r,l=0;for(;l<s.length;){let u=s[l];l===s.length-1?(c[u]=c[u]||{_errors:[]},c[u]._errors.push(t(o))):c[u]=c[u]||{_errors:[]},c=c[u],l++}}}};return i(e),r}function I_(e,t=r=>r.message){let r={errors:[]},i=(n,a=[])=>{var o,s;for(let c of n.issues)if(c.code==="invalid_union"&&c.errors.length)c.errors.map(l=>i({issues:l},[...a,...c.path]));else if(c.code==="invalid_key")i({issues:c.issues},[...a,...c.path]);else if(c.code==="invalid_element")i({issues:c.issues},[...a,...c.path]);else{let l=[...a,...c.path];if(l.length===0){r.errors.push(t(c));continue}let u=r,d=0;for(;d<l.length;){let f=l[d],p=d===l.length-1;typeof f=="string"?(u.properties??(u.properties={}),(o=u.properties)[f]??(o[f]={errors:[]}),u=u.properties[f]):(u.items??(u.items=[]),(s=u.items)[f]??(s[f]={errors:[]}),u=u.items[f]),p&&u.errors.push(t(c)),d++}}};return i(e),r}function eT(e){let t=[],r=e.map(i=>typeof i=="object"?i.key:i);for(let i of r)typeof i=="number"?t.push(`[${i}]`):typeof i=="symbol"?t.push(`[${JSON.stringify(String(i))}]`):/[^\w$]/.test(i)?t.push(`[${JSON.stringify(i)}]`):(t.length&&t.push("."),t.push(i));return t.join("")}function T_(e){let t=[],r=[...e.issues].sort((i,n)=>(i.path??[]).length-(n.path??[]).length);for(let i of r)t.push(`\u2716 ${i.message}`),i.path?.length&&t.push(` \u2192 at ${eT(i.path)}`);return t.join(`
158
- `)}var xs=e=>(t,r,i,n)=>{let a=i?{...i,async:!1}:{async:!1},o=t._zod.run({value:r,issues:[]},a);if(o instanceof Promise)throw new cn;if(o.issues.length){let s=new(n?.Err??e)(o.issues.map(c=>ir(c,a,it())));throw mf(s,n?.callee),s}return o.value},ca=xs(hr),Ss=e=>async(t,r,i,n)=>{let a=i?{...i,async:!0}:{async:!0},o=t._zod.run({value:r,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let s=new(n?.Err??e)(o.issues.map(c=>ir(c,a,it())));throw mf(s,n?.callee),s}return o.value},co=Ss(hr),ks=e=>(t,r,i)=>{let n=i?{...i,async:!1}:{async:!1},a=t._zod.run({value:r,issues:[]},n);if(a instanceof Promise)throw new cn;return a.issues.length?{success:!1,error:new(e??ml)(a.issues.map(o=>ir(o,n,it())))}:{success:!0,data:a.value}},C_=ks(hr),$s=e=>async(t,r,i)=>{let n=i?{...i,async:!0}:{async:!0},a=t._zod.run({value:r,issues:[]},n);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(o=>ir(o,n,it())))}:{success:!0,data:a.value}},A_=$s(hr),hf=e=>(t,r,i)=>{let n=i?{...i,direction:"backward"}:{direction:"backward"};return xs(e)(t,r,n)},FD=hf(hr),gf=e=>(t,r,i)=>xs(e)(t,r,i),BD=gf(hr),_f=e=>async(t,r,i)=>{let n=i?{...i,direction:"backward"}:{direction:"backward"};return Ss(e)(t,r,n)},VD=_f(hr),yf=e=>async(t,r,i)=>Ss(e)(t,r,i),ZD=yf(hr),vf=e=>(t,r,i)=>{let n=i?{...i,direction:"backward"}:{direction:"backward"};return ks(e)(t,r,n)},HD=vf(hr),bf=e=>(t,r,i)=>ks(e)(t,r,i),GD=bf(hr),wf=e=>async(t,r,i)=>{let n=i?{...i,direction:"backward"}:{direction:"backward"};return $s(e)(t,r,n)},WD=wf(hr),xf=e=>async(t,r,i)=>$s(e)(t,r,i),JD=xf(hr);var Cr={};Tn(Cr,{base64:()=>G_,base64url:()=>Sf,bigint:()=>Q_,boolean:()=>ty,browserEmail:()=>rU,cidrv4:()=>Z_,cidrv6:()=>H_,cuid:()=>O_,cuid2:()=>P_,date:()=>K_,datetime:()=>X_,domain:()=>aU,duration:()=>z_,e164:()=>J_,email:()=>U_,emoji:()=>L_,extendedDuration:()=>KD,guid:()=>D_,hex:()=>oU,hostname:()=>iU,html5Email:()=>QD,httpProtocol:()=>W_,idnEmail:()=>tU,integer:()=>ey,ipv4:()=>F_,ipv6:()=>B_,ksuid:()=>M_,lowercase:()=>iy,mac:()=>V_,md5_base64:()=>cU,md5_base64url:()=>lU,md5_hex:()=>sU,nanoid:()=>j_,null:()=>ry,number:()=>kf,rfc5322Email:()=>eU,sha1_base64:()=>dU,sha1_base64url:()=>fU,sha1_hex:()=>uU,sha256_base64:()=>mU,sha256_base64url:()=>hU,sha256_hex:()=>pU,sha384_base64:()=>_U,sha384_base64url:()=>yU,sha384_hex:()=>gU,sha512_base64:()=>bU,sha512_base64url:()=>wU,sha512_hex:()=>vU,string:()=>Y_,time:()=>q_,ulid:()=>N_,undefined:()=>ny,unicodeEmail:()=>tT,uppercase:()=>ay,uuid:()=>lo,uuid4:()=>qD,uuid6:()=>XD,uuid7:()=>YD,xid:()=>R_});var O_=/^[cC][0-9a-z]{6,}$/,P_=/^[0-9a-z]+$/,N_=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,R_=/^[0-9a-vA-V]{20}$/,M_=/^[A-Za-z0-9]{27}$/,j_=/^[a-zA-Z0-9_-]{21}$/,z_=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,KD=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,D_=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,lo=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,qD=lo(4),XD=lo(6),YD=lo(7),U_=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,QD=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,eU=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,tT=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,tU=tT,rU=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,nU="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function L_(){return new RegExp(nU,"u")}var F_=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,B_=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,V_=e=>{let t=Vr(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},Z_=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,H_=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,G_=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Sf=/^[A-Za-z0-9_-]*$/,iU=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,aU=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,W_=/^https?$/,J_=/^\+[1-9]\d{6,14}$/,rT="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",K_=new RegExp(`^${rT}$`);function nT(e){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function q_(e){return new RegExp(`^${nT(e)}$`)}function X_(e){let t=nT({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let i=`${t}(?:${r.join("|")})`;return new RegExp(`^${rT}T(?:${i})$`)}var Y_=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Q_=/^-?\d+n?$/,ey=/^-?\d+$/,kf=/^-?\d+(?:\.\d+)?$/,ty=/^(?:true|false)$/i,ry=/^null$/i;var ny=/^undefined$/i;var iy=/^[^A-Z]*$/,ay=/^[^a-z]*$/,oU=/^[0-9a-fA-F]*$/;function _l(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function yl(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}var sU=/^[0-9a-fA-F]{32}$/,cU=_l(22,"=="),lU=yl(22),uU=/^[0-9a-fA-F]{40}$/,dU=_l(27,"="),fU=yl(27),pU=/^[0-9a-fA-F]{64}$/,mU=_l(43,"="),hU=yl(43),gU=/^[0-9a-fA-F]{96}$/,_U=_l(64,""),yU=yl(64),vU=/^[0-9a-fA-F]{128}$/,bU=_l(86,"=="),wU=yl(86);var Le=k("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),aT={number:"number",bigint:"bigint",object:"date"},$f=k("$ZodCheckLessThan",(e,t)=>{Le.init(e,t);let r=aT[typeof t.value];e._zod.onattach.push(i=>{let n=i._zod.bag,a=(t.inclusive?n.maximum:n.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<a&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=i=>{(t.inclusive?i.value<=t.value:i.value<t.value)||i.issues.push({origin:r,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Ef=k("$ZodCheckGreaterThan",(e,t)=>{Le.init(e,t);let r=aT[typeof t.value];e._zod.onattach.push(i=>{let n=i._zod.bag,a=(t.inclusive?n.minimum:n.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>a&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=i=>{(t.inclusive?i.value>=t.value:i.value>t.value)||i.issues.push({origin:r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),oy=k("$ZodCheckMultipleOf",(e,t)=>{Le.init(e,t),e._zod.onattach.push(r=>{var i;(i=r._zod.bag).multipleOf??(i.multipleOf=t.value)}),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%t.value===BigInt(0):y_(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),sy=k("$ZodCheckNumberFormat",(e,t)=>{Le.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),i=r?"int":"number",[n,a]=k_[t.format];e._zod.onattach.push(o=>{let s=o._zod.bag;s.format=t.format,s.minimum=n,s.maximum=a,r&&(s.pattern=ey)}),e._zod.check=o=>{let s=o.value;if(r){if(!Number.isInteger(s)){o.issues.push({expected:i,format:t.format,code:"invalid_type",continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort});return}}s<n&&o.issues.push({origin:"number",input:s,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:"number",input:s,code:"too_big",maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),cy=k("$ZodCheckBigIntFormat",(e,t)=>{Le.init(e,t);let[r,i]=$_[t.format];e._zod.onattach.push(n=>{let a=n._zod.bag;a.format=t.format,a.minimum=r,a.maximum=i}),e._zod.check=n=>{let a=n.value;a<r&&n.issues.push({origin:"bigint",input:a,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),a>i&&n.issues.push({origin:"bigint",input:a,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),ly=k("$ZodCheckMaxSize",(e,t)=>{var r;Le.init(e,t),(r=e._zod.def).when??(r.when=i=>{let n=i.value;return!ia(n)&&n.size!==void 0}),e._zod.onattach.push(i=>{let n=i._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<n&&(i._zod.bag.maximum=t.maximum)}),e._zod.check=i=>{let n=i.value;n.size<=t.maximum||i.issues.push({origin:fl(n),code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),uy=k("$ZodCheckMinSize",(e,t)=>{var r;Le.init(e,t),(r=e._zod.def).when??(r.when=i=>{let n=i.value;return!ia(n)&&n.size!==void 0}),e._zod.onattach.push(i=>{let n=i._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>n&&(i._zod.bag.minimum=t.minimum)}),e._zod.check=i=>{let n=i.value;n.size>=t.minimum||i.issues.push({origin:fl(n),code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),dy=k("$ZodCheckSizeEquals",(e,t)=>{var r;Le.init(e,t),(r=e._zod.def).when??(r.when=i=>{let n=i.value;return!ia(n)&&n.size!==void 0}),e._zod.onattach.push(i=>{let n=i._zod.bag;n.minimum=t.size,n.maximum=t.size,n.size=t.size}),e._zod.check=i=>{let n=i.value,a=n.size;if(a===t.size)return;let o=a>t.size;i.issues.push({origin:fl(n),...o?{code:"too_big",maximum:t.size}:{code:"too_small",minimum:t.size},inclusive:!0,exact:!0,input:i.value,inst:e,continue:!t.abort})}}),fy=k("$ZodCheckMaxLength",(e,t)=>{var r;Le.init(e,t),(r=e._zod.def).when??(r.when=i=>{let n=i.value;return!ia(n)&&n.length!==void 0}),e._zod.onattach.push(i=>{let n=i._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<n&&(i._zod.bag.maximum=t.maximum)}),e._zod.check=i=>{let n=i.value;if(n.length<=t.maximum)return;let o=pl(n);i.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),py=k("$ZodCheckMinLength",(e,t)=>{var r;Le.init(e,t),(r=e._zod.def).when??(r.when=i=>{let n=i.value;return!ia(n)&&n.length!==void 0}),e._zod.onattach.push(i=>{let n=i._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>n&&(i._zod.bag.minimum=t.minimum)}),e._zod.check=i=>{let n=i.value;if(n.length>=t.minimum)return;let o=pl(n);i.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),my=k("$ZodCheckLengthEquals",(e,t)=>{var r;Le.init(e,t),(r=e._zod.def).when??(r.when=i=>{let n=i.value;return!ia(n)&&n.length!==void 0}),e._zod.onattach.push(i=>{let n=i._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=i=>{let n=i.value,a=n.length;if(a===t.length)return;let o=pl(n),s=a>t.length;i.issues.push({origin:o,...s?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:i.value,inst:e,continue:!t.abort})}}),Es=k("$ZodCheckStringFormat",(e,t)=>{var r,i;Le.init(e,t),e._zod.onattach.push(n=>{let a=n._zod.bag;a.format=t.format,t.pattern&&(a.patterns??(a.patterns=new Set),a.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(i=e._zod).check??(i.check=()=>{})}),hy=k("$ZodCheckRegex",(e,t)=>{Es.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),gy=k("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=iy),Es.init(e,t)}),_y=k("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=ay),Es.init(e,t)}),yy=k("$ZodCheckIncludes",(e,t)=>{Le.init(e,t);let r=Vr(t.includes),i=new RegExp(typeof t.position=="number"?`^.{${t.position}}${r}`:r);t.pattern=i,e._zod.onattach.push(n=>{let a=n._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(i)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),vy=k("$ZodCheckStartsWith",(e,t)=>{Le.init(e,t);let r=new RegExp(`^${Vr(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(i=>{let n=i._zod.bag;n.patterns??(n.patterns=new Set),n.patterns.add(r)}),e._zod.check=i=>{i.value.startsWith(t.prefix)||i.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:i.value,inst:e,continue:!t.abort})}}),by=k("$ZodCheckEndsWith",(e,t)=>{Le.init(e,t);let r=new RegExp(`.*${Vr(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(i=>{let n=i._zod.bag;n.patterns??(n.patterns=new Set),n.patterns.add(r)}),e._zod.check=i=>{i.value.endsWith(t.suffix)||i.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:i.value,inst:e,continue:!t.abort})}});function iT(e,t,r){e.issues.length&&t.issues.push(...mr(r,e.issues))}var wy=k("$ZodCheckProperty",(e,t)=>{Le.init(e,t),e._zod.check=r=>{let i=t.schema._zod.run({value:r.value[t.property],issues:[]},{});if(i instanceof Promise)return i.then(n=>iT(n,r,t.property));iT(i,r,t.property)}}),xy=k("$ZodCheckMimeType",(e,t)=>{Le.init(e,t);let r=new Set(t.mime);e._zod.onattach.push(i=>{i._zod.bag.mime=t.mime}),e._zod.check=i=>{r.has(i.value.type)||i.issues.push({code:"invalid_value",values:t.mime,input:i.value.type,inst:e,continue:!t.abort})}}),Sy=k("$ZodCheckOverwrite",(e,t)=>{Le.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});var vl=class{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}let i=t.split(`
159
- `).filter(o=>o),n=Math.min(...i.map(o=>o.length-o.trimStart().length)),a=i.map(o=>o.slice(n)).map(o=>" ".repeat(this.indent*2)+o);for(let o of a)this.content.push(o)}compile(){let t=Function,r=this?.args,n=[...(this?.content??[""]).map(a=>` ${a}`)];return new t(...r,n.join(`
160
- `))}};var ky={major:4,minor:4,patch:3};var de=k("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=ky;let i=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&i.unshift(e);for(let n of i)for(let a of n._zod.onattach)a(e);if(i.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let n=(o,s,c)=>{let l=sa(o),u;for(let d of s){if(d._zod.def.when){if(E_(o)||!d._zod.def.when(o))continue}else if(l)continue;let f=o.issues.length,p=d._zod.check(o);if(p instanceof Promise&&c?.async===!1)throw new cn;if(u||p instanceof Promise)u=(u??Promise.resolve()).then(async()=>{await p,o.issues.length!==f&&(l||(l=sa(o,f)))});else{if(o.issues.length===f)continue;l||(l=sa(o,f))}}return u?u.then(()=>o):o},a=(o,s,c)=>{if(sa(o))return o.aborted=!0,o;let l=n(s,i,c);if(l instanceof Promise){if(c.async===!1)throw new cn;return l.then(u=>e._zod.parse(u,c))}return e._zod.parse(l,c)};e._zod.run=(o,s)=>{if(s.skipChecks)return e._zod.parse(o,s);if(s.direction==="backward"){let l=e._zod.parse({value:o.value,issues:[]},{...s,skipChecks:!0});return l instanceof Promise?l.then(u=>a(u,o,s)):a(l,o,s)}let c=e._zod.parse(o,s);if(c instanceof Promise){if(s.async===!1)throw new cn;return c.then(l=>n(l,i,s))}return n(c,i,s)}}xe(e,"~standard",()=>({validate:n=>{try{let a=C_(e,n);return a.success?{value:a.data}:{issues:a.error?.issues}}catch{return A_(e,n).then(o=>o.success?{value:o.data}:{issues:o.error?.issues})}},vendor:"zod",version:1}))}),uo=k("$ZodString",(e,t)=>{de.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Y_(e._zod.bag),e._zod.parse=(r,i)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),ze=k("$ZodStringFormat",(e,t)=>{Es.init(e,t),uo.init(e,t)}),Ey=k("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=D_),ze.init(e,t)}),Iy=k("$ZodUUID",(e,t)=>{if(t.version){let i={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(i===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=lo(i))}else t.pattern??(t.pattern=lo());ze.init(e,t)}),Ty=k("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=U_),ze.init(e,t)}),Cy=k("$ZodURL",(e,t)=>{ze.init(e,t),e._zod.check=r=>{try{let i=r.value.trim();if(!t.normalize&&t.protocol?.source===W_.source&&!/^https?:\/\//i.test(i)){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}let n=new URL(i);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(n.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(n.protocol.endsWith(":")?n.protocol.slice(0,-1):n.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),t.normalize?r.value=n.href:r.value=i;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),Ay=k("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=L_()),ze.init(e,t)}),Oy=k("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=j_),ze.init(e,t)}),Py=k("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=O_),ze.init(e,t)}),Ny=k("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=P_),ze.init(e,t)}),Ry=k("$ZodULID",(e,t)=>{t.pattern??(t.pattern=N_),ze.init(e,t)}),My=k("$ZodXID",(e,t)=>{t.pattern??(t.pattern=R_),ze.init(e,t)}),jy=k("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=M_),ze.init(e,t)}),zy=k("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=X_(t)),ze.init(e,t)}),Dy=k("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=K_),ze.init(e,t)}),Uy=k("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=q_(t)),ze.init(e,t)}),Ly=k("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=z_),ze.init(e,t)}),Fy=k("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=F_),ze.init(e,t),e._zod.bag.format="ipv4"}),By=k("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=B_),ze.init(e,t),e._zod.bag.format="ipv6",e._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),Vy=k("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=V_(t.delimiter)),ze.init(e,t),e._zod.bag.format="mac"}),Zy=k("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Z_),ze.init(e,t)}),Hy=k("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=H_),ze.init(e,t),e._zod.check=r=>{let i=r.value.split("/");try{if(i.length!==2)throw new Error;let[n,a]=i;if(!a)throw new Error;let o=Number(a);if(`${o}`!==a)throw new Error;if(o<0||o>128)throw new Error;new URL(`http://[${n}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function Gy(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var Wy=k("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=G_),ze.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=r=>{Gy(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function wT(e){if(!Sf.test(e))return!1;let t=e.replace(/[-_]/g,i=>i==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return Gy(r)}var Jy=k("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Sf),ze.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=r=>{wT(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),Ky=k("$ZodE164",(e,t)=>{t.pattern??(t.pattern=J_),ze.init(e,t)});function xT(e,t=null){try{let r=e.split(".");if(r.length!==3)return!1;let[i]=r;if(!i)return!1;let n=JSON.parse(atob(i));return!("typ"in n&&n?.typ!=="JWT"||!n.alg||t&&(!("alg"in n)||n.alg!==t))}catch{return!1}}var qy=k("$ZodJWT",(e,t)=>{ze.init(e,t),e._zod.check=r=>{xT(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),Xy=k("$ZodCustomStringFormat",(e,t)=>{ze.init(e,t),e._zod.check=r=>{t.fn(r.value)||r.issues.push({code:"invalid_format",format:t.format,input:r.value,inst:e,continue:!t.abort})}}),Of=k("$ZodNumber",(e,t)=>{de.init(e,t),e._zod.pattern=e._zod.bag.pattern??kf,e._zod.parse=(r,i)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}let n=r.value;if(typeof n=="number"&&!Number.isNaN(n)&&Number.isFinite(n))return r;let a=typeof n=="number"?Number.isNaN(n)?"NaN":Number.isFinite(n)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:n,inst:e,...a?{received:a}:{}}),r}}),Yy=k("$ZodNumberFormat",(e,t)=>{sy.init(e,t),Of.init(e,t)}),bl=k("$ZodBoolean",(e,t)=>{de.init(e,t),e._zod.pattern=ty,e._zod.parse=(r,i)=>{if(t.coerce)try{r.value=!!r.value}catch{}let n=r.value;return typeof n=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:n,inst:e}),r}}),Pf=k("$ZodBigInt",(e,t)=>{de.init(e,t),e._zod.pattern=Q_,e._zod.parse=(r,i)=>{if(t.coerce)try{r.value=BigInt(r.value)}catch{}return typeof r.value=="bigint"||r.issues.push({expected:"bigint",code:"invalid_type",input:r.value,inst:e}),r}}),Qy=k("$ZodBigIntFormat",(e,t)=>{cy.init(e,t),Pf.init(e,t)}),ev=k("$ZodSymbol",(e,t)=>{de.init(e,t),e._zod.parse=(r,i)=>{let n=r.value;return typeof n=="symbol"||r.issues.push({expected:"symbol",code:"invalid_type",input:n,inst:e}),r}}),tv=k("$ZodUndefined",(e,t)=>{de.init(e,t),e._zod.pattern=ny,e._zod.values=new Set([void 0]),e._zod.parse=(r,i)=>{let n=r.value;return typeof n>"u"||r.issues.push({expected:"undefined",code:"invalid_type",input:n,inst:e}),r}}),rv=k("$ZodNull",(e,t)=>{de.init(e,t),e._zod.pattern=ry,e._zod.values=new Set([null]),e._zod.parse=(r,i)=>{let n=r.value;return n===null||r.issues.push({expected:"null",code:"invalid_type",input:n,inst:e}),r}}),nv=k("$ZodAny",(e,t)=>{de.init(e,t),e._zod.parse=r=>r}),wl=k("$ZodUnknown",(e,t)=>{de.init(e,t),e._zod.parse=r=>r}),xl=k("$ZodNever",(e,t)=>{de.init(e,t),e._zod.parse=(r,i)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)}),iv=k("$ZodVoid",(e,t)=>{de.init(e,t),e._zod.parse=(r,i)=>{let n=r.value;return typeof n>"u"||r.issues.push({expected:"void",code:"invalid_type",input:n,inst:e}),r}}),av=k("$ZodDate",(e,t)=>{de.init(e,t),e._zod.parse=(r,i)=>{if(t.coerce)try{r.value=new Date(r.value)}catch{}let n=r.value,a=n instanceof Date;return a&&!Number.isNaN(n.getTime())||r.issues.push({expected:"date",code:"invalid_type",input:n,...a?{received:"Invalid Date"}:{},inst:e}),r}});function sT(e,t,r){e.issues.length&&t.issues.push(...mr(r,e.issues)),t.value[r]=e.value}var ov=k("$ZodArray",(e,t)=>{de.init(e,t),e._zod.parse=(r,i)=>{let n=r.value;if(!Array.isArray(n))return r.issues.push({expected:"array",code:"invalid_type",input:n,inst:e}),r;r.value=Array(n.length);let a=[];for(let o=0;o<n.length;o++){let s=n[o],c=t.element._zod.run({value:s,issues:[]},i);c instanceof Promise?a.push(c.then(l=>sT(l,r,o))):sT(c,r,o)}return a.length?Promise.all(a).then(()=>r):r}});function Af(e,t,r,i,n,a){let o=r in i;if(e.issues.length){if(n&&a&&!o)return;t.issues.push(...mr(r,e.issues))}if(!o&&!n){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}e.value===void 0?o&&(t.value[r]=void 0):t.value[r]=e.value}function ST(e){let t=Object.keys(e.shape);for(let i of t)if(!e.shape?.[i]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${i}": expected a Zod schema`);let r=S_(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function kT(e,t,r,i,n,a){let o=[],s=n.keySet,c=n.catchall._zod,l=c.def.type,u=c.optin==="optional",d=c.optout==="optional";for(let f in t){if(f==="__proto__"||s.has(f))continue;if(l==="never"){o.push(f);continue}let p=c.run({value:t[f],issues:[]},i);p instanceof Promise?e.push(p.then(m=>Af(m,r,f,t,u,d))):Af(p,r,f,t,u,d)}return o.length&&r.issues.push({code:"unrecognized_keys",keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>r):r}var $T=k("$ZodObject",(e,t)=>{if(de.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let s=t.shape;Object.defineProperty(t,"shape",{get:()=>{let c={...s};return Object.defineProperty(t,"shape",{value:c}),c}})}let i=bs(()=>ST(t));xe(e._zod,"propValues",()=>{let s=t.shape,c={};for(let l in s){let u=s[l]._zod;if(u.values){c[l]??(c[l]=new Set);for(let d of u.values)c[l].add(d)}}return c});let n=so,a=t.catchall,o;e._zod.parse=(s,c)=>{o??(o=i.value);let l=s.value;if(!n(l))return s.issues.push({expected:"object",code:"invalid_type",input:l,inst:e}),s;s.value={};let u=[],d=o.shape;for(let f of o.keys){let p=d[f],m=p._zod.optin==="optional",h=p._zod.optout==="optional",_=p._zod.run({value:l[f],issues:[]},c);_ instanceof Promise?u.push(_.then(b=>Af(b,s,f,l,m,h))):Af(_,s,f,l,m,h)}return a?kT(u,l,s,c,i.value,e):u.length?Promise.all(u).then(()=>s):s}}),sv=k("$ZodObjectJIT",(e,t)=>{$T.init(e,t);let r=e._zod.parse,i=bs(()=>ST(t)),n=f=>{let p=new vl(["shape","payload","ctx"]),m=i.value,h=S=>{let x=pf(S);return`shape[${x}]._zod.run({ value: input[${x}], issues: [] }, ctx)`};p.write("const input = payload.value;");let _=Object.create(null),b=0;for(let S of m.keys)_[S]=`key_${b++}`;p.write("const newResult = {};");for(let S of m.keys){let x=_[S],E=pf(S),z=f[S],C=z?._zod?.optin==="optional",v=z?._zod?.optout==="optional";p.write(`const ${x} = ${h(S)};`),C&&v?p.write(`
161
- if (${x}.issues.length) {
162
- if (${E} in input) {
163
- payload.issues = payload.issues.concat(${x}.issues.map(iss => ({
164
- ...iss,
165
- path: iss.path ? [${E}, ...iss.path] : [${E}]
166
- })));
167
- }
168
- }
169
-
170
- if (${x}.value === undefined) {
171
- if (${E} in input) {
172
- newResult[${E}] = undefined;
173
- }
174
- } else {
175
- newResult[${E}] = ${x}.value;
176
- }
177
-
178
- `):C?p.write(`
179
- if (${x}.issues.length) {
180
- payload.issues = payload.issues.concat(${x}.issues.map(iss => ({
181
- ...iss,
182
- path: iss.path ? [${E}, ...iss.path] : [${E}]
183
- })));
184
- }
185
-
186
- if (${x}.value === undefined) {
187
- if (${E} in input) {
188
- newResult[${E}] = undefined;
189
- }
190
- } else {
191
- newResult[${E}] = ${x}.value;
192
- }
193
-
194
- `):p.write(`
195
- const ${x}_present = ${E} in input;
196
- if (${x}.issues.length) {
197
- payload.issues = payload.issues.concat(${x}.issues.map(iss => ({
198
- ...iss,
199
- path: iss.path ? [${E}, ...iss.path] : [${E}]
200
- })));
201
- }
202
- if (!${x}_present && !${x}.issues.length) {
203
- payload.issues.push({
204
- code: "invalid_type",
205
- expected: "nonoptional",
206
- input: undefined,
207
- path: [${E}]
208
- });
209
- }
210
-
211
- if (${x}_present) {
212
- if (${x}.value === undefined) {
213
- newResult[${E}] = undefined;
214
- } else {
215
- newResult[${E}] = ${x}.value;
216
- }
217
- }
218
-
219
- `)}p.write("payload.value = newResult;"),p.write("return payload;");let w=p.compile();return(S,x)=>w(f,S,x)},a,o=so,s=!oo.jitless,l=s&&b_.value,u=t.catchall,d;e._zod.parse=(f,p)=>{d??(d=i.value);let m=f.value;return o(m)?s&&l&&p?.async===!1&&p.jitless!==!0?(a||(a=n(t.shape)),f=a(f,p),u?kT([],m,f,p,d,e):f):r(f,p):(f.issues.push({expected:"object",code:"invalid_type",input:m,inst:e}),f)}});function cT(e,t,r,i){for(let a of e)if(a.issues.length===0)return t.value=a.value,t;let n=e.filter(a=>!sa(a));return n.length===1?(t.value=n[0].value,n[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(a=>a.issues.map(o=>ir(o,i,it())))}),t)}var Sl=k("$ZodUnion",(e,t)=>{de.init(e,t),xe(e._zod,"optin",()=>t.options.some(i=>i._zod.optin==="optional")?"optional":void 0),xe(e._zod,"optout",()=>t.options.some(i=>i._zod.optout==="optional")?"optional":void 0),xe(e._zod,"values",()=>{if(t.options.every(i=>i._zod.values))return new Set(t.options.flatMap(i=>Array.from(i._zod.values)))}),xe(e._zod,"pattern",()=>{if(t.options.every(i=>i._zod.pattern)){let i=t.options.map(n=>n._zod.pattern);return new RegExp(`^(${i.map(n=>ul(n.source)).join("|")})$`)}});let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(i,n)=>{if(r)return r(i,n);let a=!1,o=[];for(let s of t.options){let c=s._zod.run({value:i.value,issues:[]},n);if(c instanceof Promise)o.push(c),a=!0;else{if(c.issues.length===0)return c;o.push(c)}}return a?Promise.all(o).then(s=>cT(s,i,e,n)):cT(o,i,e,n)}});function lT(e,t,r,i){let n=e.filter(a=>a.issues.length===0);return n.length===1?(t.value=n[0].value,t):(n.length===0?t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(a=>a.issues.map(o=>ir(o,i,it())))}):t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:[],inclusive:!1}),t)}var cv=k("$ZodXor",(e,t)=>{Sl.init(e,t),t.inclusive=!1;let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(i,n)=>{if(r)return r(i,n);let a=!1,o=[];for(let s of t.options){let c=s._zod.run({value:i.value,issues:[]},n);c instanceof Promise?(o.push(c),a=!0):o.push(c)}return a?Promise.all(o).then(s=>lT(s,i,e,n)):lT(o,i,e,n)}}),lv=k("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Sl.init(e,t);let r=e._zod.parse;xe(e._zod,"propValues",()=>{let n={};for(let a of t.options){let o=a._zod.propValues;if(!o||Object.keys(o).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(a)}"`);for(let[s,c]of Object.entries(o)){n[s]||(n[s]=new Set);for(let l of c)n[s].add(l)}}return n});let i=bs(()=>{let n=t.options,a=new Map;for(let o of n){let s=o._zod.propValues?.[t.discriminator];if(!s||s.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(o)}"`);for(let c of s){if(a.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);a.set(c,o)}}return a});e._zod.parse=(n,a)=>{let o=n.value;if(!so(o))return n.issues.push({code:"invalid_type",expected:"object",input:o,inst:e}),n;let s=i.value.get(o?.[t.discriminator]);return s?s._zod.run(n,a):t.unionFallback||a.direction==="backward"?r(n,a):(n.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(i.value.keys()),input:o,path:[t.discriminator],inst:e}),n)}}),uv=k("$ZodIntersection",(e,t)=>{de.init(e,t),e._zod.parse=(r,i)=>{let n=r.value,a=t.left._zod.run({value:n,issues:[]},i),o=t.right._zod.run({value:n,issues:[]},i);return a instanceof Promise||o instanceof Promise?Promise.all([a,o]).then(([c,l])=>uT(r,c,l)):uT(r,a,o)}});function $y(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(oa(e)&&oa(t)){let r=Object.keys(t),i=Object.keys(e).filter(a=>r.indexOf(a)!==-1),n={...e,...t};for(let a of i){let o=$y(e[a],t[a]);if(!o.valid)return{valid:!1,mergeErrorPath:[a,...o.mergeErrorPath]};n[a]=o.data}return{valid:!0,data:n}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let i=0;i<e.length;i++){let n=e[i],a=t[i],o=$y(n,a);if(!o.valid)return{valid:!1,mergeErrorPath:[i,...o.mergeErrorPath]};r.push(o.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function uT(e,t,r){let i=new Map,n;for(let s of t.issues)if(s.code==="unrecognized_keys"){n??(n=s);for(let c of s.keys)i.has(c)||i.set(c,{}),i.get(c).l=!0}else e.issues.push(s);for(let s of r.issues)if(s.code==="unrecognized_keys")for(let c of s.keys)i.has(c)||i.set(c,{}),i.get(c).r=!0;else e.issues.push(s);let a=[...i].filter(([,s])=>s.l&&s.r).map(([s])=>s);if(a.length&&n&&e.issues.push({...n,keys:a}),sa(e))return e;let o=$y(t.value,r.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var Nf=k("$ZodTuple",(e,t)=>{de.init(e,t);let r=t.items;e._zod.parse=(i,n)=>{let a=i.value;if(!Array.isArray(a))return i.issues.push({input:a,inst:e,expected:"tuple",code:"invalid_type"}),i;i.value=[];let o=[],s=dT(r,"optin"),c=dT(r,"optout");if(!t.rest){if(a.length<s)return i.issues.push({code:"too_small",minimum:s,inclusive:!0,input:a,inst:e,origin:"array"}),i;a.length>r.length&&i.issues.push({code:"too_big",maximum:r.length,inclusive:!0,input:a,inst:e,origin:"array"})}let l=new Array(r.length);for(let u=0;u<r.length;u++){let d=r[u]._zod.run({value:a[u],issues:[]},n);d instanceof Promise?o.push(d.then(f=>{l[u]=f})):l[u]=d}if(t.rest){let u=r.length-1,d=a.slice(r.length);for(let f of d){u++;let p=t.rest._zod.run({value:f,issues:[]},n);p instanceof Promise?o.push(p.then(m=>fT(m,i,u))):fT(p,i,u)}}return o.length?Promise.all(o).then(()=>pT(l,i,r,a,c)):pT(l,i,r,a,c)}});function dT(e,t){for(let r=e.length-1;r>=0;r--)if(e[r]._zod[t]!=="optional")return r+1;return 0}function fT(e,t,r){e.issues.length&&t.issues.push(...mr(r,e.issues)),t.value[r]=e.value}function pT(e,t,r,i,n){for(let a=0;a<r.length;a++){let o=e[a],s=a<i.length;if(o.issues.length){if(!s&&a>=n){t.value.length=a;break}t.issues.push(...mr(a,o.issues))}t.value[a]=o.value}for(let a=t.value.length-1;a>=i.length&&(r[a]._zod.optout==="optional"&&t.value[a]===void 0);a--)t.value.length=a;return t}var dv=k("$ZodRecord",(e,t)=>{de.init(e,t),e._zod.parse=(r,i)=>{let n=r.value;if(!oa(n))return r.issues.push({expected:"record",code:"invalid_type",input:n,inst:e}),r;let a=[],o=t.keyType._zod.values;if(o){r.value={};let s=new Set;for(let l of o)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){s.add(typeof l=="number"?l.toString():l);let u=t.keyType._zod.run({value:l,issues:[]},i);if(u instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(u.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:u.issues.map(p=>ir(p,i,it())),input:l,path:[l],inst:e});continue}let d=u.value,f=t.valueType._zod.run({value:n[l],issues:[]},i);f instanceof Promise?a.push(f.then(p=>{p.issues.length&&r.issues.push(...mr(l,p.issues)),r.value[d]=p.value})):(f.issues.length&&r.issues.push(...mr(l,f.issues)),r.value[d]=f.value)}let c;for(let l in n)s.has(l)||(c=c??[],c.push(l));c&&c.length>0&&r.issues.push({code:"unrecognized_keys",input:n,inst:e,keys:c})}else{r.value={};for(let s of Reflect.ownKeys(n)){if(s==="__proto__"||!Object.prototype.propertyIsEnumerable.call(n,s))continue;let c=t.keyType._zod.run({value:s,issues:[]},i);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof s=="string"&&kf.test(s)&&c.issues.length){let d=t.keyType._zod.run({value:Number(s),issues:[]},i);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");d.issues.length===0&&(c=d)}if(c.issues.length){t.mode==="loose"?r.value[s]=n[s]:r.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(d=>ir(d,i,it())),input:s,path:[s],inst:e});continue}let u=t.valueType._zod.run({value:n[s],issues:[]},i);u instanceof Promise?a.push(u.then(d=>{d.issues.length&&r.issues.push(...mr(s,d.issues)),r.value[c.value]=d.value})):(u.issues.length&&r.issues.push(...mr(s,u.issues)),r.value[c.value]=u.value)}}return a.length?Promise.all(a).then(()=>r):r}}),fv=k("$ZodMap",(e,t)=>{de.init(e,t),e._zod.parse=(r,i)=>{let n=r.value;if(!(n instanceof Map))return r.issues.push({expected:"map",code:"invalid_type",input:n,inst:e}),r;let a=[];r.value=new Map;for(let[o,s]of n){let c=t.keyType._zod.run({value:o,issues:[]},i),l=t.valueType._zod.run({value:s,issues:[]},i);c instanceof Promise||l instanceof Promise?a.push(Promise.all([c,l]).then(([u,d])=>{mT(u,d,r,o,n,e,i)})):mT(c,l,r,o,n,e,i)}return a.length?Promise.all(a).then(()=>r):r}});function mT(e,t,r,i,n,a,o){e.issues.length&&(dl.has(typeof i)?r.issues.push(...mr(i,e.issues)):r.issues.push({code:"invalid_key",origin:"map",input:n,inst:a,issues:e.issues.map(s=>ir(s,o,it()))})),t.issues.length&&(dl.has(typeof i)?r.issues.push(...mr(i,t.issues)):r.issues.push({origin:"map",code:"invalid_element",input:n,inst:a,key:i,issues:t.issues.map(s=>ir(s,o,it()))})),r.value.set(e.value,t.value)}var pv=k("$ZodSet",(e,t)=>{de.init(e,t),e._zod.parse=(r,i)=>{let n=r.value;if(!(n instanceof Set))return r.issues.push({input:n,inst:e,expected:"set",code:"invalid_type"}),r;let a=[];r.value=new Set;for(let o of n){let s=t.valueType._zod.run({value:o,issues:[]},i);s instanceof Promise?a.push(s.then(c=>hT(c,r))):hT(s,r)}return a.length?Promise.all(a).then(()=>r):r}});function hT(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}var mv=k("$ZodEnum",(e,t)=>{de.init(e,t);let r=ll(t.entries),i=new Set(r);e._zod.values=i,e._zod.pattern=new RegExp(`^(${r.filter(n=>dl.has(typeof n)).map(n=>typeof n=="string"?Vr(n):n.toString()).join("|")})$`),e._zod.parse=(n,a)=>{let o=n.value;return i.has(o)||n.issues.push({code:"invalid_value",values:r,input:o,inst:e}),n}}),hv=k("$ZodLiteral",(e,t)=>{if(de.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");let r=new Set(t.values);e._zod.values=r,e._zod.pattern=new RegExp(`^(${t.values.map(i=>typeof i=="string"?Vr(i):i?Vr(i.toString()):String(i)).join("|")})$`),e._zod.parse=(i,n)=>{let a=i.value;return r.has(a)||i.issues.push({code:"invalid_value",values:t.values,input:a,inst:e}),i}}),gv=k("$ZodFile",(e,t)=>{de.init(e,t),e._zod.parse=(r,i)=>{let n=r.value;return n instanceof File||r.issues.push({expected:"file",code:"invalid_type",input:n,inst:e}),r}}),_v=k("$ZodTransform",(e,t)=>{de.init(e,t),e._zod.optin="optional",e._zod.parse=(r,i)=>{if(i.direction==="backward")throw new na(e.constructor.name);let n=t.transform(r.value,r);if(i.async)return(n instanceof Promise?n:Promise.resolve(n)).then(o=>(r.value=o,r.fallback=!0,r));if(n instanceof Promise)throw new cn;return r.value=n,r.fallback=!0,r}});function gT(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var fo=k("$ZodOptional",(e,t)=>{de.init(e,t),e._zod.optin="optional",e._zod.optout="optional",xe(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),xe(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${ul(r.source)})?$`):void 0}),e._zod.parse=(r,i)=>{if(t.innerType._zod.optin==="optional"){let n=r.value,a=t.innerType._zod.run(r,i);return a instanceof Promise?a.then(o=>gT(o,n)):gT(a,n)}return r.value===void 0?r:t.innerType._zod.run(r,i)}}),yv=k("$ZodExactOptional",(e,t)=>{fo.init(e,t),xe(e._zod,"values",()=>t.innerType._zod.values),xe(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(r,i)=>t.innerType._zod.run(r,i)}),vv=k("$ZodNullable",(e,t)=>{de.init(e,t),xe(e._zod,"optin",()=>t.innerType._zod.optin),xe(e._zod,"optout",()=>t.innerType._zod.optout),xe(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${ul(r.source)}|null)$`):void 0}),xe(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,i)=>r.value===null?r:t.innerType._zod.run(r,i)}),bv=k("$ZodDefault",(e,t)=>{de.init(e,t),e._zod.optin="optional",xe(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,i)=>{if(i.direction==="backward")return t.innerType._zod.run(r,i);if(r.value===void 0)return r.value=t.defaultValue,r;let n=t.innerType._zod.run(r,i);return n instanceof Promise?n.then(a=>_T(a,t)):_T(n,t)}});function _T(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var wv=k("$ZodPrefault",(e,t)=>{de.init(e,t),e._zod.optin="optional",xe(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,i)=>(i.direction==="backward"||r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,i))}),xv=k("$ZodNonOptional",(e,t)=>{de.init(e,t),xe(e._zod,"values",()=>{let r=t.innerType._zod.values;return r?new Set([...r].filter(i=>i!==void 0)):void 0}),e._zod.parse=(r,i)=>{let n=t.innerType._zod.run(r,i);return n instanceof Promise?n.then(a=>yT(a,e)):yT(n,e)}});function yT(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}var Sv=k("$ZodSuccess",(e,t)=>{de.init(e,t),e._zod.parse=(r,i)=>{if(i.direction==="backward")throw new na("ZodSuccess");let n=t.innerType._zod.run(r,i);return n instanceof Promise?n.then(a=>(r.value=a.issues.length===0,r)):(r.value=n.issues.length===0,r)}}),kv=k("$ZodCatch",(e,t)=>{de.init(e,t),e._zod.optin="optional",xe(e._zod,"optout",()=>t.innerType._zod.optout),xe(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,i)=>{if(i.direction==="backward")return t.innerType._zod.run(r,i);let n=t.innerType._zod.run(r,i);return n instanceof Promise?n.then(a=>(r.value=a.value,a.issues.length&&(r.value=t.catchValue({...r,error:{issues:a.issues.map(o=>ir(o,i,it()))},input:r.value}),r.issues=[],r.fallback=!0),r)):(r.value=n.value,n.issues.length&&(r.value=t.catchValue({...r,error:{issues:n.issues.map(a=>ir(a,i,it()))},input:r.value}),r.issues=[],r.fallback=!0),r)}}),$v=k("$ZodNaN",(e,t)=>{de.init(e,t),e._zod.parse=(r,i)=>((typeof r.value!="number"||!Number.isNaN(r.value))&&r.issues.push({input:r.value,inst:e,expected:"nan",code:"invalid_type"}),r)}),Rf=k("$ZodPipe",(e,t)=>{de.init(e,t),xe(e._zod,"values",()=>t.in._zod.values),xe(e._zod,"optin",()=>t.in._zod.optin),xe(e._zod,"optout",()=>t.out._zod.optout),xe(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,i)=>{if(i.direction==="backward"){let a=t.out._zod.run(r,i);return a instanceof Promise?a.then(o=>If(o,t.in,i)):If(a,t.in,i)}let n=t.in._zod.run(r,i);return n instanceof Promise?n.then(a=>If(a,t.out,i)):If(n,t.out,i)}});function If(e,t,r){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},r)}var kl=k("$ZodCodec",(e,t)=>{de.init(e,t),xe(e._zod,"values",()=>t.in._zod.values),xe(e._zod,"optin",()=>t.in._zod.optin),xe(e._zod,"optout",()=>t.out._zod.optout),xe(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,i)=>{if((i.direction||"forward")==="forward"){let a=t.in._zod.run(r,i);return a instanceof Promise?a.then(o=>Tf(o,t,i)):Tf(a,t,i)}else{let a=t.out._zod.run(r,i);return a instanceof Promise?a.then(o=>Tf(o,t,i)):Tf(a,t,i)}}});function Tf(e,t,r){if(e.issues.length)return e.aborted=!0,e;if((r.direction||"forward")==="forward"){let n=t.transform(e.value,e);return n instanceof Promise?n.then(a=>Cf(e,a,t.out,r)):Cf(e,n,t.out,r)}else{let n=t.reverseTransform(e.value,e);return n instanceof Promise?n.then(a=>Cf(e,a,t.in,r)):Cf(e,n,t.in,r)}}function Cf(e,t,r,i){return e.issues.length?(e.aborted=!0,e):r._zod.run({value:t,issues:e.issues},i)}var Ev=k("$ZodPreprocess",(e,t)=>{Rf.init(e,t)}),Iv=k("$ZodReadonly",(e,t)=>{de.init(e,t),xe(e._zod,"propValues",()=>t.innerType._zod.propValues),xe(e._zod,"values",()=>t.innerType._zod.values),xe(e._zod,"optin",()=>t.innerType?._zod?.optin),xe(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(r,i)=>{if(i.direction==="backward")return t.innerType._zod.run(r,i);let n=t.innerType._zod.run(r,i);return n instanceof Promise?n.then(vT):vT(n)}});function vT(e){return e.value=Object.freeze(e.value),e}var Tv=k("$ZodTemplateLiteral",(e,t)=>{de.init(e,t);let r=[];for(let i of t.parts)if(typeof i=="object"&&i!==null){if(!i._zod.pattern)throw new Error(`Invalid template literal part, no pattern found: ${[...i._zod.traits].shift()}`);let n=i._zod.pattern instanceof RegExp?i._zod.pattern.source:i._zod.pattern;if(!n)throw new Error(`Invalid template literal part: ${i._zod.traits}`);let a=n.startsWith("^")?1:0,o=n.endsWith("$")?n.length-1:n.length;r.push(n.slice(a,o))}else if(i===null||x_.has(typeof i))r.push(Vr(`${i}`));else throw new Error(`Invalid template literal part: ${i}`);e._zod.pattern=new RegExp(`^${r.join("")}$`),e._zod.parse=(i,n)=>typeof i.value!="string"?(i.issues.push({input:i.value,inst:e,expected:"string",code:"invalid_type"}),i):(e._zod.pattern.lastIndex=0,e._zod.pattern.test(i.value)||i.issues.push({input:i.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source}),i)}),Cv=k("$ZodFunction",(e,t)=>(de.init(e,t),e._def=t,e._zod.def=t,e.implement=r=>{if(typeof r!="function")throw new Error("implement() must be called with a function");return function(...i){let n=e._def.input?ca(e._def.input,i):i,a=Reflect.apply(r,this,n);return e._def.output?ca(e._def.output,a):a}},e.implementAsync=r=>{if(typeof r!="function")throw new Error("implementAsync() must be called with a function");return async function(...i){let n=e._def.input?await co(e._def.input,i):i,a=await Reflect.apply(r,this,n);return e._def.output?await co(e._def.output,a):a}},e._zod.parse=(r,i)=>typeof r.value!="function"?(r.issues.push({code:"invalid_type",expected:"function",input:r.value,inst:e}),r):(e._def.output&&e._def.output._zod.def.type==="promise"?r.value=e.implementAsync(r.value):r.value=e.implement(r.value),r),e.input=(...r)=>{let i=e.constructor;return Array.isArray(r[0])?new i({type:"function",input:new Nf({type:"tuple",items:r[0],rest:r[1]}),output:e._def.output}):new i({type:"function",input:r[0],output:e._def.output})},e.output=r=>{let i=e.constructor;return new i({type:"function",input:e._def.input,output:r})},e)),Av=k("$ZodPromise",(e,t)=>{de.init(e,t),e._zod.parse=(r,i)=>Promise.resolve(r.value).then(n=>t.innerType._zod.run({value:n,issues:[]},i))}),Ov=k("$ZodLazy",(e,t)=>{de.init(e,t),xe(e._zod,"innerType",()=>{let r=t;return r._cachedInner||(r._cachedInner=t.getter()),r._cachedInner}),xe(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),xe(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),xe(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),xe(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(r,i)=>e._zod.innerType._zod.run(r,i)}),Pv=k("$ZodCustom",(e,t)=>{Le.init(e,t),de.init(e,t),e._zod.parse=(r,i)=>r,e._zod.check=r=>{let i=r.value,n=t.fn(i);if(n instanceof Promise)return n.then(a=>bT(a,r,i,e));bT(n,r,i,e)}});function bT(e,t,r,i){if(!e){let n={code:"custom",input:r,inst:i,path:[...i._zod.def.path??[]],continue:!i._zod.def.abort};i._zod.def.params&&(n.params=i._zod.def.params),t.issues.push(ws(n))}}var El={};Tn(El,{ar:()=>ET,az:()=>IT,be:()=>CT,bg:()=>AT,ca:()=>OT,cs:()=>PT,da:()=>NT,de:()=>RT,el:()=>MT,en:()=>Mf,eo:()=>jT,es:()=>zT,fa:()=>DT,fi:()=>UT,fr:()=>LT,frCA:()=>FT,he:()=>BT,hr:()=>VT,hu:()=>ZT,hy:()=>GT,id:()=>WT,is:()=>JT,it:()=>KT,ja:()=>qT,ka:()=>XT,kh:()=>YT,km:()=>jf,ko:()=>QT,lt:()=>tC,mk:()=>rC,ms:()=>nC,nl:()=>iC,no:()=>aC,ota:()=>oC,pl:()=>cC,ps:()=>sC,pt:()=>lC,ro:()=>uC,ru:()=>fC,sl:()=>pC,sv:()=>mC,ta:()=>hC,th:()=>gC,tr:()=>_C,ua:()=>yC,uk:()=>zf,ur:()=>vC,uz:()=>bC,vi:()=>wC,yo:()=>kC,zhCN:()=>xC,zhTW:()=>SC});var SU=()=>{let e={string:{unit:"\u062D\u0631\u0641",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},file:{unit:"\u0628\u0627\u064A\u062A",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},array:{unit:"\u0639\u0646\u0635\u0631",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},set:{unit:"\u0639\u0646\u0635\u0631",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"}};function t(n){return e[n]??null}let r={regex:"\u0645\u062F\u062E\u0644",email:"\u0628\u0631\u064A\u062F \u0625\u0644\u0643\u062A\u0631\u0648\u0646\u064A",url:"\u0631\u0627\u0628\u0637",emoji:"\u0625\u064A\u0645\u0648\u062C\u064A",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u062A\u0627\u0631\u064A\u062E \u0648\u0648\u0642\u062A \u0628\u0645\u0639\u064A\u0627\u0631 ISO",date:"\u062A\u0627\u0631\u064A\u062E \u0628\u0645\u0639\u064A\u0627\u0631 ISO",time:"\u0648\u0642\u062A \u0628\u0645\u0639\u064A\u0627\u0631 ISO",duration:"\u0645\u062F\u0629 \u0628\u0645\u0639\u064A\u0627\u0631 ISO",ipv4:"\u0639\u0646\u0648\u0627\u0646 IPv4",ipv6:"\u0639\u0646\u0648\u0627\u0646 IPv6",cidrv4:"\u0645\u062F\u0649 \u0639\u0646\u0627\u0648\u064A\u0646 \u0628\u0635\u064A\u063A\u0629 IPv4",cidrv6:"\u0645\u062F\u0649 \u0639\u0646\u0627\u0648\u064A\u0646 \u0628\u0635\u064A\u063A\u0629 IPv6",base64:"\u0646\u064E\u0635 \u0628\u062A\u0631\u0645\u064A\u0632 base64-encoded",base64url:"\u0646\u064E\u0635 \u0628\u062A\u0631\u0645\u064A\u0632 base64url-encoded",json_string:"\u0646\u064E\u0635 \u0639\u0644\u0649 \u0647\u064A\u0626\u0629 JSON",e164:"\u0631\u0642\u0645 \u0647\u0627\u062A\u0641 \u0628\u0645\u0639\u064A\u0627\u0631 E.164",jwt:"JWT",template_literal:"\u0645\u062F\u062E\u0644"},i={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\u0645\u062F\u062E\u0644\u0627\u062A \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644\u0629: \u064A\u0641\u062A\u0631\u0636 \u0625\u062F\u062E\u0627\u0644 instanceof ${n.expected}\u060C \u0648\u0644\u0643\u0646 \u062A\u0645 \u0625\u062F\u062E\u0627\u0644 ${s}`:`\u0645\u062F\u062E\u0644\u0627\u062A \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644\u0629: \u064A\u0641\u062A\u0631\u0636 \u0625\u062F\u062E\u0627\u0644 ${a}\u060C \u0648\u0644\u0643\u0646 \u062A\u0645 \u0625\u062F\u062E\u0627\u0644 ${s}`}case"invalid_value":return n.values.length===1?`\u0645\u062F\u062E\u0644\u0627\u062A \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644\u0629: \u064A\u0641\u062A\u0631\u0636 \u0625\u062F\u062E\u0627\u0644 ${R(n.values[0])}`:`\u0627\u062E\u062A\u064A\u0627\u0631 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062A\u0648\u0642\u0639 \u0627\u0646\u062A\u0642\u0627\u0621 \u0623\u062D\u062F \u0647\u0630\u0647 \u0627\u0644\u062E\u064A\u0627\u0631\u0627\u062A: ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?` \u0623\u0643\u0628\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0623\u0646 \u062A\u0643\u0648\u0646 ${n.origin??"\u0627\u0644\u0642\u064A\u0645\u0629"} ${a} ${n.maximum.toString()} ${o.unit??"\u0639\u0646\u0635\u0631"}`:`\u0623\u0643\u0628\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0623\u0646 \u062A\u0643\u0648\u0646 ${n.origin??"\u0627\u0644\u0642\u064A\u0645\u0629"} ${a} ${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`\u0623\u0635\u063A\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0644\u0640 ${n.origin} \u0623\u0646 \u064A\u0643\u0648\u0646 ${a} ${n.minimum.toString()} ${o.unit}`:`\u0623\u0635\u063A\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0644\u0640 ${n.origin} \u0623\u0646 \u064A\u0643\u0648\u0646 ${a} ${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0628\u062F\u0623 \u0628\u0640 "${n.prefix}"`:a.format==="ends_with"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0646\u062A\u0647\u064A \u0628\u0640 "${a.suffix}"`:a.format==="includes"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u062A\u0636\u0645\u0651\u064E\u0646 "${a.includes}"`:a.format==="regex"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0637\u0627\u0628\u0642 \u0627\u0644\u0646\u0645\u0637 ${a.pattern}`:`${r[a.format]??n.format} \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644`}case"not_multiple_of":return`\u0631\u0642\u0645 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0645\u0646 \u0645\u0636\u0627\u0639\u0641\u0627\u062A ${n.divisor}`;case"unrecognized_keys":return`\u0645\u0639\u0631\u0641${n.keys.length>1?"\u0627\u062A":""} \u063A\u0631\u064A\u0628${n.keys.length>1?"\u0629":""}: ${I(n.keys,"\u060C ")}`;case"invalid_key":return`\u0645\u0639\u0631\u0641 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644 \u0641\u064A ${n.origin}`;case"invalid_union":return"\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644";case"invalid_element":return`\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644 \u0641\u064A ${n.origin}`;default:return"\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644"}}};function ET(){return{localeError:SU()}}var kU=()=>{let e={string:{unit:"simvol",verb:"olmal\u0131d\u0131r"},file:{unit:"bayt",verb:"olmal\u0131d\u0131r"},array:{unit:"element",verb:"olmal\u0131d\u0131r"},set:{unit:"element",verb:"olmal\u0131d\u0131r"}};function t(n){return e[n]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},i={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n instanceof ${n.expected}, daxil olan ${s}`:`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n ${a}, daxil olan ${s}`}case"invalid_value":return n.values.length===1?`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n ${R(n.values[0])}`:`Yanl\u0131\u015F se\xE7im: a\u015Fa\u011F\u0131dak\u0131lardan biri olmal\u0131d\u0131r: ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`\xC7ox b\xF6y\xFCk: g\xF6zl\u0259nil\u0259n ${n.origin??"d\u0259y\u0259r"} ${a}${n.maximum.toString()} ${o.unit??"element"}`:`\xC7ox b\xF6y\xFCk: g\xF6zl\u0259nil\u0259n ${n.origin??"d\u0259y\u0259r"} ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`\xC7ox ki\xE7ik: g\xF6zl\u0259nil\u0259n ${n.origin} ${a}${n.minimum.toString()} ${o.unit}`:`\xC7ox ki\xE7ik: g\xF6zl\u0259nil\u0259n ${n.origin} ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Yanl\u0131\u015F m\u0259tn: "${a.prefix}" il\u0259 ba\u015Flamal\u0131d\u0131r`:a.format==="ends_with"?`Yanl\u0131\u015F m\u0259tn: "${a.suffix}" il\u0259 bitm\u0259lidir`:a.format==="includes"?`Yanl\u0131\u015F m\u0259tn: "${a.includes}" daxil olmal\u0131d\u0131r`:a.format==="regex"?`Yanl\u0131\u015F m\u0259tn: ${a.pattern} \u015Fablonuna uy\u011Fun olmal\u0131d\u0131r`:`Yanl\u0131\u015F ${r[a.format]??n.format}`}case"not_multiple_of":return`Yanl\u0131\u015F \u0259d\u0259d: ${n.divisor} il\u0259 b\xF6l\xFCn\u0259 bil\u0259n olmal\u0131d\u0131r`;case"unrecognized_keys":return`Tan\u0131nmayan a\xE7ar${n.keys.length>1?"lar":""}: ${I(n.keys,", ")}`;case"invalid_key":return`${n.origin} daxilind\u0259 yanl\u0131\u015F a\xE7ar`;case"invalid_union":return"Yanl\u0131\u015F d\u0259y\u0259r";case"invalid_element":return`${n.origin} daxilind\u0259 yanl\u0131\u015F d\u0259y\u0259r`;default:return"Yanl\u0131\u015F d\u0259y\u0259r"}}};function IT(){return{localeError:kU()}}function TT(e,t,r,i){let n=Math.abs(e),a=n%10,o=n%100;return o>=11&&o<=19?i:a===1?t:a>=2&&a<=4?r:i}var $U=()=>{let e={string:{unit:{one:"\u0441\u0456\u043C\u0432\u0430\u043B",few:"\u0441\u0456\u043C\u0432\u0430\u043B\u044B",many:"\u0441\u0456\u043C\u0432\u0430\u043B\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},array:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u044B",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},set:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u044B",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},file:{unit:{one:"\u0431\u0430\u0439\u0442",few:"\u0431\u0430\u0439\u0442\u044B",many:"\u0431\u0430\u0439\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"}};function t(n){return e[n]??null}let r={regex:"\u0443\u0432\u043E\u0434",email:"email \u0430\u0434\u0440\u0430\u0441",url:"URL",emoji:"\u044D\u043C\u043E\u0434\u0437\u0456",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0430 \u0456 \u0447\u0430\u0441",date:"ISO \u0434\u0430\u0442\u0430",time:"ISO \u0447\u0430\u0441",duration:"ISO \u043F\u0440\u0430\u0446\u044F\u0433\u043B\u0430\u0441\u0446\u044C",ipv4:"IPv4 \u0430\u0434\u0440\u0430\u0441",ipv6:"IPv6 \u0430\u0434\u0440\u0430\u0441",cidrv4:"IPv4 \u0434\u044B\u044F\u043F\u0430\u0437\u043E\u043D",cidrv6:"IPv6 \u0434\u044B\u044F\u043F\u0430\u0437\u043E\u043D",base64:"\u0440\u0430\u0434\u043E\u043A \u0443 \u0444\u0430\u0440\u043C\u0430\u0446\u0435 base64",base64url:"\u0440\u0430\u0434\u043E\u043A \u0443 \u0444\u0430\u0440\u043C\u0430\u0446\u0435 base64url",json_string:"JSON \u0440\u0430\u0434\u043E\u043A",e164:"\u043D\u0443\u043C\u0430\u0440 E.164",jwt:"JWT",template_literal:"\u0443\u0432\u043E\u0434"},i={nan:"NaN",number:"\u043B\u0456\u043A",array:"\u043C\u0430\u0441\u0456\u045E"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u045E\u0441\u044F instanceof ${n.expected}, \u0430\u0442\u0440\u044B\u043C\u0430\u043D\u0430 ${s}`:`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u045E\u0441\u044F ${a}, \u0430\u0442\u0440\u044B\u043C\u0430\u043D\u0430 ${s}`}case"invalid_value":return n.values.length===1?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F ${R(n.values[0])}`:`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0432\u0430\u0440\u044B\u044F\u043D\u0442: \u0447\u0430\u043A\u0430\u045E\u0441\u044F \u0430\u0434\u0437\u0456\u043D \u0437 ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);if(o){let s=Number(n.maximum),c=TT(s,o.unit.one,o.unit.few,o.unit.many);return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u0432\u044F\u043B\u0456\u043A\u0456: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${n.origin??"\u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435"} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 ${o.verb} ${a}${n.maximum.toString()} ${c}`}return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u0432\u044F\u043B\u0456\u043A\u0456: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${n.origin??"\u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435"} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 \u0431\u044B\u0446\u044C ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);if(o){let s=Number(n.minimum),c=TT(s,o.unit.one,o.unit.few,o.unit.many);return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u043C\u0430\u043B\u044B: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${n.origin} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 ${o.verb} ${a}${n.minimum.toString()} ${c}`}return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u043C\u0430\u043B\u044B: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${n.origin} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 \u0431\u044B\u0446\u044C ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u043F\u0430\u0447\u044B\u043D\u0430\u0446\u0446\u0430 \u0437 "${a.prefix}"`:a.format==="ends_with"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0437\u0430\u043A\u0430\u043D\u0447\u0432\u0430\u0446\u0446\u0430 \u043D\u0430 "${a.suffix}"`:a.format==="includes"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0437\u043C\u044F\u0448\u0447\u0430\u0446\u044C "${a.includes}"`:a.format==="regex"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0430\u0434\u043F\u0430\u0432\u044F\u0434\u0430\u0446\u044C \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${a.pattern}`:`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B ${r[a.format]??n.format}`}case"not_multiple_of":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u043B\u0456\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0431\u044B\u0446\u044C \u043A\u0440\u0430\u0442\u043D\u044B\u043C ${n.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0441\u043F\u0430\u0437\u043D\u0430\u043D\u044B ${n.keys.length>1?"\u043A\u043B\u044E\u0447\u044B":"\u043A\u043B\u044E\u0447"}: ${I(n.keys,", ")}`;case"invalid_key":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u043A\u043B\u044E\u0447 \u0443 ${n.origin}`;case"invalid_union":return"\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434";case"invalid_element":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u0430\u0435 \u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435 \u045E ${n.origin}`;default:return"\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434"}}};function CT(){return{localeError:$U()}}var EU=()=>{let e={string:{unit:"\u0441\u0438\u043C\u0432\u043E\u043B\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"},file:{unit:"\u0431\u0430\u0439\u0442\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"},array:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"},set:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"}};function t(n){return e[n]??null}let r={regex:"\u0432\u0445\u043E\u0434",email:"\u0438\u043C\u0435\u0439\u043B \u0430\u0434\u0440\u0435\u0441",url:"URL",emoji:"\u0435\u043C\u043E\u0434\u0436\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0432\u0440\u0435\u043C\u0435",date:"ISO \u0434\u0430\u0442\u0430",time:"ISO \u0432\u0440\u0435\u043C\u0435",duration:"ISO \u043F\u0440\u043E\u0434\u044A\u043B\u0436\u0438\u0442\u0435\u043B\u043D\u043E\u0441\u0442",ipv4:"IPv4 \u0430\u0434\u0440\u0435\u0441",ipv6:"IPv6 \u0430\u0434\u0440\u0435\u0441",cidrv4:"IPv4 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",cidrv6:"IPv6 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",base64:"base64-\u043A\u043E\u0434\u0438\u0440\u0430\u043D \u043D\u0438\u0437",base64url:"base64url-\u043A\u043E\u0434\u0438\u0440\u0430\u043D \u043D\u0438\u0437",json_string:"JSON \u043D\u0438\u0437",e164:"E.164 \u043D\u043E\u043C\u0435\u0440",jwt:"JWT",template_literal:"\u0432\u0445\u043E\u0434"},i={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0438\u0432"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434: \u043E\u0447\u0430\u043A\u0432\u0430\u043D instanceof ${n.expected}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D ${s}`:`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434: \u043E\u0447\u0430\u043A\u0432\u0430\u043D ${a}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D ${s}`}case"invalid_value":return n.values.length===1?`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434: \u043E\u0447\u0430\u043A\u0432\u0430\u043D ${R(n.values[0])}`:`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430 \u043E\u043F\u0446\u0438\u044F: \u043E\u0447\u0430\u043A\u0432\u0430\u043D\u043E \u0435\u0434\u043D\u043E \u043E\u0442 ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`\u0422\u0432\u044A\u0440\u0434\u0435 \u0433\u043E\u043B\u044F\u043C\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${n.origin??"\u0441\u0442\u043E\u0439\u043D\u043E\u0441\u0442"} \u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430 ${a}${n.maximum.toString()} ${o.unit??"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0430"}`:`\u0422\u0432\u044A\u0440\u0434\u0435 \u0433\u043E\u043B\u044F\u043C\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${n.origin??"\u0441\u0442\u043E\u0439\u043D\u043E\u0441\u0442"} \u0434\u0430 \u0431\u044A\u0434\u0435 ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`\u0422\u0432\u044A\u0440\u0434\u0435 \u043C\u0430\u043B\u043A\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${n.origin} \u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430 ${a}${n.minimum.toString()} ${o.unit}`:`\u0422\u0432\u044A\u0440\u0434\u0435 \u043C\u0430\u043B\u043A\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${n.origin} \u0434\u0430 \u0431\u044A\u0434\u0435 ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;if(a.format==="starts_with")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0437\u0430\u043F\u043E\u0447\u0432\u0430 \u0441 "${a.prefix}"`;if(a.format==="ends_with")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0437\u0430\u0432\u044A\u0440\u0448\u0432\u0430 \u0441 "${a.suffix}"`;if(a.format==="includes")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0432\u043A\u043B\u044E\u0447\u0432\u0430 "${a.includes}"`;if(a.format==="regex")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0441\u044A\u0432\u043F\u0430\u0434\u0430 \u0441 ${a.pattern}`;let o="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D";return a.format==="emoji"&&(o="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E"),a.format==="datetime"&&(o="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E"),a.format==="date"&&(o="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430"),a.format==="time"&&(o="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E"),a.format==="duration"&&(o="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430"),`${o} ${r[a.format]??n.format}`}case"not_multiple_of":return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E \u0447\u0438\u0441\u043B\u043E: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0431\u044A\u0434\u0435 \u043A\u0440\u0430\u0442\u043D\u043E \u043D\u0430 ${n.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0437\u043F\u043E\u0437\u043D\u0430\u0442${n.keys.length>1?"\u0438":""} \u043A\u043B\u044E\u0447${n.keys.length>1?"\u043E\u0432\u0435":""}: ${I(n.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043A\u043B\u044E\u0447 \u0432 ${n.origin}`;case"invalid_union":return"\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434";case"invalid_element":return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430 \u0441\u0442\u043E\u0439\u043D\u043E\u0441\u0442 \u0432 ${n.origin}`;default:return"\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434"}}};function AT(){return{localeError:EU()}}var IU=()=>{let e={string:{unit:"car\xE0cters",verb:"contenir"},file:{unit:"bytes",verb:"contenir"},array:{unit:"elements",verb:"contenir"},set:{unit:"elements",verb:"contenir"}};function t(n){return e[n]??null}let r={regex:"entrada",email:"adre\xE7a electr\xF2nica",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data i hora ISO",date:"data ISO",time:"hora ISO",duration:"durada ISO",ipv4:"adre\xE7a IPv4",ipv6:"adre\xE7a IPv6",cidrv4:"rang IPv4",cidrv6:"rang IPv6",base64:"cadena codificada en base64",base64url:"cadena codificada en base64url",json_string:"cadena JSON",e164:"n\xFAmero E.164",jwt:"JWT",template_literal:"entrada"},i={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Tipus inv\xE0lid: s'esperava instanceof ${n.expected}, s'ha rebut ${s}`:`Tipus inv\xE0lid: s'esperava ${a}, s'ha rebut ${s}`}case"invalid_value":return n.values.length===1?`Valor inv\xE0lid: s'esperava ${R(n.values[0])}`:`Opci\xF3 inv\xE0lida: s'esperava una de ${I(n.values," o ")}`;case"too_big":{let a=n.inclusive?"com a m\xE0xim":"menys de",o=t(n.origin);return o?`Massa gran: s'esperava que ${n.origin??"el valor"} contingu\xE9s ${a} ${n.maximum.toString()} ${o.unit??"elements"}`:`Massa gran: s'esperava que ${n.origin??"el valor"} fos ${a} ${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?"com a m\xEDnim":"m\xE9s de",o=t(n.origin);return o?`Massa petit: s'esperava que ${n.origin} contingu\xE9s ${a} ${n.minimum.toString()} ${o.unit}`:`Massa petit: s'esperava que ${n.origin} fos ${a} ${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Format inv\xE0lid: ha de comen\xE7ar amb "${a.prefix}"`:a.format==="ends_with"?`Format inv\xE0lid: ha d'acabar amb "${a.suffix}"`:a.format==="includes"?`Format inv\xE0lid: ha d'incloure "${a.includes}"`:a.format==="regex"?`Format inv\xE0lid: ha de coincidir amb el patr\xF3 ${a.pattern}`:`Format inv\xE0lid per a ${r[a.format]??n.format}`}case"not_multiple_of":return`N\xFAmero inv\xE0lid: ha de ser m\xFAltiple de ${n.divisor}`;case"unrecognized_keys":return`Clau${n.keys.length>1?"s":""} no reconeguda${n.keys.length>1?"s":""}: ${I(n.keys,", ")}`;case"invalid_key":return`Clau inv\xE0lida a ${n.origin}`;case"invalid_union":return"Entrada inv\xE0lida";case"invalid_element":return`Element inv\xE0lid a ${n.origin}`;default:return"Entrada inv\xE0lida"}}};function OT(){return{localeError:IU()}}var TU=()=>{let e={string:{unit:"znak\u016F",verb:"m\xEDt"},file:{unit:"bajt\u016F",verb:"m\xEDt"},array:{unit:"prvk\u016F",verb:"m\xEDt"},set:{unit:"prvk\u016F",verb:"m\xEDt"}};function t(n){return e[n]??null}let r={regex:"regul\xE1rn\xED v\xFDraz",email:"e-mailov\xE1 adresa",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"datum a \u010Das ve form\xE1tu ISO",date:"datum ve form\xE1tu ISO",time:"\u010Das ve form\xE1tu ISO",duration:"doba trv\xE1n\xED ISO",ipv4:"IPv4 adresa",ipv6:"IPv6 adresa",cidrv4:"rozsah IPv4",cidrv6:"rozsah IPv6",base64:"\u0159et\u011Bzec zak\xF3dovan\xFD ve form\xE1tu base64",base64url:"\u0159et\u011Bzec zak\xF3dovan\xFD ve form\xE1tu base64url",json_string:"\u0159et\u011Bzec ve form\xE1tu JSON",e164:"\u010D\xEDslo E.164",jwt:"JWT",template_literal:"vstup"},i={nan:"NaN",number:"\u010D\xEDslo",string:"\u0159et\u011Bzec",function:"funkce",array:"pole"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no instanceof ${n.expected}, obdr\u017Eeno ${s}`:`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no ${a}, obdr\u017Eeno ${s}`}case"invalid_value":return n.values.length===1?`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no ${R(n.values[0])}`:`Neplatn\xE1 mo\u017Enost: o\u010Dek\xE1v\xE1na jedna z hodnot ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`Hodnota je p\u0159\xEDli\u0161 velk\xE1: ${n.origin??"hodnota"} mus\xED m\xEDt ${a}${n.maximum.toString()} ${o.unit??"prvk\u016F"}`:`Hodnota je p\u0159\xEDli\u0161 velk\xE1: ${n.origin??"hodnota"} mus\xED b\xFDt ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`Hodnota je p\u0159\xEDli\u0161 mal\xE1: ${n.origin??"hodnota"} mus\xED m\xEDt ${a}${n.minimum.toString()} ${o.unit??"prvk\u016F"}`:`Hodnota je p\u0159\xEDli\u0161 mal\xE1: ${n.origin??"hodnota"} mus\xED b\xFDt ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED za\u010D\xEDnat na "${a.prefix}"`:a.format==="ends_with"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED kon\u010Dit na "${a.suffix}"`:a.format==="includes"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED obsahovat "${a.includes}"`:a.format==="regex"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED odpov\xEDdat vzoru ${a.pattern}`:`Neplatn\xFD form\xE1t ${r[a.format]??n.format}`}case"not_multiple_of":return`Neplatn\xE9 \u010D\xEDslo: mus\xED b\xFDt n\xE1sobkem ${n.divisor}`;case"unrecognized_keys":return`Nezn\xE1m\xE9 kl\xED\u010De: ${I(n.keys,", ")}`;case"invalid_key":return`Neplatn\xFD kl\xED\u010D v ${n.origin}`;case"invalid_union":return"Neplatn\xFD vstup";case"invalid_element":return`Neplatn\xE1 hodnota v ${n.origin}`;default:return"Neplatn\xFD vstup"}}};function PT(){return{localeError:TU()}}var CU=()=>{let e={string:{unit:"tegn",verb:"havde"},file:{unit:"bytes",verb:"havde"},array:{unit:"elementer",verb:"indeholdt"},set:{unit:"elementer",verb:"indeholdt"}};function t(n){return e[n]??null}let r={regex:"input",email:"e-mailadresse",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dato- og klokkesl\xE6t",date:"ISO-dato",time:"ISO-klokkesl\xE6t",duration:"ISO-varighed",ipv4:"IPv4-omr\xE5de",ipv6:"IPv6-omr\xE5de",cidrv4:"IPv4-spektrum",cidrv6:"IPv6-spektrum",base64:"base64-kodet streng",base64url:"base64url-kodet streng",json_string:"JSON-streng",e164:"E.164-nummer",jwt:"JWT",template_literal:"input"},i={nan:"NaN",string:"streng",number:"tal",boolean:"boolean",array:"liste",object:"objekt",set:"s\xE6t",file:"fil"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Ugyldigt input: forventede instanceof ${n.expected}, fik ${s}`:`Ugyldigt input: forventede ${a}, fik ${s}`}case"invalid_value":return n.values.length===1?`Ugyldig v\xE6rdi: forventede ${R(n.values[0])}`:`Ugyldigt valg: forventede en af f\xF8lgende ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin),s=i[n.origin]??n.origin;return o?`For stor: forventede ${s??"value"} ${o.verb} ${a} ${n.maximum.toString()} ${o.unit??"elementer"}`:`For stor: forventede ${s??"value"} havde ${a} ${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin),s=i[n.origin]??n.origin;return o?`For lille: forventede ${s} ${o.verb} ${a} ${n.minimum.toString()} ${o.unit}`:`For lille: forventede ${s} havde ${a} ${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Ugyldig streng: skal starte med "${a.prefix}"`:a.format==="ends_with"?`Ugyldig streng: skal ende med "${a.suffix}"`:a.format==="includes"?`Ugyldig streng: skal indeholde "${a.includes}"`:a.format==="regex"?`Ugyldig streng: skal matche m\xF8nsteret ${a.pattern}`:`Ugyldig ${r[a.format]??n.format}`}case"not_multiple_of":return`Ugyldigt tal: skal v\xE6re deleligt med ${n.divisor}`;case"unrecognized_keys":return`${n.keys.length>1?"Ukendte n\xF8gler":"Ukendt n\xF8gle"}: ${I(n.keys,", ")}`;case"invalid_key":return`Ugyldig n\xF8gle i ${n.origin}`;case"invalid_union":return"Ugyldigt input: matcher ingen af de tilladte typer";case"invalid_element":return`Ugyldig v\xE6rdi i ${n.origin}`;default:return"Ugyldigt input"}}};function NT(){return{localeError:CU()}}var AU=()=>{let e={string:{unit:"Zeichen",verb:"zu haben"},file:{unit:"Bytes",verb:"zu haben"},array:{unit:"Elemente",verb:"zu haben"},set:{unit:"Elemente",verb:"zu haben"}};function t(n){return e[n]??null}let r={regex:"Eingabe",email:"E-Mail-Adresse",url:"URL",emoji:"Emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-Datum und -Uhrzeit",date:"ISO-Datum",time:"ISO-Uhrzeit",duration:"ISO-Dauer",ipv4:"IPv4-Adresse",ipv6:"IPv6-Adresse",cidrv4:"IPv4-Bereich",cidrv6:"IPv6-Bereich",base64:"Base64-codierter String",base64url:"Base64-URL-codierter String",json_string:"JSON-String",e164:"E.164-Nummer",jwt:"JWT",template_literal:"Eingabe"},i={nan:"NaN",number:"Zahl",array:"Array"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Ung\xFCltige Eingabe: erwartet instanceof ${n.expected}, erhalten ${s}`:`Ung\xFCltige Eingabe: erwartet ${a}, erhalten ${s}`}case"invalid_value":return n.values.length===1?`Ung\xFCltige Eingabe: erwartet ${R(n.values[0])}`:`Ung\xFCltige Option: erwartet eine von ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`Zu gro\xDF: erwartet, dass ${n.origin??"Wert"} ${a}${n.maximum.toString()} ${o.unit??"Elemente"} hat`:`Zu gro\xDF: erwartet, dass ${n.origin??"Wert"} ${a}${n.maximum.toString()} ist`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`Zu klein: erwartet, dass ${n.origin} ${a}${n.minimum.toString()} ${o.unit} hat`:`Zu klein: erwartet, dass ${n.origin} ${a}${n.minimum.toString()} ist`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Ung\xFCltiger String: muss mit "${a.prefix}" beginnen`:a.format==="ends_with"?`Ung\xFCltiger String: muss mit "${a.suffix}" enden`:a.format==="includes"?`Ung\xFCltiger String: muss "${a.includes}" enthalten`:a.format==="regex"?`Ung\xFCltiger String: muss dem Muster ${a.pattern} entsprechen`:`Ung\xFCltig: ${r[a.format]??n.format}`}case"not_multiple_of":return`Ung\xFCltige Zahl: muss ein Vielfaches von ${n.divisor} sein`;case"unrecognized_keys":return`${n.keys.length>1?"Unbekannte Schl\xFCssel":"Unbekannter Schl\xFCssel"}: ${I(n.keys,", ")}`;case"invalid_key":return`Ung\xFCltiger Schl\xFCssel in ${n.origin}`;case"invalid_union":return"Ung\xFCltige Eingabe";case"invalid_element":return`Ung\xFCltiger Wert in ${n.origin}`;default:return"Ung\xFCltige Eingabe"}}};function RT(){return{localeError:AU()}}var OU=()=>{let e={string:{unit:"\u03C7\u03B1\u03C1\u03B1\u03BA\u03C4\u03AE\u03C1\u03B5\u03C2",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"},file:{unit:"bytes",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"},array:{unit:"\u03C3\u03C4\u03BF\u03B9\u03C7\u03B5\u03AF\u03B1",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"},set:{unit:"\u03C3\u03C4\u03BF\u03B9\u03C7\u03B5\u03AF\u03B1",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"},map:{unit:"\u03BA\u03B1\u03C4\u03B1\u03C7\u03C9\u03C1\u03AE\u03C3\u03B5\u03B9\u03C2",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"}};function t(n){return e[n]??null}let r={regex:"\u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2",email:"\u03B4\u03B9\u03B5\u03CD\u03B8\u03C5\u03BD\u03C3\u03B7 email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u03B7\u03BC\u03B5\u03C1\u03BF\u03BC\u03B7\u03BD\u03AF\u03B1 \u03BA\u03B1\u03B9 \u03CE\u03C1\u03B1",date:"ISO \u03B7\u03BC\u03B5\u03C1\u03BF\u03BC\u03B7\u03BD\u03AF\u03B1",time:"ISO \u03CE\u03C1\u03B1",duration:"ISO \u03B4\u03B9\u03AC\u03C1\u03BA\u03B5\u03B9\u03B1",ipv4:"\u03B4\u03B9\u03B5\u03CD\u03B8\u03C5\u03BD\u03C3\u03B7 IPv4",ipv6:"\u03B4\u03B9\u03B5\u03CD\u03B8\u03C5\u03BD\u03C3\u03B7 IPv6",mac:"\u03B4\u03B9\u03B5\u03CD\u03B8\u03C5\u03BD\u03C3\u03B7 MAC",cidrv4:"\u03B5\u03CD\u03C1\u03BF\u03C2 IPv4",cidrv6:"\u03B5\u03CD\u03C1\u03BF\u03C2 IPv6",base64:"\u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC \u03BA\u03C9\u03B4\u03B9\u03BA\u03BF\u03C0\u03BF\u03B9\u03B7\u03BC\u03AD\u03BD\u03B7 \u03C3\u03B5 base64",base64url:"\u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC \u03BA\u03C9\u03B4\u03B9\u03BA\u03BF\u03C0\u03BF\u03B9\u03B7\u03BC\u03AD\u03BD\u03B7 \u03C3\u03B5 base64url",json_string:"\u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC JSON",e164:"\u03B1\u03C1\u03B9\u03B8\u03BC\u03CC\u03C2 E.164",jwt:"JWT",template_literal:"\u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2"},i={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return typeof n.expected=="string"&&/^[A-Z]/.test(n.expected)?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD instanceof ${n.expected}, \u03BB\u03AE\u03C6\u03B8\u03B7\u03BA\u03B5 ${s}`:`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${a}, \u03BB\u03AE\u03C6\u03B8\u03B7\u03BA\u03B5 ${s}`}case"invalid_value":return n.values.length===1?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${R(n.values[0])}`:`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03C0\u03B9\u03BB\u03BF\u03B3\u03AE: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD \u03AD\u03BD\u03B1 \u03B1\u03C0\u03CC ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B5\u03B3\u03AC\u03BB\u03BF: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${n.origin??"\u03C4\u03B9\u03BC\u03AE"} \u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9 ${a}${n.maximum.toString()} ${o.unit??"\u03C3\u03C4\u03BF\u03B9\u03C7\u03B5\u03AF\u03B1"}`:`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B5\u03B3\u03AC\u03BB\u03BF: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${n.origin??"\u03C4\u03B9\u03BC\u03AE"} \u03BD\u03B1 \u03B5\u03AF\u03BD\u03B1\u03B9 ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B9\u03BA\u03C1\u03CC: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${n.origin} \u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9 ${a}${n.minimum.toString()} ${o.unit}`:`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B9\u03BA\u03C1\u03CC: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${n.origin} \u03BD\u03B1 \u03B5\u03AF\u03BD\u03B1\u03B9 ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03BE\u03B5\u03BA\u03B9\u03BD\u03AC \u03BC\u03B5 "${a.prefix}"`:a.format==="ends_with"?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03C4\u03B5\u03BB\u03B5\u03B9\u03CE\u03BD\u03B5\u03B9 \u03BC\u03B5 "${a.suffix}"`:a.format==="includes"?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03C0\u03B5\u03C1\u03B9\u03AD\u03C7\u03B5\u03B9 "${a.includes}"`:a.format==="regex"?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03C4\u03B1\u03B9\u03C1\u03B9\u03AC\u03B6\u03B5\u03B9 \u03BC\u03B5 \u03C4\u03BF \u03BC\u03BF\u03C4\u03AF\u03B2\u03BF ${a.pattern}`:`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03BF: ${r[a.format]??n.format}`}case"not_multiple_of":return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03BF\u03C2 \u03B1\u03C1\u03B9\u03B8\u03BC\u03CC\u03C2: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03B5\u03AF\u03BD\u03B1\u03B9 \u03C0\u03BF\u03BB\u03BB\u03B1\u03C0\u03BB\u03AC\u03C3\u03B9\u03BF \u03C4\u03BF\u03C5 ${n.divisor}`;case"unrecognized_keys":return`\u0386\u03B3\u03BD\u03C9\u03C3\u03C4${n.keys.length>1?"\u03B1":"\u03BF"} \u03BA\u03BB\u03B5\u03B9\u03B4${n.keys.length>1?"\u03B9\u03AC":"\u03AF"}: ${I(n.keys,", ")}`;case"invalid_key":return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03BF \u03BA\u03BB\u03B5\u03B9\u03B4\u03AF \u03C3\u03C4\u03BF ${n.origin}`;case"invalid_union":return"\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2";case"invalid_element":return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C4\u03B9\u03BC\u03AE \u03C3\u03C4\u03BF ${n.origin}`;default:return"\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2"}}};function MT(){return{localeError:OU()}}var PU=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(n){return e[n]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},i={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return`Invalid input: expected ${a}, received ${s}`}case"invalid_value":return n.values.length===1?`Invalid input: expected ${R(n.values[0])}`:`Invalid option: expected one of ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`Too big: expected ${n.origin??"value"} to have ${a}${n.maximum.toString()} ${o.unit??"elements"}`:`Too big: expected ${n.origin??"value"} to be ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`Too small: expected ${n.origin} to have ${a}${n.minimum.toString()} ${o.unit}`:`Too small: expected ${n.origin} to be ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Invalid string: must start with "${a.prefix}"`:a.format==="ends_with"?`Invalid string: must end with "${a.suffix}"`:a.format==="includes"?`Invalid string: must include "${a.includes}"`:a.format==="regex"?`Invalid string: must match pattern ${a.pattern}`:`Invalid ${r[a.format]??n.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${n.divisor}`;case"unrecognized_keys":return`Unrecognized key${n.keys.length>1?"s":""}: ${I(n.keys,", ")}`;case"invalid_key":return`Invalid key in ${n.origin}`;case"invalid_union":return n.options&&Array.isArray(n.options)&&n.options.length>0?`Invalid discriminator value. Expected ${n.options.map(o=>`'${o}'`).join(" | ")}`:"Invalid input";case"invalid_element":return`Invalid value in ${n.origin}`;default:return"Invalid input"}}};function Mf(){return{localeError:PU()}}var NU=()=>{let e={string:{unit:"karaktrojn",verb:"havi"},file:{unit:"bajtojn",verb:"havi"},array:{unit:"elementojn",verb:"havi"},set:{unit:"elementojn",verb:"havi"}};function t(n){return e[n]??null}let r={regex:"enigo",email:"retadreso",url:"URL",emoji:"emo\u011Dio",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-datotempo",date:"ISO-dato",time:"ISO-tempo",duration:"ISO-da\u016Dro",ipv4:"IPv4-adreso",ipv6:"IPv6-adreso",cidrv4:"IPv4-rango",cidrv6:"IPv6-rango",base64:"64-ume kodita karaktraro",base64url:"URL-64-ume kodita karaktraro",json_string:"JSON-karaktraro",e164:"E.164-nombro",jwt:"JWT",template_literal:"enigo"},i={nan:"NaN",number:"nombro",array:"tabelo",null:"senvalora"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Nevalida enigo: atendi\u011Dis instanceof ${n.expected}, ricevi\u011Dis ${s}`:`Nevalida enigo: atendi\u011Dis ${a}, ricevi\u011Dis ${s}`}case"invalid_value":return n.values.length===1?`Nevalida enigo: atendi\u011Dis ${R(n.values[0])}`:`Nevalida opcio: atendi\u011Dis unu el ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`Tro granda: atendi\u011Dis ke ${n.origin??"valoro"} havu ${a}${n.maximum.toString()} ${o.unit??"elementojn"}`:`Tro granda: atendi\u011Dis ke ${n.origin??"valoro"} havu ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`Tro malgranda: atendi\u011Dis ke ${n.origin} havu ${a}${n.minimum.toString()} ${o.unit}`:`Tro malgranda: atendi\u011Dis ke ${n.origin} estu ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Nevalida karaktraro: devas komenci\u011Di per "${a.prefix}"`:a.format==="ends_with"?`Nevalida karaktraro: devas fini\u011Di per "${a.suffix}"`:a.format==="includes"?`Nevalida karaktraro: devas inkluzivi "${a.includes}"`:a.format==="regex"?`Nevalida karaktraro: devas kongrui kun la modelo ${a.pattern}`:`Nevalida ${r[a.format]??n.format}`}case"not_multiple_of":return`Nevalida nombro: devas esti oblo de ${n.divisor}`;case"unrecognized_keys":return`Nekonata${n.keys.length>1?"j":""} \u015Dlosilo${n.keys.length>1?"j":""}: ${I(n.keys,", ")}`;case"invalid_key":return`Nevalida \u015Dlosilo en ${n.origin}`;case"invalid_union":return"Nevalida enigo";case"invalid_element":return`Nevalida valoro en ${n.origin}`;default:return"Nevalida enigo"}}};function jT(){return{localeError:NU()}}var RU=()=>{let e={string:{unit:"caracteres",verb:"tener"},file:{unit:"bytes",verb:"tener"},array:{unit:"elementos",verb:"tener"},set:{unit:"elementos",verb:"tener"}};function t(n){return e[n]??null}let r={regex:"entrada",email:"direcci\xF3n de correo electr\xF3nico",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"fecha y hora ISO",date:"fecha ISO",time:"hora ISO",duration:"duraci\xF3n ISO",ipv4:"direcci\xF3n IPv4",ipv6:"direcci\xF3n IPv6",cidrv4:"rango IPv4",cidrv6:"rango IPv6",base64:"cadena codificada en base64",base64url:"URL codificada en base64",json_string:"cadena JSON",e164:"n\xFAmero E.164",jwt:"JWT",template_literal:"entrada"},i={nan:"NaN",string:"texto",number:"n\xFAmero",boolean:"booleano",array:"arreglo",object:"objeto",set:"conjunto",file:"archivo",date:"fecha",bigint:"n\xFAmero grande",symbol:"s\xEDmbolo",undefined:"indefinido",null:"nulo",function:"funci\xF3n",map:"mapa",record:"registro",tuple:"tupla",enum:"enumeraci\xF3n",union:"uni\xF3n",literal:"literal",promise:"promesa",void:"vac\xEDo",never:"nunca",unknown:"desconocido",any:"cualquiera"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Entrada inv\xE1lida: se esperaba instanceof ${n.expected}, recibido ${s}`:`Entrada inv\xE1lida: se esperaba ${a}, recibido ${s}`}case"invalid_value":return n.values.length===1?`Entrada inv\xE1lida: se esperaba ${R(n.values[0])}`:`Opci\xF3n inv\xE1lida: se esperaba una de ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin),s=i[n.origin]??n.origin;return o?`Demasiado grande: se esperaba que ${s??"valor"} tuviera ${a}${n.maximum.toString()} ${o.unit??"elementos"}`:`Demasiado grande: se esperaba que ${s??"valor"} fuera ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin),s=i[n.origin]??n.origin;return o?`Demasiado peque\xF1o: se esperaba que ${s} tuviera ${a}${n.minimum.toString()} ${o.unit}`:`Demasiado peque\xF1o: se esperaba que ${s} fuera ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Cadena inv\xE1lida: debe comenzar con "${a.prefix}"`:a.format==="ends_with"?`Cadena inv\xE1lida: debe terminar en "${a.suffix}"`:a.format==="includes"?`Cadena inv\xE1lida: debe incluir "${a.includes}"`:a.format==="regex"?`Cadena inv\xE1lida: debe coincidir con el patr\xF3n ${a.pattern}`:`Inv\xE1lido ${r[a.format]??n.format}`}case"not_multiple_of":return`N\xFAmero inv\xE1lido: debe ser m\xFAltiplo de ${n.divisor}`;case"unrecognized_keys":return`Llave${n.keys.length>1?"s":""} desconocida${n.keys.length>1?"s":""}: ${I(n.keys,", ")}`;case"invalid_key":return`Llave inv\xE1lida en ${i[n.origin]??n.origin}`;case"invalid_union":return"Entrada inv\xE1lida";case"invalid_element":return`Valor inv\xE1lido en ${i[n.origin]??n.origin}`;default:return"Entrada inv\xE1lida"}}};function zT(){return{localeError:RU()}}var MU=()=>{let e={string:{unit:"\u06A9\u0627\u0631\u0627\u06A9\u062A\u0631",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},file:{unit:"\u0628\u0627\u06CC\u062A",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},array:{unit:"\u0622\u06CC\u062A\u0645",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},set:{unit:"\u0622\u06CC\u062A\u0645",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"}};function t(n){return e[n]??null}let r={regex:"\u0648\u0631\u0648\u062F\u06CC",email:"\u0622\u062F\u0631\u0633 \u0627\u06CC\u0645\u06CC\u0644",url:"URL",emoji:"\u0627\u06CC\u0645\u0648\u062C\u06CC",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u062A\u0627\u0631\u06CC\u062E \u0648 \u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",date:"\u062A\u0627\u0631\u06CC\u062E \u0627\u06CC\u0632\u0648",time:"\u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",duration:"\u0645\u062F\u062A \u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",ipv4:"IPv4 \u0622\u062F\u0631\u0633",ipv6:"IPv6 \u0622\u062F\u0631\u0633",cidrv4:"IPv4 \u062F\u0627\u0645\u0646\u0647",cidrv6:"IPv6 \u062F\u0627\u0645\u0646\u0647",base64:"base64-encoded \u0631\u0634\u062A\u0647",base64url:"base64url-encoded \u0631\u0634\u062A\u0647",json_string:"JSON \u0631\u0634\u062A\u0647",e164:"E.164 \u0639\u062F\u062F",jwt:"JWT",template_literal:"\u0648\u0631\u0648\u062F\u06CC"},i={nan:"NaN",number:"\u0639\u062F\u062F",array:"\u0622\u0631\u0627\u06CC\u0647"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A instanceof ${n.expected} \u0645\u06CC\u200C\u0628\u0648\u062F\u060C ${s} \u062F\u0631\u06CC\u0627\u0641\u062A \u0634\u062F`:`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A ${a} \u0645\u06CC\u200C\u0628\u0648\u062F\u060C ${s} \u062F\u0631\u06CC\u0627\u0641\u062A \u0634\u062F`}case"invalid_value":return n.values.length===1?`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A ${R(n.values[0])} \u0645\u06CC\u200C\u0628\u0648\u062F`:`\u06AF\u0632\u06CC\u0646\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A \u06CC\u06A9\u06CC \u0627\u0632 ${I(n.values,"|")} \u0645\u06CC\u200C\u0628\u0648\u062F`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`\u062E\u06CC\u0644\u06CC \u0628\u0632\u0631\u06AF: ${n.origin??"\u0645\u0642\u062F\u0627\u0631"} \u0628\u0627\u06CC\u062F ${a}${n.maximum.toString()} ${o.unit??"\u0639\u0646\u0635\u0631"} \u0628\u0627\u0634\u062F`:`\u062E\u06CC\u0644\u06CC \u0628\u0632\u0631\u06AF: ${n.origin??"\u0645\u0642\u062F\u0627\u0631"} \u0628\u0627\u06CC\u062F ${a}${n.maximum.toString()} \u0628\u0627\u0634\u062F`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`\u062E\u06CC\u0644\u06CC \u06A9\u0648\u0686\u06A9: ${n.origin} \u0628\u0627\u06CC\u062F ${a}${n.minimum.toString()} ${o.unit} \u0628\u0627\u0634\u062F`:`\u062E\u06CC\u0644\u06CC \u06A9\u0648\u0686\u06A9: ${n.origin} \u0628\u0627\u06CC\u062F ${a}${n.minimum.toString()} \u0628\u0627\u0634\u062F`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 "${a.prefix}" \u0634\u0631\u0648\u0639 \u0634\u0648\u062F`:a.format==="ends_with"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 "${a.suffix}" \u062A\u0645\u0627\u0645 \u0634\u0648\u062F`:a.format==="includes"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0634\u0627\u0645\u0644 "${a.includes}" \u0628\u0627\u0634\u062F`:a.format==="regex"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC ${a.pattern} \u0645\u0637\u0627\u0628\u0642\u062A \u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F`:`${r[a.format]??n.format} \u0646\u0627\u0645\u0639\u062A\u0628\u0631`}case"not_multiple_of":return`\u0639\u062F\u062F \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0645\u0636\u0631\u0628 ${n.divisor} \u0628\u0627\u0634\u062F`;case"unrecognized_keys":return`\u06A9\u0644\u06CC\u062F${n.keys.length>1?"\u0647\u0627\u06CC":""} \u0646\u0627\u0634\u0646\u0627\u0633: ${I(n.keys,", ")}`;case"invalid_key":return`\u06A9\u0644\u06CC\u062F \u0646\u0627\u0634\u0646\u0627\u0633 \u062F\u0631 ${n.origin}`;case"invalid_union":return"\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631";case"invalid_element":return`\u0645\u0642\u062F\u0627\u0631 \u0646\u0627\u0645\u0639\u062A\u0628\u0631 \u062F\u0631 ${n.origin}`;default:return"\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631"}}};function DT(){return{localeError:MU()}}var jU=()=>{let e={string:{unit:"merkki\xE4",subject:"merkkijonon"},file:{unit:"tavua",subject:"tiedoston"},array:{unit:"alkiota",subject:"listan"},set:{unit:"alkiota",subject:"joukon"},number:{unit:"",subject:"luvun"},bigint:{unit:"",subject:"suuren kokonaisluvun"},int:{unit:"",subject:"kokonaisluvun"},date:{unit:"",subject:"p\xE4iv\xE4m\xE4\xE4r\xE4n"}};function t(n){return e[n]??null}let r={regex:"s\xE4\xE4nn\xF6llinen lauseke",email:"s\xE4hk\xF6postiosoite",url:"URL-osoite",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-aikaleima",date:"ISO-p\xE4iv\xE4m\xE4\xE4r\xE4",time:"ISO-aika",duration:"ISO-kesto",ipv4:"IPv4-osoite",ipv6:"IPv6-osoite",cidrv4:"IPv4-alue",cidrv6:"IPv6-alue",base64:"base64-koodattu merkkijono",base64url:"base64url-koodattu merkkijono",json_string:"JSON-merkkijono",e164:"E.164-luku",jwt:"JWT",template_literal:"templaattimerkkijono"},i={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Virheellinen tyyppi: odotettiin instanceof ${n.expected}, oli ${s}`:`Virheellinen tyyppi: odotettiin ${a}, oli ${s}`}case"invalid_value":return n.values.length===1?`Virheellinen sy\xF6te: t\xE4ytyy olla ${R(n.values[0])}`:`Virheellinen valinta: t\xE4ytyy olla yksi seuraavista: ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`Liian suuri: ${o.subject} t\xE4ytyy olla ${a}${n.maximum.toString()} ${o.unit}`.trim():`Liian suuri: arvon t\xE4ytyy olla ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`Liian pieni: ${o.subject} t\xE4ytyy olla ${a}${n.minimum.toString()} ${o.unit}`.trim():`Liian pieni: arvon t\xE4ytyy olla ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Virheellinen sy\xF6te: t\xE4ytyy alkaa "${a.prefix}"`:a.format==="ends_with"?`Virheellinen sy\xF6te: t\xE4ytyy loppua "${a.suffix}"`:a.format==="includes"?`Virheellinen sy\xF6te: t\xE4ytyy sis\xE4lt\xE4\xE4 "${a.includes}"`:a.format==="regex"?`Virheellinen sy\xF6te: t\xE4ytyy vastata s\xE4\xE4nn\xF6llist\xE4 lauseketta ${a.pattern}`:`Virheellinen ${r[a.format]??n.format}`}case"not_multiple_of":return`Virheellinen luku: t\xE4ytyy olla luvun ${n.divisor} monikerta`;case"unrecognized_keys":return`${n.keys.length>1?"Tuntemattomat avaimet":"Tuntematon avain"}: ${I(n.keys,", ")}`;case"invalid_key":return"Virheellinen avain tietueessa";case"invalid_union":return"Virheellinen unioni";case"invalid_element":return"Virheellinen arvo joukossa";default:return"Virheellinen sy\xF6te"}}};function UT(){return{localeError:jU()}}var zU=()=>{let e={string:{unit:"caract\xE8res",verb:"avoir"},file:{unit:"octets",verb:"avoir"},array:{unit:"\xE9l\xE9ments",verb:"avoir"},set:{unit:"\xE9l\xE9ments",verb:"avoir"}};function t(n){return e[n]??null}let r={regex:"entr\xE9e",email:"adresse e-mail",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"date et heure ISO",date:"date ISO",time:"heure ISO",duration:"dur\xE9e ISO",ipv4:"adresse IPv4",ipv6:"adresse IPv6",cidrv4:"plage IPv4",cidrv6:"plage IPv6",base64:"cha\xEEne encod\xE9e en base64",base64url:"cha\xEEne encod\xE9e en base64url",json_string:"cha\xEEne JSON",e164:"num\xE9ro E.164",jwt:"JWT",template_literal:"entr\xE9e"},i={string:"cha\xEEne",number:"nombre",int:"entier",boolean:"bool\xE9en",bigint:"grand entier",symbol:"symbole",undefined:"ind\xE9fini",null:"null",never:"jamais",void:"vide",date:"date",array:"tableau",object:"objet",tuple:"tuple",record:"enregistrement",map:"carte",set:"ensemble",file:"fichier",nonoptional:"non-optionnel",nan:"NaN",function:"fonction"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Entr\xE9e invalide : instanceof ${n.expected} attendu, ${s} re\xE7u`:`Entr\xE9e invalide : ${a} attendu, ${s} re\xE7u`}case"invalid_value":return n.values.length===1?`Entr\xE9e invalide : ${R(n.values[0])} attendu`:`Option invalide : une valeur parmi ${I(n.values,"|")} attendue`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`Trop grand : ${i[n.origin]??"valeur"} doit ${o.verb} ${a}${n.maximum.toString()} ${o.unit??"\xE9l\xE9ment(s)"}`:`Trop grand : ${i[n.origin]??"valeur"} doit \xEAtre ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`Trop petit : ${i[n.origin]??"valeur"} doit ${o.verb} ${a}${n.minimum.toString()} ${o.unit}`:`Trop petit : ${i[n.origin]??"valeur"} doit \xEAtre ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Cha\xEEne invalide : doit commencer par "${a.prefix}"`:a.format==="ends_with"?`Cha\xEEne invalide : doit se terminer par "${a.suffix}"`:a.format==="includes"?`Cha\xEEne invalide : doit inclure "${a.includes}"`:a.format==="regex"?`Cha\xEEne invalide : doit correspondre au mod\xE8le ${a.pattern}`:`${r[a.format]??n.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit \xEAtre un multiple de ${n.divisor}`;case"unrecognized_keys":return`Cl\xE9${n.keys.length>1?"s":""} non reconnue${n.keys.length>1?"s":""} : ${I(n.keys,", ")}`;case"invalid_key":return`Cl\xE9 invalide dans ${n.origin}`;case"invalid_union":return"Entr\xE9e invalide";case"invalid_element":return`Valeur invalide dans ${n.origin}`;default:return"Entr\xE9e invalide"}}};function LT(){return{localeError:zU()}}var DU=()=>{let e={string:{unit:"caract\xE8res",verb:"avoir"},file:{unit:"octets",verb:"avoir"},array:{unit:"\xE9l\xE9ments",verb:"avoir"},set:{unit:"\xE9l\xE9ments",verb:"avoir"}};function t(n){return e[n]??null}let r={regex:"entr\xE9e",email:"adresse courriel",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"date-heure ISO",date:"date ISO",time:"heure ISO",duration:"dur\xE9e ISO",ipv4:"adresse IPv4",ipv6:"adresse IPv6",cidrv4:"plage IPv4",cidrv6:"plage IPv6",base64:"cha\xEEne encod\xE9e en base64",base64url:"cha\xEEne encod\xE9e en base64url",json_string:"cha\xEEne JSON",e164:"num\xE9ro E.164",jwt:"JWT",template_literal:"entr\xE9e"},i={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Entr\xE9e invalide : attendu instanceof ${n.expected}, re\xE7u ${s}`:`Entr\xE9e invalide : attendu ${a}, re\xE7u ${s}`}case"invalid_value":return n.values.length===1?`Entr\xE9e invalide : attendu ${R(n.values[0])}`:`Option invalide : attendu l'une des valeurs suivantes ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"\u2264":"<",o=t(n.origin);return o?`Trop grand : attendu que ${n.origin??"la valeur"} ait ${a}${n.maximum.toString()} ${o.unit}`:`Trop grand : attendu que ${n.origin??"la valeur"} soit ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?"\u2265":">",o=t(n.origin);return o?`Trop petit : attendu que ${n.origin} ait ${a}${n.minimum.toString()} ${o.unit}`:`Trop petit : attendu que ${n.origin} soit ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Cha\xEEne invalide : doit commencer par "${a.prefix}"`:a.format==="ends_with"?`Cha\xEEne invalide : doit se terminer par "${a.suffix}"`:a.format==="includes"?`Cha\xEEne invalide : doit inclure "${a.includes}"`:a.format==="regex"?`Cha\xEEne invalide : doit correspondre au motif ${a.pattern}`:`${r[a.format]??n.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit \xEAtre un multiple de ${n.divisor}`;case"unrecognized_keys":return`Cl\xE9${n.keys.length>1?"s":""} non reconnue${n.keys.length>1?"s":""} : ${I(n.keys,", ")}`;case"invalid_key":return`Cl\xE9 invalide dans ${n.origin}`;case"invalid_union":return"Entr\xE9e invalide";case"invalid_element":return`Valeur invalide dans ${n.origin}`;default:return"Entr\xE9e invalide"}}};function FT(){return{localeError:DU()}}var UU=()=>{let e={string:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA",gender:"f"},number:{label:"\u05DE\u05E1\u05E4\u05E8",gender:"m"},boolean:{label:"\u05E2\u05E8\u05DA \u05D1\u05D5\u05DC\u05D9\u05D0\u05E0\u05D9",gender:"m"},bigint:{label:"BigInt",gender:"m"},date:{label:"\u05EA\u05D0\u05E8\u05D9\u05DA",gender:"m"},array:{label:"\u05DE\u05E2\u05E8\u05DA",gender:"m"},object:{label:"\u05D0\u05D5\u05D1\u05D9\u05D9\u05E7\u05D8",gender:"m"},null:{label:"\u05E2\u05E8\u05DA \u05E8\u05D9\u05E7 (null)",gender:"m"},undefined:{label:"\u05E2\u05E8\u05DA \u05DC\u05D0 \u05DE\u05D5\u05D2\u05D3\u05E8 (undefined)",gender:"m"},symbol:{label:"\u05E1\u05D9\u05DE\u05D1\u05D5\u05DC (Symbol)",gender:"m"},function:{label:"\u05E4\u05D5\u05E0\u05E7\u05E6\u05D9\u05D4",gender:"f"},map:{label:"\u05DE\u05E4\u05D4 (Map)",gender:"f"},set:{label:"\u05E7\u05D1\u05D5\u05E6\u05D4 (Set)",gender:"f"},file:{label:"\u05E7\u05D5\u05D1\u05E5",gender:"m"},promise:{label:"Promise",gender:"m"},NaN:{label:"NaN",gender:"m"},unknown:{label:"\u05E2\u05E8\u05DA \u05DC\u05D0 \u05D9\u05D3\u05D5\u05E2",gender:"m"},value:{label:"\u05E2\u05E8\u05DA",gender:"m"}},t={string:{unit:"\u05EA\u05D5\u05D5\u05D9\u05DD",shortLabel:"\u05E7\u05E6\u05E8",longLabel:"\u05D0\u05E8\u05D5\u05DA"},file:{unit:"\u05D1\u05D9\u05D9\u05D8\u05D9\u05DD",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"},array:{unit:"\u05E4\u05E8\u05D9\u05D8\u05D9\u05DD",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"},set:{unit:"\u05E4\u05E8\u05D9\u05D8\u05D9\u05DD",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"},number:{unit:"",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"}},r=l=>l?e[l]:void 0,i=l=>{let u=r(l);return u?u.label:l??e.unknown.label},n=l=>`\u05D4${i(l)}`,a=l=>(r(l)?.gender??"m")==="f"?"\u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05D9\u05D5\u05EA":"\u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA",o=l=>l?t[l]??null:null,s={regex:{label:"\u05E7\u05DC\u05D8",gender:"m"},email:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA \u05D0\u05D9\u05DE\u05D9\u05D9\u05DC",gender:"f"},url:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA \u05E8\u05E9\u05EA",gender:"f"},emoji:{label:"\u05D0\u05D9\u05DE\u05D5\u05D2'\u05D9",gender:"m"},uuid:{label:"UUID",gender:"m"},nanoid:{label:"nanoid",gender:"m"},guid:{label:"GUID",gender:"m"},cuid:{label:"cuid",gender:"m"},cuid2:{label:"cuid2",gender:"m"},ulid:{label:"ULID",gender:"m"},xid:{label:"XID",gender:"m"},ksuid:{label:"KSUID",gender:"m"},datetime:{label:"\u05EA\u05D0\u05E8\u05D9\u05DA \u05D5\u05D6\u05DE\u05DF ISO",gender:"m"},date:{label:"\u05EA\u05D0\u05E8\u05D9\u05DA ISO",gender:"m"},time:{label:"\u05D6\u05DE\u05DF ISO",gender:"m"},duration:{label:"\u05DE\u05E9\u05DA \u05D6\u05DE\u05DF ISO",gender:"m"},ipv4:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA IPv4",gender:"f"},ipv6:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA IPv6",gender:"f"},cidrv4:{label:"\u05D8\u05D5\u05D5\u05D7 IPv4",gender:"m"},cidrv6:{label:"\u05D8\u05D5\u05D5\u05D7 IPv6",gender:"m"},base64:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D1\u05D1\u05E1\u05D9\u05E1 64",gender:"f"},base64url:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D1\u05D1\u05E1\u05D9\u05E1 64 \u05DC\u05DB\u05EA\u05D5\u05D1\u05D5\u05EA \u05E8\u05E9\u05EA",gender:"f"},json_string:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA JSON",gender:"f"},e164:{label:"\u05DE\u05E1\u05E4\u05E8 E.164",gender:"m"},jwt:{label:"JWT",gender:"m"},ends_with:{label:"\u05E7\u05DC\u05D8",gender:"m"},includes:{label:"\u05E7\u05DC\u05D8",gender:"m"},lowercase:{label:"\u05E7\u05DC\u05D8",gender:"m"},starts_with:{label:"\u05E7\u05DC\u05D8",gender:"m"},uppercase:{label:"\u05E7\u05DC\u05D8",gender:"m"}},c={nan:"NaN"};return l=>{switch(l.code){case"invalid_type":{let u=l.expected,d=c[u??""]??i(u),f=M(l.input),p=c[f]??e[f]?.label??f;return/^[A-Z]/.test(l.expected)?`\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA instanceof ${l.expected}, \u05D4\u05EA\u05E7\u05D1\u05DC ${p}`:`\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${d}, \u05D4\u05EA\u05E7\u05D1\u05DC ${p}`}case"invalid_value":{if(l.values.length===1)return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05E2\u05E8\u05DA \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA ${R(l.values[0])}`;let u=l.values.map(p=>R(p));if(l.values.length===2)return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05D0\u05E4\u05E9\u05E8\u05D5\u05D9\u05D5\u05EA \u05D4\u05DE\u05EA\u05D0\u05D9\u05DE\u05D5\u05EA \u05D4\u05DF ${u[0]} \u05D0\u05D5 ${u[1]}`;let d=u[u.length-1];return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05D0\u05E4\u05E9\u05E8\u05D5\u05D9\u05D5\u05EA \u05D4\u05DE\u05EA\u05D0\u05D9\u05DE\u05D5\u05EA \u05D4\u05DF ${u.slice(0,-1).join(", ")} \u05D0\u05D5 ${d}`}case"too_big":{let u=o(l.origin),d=n(l.origin??"value");if(l.origin==="string")return`${u?.longLabel??"\u05D0\u05E8\u05D5\u05DA"} \u05DE\u05D3\u05D9: ${d} \u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05DB\u05D9\u05DC ${l.maximum.toString()} ${u?.unit??""} ${l.inclusive?"\u05D0\u05D5 \u05E4\u05D7\u05D5\u05EA":"\u05DC\u05DB\u05DC \u05D4\u05D9\u05D5\u05EA\u05E8"}`.trim();if(l.origin==="number"){let m=l.inclusive?`\u05E7\u05D8\u05DF \u05D0\u05D5 \u05E9\u05D5\u05D5\u05D4 \u05DC-${l.maximum}`:`\u05E7\u05D8\u05DF \u05DE-${l.maximum}`;return`\u05D2\u05D3\u05D5\u05DC \u05DE\u05D3\u05D9: ${d} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${m}`}if(l.origin==="array"||l.origin==="set"){let m=l.origin==="set"?"\u05E6\u05E8\u05D9\u05DB\u05D4":"\u05E6\u05E8\u05D9\u05DA",h=l.inclusive?`${l.maximum} ${u?.unit??""} \u05D0\u05D5 \u05E4\u05D7\u05D5\u05EA`:`\u05E4\u05D7\u05D5\u05EA \u05DE-${l.maximum} ${u?.unit??""}`;return`\u05D2\u05D3\u05D5\u05DC \u05DE\u05D3\u05D9: ${d} ${m} \u05DC\u05D4\u05DB\u05D9\u05DC ${h}`.trim()}let f=l.inclusive?"<=":"<",p=a(l.origin??"value");return u?.unit?`${u.longLabel} \u05DE\u05D3\u05D9: ${d} ${p} ${f}${l.maximum.toString()} ${u.unit}`:`${u?.longLabel??"\u05D2\u05D3\u05D5\u05DC"} \u05DE\u05D3\u05D9: ${d} ${p} ${f}${l.maximum.toString()}`}case"too_small":{let u=o(l.origin),d=n(l.origin??"value");if(l.origin==="string")return`${u?.shortLabel??"\u05E7\u05E6\u05E8"} \u05DE\u05D3\u05D9: ${d} \u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05DB\u05D9\u05DC ${l.minimum.toString()} ${u?.unit??""} ${l.inclusive?"\u05D0\u05D5 \u05D9\u05D5\u05EA\u05E8":"\u05DC\u05E4\u05D7\u05D5\u05EA"}`.trim();if(l.origin==="number"){let m=l.inclusive?`\u05D2\u05D3\u05D5\u05DC \u05D0\u05D5 \u05E9\u05D5\u05D5\u05D4 \u05DC-${l.minimum}`:`\u05D2\u05D3\u05D5\u05DC \u05DE-${l.minimum}`;return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${d} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${m}`}if(l.origin==="array"||l.origin==="set"){let m=l.origin==="set"?"\u05E6\u05E8\u05D9\u05DB\u05D4":"\u05E6\u05E8\u05D9\u05DA";if(l.minimum===1&&l.inclusive){let _=(l.origin==="set","\u05DC\u05E4\u05D7\u05D5\u05EA \u05E4\u05E8\u05D9\u05D8 \u05D0\u05D7\u05D3");return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${d} ${m} \u05DC\u05D4\u05DB\u05D9\u05DC ${_}`}let h=l.inclusive?`${l.minimum} ${u?.unit??""} \u05D0\u05D5 \u05D9\u05D5\u05EA\u05E8`:`\u05D9\u05D5\u05EA\u05E8 \u05DE-${l.minimum} ${u?.unit??""}`;return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${d} ${m} \u05DC\u05D4\u05DB\u05D9\u05DC ${h}`.trim()}let f=l.inclusive?">=":">",p=a(l.origin??"value");return u?.unit?`${u.shortLabel} \u05DE\u05D3\u05D9: ${d} ${p} ${f}${l.minimum.toString()} ${u.unit}`:`${u?.shortLabel??"\u05E7\u05D8\u05DF"} \u05DE\u05D3\u05D9: ${d} ${p} ${f}${l.minimum.toString()}`}case"invalid_format":{let u=l;if(u.format==="starts_with")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05EA\u05D7\u05D9\u05DC \u05D1 "${u.prefix}"`;if(u.format==="ends_with")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05E1\u05EA\u05D9\u05D9\u05DD \u05D1 "${u.suffix}"`;if(u.format==="includes")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05DB\u05DC\u05D5\u05DC "${u.includes}"`;if(u.format==="regex")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05EA\u05D0\u05D9\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA ${u.pattern}`;let d=s[u.format],f=d?.label??u.format,m=(d?.gender??"m")==="f"?"\u05EA\u05E7\u05D9\u05E0\u05D4":"\u05EA\u05E7\u05D9\u05DF";return`${f} \u05DC\u05D0 ${m}`}case"not_multiple_of":return`\u05DE\u05E1\u05E4\u05E8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05DE\u05DB\u05E4\u05DC\u05D4 \u05E9\u05DC ${l.divisor}`;case"unrecognized_keys":return`\u05DE\u05E4\u05EA\u05D7${l.keys.length>1?"\u05D5\u05EA":""} \u05DC\u05D0 \u05DE\u05D6\u05D5\u05D4${l.keys.length>1?"\u05D9\u05DD":"\u05D4"}: ${I(l.keys,", ")}`;case"invalid_key":return"\u05E9\u05D3\u05D4 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF \u05D1\u05D0\u05D5\u05D1\u05D9\u05D9\u05E7\u05D8";case"invalid_union":return"\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF";case"invalid_element":return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF \u05D1${n(l.origin??"array")}`;default:return"\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF"}}};function BT(){return{localeError:UU()}}var LU=()=>{let e={string:{unit:"znakova",verb:"imati"},file:{unit:"bajtova",verb:"imati"},array:{unit:"stavki",verb:"imati"},set:{unit:"stavki",verb:"imati"}};function t(n){return e[n]??null}let r={regex:"unos",email:"email adresa",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum i vrijeme",date:"ISO datum",time:"ISO vrijeme",duration:"ISO trajanje",ipv4:"IPv4 adresa",ipv6:"IPv6 adresa",cidrv4:"IPv4 raspon",cidrv6:"IPv6 raspon",base64:"base64 kodirani tekst",base64url:"base64url kodirani tekst",json_string:"JSON tekst",e164:"E.164 broj",jwt:"JWT",template_literal:"unos"},i={nan:"NaN",string:"tekst",number:"broj",boolean:"boolean",array:"niz",object:"objekt",set:"skup",file:"datoteka",date:"datum",bigint:"bigint",symbol:"simbol",undefined:"undefined",null:"null",function:"funkcija",map:"mapa"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Neispravan unos: o\u010Dekuje se instanceof ${n.expected}, a primljeno je ${s}`:`Neispravan unos: o\u010Dekuje se ${a}, a primljeno je ${s}`}case"invalid_value":return n.values.length===1?`Neispravna vrijednost: o\u010Dekivano ${R(n.values[0])}`:`Neispravna opcija: o\u010Dekivano jedno od ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin),s=i[n.origin]??n.origin;return o?`Preveliko: o\u010Dekivano da ${s??"vrijednost"} ima ${a}${n.maximum.toString()} ${o.unit??"elemenata"}`:`Preveliko: o\u010Dekivano da ${s??"vrijednost"} bude ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin),s=i[n.origin]??n.origin;return o?`Premalo: o\u010Dekivano da ${s} ima ${a}${n.minimum.toString()} ${o.unit}`:`Premalo: o\u010Dekivano da ${s} bude ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Neispravan tekst: mora zapo\u010Dinjati s "${a.prefix}"`:a.format==="ends_with"?`Neispravan tekst: mora zavr\u0161avati s "${a.suffix}"`:a.format==="includes"?`Neispravan tekst: mora sadr\u017Eavati "${a.includes}"`:a.format==="regex"?`Neispravan tekst: mora odgovarati uzorku ${a.pattern}`:`Neispravna ${r[a.format]??n.format}`}case"not_multiple_of":return`Neispravan broj: mora biti vi\u0161ekratnik od ${n.divisor}`;case"unrecognized_keys":return`Neprepoznat${n.keys.length>1?"i klju\u010Devi":" klju\u010D"}: ${I(n.keys,", ")}`;case"invalid_key":return`Neispravan klju\u010D u ${i[n.origin]??n.origin}`;case"invalid_union":return"Neispravan unos";case"invalid_element":return`Neispravna vrijednost u ${i[n.origin]??n.origin}`;default:return"Neispravan unos"}}};function VT(){return{localeError:LU()}}var FU=()=>{let e={string:{unit:"karakter",verb:"legyen"},file:{unit:"byte",verb:"legyen"},array:{unit:"elem",verb:"legyen"},set:{unit:"elem",verb:"legyen"}};function t(n){return e[n]??null}let r={regex:"bemenet",email:"email c\xEDm",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO id\u0151b\xE9lyeg",date:"ISO d\xE1tum",time:"ISO id\u0151",duration:"ISO id\u0151intervallum",ipv4:"IPv4 c\xEDm",ipv6:"IPv6 c\xEDm",cidrv4:"IPv4 tartom\xE1ny",cidrv6:"IPv6 tartom\xE1ny",base64:"base64-k\xF3dolt string",base64url:"base64url-k\xF3dolt string",json_string:"JSON string",e164:"E.164 sz\xE1m",jwt:"JWT",template_literal:"bemenet"},i={nan:"NaN",number:"sz\xE1m",array:"t\xF6mb"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k instanceof ${n.expected}, a kapott \xE9rt\xE9k ${s}`:`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k ${a}, a kapott \xE9rt\xE9k ${s}`}case"invalid_value":return n.values.length===1?`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k ${R(n.values[0])}`:`\xC9rv\xE9nytelen opci\xF3: valamelyik \xE9rt\xE9k v\xE1rt ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`T\xFAl nagy: ${n.origin??"\xE9rt\xE9k"} m\xE9rete t\xFAl nagy ${a}${n.maximum.toString()} ${o.unit??"elem"}`:`T\xFAl nagy: a bemeneti \xE9rt\xE9k ${n.origin??"\xE9rt\xE9k"} t\xFAl nagy: ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`T\xFAl kicsi: a bemeneti \xE9rt\xE9k ${n.origin} m\xE9rete t\xFAl kicsi ${a}${n.minimum.toString()} ${o.unit}`:`T\xFAl kicsi: a bemeneti \xE9rt\xE9k ${n.origin} t\xFAl kicsi ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\xC9rv\xE9nytelen string: "${a.prefix}" \xE9rt\xE9kkel kell kezd\u0151dnie`:a.format==="ends_with"?`\xC9rv\xE9nytelen string: "${a.suffix}" \xE9rt\xE9kkel kell v\xE9gz\u0151dnie`:a.format==="includes"?`\xC9rv\xE9nytelen string: "${a.includes}" \xE9rt\xE9ket kell tartalmaznia`:a.format==="regex"?`\xC9rv\xE9nytelen string: ${a.pattern} mint\xE1nak kell megfelelnie`:`\xC9rv\xE9nytelen ${r[a.format]??n.format}`}case"not_multiple_of":return`\xC9rv\xE9nytelen sz\xE1m: ${n.divisor} t\xF6bbsz\xF6r\xF6s\xE9nek kell lennie`;case"unrecognized_keys":return`Ismeretlen kulcs${n.keys.length>1?"s":""}: ${I(n.keys,", ")}`;case"invalid_key":return`\xC9rv\xE9nytelen kulcs ${n.origin}`;case"invalid_union":return"\xC9rv\xE9nytelen bemenet";case"invalid_element":return`\xC9rv\xE9nytelen \xE9rt\xE9k: ${n.origin}`;default:return"\xC9rv\xE9nytelen bemenet"}}};function ZT(){return{localeError:FU()}}function HT(e,t,r){return Math.abs(e)===1?t:r}function Is(e){if(!e)return"";let t=["\u0561","\u0565","\u0568","\u056B","\u0578","\u0578\u0582","\u0585"],r=e[e.length-1];return e+(t.includes(r)?"\u0576":"\u0568")}var BU=()=>{let e={string:{unit:{one:"\u0576\u0577\u0561\u0576",many:"\u0576\u0577\u0561\u0576\u0576\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"},file:{unit:{one:"\u0562\u0561\u0575\u0569",many:"\u0562\u0561\u0575\u0569\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"},array:{unit:{one:"\u057F\u0561\u0580\u0580",many:"\u057F\u0561\u0580\u0580\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"},set:{unit:{one:"\u057F\u0561\u0580\u0580",many:"\u057F\u0561\u0580\u0580\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"}};function t(n){return e[n]??null}let r={regex:"\u0574\u0578\u0582\u057F\u0584",email:"\u0567\u056C. \u0570\u0561\u057D\u0581\u0565",url:"URL",emoji:"\u0567\u0574\u0578\u057B\u056B",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0561\u0574\u057D\u0561\u0569\u056B\u057E \u0587 \u056A\u0561\u0574",date:"ISO \u0561\u0574\u057D\u0561\u0569\u056B\u057E",time:"ISO \u056A\u0561\u0574",duration:"ISO \u057F\u0587\u0578\u0572\u0578\u0582\u0569\u0575\u0578\u0582\u0576",ipv4:"IPv4 \u0570\u0561\u057D\u0581\u0565",ipv6:"IPv6 \u0570\u0561\u057D\u0581\u0565",cidrv4:"IPv4 \u0574\u056B\u057B\u0561\u056F\u0561\u0575\u0584",cidrv6:"IPv6 \u0574\u056B\u057B\u0561\u056F\u0561\u0575\u0584",base64:"base64 \u0571\u0587\u0561\u0579\u0561\u0583\u0578\u057E \u057F\u0578\u0572",base64url:"base64url \u0571\u0587\u0561\u0579\u0561\u0583\u0578\u057E \u057F\u0578\u0572",json_string:"JSON \u057F\u0578\u0572",e164:"E.164 \u0570\u0561\u0574\u0561\u0580",jwt:"JWT",template_literal:"\u0574\u0578\u0582\u057F\u0584"},i={nan:"NaN",number:"\u0569\u056B\u057E",array:"\u0566\u0561\u0576\u0563\u057E\u0561\u056E"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 instanceof ${n.expected}, \u057D\u057F\u0561\u0581\u057E\u0565\u056C \u0567 ${s}`:`\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 ${a}, \u057D\u057F\u0561\u0581\u057E\u0565\u056C \u0567 ${s}`}case"invalid_value":return n.values.length===1?`\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 ${R(n.values[1])}`:`\u054D\u056D\u0561\u056C \u057F\u0561\u0580\u0562\u0565\u0580\u0561\u056F\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 \u0570\u0565\u057F\u0587\u0575\u0561\u056C\u0576\u0565\u0580\u056B\u0581 \u0574\u0565\u056F\u0568\u055D ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);if(o){let s=Number(n.maximum),c=HT(s,o.unit.one,o.unit.many);return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0574\u0565\u056E \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${Is(n.origin??"\u0561\u0580\u056A\u0565\u0584")} \u056F\u0578\u0582\u0576\u0565\u0576\u0561 ${a}${n.maximum.toString()} ${c}`}return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0574\u0565\u056E \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${Is(n.origin??"\u0561\u0580\u056A\u0565\u0584")} \u056C\u056B\u0576\u056B ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);if(o){let s=Number(n.minimum),c=HT(s,o.unit.one,o.unit.many);return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0583\u0578\u0584\u0580 \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${Is(n.origin)} \u056F\u0578\u0582\u0576\u0565\u0576\u0561 ${a}${n.minimum.toString()} ${c}`}return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0583\u0578\u0584\u0580 \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${Is(n.origin)} \u056C\u056B\u0576\u056B ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u057D\u056F\u057D\u057E\u056B "${a.prefix}"-\u0578\u057E`:a.format==="ends_with"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u0561\u057E\u0561\u0580\u057F\u057E\u056B "${a.suffix}"-\u0578\u057E`:a.format==="includes"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u057A\u0561\u0580\u0578\u0582\u0576\u0561\u056F\u056B "${a.includes}"`:a.format==="regex"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u0570\u0561\u0574\u0561\u057A\u0561\u057F\u0561\u057D\u056D\u0561\u0576\u056B ${a.pattern} \u0571\u0587\u0561\u0579\u0561\u0583\u056B\u0576`:`\u054D\u056D\u0561\u056C ${r[a.format]??n.format}`}case"not_multiple_of":return`\u054D\u056D\u0561\u056C \u0569\u056B\u057E\u2024 \u057A\u0565\u057F\u0584 \u0567 \u0562\u0561\u0566\u0574\u0561\u057A\u0561\u057F\u056B\u056F \u056C\u056B\u0576\u056B ${n.divisor}-\u056B`;case"unrecognized_keys":return`\u0549\u0573\u0561\u0576\u0561\u0579\u057E\u0561\u056E \u0562\u0561\u0576\u0561\u056C\u056B${n.keys.length>1?"\u0576\u0565\u0580":""}. ${I(n.keys,", ")}`;case"invalid_key":return`\u054D\u056D\u0561\u056C \u0562\u0561\u0576\u0561\u056C\u056B ${Is(n.origin)}-\u0578\u0582\u0574`;case"invalid_union":return"\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574";case"invalid_element":return`\u054D\u056D\u0561\u056C \u0561\u0580\u056A\u0565\u0584 ${Is(n.origin)}-\u0578\u0582\u0574`;default:return"\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574"}}};function GT(){return{localeError:BU()}}var VU=()=>{let e={string:{unit:"karakter",verb:"memiliki"},file:{unit:"byte",verb:"memiliki"},array:{unit:"item",verb:"memiliki"},set:{unit:"item",verb:"memiliki"}};function t(n){return e[n]??null}let r={regex:"input",email:"alamat email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"tanggal dan waktu format ISO",date:"tanggal format ISO",time:"jam format ISO",duration:"durasi format ISO",ipv4:"alamat IPv4",ipv6:"alamat IPv6",cidrv4:"rentang alamat IPv4",cidrv6:"rentang alamat IPv6",base64:"string dengan enkode base64",base64url:"string dengan enkode base64url",json_string:"string JSON",e164:"angka E.164",jwt:"JWT",template_literal:"input"},i={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Input tidak valid: diharapkan instanceof ${n.expected}, diterima ${s}`:`Input tidak valid: diharapkan ${a}, diterima ${s}`}case"invalid_value":return n.values.length===1?`Input tidak valid: diharapkan ${R(n.values[0])}`:`Pilihan tidak valid: diharapkan salah satu dari ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`Terlalu besar: diharapkan ${n.origin??"value"} memiliki ${a}${n.maximum.toString()} ${o.unit??"elemen"}`:`Terlalu besar: diharapkan ${n.origin??"value"} menjadi ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`Terlalu kecil: diharapkan ${n.origin} memiliki ${a}${n.minimum.toString()} ${o.unit}`:`Terlalu kecil: diharapkan ${n.origin} menjadi ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`String tidak valid: harus dimulai dengan "${a.prefix}"`:a.format==="ends_with"?`String tidak valid: harus berakhir dengan "${a.suffix}"`:a.format==="includes"?`String tidak valid: harus menyertakan "${a.includes}"`:a.format==="regex"?`String tidak valid: harus sesuai pola ${a.pattern}`:`${r[a.format]??n.format} tidak valid`}case"not_multiple_of":return`Angka tidak valid: harus kelipatan dari ${n.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali ${n.keys.length>1?"s":""}: ${I(n.keys,", ")}`;case"invalid_key":return`Kunci tidak valid di ${n.origin}`;case"invalid_union":return"Input tidak valid";case"invalid_element":return`Nilai tidak valid di ${n.origin}`;default:return"Input tidak valid"}}};function WT(){return{localeError:VU()}}var ZU=()=>{let e={string:{unit:"stafi",verb:"a\xF0 hafa"},file:{unit:"b\xE6ti",verb:"a\xF0 hafa"},array:{unit:"hluti",verb:"a\xF0 hafa"},set:{unit:"hluti",verb:"a\xF0 hafa"}};function t(n){return e[n]??null}let r={regex:"gildi",email:"netfang",url:"vefsl\xF3\xF0",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dagsetning og t\xEDmi",date:"ISO dagsetning",time:"ISO t\xEDmi",duration:"ISO t\xEDmalengd",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded strengur",base64url:"base64url-encoded strengur",json_string:"JSON strengur",e164:"E.164 t\xF6lugildi",jwt:"JWT",template_literal:"gildi"},i={nan:"NaN",number:"n\xFAmer",array:"fylki"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Rangt gildi: \xDE\xFA sl\xF3st inn ${s} \xFEar sem \xE1 a\xF0 vera instanceof ${n.expected}`:`Rangt gildi: \xDE\xFA sl\xF3st inn ${s} \xFEar sem \xE1 a\xF0 vera ${a}`}case"invalid_value":return n.values.length===1?`Rangt gildi: gert r\xE1\xF0 fyrir ${R(n.values[0])}`:`\xD3gilt val: m\xE1 vera eitt af eftirfarandi ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`Of st\xF3rt: gert er r\xE1\xF0 fyrir a\xF0 ${n.origin??"gildi"} hafi ${a}${n.maximum.toString()} ${o.unit??"hluti"}`:`Of st\xF3rt: gert er r\xE1\xF0 fyrir a\xF0 ${n.origin??"gildi"} s\xE9 ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`Of l\xEDti\xF0: gert er r\xE1\xF0 fyrir a\xF0 ${n.origin} hafi ${a}${n.minimum.toString()} ${o.unit}`:`Of l\xEDti\xF0: gert er r\xE1\xF0 fyrir a\xF0 ${n.origin} s\xE9 ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\xD3gildur strengur: ver\xF0ur a\xF0 byrja \xE1 "${a.prefix}"`:a.format==="ends_with"?`\xD3gildur strengur: ver\xF0ur a\xF0 enda \xE1 "${a.suffix}"`:a.format==="includes"?`\xD3gildur strengur: ver\xF0ur a\xF0 innihalda "${a.includes}"`:a.format==="regex"?`\xD3gildur strengur: ver\xF0ur a\xF0 fylgja mynstri ${a.pattern}`:`Rangt ${r[a.format]??n.format}`}case"not_multiple_of":return`R\xF6ng tala: ver\xF0ur a\xF0 vera margfeldi af ${n.divisor}`;case"unrecognized_keys":return`\xD3\xFEekkt ${n.keys.length>1?"ir lyklar":"ur lykill"}: ${I(n.keys,", ")}`;case"invalid_key":return`Rangur lykill \xED ${n.origin}`;case"invalid_union":return"Rangt gildi";case"invalid_element":return`Rangt gildi \xED ${n.origin}`;default:return"Rangt gildi"}}};function JT(){return{localeError:ZU()}}var HU=()=>{let e={string:{unit:"caratteri",verb:"avere"},file:{unit:"byte",verb:"avere"},array:{unit:"elementi",verb:"avere"},set:{unit:"elementi",verb:"avere"}};function t(n){return e[n]??null}let r={regex:"input",email:"indirizzo email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data e ora ISO",date:"data ISO",time:"ora ISO",duration:"durata ISO",ipv4:"indirizzo IPv4",ipv6:"indirizzo IPv6",cidrv4:"intervallo IPv4",cidrv6:"intervallo IPv6",base64:"stringa codificata in base64",base64url:"URL codificata in base64",json_string:"stringa JSON",e164:"numero E.164",jwt:"JWT",template_literal:"input"},i={nan:"NaN",number:"numero",array:"vettore"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Input non valido: atteso instanceof ${n.expected}, ricevuto ${s}`:`Input non valido: atteso ${a}, ricevuto ${s}`}case"invalid_value":return n.values.length===1?`Input non valido: atteso ${R(n.values[0])}`:`Opzione non valida: atteso uno tra ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`Troppo grande: ${n.origin??"valore"} deve avere ${a}${n.maximum.toString()} ${o.unit??"elementi"}`:`Troppo grande: ${n.origin??"valore"} deve essere ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`Troppo piccolo: ${n.origin} deve avere ${a}${n.minimum.toString()} ${o.unit}`:`Troppo piccolo: ${n.origin} deve essere ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Stringa non valida: deve iniziare con "${a.prefix}"`:a.format==="ends_with"?`Stringa non valida: deve terminare con "${a.suffix}"`:a.format==="includes"?`Stringa non valida: deve includere "${a.includes}"`:a.format==="regex"?`Stringa non valida: deve corrispondere al pattern ${a.pattern}`:`Input non valido: ${r[a.format]??n.format}`}case"not_multiple_of":return`Numero non valido: deve essere un multiplo di ${n.divisor}`;case"unrecognized_keys":return`Chiav${n.keys.length>1?"i":"e"} non riconosciut${n.keys.length>1?"e":"a"}: ${I(n.keys,", ")}`;case"invalid_key":return`Chiave non valida in ${n.origin}`;case"invalid_union":return"Input non valido";case"invalid_element":return`Valore non valido in ${n.origin}`;default:return"Input non valido"}}};function KT(){return{localeError:HU()}}var GU=()=>{let e={string:{unit:"\u6587\u5B57",verb:"\u3067\u3042\u308B"},file:{unit:"\u30D0\u30A4\u30C8",verb:"\u3067\u3042\u308B"},array:{unit:"\u8981\u7D20",verb:"\u3067\u3042\u308B"},set:{unit:"\u8981\u7D20",verb:"\u3067\u3042\u308B"}};function t(n){return e[n]??null}let r={regex:"\u5165\u529B\u5024",email:"\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9",url:"URL",emoji:"\u7D75\u6587\u5B57",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO\u65E5\u6642",date:"ISO\u65E5\u4ED8",time:"ISO\u6642\u523B",duration:"ISO\u671F\u9593",ipv4:"IPv4\u30A2\u30C9\u30EC\u30B9",ipv6:"IPv6\u30A2\u30C9\u30EC\u30B9",cidrv4:"IPv4\u7BC4\u56F2",cidrv6:"IPv6\u7BC4\u56F2",base64:"base64\u30A8\u30F3\u30B3\u30FC\u30C9\u6587\u5B57\u5217",base64url:"base64url\u30A8\u30F3\u30B3\u30FC\u30C9\u6587\u5B57\u5217",json_string:"JSON\u6587\u5B57\u5217",e164:"E.164\u756A\u53F7",jwt:"JWT",template_literal:"\u5165\u529B\u5024"},i={nan:"NaN",number:"\u6570\u5024",array:"\u914D\u5217"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\u7121\u52B9\u306A\u5165\u529B: instanceof ${n.expected}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F\u304C\u3001${s}\u304C\u5165\u529B\u3055\u308C\u307E\u3057\u305F`:`\u7121\u52B9\u306A\u5165\u529B: ${a}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F\u304C\u3001${s}\u304C\u5165\u529B\u3055\u308C\u307E\u3057\u305F`}case"invalid_value":return n.values.length===1?`\u7121\u52B9\u306A\u5165\u529B: ${R(n.values[0])}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F`:`\u7121\u52B9\u306A\u9078\u629E: ${I(n.values,"\u3001")}\u306E\u3044\u305A\u308C\u304B\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;case"too_big":{let a=n.inclusive?"\u4EE5\u4E0B\u3067\u3042\u308B":"\u3088\u308A\u5C0F\u3055\u3044",o=t(n.origin);return o?`\u5927\u304D\u3059\u304E\u308B\u5024: ${n.origin??"\u5024"}\u306F${n.maximum.toString()}${o.unit??"\u8981\u7D20"}${a}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u5927\u304D\u3059\u304E\u308B\u5024: ${n.origin??"\u5024"}\u306F${n.maximum.toString()}${a}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`}case"too_small":{let a=n.inclusive?"\u4EE5\u4E0A\u3067\u3042\u308B":"\u3088\u308A\u5927\u304D\u3044",o=t(n.origin);return o?`\u5C0F\u3055\u3059\u304E\u308B\u5024: ${n.origin}\u306F${n.minimum.toString()}${o.unit}${a}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u5C0F\u3055\u3059\u304E\u308B\u5024: ${n.origin}\u306F${n.minimum.toString()}${a}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${a.prefix}"\u3067\u59CB\u307E\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:a.format==="ends_with"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${a.suffix}"\u3067\u7D42\u308F\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:a.format==="includes"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${a.includes}"\u3092\u542B\u3080\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:a.format==="regex"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: \u30D1\u30BF\u30FC\u30F3${a.pattern}\u306B\u4E00\u81F4\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u7121\u52B9\u306A${r[a.format]??n.format}`}case"not_multiple_of":return`\u7121\u52B9\u306A\u6570\u5024: ${n.divisor}\u306E\u500D\u6570\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;case"unrecognized_keys":return`\u8A8D\u8B58\u3055\u308C\u3066\u3044\u306A\u3044\u30AD\u30FC${n.keys.length>1?"\u7FA4":""}: ${I(n.keys,"\u3001")}`;case"invalid_key":return`${n.origin}\u5185\u306E\u7121\u52B9\u306A\u30AD\u30FC`;case"invalid_union":return"\u7121\u52B9\u306A\u5165\u529B";case"invalid_element":return`${n.origin}\u5185\u306E\u7121\u52B9\u306A\u5024`;default:return"\u7121\u52B9\u306A\u5165\u529B"}}};function qT(){return{localeError:GU()}}var WU=()=>{let e={string:{unit:"\u10E1\u10D8\u10DB\u10D1\u10DD\u10DA\u10DD",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"},file:{unit:"\u10D1\u10D0\u10D8\u10E2\u10D8",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"},array:{unit:"\u10D4\u10DA\u10D4\u10DB\u10D4\u10DC\u10E2\u10D8",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"},set:{unit:"\u10D4\u10DA\u10D4\u10DB\u10D4\u10DC\u10E2\u10D8",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"}};function t(n){return e[n]??null}let r={regex:"\u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0",email:"\u10D4\u10DA-\u10E4\u10DD\u10E1\u10E2\u10D8\u10E1 \u10DB\u10D8\u10E1\u10D0\u10DB\u10D0\u10E0\u10D7\u10D8",url:"URL",emoji:"\u10D4\u10DB\u10DD\u10EF\u10D8",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u10D7\u10D0\u10E0\u10D8\u10E6\u10D8-\u10D3\u10E0\u10DD",date:"\u10D7\u10D0\u10E0\u10D8\u10E6\u10D8",time:"\u10D3\u10E0\u10DD",duration:"\u10EE\u10D0\u10DC\u10D2\u10E0\u10EB\u10DA\u10D8\u10D5\u10DD\u10D1\u10D0",ipv4:"IPv4 \u10DB\u10D8\u10E1\u10D0\u10DB\u10D0\u10E0\u10D7\u10D8",ipv6:"IPv6 \u10DB\u10D8\u10E1\u10D0\u10DB\u10D0\u10E0\u10D7\u10D8",cidrv4:"IPv4 \u10D3\u10D8\u10D0\u10DE\u10D0\u10D6\u10DD\u10DC\u10D8",cidrv6:"IPv6 \u10D3\u10D8\u10D0\u10DE\u10D0\u10D6\u10DD\u10DC\u10D8",base64:"base64-\u10D9\u10DD\u10D3\u10D8\u10E0\u10D4\u10D1\u10E3\u10DA\u10D8 \u10D5\u10D4\u10DA\u10D8",base64url:"base64url-\u10D9\u10DD\u10D3\u10D8\u10E0\u10D4\u10D1\u10E3\u10DA\u10D8 \u10D5\u10D4\u10DA\u10D8",json_string:"JSON \u10D5\u10D4\u10DA\u10D8",e164:"E.164 \u10DC\u10DD\u10DB\u10D4\u10E0\u10D8",jwt:"JWT",template_literal:"\u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0"},i={nan:"NaN",number:"\u10E0\u10D8\u10EA\u10EE\u10D5\u10D8",string:"\u10D5\u10D4\u10DA\u10D8",boolean:"\u10D1\u10E3\u10DA\u10D4\u10D0\u10DC\u10D8",function:"\u10E4\u10E3\u10DC\u10E5\u10EA\u10D8\u10D0",array:"\u10DB\u10D0\u10E1\u10D8\u10D5\u10D8"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 instanceof ${n.expected}, \u10DB\u10D8\u10E6\u10D4\u10D1\u10E3\u10DA\u10D8 ${s}`:`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${a}, \u10DB\u10D8\u10E6\u10D4\u10D1\u10E3\u10DA\u10D8 ${s}`}case"invalid_value":return n.values.length===1?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${R(n.values[0])}`:`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D0\u10E0\u10D8\u10D0\u10DC\u10E2\u10D8: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8\u10D0 \u10D4\u10E0\u10D7-\u10D4\u10E0\u10D7\u10D8 ${I(n.values,"|")}-\u10D3\u10D0\u10DC`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10D3\u10D8\u10D3\u10D8: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${n.origin??"\u10DB\u10DC\u10D8\u10E8\u10D5\u10DC\u10D4\u10DA\u10DD\u10D1\u10D0"} ${o.verb} ${a}${n.maximum.toString()} ${o.unit}`:`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10D3\u10D8\u10D3\u10D8: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${n.origin??"\u10DB\u10DC\u10D8\u10E8\u10D5\u10DC\u10D4\u10DA\u10DD\u10D1\u10D0"} \u10D8\u10E7\u10DD\u10E1 ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10DE\u10D0\u10E2\u10D0\u10E0\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${n.origin} ${o.verb} ${a}${n.minimum.toString()} ${o.unit}`:`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10DE\u10D0\u10E2\u10D0\u10E0\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${n.origin} \u10D8\u10E7\u10DD\u10E1 ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D4\u10DA\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10D8\u10EC\u10E7\u10D4\u10D1\u10DD\u10D3\u10D4\u10E1 "${a.prefix}"-\u10D8\u10D7`:a.format==="ends_with"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D4\u10DA\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10DB\u10D7\u10D0\u10D5\u10E0\u10D3\u10D4\u10D1\u10DD\u10D3\u10D4\u10E1 "${a.suffix}"-\u10D8\u10D7`:a.format==="includes"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D4\u10DA\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1 "${a.includes}"-\u10E1`:a.format==="regex"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D4\u10DA\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D4\u10E1\u10D0\u10D1\u10D0\u10DB\u10D4\u10D1\u10DD\u10D3\u10D4\u10E1 \u10E8\u10D0\u10D1\u10DA\u10DD\u10DC\u10E1 ${a.pattern}`:`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 ${r[a.format]??n.format}`}case"not_multiple_of":return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E0\u10D8\u10EA\u10EE\u10D5\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10D8\u10E7\u10DD\u10E1 ${n.divisor}-\u10D8\u10E1 \u10EF\u10D4\u10E0\u10D0\u10D3\u10D8`;case"unrecognized_keys":return`\u10E3\u10EA\u10DC\u10DD\u10D1\u10D8 \u10D2\u10D0\u10E1\u10D0\u10E6\u10D4\u10D1${n.keys.length>1?"\u10D4\u10D1\u10D8":"\u10D8"}: ${I(n.keys,", ")}`;case"invalid_key":return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D2\u10D0\u10E1\u10D0\u10E6\u10D4\u10D1\u10D8 ${n.origin}-\u10E8\u10D8`;case"invalid_union":return"\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0";case"invalid_element":return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10DB\u10DC\u10D8\u10E8\u10D5\u10DC\u10D4\u10DA\u10DD\u10D1\u10D0 ${n.origin}-\u10E8\u10D8`;default:return"\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0"}}};function XT(){return{localeError:WU()}}var JU=()=>{let e={string:{unit:"\u178F\u17BD\u17A2\u1780\u17D2\u179F\u179A",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},file:{unit:"\u1794\u17C3",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},array:{unit:"\u1792\u17B6\u178F\u17BB",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},set:{unit:"\u1792\u17B6\u178F\u17BB",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"}};function t(n){return e[n]??null}let r={regex:"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B",email:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793\u17A2\u17CA\u17B8\u1798\u17C2\u179B",url:"URL",emoji:"\u179F\u1789\u17D2\u1789\u17B6\u17A2\u17B6\u179A\u1798\u17D2\u1798\u178E\u17CD",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u1780\u17B6\u179B\u1794\u179A\u17B7\u1785\u17D2\u1786\u17C1\u1791 \u1793\u17B7\u1784\u1798\u17C9\u17C4\u1784 ISO",date:"\u1780\u17B6\u179B\u1794\u179A\u17B7\u1785\u17D2\u1786\u17C1\u1791 ISO",time:"\u1798\u17C9\u17C4\u1784 ISO",duration:"\u179A\u1799\u17C8\u1796\u17C1\u179B ISO",ipv4:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv4",ipv6:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv6",cidrv4:"\u178A\u17C2\u1793\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv4",cidrv6:"\u178A\u17C2\u1793\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv6",base64:"\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u17A2\u17CA\u17B7\u1780\u17BC\u178A base64",base64url:"\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u17A2\u17CA\u17B7\u1780\u17BC\u178A base64url",json_string:"\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A JSON",e164:"\u179B\u17C1\u1781 E.164",jwt:"JWT",template_literal:"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B"},i={nan:"NaN",number:"\u179B\u17C1\u1781",array:"\u17A2\u17B6\u179A\u17C1 (Array)",null:"\u1782\u17D2\u1798\u17B6\u1793\u178F\u1798\u17D2\u179B\u17C3 (null)"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A instanceof ${n.expected} \u1794\u17C9\u17BB\u1793\u17D2\u178F\u17C2\u1791\u1791\u17BD\u179B\u1794\u17B6\u1793 ${s}`:`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${a} \u1794\u17C9\u17BB\u1793\u17D2\u178F\u17C2\u1791\u1791\u17BD\u179B\u1794\u17B6\u1793 ${s}`}case"invalid_value":return n.values.length===1?`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${R(n.values[0])}`:`\u1787\u1798\u17D2\u179A\u17BE\u179F\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1787\u17B6\u1798\u17BD\u1799\u1780\u17D2\u1793\u17BB\u1784\u1785\u17C6\u178E\u17C4\u1798 ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`\u1792\u17C6\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${n.origin??"\u178F\u1798\u17D2\u179B\u17C3"} ${a} ${n.maximum.toString()} ${o.unit??"\u1792\u17B6\u178F\u17BB"}`:`\u1792\u17C6\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${n.origin??"\u178F\u1798\u17D2\u179B\u17C3"} ${a} ${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`\u178F\u17BC\u1785\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${n.origin} ${a} ${n.minimum.toString()} ${o.unit}`:`\u178F\u17BC\u1785\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${n.origin} ${a} ${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1785\u17B6\u1794\u17CB\u1795\u17D2\u178F\u17BE\u1798\u178A\u17C4\u1799 "${a.prefix}"`:a.format==="ends_with"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1794\u1789\u17D2\u1785\u1794\u17CB\u178A\u17C4\u1799 "${a.suffix}"`:a.format==="includes"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1798\u17B6\u1793 "${a.includes}"`:a.format==="regex"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u178F\u17C2\u1795\u17D2\u1782\u17BC\u1795\u17D2\u1782\u1784\u1793\u17B9\u1784\u1791\u1798\u17D2\u179A\u1784\u17CB\u178A\u17C2\u179B\u1794\u17B6\u1793\u1780\u17C6\u178E\u178F\u17CB ${a.pattern}`:`\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 ${r[a.format]??n.format}`}case"not_multiple_of":return`\u179B\u17C1\u1781\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u178F\u17C2\u1787\u17B6\u1796\u17A0\u17BB\u1782\u17BB\u178E\u1793\u17C3 ${n.divisor}`;case"unrecognized_keys":return`\u179A\u1780\u1783\u17BE\u1789\u179F\u17C4\u1798\u17B7\u1793\u179F\u17D2\u1782\u17B6\u179B\u17CB\u17D6 ${I(n.keys,", ")}`;case"invalid_key":return`\u179F\u17C4\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u1793\u17C5\u1780\u17D2\u1793\u17BB\u1784 ${n.origin}`;case"invalid_union":return"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C";case"invalid_element":return`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u1793\u17C5\u1780\u17D2\u1793\u17BB\u1784 ${n.origin}`;default:return"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C"}}};function jf(){return{localeError:JU()}}function YT(){return jf()}var KU=()=>{let e={string:{unit:"\uBB38\uC790",verb:"to have"},file:{unit:"\uBC14\uC774\uD2B8",verb:"to have"},array:{unit:"\uAC1C",verb:"to have"},set:{unit:"\uAC1C",verb:"to have"}};function t(n){return e[n]??null}let r={regex:"\uC785\uB825",email:"\uC774\uBA54\uC77C \uC8FC\uC18C",url:"URL",emoji:"\uC774\uBAA8\uC9C0",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \uB0A0\uC9DC\uC2DC\uAC04",date:"ISO \uB0A0\uC9DC",time:"ISO \uC2DC\uAC04",duration:"ISO \uAE30\uAC04",ipv4:"IPv4 \uC8FC\uC18C",ipv6:"IPv6 \uC8FC\uC18C",cidrv4:"IPv4 \uBC94\uC704",cidrv6:"IPv6 \uBC94\uC704",base64:"base64 \uC778\uCF54\uB529 \uBB38\uC790\uC5F4",base64url:"base64url \uC778\uCF54\uB529 \uBB38\uC790\uC5F4",json_string:"JSON \uBB38\uC790\uC5F4",e164:"E.164 \uBC88\uD638",jwt:"JWT",template_literal:"\uC785\uB825"},i={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\uC798\uBABB\uB41C \uC785\uB825: \uC608\uC0C1 \uD0C0\uC785\uC740 instanceof ${n.expected}, \uBC1B\uC740 \uD0C0\uC785\uC740 ${s}\uC785\uB2C8\uB2E4`:`\uC798\uBABB\uB41C \uC785\uB825: \uC608\uC0C1 \uD0C0\uC785\uC740 ${a}, \uBC1B\uC740 \uD0C0\uC785\uC740 ${s}\uC785\uB2C8\uB2E4`}case"invalid_value":return n.values.length===1?`\uC798\uBABB\uB41C \uC785\uB825: \uAC12\uC740 ${R(n.values[0])} \uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4`:`\uC798\uBABB\uB41C \uC635\uC158: ${I(n.values,"\uB610\uB294 ")} \uC911 \uD558\uB098\uC5EC\uC57C \uD569\uB2C8\uB2E4`;case"too_big":{let a=n.inclusive?"\uC774\uD558":"\uBBF8\uB9CC",o=a==="\uBBF8\uB9CC"?"\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4":"\uC5EC\uC57C \uD569\uB2C8\uB2E4",s=t(n.origin),c=s?.unit??"\uC694\uC18C";return s?`${n.origin??"\uAC12"}\uC774 \uB108\uBB34 \uD07D\uB2C8\uB2E4: ${n.maximum.toString()}${c} ${a}${o}`:`${n.origin??"\uAC12"}\uC774 \uB108\uBB34 \uD07D\uB2C8\uB2E4: ${n.maximum.toString()} ${a}${o}`}case"too_small":{let a=n.inclusive?"\uC774\uC0C1":"\uCD08\uACFC",o=a==="\uC774\uC0C1"?"\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4":"\uC5EC\uC57C \uD569\uB2C8\uB2E4",s=t(n.origin),c=s?.unit??"\uC694\uC18C";return s?`${n.origin??"\uAC12"}\uC774 \uB108\uBB34 \uC791\uC2B5\uB2C8\uB2E4: ${n.minimum.toString()}${c} ${a}${o}`:`${n.origin??"\uAC12"}\uC774 \uB108\uBB34 \uC791\uC2B5\uB2C8\uB2E4: ${n.minimum.toString()} ${a}${o}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${a.prefix}"(\uC73C)\uB85C \uC2DC\uC791\uD574\uC57C \uD569\uB2C8\uB2E4`:a.format==="ends_with"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${a.suffix}"(\uC73C)\uB85C \uB05D\uB098\uC57C \uD569\uB2C8\uB2E4`:a.format==="includes"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${a.includes}"\uC744(\uB97C) \uD3EC\uD568\uD574\uC57C \uD569\uB2C8\uB2E4`:a.format==="regex"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: \uC815\uADDC\uC2DD ${a.pattern} \uD328\uD134\uACFC \uC77C\uCE58\uD574\uC57C \uD569\uB2C8\uB2E4`:`\uC798\uBABB\uB41C ${r[a.format]??n.format}`}case"not_multiple_of":return`\uC798\uBABB\uB41C \uC22B\uC790: ${n.divisor}\uC758 \uBC30\uC218\uC5EC\uC57C \uD569\uB2C8\uB2E4`;case"unrecognized_keys":return`\uC778\uC2DD\uD560 \uC218 \uC5C6\uB294 \uD0A4: ${I(n.keys,", ")}`;case"invalid_key":return`\uC798\uBABB\uB41C \uD0A4: ${n.origin}`;case"invalid_union":return"\uC798\uBABB\uB41C \uC785\uB825";case"invalid_element":return`\uC798\uBABB\uB41C \uAC12: ${n.origin}`;default:return"\uC798\uBABB\uB41C \uC785\uB825"}}};function QT(){return{localeError:KU()}}var $l=e=>e.charAt(0).toUpperCase()+e.slice(1);function eC(e){let t=Math.abs(e),r=t%10,i=t%100;return i>=11&&i<=19||r===0?"many":r===1?"one":"few"}var qU=()=>{let e={string:{unit:{one:"simbolis",few:"simboliai",many:"simboli\u0173"},verb:{smaller:{inclusive:"turi b\u016Bti ne ilgesn\u0117 kaip",notInclusive:"turi b\u016Bti trumpesn\u0117 kaip"},bigger:{inclusive:"turi b\u016Bti ne trumpesn\u0117 kaip",notInclusive:"turi b\u016Bti ilgesn\u0117 kaip"}}},file:{unit:{one:"baitas",few:"baitai",many:"bait\u0173"},verb:{smaller:{inclusive:"turi b\u016Bti ne didesnis kaip",notInclusive:"turi b\u016Bti ma\u017Eesnis kaip"},bigger:{inclusive:"turi b\u016Bti ne ma\u017Eesnis kaip",notInclusive:"turi b\u016Bti didesnis kaip"}}},array:{unit:{one:"element\u0105",few:"elementus",many:"element\u0173"},verb:{smaller:{inclusive:"turi tur\u0117ti ne daugiau kaip",notInclusive:"turi tur\u0117ti ma\u017Eiau kaip"},bigger:{inclusive:"turi tur\u0117ti ne ma\u017Eiau kaip",notInclusive:"turi tur\u0117ti daugiau kaip"}}},set:{unit:{one:"element\u0105",few:"elementus",many:"element\u0173"},verb:{smaller:{inclusive:"turi tur\u0117ti ne daugiau kaip",notInclusive:"turi tur\u0117ti ma\u017Eiau kaip"},bigger:{inclusive:"turi tur\u0117ti ne ma\u017Eiau kaip",notInclusive:"turi tur\u0117ti daugiau kaip"}}}};function t(n,a,o,s){let c=e[n]??null;return c===null?c:{unit:c.unit[a],verb:c.verb[s][o?"inclusive":"notInclusive"]}}let r={regex:"\u012Fvestis",email:"el. pa\u0161to adresas",url:"URL",emoji:"jaustukas",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO data ir laikas",date:"ISO data",time:"ISO laikas",duration:"ISO trukm\u0117",ipv4:"IPv4 adresas",ipv6:"IPv6 adresas",cidrv4:"IPv4 tinklo prefiksas (CIDR)",cidrv6:"IPv6 tinklo prefiksas (CIDR)",base64:"base64 u\u017Ekoduota eilut\u0117",base64url:"base64url u\u017Ekoduota eilut\u0117",json_string:"JSON eilut\u0117",e164:"E.164 numeris",jwt:"JWT",template_literal:"\u012Fvestis"},i={nan:"NaN",number:"skai\u010Dius",bigint:"sveikasis skai\u010Dius",string:"eilut\u0117",boolean:"login\u0117 reik\u0161m\u0117",undefined:"neapibr\u0117\u017Eta reik\u0161m\u0117",function:"funkcija",symbol:"simbolis",array:"masyvas",object:"objektas",null:"nulin\u0117 reik\u0161m\u0117"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Gautas tipas ${s}, o tik\u0117tasi - instanceof ${n.expected}`:`Gautas tipas ${s}, o tik\u0117tasi - ${a}`}case"invalid_value":return n.values.length===1?`Privalo b\u016Bti ${R(n.values[0])}`:`Privalo b\u016Bti vienas i\u0161 ${I(n.values,"|")} pasirinkim\u0173`;case"too_big":{let a=i[n.origin]??n.origin,o=t(n.origin,eC(Number(n.maximum)),n.inclusive??!1,"smaller");if(o?.verb)return`${$l(a??n.origin??"reik\u0161m\u0117")} ${o.verb} ${n.maximum.toString()} ${o.unit??"element\u0173"}`;let s=n.inclusive?"ne didesnis kaip":"ma\u017Eesnis kaip";return`${$l(a??n.origin??"reik\u0161m\u0117")} turi b\u016Bti ${s} ${n.maximum.toString()} ${o?.unit}`}case"too_small":{let a=i[n.origin]??n.origin,o=t(n.origin,eC(Number(n.minimum)),n.inclusive??!1,"bigger");if(o?.verb)return`${$l(a??n.origin??"reik\u0161m\u0117")} ${o.verb} ${n.minimum.toString()} ${o.unit??"element\u0173"}`;let s=n.inclusive?"ne ma\u017Eesnis kaip":"didesnis kaip";return`${$l(a??n.origin??"reik\u0161m\u0117")} turi b\u016Bti ${s} ${n.minimum.toString()} ${o?.unit}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Eilut\u0117 privalo prasid\u0117ti "${a.prefix}"`:a.format==="ends_with"?`Eilut\u0117 privalo pasibaigti "${a.suffix}"`:a.format==="includes"?`Eilut\u0117 privalo \u012Ftraukti "${a.includes}"`:a.format==="regex"?`Eilut\u0117 privalo atitikti ${a.pattern}`:`Neteisingas ${r[a.format]??n.format}`}case"not_multiple_of":return`Skai\u010Dius privalo b\u016Bti ${n.divisor} kartotinis.`;case"unrecognized_keys":return`Neatpa\u017Eint${n.keys.length>1?"i":"as"} rakt${n.keys.length>1?"ai":"as"}: ${I(n.keys,", ")}`;case"invalid_key":return"Rastas klaidingas raktas";case"invalid_union":return"Klaidinga \u012Fvestis";case"invalid_element":{let a=i[n.origin]??n.origin;return`${$l(a??n.origin??"reik\u0161m\u0117")} turi klaiding\u0105 \u012Fvest\u012F`}default:return"Klaidinga \u012Fvestis"}}};function tC(){return{localeError:qU()}}var XU=()=>{let e={string:{unit:"\u0437\u043D\u0430\u0446\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},file:{unit:"\u0431\u0430\u0458\u0442\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},array:{unit:"\u0441\u0442\u0430\u0432\u043A\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},set:{unit:"\u0441\u0442\u0430\u0432\u043A\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"}};function t(n){return e[n]??null}let r={regex:"\u0432\u043D\u0435\u0441",email:"\u0430\u0434\u0440\u0435\u0441\u0430 \u043D\u0430 \u0435-\u043F\u043E\u0448\u0442\u0430",url:"URL",emoji:"\u0435\u043C\u043E\u045F\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0443\u043C \u0438 \u0432\u0440\u0435\u043C\u0435",date:"ISO \u0434\u0430\u0442\u0443\u043C",time:"ISO \u0432\u0440\u0435\u043C\u0435",duration:"ISO \u0432\u0440\u0435\u043C\u0435\u0442\u0440\u0430\u0435\u045A\u0435",ipv4:"IPv4 \u0430\u0434\u0440\u0435\u0441\u0430",ipv6:"IPv6 \u0430\u0434\u0440\u0435\u0441\u0430",cidrv4:"IPv4 \u043E\u043F\u0441\u0435\u0433",cidrv6:"IPv6 \u043E\u043F\u0441\u0435\u0433",base64:"base64-\u0435\u043D\u043A\u043E\u0434\u0438\u0440\u0430\u043D\u0430 \u043D\u0438\u0437\u0430",base64url:"base64url-\u0435\u043D\u043A\u043E\u0434\u0438\u0440\u0430\u043D\u0430 \u043D\u0438\u0437\u0430",json_string:"JSON \u043D\u0438\u0437\u0430",e164:"E.164 \u0431\u0440\u043E\u0458",jwt:"JWT",template_literal:"\u0432\u043D\u0435\u0441"},i={nan:"NaN",number:"\u0431\u0440\u043E\u0458",array:"\u043D\u0438\u0437\u0430"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 instanceof ${n.expected}, \u043F\u0440\u0438\u043C\u0435\u043D\u043E ${s}`:`\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${a}, \u043F\u0440\u0438\u043C\u0435\u043D\u043E ${s}`}case"invalid_value":return n.values.length===1?`Invalid input: expected ${R(n.values[0])}`:`\u0413\u0440\u0435\u0448\u0430\u043D\u0430 \u043E\u043F\u0446\u0438\u0458\u0430: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 \u0435\u0434\u043D\u0430 ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u0433\u043E\u043B\u0435\u043C: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${n.origin??"\u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442\u0430"} \u0434\u0430 \u0438\u043C\u0430 ${a}${n.maximum.toString()} ${o.unit??"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0438"}`:`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u0433\u043E\u043B\u0435\u043C: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${n.origin??"\u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442\u0430"} \u0434\u0430 \u0431\u0438\u0434\u0435 ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u043C\u0430\u043B: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${n.origin} \u0434\u0430 \u0438\u043C\u0430 ${a}${n.minimum.toString()} ${o.unit}`:`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u043C\u0430\u043B: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${n.origin} \u0434\u0430 \u0431\u0438\u0434\u0435 ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0437\u0430\u043F\u043E\u0447\u043D\u0443\u0432\u0430 \u0441\u043E "${a.prefix}"`:a.format==="ends_with"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0437\u0430\u0432\u0440\u0448\u0443\u0432\u0430 \u0441\u043E "${a.suffix}"`:a.format==="includes"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0432\u043A\u043B\u0443\u0447\u0443\u0432\u0430 "${a.includes}"`:a.format==="regex"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u043E\u0434\u0433\u043E\u0430\u0440\u0430 \u043D\u0430 \u043F\u0430\u0442\u0435\u0440\u043D\u043E\u0442 ${a.pattern}`:`Invalid ${r[a.format]??n.format}`}case"not_multiple_of":return`\u0413\u0440\u0435\u0448\u0435\u043D \u0431\u0440\u043E\u0458: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0431\u0438\u0434\u0435 \u0434\u0435\u043B\u0438\u0432 \u0441\u043E ${n.divisor}`;case"unrecognized_keys":return`${n.keys.length>1?"\u041D\u0435\u043F\u0440\u0435\u043F\u043E\u0437\u043D\u0430\u0435\u043D\u0438 \u043A\u043B\u0443\u0447\u0435\u0432\u0438":"\u041D\u0435\u043F\u0440\u0435\u043F\u043E\u0437\u043D\u0430\u0435\u043D \u043A\u043B\u0443\u0447"}: ${I(n.keys,", ")}`;case"invalid_key":return`\u0413\u0440\u0435\u0448\u0435\u043D \u043A\u043B\u0443\u0447 \u0432\u043E ${n.origin}`;case"invalid_union":return"\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441";case"invalid_element":return`\u0413\u0440\u0435\u0448\u043D\u0430 \u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442 \u0432\u043E ${n.origin}`;default:return"\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441"}}};function rC(){return{localeError:XU()}}var YU=()=>{let e={string:{unit:"aksara",verb:"mempunyai"},file:{unit:"bait",verb:"mempunyai"},array:{unit:"elemen",verb:"mempunyai"},set:{unit:"elemen",verb:"mempunyai"}};function t(n){return e[n]??null}let r={regex:"input",email:"alamat e-mel",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"tarikh masa ISO",date:"tarikh ISO",time:"masa ISO",duration:"tempoh ISO",ipv4:"alamat IPv4",ipv6:"alamat IPv6",cidrv4:"julat IPv4",cidrv6:"julat IPv6",base64:"string dikodkan base64",base64url:"string dikodkan base64url",json_string:"string JSON",e164:"nombor E.164",jwt:"JWT",template_literal:"input"},i={nan:"NaN",number:"nombor"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Input tidak sah: dijangka instanceof ${n.expected}, diterima ${s}`:`Input tidak sah: dijangka ${a}, diterima ${s}`}case"invalid_value":return n.values.length===1?`Input tidak sah: dijangka ${R(n.values[0])}`:`Pilihan tidak sah: dijangka salah satu daripada ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`Terlalu besar: dijangka ${n.origin??"nilai"} ${o.verb} ${a}${n.maximum.toString()} ${o.unit??"elemen"}`:`Terlalu besar: dijangka ${n.origin??"nilai"} adalah ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`Terlalu kecil: dijangka ${n.origin} ${o.verb} ${a}${n.minimum.toString()} ${o.unit}`:`Terlalu kecil: dijangka ${n.origin} adalah ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`String tidak sah: mesti bermula dengan "${a.prefix}"`:a.format==="ends_with"?`String tidak sah: mesti berakhir dengan "${a.suffix}"`:a.format==="includes"?`String tidak sah: mesti mengandungi "${a.includes}"`:a.format==="regex"?`String tidak sah: mesti sepadan dengan corak ${a.pattern}`:`${r[a.format]??n.format} tidak sah`}case"not_multiple_of":return`Nombor tidak sah: perlu gandaan ${n.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali: ${I(n.keys,", ")}`;case"invalid_key":return`Kunci tidak sah dalam ${n.origin}`;case"invalid_union":return"Input tidak sah";case"invalid_element":return`Nilai tidak sah dalam ${n.origin}`;default:return"Input tidak sah"}}};function nC(){return{localeError:YU()}}var QU=()=>{let e={string:{unit:"tekens",verb:"heeft"},file:{unit:"bytes",verb:"heeft"},array:{unit:"elementen",verb:"heeft"},set:{unit:"elementen",verb:"heeft"}};function t(n){return e[n]??null}let r={regex:"invoer",email:"emailadres",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum en tijd",date:"ISO datum",time:"ISO tijd",duration:"ISO duur",ipv4:"IPv4-adres",ipv6:"IPv6-adres",cidrv4:"IPv4-bereik",cidrv6:"IPv6-bereik",base64:"base64-gecodeerde tekst",base64url:"base64 URL-gecodeerde tekst",json_string:"JSON string",e164:"E.164-nummer",jwt:"JWT",template_literal:"invoer"},i={nan:"NaN",number:"getal"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Ongeldige invoer: verwacht instanceof ${n.expected}, ontving ${s}`:`Ongeldige invoer: verwacht ${a}, ontving ${s}`}case"invalid_value":return n.values.length===1?`Ongeldige invoer: verwacht ${R(n.values[0])}`:`Ongeldige optie: verwacht \xE9\xE9n van ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin),s=n.origin==="date"?"laat":n.origin==="string"?"lang":"groot";return o?`Te ${s}: verwacht dat ${n.origin??"waarde"} ${a}${n.maximum.toString()} ${o.unit??"elementen"} ${o.verb}`:`Te ${s}: verwacht dat ${n.origin??"waarde"} ${a}${n.maximum.toString()} is`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin),s=n.origin==="date"?"vroeg":n.origin==="string"?"kort":"klein";return o?`Te ${s}: verwacht dat ${n.origin} ${a}${n.minimum.toString()} ${o.unit} ${o.verb}`:`Te ${s}: verwacht dat ${n.origin} ${a}${n.minimum.toString()} is`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Ongeldige tekst: moet met "${a.prefix}" beginnen`:a.format==="ends_with"?`Ongeldige tekst: moet op "${a.suffix}" eindigen`:a.format==="includes"?`Ongeldige tekst: moet "${a.includes}" bevatten`:a.format==="regex"?`Ongeldige tekst: moet overeenkomen met patroon ${a.pattern}`:`Ongeldig: ${r[a.format]??n.format}`}case"not_multiple_of":return`Ongeldig getal: moet een veelvoud van ${n.divisor} zijn`;case"unrecognized_keys":return`Onbekende key${n.keys.length>1?"s":""}: ${I(n.keys,", ")}`;case"invalid_key":return`Ongeldige key in ${n.origin}`;case"invalid_union":return"Ongeldige invoer";case"invalid_element":return`Ongeldige waarde in ${n.origin}`;default:return"Ongeldige invoer"}}};function iC(){return{localeError:QU()}}var e2=()=>{let e={string:{unit:"tegn",verb:"\xE5 ha"},file:{unit:"bytes",verb:"\xE5 ha"},array:{unit:"elementer",verb:"\xE5 inneholde"},set:{unit:"elementer",verb:"\xE5 inneholde"}};function t(n){return e[n]??null}let r={regex:"input",email:"e-postadresse",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dato- og klokkeslett",date:"ISO-dato",time:"ISO-klokkeslett",duration:"ISO-varighet",ipv4:"IPv4-omr\xE5de",ipv6:"IPv6-omr\xE5de",cidrv4:"IPv4-spekter",cidrv6:"IPv6-spekter",base64:"base64-enkodet streng",base64url:"base64url-enkodet streng",json_string:"JSON-streng",e164:"E.164-nummer",jwt:"JWT",template_literal:"input"},i={nan:"NaN",number:"tall",array:"liste"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Ugyldig input: forventet instanceof ${n.expected}, fikk ${s}`:`Ugyldig input: forventet ${a}, fikk ${s}`}case"invalid_value":return n.values.length===1?`Ugyldig verdi: forventet ${R(n.values[0])}`:`Ugyldig valg: forventet en av ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`For stor(t): forventet ${n.origin??"value"} til \xE5 ha ${a}${n.maximum.toString()} ${o.unit??"elementer"}`:`For stor(t): forventet ${n.origin??"value"} til \xE5 ha ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`For lite(n): forventet ${n.origin} til \xE5 ha ${a}${n.minimum.toString()} ${o.unit}`:`For lite(n): forventet ${n.origin} til \xE5 ha ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Ugyldig streng: m\xE5 starte med "${a.prefix}"`:a.format==="ends_with"?`Ugyldig streng: m\xE5 ende med "${a.suffix}"`:a.format==="includes"?`Ugyldig streng: m\xE5 inneholde "${a.includes}"`:a.format==="regex"?`Ugyldig streng: m\xE5 matche m\xF8nsteret ${a.pattern}`:`Ugyldig ${r[a.format]??n.format}`}case"not_multiple_of":return`Ugyldig tall: m\xE5 v\xE6re et multiplum av ${n.divisor}`;case"unrecognized_keys":return`${n.keys.length>1?"Ukjente n\xF8kler":"Ukjent n\xF8kkel"}: ${I(n.keys,", ")}`;case"invalid_key":return`Ugyldig n\xF8kkel i ${n.origin}`;case"invalid_union":return"Ugyldig input";case"invalid_element":return`Ugyldig verdi i ${n.origin}`;default:return"Ugyldig input"}}};function aC(){return{localeError:e2()}}var t2=()=>{let e={string:{unit:"harf",verb:"olmal\u0131d\u0131r"},file:{unit:"bayt",verb:"olmal\u0131d\u0131r"},array:{unit:"unsur",verb:"olmal\u0131d\u0131r"},set:{unit:"unsur",verb:"olmal\u0131d\u0131r"}};function t(n){return e[n]??null}let r={regex:"giren",email:"epostag\xE2h",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO heng\xE2m\u0131",date:"ISO tarihi",time:"ISO zaman\u0131",duration:"ISO m\xFCddeti",ipv4:"IPv4 ni\u015F\xE2n\u0131",ipv6:"IPv6 ni\u015F\xE2n\u0131",cidrv4:"IPv4 menzili",cidrv6:"IPv6 menzili",base64:"base64-\u015Fifreli metin",base64url:"base64url-\u015Fifreli metin",json_string:"JSON metin",e164:"E.164 say\u0131s\u0131",jwt:"JWT",template_literal:"giren"},i={nan:"NaN",number:"numara",array:"saf",null:"gayb"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`F\xE2sit giren: umulan instanceof ${n.expected}, al\u0131nan ${s}`:`F\xE2sit giren: umulan ${a}, al\u0131nan ${s}`}case"invalid_value":return n.values.length===1?`F\xE2sit giren: umulan ${R(n.values[0])}`:`F\xE2sit tercih: m\xFBteberler ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`Fazla b\xFCy\xFCk: ${n.origin??"value"}, ${a}${n.maximum.toString()} ${o.unit??"elements"} sahip olmal\u0131yd\u0131.`:`Fazla b\xFCy\xFCk: ${n.origin??"value"}, ${a}${n.maximum.toString()} olmal\u0131yd\u0131.`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`Fazla k\xFC\xE7\xFCk: ${n.origin}, ${a}${n.minimum.toString()} ${o.unit} sahip olmal\u0131yd\u0131.`:`Fazla k\xFC\xE7\xFCk: ${n.origin}, ${a}${n.minimum.toString()} olmal\u0131yd\u0131.`}case"invalid_format":{let a=n;return a.format==="starts_with"?`F\xE2sit metin: "${a.prefix}" ile ba\u015Flamal\u0131.`:a.format==="ends_with"?`F\xE2sit metin: "${a.suffix}" ile bitmeli.`:a.format==="includes"?`F\xE2sit metin: "${a.includes}" ihtiv\xE2 etmeli.`:a.format==="regex"?`F\xE2sit metin: ${a.pattern} nak\u015F\u0131na uymal\u0131.`:`F\xE2sit ${r[a.format]??n.format}`}case"not_multiple_of":return`F\xE2sit say\u0131: ${n.divisor} kat\u0131 olmal\u0131yd\u0131.`;case"unrecognized_keys":return`Tan\u0131nmayan anahtar ${n.keys.length>1?"s":""}: ${I(n.keys,", ")}`;case"invalid_key":return`${n.origin} i\xE7in tan\u0131nmayan anahtar var.`;case"invalid_union":return"Giren tan\u0131namad\u0131.";case"invalid_element":return`${n.origin} i\xE7in tan\u0131nmayan k\u0131ymet var.`;default:return"K\u0131ymet tan\u0131namad\u0131."}}};function oC(){return{localeError:t2()}}var r2=()=>{let e={string:{unit:"\u062A\u0648\u06A9\u064A",verb:"\u0648\u0644\u0631\u064A"},file:{unit:"\u0628\u0627\u06CC\u067C\u0633",verb:"\u0648\u0644\u0631\u064A"},array:{unit:"\u062A\u0648\u06A9\u064A",verb:"\u0648\u0644\u0631\u064A"},set:{unit:"\u062A\u0648\u06A9\u064A",verb:"\u0648\u0644\u0631\u064A"}};function t(n){return e[n]??null}let r={regex:"\u0648\u0631\u0648\u062F\u064A",email:"\u0628\u0631\u06CC\u069A\u0646\u0627\u0644\u06CC\u06A9",url:"\u06CC\u0648 \u0622\u0631 \u0627\u0644",emoji:"\u0627\u06CC\u0645\u0648\u062C\u064A",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0646\u06CC\u067C\u0647 \u0627\u0648 \u0648\u062E\u062A",date:"\u0646\u06D0\u067C\u0647",time:"\u0648\u062E\u062A",duration:"\u0645\u0648\u062F\u0647",ipv4:"\u062F IPv4 \u067E\u062A\u0647",ipv6:"\u062F IPv6 \u067E\u062A\u0647",cidrv4:"\u062F IPv4 \u0633\u0627\u062D\u0647",cidrv6:"\u062F IPv6 \u0633\u0627\u062D\u0647",base64:"base64-encoded \u0645\u062A\u0646",base64url:"base64url-encoded \u0645\u062A\u0646",json_string:"JSON \u0645\u062A\u0646",e164:"\u062F E.164 \u0634\u0645\u06D0\u0631\u0647",jwt:"JWT",template_literal:"\u0648\u0631\u0648\u062F\u064A"},i={nan:"NaN",number:"\u0639\u062F\u062F",array:"\u0627\u0631\u06D0"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F instanceof ${n.expected} \u0648\u0627\u06CC, \u0645\u06AB\u0631 ${s} \u062A\u0631\u0644\u0627\u0633\u0647 \u0634\u0648`:`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F ${a} \u0648\u0627\u06CC, \u0645\u06AB\u0631 ${s} \u062A\u0631\u0644\u0627\u0633\u0647 \u0634\u0648`}case"invalid_value":return n.values.length===1?`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F ${R(n.values[0])} \u0648\u0627\u06CC`:`\u0646\u0627\u0633\u0645 \u0627\u0646\u062A\u062E\u0627\u0628: \u0628\u0627\u06CC\u062F \u06CC\u0648 \u0644\u0647 ${I(n.values,"|")} \u0685\u062E\u0647 \u0648\u0627\u06CC`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`\u0689\u06CC\u0631 \u0644\u0648\u06CC: ${n.origin??"\u0627\u0631\u0632\u069A\u062A"} \u0628\u0627\u06CC\u062F ${a}${n.maximum.toString()} ${o.unit??"\u0639\u0646\u0635\u0631\u0648\u0646\u0647"} \u0648\u0644\u0631\u064A`:`\u0689\u06CC\u0631 \u0644\u0648\u06CC: ${n.origin??"\u0627\u0631\u0632\u069A\u062A"} \u0628\u0627\u06CC\u062F ${a}${n.maximum.toString()} \u0648\u064A`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`\u0689\u06CC\u0631 \u06A9\u0648\u0686\u0646\u06CC: ${n.origin} \u0628\u0627\u06CC\u062F ${a}${n.minimum.toString()} ${o.unit} \u0648\u0644\u0631\u064A`:`\u0689\u06CC\u0631 \u06A9\u0648\u0686\u0646\u06CC: ${n.origin} \u0628\u0627\u06CC\u062F ${a}${n.minimum.toString()} \u0648\u064A`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F "${a.prefix}" \u0633\u0631\u0647 \u067E\u06CC\u0644 \u0634\u064A`:a.format==="ends_with"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F "${a.suffix}" \u0633\u0631\u0647 \u067E\u0627\u06CC \u062A\u0647 \u0648\u0631\u0633\u064A\u0696\u064A`:a.format==="includes"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F "${a.includes}" \u0648\u0644\u0631\u064A`:a.format==="regex"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F ${a.pattern} \u0633\u0631\u0647 \u0645\u0637\u0627\u0628\u0642\u062A \u0648\u0644\u0631\u064A`:`${r[a.format]??n.format} \u0646\u0627\u0633\u0645 \u062F\u06CC`}case"not_multiple_of":return`\u0646\u0627\u0633\u0645 \u0639\u062F\u062F: \u0628\u0627\u06CC\u062F \u062F ${n.divisor} \u0645\u0636\u0631\u0628 \u0648\u064A`;case"unrecognized_keys":return`\u0646\u0627\u0633\u0645 ${n.keys.length>1?"\u06A9\u0644\u06CC\u0689\u0648\u0646\u0647":"\u06A9\u0644\u06CC\u0689"}: ${I(n.keys,", ")}`;case"invalid_key":return`\u0646\u0627\u0633\u0645 \u06A9\u0644\u06CC\u0689 \u067E\u0647 ${n.origin} \u06A9\u06D0`;case"invalid_union":return"\u0646\u0627\u0633\u0645\u0647 \u0648\u0631\u0648\u062F\u064A";case"invalid_element":return`\u0646\u0627\u0633\u0645 \u0639\u0646\u0635\u0631 \u067E\u0647 ${n.origin} \u06A9\u06D0`;default:return"\u0646\u0627\u0633\u0645\u0647 \u0648\u0631\u0648\u062F\u064A"}}};function sC(){return{localeError:r2()}}var n2=()=>{let e={string:{unit:"znak\xF3w",verb:"mie\u0107"},file:{unit:"bajt\xF3w",verb:"mie\u0107"},array:{unit:"element\xF3w",verb:"mie\u0107"},set:{unit:"element\xF3w",verb:"mie\u0107"}};function t(n){return e[n]??null}let r={regex:"wyra\u017Cenie",email:"adres email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data i godzina w formacie ISO",date:"data w formacie ISO",time:"godzina w formacie ISO",duration:"czas trwania ISO",ipv4:"adres IPv4",ipv6:"adres IPv6",cidrv4:"zakres IPv4",cidrv6:"zakres IPv6",base64:"ci\u0105g znak\xF3w zakodowany w formacie base64",base64url:"ci\u0105g znak\xF3w zakodowany w formacie base64url",json_string:"ci\u0105g znak\xF3w w formacie JSON",e164:"liczba E.164",jwt:"JWT",template_literal:"wej\u015Bcie"},i={nan:"NaN",number:"liczba",array:"tablica"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano instanceof ${n.expected}, otrzymano ${s}`:`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano ${a}, otrzymano ${s}`}case"invalid_value":return n.values.length===1?`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano ${R(n.values[0])}`:`Nieprawid\u0142owa opcja: oczekiwano jednej z warto\u015Bci ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`Za du\u017Ca warto\u015B\u0107: oczekiwano, \u017Ce ${n.origin??"warto\u015B\u0107"} b\u0119dzie mie\u0107 ${a}${n.maximum.toString()} ${o.unit??"element\xF3w"}`:`Zbyt du\u017C(y/a/e): oczekiwano, \u017Ce ${n.origin??"warto\u015B\u0107"} b\u0119dzie wynosi\u0107 ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`Za ma\u0142a warto\u015B\u0107: oczekiwano, \u017Ce ${n.origin??"warto\u015B\u0107"} b\u0119dzie mie\u0107 ${a}${n.minimum.toString()} ${o.unit??"element\xF3w"}`:`Zbyt ma\u0142(y/a/e): oczekiwano, \u017Ce ${n.origin??"warto\u015B\u0107"} b\u0119dzie wynosi\u0107 ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi zaczyna\u0107 si\u0119 od "${a.prefix}"`:a.format==="ends_with"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi ko\u0144czy\u0107 si\u0119 na "${a.suffix}"`:a.format==="includes"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi zawiera\u0107 "${a.includes}"`:a.format==="regex"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi odpowiada\u0107 wzorcowi ${a.pattern}`:`Nieprawid\u0142ow(y/a/e) ${r[a.format]??n.format}`}case"not_multiple_of":return`Nieprawid\u0142owa liczba: musi by\u0107 wielokrotno\u015Bci\u0105 ${n.divisor}`;case"unrecognized_keys":return`Nierozpoznane klucze${n.keys.length>1?"s":""}: ${I(n.keys,", ")}`;case"invalid_key":return`Nieprawid\u0142owy klucz w ${n.origin}`;case"invalid_union":return"Nieprawid\u0142owe dane wej\u015Bciowe";case"invalid_element":return`Nieprawid\u0142owa warto\u015B\u0107 w ${n.origin}`;default:return"Nieprawid\u0142owe dane wej\u015Bciowe"}}};function cC(){return{localeError:n2()}}var i2=()=>{let e={string:{unit:"caracteres",verb:"ter"},file:{unit:"bytes",verb:"ter"},array:{unit:"itens",verb:"ter"},set:{unit:"itens",verb:"ter"}};function t(n){return e[n]??null}let r={regex:"padr\xE3o",email:"endere\xE7o de e-mail",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data e hora ISO",date:"data ISO",time:"hora ISO",duration:"dura\xE7\xE3o ISO",ipv4:"endere\xE7o IPv4",ipv6:"endere\xE7o IPv6",cidrv4:"faixa de IPv4",cidrv6:"faixa de IPv6",base64:"texto codificado em base64",base64url:"URL codificada em base64",json_string:"texto JSON",e164:"n\xFAmero E.164",jwt:"JWT",template_literal:"entrada"},i={nan:"NaN",number:"n\xFAmero",null:"nulo"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Tipo inv\xE1lido: esperado instanceof ${n.expected}, recebido ${s}`:`Tipo inv\xE1lido: esperado ${a}, recebido ${s}`}case"invalid_value":return n.values.length===1?`Entrada inv\xE1lida: esperado ${R(n.values[0])}`:`Op\xE7\xE3o inv\xE1lida: esperada uma das ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`Muito grande: esperado que ${n.origin??"valor"} tivesse ${a}${n.maximum.toString()} ${o.unit??"elementos"}`:`Muito grande: esperado que ${n.origin??"valor"} fosse ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`Muito pequeno: esperado que ${n.origin} tivesse ${a}${n.minimum.toString()} ${o.unit}`:`Muito pequeno: esperado que ${n.origin} fosse ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Texto inv\xE1lido: deve come\xE7ar com "${a.prefix}"`:a.format==="ends_with"?`Texto inv\xE1lido: deve terminar com "${a.suffix}"`:a.format==="includes"?`Texto inv\xE1lido: deve incluir "${a.includes}"`:a.format==="regex"?`Texto inv\xE1lido: deve corresponder ao padr\xE3o ${a.pattern}`:`${r[a.format]??n.format} inv\xE1lido`}case"not_multiple_of":return`N\xFAmero inv\xE1lido: deve ser m\xFAltiplo de ${n.divisor}`;case"unrecognized_keys":return`Chave${n.keys.length>1?"s":""} desconhecida${n.keys.length>1?"s":""}: ${I(n.keys,", ")}`;case"invalid_key":return`Chave inv\xE1lida em ${n.origin}`;case"invalid_union":return"Entrada inv\xE1lida";case"invalid_element":return`Valor inv\xE1lido em ${n.origin}`;default:return"Campo inv\xE1lido"}}};function lC(){return{localeError:i2()}}var a2=()=>{let e={string:{unit:"caractere",verb:"s\u0103 aib\u0103"},file:{unit:"octe\u021Bi",verb:"s\u0103 aib\u0103"},array:{unit:"elemente",verb:"s\u0103 aib\u0103"},set:{unit:"elemente",verb:"s\u0103 aib\u0103"},map:{unit:"intr\u0103ri",verb:"s\u0103 aib\u0103"}};function t(n){return e[n]??null}let r={regex:"intrare",email:"adres\u0103 de email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"dat\u0103 \u0219i or\u0103 ISO",date:"dat\u0103 ISO",time:"or\u0103 ISO",duration:"durat\u0103 ISO",ipv4:"adres\u0103 IPv4",ipv6:"adres\u0103 IPv6",mac:"adres\u0103 MAC",cidrv4:"interval IPv4",cidrv6:"interval IPv6",base64:"\u0219ir codat base64",base64url:"\u0219ir codat base64url",json_string:"\u0219ir JSON",e164:"num\u0103r E.164",jwt:"JWT",template_literal:"intrare"},i={nan:"NaN",string:"\u0219ir",number:"num\u0103r",boolean:"boolean",function:"func\u021Bie",array:"matrice",object:"obiect",undefined:"nedefinit",symbol:"simbol",bigint:"num\u0103r mare",void:"void",never:"never",map:"hart\u0103",set:"set"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return`Intrare invalid\u0103: a\u0219teptat ${a}, primit ${s}`}case"invalid_value":return n.values.length===1?`Intrare invalid\u0103: a\u0219teptat ${R(n.values[0])}`:`Op\u021Biune invalid\u0103: a\u0219teptat una dintre ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`Prea mare: a\u0219teptat ca ${n.origin??"valoarea"} ${o.verb} ${a}${n.maximum.toString()} ${o.unit??"elemente"}`:`Prea mare: a\u0219teptat ca ${n.origin??"valoarea"} s\u0103 fie ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`Prea mic: a\u0219teptat ca ${n.origin} ${o.verb} ${a}${n.minimum.toString()} ${o.unit}`:`Prea mic: a\u0219teptat ca ${n.origin} s\u0103 fie ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\u0218ir invalid: trebuie s\u0103 \xEEnceap\u0103 cu "${a.prefix}"`:a.format==="ends_with"?`\u0218ir invalid: trebuie s\u0103 se termine cu "${a.suffix}"`:a.format==="includes"?`\u0218ir invalid: trebuie s\u0103 includ\u0103 "${a.includes}"`:a.format==="regex"?`\u0218ir invalid: trebuie s\u0103 se potriveasc\u0103 cu modelul ${a.pattern}`:`Format invalid: ${r[a.format]??n.format}`}case"not_multiple_of":return`Num\u0103r invalid: trebuie s\u0103 fie multiplu de ${n.divisor}`;case"unrecognized_keys":return`Chei nerecunoscute: ${I(n.keys,", ")}`;case"invalid_key":return`Cheie invalid\u0103 \xEEn ${n.origin}`;case"invalid_union":return"Intrare invalid\u0103";case"invalid_element":return`Valoare invalid\u0103 \xEEn ${n.origin}`;default:return"Intrare invalid\u0103"}}};function uC(){return{localeError:a2()}}function dC(e,t,r,i){let n=Math.abs(e),a=n%10,o=n%100;return o>=11&&o<=19?i:a===1?t:a>=2&&a<=4?r:i}var o2=()=>{let e={string:{unit:{one:"\u0441\u0438\u043C\u0432\u043E\u043B",few:"\u0441\u0438\u043C\u0432\u043E\u043B\u0430",many:"\u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"},file:{unit:{one:"\u0431\u0430\u0439\u0442",few:"\u0431\u0430\u0439\u0442\u0430",many:"\u0431\u0430\u0439\u0442"},verb:"\u0438\u043C\u0435\u0442\u044C"},array:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"},set:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"}};function t(n){return e[n]??null}let r={regex:"\u0432\u0432\u043E\u0434",email:"email \u0430\u0434\u0440\u0435\u0441",url:"URL",emoji:"\u044D\u043C\u043E\u0434\u0437\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0430 \u0438 \u0432\u0440\u0435\u043C\u044F",date:"ISO \u0434\u0430\u0442\u0430",time:"ISO \u0432\u0440\u0435\u043C\u044F",duration:"ISO \u0434\u043B\u0438\u0442\u0435\u043B\u044C\u043D\u043E\u0441\u0442\u044C",ipv4:"IPv4 \u0430\u0434\u0440\u0435\u0441",ipv6:"IPv6 \u0430\u0434\u0440\u0435\u0441",cidrv4:"IPv4 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",cidrv6:"IPv6 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",base64:"\u0441\u0442\u0440\u043E\u043A\u0430 \u0432 \u0444\u043E\u0440\u043C\u0430\u0442\u0435 base64",base64url:"\u0441\u0442\u0440\u043E\u043A\u0430 \u0432 \u0444\u043E\u0440\u043C\u0430\u0442\u0435 base64url",json_string:"JSON \u0441\u0442\u0440\u043E\u043A\u0430",e164:"\u043D\u043E\u043C\u0435\u0440 E.164",jwt:"JWT",template_literal:"\u0432\u0432\u043E\u0434"},i={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0441\u0438\u0432"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C instanceof ${n.expected}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D\u043E ${s}`:`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C ${a}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D\u043E ${s}`}case"invalid_value":return n.values.length===1?`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C ${R(n.values[0])}`:`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0430\u0440\u0438\u0430\u043D\u0442: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C \u043E\u0434\u043D\u043E \u0438\u0437 ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);if(o){let s=Number(n.maximum),c=dC(s,o.unit.one,o.unit.few,o.unit.many);return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u0431\u043E\u043B\u044C\u0448\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${n.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435"} \u0431\u0443\u0434\u0435\u0442 \u0438\u043C\u0435\u0442\u044C ${a}${n.maximum.toString()} ${c}`}return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u0431\u043E\u043B\u044C\u0448\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${n.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435"} \u0431\u0443\u0434\u0435\u0442 ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);if(o){let s=Number(n.minimum),c=dC(s,o.unit.one,o.unit.few,o.unit.many);return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u043C\u0430\u043B\u0435\u043D\u044C\u043A\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${n.origin} \u0431\u0443\u0434\u0435\u0442 \u0438\u043C\u0435\u0442\u044C ${a}${n.minimum.toString()} ${c}`}return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u043C\u0430\u043B\u0435\u043D\u044C\u043A\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${n.origin} \u0431\u0443\u0434\u0435\u0442 ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u043D\u0430\u0447\u0438\u043D\u0430\u0442\u044C\u0441\u044F \u0441 "${a.prefix}"`:a.format==="ends_with"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0437\u0430\u043A\u0430\u043D\u0447\u0438\u0432\u0430\u0442\u044C\u0441\u044F \u043D\u0430 "${a.suffix}"`:a.format==="includes"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0441\u043E\u0434\u0435\u0440\u0436\u0430\u0442\u044C "${a.includes}"`:a.format==="regex"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043E\u0432\u0430\u0442\u044C \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${a.pattern}`:`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 ${r[a.format]??n.format}`}case"not_multiple_of":return`\u041D\u0435\u0432\u0435\u0440\u043D\u043E\u0435 \u0447\u0438\u0441\u043B\u043E: \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u043A\u0440\u0430\u0442\u043D\u044B\u043C ${n.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0441\u043F\u043E\u0437\u043D\u0430\u043D\u043D${n.keys.length>1?"\u044B\u0435":"\u044B\u0439"} \u043A\u043B\u044E\u0447${n.keys.length>1?"\u0438":""}: ${I(n.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u043A\u043B\u044E\u0447 \u0432 ${n.origin}`;case"invalid_union":return"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0435 \u0432\u0445\u043E\u0434\u043D\u044B\u0435 \u0434\u0430\u043D\u043D\u044B\u0435";case"invalid_element":return`\u041D\u0435\u0432\u0435\u0440\u043D\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u0432 ${n.origin}`;default:return"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0435 \u0432\u0445\u043E\u0434\u043D\u044B\u0435 \u0434\u0430\u043D\u043D\u044B\u0435"}}};function fC(){return{localeError:o2()}}var s2=()=>{let e={string:{unit:"znakov",verb:"imeti"},file:{unit:"bajtov",verb:"imeti"},array:{unit:"elementov",verb:"imeti"},set:{unit:"elementov",verb:"imeti"}};function t(n){return e[n]??null}let r={regex:"vnos",email:"e-po\u0161tni naslov",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum in \u010Das",date:"ISO datum",time:"ISO \u010Das",duration:"ISO trajanje",ipv4:"IPv4 naslov",ipv6:"IPv6 naslov",cidrv4:"obseg IPv4",cidrv6:"obseg IPv6",base64:"base64 kodiran niz",base64url:"base64url kodiran niz",json_string:"JSON niz",e164:"E.164 \u0161tevilka",jwt:"JWT",template_literal:"vnos"},i={nan:"NaN",number:"\u0161tevilo",array:"tabela"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Neveljaven vnos: pri\u010Dakovano instanceof ${n.expected}, prejeto ${s}`:`Neveljaven vnos: pri\u010Dakovano ${a}, prejeto ${s}`}case"invalid_value":return n.values.length===1?`Neveljaven vnos: pri\u010Dakovano ${R(n.values[0])}`:`Neveljavna mo\u017Enost: pri\u010Dakovano eno izmed ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`Preveliko: pri\u010Dakovano, da bo ${n.origin??"vrednost"} imelo ${a}${n.maximum.toString()} ${o.unit??"elementov"}`:`Preveliko: pri\u010Dakovano, da bo ${n.origin??"vrednost"} ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`Premajhno: pri\u010Dakovano, da bo ${n.origin} imelo ${a}${n.minimum.toString()} ${o.unit}`:`Premajhno: pri\u010Dakovano, da bo ${n.origin} ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Neveljaven niz: mora se za\u010Deti z "${a.prefix}"`:a.format==="ends_with"?`Neveljaven niz: mora se kon\u010Dati z "${a.suffix}"`:a.format==="includes"?`Neveljaven niz: mora vsebovati "${a.includes}"`:a.format==="regex"?`Neveljaven niz: mora ustrezati vzorcu ${a.pattern}`:`Neveljaven ${r[a.format]??n.format}`}case"not_multiple_of":return`Neveljavno \u0161tevilo: mora biti ve\u010Dkratnik ${n.divisor}`;case"unrecognized_keys":return`Neprepoznan${n.keys.length>1?"i klju\u010Di":" klju\u010D"}: ${I(n.keys,", ")}`;case"invalid_key":return`Neveljaven klju\u010D v ${n.origin}`;case"invalid_union":return"Neveljaven vnos";case"invalid_element":return`Neveljavna vrednost v ${n.origin}`;default:return"Neveljaven vnos"}}};function pC(){return{localeError:s2()}}var c2=()=>{let e={string:{unit:"tecken",verb:"att ha"},file:{unit:"bytes",verb:"att ha"},array:{unit:"objekt",verb:"att inneh\xE5lla"},set:{unit:"objekt",verb:"att inneh\xE5lla"}};function t(n){return e[n]??null}let r={regex:"regulj\xE4rt uttryck",email:"e-postadress",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-datum och tid",date:"ISO-datum",time:"ISO-tid",duration:"ISO-varaktighet",ipv4:"IPv4-intervall",ipv6:"IPv6-intervall",cidrv4:"IPv4-spektrum",cidrv6:"IPv6-spektrum",base64:"base64-kodad str\xE4ng",base64url:"base64url-kodad str\xE4ng",json_string:"JSON-str\xE4ng",e164:"E.164-nummer",jwt:"JWT",template_literal:"mall-literal"},i={nan:"NaN",number:"antal",array:"lista"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Ogiltig inmatning: f\xF6rv\xE4ntat instanceof ${n.expected}, fick ${s}`:`Ogiltig inmatning: f\xF6rv\xE4ntat ${a}, fick ${s}`}case"invalid_value":return n.values.length===1?`Ogiltig inmatning: f\xF6rv\xE4ntat ${R(n.values[0])}`:`Ogiltigt val: f\xF6rv\xE4ntade en av ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`F\xF6r stor(t): f\xF6rv\xE4ntade ${n.origin??"v\xE4rdet"} att ha ${a}${n.maximum.toString()} ${o.unit??"element"}`:`F\xF6r stor(t): f\xF6rv\xE4ntat ${n.origin??"v\xE4rdet"} att ha ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`F\xF6r lite(t): f\xF6rv\xE4ntade ${n.origin??"v\xE4rdet"} att ha ${a}${n.minimum.toString()} ${o.unit}`:`F\xF6r lite(t): f\xF6rv\xE4ntade ${n.origin??"v\xE4rdet"} att ha ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Ogiltig str\xE4ng: m\xE5ste b\xF6rja med "${a.prefix}"`:a.format==="ends_with"?`Ogiltig str\xE4ng: m\xE5ste sluta med "${a.suffix}"`:a.format==="includes"?`Ogiltig str\xE4ng: m\xE5ste inneh\xE5lla "${a.includes}"`:a.format==="regex"?`Ogiltig str\xE4ng: m\xE5ste matcha m\xF6nstret "${a.pattern}"`:`Ogiltig(t) ${r[a.format]??n.format}`}case"not_multiple_of":return`Ogiltigt tal: m\xE5ste vara en multipel av ${n.divisor}`;case"unrecognized_keys":return`${n.keys.length>1?"Ok\xE4nda nycklar":"Ok\xE4nd nyckel"}: ${I(n.keys,", ")}`;case"invalid_key":return`Ogiltig nyckel i ${n.origin??"v\xE4rdet"}`;case"invalid_union":return"Ogiltig input";case"invalid_element":return`Ogiltigt v\xE4rde i ${n.origin??"v\xE4rdet"}`;default:return"Ogiltig input"}}};function mC(){return{localeError:c2()}}var l2=()=>{let e={string:{unit:"\u0B8E\u0BB4\u0BC1\u0BA4\u0BCD\u0BA4\u0BC1\u0B95\u0BCD\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},file:{unit:"\u0BAA\u0BC8\u0B9F\u0BCD\u0B9F\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},array:{unit:"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},set:{unit:"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"}};function t(n){return e[n]??null}let r={regex:"\u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1",email:"\u0BAE\u0BBF\u0BA9\u0BCD\u0BA9\u0B9E\u0BCD\u0B9A\u0BB2\u0BCD \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0BA4\u0BC7\u0BA4\u0BBF \u0BA8\u0BC7\u0BB0\u0BAE\u0BCD",date:"ISO \u0BA4\u0BC7\u0BA4\u0BBF",time:"ISO \u0BA8\u0BC7\u0BB0\u0BAE\u0BCD",duration:"ISO \u0B95\u0BBE\u0BB2 \u0B85\u0BB3\u0BB5\u0BC1",ipv4:"IPv4 \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",ipv6:"IPv6 \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",cidrv4:"IPv4 \u0BB5\u0BB0\u0BAE\u0BCD\u0BAA\u0BC1",cidrv6:"IPv6 \u0BB5\u0BB0\u0BAE\u0BCD\u0BAA\u0BC1",base64:"base64-encoded \u0B9A\u0BB0\u0BAE\u0BCD",base64url:"base64url-encoded \u0B9A\u0BB0\u0BAE\u0BCD",json_string:"JSON \u0B9A\u0BB0\u0BAE\u0BCD",e164:"E.164 \u0B8E\u0BA3\u0BCD",jwt:"JWT",template_literal:"input"},i={nan:"NaN",number:"\u0B8E\u0BA3\u0BCD",array:"\u0B85\u0BA3\u0BBF",null:"\u0BB5\u0BC6\u0BB1\u0BC1\u0BAE\u0BC8"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 instanceof ${n.expected}, \u0BAA\u0BC6\u0BB1\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${s}`:`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${a}, \u0BAA\u0BC6\u0BB1\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${s}`}case"invalid_value":return n.values.length===1?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${R(n.values[0])}`:`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0BB5\u0BBF\u0BB0\u0BC1\u0BAA\u0BCD\u0BAA\u0BAE\u0BCD: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${I(n.values,"|")} \u0B87\u0BB2\u0BCD \u0B92\u0BA9\u0BCD\u0BB1\u0BC1`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`\u0BAE\u0BBF\u0B95 \u0BAA\u0BC6\u0BB0\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${n.origin??"\u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1"} ${a}${n.maximum.toString()} ${o.unit??"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD"} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:`\u0BAE\u0BBF\u0B95 \u0BAA\u0BC6\u0BB0\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${n.origin??"\u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1"} ${a}${n.maximum.toString()} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`\u0BAE\u0BBF\u0B95\u0B9A\u0BCD \u0B9A\u0BBF\u0BB1\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${n.origin} ${a}${n.minimum.toString()} ${o.unit} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:`\u0BAE\u0BBF\u0B95\u0B9A\u0BCD \u0B9A\u0BBF\u0BB1\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${n.origin} ${a}${n.minimum.toString()} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${a.prefix}" \u0B87\u0BB2\u0BCD \u0BA4\u0BCA\u0B9F\u0B99\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:a.format==="ends_with"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${a.suffix}" \u0B87\u0BB2\u0BCD \u0BAE\u0BC1\u0B9F\u0BBF\u0BB5\u0B9F\u0BC8\u0BAF \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:a.format==="includes"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${a.includes}" \u0B90 \u0B89\u0BB3\u0BCD\u0BB3\u0B9F\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:a.format==="regex"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: ${a.pattern} \u0BAE\u0BC1\u0BB1\u0BC8\u0BAA\u0BBE\u0B9F\u0BCD\u0B9F\u0BC1\u0B9F\u0BA9\u0BCD \u0BAA\u0BCA\u0BB0\u0BC1\u0BA8\u0BCD\u0BA4 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 ${r[a.format]??n.format}`}case"not_multiple_of":return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B8E\u0BA3\u0BCD: ${n.divisor} \u0B87\u0BA9\u0BCD \u0BAA\u0BB2\u0BAE\u0BBE\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`;case"unrecognized_keys":return`\u0B85\u0B9F\u0BC8\u0BAF\u0BBE\u0BB3\u0BAE\u0BCD \u0BA4\u0BC6\u0BB0\u0BBF\u0BAF\u0BBE\u0BA4 \u0BB5\u0BBF\u0B9A\u0BC8${n.keys.length>1?"\u0B95\u0BB3\u0BCD":""}: ${I(n.keys,", ")}`;case"invalid_key":return`${n.origin} \u0B87\u0BB2\u0BCD \u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0BB5\u0BBF\u0B9A\u0BC8`;case"invalid_union":return"\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1";case"invalid_element":return`${n.origin} \u0B87\u0BB2\u0BCD \u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1`;default:return"\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1"}}};function hC(){return{localeError:l2()}}var u2=()=>{let e={string:{unit:"\u0E15\u0E31\u0E27\u0E2D\u0E31\u0E01\u0E29\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},file:{unit:"\u0E44\u0E1A\u0E15\u0E4C",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},array:{unit:"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},set:{unit:"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"}};function t(n){return e[n]??null}let r={regex:"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E1B\u0E49\u0E2D\u0E19",email:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48\u0E2D\u0E35\u0E40\u0E21\u0E25",url:"URL",emoji:"\u0E2D\u0E34\u0E42\u0E21\u0E08\u0E34",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",date:"\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48\u0E41\u0E1A\u0E1A ISO",time:"\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",duration:"\u0E0A\u0E48\u0E27\u0E07\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",ipv4:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48 IPv4",ipv6:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48 IPv6",cidrv4:"\u0E0A\u0E48\u0E27\u0E07 IP \u0E41\u0E1A\u0E1A IPv4",cidrv6:"\u0E0A\u0E48\u0E27\u0E07 IP \u0E41\u0E1A\u0E1A IPv6",base64:"\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E1A\u0E1A Base64",base64url:"\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E1A\u0E1A Base64 \u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A URL",json_string:"\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E1A\u0E1A JSON",e164:"\u0E40\u0E1A\u0E2D\u0E23\u0E4C\u0E42\u0E17\u0E23\u0E28\u0E31\u0E1E\u0E17\u0E4C\u0E23\u0E30\u0E2B\u0E27\u0E48\u0E32\u0E07\u0E1B\u0E23\u0E30\u0E40\u0E17\u0E28 (E.164)",jwt:"\u0E42\u0E17\u0E40\u0E04\u0E19 JWT",template_literal:"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E1B\u0E49\u0E2D\u0E19"},i={nan:"NaN",number:"\u0E15\u0E31\u0E27\u0E40\u0E25\u0E02",array:"\u0E2D\u0E32\u0E23\u0E4C\u0E40\u0E23\u0E22\u0E4C (Array)",null:"\u0E44\u0E21\u0E48\u0E21\u0E35\u0E04\u0E48\u0E32 (null)"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\u0E1B\u0E23\u0E30\u0E40\u0E20\u0E17\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 instanceof ${n.expected} \u0E41\u0E15\u0E48\u0E44\u0E14\u0E49\u0E23\u0E31\u0E1A ${s}`:`\u0E1B\u0E23\u0E30\u0E40\u0E20\u0E17\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 ${a} \u0E41\u0E15\u0E48\u0E44\u0E14\u0E49\u0E23\u0E31\u0E1A ${s}`}case"invalid_value":return n.values.length===1?`\u0E04\u0E48\u0E32\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 ${R(n.values[0])}`:`\u0E15\u0E31\u0E27\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19\u0E2B\u0E19\u0E36\u0E48\u0E07\u0E43\u0E19 ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"\u0E44\u0E21\u0E48\u0E40\u0E01\u0E34\u0E19":"\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32",o=t(n.origin);return o?`\u0E40\u0E01\u0E34\u0E19\u0E01\u0E33\u0E2B\u0E19\u0E14: ${n.origin??"\u0E04\u0E48\u0E32"} \u0E04\u0E27\u0E23\u0E21\u0E35${a} ${n.maximum.toString()} ${o.unit??"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23"}`:`\u0E40\u0E01\u0E34\u0E19\u0E01\u0E33\u0E2B\u0E19\u0E14: ${n.origin??"\u0E04\u0E48\u0E32"} \u0E04\u0E27\u0E23\u0E21\u0E35${a} ${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?"\u0E2D\u0E22\u0E48\u0E32\u0E07\u0E19\u0E49\u0E2D\u0E22":"\u0E21\u0E32\u0E01\u0E01\u0E27\u0E48\u0E32",o=t(n.origin);return o?`\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32\u0E01\u0E33\u0E2B\u0E19\u0E14: ${n.origin} \u0E04\u0E27\u0E23\u0E21\u0E35${a} ${n.minimum.toString()} ${o.unit}`:`\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32\u0E01\u0E33\u0E2B\u0E19\u0E14: ${n.origin} \u0E04\u0E27\u0E23\u0E21\u0E35${a} ${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E02\u0E36\u0E49\u0E19\u0E15\u0E49\u0E19\u0E14\u0E49\u0E27\u0E22 "${a.prefix}"`:a.format==="ends_with"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E25\u0E07\u0E17\u0E49\u0E32\u0E22\u0E14\u0E49\u0E27\u0E22 "${a.suffix}"`:a.format==="includes"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E21\u0E35 "${a.includes}" \u0E2D\u0E22\u0E39\u0E48\u0E43\u0E19\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21`:a.format==="regex"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E15\u0E49\u0E2D\u0E07\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E17\u0E35\u0E48\u0E01\u0E33\u0E2B\u0E19\u0E14 ${a.pattern}`:`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: ${r[a.format]??n.format}`}case"not_multiple_of":return`\u0E15\u0E31\u0E27\u0E40\u0E25\u0E02\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E08\u0E33\u0E19\u0E27\u0E19\u0E17\u0E35\u0E48\u0E2B\u0E32\u0E23\u0E14\u0E49\u0E27\u0E22 ${n.divisor} \u0E44\u0E14\u0E49\u0E25\u0E07\u0E15\u0E31\u0E27`;case"unrecognized_keys":return`\u0E1E\u0E1A\u0E04\u0E35\u0E22\u0E4C\u0E17\u0E35\u0E48\u0E44\u0E21\u0E48\u0E23\u0E39\u0E49\u0E08\u0E31\u0E01: ${I(n.keys,", ")}`;case"invalid_key":return`\u0E04\u0E35\u0E22\u0E4C\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E43\u0E19 ${n.origin}`;case"invalid_union":return"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E22\u0E39\u0E40\u0E19\u0E35\u0E22\u0E19\u0E17\u0E35\u0E48\u0E01\u0E33\u0E2B\u0E19\u0E14\u0E44\u0E27\u0E49";case"invalid_element":return`\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E43\u0E19 ${n.origin}`;default:return"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07"}}};function gC(){return{localeError:u2()}}var d2=()=>{let e={string:{unit:"karakter",verb:"olmal\u0131"},file:{unit:"bayt",verb:"olmal\u0131"},array:{unit:"\xF6\u011Fe",verb:"olmal\u0131"},set:{unit:"\xF6\u011Fe",verb:"olmal\u0131"}};function t(n){return e[n]??null}let r={regex:"girdi",email:"e-posta adresi",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO tarih ve saat",date:"ISO tarih",time:"ISO saat",duration:"ISO s\xFCre",ipv4:"IPv4 adresi",ipv6:"IPv6 adresi",cidrv4:"IPv4 aral\u0131\u011F\u0131",cidrv6:"IPv6 aral\u0131\u011F\u0131",base64:"base64 ile \u015Fifrelenmi\u015F metin",base64url:"base64url ile \u015Fifrelenmi\u015F metin",json_string:"JSON dizesi",e164:"E.164 say\u0131s\u0131",jwt:"JWT",template_literal:"\u015Eablon dizesi"},i={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Ge\xE7ersiz de\u011Fer: beklenen instanceof ${n.expected}, al\u0131nan ${s}`:`Ge\xE7ersiz de\u011Fer: beklenen ${a}, al\u0131nan ${s}`}case"invalid_value":return n.values.length===1?`Ge\xE7ersiz de\u011Fer: beklenen ${R(n.values[0])}`:`Ge\xE7ersiz se\xE7enek: a\u015Fa\u011F\u0131dakilerden biri olmal\u0131: ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`\xC7ok b\xFCy\xFCk: beklenen ${n.origin??"de\u011Fer"} ${a}${n.maximum.toString()} ${o.unit??"\xF6\u011Fe"}`:`\xC7ok b\xFCy\xFCk: beklenen ${n.origin??"de\u011Fer"} ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`\xC7ok k\xFC\xE7\xFCk: beklenen ${n.origin} ${a}${n.minimum.toString()} ${o.unit}`:`\xC7ok k\xFC\xE7\xFCk: beklenen ${n.origin} ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Ge\xE7ersiz metin: "${a.prefix}" ile ba\u015Flamal\u0131`:a.format==="ends_with"?`Ge\xE7ersiz metin: "${a.suffix}" ile bitmeli`:a.format==="includes"?`Ge\xE7ersiz metin: "${a.includes}" i\xE7ermeli`:a.format==="regex"?`Ge\xE7ersiz metin: ${a.pattern} desenine uymal\u0131`:`Ge\xE7ersiz ${r[a.format]??n.format}`}case"not_multiple_of":return`Ge\xE7ersiz say\u0131: ${n.divisor} ile tam b\xF6l\xFCnebilmeli`;case"unrecognized_keys":return`Tan\u0131nmayan anahtar${n.keys.length>1?"lar":""}: ${I(n.keys,", ")}`;case"invalid_key":return`${n.origin} i\xE7inde ge\xE7ersiz anahtar`;case"invalid_union":return"Ge\xE7ersiz de\u011Fer";case"invalid_element":return`${n.origin} i\xE7inde ge\xE7ersiz de\u011Fer`;default:return"Ge\xE7ersiz de\u011Fer"}}};function _C(){return{localeError:d2()}}var f2=()=>{let e={string:{unit:"\u0441\u0438\u043C\u0432\u043E\u043B\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},file:{unit:"\u0431\u0430\u0439\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},array:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},set:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"}};function t(n){return e[n]??null}let r={regex:"\u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456",email:"\u0430\u0434\u0440\u0435\u0441\u0430 \u0435\u043B\u0435\u043A\u0442\u0440\u043E\u043D\u043D\u043E\u0457 \u043F\u043E\u0448\u0442\u0438",url:"URL",emoji:"\u0435\u043C\u043E\u0434\u0437\u0456",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0434\u0430\u0442\u0430 \u0442\u0430 \u0447\u0430\u0441 ISO",date:"\u0434\u0430\u0442\u0430 ISO",time:"\u0447\u0430\u0441 ISO",duration:"\u0442\u0440\u0438\u0432\u0430\u043B\u0456\u0441\u0442\u044C ISO",ipv4:"\u0430\u0434\u0440\u0435\u0441\u0430 IPv4",ipv6:"\u0430\u0434\u0440\u0435\u0441\u0430 IPv6",cidrv4:"\u0434\u0456\u0430\u043F\u0430\u0437\u043E\u043D IPv4",cidrv6:"\u0434\u0456\u0430\u043F\u0430\u0437\u043E\u043D IPv6",base64:"\u0440\u044F\u0434\u043E\u043A \u0443 \u043A\u043E\u0434\u0443\u0432\u0430\u043D\u043D\u0456 base64",base64url:"\u0440\u044F\u0434\u043E\u043A \u0443 \u043A\u043E\u0434\u0443\u0432\u0430\u043D\u043D\u0456 base64url",json_string:"\u0440\u044F\u0434\u043E\u043A JSON",e164:"\u043D\u043E\u043C\u0435\u0440 E.164",jwt:"JWT",template_literal:"\u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456"},i={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0438\u0432"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F instanceof ${n.expected}, \u043E\u0442\u0440\u0438\u043C\u0430\u043D\u043E ${s}`:`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F ${a}, \u043E\u0442\u0440\u0438\u043C\u0430\u043D\u043E ${s}`}case"invalid_value":return n.values.length===1?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F ${R(n.values[0])}`:`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0430 \u043E\u043F\u0446\u0456\u044F: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F \u043E\u0434\u043D\u0435 \u0437 ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u0432\u0435\u043B\u0438\u043A\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${n.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F"} ${o.verb} ${a}${n.maximum.toString()} ${o.unit??"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432"}`:`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u0432\u0435\u043B\u0438\u043A\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${n.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F"} \u0431\u0443\u0434\u0435 ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u043C\u0430\u043B\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${n.origin} ${o.verb} ${a}${n.minimum.toString()} ${o.unit}`:`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u043C\u0430\u043B\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${n.origin} \u0431\u0443\u0434\u0435 ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u043F\u043E\u0447\u0438\u043D\u0430\u0442\u0438\u0441\u044F \u0437 "${a.prefix}"`:a.format==="ends_with"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u0437\u0430\u043A\u0456\u043D\u0447\u0443\u0432\u0430\u0442\u0438\u0441\u044F \u043D\u0430 "${a.suffix}"`:a.format==="includes"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u043C\u0456\u0441\u0442\u0438\u0442\u0438 "${a.includes}"`:a.format==="regex"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0442\u0438 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${a.pattern}`:`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 ${r[a.format]??n.format}`}case"not_multiple_of":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0435 \u0447\u0438\u0441\u043B\u043E: \u043F\u043E\u0432\u0438\u043D\u043D\u043E \u0431\u0443\u0442\u0438 \u043A\u0440\u0430\u0442\u043D\u0438\u043C ${n.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u043E\u0437\u043F\u0456\u0437\u043D\u0430\u043D\u0438\u0439 \u043A\u043B\u044E\u0447${n.keys.length>1?"\u0456":""}: ${I(n.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u043A\u043B\u044E\u0447 \u0443 ${n.origin}`;case"invalid_union":return"\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456";case"invalid_element":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F \u0443 ${n.origin}`;default:return"\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456"}}};function zf(){return{localeError:f2()}}function yC(){return zf()}var p2=()=>{let e={string:{unit:"\u062D\u0631\u0648\u0641",verb:"\u06C1\u0648\u0646\u0627"},file:{unit:"\u0628\u0627\u0626\u0679\u0633",verb:"\u06C1\u0648\u0646\u0627"},array:{unit:"\u0622\u0626\u0679\u0645\u0632",verb:"\u06C1\u0648\u0646\u0627"},set:{unit:"\u0622\u0626\u0679\u0645\u0632",verb:"\u06C1\u0648\u0646\u0627"}};function t(n){return e[n]??null}let r={regex:"\u0627\u0646 \u067E\u0679",email:"\u0627\u06CC \u0645\u06CC\u0644 \u0627\u06CC\u0688\u0631\u06CC\u0633",url:"\u06CC\u0648 \u0622\u0631 \u0627\u06CC\u0644",emoji:"\u0627\u06CC\u0645\u0648\u062C\u06CC",uuid:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",uuidv4:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC \u0648\u06CC 4",uuidv6:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC \u0648\u06CC 6",nanoid:"\u0646\u06CC\u0646\u0648 \u0622\u0626\u06CC \u0688\u06CC",guid:"\u062C\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",cuid:"\u0633\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",cuid2:"\u0633\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC 2",ulid:"\u06CC\u0648 \u0627\u06CC\u0644 \u0622\u0626\u06CC \u0688\u06CC",xid:"\u0627\u06CC\u06A9\u0633 \u0622\u0626\u06CC \u0688\u06CC",ksuid:"\u06A9\u06D2 \u0627\u06CC\u0633 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",datetime:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0688\u06CC\u0679 \u0679\u0627\u0626\u0645",date:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u062A\u0627\u0631\u06CC\u062E",time:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0648\u0642\u062A",duration:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0645\u062F\u062A",ipv4:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 4 \u0627\u06CC\u0688\u0631\u06CC\u0633",ipv6:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 6 \u0627\u06CC\u0688\u0631\u06CC\u0633",cidrv4:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 4 \u0631\u06CC\u0646\u062C",cidrv6:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 6 \u0631\u06CC\u0646\u062C",base64:"\u0628\u06CC\u0633 64 \u0627\u0646 \u06A9\u0648\u0688\u0688 \u0633\u0679\u0631\u0646\u06AF",base64url:"\u0628\u06CC\u0633 64 \u06CC\u0648 \u0622\u0631 \u0627\u06CC\u0644 \u0627\u0646 \u06A9\u0648\u0688\u0688 \u0633\u0679\u0631\u0646\u06AF",json_string:"\u062C\u06D2 \u0627\u06CC\u0633 \u0627\u0648 \u0627\u06CC\u0646 \u0633\u0679\u0631\u0646\u06AF",e164:"\u0627\u06CC 164 \u0646\u0645\u0628\u0631",jwt:"\u062C\u06D2 \u0688\u0628\u0644\u06CC\u0648 \u0679\u06CC",template_literal:"\u0627\u0646 \u067E\u0679"},i={nan:"NaN",number:"\u0646\u0645\u0628\u0631",array:"\u0622\u0631\u06D2",null:"\u0646\u0644"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: instanceof ${n.expected} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627\u060C ${s} \u0645\u0648\u0635\u0648\u0644 \u06C1\u0648\u0627`:`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: ${a} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627\u060C ${s} \u0645\u0648\u0635\u0648\u0644 \u06C1\u0648\u0627`}case"invalid_value":return n.values.length===1?`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: ${R(n.values[0])} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`:`\u063A\u0644\u0637 \u0622\u067E\u0634\u0646: ${I(n.values,"|")} \u0645\u06CC\u06BA \u0633\u06D2 \u0627\u06CC\u06A9 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`\u0628\u06C1\u062A \u0628\u0691\u0627: ${n.origin??"\u0648\u06CC\u0644\u06CC\u0648"} \u06A9\u06D2 ${a}${n.maximum.toString()} ${o.unit??"\u0639\u0646\u0627\u0635\u0631"} \u06C1\u0648\u0646\u06D2 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u06D2`:`\u0628\u06C1\u062A \u0628\u0691\u0627: ${n.origin??"\u0648\u06CC\u0644\u06CC\u0648"} \u06A9\u0627 ${a}${n.maximum.toString()} \u06C1\u0648\u0646\u0627 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`\u0628\u06C1\u062A \u0686\u06BE\u0648\u0679\u0627: ${n.origin} \u06A9\u06D2 ${a}${n.minimum.toString()} ${o.unit} \u06C1\u0648\u0646\u06D2 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u06D2`:`\u0628\u06C1\u062A \u0686\u06BE\u0648\u0679\u0627: ${n.origin} \u06A9\u0627 ${a}${n.minimum.toString()} \u06C1\u0648\u0646\u0627 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${a.prefix}" \u0633\u06D2 \u0634\u0631\u0648\u0639 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:a.format==="ends_with"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${a.suffix}" \u067E\u0631 \u062E\u062A\u0645 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:a.format==="includes"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${a.includes}" \u0634\u0627\u0645\u0644 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:a.format==="regex"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: \u067E\u06CC\u0679\u0631\u0646 ${a.pattern} \u0633\u06D2 \u0645\u06CC\u0686 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:`\u063A\u0644\u0637 ${r[a.format]??n.format}`}case"not_multiple_of":return`\u063A\u0644\u0637 \u0646\u0645\u0628\u0631: ${n.divisor} \u06A9\u0627 \u0645\u0636\u0627\u0639\u0641 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`;case"unrecognized_keys":return`\u063A\u06CC\u0631 \u062A\u0633\u0644\u06CC\u0645 \u0634\u062F\u06C1 \u06A9\u06CC${n.keys.length>1?"\u0632":""}: ${I(n.keys,"\u060C ")}`;case"invalid_key":return`${n.origin} \u0645\u06CC\u06BA \u063A\u0644\u0637 \u06A9\u06CC`;case"invalid_union":return"\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679";case"invalid_element":return`${n.origin} \u0645\u06CC\u06BA \u063A\u0644\u0637 \u0648\u06CC\u0644\u06CC\u0648`;default:return"\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679"}}};function vC(){return{localeError:p2()}}var m2=()=>{let e={string:{unit:"belgi",verb:"bo\u2018lishi kerak"},file:{unit:"bayt",verb:"bo\u2018lishi kerak"},array:{unit:"element",verb:"bo\u2018lishi kerak"},set:{unit:"element",verb:"bo\u2018lishi kerak"},map:{unit:"yozuv",verb:"bo\u2018lishi kerak"}};function t(n){return e[n]??null}let r={regex:"kirish",email:"elektron pochta manzili",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO sana va vaqti",date:"ISO sana",time:"ISO vaqt",duration:"ISO davomiylik",ipv4:"IPv4 manzil",ipv6:"IPv6 manzil",mac:"MAC manzil",cidrv4:"IPv4 diapazon",cidrv6:"IPv6 diapazon",base64:"base64 kodlangan satr",base64url:"base64url kodlangan satr",json_string:"JSON satr",e164:"E.164 raqam",jwt:"JWT",template_literal:"kirish"},i={nan:"NaN",number:"raqam",array:"massiv"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Noto\u2018g\u2018ri kirish: kutilgan instanceof ${n.expected}, qabul qilingan ${s}`:`Noto\u2018g\u2018ri kirish: kutilgan ${a}, qabul qilingan ${s}`}case"invalid_value":return n.values.length===1?`Noto\u2018g\u2018ri kirish: kutilgan ${R(n.values[0])}`:`Noto\u2018g\u2018ri variant: quyidagilardan biri kutilgan ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`Juda katta: kutilgan ${n.origin??"qiymat"} ${a}${n.maximum.toString()} ${o.unit} ${o.verb}`:`Juda katta: kutilgan ${n.origin??"qiymat"} ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`Juda kichik: kutilgan ${n.origin} ${a}${n.minimum.toString()} ${o.unit} ${o.verb}`:`Juda kichik: kutilgan ${n.origin} ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Noto\u2018g\u2018ri satr: "${a.prefix}" bilan boshlanishi kerak`:a.format==="ends_with"?`Noto\u2018g\u2018ri satr: "${a.suffix}" bilan tugashi kerak`:a.format==="includes"?`Noto\u2018g\u2018ri satr: "${a.includes}" ni o\u2018z ichiga olishi kerak`:a.format==="regex"?`Noto\u2018g\u2018ri satr: ${a.pattern} shabloniga mos kelishi kerak`:`Noto\u2018g\u2018ri ${r[a.format]??n.format}`}case"not_multiple_of":return`Noto\u2018g\u2018ri raqam: ${n.divisor} ning karralisi bo\u2018lishi kerak`;case"unrecognized_keys":return`Noma\u2019lum kalit${n.keys.length>1?"lar":""}: ${I(n.keys,", ")}`;case"invalid_key":return`${n.origin} dagi kalit noto\u2018g\u2018ri`;case"invalid_union":return"Noto\u2018g\u2018ri kirish";case"invalid_element":return`${n.origin} da noto\u2018g\u2018ri qiymat`;default:return"Noto\u2018g\u2018ri kirish"}}};function bC(){return{localeError:m2()}}var h2=()=>{let e={string:{unit:"k\xFD t\u1EF1",verb:"c\xF3"},file:{unit:"byte",verb:"c\xF3"},array:{unit:"ph\u1EA7n t\u1EED",verb:"c\xF3"},set:{unit:"ph\u1EA7n t\u1EED",verb:"c\xF3"}};function t(n){return e[n]??null}let r={regex:"\u0111\u1EA7u v\xE0o",email:"\u0111\u1ECBa ch\u1EC9 email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ng\xE0y gi\u1EDD ISO",date:"ng\xE0y ISO",time:"gi\u1EDD ISO",duration:"kho\u1EA3ng th\u1EDDi gian ISO",ipv4:"\u0111\u1ECBa ch\u1EC9 IPv4",ipv6:"\u0111\u1ECBa ch\u1EC9 IPv6",cidrv4:"d\u1EA3i IPv4",cidrv6:"d\u1EA3i IPv6",base64:"chu\u1ED7i m\xE3 h\xF3a base64",base64url:"chu\u1ED7i m\xE3 h\xF3a base64url",json_string:"chu\u1ED7i JSON",e164:"s\u1ED1 E.164",jwt:"JWT",template_literal:"\u0111\u1EA7u v\xE0o"},i={nan:"NaN",number:"s\u1ED1",array:"m\u1EA3ng"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i instanceof ${n.expected}, nh\u1EADn \u0111\u01B0\u1EE3c ${s}`:`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i ${a}, nh\u1EADn \u0111\u01B0\u1EE3c ${s}`}case"invalid_value":return n.values.length===1?`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i ${R(n.values[0])}`:`T\xF9y ch\u1ECDn kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i m\u1ED9t trong c\xE1c gi\xE1 tr\u1ECB ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`Qu\xE1 l\u1EDBn: mong \u0111\u1EE3i ${n.origin??"gi\xE1 tr\u1ECB"} ${o.verb} ${a}${n.maximum.toString()} ${o.unit??"ph\u1EA7n t\u1EED"}`:`Qu\xE1 l\u1EDBn: mong \u0111\u1EE3i ${n.origin??"gi\xE1 tr\u1ECB"} ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`Qu\xE1 nh\u1ECF: mong \u0111\u1EE3i ${n.origin} ${o.verb} ${a}${n.minimum.toString()} ${o.unit}`:`Qu\xE1 nh\u1ECF: mong \u0111\u1EE3i ${n.origin} ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i b\u1EAFt \u0111\u1EA7u b\u1EB1ng "${a.prefix}"`:a.format==="ends_with"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i k\u1EBFt th\xFAc b\u1EB1ng "${a.suffix}"`:a.format==="includes"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i bao g\u1ED3m "${a.includes}"`:a.format==="regex"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i kh\u1EDBp v\u1EDBi m\u1EABu ${a.pattern}`:`${r[a.format]??n.format} kh\xF4ng h\u1EE3p l\u1EC7`}case"not_multiple_of":return`S\u1ED1 kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i l\xE0 b\u1ED9i s\u1ED1 c\u1EE7a ${n.divisor}`;case"unrecognized_keys":return`Kh\xF3a kh\xF4ng \u0111\u01B0\u1EE3c nh\u1EADn d\u1EA1ng: ${I(n.keys,", ")}`;case"invalid_key":return`Kh\xF3a kh\xF4ng h\u1EE3p l\u1EC7 trong ${n.origin}`;case"invalid_union":return"\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7";case"invalid_element":return`Gi\xE1 tr\u1ECB kh\xF4ng h\u1EE3p l\u1EC7 trong ${n.origin}`;default:return"\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7"}}};function wC(){return{localeError:h2()}}var g2=()=>{let e={string:{unit:"\u5B57\u7B26",verb:"\u5305\u542B"},file:{unit:"\u5B57\u8282",verb:"\u5305\u542B"},array:{unit:"\u9879",verb:"\u5305\u542B"},set:{unit:"\u9879",verb:"\u5305\u542B"}};function t(n){return e[n]??null}let r={regex:"\u8F93\u5165",email:"\u7535\u5B50\u90AE\u4EF6",url:"URL",emoji:"\u8868\u60C5\u7B26\u53F7",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO\u65E5\u671F\u65F6\u95F4",date:"ISO\u65E5\u671F",time:"ISO\u65F6\u95F4",duration:"ISO\u65F6\u957F",ipv4:"IPv4\u5730\u5740",ipv6:"IPv6\u5730\u5740",cidrv4:"IPv4\u7F51\u6BB5",cidrv6:"IPv6\u7F51\u6BB5",base64:"base64\u7F16\u7801\u5B57\u7B26\u4E32",base64url:"base64url\u7F16\u7801\u5B57\u7B26\u4E32",json_string:"JSON\u5B57\u7B26\u4E32",e164:"E.164\u53F7\u7801",jwt:"JWT",template_literal:"\u8F93\u5165"},i={nan:"NaN",number:"\u6570\u5B57",array:"\u6570\u7EC4",null:"\u7A7A\u503C(null)"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B instanceof ${n.expected}\uFF0C\u5B9E\u9645\u63A5\u6536 ${s}`:`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B ${a}\uFF0C\u5B9E\u9645\u63A5\u6536 ${s}`}case"invalid_value":return n.values.length===1?`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B ${R(n.values[0])}`:`\u65E0\u6548\u9009\u9879\uFF1A\u671F\u671B\u4EE5\u4E0B\u4E4B\u4E00 ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`\u6570\u503C\u8FC7\u5927\uFF1A\u671F\u671B ${n.origin??"\u503C"} ${a}${n.maximum.toString()} ${o.unit??"\u4E2A\u5143\u7D20"}`:`\u6570\u503C\u8FC7\u5927\uFF1A\u671F\u671B ${n.origin??"\u503C"} ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`\u6570\u503C\u8FC7\u5C0F\uFF1A\u671F\u671B ${n.origin} ${a}${n.minimum.toString()} ${o.unit}`:`\u6570\u503C\u8FC7\u5C0F\uFF1A\u671F\u671B ${n.origin} ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u4EE5 "${a.prefix}" \u5F00\u5934`:a.format==="ends_with"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u4EE5 "${a.suffix}" \u7ED3\u5C3E`:a.format==="includes"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u5305\u542B "${a.includes}"`:a.format==="regex"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u6EE1\u8DB3\u6B63\u5219\u8868\u8FBE\u5F0F ${a.pattern}`:`\u65E0\u6548${r[a.format]??n.format}`}case"not_multiple_of":return`\u65E0\u6548\u6570\u5B57\uFF1A\u5FC5\u987B\u662F ${n.divisor} \u7684\u500D\u6570`;case"unrecognized_keys":return`\u51FA\u73B0\u672A\u77E5\u7684\u952E(key): ${I(n.keys,", ")}`;case"invalid_key":return`${n.origin} \u4E2D\u7684\u952E(key)\u65E0\u6548`;case"invalid_union":return"\u65E0\u6548\u8F93\u5165";case"invalid_element":return`${n.origin} \u4E2D\u5305\u542B\u65E0\u6548\u503C(value)`;default:return"\u65E0\u6548\u8F93\u5165"}}};function xC(){return{localeError:g2()}}var _2=()=>{let e={string:{unit:"\u5B57\u5143",verb:"\u64C1\u6709"},file:{unit:"\u4F4D\u5143\u7D44",verb:"\u64C1\u6709"},array:{unit:"\u9805\u76EE",verb:"\u64C1\u6709"},set:{unit:"\u9805\u76EE",verb:"\u64C1\u6709"}};function t(n){return e[n]??null}let r={regex:"\u8F38\u5165",email:"\u90F5\u4EF6\u5730\u5740",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u65E5\u671F\u6642\u9593",date:"ISO \u65E5\u671F",time:"ISO \u6642\u9593",duration:"ISO \u671F\u9593",ipv4:"IPv4 \u4F4D\u5740",ipv6:"IPv6 \u4F4D\u5740",cidrv4:"IPv4 \u7BC4\u570D",cidrv6:"IPv6 \u7BC4\u570D",base64:"base64 \u7DE8\u78BC\u5B57\u4E32",base64url:"base64url \u7DE8\u78BC\u5B57\u4E32",json_string:"JSON \u5B57\u4E32",e164:"E.164 \u6578\u503C",jwt:"JWT",template_literal:"\u8F38\u5165"},i={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA instanceof ${n.expected}\uFF0C\u4F46\u6536\u5230 ${s}`:`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA ${a}\uFF0C\u4F46\u6536\u5230 ${s}`}case"invalid_value":return n.values.length===1?`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA ${R(n.values[0])}`:`\u7121\u6548\u7684\u9078\u9805\uFF1A\u9810\u671F\u70BA\u4EE5\u4E0B\u5176\u4E2D\u4E4B\u4E00 ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`\u6578\u503C\u904E\u5927\uFF1A\u9810\u671F ${n.origin??"\u503C"} \u61C9\u70BA ${a}${n.maximum.toString()} ${o.unit??"\u500B\u5143\u7D20"}`:`\u6578\u503C\u904E\u5927\uFF1A\u9810\u671F ${n.origin??"\u503C"} \u61C9\u70BA ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`\u6578\u503C\u904E\u5C0F\uFF1A\u9810\u671F ${n.origin} \u61C9\u70BA ${a}${n.minimum.toString()} ${o.unit}`:`\u6578\u503C\u904E\u5C0F\uFF1A\u9810\u671F ${n.origin} \u61C9\u70BA ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u4EE5 "${a.prefix}" \u958B\u982D`:a.format==="ends_with"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u4EE5 "${a.suffix}" \u7D50\u5C3E`:a.format==="includes"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u5305\u542B "${a.includes}"`:a.format==="regex"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u7B26\u5408\u683C\u5F0F ${a.pattern}`:`\u7121\u6548\u7684 ${r[a.format]??n.format}`}case"not_multiple_of":return`\u7121\u6548\u7684\u6578\u5B57\uFF1A\u5FC5\u9808\u70BA ${n.divisor} \u7684\u500D\u6578`;case"unrecognized_keys":return`\u7121\u6CD5\u8B58\u5225\u7684\u9375\u503C${n.keys.length>1?"\u5011":""}\uFF1A${I(n.keys,"\u3001")}`;case"invalid_key":return`${n.origin} \u4E2D\u6709\u7121\u6548\u7684\u9375\u503C`;case"invalid_union":return"\u7121\u6548\u7684\u8F38\u5165\u503C";case"invalid_element":return`${n.origin} \u4E2D\u6709\u7121\u6548\u7684\u503C`;default:return"\u7121\u6548\u7684\u8F38\u5165\u503C"}}};function SC(){return{localeError:_2()}}var y2=()=>{let e={string:{unit:"\xE0mi",verb:"n\xED"},file:{unit:"bytes",verb:"n\xED"},array:{unit:"nkan",verb:"n\xED"},set:{unit:"nkan",verb:"n\xED"}};function t(n){return e[n]??null}let r={regex:"\u1EB9\u0300r\u1ECD \xECb\xE1w\u1ECDl\xE9",email:"\xE0d\xEDr\u1EB9\u0301s\xEC \xECm\u1EB9\u0301l\xEC",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\xE0k\xF3k\xF2 ISO",date:"\u1ECDj\u1ECD\u0301 ISO",time:"\xE0k\xF3k\xF2 ISO",duration:"\xE0k\xF3k\xF2 t\xF3 p\xE9 ISO",ipv4:"\xE0d\xEDr\u1EB9\u0301s\xEC IPv4",ipv6:"\xE0d\xEDr\u1EB9\u0301s\xEC IPv6",cidrv4:"\xE0gb\xE8gb\xE8 IPv4",cidrv6:"\xE0gb\xE8gb\xE8 IPv6",base64:"\u1ECD\u0300r\u1ECD\u0300 t\xED a k\u1ECD\u0301 n\xED base64",base64url:"\u1ECD\u0300r\u1ECD\u0300 base64url",json_string:"\u1ECD\u0300r\u1ECD\u0300 JSON",e164:"n\u1ECD\u0301mb\xE0 E.164",jwt:"JWT",template_literal:"\u1EB9\u0300r\u1ECD \xECb\xE1w\u1ECDl\xE9"},i={nan:"NaN",number:"n\u1ECD\u0301mb\xE0",array:"akop\u1ECD"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=M(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi instanceof ${n.expected}, \xE0m\u1ECD\u0300 a r\xED ${s}`:`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi ${a}, \xE0m\u1ECD\u0300 a r\xED ${s}`}case"invalid_value":return n.values.length===1?`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi ${R(n.values[0])}`:`\xC0\u1E63\xE0y\xE0n a\u1E63\xEC\u1E63e: yan \u1ECD\u0300kan l\xE1ra ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`T\xF3 p\u1ECD\u0300 j\xF9: a n\xED l\xE1ti j\u1EB9\u0301 p\xE9 ${n.origin??"iye"} ${o.verb} ${a}${n.maximum} ${o.unit}`:`T\xF3 p\u1ECD\u0300 j\xF9: a n\xED l\xE1ti j\u1EB9\u0301 ${a}${n.maximum}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`K\xE9r\xE9 ju: a n\xED l\xE1ti j\u1EB9\u0301 p\xE9 ${n.origin} ${o.verb} ${a}${n.minimum} ${o.unit}`:`K\xE9r\xE9 ju: a n\xED l\xE1ti j\u1EB9\u0301 ${a}${n.minimum}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 b\u1EB9\u0300r\u1EB9\u0300 p\u1EB9\u0300l\xFA "${a.prefix}"`:a.format==="ends_with"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 par\xED p\u1EB9\u0300l\xFA "${a.suffix}"`:a.format==="includes"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 n\xED "${a.includes}"`:a.format==="regex"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 b\xE1 \xE0p\u1EB9\u1EB9r\u1EB9 mu ${a.pattern}`:`A\u1E63\xEC\u1E63e: ${r[a.format]??n.format}`}case"not_multiple_of":return`N\u1ECD\u0301mb\xE0 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 j\u1EB9\u0301 \xE8y\xE0 p\xEDp\xEDn ti ${n.divisor}`;case"unrecognized_keys":return`B\u1ECDt\xECn\xEC \xE0\xECm\u1ECD\u0300: ${I(n.keys,", ")}`;case"invalid_key":return`B\u1ECDt\xECn\xEC a\u1E63\xEC\u1E63e n\xEDn\xFA ${n.origin}`;case"invalid_union":return"\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e";case"invalid_element":return`Iye a\u1E63\xEC\u1E63e n\xEDn\xFA ${n.origin}`;default:return"\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e"}}};function kC(){return{localeError:y2()}}var $C,Nv=Symbol("ZodOutput"),Rv=Symbol("ZodInput"),Df=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...r){let i=r[0];return this._map.set(t,i),i&&typeof i=="object"&&"id"in i&&this._idmap.set(i.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){let r=this._map.get(t);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(t),this}get(t){let r=t._zod.parent;if(r){let i={...this.get(r)??{}};delete i.id;let n={...i,...this._map.get(t)};return Object.keys(n).length?n:void 0}return this._map.get(t)}has(t){return this._map.has(t)}};function Uf(){return new Df}($C=globalThis).__zod_globalRegistry??($C.__zod_globalRegistry=Uf());var Ne=globalThis.__zod_globalRegistry;function Mv(e,t){return new e({type:"string",...F(t)})}function jv(e,t){return new e({type:"string",coerce:!0,...F(t)})}function Lf(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...F(t)})}function Il(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...F(t)})}function Ff(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...F(t)})}function Bf(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...F(t)})}function Vf(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...F(t)})}function Zf(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...F(t)})}function Tl(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...F(t)})}function Hf(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...F(t)})}function Gf(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...F(t)})}function Wf(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...F(t)})}function Jf(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...F(t)})}function Kf(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...F(t)})}function qf(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...F(t)})}function Xf(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...F(t)})}function Yf(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...F(t)})}function Qf(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...F(t)})}function zv(e,t){return new e({type:"string",format:"mac",check:"string_format",abort:!1,...F(t)})}function ep(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...F(t)})}function tp(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...F(t)})}function rp(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...F(t)})}function np(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...F(t)})}function ip(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...F(t)})}function ap(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...F(t)})}var Dv={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6};function Uv(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...F(t)})}function Lv(e,t){return new e({type:"string",format:"date",check:"string_format",...F(t)})}function Fv(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...F(t)})}function Bv(e,t){return new e({type:"string",format:"duration",check:"string_format",...F(t)})}function Vv(e,t){return new e({type:"number",checks:[],...F(t)})}function Zv(e,t){return new e({type:"number",coerce:!0,checks:[],...F(t)})}function Hv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...F(t)})}function Gv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float32",...F(t)})}function Wv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float64",...F(t)})}function Jv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"int32",...F(t)})}function Kv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"uint32",...F(t)})}function qv(e,t){return new e({type:"boolean",...F(t)})}function Xv(e,t){return new e({type:"boolean",coerce:!0,...F(t)})}function Yv(e,t){return new e({type:"bigint",...F(t)})}function Qv(e,t){return new e({type:"bigint",coerce:!0,...F(t)})}function eb(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...F(t)})}function tb(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...F(t)})}function rb(e,t){return new e({type:"symbol",...F(t)})}function nb(e,t){return new e({type:"undefined",...F(t)})}function ib(e,t){return new e({type:"null",...F(t)})}function ab(e){return new e({type:"any"})}function Cl(e){return new e({type:"unknown"})}function Al(e,t){return new e({type:"never",...F(t)})}function ob(e,t){return new e({type:"void",...F(t)})}function sb(e,t){return new e({type:"date",...F(t)})}function cb(e,t){return new e({type:"date",coerce:!0,...F(t)})}function lb(e,t){return new e({type:"nan",...F(t)})}function Bn(e,t){return new $f({check:"less_than",...F(t),value:e,inclusive:!1})}function Ar(e,t){return new $f({check:"less_than",...F(t),value:e,inclusive:!0})}function Vn(e,t){return new Ef({check:"greater_than",...F(t),value:e,inclusive:!1})}function ar(e,t){return new Ef({check:"greater_than",...F(t),value:e,inclusive:!0})}function op(e){return Vn(0,e)}function sp(e){return Bn(0,e)}function cp(e){return Ar(0,e)}function lp(e){return ar(0,e)}function la(e,t){return new oy({check:"multiple_of",...F(t),value:e})}function ua(e,t){return new ly({check:"max_size",...F(t),maximum:e})}function Zn(e,t){return new uy({check:"min_size",...F(t),minimum:e})}function po(e,t){return new dy({check:"size_equals",...F(t),size:e})}function mo(e,t){return new fy({check:"max_length",...F(t),maximum:e})}function _i(e,t){return new py({check:"min_length",...F(t),minimum:e})}function ho(e,t){return new my({check:"length_equals",...F(t),length:e})}function Ts(e,t){return new hy({check:"string_format",format:"regex",...F(t),pattern:e})}function Cs(e){return new gy({check:"string_format",format:"lowercase",...F(e)})}function As(e){return new _y({check:"string_format",format:"uppercase",...F(e)})}function Os(e,t){return new yy({check:"string_format",format:"includes",...F(t),includes:e})}function Ps(e,t){return new vy({check:"string_format",format:"starts_with",...F(t),prefix:e})}function Ns(e,t){return new by({check:"string_format",format:"ends_with",...F(t),suffix:e})}function up(e,t,r){return new wy({check:"property",property:e,schema:t,...F(r)})}function Rs(e,t){return new xy({check:"mime_type",mime:e,...F(t)})}function ln(e){return new Sy({check:"overwrite",tx:e})}function Ms(e){return ln(t=>t.normalize(e))}function js(){return ln(e=>e.trim())}function zs(){return ln(e=>e.toLowerCase())}function Ds(){return ln(e=>e.toUpperCase())}function Us(){return ln(e=>v_(e))}function ub(e,t,r){return new e({type:"array",element:t,...F(r)})}function b2(e,t,r){return new e({type:"union",options:t,...F(r)})}function w2(e,t,r){return new e({type:"union",options:t,inclusive:!1,...F(r)})}function x2(e,t,r,i){return new e({type:"union",options:r,discriminator:t,...F(i)})}function S2(e,t,r){return new e({type:"intersection",left:t,right:r})}function k2(e,t,r,i){let n=r instanceof de,a=n?i:r,o=n?r:null;return new e({type:"tuple",items:t,rest:o,...F(a)})}function $2(e,t,r,i){return new e({type:"record",keyType:t,valueType:r,...F(i)})}function E2(e,t,r,i){return new e({type:"map",keyType:t,valueType:r,...F(i)})}function I2(e,t,r){return new e({type:"set",valueType:t,...F(r)})}function T2(e,t,r){let i=Array.isArray(t)?Object.fromEntries(t.map(n=>[n,n])):t;return new e({type:"enum",entries:i,...F(r)})}function C2(e,t,r){return new e({type:"enum",entries:t,...F(r)})}function A2(e,t,r){return new e({type:"literal",values:Array.isArray(t)?t:[t],...F(r)})}function db(e,t){return new e({type:"file",...F(t)})}function O2(e,t){return new e({type:"transform",transform:t})}function P2(e,t){return new e({type:"optional",innerType:t})}function N2(e,t){return new e({type:"nullable",innerType:t})}function R2(e,t,r){return new e({type:"default",innerType:t,get defaultValue(){return typeof r=="function"?r():w_(r)}})}function M2(e,t,r){return new e({type:"nonoptional",innerType:t,...F(r)})}function j2(e,t){return new e({type:"success",innerType:t})}function z2(e,t,r){return new e({type:"catch",innerType:t,catchValue:typeof r=="function"?r:()=>r})}function D2(e,t,r){return new e({type:"pipe",in:t,out:r})}function U2(e,t){return new e({type:"readonly",innerType:t})}function L2(e,t,r){return new e({type:"template_literal",parts:t,...F(r)})}function F2(e,t){return new e({type:"lazy",getter:t})}function B2(e,t){return new e({type:"promise",innerType:t})}function fb(e,t,r){let i=F(r);return i.abort??(i.abort=!0),new e({type:"custom",check:"custom",fn:t,...i})}function pb(e,t,r){return new e({type:"custom",check:"custom",fn:t,...F(r)})}function mb(e,t){let r=EC(i=>(i.addIssue=n=>{if(typeof n=="string")i.issues.push(ws(n,i.value,r._zod.def));else{let a=n;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),a.input??(a.input=i.value),a.inst??(a.inst=r),a.continue??(a.continue=!r._zod.def.abort),i.issues.push(ws(a))}},e(i.value,i)),t);return r}function EC(e,t){let r=new Le({check:"custom",...F(t)});return r._zod.check=e,r}function hb(e){let t=new Le({check:"describe"});return t._zod.onattach=[r=>{let i=Ne.get(r)??{};Ne.add(r,{...i,description:e})}],t._zod.check=()=>{},t}function gb(e){let t=new Le({check:"meta"});return t._zod.onattach=[r=>{let i=Ne.get(r)??{};Ne.add(r,{...i,...e})}],t._zod.check=()=>{},t}function _b(e,t){let r=F(t),i=r.truthy??["true","1","yes","on","y","enabled"],n=r.falsy??["false","0","no","off","n","disabled"];r.case!=="sensitive"&&(i=i.map(p=>typeof p=="string"?p.toLowerCase():p),n=n.map(p=>typeof p=="string"?p.toLowerCase():p));let a=new Set(i),o=new Set(n),s=e.Codec??kl,c=e.Boolean??bl,l=e.String??uo,u=new l({type:"string",error:r.error}),d=new c({type:"boolean",error:r.error}),f=new s({type:"pipe",in:u,out:d,transform:((p,m)=>{let h=p;return r.case!=="sensitive"&&(h=h.toLowerCase()),a.has(h)?!0:o.has(h)?!1:(m.issues.push({code:"invalid_value",expected:"stringbool",values:[...a,...o],input:m.value,inst:f,continue:!1}),{})}),reverseTransform:((p,m)=>p===!0?i[0]||"true":n[0]||"false"),error:r.error});return f}function Ls(e,t,r,i={}){let n=F(i),a={...F(i),check:"string_format",type:"string",format:t,fn:typeof r=="function"?r:s=>r.test(s),...n};return r instanceof RegExp&&(a.pattern=r),new e(a)}function da(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??Ne,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function Re(e,t,r={path:[],schemaPath:[]}){var i;let n=e._zod.def,a=t.seen.get(e);if(a)return a.count++,r.schemaPath.includes(e)&&(a.cycle=r.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let u={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,u);else{let f=o.schema,p=t.processors[n.type];if(!p)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${n.type}`);p(e,t,f,u)}let d=e._zod.parent;d&&(o.ref||(o.ref=d),Re(d,t,u),t.seen.get(d).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io==="input"&&or(e)&&(delete o.schema.examples,delete o.schema.default),t.io==="input"&&"_prefault"in o.schema&&((i=o.schema).default??(i.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function fa(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let i=new Map;for(let o of e.seen.entries()){let s=e.metadataRegistry.get(o[0])?.id;if(s){let c=i.get(s);if(c&&c!==o[0])throw new Error(`Duplicate schema id "${s}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);i.set(s,o[0])}}let n=o=>{let s=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let d=e.external.registry.get(o[0])?.id,f=e.external.uri??(m=>m);if(d)return{ref:f(d)};let p=o[1].defId??o[1].schema.id??`schema${e.counter++}`;return o[1].defId=p,{defId:p,ref:`${f("__shared")}#/${s}/${p}`}}if(o[1]===r)return{ref:"#"};let l=`#/${s}/`,u=o[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:l+u}},a=o=>{if(o[1].schema.$ref)return;let s=o[1],{ref:c,defId:l}=n(o);s.def={...s.schema},l&&(s.defId=l);let u=s.schema;for(let d in u)delete u[d];u.$ref=c};if(e.cycles==="throw")for(let o of e.seen.entries()){let s=o[1];if(s.cycle)throw new Error(`Cycle detected: #/${s.cycle?.join("/")}/<root>
220
-
221
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let o of e.seen.entries()){let s=o[1];if(t===o[0]){a(o);continue}if(e.external){let l=e.external.registry.get(o[0])?.id;if(t!==o[0]&&l){a(o);continue}}if(e.metadataRegistry.get(o[0])?.id){a(o);continue}if(s.cycle){a(o);continue}if(s.count>1&&e.reused==="ref"){a(o);continue}}}function pa(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let i=s=>{let c=e.seen.get(s);if(c.ref===null)return;let l=c.def??c.schema,u={...l},d=c.ref;if(c.ref=null,d){i(d);let p=e.seen.get(d),m=p.schema;if(m.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(l.allOf=l.allOf??[],l.allOf.push(m)):Object.assign(l,m),Object.assign(l,u),s._zod.parent===d)for(let _ in l)_==="$ref"||_==="allOf"||_ in u||delete l[_];if(m.$ref&&p.def)for(let _ in l)_==="$ref"||_==="allOf"||_ in p.def&&JSON.stringify(l[_])===JSON.stringify(p.def[_])&&delete l[_]}let f=s._zod.parent;if(f&&f!==d){i(f);let p=e.seen.get(f);if(p?.schema.$ref&&(l.$ref=p.schema.$ref,p.def))for(let m in l)m==="$ref"||m==="allOf"||m in p.def&&JSON.stringify(l[m])===JSON.stringify(p.def[m])&&delete l[m]}e.override({zodSchema:s,jsonSchema:l,path:c.path??[]})};for(let s of[...e.seen.entries()].reverse())i(s[0]);let n={};if(e.target==="draft-2020-12"?n.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?n.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?n.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let s=e.external.registry.get(t)?.id;if(!s)throw new Error("Schema is missing an `id` property");n.$id=e.external.uri(s)}Object.assign(n,r.def??r.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&n.id===a&&delete n.id;let o=e.external?.defs??{};for(let s of e.seen.entries()){let c=s[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,o[c.defId]=c.def)}e.external||Object.keys(o).length>0&&(e.target==="draft-2020-12"?n.$defs=o:n.definitions=o);try{let s=JSON.parse(JSON.stringify(n));return Object.defineProperty(s,"~standard",{value:{...t["~standard"],jsonSchema:{input:Fs(t,"input",e.processors),output:Fs(t,"output",e.processors)}},enumerable:!1,writable:!1}),s}catch{throw new Error("Error converting schema to JSON.")}}function or(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let i=e._zod.def;if(i.type==="transform")return!0;if(i.type==="array")return or(i.element,r);if(i.type==="set")return or(i.valueType,r);if(i.type==="lazy")return or(i.getter(),r);if(i.type==="promise"||i.type==="optional"||i.type==="nonoptional"||i.type==="nullable"||i.type==="readonly"||i.type==="default"||i.type==="prefault")return or(i.innerType,r);if(i.type==="intersection")return or(i.left,r)||or(i.right,r);if(i.type==="record"||i.type==="map")return or(i.keyType,r)||or(i.valueType,r);if(i.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:or(i.in,r)||or(i.out,r);if(i.type==="object"){for(let n in i.shape)if(or(i.shape[n],r))return!0;return!1}if(i.type==="union"){for(let n of i.options)if(or(n,r))return!0;return!1}if(i.type==="tuple"){for(let n of i.items)if(or(n,r))return!0;return!!(i.rest&&or(i.rest,r))}return!1}var yb=(e,t={})=>r=>{let i=da({...r,processors:t});return Re(e,i),fa(i,e),pa(i,e)},Fs=(e,t,r={})=>i=>{let{libraryOptions:n,target:a}=i??{},o=da({...n??{},target:a,io:t,processors:r});return Re(e,o),fa(o,e),pa(o,e)};var V2={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},vb=(e,t,r,i)=>{let n=r;n.type="string";let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a=="number"&&(n.minLength=a),typeof o=="number"&&(n.maxLength=o),s&&(n.format=V2[s]??s,n.format===""&&delete n.format,s==="time"&&delete n.format),l&&(n.contentEncoding=l),c&&c.size>0){let u=[...c];u.length===1?n.pattern=u[0].source:u.length>1&&(n.allOf=[...u.map(d=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))])}},bb=(e,t,r,i)=>{let n=r,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s=="string"&&s.includes("int")?n.type="integer":n.type="number";let d=typeof u=="number"&&u>=(a??Number.NEGATIVE_INFINITY),f=typeof l=="number"&&l<=(o??Number.POSITIVE_INFINITY),p=t.target==="draft-04"||t.target==="openapi-3.0";d?p?(n.minimum=u,n.exclusiveMinimum=!0):n.exclusiveMinimum=u:typeof a=="number"&&(n.minimum=a),f?p?(n.maximum=l,n.exclusiveMaximum=!0):n.exclusiveMaximum=l:typeof o=="number"&&(n.maximum=o),typeof c=="number"&&(n.multipleOf=c)},wb=(e,t,r,i)=>{r.type="boolean"},xb=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},Sb=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},kb=(e,t,r,i)=>{t.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"},$b=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},Eb=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},Ib=(e,t,r,i)=>{r.not={}},Tb=(e,t,r,i)=>{},Cb=(e,t,r,i)=>{},Ab=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},Ob=(e,t,r,i)=>{let n=e._zod.def,a=ll(n.entries);a.every(o=>typeof o=="number")&&(r.type="number"),a.every(o=>typeof o=="string")&&(r.type="string"),r.enum=a},Pb=(e,t,r,i)=>{let n=e._zod.def,a=[];for(let o of n.values)if(o===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof o=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");a.push(Number(o))}else a.push(o);if(a.length!==0)if(a.length===1){let o=a[0];r.type=o===null?"null":typeof o,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[o]:r.const=o}else a.every(o=>typeof o=="number")&&(r.type="number"),a.every(o=>typeof o=="string")&&(r.type="string"),a.every(o=>typeof o=="boolean")&&(r.type="boolean"),a.every(o=>o===null)&&(r.type="null"),r.enum=a},Nb=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},Rb=(e,t,r,i)=>{let n=r,a=e._zod.pattern;if(!a)throw new Error("Pattern not found in template literal");n.type="string",n.pattern=a.source},Mb=(e,t,r,i)=>{let n=r,a={type:"string",format:"binary",contentEncoding:"binary"},{minimum:o,maximum:s,mime:c}=e._zod.bag;o!==void 0&&(a.minLength=o),s!==void 0&&(a.maxLength=s),c?c.length===1?(a.contentMediaType=c[0],Object.assign(n,a)):(Object.assign(n,a),n.anyOf=c.map(l=>({contentMediaType:l}))):Object.assign(n,a)},jb=(e,t,r,i)=>{r.type="boolean"},zb=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},Db=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},Ub=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Lb=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},Fb=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},Bb=(e,t,r,i)=>{let n=r,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o=="number"&&(n.minItems=o),typeof s=="number"&&(n.maxItems=s),n.type="array",n.items=Re(a.element,t,{...i,path:[...i.path,"items"]})},Vb=(e,t,r,i)=>{let n=r,a=e._zod.def;n.type="object",n.properties={};let o=a.shape;for(let l in o)n.properties[l]=Re(o[l],t,{...i,path:[...i.path,"properties",l]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(l=>{let u=a.shape[l]._zod;return t.io==="input"?u.optin===void 0:u.optout===void 0}));c.size>0&&(n.required=Array.from(c)),a.catchall?._zod.def.type==="never"?n.additionalProperties=!1:a.catchall?a.catchall&&(n.additionalProperties=Re(a.catchall,t,{...i,path:[...i.path,"additionalProperties"]})):t.io==="output"&&(n.additionalProperties=!1)},fp=(e,t,r,i)=>{let n=e._zod.def,a=n.inclusive===!1,o=n.options.map((s,c)=>Re(s,t,{...i,path:[...i.path,a?"oneOf":"anyOf",c]}));a?r.oneOf=o:r.anyOf=o},Zb=(e,t,r,i)=>{let n=e._zod.def,a=Re(n.left,t,{...i,path:[...i.path,"allOf",0]}),o=Re(n.right,t,{...i,path:[...i.path,"allOf",1]}),s=l=>"allOf"in l&&Object.keys(l).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];r.allOf=c},Hb=(e,t,r,i)=>{let n=r,a=e._zod.def;n.type="array";let o=t.target==="draft-2020-12"?"prefixItems":"items",s=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",c=a.items.map((f,p)=>Re(f,t,{...i,path:[...i.path,o,p]})),l=a.rest?Re(a.rest,t,{...i,path:[...i.path,s,...t.target==="openapi-3.0"?[a.items.length]:[]]}):null;t.target==="draft-2020-12"?(n.prefixItems=c,l&&(n.items=l)):t.target==="openapi-3.0"?(n.items={anyOf:c},l&&n.items.anyOf.push(l),n.minItems=c.length,l||(n.maxItems=c.length)):(n.items=c,l&&(n.additionalItems=l));let{minimum:u,maximum:d}=e._zod.bag;typeof u=="number"&&(n.minItems=u),typeof d=="number"&&(n.maxItems=d)},Gb=(e,t,r,i)=>{let n=r,a=e._zod.def;n.type="object";let o=a.keyType,c=o._zod.bag?.patterns;if(a.mode==="loose"&&c&&c.size>0){let u=Re(a.valueType,t,{...i,path:[...i.path,"patternProperties","*"]});n.patternProperties={};for(let d of c)n.patternProperties[d.source]=u}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(n.propertyNames=Re(a.keyType,t,{...i,path:[...i.path,"propertyNames"]})),n.additionalProperties=Re(a.valueType,t,{...i,path:[...i.path,"additionalProperties"]});let l=o._zod.values;if(l){let u=[...l].filter(d=>typeof d=="string"||typeof d=="number");u.length>0&&(n.required=u)}},Wb=(e,t,r,i)=>{let n=e._zod.def,a=Re(n.innerType,t,i),o=t.seen.get(e);t.target==="openapi-3.0"?(o.ref=n.innerType,r.nullable=!0):r.anyOf=[a,{type:"null"}]},Jb=(e,t,r,i)=>{let n=e._zod.def;Re(n.innerType,t,i);let a=t.seen.get(e);a.ref=n.innerType},Kb=(e,t,r,i)=>{let n=e._zod.def;Re(n.innerType,t,i);let a=t.seen.get(e);a.ref=n.innerType,r.default=JSON.parse(JSON.stringify(n.defaultValue))},qb=(e,t,r,i)=>{let n=e._zod.def;Re(n.innerType,t,i);let a=t.seen.get(e);a.ref=n.innerType,t.io==="input"&&(r._prefault=JSON.parse(JSON.stringify(n.defaultValue)))},Xb=(e,t,r,i)=>{let n=e._zod.def;Re(n.innerType,t,i);let a=t.seen.get(e);a.ref=n.innerType;let o;try{o=n.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}r.default=o},Yb=(e,t,r,i)=>{let n=e._zod.def,a=n.in._zod.traits.has("$ZodTransform"),o=t.io==="input"?a?n.out:n.in:n.out;Re(o,t,i);let s=t.seen.get(e);s.ref=o},Qb=(e,t,r,i)=>{let n=e._zod.def;Re(n.innerType,t,i);let a=t.seen.get(e);a.ref=n.innerType,r.readOnly=!0},ew=(e,t,r,i)=>{let n=e._zod.def;Re(n.innerType,t,i);let a=t.seen.get(e);a.ref=n.innerType},pp=(e,t,r,i)=>{let n=e._zod.def;Re(n.innerType,t,i);let a=t.seen.get(e);a.ref=n.innerType},tw=(e,t,r,i)=>{let n=e._zod.innerType;Re(n,t,i);let a=t.seen.get(e);a.ref=n},dp={string:vb,number:bb,boolean:wb,bigint:xb,symbol:Sb,null:kb,undefined:$b,void:Eb,never:Ib,any:Tb,unknown:Cb,date:Ab,enum:Ob,literal:Pb,nan:Nb,template_literal:Rb,file:Mb,success:jb,custom:zb,function:Db,transform:Ub,map:Lb,set:Fb,array:Bb,object:Vb,union:fp,intersection:Zb,tuple:Hb,record:Gb,nullable:Wb,nonoptional:Jb,default:Kb,prefault:qb,catch:Xb,pipe:Yb,readonly:Qb,promise:ew,optional:pp,lazy:tw};function go(e,t){if("_idmap"in e){let i=e,n=da({...t,processors:dp}),a={};for(let c of i._idmap.entries()){let[l,u]=c;Re(u,n)}let o={},s={registry:i,uri:t?.uri,defs:a};n.external=s;for(let c of i._idmap.entries()){let[l,u]=c;fa(n,u),o[l]=pa(n,u)}if(Object.keys(a).length>0){let c=n.target==="draft-2020-12"?"$defs":"definitions";o.__shared={[c]:a}}return{schemas:o}}let r=da({...t,processors:dp});return Re(e,r),fa(r,e),pa(r,e)}var mp=class{get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter(t){this.ctx.counter=t}get seen(){return this.ctx.seen}constructor(t){let r=t?.target??"draft-2020-12";r==="draft-4"&&(r="draft-04"),r==="draft-7"&&(r="draft-07"),this.ctx=da({processors:dp,target:r,...t?.metadata&&{metadata:t.metadata},...t?.unrepresentable&&{unrepresentable:t.unrepresentable},...t?.override&&{override:t.override},...t?.io&&{io:t.io}})}process(t,r={path:[],schemaPath:[]}){return Re(t,this.ctx,r)}emit(t,r){r&&(r.cycles&&(this.ctx.cycles=r.cycles),r.reused&&(this.ctx.reused=r.reused),r.external&&(this.ctx.external=r.external)),fa(this.ctx,t);let i=pa(this.ctx,t),{"~standard":n,...a}=i;return a}};var IC={};function Ve(e){if(typeof e!="object"||e===null)return!1;let t=e;if(!("_zod"in t))return!1;let r=t._zod;return typeof r=="object"&&r!==null&&"def"in r}function at(e){if(typeof e!="object"||e===null)return!1;let t=e;if(!("_def"in t)||"_zod"in t)return!1;let r=t._def;return typeof r=="object"&&r!=null&&"typeName"in r}function TC(e){return Ve(e)&&console.warn("[WARNING] Attempting to use Zod 4 schema in a context where Zod 3 schema is expected. This may cause unexpected behavior."),at(e)}function gr(e){return!e||typeof e!="object"||Array.isArray(e)?!1:!!(Ve(e)||at(e))}function rw(e){return typeof e=="object"&&e!==null&&"_def"in e&&typeof e._def=="object"&&e._def!==null&&"typeName"in e._def&&e._def.typeName==="ZodLiteral"}function nw(e){return Ve(e)?typeof e=="object"&&e!==null&&"_zod"in e&&typeof e._zod=="object"&&e._zod!==null&&"def"in e._zod&&typeof e._zod.def=="object"&&e._zod.def!==null&&"type"in e._zod.def&&e._zod.def.type==="literal":!1}function CC(e){return!!(rw(e)||nw(e))}async function gp(e,t){if(Ve(e))try{return{success:!0,data:await co(e,t)}}catch(r){return{success:!1,error:r}}if(at(e))return await e.safeParseAsync(t);throw new Error("Schema must be an instance of z3.ZodType or z4.$ZodType")}async function ma(e,t){if(Ve(e))return await co(e,t);if(at(e))return await e.parseAsync(t);throw new Error("Schema must be an instance of z3.ZodType or z4.$ZodType")}function AC(e,t){if(Ve(e))try{return{success:!0,data:ca(e,t)}}catch(r){return{success:!1,error:r}}if(at(e))return e.safeParse(t);throw new Error("Schema must be an instance of z3.ZodType or z4.$ZodType")}function ha(e,t){if(Ve(e))return ca(e,t);if(at(e))return e.parse(t);throw new Error("Schema must be an instance of z3.ZodType or z4.$ZodType")}function bi(e){if(Ve(e))return Ne.get(e)?.description;if(at(e)||"description"in e&&typeof e.description=="string")return e.description}function OC(e){if(!gr(e))return!1;if(at(e)){let t=e._def;if(t.typeName==="ZodObject"){let r=e;return!r.shape||Object.keys(r.shape).length===0}if(t.typeName==="ZodRecord")return!0}if(Ve(e)){let t=e._zod.def;if(t.type==="object"){let r=e;return!r.shape||Object.keys(r.shape).length===0}if(t.type==="record")return!0}return typeof e=="object"&&e!==null&&!("shape"in e)}function Vs(e){return gr(e)?at(e)?e._def.typeName==="ZodString":Ve(e)?e._zod.def.type==="string":!1:!1}function Ol(e){return typeof e=="object"&&e!==null&&"_def"in e&&typeof e._def=="object"&&e._def!==null&&"typeName"in e._def&&e._def.typeName==="ZodObject"}function Zr(e){return Ve(e)?typeof e=="object"&&e!==null&&"_zod"in e&&typeof e._zod=="object"&&e._zod!==null&&"def"in e._zod&&typeof e._zod.def=="object"&&e._zod.def!==null&&"type"in e._zod.def&&e._zod.def.type==="object":!1}function Pl(e){return Ve(e)?typeof e=="object"&&e!==null&&"_zod"in e&&typeof e._zod=="object"&&e._zod!==null&&"def"in e._zod&&typeof e._zod.def=="object"&&e._zod.def!==null&&"type"in e._zod.def&&e._zod.def.type==="array":!1}function iw(e){return Ve(e)?typeof e=="object"&&e!==null&&"_zod"in e&&typeof e._zod=="object"&&e._zod!==null&&"def"in e._zod&&typeof e._zod.def=="object"&&e._zod.def!==null&&"type"in e._zod.def&&e._zod.def.type==="optional":!1}function aw(e){return Ve(e)?typeof e=="object"&&e!==null&&"_zod"in e&&typeof e._zod=="object"&&e._zod!==null&&"def"in e._zod&&typeof e._zod.def=="object"&&e._zod.def!==null&&"type"in e._zod.def&&e._zod.def.type==="nullable":!1}function Bt(e){return!!(Ol(e)||Zr(e))}function vi(e){if(at(e))return e.shape;if(Ve(e))return e._zod.def.shape;throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject")}function _p(e,t){if(at(e))return e.extend(t);if(Ve(e))return j.extend(e,t);throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject")}function ga(e){if(at(e))return e.partial();if(Ve(e))return j.partial(fo,e,void 0);throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject")}function Bs(e,t=!1){if(Ol(e))return e.strict();if(Zr(e)){let r=e._zod.def.shape;if(t)for(let[a,o]of Object.entries(e._zod.def.shape)){if(Zr(o))r[a]=Bs(o,t);else if(Pl(o)){let c=o._zod.def.element;Zr(c)&&(c=Bs(c,t)),r[a]=We(o,{...o._zod.def,element:c})}else r[a]=o;let s=Ne.get(o);s&&Ne.add(r[a],s)}let i=We(e,{...e._zod.def,shape:r,catchall:Al(xl)}),n=Ne.get(e);return n&&Ne.add(i,n),i}throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject")}function hp(e,t=!1){if(Ol(e))return e.passthrough();if(Zr(e)){let r=e._zod.def.shape;if(t)for(let[a,o]of Object.entries(e._zod.def.shape)){if(Zr(o))r[a]=hp(o,t);else if(Pl(o)){let c=o._zod.def.element;Zr(c)&&(c=hp(c,t)),r[a]=We(o,{...o._zod.def,element:c})}else r[a]=o;let s=Ne.get(o);s&&Ne.add(r[a],s)}let i=We(e,{...e._zod.def,shape:r,catchall:Cl(wl)}),n=Ne.get(e);return n&&Ne.add(i,n),i}throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject")}function yp(e){if(at(e))try{let t=e.parse(void 0);return()=>t}catch{return}if(Ve(e))try{let t=ca(e,void 0);return()=>t}catch{return}}function H2(e){return at(e)&&"typeName"in e._def&&e._def.typeName==="ZodEffects"}function G2(e){return Ve(e)&&e._zod.def.type==="pipe"}function _o(e,t,r){let i=r.get(e);if(i!==void 0)return i;if(at(e))return H2(e)?_o(e._def.schema,t,r):e;if(Ve(e)){let n=e;if(G2(e)&&(n=_o(e._zod.def.in,t,r)),t){if(Zr(n)){let o={};for(let[s,c]of Object.entries(n._zod.def.shape))o[s]=_o(c,t,r);n=We(n,{...n._zod.def,shape:o})}else if(Pl(n)){let o=_o(n._zod.def.element,t,r);n=We(n,{...n._zod.def,element:o})}else if(iw(n)){let o=_o(n._zod.def.innerType,t,r);n=We(n,{...n._zod.def,innerType:o})}else if(aw(n)){let o=_o(n._zod.def.innerType,t,r);n=We(n,{...n._zod.def,innerType:o})}}let a=Ne.get(e);return a&&Ne.add(n,a),r.set(e,n),n}throw new Error("Schema must be an instance of z3.ZodType or z4.$ZodType")}function vp(e,t=!1){return _o(e,t,new WeakMap)}function PC(e,t){if(at(e)){let r=vi(e),i={};for(let[n,a]of Object.entries(r))t(n,a)?i[n]=a.optional():i[n]=a;return e.extend(i)}if(Ve(e)){let r=vi(e),i={...e._zod.def.shape};for(let[o,s]of Object.entries(r))t(o,s)&&(i[o]=new fo({type:"optional",innerType:s}));let n=We(e,{...e._zod.def,shape:i}),a=Ne.get(e);return a&&Ne.add(n,a),n}throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject")}function bp(e){return e instanceof Error&&(e.constructor.name==="ZodError"||e.constructor.name==="$ZodError")}var RC=Symbol("Let zodToJsonSchema decide on which parser to use"),NC={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref",openAiAnyTypeName:"OpenAiAnyType"},MC=e=>typeof e=="string"?{...NC,name:e}:{...NC,...e};var jC=e=>{let t=MC(e),r=t.name!==void 0?[...t.basePath,t.definitionPath,t.name]:t.basePath;return{...t,flags:{hasReferencedOpenAiAnyType:!1},currentPath:r,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([i,n])=>[n._def,{def:n._def,path:[...t.basePath,t.definitionPath,i],jsonSchema:void 0}]))}};var wp=(e,t)=>{let r=0;for(;r<e.length&&r<t.length&&e[r]===t[r];r++);return[(e.length-r).toString(),...t.slice(r)].join("/")};function Ye(e){if(e.target!=="openAi")return{};let t=[...e.basePath,e.definitionPath,e.openAiAnyTypeName];return e.flags.hasReferencedOpenAiAnyType=!0,{$ref:e.$refStrategy==="relative"?wp(t,e.currentPath):t.join("/")}}function ow(e,t,r,i){i?.errorMessages&&r&&(e.errorMessage={...e.errorMessage,[t]:r})}function Oe(e,t,r,i,n){e[t]=r,ow(e,t,i,n)}var It={};Tn(It,{BRAND:()=>yL,DIRTY:()=>yo,EMPTY_PATH:()=>q2,INVALID:()=>oe,NEVER:()=>r6,OK:()=>Vt,ParseStatus:()=>Pt,Schema:()=>ve,ZodAny:()=>va,ZodArray:()=>ki,ZodBigInt:()=>bo,ZodBoolean:()=>wo,ZodBranded:()=>Rl,ZodCatch:()=>Po,ZodDate:()=>xo,ZodDefault:()=>Oo,ZodDiscriminatedUnion:()=>kp,ZodEffects:()=>Wr,ZodEnum:()=>Co,ZodError:()=>_r,ZodFirstPartyTypeKind:()=>U,ZodFunction:()=>Ep,ZodIntersection:()=>Eo,ZodIssueCode:()=>D,ZodLazy:()=>Io,ZodLiteral:()=>To,ZodMap:()=>Ks,ZodNaN:()=>Xs,ZodNativeEnum:()=>Ao,ZodNever:()=>un,ZodNull:()=>ko,ZodNullable:()=>Wn,ZodNumber:()=>vo,ZodObject:()=>yr,ZodOptional:()=>Hr,ZodParsedType:()=>X,ZodPipeline:()=>Ml,ZodPromise:()=>ba,ZodReadonly:()=>No,ZodRecord:()=>$p,ZodSchema:()=>ve,ZodSet:()=>qs,ZodString:()=>ya,ZodSymbol:()=>Ws,ZodTransformer:()=>Wr,ZodTuple:()=>Gn,ZodType:()=>ve,ZodUndefined:()=>So,ZodUnion:()=>$o,ZodUnknown:()=>Si,ZodVoid:()=>Js,addIssueToContext:()=>H,any:()=>IL,array:()=>OL,bigint:()=>xL,boolean:()=>WC,coerce:()=>t6,custom:()=>ZC,date:()=>SL,datetimeRegex:()=>BC,defaultErrorMap:()=>wi,discriminatedUnion:()=>ML,effect:()=>WL,enum:()=>ZL,function:()=>FL,getErrorMap:()=>Zs,getParsedType:()=>Hn,instanceof:()=>bL,intersection:()=>jL,isAborted:()=>xp,isAsync:()=>Hs,isDirty:()=>Sp,isValid:()=>_a,late:()=>vL,lazy:()=>BL,literal:()=>VL,makeIssue:()=>Nl,map:()=>UL,nan:()=>wL,nativeEnum:()=>HL,never:()=>CL,null:()=>EL,nullable:()=>KL,number:()=>GC,object:()=>PL,objectUtil:()=>sw,oboolean:()=>e6,onumber:()=>QL,optional:()=>JL,ostring:()=>YL,pipeline:()=>XL,preprocess:()=>qL,promise:()=>GL,quotelessJson:()=>W2,record:()=>DL,set:()=>LL,setErrorMap:()=>K2,strictObject:()=>NL,string:()=>HC,symbol:()=>kL,transformer:()=>WL,tuple:()=>zL,undefined:()=>$L,union:()=>RL,unknown:()=>TL,util:()=>Ee,void:()=>AL});var Ee;(function(e){e.assertEqual=n=>{};function t(n){}e.assertIs=t;function r(n){throw new Error}e.assertNever=r,e.arrayToEnum=n=>{let a={};for(let o of n)a[o]=o;return a},e.getValidEnumValues=n=>{let a=e.objectKeys(n).filter(s=>typeof n[n[s]]!="number"),o={};for(let s of a)o[s]=n[s];return e.objectValues(o)},e.objectValues=n=>e.objectKeys(n).map(function(a){return n[a]}),e.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{let a=[];for(let o in n)Object.prototype.hasOwnProperty.call(n,o)&&a.push(o);return a},e.find=(n,a)=>{for(let o of n)if(a(o))return o},e.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&Number.isFinite(n)&&Math.floor(n)===n;function i(n,a=" | "){return n.map(o=>typeof o=="string"?`'${o}'`:o).join(a)}e.joinValues=i,e.jsonStringifyReplacer=(n,a)=>typeof a=="bigint"?a.toString():a})(Ee||(Ee={}));var sw;(function(e){e.mergeShapes=(t,r)=>({...t,...r})})(sw||(sw={}));var X=Ee.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Hn=e=>{switch(typeof e){case"undefined":return X.undefined;case"string":return X.string;case"number":return Number.isNaN(e)?X.nan:X.number;case"boolean":return X.boolean;case"function":return X.function;case"bigint":return X.bigint;case"symbol":return X.symbol;case"object":return Array.isArray(e)?X.array:e===null?X.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?X.promise:typeof Map<"u"&&e instanceof Map?X.map:typeof Set<"u"&&e instanceof Set?X.set:typeof Date<"u"&&e instanceof Date?X.date:X.object;default:return X.unknown}};var D=Ee.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),W2=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),_r=class e extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=i=>{this.issues=[...this.issues,i]},this.addIssues=(i=[])=>{this.issues=[...this.issues,...i]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=t}format(t){let r=t||function(a){return a.message},i={_errors:[]},n=a=>{for(let o of a.issues)if(o.code==="invalid_union")o.unionErrors.map(n);else if(o.code==="invalid_return_type")n(o.returnTypeError);else if(o.code==="invalid_arguments")n(o.argumentsError);else if(o.path.length===0)i._errors.push(r(o));else{let s=i,c=0;for(;c<o.path.length;){let l=o.path[c];c===o.path.length-1?(s[l]=s[l]||{_errors:[]},s[l]._errors.push(r(o))):s[l]=s[l]||{_errors:[]},s=s[l],c++}}};return n(this),i}static assert(t){if(!(t instanceof e))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Ee.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=r=>r.message){let r=Object.create(null),i=[];for(let n of this.issues)if(n.path.length>0){let a=n.path[0];r[a]=r[a]||[],r[a].push(t(n))}else i.push(t(n));return{formErrors:i,fieldErrors:r}}get formErrors(){return this.flatten()}};_r.create=e=>new _r(e);var J2=(e,t)=>{let r;switch(e.code){case D.invalid_type:e.received===X.undefined?r="Required":r=`Expected ${e.expected}, received ${e.received}`;break;case D.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,Ee.jsonStringifyReplacer)}`;break;case D.unrecognized_keys:r=`Unrecognized key(s) in object: ${Ee.joinValues(e.keys,", ")}`;break;case D.invalid_union:r="Invalid input";break;case D.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${Ee.joinValues(e.options)}`;break;case D.invalid_enum_value:r=`Invalid enum value. Expected ${Ee.joinValues(e.options)}, received '${e.received}'`;break;case D.invalid_arguments:r="Invalid function arguments";break;case D.invalid_return_type:r="Invalid function return type";break;case D.invalid_date:r="Invalid date";break;case D.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(r=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?r=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?r=`Invalid input: must end with "${e.validation.endsWith}"`:Ee.assertNever(e.validation):e.validation!=="regex"?r=`Invalid ${e.validation}`:r="Invalid";break;case D.too_small:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:r="Invalid input";break;case D.too_big:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?r=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:r="Invalid input";break;case D.custom:r="Invalid input";break;case D.invalid_intersection_types:r="Intersection results could not be merged";break;case D.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case D.not_finite:r="Number must be finite";break;default:r=t.defaultError,Ee.assertNever(e)}return{message:r}},wi=J2;var zC=wi;function K2(e){zC=e}function Zs(){return zC}var Nl=e=>{let{data:t,path:r,errorMaps:i,issueData:n}=e,a=[...r,...n.path||[]],o={...n,path:a};if(n.message!==void 0)return{...n,path:a,message:n.message};let s="",c=i.filter(l=>!!l).slice().reverse();for(let l of c)s=l(o,{data:t,defaultError:s}).message;return{...n,path:a,message:s}},q2=[];function H(e,t){let r=Zs(),i=Nl({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===wi?void 0:wi].filter(n=>!!n)});e.common.issues.push(i)}var Pt=class e{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,r){let i=[];for(let n of r){if(n.status==="aborted")return oe;n.status==="dirty"&&t.dirty(),i.push(n.value)}return{status:t.value,value:i}}static async mergeObjectAsync(t,r){let i=[];for(let n of r){let a=await n.key,o=await n.value;i.push({key:a,value:o})}return e.mergeObjectSync(t,i)}static mergeObjectSync(t,r){let i={};for(let n of r){let{key:a,value:o}=n;if(a.status==="aborted"||o.status==="aborted")return oe;a.status==="dirty"&&t.dirty(),o.status==="dirty"&&t.dirty(),a.value!=="__proto__"&&(typeof o.value<"u"||n.alwaysSet)&&(i[a.value]=o.value)}return{status:t.value,value:i}}},oe=Object.freeze({status:"aborted"}),yo=e=>({status:"dirty",value:e}),Vt=e=>({status:"valid",value:e}),xp=e=>e.status==="aborted",Sp=e=>e.status==="dirty",_a=e=>e.status==="valid",Hs=e=>typeof Promise<"u"&&e instanceof Promise;var ne;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(ne||(ne={}));var Gr=class{constructor(t,r,i,n){this._cachedPath=[],this.parent=t,this.data=r,this._path=i,this._key=n}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},DC=(e,t)=>{if(_a(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new _r(e.common.issues);return this._error=r,this._error}}};function he(e){if(!e)return{};let{errorMap:t,invalid_type_error:r,required_error:i,description:n}=e;if(t&&(r||i))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:n}:{errorMap:(o,s)=>{let{message:c}=e;return o.code==="invalid_enum_value"?{message:c??s.defaultError}:typeof s.data>"u"?{message:c??i??s.defaultError}:o.code!=="invalid_type"?{message:s.defaultError}:{message:c??r??s.defaultError}},description:n}}var ve=class{get description(){return this._def.description}_getType(t){return Hn(t.data)}_getOrReturnCtx(t,r){return r||{common:t.parent.common,data:t.data,parsedType:Hn(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new Pt,ctx:{common:t.parent.common,data:t.data,parsedType:Hn(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let r=this._parse(t);if(Hs(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(t){let r=this._parse(t);return Promise.resolve(r)}parse(t,r){let i=this.safeParse(t,r);if(i.success)return i.data;throw i.error}safeParse(t,r){let i={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Hn(t)},n=this._parseSync({data:t,path:i.path,parent:i});return DC(i,n)}"~validate"(t){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Hn(t)};if(!this["~standard"].async)try{let i=this._parseSync({data:t,path:[],parent:r});return _a(i)?{value:i.value}:{issues:r.common.issues}}catch(i){i?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:r}).then(i=>_a(i)?{value:i.value}:{issues:r.common.issues})}async parseAsync(t,r){let i=await this.safeParseAsync(t,r);if(i.success)return i.data;throw i.error}async safeParseAsync(t,r){let i={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Hn(t)},n=this._parse({data:t,path:i.path,parent:i}),a=await(Hs(n)?n:Promise.resolve(n));return DC(i,a)}refine(t,r){let i=n=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(n):r;return this._refinement((n,a)=>{let o=t(n),s=()=>a.addIssue({code:D.custom,...i(n)});return typeof Promise<"u"&&o instanceof Promise?o.then(c=>c?!0:(s(),!1)):o?!0:(s(),!1)})}refinement(t,r){return this._refinement((i,n)=>t(i)?!0:(n.addIssue(typeof r=="function"?r(i,n):r),!1))}_refinement(t){return new Wr({schema:this,typeName:U.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return Hr.create(this,this._def)}nullable(){return Wn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ki.create(this)}promise(){return ba.create(this,this._def)}or(t){return $o.create([this,t],this._def)}and(t){return Eo.create(this,t,this._def)}transform(t){return new Wr({...he(this._def),schema:this,typeName:U.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let r=typeof t=="function"?t:()=>t;return new Oo({...he(this._def),innerType:this,defaultValue:r,typeName:U.ZodDefault})}brand(){return new Rl({typeName:U.ZodBranded,type:this,...he(this._def)})}catch(t){let r=typeof t=="function"?t:()=>t;return new Po({...he(this._def),innerType:this,catchValue:r,typeName:U.ZodCatch})}describe(t){let r=this.constructor;return new r({...this._def,description:t})}pipe(t){return Ml.create(this,t)}readonly(){return No.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},X2=/^c[^\s-]{8,}$/i,Y2=/^[0-9a-z]+$/,Q2=/^[0-9A-HJKMNP-TV-Z]{26}$/i,eL=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,tL=/^[a-z0-9_-]{21}$/i,rL=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,nL=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,iL=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,aL="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",cw,oL=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,sL=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,cL=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,lL=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,uL=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,dL=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,LC="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",fL=new RegExp(`^${LC}$`);function FC(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);let r=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${r}`}function pL(e){return new RegExp(`^${FC(e)}$`)}function BC(e){let t=`${LC}T${FC(e)}`,r=[];return r.push(e.local?"Z?":"Z"),e.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,new RegExp(`^${t}$`)}function mL(e,t){return!!((t==="v4"||!t)&&oL.test(e)||(t==="v6"||!t)&&cL.test(e))}function hL(e,t){if(!rL.test(e))return!1;try{let[r]=e.split(".");if(!r)return!1;let i=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),n=JSON.parse(atob(i));return!(typeof n!="object"||n===null||"typ"in n&&n?.typ!=="JWT"||!n.alg||t&&n.alg!==t)}catch{return!1}}function gL(e,t){return!!((t==="v4"||!t)&&sL.test(e)||(t==="v6"||!t)&&lL.test(e))}var ya=class e extends ve{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==X.string){let a=this._getOrReturnCtx(t);return H(a,{code:D.invalid_type,expected:X.string,received:a.parsedType}),oe}let i=new Pt,n;for(let a of this._def.checks)if(a.kind==="min")t.data.length<a.value&&(n=this._getOrReturnCtx(t,n),H(n,{code:D.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),i.dirty());else if(a.kind==="max")t.data.length>a.value&&(n=this._getOrReturnCtx(t,n),H(n,{code:D.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),i.dirty());else if(a.kind==="length"){let o=t.data.length>a.value,s=t.data.length<a.value;(o||s)&&(n=this._getOrReturnCtx(t,n),o?H(n,{code:D.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):s&&H(n,{code:D.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),i.dirty())}else if(a.kind==="email")iL.test(t.data)||(n=this._getOrReturnCtx(t,n),H(n,{validation:"email",code:D.invalid_string,message:a.message}),i.dirty());else if(a.kind==="emoji")cw||(cw=new RegExp(aL,"u")),cw.test(t.data)||(n=this._getOrReturnCtx(t,n),H(n,{validation:"emoji",code:D.invalid_string,message:a.message}),i.dirty());else if(a.kind==="uuid")eL.test(t.data)||(n=this._getOrReturnCtx(t,n),H(n,{validation:"uuid",code:D.invalid_string,message:a.message}),i.dirty());else if(a.kind==="nanoid")tL.test(t.data)||(n=this._getOrReturnCtx(t,n),H(n,{validation:"nanoid",code:D.invalid_string,message:a.message}),i.dirty());else if(a.kind==="cuid")X2.test(t.data)||(n=this._getOrReturnCtx(t,n),H(n,{validation:"cuid",code:D.invalid_string,message:a.message}),i.dirty());else if(a.kind==="cuid2")Y2.test(t.data)||(n=this._getOrReturnCtx(t,n),H(n,{validation:"cuid2",code:D.invalid_string,message:a.message}),i.dirty());else if(a.kind==="ulid")Q2.test(t.data)||(n=this._getOrReturnCtx(t,n),H(n,{validation:"ulid",code:D.invalid_string,message:a.message}),i.dirty());else if(a.kind==="url")try{new URL(t.data)}catch{n=this._getOrReturnCtx(t,n),H(n,{validation:"url",code:D.invalid_string,message:a.message}),i.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(t.data)||(n=this._getOrReturnCtx(t,n),H(n,{validation:"regex",code:D.invalid_string,message:a.message}),i.dirty())):a.kind==="trim"?t.data=t.data.trim():a.kind==="includes"?t.data.includes(a.value,a.position)||(n=this._getOrReturnCtx(t,n),H(n,{code:D.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),i.dirty()):a.kind==="toLowerCase"?t.data=t.data.toLowerCase():a.kind==="toUpperCase"?t.data=t.data.toUpperCase():a.kind==="startsWith"?t.data.startsWith(a.value)||(n=this._getOrReturnCtx(t,n),H(n,{code:D.invalid_string,validation:{startsWith:a.value},message:a.message}),i.dirty()):a.kind==="endsWith"?t.data.endsWith(a.value)||(n=this._getOrReturnCtx(t,n),H(n,{code:D.invalid_string,validation:{endsWith:a.value},message:a.message}),i.dirty()):a.kind==="datetime"?BC(a).test(t.data)||(n=this._getOrReturnCtx(t,n),H(n,{code:D.invalid_string,validation:"datetime",message:a.message}),i.dirty()):a.kind==="date"?fL.test(t.data)||(n=this._getOrReturnCtx(t,n),H(n,{code:D.invalid_string,validation:"date",message:a.message}),i.dirty()):a.kind==="time"?pL(a).test(t.data)||(n=this._getOrReturnCtx(t,n),H(n,{code:D.invalid_string,validation:"time",message:a.message}),i.dirty()):a.kind==="duration"?nL.test(t.data)||(n=this._getOrReturnCtx(t,n),H(n,{validation:"duration",code:D.invalid_string,message:a.message}),i.dirty()):a.kind==="ip"?mL(t.data,a.version)||(n=this._getOrReturnCtx(t,n),H(n,{validation:"ip",code:D.invalid_string,message:a.message}),i.dirty()):a.kind==="jwt"?hL(t.data,a.alg)||(n=this._getOrReturnCtx(t,n),H(n,{validation:"jwt",code:D.invalid_string,message:a.message}),i.dirty()):a.kind==="cidr"?gL(t.data,a.version)||(n=this._getOrReturnCtx(t,n),H(n,{validation:"cidr",code:D.invalid_string,message:a.message}),i.dirty()):a.kind==="base64"?uL.test(t.data)||(n=this._getOrReturnCtx(t,n),H(n,{validation:"base64",code:D.invalid_string,message:a.message}),i.dirty()):a.kind==="base64url"?dL.test(t.data)||(n=this._getOrReturnCtx(t,n),H(n,{validation:"base64url",code:D.invalid_string,message:a.message}),i.dirty()):Ee.assertNever(a);return{status:i.value,value:t.data}}_regex(t,r,i){return this.refinement(n=>t.test(n),{validation:r,code:D.invalid_string,...ne.errToObj(i)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...ne.errToObj(t)})}url(t){return this._addCheck({kind:"url",...ne.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...ne.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...ne.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...ne.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...ne.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...ne.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...ne.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...ne.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...ne.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...ne.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...ne.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...ne.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:t?.offset??!1,local:t?.local??!1,...ne.errToObj(t?.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof t?.precision>"u"?null:t?.precision,...ne.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...ne.errToObj(t)})}regex(t,r){return this._addCheck({kind:"regex",regex:t,...ne.errToObj(r)})}includes(t,r){return this._addCheck({kind:"includes",value:t,position:r?.position,...ne.errToObj(r?.message)})}startsWith(t,r){return this._addCheck({kind:"startsWith",value:t,...ne.errToObj(r)})}endsWith(t,r){return this._addCheck({kind:"endsWith",value:t,...ne.errToObj(r)})}min(t,r){return this._addCheck({kind:"min",value:t,...ne.errToObj(r)})}max(t,r){return this._addCheck({kind:"max",value:t,...ne.errToObj(r)})}length(t,r){return this._addCheck({kind:"length",value:t,...ne.errToObj(r)})}nonempty(t){return this.min(1,ne.errToObj(t))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxLength(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};ya.create=e=>new ya({checks:[],typeName:U.ZodString,coerce:e?.coerce??!1,...he(e)});function _L(e,t){let r=(e.toString().split(".")[1]||"").length,i=(t.toString().split(".")[1]||"").length,n=r>i?r:i,a=Number.parseInt(e.toFixed(n).replace(".","")),o=Number.parseInt(t.toFixed(n).replace(".",""));return a%o/10**n}var vo=class e extends ve{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==X.number){let a=this._getOrReturnCtx(t);return H(a,{code:D.invalid_type,expected:X.number,received:a.parsedType}),oe}let i,n=new Pt;for(let a of this._def.checks)a.kind==="int"?Ee.isInteger(t.data)||(i=this._getOrReturnCtx(t,i),H(i,{code:D.invalid_type,expected:"integer",received:"float",message:a.message}),n.dirty()):a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(i=this._getOrReturnCtx(t,i),H(i,{code:D.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),n.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(i=this._getOrReturnCtx(t,i),H(i,{code:D.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),n.dirty()):a.kind==="multipleOf"?_L(t.data,a.value)!==0&&(i=this._getOrReturnCtx(t,i),H(i,{code:D.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):a.kind==="finite"?Number.isFinite(t.data)||(i=this._getOrReturnCtx(t,i),H(i,{code:D.not_finite,message:a.message}),n.dirty()):Ee.assertNever(a);return{status:n.value,value:t.data}}gte(t,r){return this.setLimit("min",t,!0,ne.toString(r))}gt(t,r){return this.setLimit("min",t,!1,ne.toString(r))}lte(t,r){return this.setLimit("max",t,!0,ne.toString(r))}lt(t,r){return this.setLimit("max",t,!1,ne.toString(r))}setLimit(t,r,i,n){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:i,message:ne.toString(n)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:ne.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:ne.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:ne.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:ne.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:ne.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:ne.toString(r)})}finite(t){return this._addCheck({kind:"finite",message:ne.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:ne.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:ne.toString(t)})}get minValue(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&Ee.isInteger(t.value))}get isFinite(){let t=null,r=null;for(let i of this._def.checks){if(i.kind==="finite"||i.kind==="int"||i.kind==="multipleOf")return!0;i.kind==="min"?(r===null||i.value>r)&&(r=i.value):i.kind==="max"&&(t===null||i.value<t)&&(t=i.value)}return Number.isFinite(r)&&Number.isFinite(t)}};vo.create=e=>new vo({checks:[],typeName:U.ZodNumber,coerce:e?.coerce||!1,...he(e)});var bo=class e extends ve{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==X.bigint)return this._getInvalidInput(t);let i,n=new Pt;for(let a of this._def.checks)a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(i=this._getOrReturnCtx(t,i),H(i,{code:D.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),n.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(i=this._getOrReturnCtx(t,i),H(i,{code:D.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),n.dirty()):a.kind==="multipleOf"?t.data%a.value!==BigInt(0)&&(i=this._getOrReturnCtx(t,i),H(i,{code:D.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):Ee.assertNever(a);return{status:n.value,value:t.data}}_getInvalidInput(t){let r=this._getOrReturnCtx(t);return H(r,{code:D.invalid_type,expected:X.bigint,received:r.parsedType}),oe}gte(t,r){return this.setLimit("min",t,!0,ne.toString(r))}gt(t,r){return this.setLimit("min",t,!1,ne.toString(r))}lte(t,r){return this.setLimit("max",t,!0,ne.toString(r))}lt(t,r){return this.setLimit("max",t,!1,ne.toString(r))}setLimit(t,r,i,n){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:i,message:ne.toString(n)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:ne.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:ne.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:ne.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:ne.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:ne.toString(r)})}get minValue(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};bo.create=e=>new bo({checks:[],typeName:U.ZodBigInt,coerce:e?.coerce??!1,...he(e)});var wo=class extends ve{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==X.boolean){let i=this._getOrReturnCtx(t);return H(i,{code:D.invalid_type,expected:X.boolean,received:i.parsedType}),oe}return Vt(t.data)}};wo.create=e=>new wo({typeName:U.ZodBoolean,coerce:e?.coerce||!1,...he(e)});var xo=class e extends ve{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==X.date){let a=this._getOrReturnCtx(t);return H(a,{code:D.invalid_type,expected:X.date,received:a.parsedType}),oe}if(Number.isNaN(t.data.getTime())){let a=this._getOrReturnCtx(t);return H(a,{code:D.invalid_date}),oe}let i=new Pt,n;for(let a of this._def.checks)a.kind==="min"?t.data.getTime()<a.value&&(n=this._getOrReturnCtx(t,n),H(n,{code:D.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),i.dirty()):a.kind==="max"?t.data.getTime()>a.value&&(n=this._getOrReturnCtx(t,n),H(n,{code:D.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),i.dirty()):Ee.assertNever(a);return{status:i.value,value:new Date(t.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(t,r){return this._addCheck({kind:"min",value:t.getTime(),message:ne.toString(r)})}max(t,r){return this._addCheck({kind:"max",value:t.getTime(),message:ne.toString(r)})}get minDate(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t!=null?new Date(t):null}};xo.create=e=>new xo({checks:[],coerce:e?.coerce||!1,typeName:U.ZodDate,...he(e)});var Ws=class extends ve{_parse(t){if(this._getType(t)!==X.symbol){let i=this._getOrReturnCtx(t);return H(i,{code:D.invalid_type,expected:X.symbol,received:i.parsedType}),oe}return Vt(t.data)}};Ws.create=e=>new Ws({typeName:U.ZodSymbol,...he(e)});var So=class extends ve{_parse(t){if(this._getType(t)!==X.undefined){let i=this._getOrReturnCtx(t);return H(i,{code:D.invalid_type,expected:X.undefined,received:i.parsedType}),oe}return Vt(t.data)}};So.create=e=>new So({typeName:U.ZodUndefined,...he(e)});var ko=class extends ve{_parse(t){if(this._getType(t)!==X.null){let i=this._getOrReturnCtx(t);return H(i,{code:D.invalid_type,expected:X.null,received:i.parsedType}),oe}return Vt(t.data)}};ko.create=e=>new ko({typeName:U.ZodNull,...he(e)});var va=class extends ve{constructor(){super(...arguments),this._any=!0}_parse(t){return Vt(t.data)}};va.create=e=>new va({typeName:U.ZodAny,...he(e)});var Si=class extends ve{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Vt(t.data)}};Si.create=e=>new Si({typeName:U.ZodUnknown,...he(e)});var un=class extends ve{_parse(t){let r=this._getOrReturnCtx(t);return H(r,{code:D.invalid_type,expected:X.never,received:r.parsedType}),oe}};un.create=e=>new un({typeName:U.ZodNever,...he(e)});var Js=class extends ve{_parse(t){if(this._getType(t)!==X.undefined){let i=this._getOrReturnCtx(t);return H(i,{code:D.invalid_type,expected:X.void,received:i.parsedType}),oe}return Vt(t.data)}};Js.create=e=>new Js({typeName:U.ZodVoid,...he(e)});var ki=class e extends ve{_parse(t){let{ctx:r,status:i}=this._processInputParams(t),n=this._def;if(r.parsedType!==X.array)return H(r,{code:D.invalid_type,expected:X.array,received:r.parsedType}),oe;if(n.exactLength!==null){let o=r.data.length>n.exactLength.value,s=r.data.length<n.exactLength.value;(o||s)&&(H(r,{code:o?D.too_big:D.too_small,minimum:s?n.exactLength.value:void 0,maximum:o?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),i.dirty())}if(n.minLength!==null&&r.data.length<n.minLength.value&&(H(r,{code:D.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),i.dirty()),n.maxLength!==null&&r.data.length>n.maxLength.value&&(H(r,{code:D.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),i.dirty()),r.common.async)return Promise.all([...r.data].map((o,s)=>n.type._parseAsync(new Gr(r,o,r.path,s)))).then(o=>Pt.mergeArray(i,o));let a=[...r.data].map((o,s)=>n.type._parseSync(new Gr(r,o,r.path,s)));return Pt.mergeArray(i,a)}get element(){return this._def.type}min(t,r){return new e({...this._def,minLength:{value:t,message:ne.toString(r)}})}max(t,r){return new e({...this._def,maxLength:{value:t,message:ne.toString(r)}})}length(t,r){return new e({...this._def,exactLength:{value:t,message:ne.toString(r)}})}nonempty(t){return this.min(1,t)}};ki.create=(e,t)=>new ki({type:e,minLength:null,maxLength:null,exactLength:null,typeName:U.ZodArray,...he(t)});function Gs(e){if(e instanceof yr){let t={};for(let r in e.shape){let i=e.shape[r];t[r]=Hr.create(Gs(i))}return new yr({...e._def,shape:()=>t})}else return e instanceof ki?new ki({...e._def,type:Gs(e.element)}):e instanceof Hr?Hr.create(Gs(e.unwrap())):e instanceof Wn?Wn.create(Gs(e.unwrap())):e instanceof Gn?Gn.create(e.items.map(t=>Gs(t))):e}var yr=class e extends ve{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let t=this._def.shape(),r=Ee.objectKeys(t);return this._cached={shape:t,keys:r},this._cached}_parse(t){if(this._getType(t)!==X.object){let l=this._getOrReturnCtx(t);return H(l,{code:D.invalid_type,expected:X.object,received:l.parsedType}),oe}let{status:i,ctx:n}=this._processInputParams(t),{shape:a,keys:o}=this._getCached(),s=[];if(!(this._def.catchall instanceof un&&this._def.unknownKeys==="strip"))for(let l in n.data)o.includes(l)||s.push(l);let c=[];for(let l of o){let u=a[l],d=n.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new Gr(n,d,n.path,l)),alwaysSet:l in n.data})}if(this._def.catchall instanceof un){let l=this._def.unknownKeys;if(l==="passthrough")for(let u of s)c.push({key:{status:"valid",value:u},value:{status:"valid",value:n.data[u]}});else if(l==="strict")s.length>0&&(H(n,{code:D.unrecognized_keys,keys:s}),i.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let l=this._def.catchall;for(let u of s){let d=n.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new Gr(n,d,n.path,u)),alwaysSet:u in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let l=[];for(let u of c){let d=await u.key,f=await u.value;l.push({key:d,value:f,alwaysSet:u.alwaysSet})}return l}).then(l=>Pt.mergeObjectSync(i,l)):Pt.mergeObjectSync(i,c)}get shape(){return this._def.shape()}strict(t){return ne.errToObj,new e({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(r,i)=>{let n=this._def.errorMap?.(r,i).message??i.defaultError;return r.code==="unrecognized_keys"?{message:ne.errToObj(t).message??n}:{message:n}}}:{}})}strip(){return new e({...this._def,unknownKeys:"strip"})}passthrough(){return new e({...this._def,unknownKeys:"passthrough"})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:U.ZodObject})}setKey(t,r){return this.augment({[t]:r})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let r={};for(let i of Ee.objectKeys(t))t[i]&&this.shape[i]&&(r[i]=this.shape[i]);return new e({...this._def,shape:()=>r})}omit(t){let r={};for(let i of Ee.objectKeys(this.shape))t[i]||(r[i]=this.shape[i]);return new e({...this._def,shape:()=>r})}deepPartial(){return Gs(this)}partial(t){let r={};for(let i of Ee.objectKeys(this.shape)){let n=this.shape[i];t&&!t[i]?r[i]=n:r[i]=n.optional()}return new e({...this._def,shape:()=>r})}required(t){let r={};for(let i of Ee.objectKeys(this.shape))if(t&&!t[i])r[i]=this.shape[i];else{let a=this.shape[i];for(;a instanceof Hr;)a=a._def.innerType;r[i]=a}return new e({...this._def,shape:()=>r})}keyof(){return VC(Ee.objectKeys(this.shape))}};yr.create=(e,t)=>new yr({shape:()=>e,unknownKeys:"strip",catchall:un.create(),typeName:U.ZodObject,...he(t)});yr.strictCreate=(e,t)=>new yr({shape:()=>e,unknownKeys:"strict",catchall:un.create(),typeName:U.ZodObject,...he(t)});yr.lazycreate=(e,t)=>new yr({shape:e,unknownKeys:"strip",catchall:un.create(),typeName:U.ZodObject,...he(t)});var $o=class extends ve{_parse(t){let{ctx:r}=this._processInputParams(t),i=this._def.options;function n(a){for(let s of a)if(s.result.status==="valid")return s.result;for(let s of a)if(s.result.status==="dirty")return r.common.issues.push(...s.ctx.common.issues),s.result;let o=a.map(s=>new _r(s.ctx.common.issues));return H(r,{code:D.invalid_union,unionErrors:o}),oe}if(r.common.async)return Promise.all(i.map(async a=>{let o={...r,common:{...r.common,issues:[]},parent:null};return{result:await a._parseAsync({data:r.data,path:r.path,parent:o}),ctx:o}})).then(n);{let a,o=[];for(let c of i){let l={...r,common:{...r.common,issues:[]},parent:null},u=c._parseSync({data:r.data,path:r.path,parent:l});if(u.status==="valid")return u;u.status==="dirty"&&!a&&(a={result:u,ctx:l}),l.common.issues.length&&o.push(l.common.issues)}if(a)return r.common.issues.push(...a.ctx.common.issues),a.result;let s=o.map(c=>new _r(c));return H(r,{code:D.invalid_union,unionErrors:s}),oe}}get options(){return this._def.options}};$o.create=(e,t)=>new $o({options:e,typeName:U.ZodUnion,...he(t)});var xi=e=>e instanceof Io?xi(e.schema):e instanceof Wr?xi(e.innerType()):e instanceof To?[e.value]:e instanceof Co?e.options:e instanceof Ao?Ee.objectValues(e.enum):e instanceof Oo?xi(e._def.innerType):e instanceof So?[void 0]:e instanceof ko?[null]:e instanceof Hr?[void 0,...xi(e.unwrap())]:e instanceof Wn?[null,...xi(e.unwrap())]:e instanceof Rl||e instanceof No?xi(e.unwrap()):e instanceof Po?xi(e._def.innerType):[],kp=class e extends ve{_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==X.object)return H(r,{code:D.invalid_type,expected:X.object,received:r.parsedType}),oe;let i=this.discriminator,n=r.data[i],a=this.optionsMap.get(n);return a?r.common.async?a._parseAsync({data:r.data,path:r.path,parent:r}):a._parseSync({data:r.data,path:r.path,parent:r}):(H(r,{code:D.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[i]}),oe)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,r,i){let n=new Map;for(let a of r){let o=xi(a.shape[t]);if(!o.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let s of o){if(n.has(s))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(s)}`);n.set(s,a)}}return new e({typeName:U.ZodDiscriminatedUnion,discriminator:t,options:r,optionsMap:n,...he(i)})}};function lw(e,t){let r=Hn(e),i=Hn(t);if(e===t)return{valid:!0,data:e};if(r===X.object&&i===X.object){let n=Ee.objectKeys(t),a=Ee.objectKeys(e).filter(s=>n.indexOf(s)!==-1),o={...e,...t};for(let s of a){let c=lw(e[s],t[s]);if(!c.valid)return{valid:!1};o[s]=c.data}return{valid:!0,data:o}}else if(r===X.array&&i===X.array){if(e.length!==t.length)return{valid:!1};let n=[];for(let a=0;a<e.length;a++){let o=e[a],s=t[a],c=lw(o,s);if(!c.valid)return{valid:!1};n.push(c.data)}return{valid:!0,data:n}}else return r===X.date&&i===X.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}var Eo=class extends ve{_parse(t){let{status:r,ctx:i}=this._processInputParams(t),n=(a,o)=>{if(xp(a)||xp(o))return oe;let s=lw(a.value,o.value);return s.valid?((Sp(a)||Sp(o))&&r.dirty(),{status:r.value,value:s.data}):(H(i,{code:D.invalid_intersection_types}),oe)};return i.common.async?Promise.all([this._def.left._parseAsync({data:i.data,path:i.path,parent:i}),this._def.right._parseAsync({data:i.data,path:i.path,parent:i})]).then(([a,o])=>n(a,o)):n(this._def.left._parseSync({data:i.data,path:i.path,parent:i}),this._def.right._parseSync({data:i.data,path:i.path,parent:i}))}};Eo.create=(e,t,r)=>new Eo({left:e,right:t,typeName:U.ZodIntersection,...he(r)});var Gn=class e extends ve{_parse(t){let{status:r,ctx:i}=this._processInputParams(t);if(i.parsedType!==X.array)return H(i,{code:D.invalid_type,expected:X.array,received:i.parsedType}),oe;if(i.data.length<this._def.items.length)return H(i,{code:D.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),oe;!this._def.rest&&i.data.length>this._def.items.length&&(H(i,{code:D.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let a=[...i.data].map((o,s)=>{let c=this._def.items[s]||this._def.rest;return c?c._parse(new Gr(i,o,i.path,s)):null}).filter(o=>!!o);return i.common.async?Promise.all(a).then(o=>Pt.mergeArray(r,o)):Pt.mergeArray(r,a)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};Gn.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Gn({items:e,typeName:U.ZodTuple,rest:null,...he(t)})};var $p=class e extends ve{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:i}=this._processInputParams(t);if(i.parsedType!==X.object)return H(i,{code:D.invalid_type,expected:X.object,received:i.parsedType}),oe;let n=[],a=this._def.keyType,o=this._def.valueType;for(let s in i.data)n.push({key:a._parse(new Gr(i,s,i.path,s)),value:o._parse(new Gr(i,i.data[s],i.path,s)),alwaysSet:s in i.data});return i.common.async?Pt.mergeObjectAsync(r,n):Pt.mergeObjectSync(r,n)}get element(){return this._def.valueType}static create(t,r,i){return r instanceof ve?new e({keyType:t,valueType:r,typeName:U.ZodRecord,...he(i)}):new e({keyType:ya.create(),valueType:t,typeName:U.ZodRecord,...he(r)})}},Ks=class extends ve{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:i}=this._processInputParams(t);if(i.parsedType!==X.map)return H(i,{code:D.invalid_type,expected:X.map,received:i.parsedType}),oe;let n=this._def.keyType,a=this._def.valueType,o=[...i.data.entries()].map(([s,c],l)=>({key:n._parse(new Gr(i,s,i.path,[l,"key"])),value:a._parse(new Gr(i,c,i.path,[l,"value"]))}));if(i.common.async){let s=new Map;return Promise.resolve().then(async()=>{for(let c of o){let l=await c.key,u=await c.value;if(l.status==="aborted"||u.status==="aborted")return oe;(l.status==="dirty"||u.status==="dirty")&&r.dirty(),s.set(l.value,u.value)}return{status:r.value,value:s}})}else{let s=new Map;for(let c of o){let l=c.key,u=c.value;if(l.status==="aborted"||u.status==="aborted")return oe;(l.status==="dirty"||u.status==="dirty")&&r.dirty(),s.set(l.value,u.value)}return{status:r.value,value:s}}}};Ks.create=(e,t,r)=>new Ks({valueType:t,keyType:e,typeName:U.ZodMap,...he(r)});var qs=class e extends ve{_parse(t){let{status:r,ctx:i}=this._processInputParams(t);if(i.parsedType!==X.set)return H(i,{code:D.invalid_type,expected:X.set,received:i.parsedType}),oe;let n=this._def;n.minSize!==null&&i.data.size<n.minSize.value&&(H(i,{code:D.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),r.dirty()),n.maxSize!==null&&i.data.size>n.maxSize.value&&(H(i,{code:D.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),r.dirty());let a=this._def.valueType;function o(c){let l=new Set;for(let u of c){if(u.status==="aborted")return oe;u.status==="dirty"&&r.dirty(),l.add(u.value)}return{status:r.value,value:l}}let s=[...i.data.values()].map((c,l)=>a._parse(new Gr(i,c,i.path,l)));return i.common.async?Promise.all(s).then(c=>o(c)):o(s)}min(t,r){return new e({...this._def,minSize:{value:t,message:ne.toString(r)}})}max(t,r){return new e({...this._def,maxSize:{value:t,message:ne.toString(r)}})}size(t,r){return this.min(t,r).max(t,r)}nonempty(t){return this.min(1,t)}};qs.create=(e,t)=>new qs({valueType:e,minSize:null,maxSize:null,typeName:U.ZodSet,...he(t)});var Ep=class e extends ve{constructor(){super(...arguments),this.validate=this.implement}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==X.function)return H(r,{code:D.invalid_type,expected:X.function,received:r.parsedType}),oe;function i(s,c){return Nl({data:s,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Zs(),wi].filter(l=>!!l),issueData:{code:D.invalid_arguments,argumentsError:c}})}function n(s,c){return Nl({data:s,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Zs(),wi].filter(l=>!!l),issueData:{code:D.invalid_return_type,returnTypeError:c}})}let a={errorMap:r.common.contextualErrorMap},o=r.data;if(this._def.returns instanceof ba){let s=this;return Vt(async function(...c){let l=new _r([]),u=await s._def.args.parseAsync(c,a).catch(p=>{throw l.addIssue(i(c,p)),l}),d=await Reflect.apply(o,this,u);return await s._def.returns._def.type.parseAsync(d,a).catch(p=>{throw l.addIssue(n(d,p)),l})})}else{let s=this;return Vt(function(...c){let l=s._def.args.safeParse(c,a);if(!l.success)throw new _r([i(c,l.error)]);let u=Reflect.apply(o,this,l.data),d=s._def.returns.safeParse(u,a);if(!d.success)throw new _r([n(u,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:Gn.create(t).rest(Si.create())})}returns(t){return new e({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,r,i){return new e({args:t||Gn.create([]).rest(Si.create()),returns:r||Si.create(),typeName:U.ZodFunction,...he(i)})}},Io=class extends ve{get schema(){return this._def.getter()}_parse(t){let{ctx:r}=this._processInputParams(t);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};Io.create=(e,t)=>new Io({getter:e,typeName:U.ZodLazy,...he(t)});var To=class extends ve{_parse(t){if(t.data!==this._def.value){let r=this._getOrReturnCtx(t);return H(r,{received:r.data,code:D.invalid_literal,expected:this._def.value}),oe}return{status:"valid",value:t.data}}get value(){return this._def.value}};To.create=(e,t)=>new To({value:e,typeName:U.ZodLiteral,...he(t)});function VC(e,t){return new Co({values:e,typeName:U.ZodEnum,...he(t)})}var Co=class e extends ve{_parse(t){if(typeof t.data!="string"){let r=this._getOrReturnCtx(t),i=this._def.values;return H(r,{expected:Ee.joinValues(i),received:r.parsedType,code:D.invalid_type}),oe}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){let r=this._getOrReturnCtx(t),i=this._def.values;return H(r,{received:r.data,code:D.invalid_enum_value,options:i}),oe}return Vt(t.data)}get options(){return this._def.values}get enum(){let t={};for(let r of this._def.values)t[r]=r;return t}get Values(){let t={};for(let r of this._def.values)t[r]=r;return t}get Enum(){let t={};for(let r of this._def.values)t[r]=r;return t}extract(t,r=this._def){return e.create(t,{...this._def,...r})}exclude(t,r=this._def){return e.create(this.options.filter(i=>!t.includes(i)),{...this._def,...r})}};Co.create=VC;var Ao=class extends ve{_parse(t){let r=Ee.getValidEnumValues(this._def.values),i=this._getOrReturnCtx(t);if(i.parsedType!==X.string&&i.parsedType!==X.number){let n=Ee.objectValues(r);return H(i,{expected:Ee.joinValues(n),received:i.parsedType,code:D.invalid_type}),oe}if(this._cache||(this._cache=new Set(Ee.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){let n=Ee.objectValues(r);return H(i,{received:i.data,code:D.invalid_enum_value,options:n}),oe}return Vt(t.data)}get enum(){return this._def.values}};Ao.create=(e,t)=>new Ao({values:e,typeName:U.ZodNativeEnum,...he(t)});var ba=class extends ve{unwrap(){return this._def.type}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==X.promise&&r.common.async===!1)return H(r,{code:D.invalid_type,expected:X.promise,received:r.parsedType}),oe;let i=r.parsedType===X.promise?r.data:Promise.resolve(r.data);return Vt(i.then(n=>this._def.type.parseAsync(n,{path:r.path,errorMap:r.common.contextualErrorMap})))}};ba.create=(e,t)=>new ba({type:e,typeName:U.ZodPromise,...he(t)});var Wr=class extends ve{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===U.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:r,ctx:i}=this._processInputParams(t),n=this._def.effect||null,a={addIssue:o=>{H(i,o),o.fatal?r.abort():r.dirty()},get path(){return i.path}};if(a.addIssue=a.addIssue.bind(a),n.type==="preprocess"){let o=n.transform(i.data,a);if(i.common.async)return Promise.resolve(o).then(async s=>{if(r.value==="aborted")return oe;let c=await this._def.schema._parseAsync({data:s,path:i.path,parent:i});return c.status==="aborted"?oe:c.status==="dirty"?yo(c.value):r.value==="dirty"?yo(c.value):c});{if(r.value==="aborted")return oe;let s=this._def.schema._parseSync({data:o,path:i.path,parent:i});return s.status==="aborted"?oe:s.status==="dirty"?yo(s.value):r.value==="dirty"?yo(s.value):s}}if(n.type==="refinement"){let o=s=>{let c=n.refinement(s,a);if(i.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return s};if(i.common.async===!1){let s=this._def.schema._parseSync({data:i.data,path:i.path,parent:i});return s.status==="aborted"?oe:(s.status==="dirty"&&r.dirty(),o(s.value),{status:r.value,value:s.value})}else return this._def.schema._parseAsync({data:i.data,path:i.path,parent:i}).then(s=>s.status==="aborted"?oe:(s.status==="dirty"&&r.dirty(),o(s.value).then(()=>({status:r.value,value:s.value}))))}if(n.type==="transform")if(i.common.async===!1){let o=this._def.schema._parseSync({data:i.data,path:i.path,parent:i});if(!_a(o))return oe;let s=n.transform(o.value,a);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:s}}else return this._def.schema._parseAsync({data:i.data,path:i.path,parent:i}).then(o=>_a(o)?Promise.resolve(n.transform(o.value,a)).then(s=>({status:r.value,value:s})):oe);Ee.assertNever(n)}};Wr.create=(e,t,r)=>new Wr({schema:e,typeName:U.ZodEffects,effect:t,...he(r)});Wr.createWithPreprocess=(e,t,r)=>new Wr({schema:t,effect:{type:"preprocess",transform:e},typeName:U.ZodEffects,...he(r)});var Hr=class extends ve{_parse(t){return this._getType(t)===X.undefined?Vt(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};Hr.create=(e,t)=>new Hr({innerType:e,typeName:U.ZodOptional,...he(t)});var Wn=class extends ve{_parse(t){return this._getType(t)===X.null?Vt(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};Wn.create=(e,t)=>new Wn({innerType:e,typeName:U.ZodNullable,...he(t)});var Oo=class extends ve{_parse(t){let{ctx:r}=this._processInputParams(t),i=r.data;return r.parsedType===X.undefined&&(i=this._def.defaultValue()),this._def.innerType._parse({data:i,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};Oo.create=(e,t)=>new Oo({innerType:e,typeName:U.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...he(t)});var Po=class extends ve{_parse(t){let{ctx:r}=this._processInputParams(t),i={...r,common:{...r.common,issues:[]}},n=this._def.innerType._parse({data:i.data,path:i.path,parent:{...i}});return Hs(n)?n.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new _r(i.common.issues)},input:i.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new _r(i.common.issues)},input:i.data})}}removeCatch(){return this._def.innerType}};Po.create=(e,t)=>new Po({innerType:e,typeName:U.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...he(t)});var Xs=class extends ve{_parse(t){if(this._getType(t)!==X.nan){let i=this._getOrReturnCtx(t);return H(i,{code:D.invalid_type,expected:X.nan,received:i.parsedType}),oe}return{status:"valid",value:t.data}}};Xs.create=e=>new Xs({typeName:U.ZodNaN,...he(e)});var yL=Symbol("zod_brand"),Rl=class extends ve{_parse(t){let{ctx:r}=this._processInputParams(t),i=r.data;return this._def.type._parse({data:i,path:r.path,parent:r})}unwrap(){return this._def.type}},Ml=class e extends ve{_parse(t){let{status:r,ctx:i}=this._processInputParams(t);if(i.common.async)return(async()=>{let a=await this._def.in._parseAsync({data:i.data,path:i.path,parent:i});return a.status==="aborted"?oe:a.status==="dirty"?(r.dirty(),yo(a.value)):this._def.out._parseAsync({data:a.value,path:i.path,parent:i})})();{let n=this._def.in._parseSync({data:i.data,path:i.path,parent:i});return n.status==="aborted"?oe:n.status==="dirty"?(r.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:i.path,parent:i})}}static create(t,r){return new e({in:t,out:r,typeName:U.ZodPipeline})}},No=class extends ve{_parse(t){let r=this._def.innerType._parse(t),i=n=>(_a(n)&&(n.value=Object.freeze(n.value)),n);return Hs(r)?r.then(n=>i(n)):i(r)}unwrap(){return this._def.innerType}};No.create=(e,t)=>new No({innerType:e,typeName:U.ZodReadonly,...he(t)});function UC(e,t){let r=typeof e=="function"?e(t):typeof e=="string"?{message:e}:e;return typeof r=="string"?{message:r}:r}function ZC(e,t={},r){return e?va.create().superRefine((i,n)=>{let a=e(i);if(a instanceof Promise)return a.then(o=>{if(!o){let s=UC(t,i),c=s.fatal??r??!0;n.addIssue({code:"custom",...s,fatal:c})}});if(!a){let o=UC(t,i),s=o.fatal??r??!0;n.addIssue({code:"custom",...o,fatal:s})}}):va.create()}var vL={object:yr.lazycreate},U;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(U||(U={}));var bL=(e,t={message:`Input not instance of ${e.name}`})=>ZC(r=>r instanceof e,t),HC=ya.create,GC=vo.create,wL=Xs.create,xL=bo.create,WC=wo.create,SL=xo.create,kL=Ws.create,$L=So.create,EL=ko.create,IL=va.create,TL=Si.create,CL=un.create,AL=Js.create,OL=ki.create,PL=yr.create,NL=yr.strictCreate,RL=$o.create,ML=kp.create,jL=Eo.create,zL=Gn.create,DL=$p.create,UL=Ks.create,LL=qs.create,FL=Ep.create,BL=Io.create,VL=To.create,ZL=Co.create,HL=Ao.create,GL=ba.create,WL=Wr.create,JL=Hr.create,KL=Wn.create,qL=Wr.createWithPreprocess,XL=Ml.create,YL=()=>HC().optional(),QL=()=>GC().optional(),e6=()=>WC().optional(),t6={string:(e=>ya.create({...e,coerce:!0})),number:(e=>vo.create({...e,coerce:!0})),boolean:(e=>wo.create({...e,coerce:!0})),bigint:(e=>bo.create({...e,coerce:!0})),date:(e=>xo.create({...e,coerce:!0}))};var r6=oe;function JC(e,t){let r={type:"array"};return e.type?._def&&e.type?._def?.typeName!==U.ZodAny&&(r.items=se(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&Oe(r,"minItems",e.minLength.value,e.minLength.message,t),e.maxLength&&Oe(r,"maxItems",e.maxLength.value,e.maxLength.message,t),e.exactLength&&(Oe(r,"minItems",e.exactLength.value,e.exactLength.message,t),Oe(r,"maxItems",e.exactLength.value,e.exactLength.message,t)),r}function KC(e,t){let r={type:"integer",format:"int64"};if(!e.checks)return r;for(let i of e.checks)switch(i.kind){case"min":t.target==="jsonSchema7"?i.inclusive?Oe(r,"minimum",i.value,i.message,t):Oe(r,"exclusiveMinimum",i.value,i.message,t):(i.inclusive||(r.exclusiveMinimum=!0),Oe(r,"minimum",i.value,i.message,t));break;case"max":t.target==="jsonSchema7"?i.inclusive?Oe(r,"maximum",i.value,i.message,t):Oe(r,"exclusiveMaximum",i.value,i.message,t):(i.inclusive||(r.exclusiveMaximum=!0),Oe(r,"maximum",i.value,i.message,t));break;case"multipleOf":Oe(r,"multipleOf",i.value,i.message,t);break}return r}function qC(){return{type:"boolean"}}function Ip(e,t){return se(e.type._def,t)}var XC=(e,t)=>se(e.innerType._def,t);function uw(e,t,r){let i=r??t.dateStrategy;if(Array.isArray(i))return{anyOf:i.map(n=>uw(e,t,n))};switch(i){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return n6(e,t)}}var n6=(e,t)=>{let r={type:"integer",format:"unix-time"};if(t.target==="openApi3")return r;for(let i of e.checks)switch(i.kind){case"min":Oe(r,"minimum",i.value,i.message,t);break;case"max":Oe(r,"maximum",i.value,i.message,t);break}return r};function YC(e,t){return{...se(e.innerType._def,t),default:e.defaultValue()}}function QC(e,t){return t.effectStrategy==="input"?se(e.schema._def,t):Ye(t)}function eA(e){return{type:"string",enum:Array.from(e.values)}}var i6=e=>"type"in e&&e.type==="string"?!1:"allOf"in e;function tA(e,t){let r=[se(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),se(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(a=>!!a),i=t.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,n=[];return r.forEach(a=>{if(i6(a))n.push(...a.allOf),a.unevaluatedProperties===void 0&&(i=void 0);else{let o=a;if("additionalProperties"in a&&a.additionalProperties===!1){let{additionalProperties:s,...c}=a;o=c}else i=void 0;n.push(o)}}),n.length?{allOf:n,...i}:void 0}function rA(e,t){let r=typeof e.value;return r!=="bigint"&&r!=="number"&&r!=="boolean"&&r!=="string"?{type:Array.isArray(e.value)?"array":"object"}:t.target==="openApi3"?{type:r==="bigint"?"integer":r,enum:[e.value]}:{type:r==="bigint"?"integer":r,const:e.value}}var dw,dn={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(dw===void 0&&(dw=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),dw),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function Tp(e,t){let r={type:"string"};if(e.checks)for(let i of e.checks)switch(i.kind){case"min":Oe(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,i.value):i.value,i.message,t);break;case"max":Oe(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,i.value):i.value,i.message,t);break;case"email":switch(t.emailStrategy){case"format:email":fn(r,"email",i.message,t);break;case"format:idn-email":fn(r,"idn-email",i.message,t);break;case"pattern:zod":sr(r,dn.email,i.message,t);break}break;case"url":fn(r,"uri",i.message,t);break;case"uuid":fn(r,"uuid",i.message,t);break;case"regex":sr(r,i.regex,i.message,t);break;case"cuid":sr(r,dn.cuid,i.message,t);break;case"cuid2":sr(r,dn.cuid2,i.message,t);break;case"startsWith":sr(r,RegExp(`^${fw(i.value,t)}`),i.message,t);break;case"endsWith":sr(r,RegExp(`${fw(i.value,t)}$`),i.message,t);break;case"datetime":fn(r,"date-time",i.message,t);break;case"date":fn(r,"date",i.message,t);break;case"time":fn(r,"time",i.message,t);break;case"duration":fn(r,"duration",i.message,t);break;case"length":Oe(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,i.value):i.value,i.message,t),Oe(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,i.value):i.value,i.message,t);break;case"includes":sr(r,RegExp(fw(i.value,t)),i.message,t);break;case"ip":i.version!=="v6"&&fn(r,"ipv4",i.message,t),i.version!=="v4"&&fn(r,"ipv6",i.message,t);break;case"base64url":sr(r,dn.base64url,i.message,t);break;case"jwt":sr(r,dn.jwt,i.message,t);break;case"cidr":i.version!=="v6"&&sr(r,dn.ipv4Cidr,i.message,t),i.version!=="v4"&&sr(r,dn.ipv6Cidr,i.message,t);break;case"emoji":sr(r,dn.emoji(),i.message,t);break;case"ulid":sr(r,dn.ulid,i.message,t);break;case"base64":switch(t.base64Strategy){case"format:binary":fn(r,"binary",i.message,t);break;case"contentEncoding:base64":Oe(r,"contentEncoding","base64",i.message,t);break;case"pattern:zod":sr(r,dn.base64,i.message,t);break}break;case"nanoid":sr(r,dn.nanoid,i.message,t);break;case"toLowerCase":case"toUpperCase":case"trim":break;default:}return r}function fw(e,t){return t.patternStrategy==="escape"?o6(e):e}var a6=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function o6(e){let t="";for(let r=0;r<e.length;r++)a6.has(e[r])||(t+="\\"),t+=e[r];return t}function fn(e,t,r,i){e.format||e.anyOf?.some(n=>n.format)?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format,...e.errorMessage&&i.errorMessages&&{errorMessage:{format:e.errorMessage.format}}}),delete e.format,e.errorMessage&&(delete e.errorMessage.format,Object.keys(e.errorMessage).length===0&&delete e.errorMessage)),e.anyOf.push({format:t,...r&&i.errorMessages&&{errorMessage:{format:r}}})):Oe(e,"format",t,r,i)}function sr(e,t,r,i){e.pattern||e.allOf?.some(n=>n.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern,...e.errorMessage&&i.errorMessages&&{errorMessage:{pattern:e.errorMessage.pattern}}}),delete e.pattern,e.errorMessage&&(delete e.errorMessage.pattern,Object.keys(e.errorMessage).length===0&&delete e.errorMessage)),e.allOf.push({pattern:nA(t,i),...r&&i.errorMessages&&{errorMessage:{pattern:r}}})):Oe(e,"pattern",nA(t,i),r,i)}function nA(e,t){if(!t.applyRegexFlags||!e.flags)return e.source;let r={i:e.flags.includes("i"),m:e.flags.includes("m"),s:e.flags.includes("s")},i=r.i?e.source.toLowerCase():e.source,n="",a=!1,o=!1,s=!1;for(let c=0;c<i.length;c++){if(a){n+=i[c],a=!1;continue}if(r.i){if(o){if(i[c].match(/[a-z]/)){s?(n+=i[c],n+=`${i[c-2]}-${i[c]}`.toUpperCase(),s=!1):i[c+1]==="-"&&i[c+2]?.match(/[a-z]/)?(n+=i[c],s=!0):n+=`${i[c]}${i[c].toUpperCase()}`;continue}}else if(i[c].match(/[a-z]/)){n+=`[${i[c]}${i[c].toUpperCase()}]`;continue}}if(r.m){if(i[c]==="^"){n+=`(^|(?<=[\r
222
- ]))`;continue}else if(i[c]==="$"){n+=`($|(?=[\r
223
- ]))`;continue}}if(r.s&&i[c]==="."){n+=o?`${i[c]}\r
224
- `:`[${i[c]}\r
225
- ]`;continue}n+=i[c],i[c]==="\\"?a=!0:o&&i[c]==="]"?o=!1:!o&&i[c]==="["&&(o=!0)}try{new RegExp(n)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return n}function Cp(e,t){if(t.target==="openAi"&&console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead."),t.target==="openApi3"&&e.keyType?._def.typeName===U.ZodEnum)return{type:"object",required:e.keyType._def.values,properties:e.keyType._def.values.reduce((i,n)=>({...i,[n]:se(e.valueType._def,{...t,currentPath:[...t.currentPath,"properties",n]})??Ye(t)}),{}),additionalProperties:t.rejectedAdditionalProperties};let r={type:"object",additionalProperties:se(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??t.allowedAdditionalProperties};if(t.target==="openApi3")return r;if(e.keyType?._def.typeName===U.ZodString&&e.keyType._def.checks?.length){let{type:i,...n}=Tp(e.keyType._def,t);return{...r,propertyNames:n}}else{if(e.keyType?._def.typeName===U.ZodEnum)return{...r,propertyNames:{enum:e.keyType._def.values}};if(e.keyType?._def.typeName===U.ZodBranded&&e.keyType._def.type._def.typeName===U.ZodString&&e.keyType._def.type._def.checks?.length){let{type:i,...n}=Ip(e.keyType._def,t);return{...r,propertyNames:n}}}return r}function iA(e,t){return t.mapStrategy==="record"?Cp(e,t):{type:"array",maxItems:125,items:{type:"array",items:[se(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||Ye(t),se(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||Ye(t)],minItems:2,maxItems:2}}}function aA(e){let t=e.values,r=Object.keys(e.values).filter(n=>typeof t[t[n]]!="number").map(n=>t[n]),i=Array.from(new Set(r.map(n=>typeof n)));return{type:i.length===1?i[0]==="string"?"string":"number":["string","number"],enum:r}}function oA(e){return e.target==="openAi"?void 0:{not:Ye({...e,currentPath:[...e.currentPath,"not"]})}}function sA(e){return e.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var jl={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function lA(e,t){if(t.target==="openApi3")return cA(e,t);let r=e.options instanceof Map?Array.from(e.options.values()):e.options;if(r.every(i=>i._def.typeName in jl&&(!i._def.checks||!i._def.checks.length))){let i=r.reduce((n,a)=>{let o=jl[a._def.typeName];return o&&!n.includes(o)?[...n,o]:n},[]);return{type:i.length>1?i:i[0]}}else if(r.every(i=>i._def.typeName==="ZodLiteral"&&!i.description)){let i=r.reduce((n,a)=>{let o=typeof a._def.value;switch(o){case"string":case"number":case"boolean":return[...n,o];case"bigint":return[...n,"integer"];case"object":return a._def.value===null?[...n,"null"]:n;default:return n}},[]);if(i.length===r.length){let n=i.filter((a,o,s)=>s.indexOf(a)===o);return{type:n.length>1?n:n[0],enum:r.reduce((a,o)=>a.includes(o._def.value)?a:[...a,o._def.value],[])}}}else if(r.every(i=>i._def.typeName==="ZodEnum"))return{type:"string",enum:r.reduce((i,n)=>[...i,...n._def.values.filter(a=>!i.includes(a))],[])};return cA(e,t)}var cA=(e,t)=>{let r=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((i,n)=>se(i._def,{...t,currentPath:[...t.currentPath,"anyOf",`${n}`]})).filter(i=>!!i&&(!t.strictUnions||typeof i=="object"&&Object.keys(i).length>0));return r.length?{anyOf:r}:void 0};function uA(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return t.target==="openApi3"?{type:jl[e.innerType._def.typeName],nullable:!0}:{type:[jl[e.innerType._def.typeName],"null"]};if(t.target==="openApi3"){let i=se(e.innerType._def,{...t,currentPath:[...t.currentPath]});return i&&"$ref"in i?{allOf:[i],nullable:!0}:i&&{...i,nullable:!0}}let r=se(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}function dA(e,t){let r={type:"number"};if(!e.checks)return r;for(let i of e.checks)switch(i.kind){case"int":r.type="integer",ow(r,"type",i.message,t);break;case"min":t.target==="jsonSchema7"?i.inclusive?Oe(r,"minimum",i.value,i.message,t):Oe(r,"exclusiveMinimum",i.value,i.message,t):(i.inclusive||(r.exclusiveMinimum=!0),Oe(r,"minimum",i.value,i.message,t));break;case"max":t.target==="jsonSchema7"?i.inclusive?Oe(r,"maximum",i.value,i.message,t):Oe(r,"exclusiveMaximum",i.value,i.message,t):(i.inclusive||(r.exclusiveMaximum=!0),Oe(r,"maximum",i.value,i.message,t));break;case"multipleOf":Oe(r,"multipleOf",i.value,i.message,t);break}return r}function fA(e,t){let r=t.target==="openAi",i={type:"object",properties:{}},n=[],a=e.shape();for(let s in a){let c=a[s];if(c===void 0||c._def===void 0)continue;let l=c6(c);l&&r&&(c._def.typeName==="ZodOptional"&&(c=c._def.innerType),c.isNullable()||(c=c.nullable()),l=!1);let u=se(c._def,{...t,currentPath:[...t.currentPath,"properties",s],propertyPath:[...t.currentPath,"properties",s]});u!==void 0&&(i.properties[s]=u,l||n.push(s))}n.length&&(i.required=n);let o=s6(e,t);return o!==void 0&&(i.additionalProperties=o),i}function s6(e,t){if(e.catchall._def.typeName!=="ZodNever")return se(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]});switch(e.unknownKeys){case"passthrough":return t.allowedAdditionalProperties;case"strict":return t.rejectedAdditionalProperties;case"strip":return t.removeAdditionalStrategy==="strict"?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}function c6(e){try{return e.isOptional()}catch{return!0}}var pA=(e,t)=>{if(t.currentPath.toString()===t.propertyPath?.toString())return se(e.innerType._def,t);let r=se(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return r?{anyOf:[{not:Ye(t)},r]}:Ye(t)};var mA=(e,t)=>{if(t.pipeStrategy==="input")return se(e.in._def,t);if(t.pipeStrategy==="output")return se(e.out._def,t);let r=se(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]});return{allOf:[r,se(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",r?"1":"0"]})].filter(i=>i!==void 0)}};function hA(e,t){return se(e.type._def,t)}function gA(e,t){let r={type:"array",uniqueItems:!0,items:se(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&Oe(r,"minItems",e.minSize.value,e.minSize.message,t),e.maxSize&&Oe(r,"maxItems",e.maxSize.value,e.maxSize.message,t),r}function _A(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((r,i)=>se(r._def,{...t,currentPath:[...t.currentPath,"items",`${i}`]})).reduce((r,i)=>i===void 0?r:[...r,i],[]),additionalItems:se(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((r,i)=>se(r._def,{...t,currentPath:[...t.currentPath,"items",`${i}`]})).reduce((r,i)=>i===void 0?r:[...r,i],[])}}function yA(e){return{not:Ye(e)}}function vA(e){return Ye(e)}var bA=(e,t)=>se(e.innerType._def,t);var wA=(e,t,r)=>{switch(t){case U.ZodString:return Tp(e,r);case U.ZodNumber:return dA(e,r);case U.ZodObject:return fA(e,r);case U.ZodBigInt:return KC(e,r);case U.ZodBoolean:return qC();case U.ZodDate:return uw(e,r);case U.ZodUndefined:return yA(r);case U.ZodNull:return sA(r);case U.ZodArray:return JC(e,r);case U.ZodUnion:case U.ZodDiscriminatedUnion:return lA(e,r);case U.ZodIntersection:return tA(e,r);case U.ZodTuple:return _A(e,r);case U.ZodRecord:return Cp(e,r);case U.ZodLiteral:return rA(e,r);case U.ZodEnum:return eA(e);case U.ZodNativeEnum:return aA(e);case U.ZodNullable:return uA(e,r);case U.ZodOptional:return pA(e,r);case U.ZodMap:return iA(e,r);case U.ZodSet:return gA(e,r);case U.ZodLazy:return()=>e.getter()._def;case U.ZodPromise:return hA(e,r);case U.ZodNaN:case U.ZodNever:return oA(r);case U.ZodEffects:return QC(e,r);case U.ZodAny:return Ye(r);case U.ZodUnknown:return vA(r);case U.ZodDefault:return YC(e,r);case U.ZodBranded:return Ip(e,r);case U.ZodReadonly:return bA(e,r);case U.ZodCatch:return XC(e,r);case U.ZodPipeline:return mA(e,r);case U.ZodFunction:case U.ZodVoid:case U.ZodSymbol:return;default:return(i=>{})(t)}};function se(e,t,r=!1){let i=t.seen.get(e);if(t.override){let s=t.override?.(e,t,i,r);if(s!==RC)return s}if(i&&!r){let s=l6(i,t);if(s!==void 0)return s}let n={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,n);let a=wA(e,e.typeName,t),o=typeof a=="function"?se(a(),t):a;if(o&&u6(e,t,o),t.postProcess){let s=t.postProcess(o,e,t);return n.jsonSchema=o,s}return n.jsonSchema=o,o}var l6=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:wp(t.currentPath,e.path)};case"none":case"seen":return e.path.length<t.currentPath.length&&e.path.every((r,i)=>t.currentPath[i]===r)?(console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),Ye(t)):t.$refStrategy==="seen"?Ye(t):void 0}},u6=(e,t,r)=>(e.description&&(r.description=e.description,t.markdownDescription&&(r.markdownDescription=e.description)),r);var xA=(e,t)=>{let r=jC(t),i=typeof t=="object"&&t.definitions?Object.entries(t.definitions).reduce((c,[l,u])=>({...c,[l]:se(u._def,{...r,currentPath:[...r.basePath,r.definitionPath,l]},!0)??Ye(r)}),{}):void 0,n=typeof t=="string"?t:t?.nameStrategy==="title"?void 0:t?.name,a=se(e._def,n===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,n]},!1)??Ye(r),o=typeof t=="object"&&t.name!==void 0&&t.nameStrategy==="title"?t.name:void 0;o!==void 0&&(a.title=o),r.flags.hasReferencedOpenAiAnyType&&(i||(i={}),i[r.openAiAnyTypeName]||(i[r.openAiAnyTypeName]={type:["string","number","integer","boolean","array","null"],items:{$ref:r.$refStrategy==="relative"?"1":[...r.basePath,r.definitionPath,r.openAiAnyTypeName].join("/")}}));let s=n===void 0?i?{...a,[r.definitionPath]:i}:a:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,n].join("/"),[r.definitionPath]:{...i,[n]:a}};return r.target==="jsonSchema7"?s.$schema="http://json-schema.org/draft-07/schema#":(r.target==="jsonSchema2019-09"||r.target==="openAi")&&(s.$schema="https://json-schema.org/draft/2019-09/schema#"),r.target==="openAi"&&("anyOf"in s||"oneOf"in s||"allOf"in s||"type"in s&&Array.isArray(s.type))&&console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."),s};function Jn(e,t){let r=typeof e;if(r!==typeof t)return!1;if(Array.isArray(e)){if(!Array.isArray(t))return!1;let i=e.length;if(i!==t.length)return!1;for(let n=0;n<i;n++)if(!Jn(e[n],t[n]))return!1;return!0}if(r==="object"){if(!e||!t)return e===t;let i=Object.keys(e),n=Object.keys(t);if(i.length!==n.length)return!1;for(let o of i)if(!Jn(e[o],t[o]))return!1;return!0}return e===t}function Or(e){return encodeURI(d6(e))}function d6(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}var f6={prefixItems:!0,items:!0,allOf:!0,anyOf:!0,oneOf:!0},p6={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependentSchemas:!0},m6={id:!0,$id:!0,$ref:!0,$schema:!0,$anchor:!0,$vocabulary:!0,$comment:!0,default:!0,enum:!0,const:!0,required:!0,type:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0},h6=typeof self<"u"&&self.location&&self.location.origin!=="null"?new URL(self.location.origin+self.location.pathname+location.search):new URL("https://github.com/cfworker");function pn(e,t=Object.create(null),r=h6,i=""){if(e&&typeof e=="object"&&!Array.isArray(e)){let a=e.$id||e.id;if(a){let o=new URL(a,r.href);o.hash.length>1?t[o.href]=e:(o.hash="",i===""?r=o:pn(e,t,r))}}else if(e!==!0&&e!==!1)return t;let n=r.href+(i?"#"+i:"");if(t[n]!==void 0)throw new Error(`Duplicate schema URI "${n}".`);if(t[n]=e,e===!0||e===!1)return t;if(e.__absolute_uri__===void 0&&Object.defineProperty(e,"__absolute_uri__",{enumerable:!1,value:n}),e.$ref&&e.__absolute_ref__===void 0){let a=new URL(e.$ref,r.href);a.hash=a.hash,Object.defineProperty(e,"__absolute_ref__",{enumerable:!1,value:a.href})}if(e.$recursiveRef&&e.__absolute_recursive_ref__===void 0){let a=new URL(e.$recursiveRef,r.href);a.hash=a.hash,Object.defineProperty(e,"__absolute_recursive_ref__",{enumerable:!1,value:a.href})}if(e.$anchor){let a=new URL("#"+e.$anchor,r.href);t[a.href]=e}for(let a in e){if(m6[a])continue;let o=`${i}/${Or(a)}`,s=e[a];if(Array.isArray(s)){if(f6[a]){let c=s.length;for(let l=0;l<c;l++)pn(s[l],t,r,`${o}/${l}`)}}else if(p6[a])for(let c in s)pn(s[c],t,r,`${o}/${Or(c)}`);else pn(s,t,r,o)}return t}var g6=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,_6=[0,31,28,31,30,31,30,31,31,30,31,30,31],y6=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i,v6=/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,b6=/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,w6=/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,x6=/^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)(?:\.(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,S6=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,k6=/^(?:\/(?:[^~/]|~0|~1)*)*$/,$6=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,E6=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,I6=e=>{if(e[0]==='"')return!1;let[t,r,...i]=e.split("@");return!t||!r||i.length!==0||t.length>64||r.length>253||t[0]==="."||t.endsWith(".")||t.includes("..")||!/^[a-z0-9.-]+$/i.test(r)||!/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+$/i.test(t)?!1:r.split(".").every(n=>/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i.test(n))},T6=/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,C6=/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,A6=e=>e.length>1&&e.length<80&&(/^P\d+([.,]\d+)?W$/.test(e)||/^P[\dYMDTHS]*(\d[.,]\d+)?[YMDHS]$/.test(e)&&/^P([.,\d]+Y)?([.,\d]+M)?([.,\d]+D)?(T([.,\d]+H)?([.,\d]+M)?([.,\d]+S)?)?$/.test(e));function Kn(e){return e.test.bind(e)}var pw={date:SA,time:kA.bind(void 0,!1),"date-time":N6,duration:A6,uri:j6,"uri-reference":Kn(b6),"uri-template":Kn(w6),url:Kn(x6),email:I6,hostname:Kn(v6),ipv4:Kn(T6),ipv6:Kn(C6),regex:D6,uuid:Kn(S6),"json-pointer":Kn(k6),"json-pointer-uri-fragment":Kn($6),"relative-json-pointer":Kn(E6)};function O6(e){return e%4===0&&(e%100!==0||e%400===0)}function SA(e){let t=e.match(g6);if(!t)return!1;let r=+t[1],i=+t[2],n=+t[3];return i>=1&&i<=12&&n>=1&&n<=(i==2&&O6(r)?29:_6[i])}function kA(e,t){let r=t.match(y6);if(!r)return!1;let i=+r[1],n=+r[2],a=+r[3],o=!!r[5];return(i<=23&&n<=59&&a<=59||i==23&&n==59&&a==60)&&(!e||o)}var P6=/t|\s/i;function N6(e){let t=e.split(P6);return t.length==2&&SA(t[0])&&kA(!0,t[1])}var R6=/\/|:/,M6=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function j6(e){return R6.test(e)&&M6.test(e)}var z6=/[^\\]\\Z/;function D6(e){if(z6.test(e))return!1;try{return new RegExp(e,"u"),!0}catch{return!1}}var $A;(function(e){e[e.Flag=1]="Flag",e[e.Basic=2]="Basic",e[e.Detailed=4]="Detailed"})($A||($A={}));function EA(e){let t=0,r=e.length,i=0,n;for(;i<r;)t++,n=e.charCodeAt(i++),n>=55296&&n<=56319&&i<r&&(n=e.charCodeAt(i),(n&64512)==56320&&i++);return t}function Ze(e,t,r="2019-09",i=pn(t),n=!0,a=null,o="#",s="#",c=Object.create(null)){if(t===!0)return{valid:!0,errors:[]};if(t===!1)return{valid:!1,errors:[{instanceLocation:o,keyword:"false",keywordLocation:o,error:"False boolean schema."}]};let l=typeof e,u;switch(l){case"boolean":case"number":case"string":u=l;break;case"object":e===null?u="null":Array.isArray(e)?u="array":u="object";break;default:throw new Error(`Instances of "${l}" type are not supported.`)}let{$ref:d,$recursiveRef:f,$recursiveAnchor:p,type:m,const:h,enum:_,required:b,not:w,anyOf:S,allOf:x,oneOf:E,if:z,then:C,else:v,format:Z,properties:B,patternProperties:A,additionalProperties:L,unevaluatedProperties:G,minProperties:Y,maxProperties:Ie,propertyNames:me,dependentRequired:En,dependentSchemas:Rr,dependencies:Na,prefixItems:Qr,items:oi,additionalItems:Oc,unevaluatedItems:Pc,contains:Nc,minContains:en,maxContains:y,minItems:g,maxItems:P,uniqueItems:$,minimum:$e,maximum:Me,exclusiveMinimum:mt,exclusiveMaximum:st,multipleOf:Rt,minLength:Mr,maxLength:ct,pattern:In,__absolute_ref__:Go,__absolute_recursive_ref__:ju}=t,q=[];if(p===!0&&a===null&&(a=t),f==="#"){let ce=a===null?i[ju]:a,ie=`${s}/$recursiveRef`,fe=Ze(e,a===null?t:a,r,i,n,ce,o,ie,c);fe.valid||q.push({instanceLocation:o,keyword:"$recursiveRef",keywordLocation:ie,error:"A subschema had errors."},...fe.errors)}if(d!==void 0){let ie=i[Go||d];if(ie===void 0){let J=`Unresolved $ref "${d}".`;throw Go&&Go!==d&&(J+=` Absolute URI "${Go}".`),J+=`
226
- Known schemas:
227
- - ${Object.keys(i).join(`
228
- - `)}`,new Error(J)}let fe=`${s}/$ref`,ee=Ze(e,ie,r,i,n,a,o,fe,c);if(ee.valid||q.push({instanceLocation:o,keyword:"$ref",keywordLocation:fe,error:"A subschema had errors."},...ee.errors),r==="4"||r==="7")return{valid:q.length===0,errors:q}}if(Array.isArray(m)){let ce=m.length,ie=!1;for(let fe=0;fe<ce;fe++)if(u===m[fe]||m[fe]==="integer"&&u==="number"&&e%1===0&&e===e){ie=!0;break}ie||q.push({instanceLocation:o,keyword:"type",keywordLocation:`${s}/type`,error:`Instance type "${u}" is invalid. Expected "${m.join('", "')}".`})}else m==="integer"?(u!=="number"||e%1||e!==e)&&q.push({instanceLocation:o,keyword:"type",keywordLocation:`${s}/type`,error:`Instance type "${u}" is invalid. Expected "${m}".`}):m!==void 0&&u!==m&&q.push({instanceLocation:o,keyword:"type",keywordLocation:`${s}/type`,error:`Instance type "${u}" is invalid. Expected "${m}".`});if(h!==void 0&&(u==="object"||u==="array"?Jn(e,h)||q.push({instanceLocation:o,keyword:"const",keywordLocation:`${s}/const`,error:`Instance does not match ${JSON.stringify(h)}.`}):e!==h&&q.push({instanceLocation:o,keyword:"const",keywordLocation:`${s}/const`,error:`Instance does not match ${JSON.stringify(h)}.`})),_!==void 0&&(u==="object"||u==="array"?_.some(ce=>Jn(e,ce))||q.push({instanceLocation:o,keyword:"enum",keywordLocation:`${s}/enum`,error:`Instance does not match any of ${JSON.stringify(_)}.`}):_.some(ce=>e===ce)||q.push({instanceLocation:o,keyword:"enum",keywordLocation:`${s}/enum`,error:`Instance does not match any of ${JSON.stringify(_)}.`})),w!==void 0){let ce=`${s}/not`;Ze(e,w,r,i,n,a,o,ce).valid&&q.push({instanceLocation:o,keyword:"not",keywordLocation:ce,error:'Instance matched "not" schema.'})}let Ra=[];if(S!==void 0){let ce=`${s}/anyOf`,ie=q.length,fe=!1;for(let ee=0;ee<S.length;ee++){let J=S[ee],ue=Object.create(c),le=Ze(e,J,r,i,n,p===!0?a:null,o,`${ce}/${ee}`,ue);q.push(...le.errors),fe=fe||le.valid,le.valid&&Ra.push(ue)}fe?q.length=ie:q.splice(ie,0,{instanceLocation:o,keyword:"anyOf",keywordLocation:ce,error:"Instance does not match any subschemas."})}if(x!==void 0){let ce=`${s}/allOf`,ie=q.length,fe=!0;for(let ee=0;ee<x.length;ee++){let J=x[ee],ue=Object.create(c),le=Ze(e,J,r,i,n,p===!0?a:null,o,`${ce}/${ee}`,ue);q.push(...le.errors),fe=fe&&le.valid,le.valid&&Ra.push(ue)}fe?q.length=ie:q.splice(ie,0,{instanceLocation:o,keyword:"allOf",keywordLocation:ce,error:"Instance does not match every subschema."})}if(E!==void 0){let ce=`${s}/oneOf`,ie=q.length,fe=E.filter((ee,J)=>{let ue=Object.create(c),le=Ze(e,ee,r,i,n,p===!0?a:null,o,`${ce}/${J}`,ue);return q.push(...le.errors),le.valid&&Ra.push(ue),le.valid}).length;fe===1?q.length=ie:q.splice(ie,0,{instanceLocation:o,keyword:"oneOf",keywordLocation:ce,error:`Instance does not match exactly one subschema (${fe} matches).`})}if((u==="object"||u==="array")&&Object.assign(c,...Ra),z!==void 0){let ce=`${s}/if`;if(Ze(e,z,r,i,n,a,o,ce,c).valid){if(C!==void 0){let fe=Ze(e,C,r,i,n,a,o,`${s}/then`,c);fe.valid||q.push({instanceLocation:o,keyword:"if",keywordLocation:ce,error:'Instance does not match "then" schema.'},...fe.errors)}}else if(v!==void 0){let fe=Ze(e,v,r,i,n,a,o,`${s}/else`,c);fe.valid||q.push({instanceLocation:o,keyword:"if",keywordLocation:ce,error:'Instance does not match "else" schema.'},...fe.errors)}}if(u==="object"){if(b!==void 0)for(let ee of b)ee in e||q.push({instanceLocation:o,keyword:"required",keywordLocation:`${s}/required`,error:`Instance does not have required property "${ee}".`});let ce=Object.keys(e);if(Y!==void 0&&ce.length<Y&&q.push({instanceLocation:o,keyword:"minProperties",keywordLocation:`${s}/minProperties`,error:`Instance does not have at least ${Y} properties.`}),Ie!==void 0&&ce.length>Ie&&q.push({instanceLocation:o,keyword:"maxProperties",keywordLocation:`${s}/maxProperties`,error:`Instance does not have at least ${Ie} properties.`}),me!==void 0){let ee=`${s}/propertyNames`;for(let J in e){let ue=`${o}/${Or(J)}`,le=Ze(J,me,r,i,n,a,ue,ee);le.valid||q.push({instanceLocation:o,keyword:"propertyNames",keywordLocation:ee,error:`Property name "${J}" does not match schema.`},...le.errors)}}if(En!==void 0){let ee=`${s}/dependantRequired`;for(let J in En)if(J in e){let ue=En[J];for(let le of ue)le in e||q.push({instanceLocation:o,keyword:"dependentRequired",keywordLocation:ee,error:`Instance has "${J}" but does not have "${le}".`})}}if(Rr!==void 0)for(let ee in Rr){let J=`${s}/dependentSchemas`;if(ee in e){let ue=Ze(e,Rr[ee],r,i,n,a,o,`${J}/${Or(ee)}`,c);ue.valid||q.push({instanceLocation:o,keyword:"dependentSchemas",keywordLocation:J,error:`Instance has "${ee}" but does not match dependant schema.`},...ue.errors)}}if(Na!==void 0){let ee=`${s}/dependencies`;for(let J in Na)if(J in e){let ue=Na[J];if(Array.isArray(ue))for(let le of ue)le in e||q.push({instanceLocation:o,keyword:"dependencies",keywordLocation:ee,error:`Instance has "${J}" but does not have "${le}".`});else{let le=Ze(e,ue,r,i,n,a,o,`${ee}/${Or(J)}`);le.valid||q.push({instanceLocation:o,keyword:"dependencies",keywordLocation:ee,error:`Instance has "${J}" but does not match dependant schema.`},...le.errors)}}}let ie=Object.create(null),fe=!1;if(B!==void 0){let ee=`${s}/properties`;for(let J in B){if(!(J in e))continue;let ue=`${o}/${Or(J)}`,le=Ze(e[J],B[J],r,i,n,a,ue,`${ee}/${Or(J)}`);if(le.valid)c[J]=ie[J]=!0;else if(fe=n,q.push({instanceLocation:o,keyword:"properties",keywordLocation:ee,error:`Property "${J}" does not match schema.`},...le.errors),fe)break}}if(!fe&&A!==void 0){let ee=`${s}/patternProperties`;for(let J in A){let ue=new RegExp(J,"u"),le=A[J];for(let ur in e){if(!ue.test(ur))continue;let IS=`${o}/${Or(ur)}`,TS=Ze(e[ur],le,r,i,n,a,IS,`${ee}/${Or(J)}`);TS.valid?c[ur]=ie[ur]=!0:(fe=n,q.push({instanceLocation:o,keyword:"patternProperties",keywordLocation:ee,error:`Property "${ur}" matches pattern "${J}" but does not match associated schema.`},...TS.errors))}}}if(!fe&&L!==void 0){let ee=`${s}/additionalProperties`;for(let J in e){if(ie[J])continue;let ue=`${o}/${Or(J)}`,le=Ze(e[J],L,r,i,n,a,ue,ee);le.valid?c[J]=!0:(fe=n,q.push({instanceLocation:o,keyword:"additionalProperties",keywordLocation:ee,error:`Property "${J}" does not match additional properties schema.`},...le.errors))}}else if(!fe&&G!==void 0){let ee=`${s}/unevaluatedProperties`;for(let J in e)if(!c[J]){let ue=`${o}/${Or(J)}`,le=Ze(e[J],G,r,i,n,a,ue,ee);le.valid?c[J]=!0:q.push({instanceLocation:o,keyword:"unevaluatedProperties",keywordLocation:ee,error:`Property "${J}" does not match unevaluated properties schema.`},...le.errors)}}}else if(u==="array"){P!==void 0&&e.length>P&&q.push({instanceLocation:o,keyword:"maxItems",keywordLocation:`${s}/maxItems`,error:`Array has too many items (${e.length} > ${P}).`}),g!==void 0&&e.length<g&&q.push({instanceLocation:o,keyword:"minItems",keywordLocation:`${s}/minItems`,error:`Array has too few items (${e.length} < ${g}).`});let ce=e.length,ie=0,fe=!1;if(Qr!==void 0){let ee=`${s}/prefixItems`,J=Math.min(Qr.length,ce);for(;ie<J;ie++){let ue=Ze(e[ie],Qr[ie],r,i,n,a,`${o}/${ie}`,`${ee}/${ie}`);if(c[ie]=!0,!ue.valid&&(fe=n,q.push({instanceLocation:o,keyword:"prefixItems",keywordLocation:ee,error:"Items did not match schema."},...ue.errors),fe))break}}if(oi!==void 0){let ee=`${s}/items`;if(Array.isArray(oi)){let J=Math.min(oi.length,ce);for(;ie<J;ie++){let ue=Ze(e[ie],oi[ie],r,i,n,a,`${o}/${ie}`,`${ee}/${ie}`);if(c[ie]=!0,!ue.valid&&(fe=n,q.push({instanceLocation:o,keyword:"items",keywordLocation:ee,error:"Items did not match schema."},...ue.errors),fe))break}}else for(;ie<ce;ie++){let J=Ze(e[ie],oi,r,i,n,a,`${o}/${ie}`,ee);if(c[ie]=!0,!J.valid&&(fe=n,q.push({instanceLocation:o,keyword:"items",keywordLocation:ee,error:"Items did not match schema."},...J.errors),fe))break}if(!fe&&Oc!==void 0){let J=`${s}/additionalItems`;for(;ie<ce;ie++){let ue=Ze(e[ie],Oc,r,i,n,a,`${o}/${ie}`,J);c[ie]=!0,ue.valid||(fe=n,q.push({instanceLocation:o,keyword:"additionalItems",keywordLocation:J,error:"Items did not match additional items schema."},...ue.errors))}}}if(Nc!==void 0)if(ce===0&&en===void 0)q.push({instanceLocation:o,keyword:"contains",keywordLocation:`${s}/contains`,error:"Array is empty. It must contain at least one item matching the schema."});else if(en!==void 0&&ce<en)q.push({instanceLocation:o,keyword:"minContains",keywordLocation:`${s}/minContains`,error:`Array has less items (${ce}) than minContains (${en}).`});else{let ee=`${s}/contains`,J=q.length,ue=0;for(let le=0;le<ce;le++){let ur=Ze(e[le],Nc,r,i,n,a,`${o}/${le}`,ee);ur.valid?(c[le]=!0,ue++):q.push(...ur.errors)}ue>=(en||0)&&(q.length=J),en===void 0&&y===void 0&&ue===0?q.splice(J,0,{instanceLocation:o,keyword:"contains",keywordLocation:ee,error:"Array does not contain item matching schema."}):en!==void 0&&ue<en?q.push({instanceLocation:o,keyword:"minContains",keywordLocation:`${s}/minContains`,error:`Array must contain at least ${en} items matching schema. Only ${ue} items were found.`}):y!==void 0&&ue>y&&q.push({instanceLocation:o,keyword:"maxContains",keywordLocation:`${s}/maxContains`,error:`Array may contain at most ${y} items matching schema. ${ue} items were found.`})}if(!fe&&Pc!==void 0){let ee=`${s}/unevaluatedItems`;for(ie;ie<ce;ie++){if(c[ie])continue;let J=Ze(e[ie],Pc,r,i,n,a,`${o}/${ie}`,ee);c[ie]=!0,J.valid||q.push({instanceLocation:o,keyword:"unevaluatedItems",keywordLocation:ee,error:"Items did not match unevaluated items schema."},...J.errors)}}if($)for(let ee=0;ee<ce;ee++){let J=e[ee],ue=typeof J=="object"&&J!==null;for(let le=0;le<ce;le++){if(ee===le)continue;let ur=e[le];(J===ur||ue&&(typeof ur=="object"&&ur!==null)&&Jn(J,ur))&&(q.push({instanceLocation:o,keyword:"uniqueItems",keywordLocation:`${s}/uniqueItems`,error:`Duplicate items at indexes ${ee} and ${le}.`}),ee=Number.MAX_SAFE_INTEGER,le=Number.MAX_SAFE_INTEGER)}}}else if(u==="number"){if(r==="4"?($e!==void 0&&(mt===!0&&e<=$e||e<$e)&&q.push({instanceLocation:o,keyword:"minimum",keywordLocation:`${s}/minimum`,error:`${e} is less than ${mt?"or equal to ":""} ${$e}.`}),Me!==void 0&&(st===!0&&e>=Me||e>Me)&&q.push({instanceLocation:o,keyword:"maximum",keywordLocation:`${s}/maximum`,error:`${e} is greater than ${st?"or equal to ":""} ${Me}.`})):($e!==void 0&&e<$e&&q.push({instanceLocation:o,keyword:"minimum",keywordLocation:`${s}/minimum`,error:`${e} is less than ${$e}.`}),Me!==void 0&&e>Me&&q.push({instanceLocation:o,keyword:"maximum",keywordLocation:`${s}/maximum`,error:`${e} is greater than ${Me}.`}),mt!==void 0&&e<=mt&&q.push({instanceLocation:o,keyword:"exclusiveMinimum",keywordLocation:`${s}/exclusiveMinimum`,error:`${e} is less than ${mt}.`}),st!==void 0&&e>=st&&q.push({instanceLocation:o,keyword:"exclusiveMaximum",keywordLocation:`${s}/exclusiveMaximum`,error:`${e} is greater than or equal to ${st}.`})),Rt!==void 0){let ce=e%Rt;Math.abs(0-ce)>=11920929e-14&&Math.abs(Rt-ce)>=11920929e-14&&q.push({instanceLocation:o,keyword:"multipleOf",keywordLocation:`${s}/multipleOf`,error:`${e} is not a multiple of ${Rt}.`})}}else if(u==="string"){let ce=Mr===void 0&&ct===void 0?0:EA(e);Mr!==void 0&&ce<Mr&&q.push({instanceLocation:o,keyword:"minLength",keywordLocation:`${s}/minLength`,error:`String is too short (${ce} < ${Mr}).`}),ct!==void 0&&ce>ct&&q.push({instanceLocation:o,keyword:"maxLength",keywordLocation:`${s}/maxLength`,error:`String is too long (${ce} > ${ct}).`}),In!==void 0&&!new RegExp(In,"u").test(e)&&q.push({instanceLocation:o,keyword:"pattern",keywordLocation:`${s}/pattern`,error:"String does not match pattern."}),Z!==void 0&&pw[Z]&&!pw[Z](e)&&q.push({instanceLocation:o,keyword:"format",keywordLocation:`${s}/format`,error:`String does not match format "${Z}".`})}return{valid:q.length===0,errors:q}}var Ap=class{schema;draft;shortCircuit;lookup;constructor(t,r="2019-09",i=!0){this.schema=t,this.draft=r,this.shortCircuit=i,this.lookup=pn(t)}validate(t){return Ze(t,this.schema,this.draft,this.lookup,this.shortCircuit)}addSchema(t,r){r&&(t={...t,$id:r}),pn(t,this.lookup)}};var TA=T({Validator:()=>Ap,deepCompareStrict:()=>Jn,toJsonSchema:()=>bt,validatesOnlyStrings:()=>Ys}),IA=new WeakMap;function bt(e,t){let r=!t&&e!=null&&typeof e=="object";if(r){let n=IA.get(e);if(n)return n}let i;if(ff(e)&&!Ve(e))i=e["~standard"].jsonSchema.input({target:"draft-07"});else if(Ve(e)){let n=vp(e,!0);Zr(n)?i=go(Bs(n,!0),t):i=go(e,t)}else at(e)?i=xA(e):i=e;return r&&i!=null&&typeof i=="object"&&IA.set(e,i),i}function Ys(e){if(!e||typeof e!="object"||Object.keys(e).length===0||Array.isArray(e))return!1;if("type"in e)return typeof e.type=="string"?e.type==="string":Array.isArray(e.type)?e.type.every(t=>t==="string"):!1;if("enum"in e)return Array.isArray(e.enum)&&e.enum.length>0&&e.enum.every(t=>typeof t=="string");if("const"in e)return typeof e.const=="string";if("allOf"in e&&Array.isArray(e.allOf))return e.allOf.some(t=>Ys(t));if("anyOf"in e&&Array.isArray(e.anyOf)||"oneOf"in e&&Array.isArray(e.oneOf)){let t="anyOf"in e?e.anyOf:e.oneOf;return t.length>0&&t.every(r=>Ys(r))}if("not"in e)return!1;if("$ref"in e&&typeof e.$ref=="string"){let t=e.$ref,r=pn(e);return r[t]?Ys(r[t]):!1}return!1}function zl(e){return e?e.lc_runnable:!1}var CA=class{includeNames;includeTypes;includeTags;excludeNames;excludeTypes;excludeTags;constructor(e){this.includeNames=e.includeNames,this.includeTypes=e.includeTypes,this.includeTags=e.includeTags,this.excludeNames=e.excludeNames,this.excludeTypes=e.excludeTypes,this.excludeTags=e.excludeTags}includeEvent(e,t){let r=this.includeNames===void 0&&this.includeTypes===void 0&&this.includeTags===void 0,i=e.tags??[];return this.includeNames!==void 0&&(r=r||this.includeNames.includes(e.name)),this.includeTypes!==void 0&&(r=r||this.includeTypes.includes(t)),this.includeTags!==void 0&&(r=r||i.some(n=>this.includeTags?.includes(n))),this.excludeNames!==void 0&&(r=r&&!this.excludeNames.includes(e.name)),this.excludeTypes!==void 0&&(r=r&&!this.excludeTypes.includes(t)),this.excludeTags!==void 0&&(r=r&&i.every(n=>!this.excludeTags?.includes(n))),r}},AA=e=>btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");function mw(e){return e.replace(/[^a-zA-Z-_0-9]/g,"_")}var U6=["*","_","`"];function L6(e){let t="";for(let[r,i]of Object.entries(e))t+=` classDef ${r} ${i};
229
- `;return t}function OA(e,t,r){let{firstNode:i,lastNode:n,nodeColors:a,withStyles:o=!0,curveStyle:s="linear",wrapLabelNWords:c=9}=r??{},l=o?`%%{init: {'flowchart': {'curve': '${s}'}}}%%
230
- graph TD;
231
- `:`graph TD;
232
- `;if(o){let m="default",h={[m]:"{0}({1})"};i!==void 0&&(h[i]="{0}([{1}]):::first"),n!==void 0&&(h[n]="{0}([{1}]):::last");for(let[_,b]of Object.entries(e)){let w=b.name.split(":").pop()??"",S=U6.some(E=>w.startsWith(E)&&w.endsWith(E))?`<p>${w}</p>`:w;Object.keys(b.metadata??{}).length&&(S+=`<hr/><small><em>${Object.entries(b.metadata??{}).map(([E,z])=>`${E} = ${z}`).join(`
233
- `)}</em></small>`);let x=(h[_]??h[m]).replace("{0}",mw(_)).replace("{1}",S);l+=` ${x}
234
- `}}let u={};for(let m of t){let h=m.source.split(":"),_=m.target.split(":"),b=h.filter((w,S)=>w===_[S]).join(":");u[b]||(u[b]=[]),u[b].push(m)}let d=new Set;function f(m){return[...m].sort((h,_)=>h.split(":").length-_.split(":").length)}function p(m,h){let _=m.length===1&&m[0].source===m[0].target;if(h&&!_){let w=h.split(":").pop();if(d.has(h))throw new Error(`Found duplicate subgraph '${w}' at '${h} -- this likely means that you're reusing a subgraph node with the same name. Please adjust your graph to have subgraph nodes with unique names.`);d.add(h),l+=` subgraph ${w}
235
- `}let b=f(Object.keys(u).filter(w=>w.startsWith(`${h}:`)&&w!==h&&w.split(":").length===h.split(":").length+1));for(let w of b)p(u[w],w);for(let w of m){let{source:S,target:x,data:E,conditional:z}=w,C="";if(E!==void 0){let v=E,Z=v.split(" ");Z.length>c&&(v=Array.from({length:Math.ceil(Z.length/c)},(B,A)=>Z.slice(A*c,(A+1)*c).join(" ")).join("&nbsp;<br>&nbsp;")),C=z?` -. &nbsp;${v}&nbsp; .-> `:` -- &nbsp;${v}&nbsp; --> `}else C=z?" -.-> ":" --> ";l+=` ${mw(S)}${C}${mw(x)};
236
- `}h&&!_&&(l+=` end
237
- `)}p(u[""]??[],"");for(let m in u)!m.includes(":")&&m!==""&&p(u[m],m);return o&&(l+=L6(a??{})),l}async function PA(e,t){let r=t?.backgroundColor??"white",i=t?.imageType??"png",n=AA(e);r!==void 0&&(/^#(?:[0-9a-fA-F]{3}){1,2}$/.test(r)||(r=`!${r}`));let a=`https://mermaid.ink/img/${n}?bgColor=${r}&type=${i}`,o=await fetch(a);if(!o.ok)throw new Error(["Failed to render the graph using the Mermaid.INK API.",`Status code: ${o.status}`,`Status text: ${o.statusText}`].join(`
238
- `));return await o.blob()}var MA=T({Graph:()=>Ro});function F6(e,t){if(e!==void 0&&!li(e))return e;if(zl(t))try{let r=t.getName();return r=r.startsWith("Runnable")?r.slice(8):r,r}catch{return t.getName()}else return t.name??"UnknownSchema"}function B6(e){return zl(e.data)?{type:"runnable",data:{id:e.data.lc_id,name:e.data.getName()}}:{type:"schema",data:{...bt(e.data.schema),title:e.data.name}}}var Ro=class jA{nodes={};edges=[];constructor(t){this.nodes=t?.nodes??this.nodes,this.edges=t?.edges??this.edges}toJSON(){let t={};return Object.values(this.nodes).forEach((r,i)=>{t[r.id]=li(r.id)?i:r.id}),{nodes:Object.values(this.nodes).map(r=>({id:t[r.id],...B6(r)})),edges:this.edges.map(r=>{let i={source:t[r.source],target:t[r.target]};return typeof r.data<"u"&&(i.data=r.data),typeof r.conditional<"u"&&(i.conditional=r.conditional),i})}}addNode(t,r,i){if(r!==void 0&&this.nodes[r]!==void 0)throw new Error(`Node with id ${r} already exists`);let n=r??Zi(),a={id:n,data:t,name:F6(r,t),metadata:i};return this.nodes[n]=a,a}removeNode(t){delete this.nodes[t.id],this.edges=this.edges.filter(r=>r.source!==t.id&&r.target!==t.id)}addEdge(t,r,i,n){if(this.nodes[t.id]===void 0)throw new Error(`Source node ${t.id} not in graph`);if(this.nodes[r.id]===void 0)throw new Error(`Target node ${r.id} not in graph`);let a={source:t.id,target:r.id,data:i,conditional:n};return this.edges.push(a),a}firstNode(){return NA(this)}lastNode(){return RA(this)}extend(t,r=""){let i=r;Object.values(t.nodes).map(c=>c.id).every(li)&&(i="");let n=c=>i?`${i}:${c}`:c;Object.entries(t.nodes).forEach(([c,l])=>{this.nodes[n(c)]={...l,id:n(c)}});let a=t.edges.map(c=>({...c,source:n(c.source),target:n(c.target)}));this.edges=[...this.edges,...a];let o=t.firstNode(),s=t.lastNode();return[o?{id:n(o.id),data:o.data}:void 0,s?{id:n(s.id),data:s.data}:void 0]}trimFirstNode(){let t=this.firstNode();t&&NA(this,[t.id])&&this.removeNode(t)}trimLastNode(){let t=this.lastNode();t&&RA(this,[t.id])&&this.removeNode(t)}reid(){let t=Object.fromEntries(Object.values(this.nodes).map(n=>[n.id,n.name])),r=new Map;Object.values(t).forEach(n=>{r.set(n,(r.get(n)||0)+1)});let i=n=>{let a=t[n];return li(n)&&r.get(a)===1?a:n};return new jA({nodes:Object.fromEntries(Object.entries(this.nodes).map(([n,a])=>[i(n),{...a,id:i(n)}])),edges:this.edges.map(n=>({...n,source:i(n.source),target:i(n.target)}))})}drawMermaid(t){let{withStyles:r,curveStyle:i,nodeColors:n={default:"fill:#f2f0ff,line-height:1.2",first:"fill-opacity:0",last:"fill:#bfb6fc"},wrapLabelNWords:a}=t??{},o=this.reid(),s=o.firstNode(),c=o.lastNode();return OA(o.nodes,o.edges,{firstNode:s?.id,lastNode:c?.id,withStyles:r,curveStyle:i,nodeColors:n,wrapLabelNWords:a})}async drawMermaidPng(t){return PA(this.drawMermaid(t),{backgroundColor:t?.backgroundColor})}};function NA(e,t=[]){let r=new Set(e.edges.filter(n=>!t.includes(n.source)).map(n=>n.target)),i=[];for(let n of Object.values(e.nodes))!t.includes(n.id)&&!r.has(n.id)&&i.push(n);return i.length===1?i[0]:void 0}function RA(e,t=[]){let r=new Set(e.edges.filter(n=>!t.includes(n.target)).map(n=>n.source)),i=[];for(let n of Object.values(e.nodes))!t.includes(n.id)&&!r.has(n.id)&&i.push(n);return i.length===1?i[0]:void 0}function Op({name:e,serialized:t}){return e!==void 0?e:t?.name!==void 0?t.name:t?.id!==void 0&&Array.isArray(t?.id)?t.id[t.id.length-1]:"Unnamed"}var zA=e=>e.name==="event_stream_tracer",DA=class extends Ot{autoClose=!0;includeNames;includeTypes;includeTags;excludeNames;excludeTypes;excludeTags;runInfoMap=new Map;tappedPromises=new Map;transformStream;writer;receiveStream;readableStreamClosed=!1;name="event_stream_tracer";lc_prefer_streaming=!0;constructor(e){super({_awaitHandler:!0,...e}),this.autoClose=e?.autoClose??!0,this.includeNames=e?.includeNames,this.includeTypes=e?.includeTypes,this.includeTags=e?.includeTags,this.excludeNames=e?.excludeNames,this.excludeTypes=e?.excludeTypes,this.excludeTags=e?.excludeTags,this.transformStream=new TransformStream({flush:()=>{this.readableStreamClosed=!0}}),this.writer=this.transformStream.writable.getWriter(),this.receiveStream=dt.fromReadableStream(this.transformStream.readable)}[Symbol.asyncIterator](){return this.receiveStream}async persistRun(e){}_includeRun(e){let t=e.tags??[],r=this.includeNames===void 0&&this.includeTags===void 0&&this.includeTypes===void 0;return this.includeNames!==void 0&&(r=r||this.includeNames.includes(e.name)),this.includeTypes!==void 0&&(r=r||this.includeTypes.includes(e.runType)),this.includeTags!==void 0&&(r=r||t.find(i=>this.includeTags?.includes(i))!==void 0),this.excludeNames!==void 0&&(r=r&&!this.excludeNames.includes(e.name)),this.excludeTypes!==void 0&&(r=r&&!this.excludeTypes.includes(e.runType)),this.excludeTags!==void 0&&(r=r&&t.every(i=>!this.excludeTags?.includes(i))),r}async*tapOutputIterable(e,t){let r=await t.next();if(r.done)return;let i=this.runInfoMap.get(e);if(i===void 0){yield r.value;return}function n(o,s){return o==="llm"&&typeof s=="string"?new mi({text:s}):s}let a=this.tappedPromises.get(e);if(a===void 0){let o;a=new Promise(s=>{o=s}),this.tappedPromises.set(e,a);try{let s={event:`on_${i.runType}_stream`,run_id:e,name:i.name,tags:i.tags,metadata:i.metadata,data:{}};await this.send({...s,data:{chunk:n(i.runType,r.value)}},i),yield r.value;for await(let c of t)i.runType!=="tool"&&i.runType!=="retriever"&&await this.send({...s,data:{chunk:n(i.runType,c)}},i),yield c}finally{o?.()}}else{yield r.value;for await(let o of t)yield o}}async send(e,t){this.readableStreamClosed||this._includeRun(t)&&await this.writer.write(e)}async sendEndEvent(e,t){let r=this.tappedPromises.get(e.run_id);r!==void 0?r.then(()=>{this.send(e,t)}):await this.send(e,t)}async onLLMStart(e){let t=Op(e),r=e.inputs.messages!==void 0?"chat_model":"llm",i={tags:e.tags??[],metadata:e.extra?.metadata??{},name:t,runType:r,inputs:e.inputs};this.runInfoMap.set(e.id,i);let n=`on_${r}_start`;await this.send({event:n,data:{input:e.inputs},name:t,tags:e.tags??[],run_id:e.id,metadata:e.extra?.metadata??{}},i)}async onLLMNewToken(e,t,r){let i=this.runInfoMap.get(e.id),n,a;if(i===void 0)throw new Error(`onLLMNewToken: Run ID ${e.id} not found in run map.`);if(this.runInfoMap.size!==1){if(i.runType==="chat_model")a="on_chat_model_stream",r?.chunk===void 0?n=new Qe({content:t,id:`run-${e.id}`}):n=r.chunk.message;else if(i.runType==="llm")a="on_llm_stream",r?.chunk===void 0?n=new mi({text:t}):n=r.chunk;else throw new Error(`Unexpected run type ${i.runType}`);await this.send({event:a,data:{chunk:n},run_id:e.id,name:i.name,tags:i.tags,metadata:i.metadata},i)}}async onLLMEnd(e){let t=this.runInfoMap.get(e.id);this.runInfoMap.delete(e.id);let r;if(t===void 0)throw new Error(`onLLMEnd: Run ID ${e.id} not found in run map.`);let i=e.outputs?.generations,n;if(t.runType==="chat_model"){for(let a of i??[]){if(n!==void 0)break;n=a[0]?.message}r="on_chat_model_end"}else if(t.runType==="llm")n={generations:i?.map(a=>a.map(o=>({text:o.text,generationInfo:o.generationInfo}))),llmOutput:e.outputs?.llmOutput??{}},r="on_llm_end";else throw new Error(`onLLMEnd: Unexpected run type: ${t.runType}`);await this.sendEndEvent({event:r,data:{output:n,input:t.inputs},run_id:e.id,name:t.name,tags:t.tags,metadata:t.metadata},t)}async onChainStart(e){let t=Op(e),r=e.run_type??"chain",i={tags:e.tags??[],metadata:e.extra?.metadata??{},name:t,runType:e.run_type},n={};e.inputs.input===""&&Object.keys(e.inputs).length===1?(n={},i.inputs={}):e.inputs.input!==void 0?(n.input=e.inputs.input,i.inputs=e.inputs.input):(n.input=e.inputs,i.inputs=e.inputs),this.runInfoMap.set(e.id,i),await this.send({event:`on_${r}_start`,data:n,name:t,tags:e.tags??[],run_id:e.id,metadata:e.extra?.metadata??{}},i)}async onChainEnd(e){let t=this.runInfoMap.get(e.id);if(this.runInfoMap.delete(e.id),t===void 0)throw new Error(`onChainEnd: Run ID ${e.id} not found in run map.`);let r=`on_${e.run_type}_end`,i=e.inputs??t.inputs??{},n={output:e.outputs?.output??e.outputs,input:i};i.input&&Object.keys(i).length===1&&(n.input=i.input,t.inputs=i.input),await this.sendEndEvent({event:r,data:n,run_id:e.id,name:t.name,tags:t.tags,metadata:t.metadata??{}},t)}async onToolStart(e){let t=Op(e),r={tags:e.tags??[],metadata:e.extra?.metadata??{},name:t,runType:"tool",inputs:e.inputs??{}};this.runInfoMap.set(e.id,r),await this.send({event:"on_tool_start",data:{input:e.inputs??{}},name:t,run_id:e.id,tags:e.tags??[],metadata:e.extra?.metadata??{}},r)}async onToolEnd(e){let t=this.runInfoMap.get(e.id);if(this.runInfoMap.delete(e.id),t===void 0)throw new Error(`onToolEnd: Run ID ${e.id} not found in run map.`);if(t.inputs===void 0)throw new Error(`onToolEnd: Run ID ${e.id} is a tool call, and is expected to have traced inputs.`);let r=e.outputs?.output===void 0?e.outputs:e.outputs.output;await this.sendEndEvent({event:"on_tool_end",data:{output:r,input:t.inputs},run_id:e.id,name:t.name,tags:t.tags,metadata:t.metadata},t)}async onToolError(e){let t=this.runInfoMap.get(e.id);if(this.runInfoMap.delete(e.id),t===void 0)throw new Error(`onToolEnd: Run ID ${e.id} not found in run map.`);if(t.inputs===void 0)throw new Error(`onToolEnd: Run ID ${e.id} is a tool call, and is expected to have traced inputs.`);await this.sendEndEvent({event:"on_tool_error",data:{input:t.inputs,error:e.error},run_id:e.id,name:t.name,tags:t.tags,metadata:t.metadata},t)}async onRetrieverStart(e){let t=Op(e),r={tags:e.tags??[],metadata:e.extra?.metadata??{},name:t,runType:"retriever",inputs:{query:e.inputs.query}};this.runInfoMap.set(e.id,r),await this.send({event:"on_retriever_start",data:{input:{query:e.inputs.query}},name:t,tags:e.tags??[],run_id:e.id,metadata:e.extra?.metadata??{}},r)}async onRetrieverEnd(e){let t=this.runInfoMap.get(e.id);if(this.runInfoMap.delete(e.id),t===void 0)throw new Error(`onRetrieverEnd: Run ID ${e.id} not found in run map.`);await this.sendEndEvent({event:"on_retriever_end",data:{output:e.outputs?.documents??e.outputs,input:t.inputs},run_id:e.id,name:t.name,tags:t.tags,metadata:t.metadata},t)}async handleCustomEvent(e,t,r){let i=this.runInfoMap.get(r);if(i===void 0)throw new Error(`handleCustomEvent: Run ID ${r} not found in run map.`);await this.send({event:"on_custom_event",run_id:r,name:e,tags:i.tags,metadata:i.metadata,data:t},i)}async finish(){let e=[...this.tappedPromises.values()];Promise.all(e).finally(()=>{this.writer.close()})}};var hw=class extends Ot{name="RootListenersTracer";rootId;config;argOnStart;argOnEnd;argOnError;constructor({config:e,onStart:t,onEnd:r,onError:i}){super({_awaitHandler:!0}),this.config=e,this.argOnStart=t,this.argOnEnd=r,this.argOnError=i}persistRun(e){return Promise.resolve()}async onRunCreate(e){this.rootId||(this.rootId=e.id,this.argOnStart&&await this.argOnStart(e,this.config))}async onRunUpdate(e){e.id===this.rootId&&(e.error?this.argOnError&&await this.argOnError(e,this.config):this.argOnEnd&&await this.argOnEnd(e,this.config))}};function UA(e){let t=new TextEncoder,r=new ReadableStream({async start(i){for await(let n of e)i.enqueue(t.encode(`event: data
239
- data: ${JSON.stringify(n)}
240
-
241
- `));i.enqueue(t.encode(`event: end
242
-
243
- `)),i.close()}});return dt.fromReadableStream(r)}function gw(e){return typeof e=="object"&&e!==null&&typeof e[Symbol.iterator]=="function"&&typeof e.next=="function"}var LA=e=>e!=null&&typeof e=="object"&&"next"in e&&typeof e.next=="function";function Pp(e){return typeof e=="object"&&e!==null&&typeof e[Symbol.asyncIterator]=="function"}function _w(e){return e!=null&&typeof e=="object"&&typeof e.next=="function"}async function FA(e,t){try{let r=await e.next();for(;!r.done;)await t?.(r.value),r=await e.next();return r.value}finally{await e.return?.(void 0)}}function*yw(e,t){for(;;){let{value:r,done:i}=Ae.runWithConfig(pr(e),t.next.bind(t),!0);if(i)break;yield r}}async function*Np(e,t){let r=t[Symbol.asyncIterator]();for(;;){let{value:i,done:n}=await Ae.runWithConfig(pr(e),r.next.bind(t),!0);if(n)break;yield i}}function ft(e,t){return e&&!Array.isArray(e)&&!(e instanceof Date)&&typeof e=="object"?e:{[t]:e}}var ae=class extends lt{lc_runnable=!0;name;getName(e){let t=this.name??this.constructor.lc_name()??this.constructor.name;return e?`${t}${e}`:t}withRetry(e){return new Mp({bound:this,kwargs:{},config:{},maxAttemptNumber:e?.stopAfterAttempt,...e})}withConfig(e){return new Jr({bound:this,config:e,kwargs:{}})}withFallbacks(e){let t=Array.isArray(e)?e:e.fallbacks;return new vw({runnable:this,fallbacks:t})}_getOptionsList(e,t=0){if(Array.isArray(e)&&e.length!==t)throw new Error(`Passed "options" must be an array with the same length as the inputs, but got ${e.length} options for ${t} inputs`);if(Array.isArray(e))return e.map(we);if(t>1&&!Array.isArray(e)&&e.runId){console.warn("Provided runId will be used only for the first element of the batch.");let r=Object.fromEntries(Object.entries(e).filter(([i])=>i!=="runId"));return Array.from({length:t},(i,n)=>we(n===0?e:r))}return Array.from({length:t},()=>we(e))}async batch(e,t,r){let i=this._getOptionsList(t??{},e.length),n=new hi({maxConcurrency:i[0]?.maxConcurrency??r?.maxConcurrency,onFailedAttempt:o=>{throw o}}),a=e.map((o,s)=>n.call(async()=>{try{return await this.invoke(o,i[s])}catch(c){if(r?.returnExceptions)return c;throw c}}));return Promise.all(a)}async*_streamIterator(e,t){yield this.invoke(e,t)}async stream(e,t){let r=we(t),i=new Qi({generator:this._streamIterator(e,r),config:r});return await i.setup,dt.fromAsyncGenerator(i)}_separateRunnableConfigFromCallOptions(e){let t;e===void 0?t=we(e):t=we({callbacks:e.callbacks,tags:e.tags,metadata:e.metadata,runName:e.runName,configurable:e.configurable,recursionLimit:e.recursionLimit,maxConcurrency:e.maxConcurrency,runId:e.runId,timeout:e.timeout,signal:e.signal});let r={...e};return delete r.callbacks,delete r.tags,delete r.metadata,delete r.runName,delete r.configurable,delete r.recursionLimit,delete r.maxConcurrency,delete r.runId,delete r.timeout,delete r.signal,[t,r]}async _callWithConfig(e,t,r){let i=we(r),n=await(await Ft(i))?.handleChainStart(this.toJSON(),ft(t,"input"),i.runId,i?.runType,void 0,void 0,i?.runName??this.getName());delete i.runId;let a;try{a=await Er(e.call(this,t,i,n),i.signal)}catch(o){throw await n?.handleChainError(o),o}return await n?.handleChainEnd(ft(a,"output")),a}async _batchWithConfig(e,t,r,i){let n=this._getOptionsList(r??{},t.length),a=await Promise.all(n.map(Ft)),o=await Promise.all(a.map(async(c,l)=>{let u=await c?.handleChainStart(this.toJSON(),ft(t[l],"input"),n[l].runId,n[l].runType,void 0,void 0,n[l].runName??this.getName());return delete n[l].runId,u})),s;try{s=await Er(e.call(this,t,n,o,i),n?.[0]?.signal)}catch(c){throw await Promise.all(o.map(l=>l?.handleChainError(c))),c}return await Promise.all(o.map(c=>c?.handleChainEnd(ft(s,"output")))),s}_concatOutputChunks(e,t){return Ir(e,t)}async*_transformStreamWithConfig(e,t,r){let i,n=!0,a,o=!0,s=we(r),c=await Ft(s),l=this;async function*u(){for await(let f of e){if(n)if(i===void 0)i=f;else try{i=l._concatOutputChunks(i,f)}catch{i=void 0,n=!1}yield f}}let d;try{let f=await d_(t.bind(this),u(),async()=>c?.handleChainStart(this.toJSON(),{input:""},s.runId,s.runType,void 0,void 0,s.runName??this.getName(),void 0,{lc_defers_inputs:!0}),s.signal,s);delete s.runId,d=f.setup;let p=d?.handlers.find(zA),m=f.output;p!==void 0&&d!==void 0&&(m=p.tapOutputIterable(d.runId,m));let h=d?.handlers.find(p_);h!==void 0&&d!==void 0&&(m=h.tapOutputIterable(d.runId,m));for await(let _ of m)if(yield _,o)if(a===void 0)a=_;else try{a=this._concatOutputChunks(a,_)}catch{a=void 0,o=!1}}catch(f){throw await d?.handleChainError(f,void 0,void 0,void 0,{inputs:ft(i,"input")}),f}await d?.handleChainEnd(a??{},void 0,void 0,void 0,{inputs:ft(i,"input")})}getGraph(e){let t=new Ro,r=t.addNode({name:`${this.getName()}Input`,schema:It.any()}),i=t.addNode(this),n=t.addNode({name:`${this.getName()}Output`,schema:It.any()});return t.addEdge(r,i),t.addEdge(i,n),t}pipe(e){return new Pr({first:this,last:tt(e)})}pick(e){return this.pipe(new bw(e))}assign(e){return this.pipe(new Ul(new wa({steps:e})))}async*transform(e,t){let r;for await(let i of e)r===void 0?r=i:r=this._concatOutputChunks(r,i);yield*this._streamIterator(r,we(t))}async*streamLog(e,t,r){let i=new lf({...r,autoClose:!1,_schemaFormat:"original"}),n=we(t);yield*this._streamLog(e,i,n)}async*_streamLog(e,t,r){let{callbacks:i}=r;if(i===void 0)r.callbacks=[t];else if(Array.isArray(i))r.callbacks=i.concat([t]);else{let s=i.copy();s.addHandler(t,!0),r.callbacks=s}let n=this.stream(e,r);async function a(){try{let s=await n;for await(let c of s){let l=new Fn({ops:[{op:"add",path:"/streamed_output/-",value:c}]});await t.writer.write(l)}}finally{await t.writer.close()}}let o=a();try{for await(let s of t)yield s}finally{await o}}streamEvents(e,t,r){let i;if(t.version==="v1")i=this._streamEventsV1(e,t,r);else if(t.version==="v2")i=this._streamEventsV2(e,t,r);else throw new Error('Only versions "v1" and "v2" of the schema are currently supported.');return t.encoding==="text/event-stream"?UA(i):dt.fromAsyncGenerator(i)}async*_streamEventsV2(e,t,r){let i=new DA({...r,autoClose:!1}),n=we(t),a=n.runId??Ur();n.runId=a;let o=n.callbacks;if(o===void 0)n.callbacks=[i];else if(Array.isArray(o))n.callbacks=o.concat(i);else{let p=o.copy();p.addHandler(i,!0),n.callbacks=p}let s=new AbortController,c=this;async function l(){let p;try{if(n.signal)if("any"in AbortSignal)p=AbortSignal.any([s.signal,n.signal]);else{let _=new AbortController;n.signal.addEventListener("abort",()=>_.abort(),{once:!0}),s.signal.addEventListener("abort",()=>_.abort(),{once:!0}),p=_.signal}else p=s.signal;let m=await c.stream(e,{...n,signal:p}),h=i.tapOutputIterable(a,m);for await(let _ of h)if(s.signal.aborted)break}finally{await i.finish()}}let u=l(),d=!1,f;try{for await(let p of i){if(!d){p.data.input=e,d=!0,f=p.run_id,yield p;continue}p.run_id===f&&p.event.endsWith("_end")&&p.data?.input&&delete p.data.input,yield p}}finally{s.abort(),await u}}async*_streamEventsV1(e,t,r){let i,n=!1,a=we(t),o=a.tags??[],s=a.metadata??{},c=a.runName??this.getName(),l=new lf({...r,autoClose:!1,_schemaFormat:"streaming_events"}),u=new CA({...r}),d=this._streamLog(e,l,a);for await(let p of d){if(i?i=i.concat(p):i=cf.fromRunLogPatch(p),i.state===void 0)throw new Error('Internal error: "streamEvents" state is missing. Please open a bug report.');if(!n){n=!0;let b={...i.state},w={run_id:b.id,event:`on_${b.type}_start`,name:c,tags:o,metadata:s,data:{input:e}};u.includeEvent(w,b.type)&&(yield w)}let m=p.ops.filter(b=>b.path.startsWith("/logs/")).map(b=>b.path.split("/")[2]),h=[...new Set(m)];for(let b of h){let w,S={},x=i.state.logs[b];if(x.end_time===void 0?x.streamed_output.length>0?w="stream":w="start":w="end",w==="start")x.inputs!==void 0&&(S.input=x.inputs);else if(w==="end")x.inputs!==void 0&&(S.input=x.inputs),S.output=x.final_output;else if(w==="stream"){let E=x.streamed_output.length;if(E!==1)throw new Error(`Expected exactly one chunk of streamed output, got ${E} instead. Encountered in: "${x.name}"`);S={chunk:x.streamed_output[0]},x.streamed_output=[]}yield{event:`on_${x.type}_${w}`,name:x.name,run_id:x.id,tags:x.tags,metadata:x.metadata,data:S}}let{state:_}=i;if(_.streamed_output.length>0){let b=_.streamed_output.length;if(b!==1)throw new Error(`Expected exactly one chunk of streamed output, got ${b} instead. Encountered in: "${_.name}"`);let w={chunk:_.streamed_output[0]};_.streamed_output=[];let S={event:`on_${_.type}_stream`,run_id:_.id,tags:o,metadata:s,name:c,data:w};u.includeEvent(S,_.type)&&(yield S)}}let f=i?.state;if(f!==void 0){let p={event:`on_${f.type}_end`,name:c,run_id:f.id,tags:o,metadata:s,data:{output:f.final_output}};u.includeEvent(p,f.type)&&(yield p)}}static isRunnable(e){return zl(e)}withListeners({onStart:e,onEnd:t,onError:r}){return new Jr({bound:this,config:{},configFactories:[i=>({callbacks:[new hw({config:i,onStart:e,onEnd:t,onError:r})]})]})}asTool(e){return H6(this,e)}},Jr=class BA extends ae{static lc_name(){return"RunnableBinding"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;bound;config;kwargs;configFactories;constructor(t){super(t),this.bound=t.bound,this.kwargs=t.kwargs,this.config=t.config,this.configFactories=t.configFactories}getName(t){return this.bound.getName(t)}async _mergeConfig(...t){let r=vt(this.config,...t);return vt(r,...this.configFactories?await Promise.all(this.configFactories.map(async i=>await i(r))):[])}withConfig(t){return new this.constructor({bound:this.bound,kwargs:this.kwargs,config:{...this.config,...t}})}withRetry(t){return new Mp({bound:this.bound,kwargs:this.kwargs,config:this.config,maxAttemptNumber:t?.stopAfterAttempt,...t})}async invoke(t,r){return this.bound.invoke(t,await this._mergeConfig(r,this.kwargs))}async batch(t,r,i){let n=Array.isArray(r)?await Promise.all(r.map(async a=>this._mergeConfig(we(a),this.kwargs))):await this._mergeConfig(we(r),this.kwargs);return this.bound.batch(t,n,i)}_concatOutputChunks(t,r){return this.bound._concatOutputChunks(t,r)}async*_streamIterator(t,r){yield*this.bound._streamIterator(t,await this._mergeConfig(we(r),this.kwargs))}async stream(t,r){return this.bound.stream(t,await this._mergeConfig(we(r),this.kwargs))}async*transform(t,r){yield*this.bound.transform(t,await this._mergeConfig(we(r),this.kwargs))}streamEvents(t,r,i){let n=this,a=async function*(){yield*n.bound.streamEvents(t,{...await n._mergeConfig(we(r),n.kwargs),version:r.version},i)};return dt.fromAsyncGenerator(a())}static isRunnableBinding(t){return t.bound&&ae.isRunnable(t.bound)}withListeners({onStart:t,onEnd:r,onError:i}){return new BA({bound:this.bound,kwargs:this.kwargs,config:this.config,configFactories:[n=>({callbacks:[new hw({config:n,onStart:t,onEnd:r,onError:i})]})]})}},VA=class ZA extends ae{static lc_name(){return"RunnableEach"}lc_serializable=!0;lc_namespace=["langchain_core","runnables"];bound;constructor(t){super(t),this.bound=t.bound}async invoke(t,r){return this._callWithConfig(this._invoke.bind(this),t,r)}async _invoke(t,r,i){return this.bound.batch(t,Se(r,{callbacks:i?.getChild()}))}withListeners({onStart:t,onEnd:r,onError:i}){return new ZA({bound:this.bound.withListeners({onStart:t,onEnd:r,onError:i})})}},Mp=class extends Jr{static lc_name(){return"RunnableRetry"}lc_namespace=["langchain_core","runnables"];maxAttemptNumber=3;onFailedAttempt=()=>{};constructor(e){super(e),this.maxAttemptNumber=e.maxAttemptNumber??this.maxAttemptNumber,this.onFailedAttempt=e.onFailedAttempt??this.onFailedAttempt}_patchConfigForRetry(e,t,r){let i=e>1?`retry:attempt:${e}`:void 0;return Se(t,{callbacks:r?.getChild(i)})}async _invoke(e,t,r){return sl(i=>super.invoke(e,this._patchConfigForRetry(i,t,r)),{onFailedAttempt:({error:i})=>this.onFailedAttempt(i,e),retries:Math.max(this.maxAttemptNumber-1,0),randomize:!0})}async invoke(e,t){return this._callWithConfig(this._invoke.bind(this),e,t)}async _batch(e,t,r,i){let n={};try{await sl(async a=>{let o=e.map((d,f)=>f).filter(d=>n[d.toString()]===void 0||n[d.toString()]instanceof Error),s=o.map(d=>e[d]),c=o.map(d=>this._patchConfigForRetry(a,t?.[d],r?.[d])),l=await super.batch(s,c,{...i,returnExceptions:!0}),u;for(let d=0;d<l.length;d+=1){let f=l[d],p=o[d];f instanceof Error&&u===void 0&&(u=f,u.input=s[d]),n[p.toString()]=f}if(u)throw u;return l},{onFailedAttempt:({error:a})=>this.onFailedAttempt(a,a.input),retries:Math.max(this.maxAttemptNumber-1,0),randomize:!0})}catch(a){if(i?.returnExceptions!==!0)throw a}return Object.keys(n).sort((a,o)=>parseInt(a,10)-parseInt(o,10)).map(a=>n[parseInt(a,10)])}async batch(e,t,r){return this._batchWithConfig(this._batch.bind(this),e,t,r)}},Pr=class Dl extends ae{static lc_name(){return"RunnableSequence"}first;middle=[];last;omitSequenceTags=!1;lc_serializable=!0;lc_namespace=["langchain_core","runnables"];constructor(t){super(t),this.first=t.first,this.middle=t.middle??this.middle,this.last=t.last,this.name=t.name,this.omitSequenceTags=t.omitSequenceTags??this.omitSequenceTags}get steps(){return[this.first,...this.middle,this.last]}async invoke(t,r){let i=we(r),n=await(await Ft(i))?.handleChainStart(this.toJSON(),ft(t,"input"),i.runId,void 0,void 0,void 0,i?.runName);delete i.runId;let a=t,o;try{let s=[this.first,...this.middle];for(let c=0;c<s.length;c+=1)a=await Er(s[c].invoke(a,Se(i,{callbacks:n?.getChild(this.omitSequenceTags?void 0:`seq:step:${c+1}`)})),i.signal);if(i.signal?.aborted)throw Yi(i.signal);o=await this.last.invoke(a,Se(i,{callbacks:n?.getChild(this.omitSequenceTags?void 0:`seq:step:${this.steps.length}`)}))}catch(s){throw await n?.handleChainError(s),s}return await n?.handleChainEnd(ft(o,"output")),o}async batch(t,r,i){let n=this._getOptionsList(r??{},t.length),a=await Promise.all(n.map(Ft)),o=await Promise.all(a.map(async(c,l)=>{let u=await c?.handleChainStart(this.toJSON(),ft(t[l],"input"),n[l].runId,void 0,void 0,void 0,n[l].runName);return delete n[l].runId,u})),s=t;try{for(let c=0;c<this.steps.length;c+=1)s=await Er(this.steps[c].batch(s,o.map((l,u)=>{let d=l?.getChild(this.omitSequenceTags?void 0:`seq:step:${c+1}`);return Se(n[u],{callbacks:d})}),i),n[0]?.signal)}catch(c){throw await Promise.all(o.map(l=>l?.handleChainError(c))),c}return await Promise.all(o.map(c=>c?.handleChainEnd(ft(s,"output")))),s}_concatOutputChunks(t,r){return this.last._concatOutputChunks(t,r)}async*_streamIterator(t,r){let i=await Ft(r),{runId:n,...a}=r??{},o=await i?.handleChainStart(this.toJSON(),ft(t,"input"),n,void 0,void 0,void 0,a?.runName),s=[this.first,...this.middle,this.last],c=!0,l;async function*u(){yield t}try{let d=s[0].transform(u(),Se(a,{callbacks:o?.getChild(this.omitSequenceTags?void 0:"seq:step:1")}));for(let f=1;f<s.length;f+=1)d=await s[f].transform(d,Se(a,{callbacks:o?.getChild(this.omitSequenceTags?void 0:`seq:step:${f+1}`)}));for await(let f of d)if(r?.signal?.throwIfAborted(),yield f,c)if(l===void 0)l=f;else try{l=this._concatOutputChunks(l,f)}catch{l=void 0,c=!1}}catch(d){throw await o?.handleChainError(d),d}await o?.handleChainEnd(ft(l,"output"))}getGraph(t){let r=new Ro,i=null;return this.steps.forEach((n,a)=>{let o=n.getGraph(t);a!==0&&o.trimFirstNode(),a!==this.steps.length-1&&o.trimLastNode(),r.extend(o);let s=o.firstNode();if(!s)throw new Error(`Runnable ${n} has no first node`);i&&r.addEdge(i,s),i=o.lastNode()}),r}pipe(t){return Dl.isRunnableSequence(t)?new Dl({first:this.first,middle:this.middle.concat([this.last,t.first,...t.middle]),last:t.last,name:this.name??t.name}):new Dl({first:this.first,middle:[...this.middle,this.last],last:tt(t),name:this.name})}static isRunnableSequence(t){return Array.isArray(t.middle)&&ae.isRunnable(t)}static from([t,...r],i){let n={};return typeof i=="string"?n.name=i:i!==void 0&&(n=i),new Dl({...n,first:tt(t),middle:r.slice(0,-1).map(tt),last:tt(r[r.length-1])})}},wa=class HA extends ae{static lc_name(){return"RunnableMap"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;steps;getStepsKeys(){return Object.keys(this.steps)}constructor(t){super(t),this.steps={};for(let[r,i]of Object.entries(t.steps))this.steps[r]=tt(i)}static from(t){return new HA({steps:t})}async invoke(t,r){let i=we(r),n=await(await Ft(i))?.handleChainStart(this.toJSON(),{input:t},i.runId,void 0,void 0,void 0,i?.runName);delete i.runId;let a={};try{let o=Object.entries(this.steps).map(async([s,c])=>{a[s]=await c.invoke(t,Se(i,{callbacks:n?.getChild(`map:key:${s}`)}))});await Er(Promise.all(o),i.signal)}catch(o){throw await n?.handleChainError(o),o}return await n?.handleChainEnd(a),a}async*_transform(t,r,i){let n={...this.steps},a=ef(t,Object.keys(n).length),o=new Map(Object.entries(n).map(([s,c],l)=>{let u=c.transform(a[l],Se(i,{callbacks:r?.getChild(`map:key:${s}`)}));return[s,u.next().then(d=>({key:s,gen:u,result:d}))]}));for(;o.size;){let{key:s,result:c,gen:l}=await Er(Promise.race(o.values()),i?.signal);o.delete(s),c.done||(yield{[s]:c.value},o.set(s,l.next().then(u=>({key:s,gen:l,result:u}))))}}transform(t,r){return this._transformStreamWithConfig(t,this._transform.bind(this),r)}async stream(t,r){async function*i(){yield t}let n=we(r),a=new Qi({generator:this.transform(i(),n),config:n});return await a.setup,dt.fromAsyncGenerator(a)}},V6=class GA extends ae{lc_serializable=!1;lc_namespace=["langchain_core","runnables"];func;constructor(t){if(super(t),!Yd(t.func))throw new Error("RunnableTraceable requires a function that is wrapped in traceable higher-order function");this.func=t.func}async invoke(t,r){let[i]=this._getOptionsList(r??{},1),n=await Ft(i);return Er(this.func(Se(i,{callbacks:n}),t),i?.signal)}async*_streamIterator(t,r){let[i]=this._getOptionsList(r??{},1),n=await this.invoke(t,r);if(Pp(n)){for await(let a of n)i?.signal?.throwIfAborted(),yield a;return}if(LA(n)){for(;;){i?.signal?.throwIfAborted();let a=n.next();if(a.done)break;yield a.value}return}yield n}static from(t){return new GA({func:t})}};function Z6(e){if(Yd(e))throw new Error("RunnableLambda requires a function that is not wrapped in traceable higher-order function. This shouldn't happen.")}var Zt=class WA extends ae{static lc_name(){return"RunnableLambda"}lc_namespace=["langchain_core","runnables"];func;constructor(t){if(Yd(t.func))return V6.from(t.func);super(t),Z6(t.func),this.func=t.func}static from(t){return new WA({func:t})}async _invoke(t,r,i){return new Promise((n,a)=>{let o=Se(r,{callbacks:i?.getChild(),recursionLimit:(r?.recursionLimit??25)-1});Ae.runWithConfig(pr(o),async()=>{try{let s=await this.func(t,{...o});if(s&&ae.isRunnable(s)){if(r?.recursionLimit===0)throw new Error("Recursion limit reached.");s=await s.invoke(t,{...o,recursionLimit:(o.recursionLimit??25)-1})}else if(Pp(s)){let c;for await(let l of Np(o,s))if(r?.signal?.throwIfAborted(),c===void 0)c=l;else try{c=this._concatOutputChunks(c,l)}catch{c=l}s=c}else if(gw(s)){let c;for(let l of yw(o,s))if(r?.signal?.throwIfAborted(),c===void 0)c=l;else try{c=this._concatOutputChunks(c,l)}catch{c=l}s=c}n(s)}catch(s){a(s)}})})}async invoke(t,r){return this._callWithConfig(this._invoke.bind(this),t,r)}async*_transform(t,r,i){let n;for await(let s of t)if(n===void 0)n=s;else try{n=this._concatOutputChunks(n,s)}catch{n=s}let a=Se(i,{callbacks:r?.getChild(),recursionLimit:(i?.recursionLimit??25)-1}),o=await new Promise((s,c)=>{Ae.runWithConfig(pr(a),async()=>{try{s(await this.func(n,{...a,config:a}))}catch(l){c(l)}})});if(o&&ae.isRunnable(o)){if(i?.recursionLimit===0)throw new Error("Recursion limit reached.");let s=await o.stream(n,a);for await(let c of s)yield c}else if(Pp(o))for await(let s of Np(a,o))i?.signal?.throwIfAborted(),yield s;else if(gw(o))for(let s of yw(a,o))i?.signal?.throwIfAborted(),yield s;else yield o}transform(t,r){return this._transformStreamWithConfig(t,this._transform.bind(this),r)}async stream(t,r){async function*i(){yield t}let n=we(r),a=new Qi({generator:this.transform(i(),n),config:n});return await a.setup,dt.fromAsyncGenerator(a)}},JA=class extends wa{},vw=class extends ae{static lc_name(){return"RunnableWithFallbacks"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;runnable;fallbacks;constructor(e){super(e),this.runnable=e.runnable,this.fallbacks=e.fallbacks}*runnables(){yield this.runnable;for(let e of this.fallbacks)yield e}async invoke(e,t){let r=we(t),i=await Ft(r),{runId:n,...a}=r,o=await i?.handleChainStart(this.toJSON(),ft(e,"input"),n,void 0,void 0,void 0,a?.runName),s=Se(a,{callbacks:o?.getChild()});return await Ae.runWithConfig(s,async()=>{let c;for(let l of this.runnables()){r?.signal?.throwIfAborted();try{let u=await l.invoke(e,s);return await o?.handleChainEnd(ft(u,"output")),u}catch(u){c===void 0&&(c=u)}}throw c===void 0?new Error("No error stored at end of fallback."):(await o?.handleChainError(c),c)})}async*_streamIterator(e,t){let r=we(t),i=await Ft(r),{runId:n,...a}=r,o=await i?.handleChainStart(this.toJSON(),ft(e,"input"),n,void 0,void 0,void 0,a?.runName),s,c;for(let u of this.runnables()){r?.signal?.throwIfAborted();let d=Se(a,{callbacks:o?.getChild()});try{c=Np(d,await u.stream(e,d));break}catch(f){s===void 0&&(s=f)}}if(c===void 0){let u=s??new Error("No error stored at end of fallback.");throw await o?.handleChainError(u),u}let l;try{for await(let u of c){yield u;try{l=l===void 0?l:this._concatOutputChunks(l,u)}catch{l=void 0}}}catch(u){throw await o?.handleChainError(u),u}await o?.handleChainEnd(ft(l,"output"))}async batch(e,t,r){if(r?.returnExceptions)throw new Error("Not implemented.");let i=this._getOptionsList(t??{},e.length),n=await Promise.all(i.map(s=>Ft(s))),a=await Promise.all(n.map(async(s,c)=>{let l=await s?.handleChainStart(this.toJSON(),ft(e[c],"input"),i[c].runId,void 0,void 0,void 0,i[c].runName);return delete i[c].runId,l})),o;for(let s of this.runnables()){i[0].signal?.throwIfAborted();try{let c=await s.batch(e,a.map((l,u)=>Se(i[u],{callbacks:l?.getChild()})),r);return await Promise.all(a.map((l,u)=>l?.handleChainEnd(ft(c[u],"output")))),c}catch(c){o===void 0&&(o=c)}}throw o?(await Promise.all(a.map(s=>s?.handleChainError(o))),o):new Error("No error stored at end of fallbacks.")}};function tt(e){if(typeof e=="function")return new Zt({func:e});if(ae.isRunnable(e))return e;if(!Array.isArray(e)&&typeof e=="object"){let t={};for(let[r,i]of Object.entries(e))t[r]=tt(i);return new wa({steps:t})}else throw new Error(`Expected a Runnable, function or object.
244
- Instead got an unsupported type.`)}var Ul=class extends ae{static lc_name(){return"RunnableAssign"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;mapper;constructor(e){e instanceof wa&&(e={mapper:e}),super(e),this.mapper=e.mapper}async invoke(e,t){let r=await this.mapper.invoke(e,t);return{...e,...r}}async*_transform(e,t,r){let i=this.mapper.getStepsKeys(),[n,a]=ef(e),o=this.mapper.transform(a,Se(r,{callbacks:t?.getChild()})),s=o.next();for await(let c of n){if(typeof c!="object"||Array.isArray(c))throw new Error(`RunnableAssign can only be used with objects as input, got ${typeof c}`);let l=Object.fromEntries(Object.entries(c).filter(([u])=>!i.includes(u)));Object.keys(l).length>0&&(yield l)}yield(await s).value;for await(let c of o)yield c}transform(e,t){return this._transformStreamWithConfig(e,this._transform.bind(this),t)}async stream(e,t){async function*r(){yield e}let i=we(t),n=new Qi({generator:this.transform(r(),i),config:i});return await n.setup,dt.fromAsyncGenerator(n)}},bw=class extends ae{static lc_name(){return"RunnablePick"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;keys;constructor(e){(typeof e=="string"||Array.isArray(e))&&(e={keys:e}),super(e),this.keys=e.keys}async _pick(e){if(typeof this.keys=="string")return e[this.keys];{let t=this.keys.map(r=>[r,e[r]]).filter(r=>r[1]!==void 0);return t.length===0?void 0:Object.fromEntries(t)}}async invoke(e,t){return this._callWithConfig(this._pick.bind(this),e,t)}async*_transform(e){for await(let t of e){let r=await this._pick(t);r!==void 0&&(yield r)}}transform(e,t){return this._transformStreamWithConfig(e,this._transform.bind(this),t)}async stream(e,t){async function*r(){yield e}let i=we(t),n=new Qi({generator:this.transform(r(),i),config:i});return await n.setup,dt.fromAsyncGenerator(n)}},Rp=class extends Jr{name;description;schema;constructor(e){let t=Pr.from([Zt.from(async r=>{let i;if(Gi(r))try{i=await ma(this.schema,r.args)}catch{throw new rs("Received tool input did not match expected schema",JSON.stringify(r.args))}else i=r;return i}).withConfig({runName:`${e.name}:parse_input`}),e.bound]).withConfig({runName:e.name});super({bound:t,config:e.config??{}}),this.name=e.name,this.description=e.description,this.schema=e.schema}static lc_name(){return"RunnableToolLike"}};function H6(e,t){let r=t.name??e.getName(),i=t.description??bi(t.schema);return Vs(t.schema)?new Rp({name:r,description:i,schema:It.object({input:It.string()}).transform(n=>n.input),bound:e}):new Rp({name:r,description:i,schema:t.schema,bound:e})}var jp=(e,t)=>{let r=[...new Set(t?.map(n=>{if(typeof n=="string")return n;let a=new n({});if(!("getType"in a)||typeof a.getType!="function")throw new Error("Invalid type provided.");return a.getType()}))],i=e.getType();return r.some(n=>n===i)};function QA(e,t){return Array.isArray(e)?KA(e,t):Zt.from(r=>KA(r,e))}function KA(e,t={}){let{includeNames:r,excludeNames:i,includeTypes:n,excludeTypes:a,includeIds:o,excludeIds:s}=t,c=[];for(let l of e)if(!(i&&l.name&&i.includes(l.name))){{if(a&&jp(l,a))continue;if(s&&l.id&&s.includes(l.id))continue}n||o||r?(r&&l.name&&r.some(u=>u===l.name)||n&&jp(l,n)||o&&l.id&&o.some(u=>u===l.id))&&c.push(l):c.push(l)}return c}function eO(e){return Array.isArray(e)?qA(e):Zt.from(qA)}function qA(e){if(!e.length)return[];let t=[];for(let r of e){let i=r,n=t.pop();if(!n)t.push(i);else if(i.getType()==="tool"||i.getType()!==n.getType())t.push(n,i);else{let a=Ja(n),o=Ja(i),s=a.concat(o);typeof a.content=="string"&&typeof o.content=="string"&&(s.content=`${a.content}
245
- ${o.content}`),t.push(W6(s))}}return t}function tO(e,t){if(Array.isArray(e)){let r=e;if(!t)throw new Error("Options parameter is required when providing messages.");return XA(r,t)}else{let r=e;return Zt.from(i=>XA(i,r)).withConfig({runName:"trim_messages"})}}async function XA(e,t){let{maxTokens:r,tokenCounter:i,strategy:n="last",allowPartial:a=!1,endOn:o,startOn:s,includeSystem:c=!1,textSplitter:l}=t;if(s&&n==="first")throw new Error("`startOn` should only be specified if `strategy` is 'last'.");if(c&&n==="first")throw new Error("`includeSystem` should only be specified if `strategy` is 'last'.");let u;"getNumTokens"in i?u=async f=>(await Promise.all(f.map(p=>i.getNumTokens(p.content)))).reduce((p,m)=>p+m,0):u=async f=>i(f);let d=xw;if(l&&("splitText"in l?d=l.splitText:d=async f=>l(f)),n==="first")return rO(e,{maxTokens:r,tokenCounter:u,textSplitter:d,partialStrategy:a?"first":void 0,endOn:o});if(n==="last")return G6(e,{maxTokens:r,tokenCounter:u,textSplitter:d,allowPartial:a,includeSystem:c,startOn:s,endOn:o});throw new Error(`Unrecognized strategy: '${n}'. Must be one of 'first' or 'last'.`)}async function rO(e,t){let{maxTokens:r,tokenCounter:i,textSplitter:n,partialStrategy:a,endOn:o}=t,s=[...e],c=0;for(let l=0;l<s.length;l+=1)if(await i(l>0?s.slice(0,-l):s)<=r){c=s.length-l;break}if(c<s.length&&a){let l=!1;if(Array.isArray(s[c].content)){let u=s[c];if(typeof u.content=="string")throw new Error("Expected content to be an array.");let d=u.content.length,f=a==="last"?[...u.content].reverse():u.content;for(let p=1;p<=d;p+=1){let m=a==="first"?f.slice(0,p):f.slice(-p),h=Object.fromEntries(Object.entries(u).filter(([w])=>w!=="type"&&!w.startsWith("lc_"))),_=ww(u.getType(),{...h,content:m}),b=[...s.slice(0,c),_];if(await i(b)<=r)s=b,c+=1,l=!0;else break}l&&a==="last"&&(u.content=[...f].reverse())}if(!l){let u=s[c],d;if(Array.isArray(u.content)&&u.content.some(f=>typeof f=="string"||f.type==="text")?d=u.content.find(f=>f.type==="text"&&f.text)?.text:typeof u.content=="string"&&(d=u.content),d){let f=await n(d),p=f.length;a==="last"&&f.reverse();for(let m=0;m<p-1;m+=1)if(f.pop(),u.content=f.join(""),await i([...s.slice(0,c),u])<=r){a==="last"&&(u.content=[...f].reverse().join("")),s=[...s.slice(0,c),u],c+=1;break}}}}if(o){let l=Array.isArray(o)?o:[o];for(;c>0&&!jp(s[c-1],l);)c-=1}return s.slice(0,c)}async function G6(e,t){let{allowPartial:r=!1,includeSystem:i=!1,endOn:n,startOn:a,...o}=t,s=e.map(u=>{let d=Object.fromEntries(Object.entries(u).filter(([f])=>f!=="type"&&!f.startsWith("lc_")));return ww(u.getType(),d,di(u))});if(n){let u=Array.isArray(n)?n:[n];for(;s.length>0&&!jp(s[s.length-1],u);)s=s.slice(0,-1)}let c=i&&s[0]?.getType()==="system",l=c?s.slice(0,1).concat(s.slice(1).reverse()):s.reverse();return l=await rO(l,{...o,partialStrategy:r?"last":void 0,endOn:a}),c?[l[0],...l.slice(1).reverse()]:l.reverse()}var YA={human:{message:rt,messageChunk:Wa},ai:{message:Ce,messageChunk:Qe},system:{message:er,messageChunk:fi},developer:{message:er,messageChunk:fi},tool:{message:_t,messageChunk:ts},function:{message:Ha,messageChunk:Ga},generic:{message:an,messageChunk:Za},remove:{message:Lr,messageChunk:Lr}};function ww(e,t,r){let i,n;switch(e){case"human":r?i=new Wa(t):n=new rt(t);break;case"ai":if(r){let a={...t};"tool_calls"in a&&(a={...a,tool_call_chunks:a.tool_calls?.map(o=>({...o,type:"tool_call_chunk",index:void 0,args:JSON.stringify(o.args)}))}),i=new Qe(a)}else n=new Ce(t);break;case"system":r?i=new fi(t):n=new er(t);break;case"developer":r?i=new fi({...t,additional_kwargs:{...t.additional_kwargs,__openai_role__:"developer"}}):n=new er({...t,additional_kwargs:{...t.additional_kwargs,__openai_role__:"developer"}});break;case"tool":if("tool_call_id"in t)r?i=new ts(t):n=new _t(t);else throw new Error("Can not convert ToolMessage to ToolMessageChunk if 'tool_call_id' field is not defined.");break;case"function":if(r)i=new Ga(t);else{if(!t.name)throw new Error("FunctionMessage must have a 'name' field");n=new Ha(t)}break;case"generic":if("role"in t)r?i=new Za(t):n=new an(t);else throw new Error("Can not convert ChatMessage to ChatMessageChunk if 'role' field is not defined.");break;default:throw new Error(`Unrecognized message type ${e}`)}if(r&&i)return i;if(n)return n;throw new Error(`Unrecognized message type ${e}`)}function W6(e){let t=e.getType(),r,i=Object.fromEntries(Object.entries(e).filter(([n])=>!["type","tool_call_chunks"].includes(n)&&!n.startsWith("lc_")));if(t in YA&&(r=ww(t,i)),!r)throw new Error(`Unrecognized message chunk class ${t}. Supported classes are ${Object.keys(YA)}`);return r}function xw(e){let t=e.split(`
246
- `);return Promise.resolve([...t.slice(0,-1).map(r=>`${r}
247
- `),t[t.length-1]])}var nO=["tool_call","tool_call_chunk","invalid_tool_call","server_tool_call","server_tool_call_chunk","server_tool_call_result"];var iO=["image","video","audio","text-plain","file"];var aO=["text","reasoning",...nO,...iO];var oO=T({AIMessage:()=>Ce,AIMessageChunk:()=>Qe,BaseMessage:()=>Te,BaseMessageChunk:()=>$t,ChatMessage:()=>an,ChatMessageChunk:()=>Za,DEFAULT_MERGE_IGNORE_KEYS:()=>qh,FunctionMessage:()=>Ha,FunctionMessageChunk:()=>Ga,HumanMessage:()=>rt,HumanMessageChunk:()=>Wa,KNOWN_BLOCK_TYPES:()=>aO,RemoveMessage:()=>Lr,SystemMessage:()=>er,SystemMessageChunk:()=>fi,ToolMessage:()=>_t,ToolMessageChunk:()=>ts,_isMessageFieldWithRole:()=>md,_mergeDicts:()=>Ke,_mergeLists:()=>Hi,_mergeObj:()=>pd,_mergeStatus:()=>fd,coerceMessageLikeToMessage:()=>yt,collapseToolCallChunks:()=>gd,convertToChunk:()=>Ja,convertToOpenAIImageBlock:()=>cd,convertToProviderContentBlock:()=>Sk,defaultTextSplitter:()=>xw,defaultToolCallParser:()=>Gc,filterMessages:()=>QA,getBufferString:()=>as,iife:()=>g$,isAIMessage:()=>is,isAIMessageChunk:()=>Jc,isBase64ContentBlock:()=>es,isBaseMessage:()=>qe,isBaseMessageChunk:()=>di,isChatMessage:()=>c$,isChatMessageChunk:()=>l$,isDataContentBlock:()=>Rn,isDirectToolOutput:()=>Hc,isFunctionMessage:()=>u$,isFunctionMessageChunk:()=>d$,isHumanMessage:()=>f$,isHumanMessageChunk:()=>p$,isIDContentBlock:()=>sd,isMessage:()=>dd,isOpenAIToolCallArray:()=>Dk,isPlainTextContentBlock:()=>wk,isSystemMessage:()=>m$,isSystemMessageChunk:()=>h$,isToolMessage:()=>Wc,isToolMessageChunk:()=>Xh,isURLContentBlock:()=>Qo,mapChatMessagesToStoredMessages:()=>y$,mapStoredMessageToChatMessage:()=>Kc,mapStoredMessagesToChatMessages:()=>_$,mergeContent:()=>zt,mergeMessageRuns:()=>eO,mergeResponseMetadata:()=>hd,mergeUsageMetadata:()=>ns,parseBase64DataUrl:()=>Zc,parseMimeType:()=>xk,trimMessages:()=>tO});var sO=T({BaseChatMessageHistory:()=>Sw,BaseListChatMessageHistory:()=>zp,InMemoryChatMessageHistory:()=>J6}),Sw=class extends lt{async addMessages(e){for(let t of e)await this.addMessage(t)}},zp=class extends lt{addUserMessage(e){return this.addMessage(new rt(e))}addAIMessage(e){return this.addMessage(new Ce(e))}async addMessages(e){for(let t of e)await this.addMessage(t)}clear(){throw new Error("Not implemented.")}},J6=class extends zp{lc_namespace=["langchain","stores","message","in_memory"];messages=[];constructor(e){super(...arguments),this.messages=e??[]}async getMessages(){return this.messages}async addMessage(e){this.messages.push(e)}async clear(){this.messages=[]}};var Nr=class{pageContent;metadata;id;constructor(e){this.pageContent=e.pageContent!==void 0?e.pageContent.toString():"",this.metadata=e.metadata??{},this.id=e.id}};var kw=class extends ae{lc_namespace=["langchain_core","documents","transformers"];invoke(e,t){return this.transformDocuments(e)}},cO=class extends kw{async transformDocuments(e){let t=[];for(let r of e){let i=await this._transformDocument(r);t.push(i)}return t}};var lO=T({BaseDocumentTransformer:()=>kw,Document:()=>Nr,MappingDocumentTransformer:()=>cO});var uO=T({BaseDocumentLoader:()=>$w}),$w=class{};var dO=T({LangSmithLoader:()=>K6}),K6=class extends $w{datasetId;datasetName;exampleIds;asOf;splits;inlineS3Urls;offset;limit;metadata;filter;contentKey;formatContent;client;constructor(e){if(super(),e.client&&e.clientConfig)throw new Error("client and clientConfig cannot both be provided.");this.client=e.client??new Dn(e?.clientConfig),this.contentKey=e.contentKey?e.contentKey.split("."):[],this.formatContent=e.formatContent??q6,this.datasetId=e.datasetId,this.datasetName=e.datasetName,this.exampleIds=e.exampleIds,this.asOf=e.asOf,this.splits=e.splits,this.inlineS3Urls=e.inlineS3Urls,this.offset=e.offset,this.limit=e.limit,this.metadata=e.metadata,this.filter=e.filter}async load(){let e=[];for await(let t of this.client.listExamples({datasetId:this.datasetId,datasetName:this.datasetName,exampleIds:this.exampleIds,asOf:this.asOf,splits:this.splits,inlineS3Urls:this.inlineS3Urls,offset:this.offset,limit:this.limit,metadata:this.metadata,filter:this.filter})){let r=t.inputs;for(let a of this.contentKey)r=r[a];let i=this.formatContent(r),n=t;["created_at","modified_at"].forEach(a=>{a in n&&typeof n[a]=="object"&&(n[a]=n[a].toString())}),e.push({pageContent:i,metadata:n})}return e}};function q6(e){if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}var fO=T({Embeddings:()=>Dp}),Dp=class{caller;constructor(e){this.caller=new hi(e??{})}};var Qs=class extends lt{lc_namespace=["langchain_core","example_selectors","base"]};var Ew=class{async getPromptAsync(e,t){return this.getPrompt(e).partial(t?.partialVariables??{})}},pO=class extends Ew{defaultPrompt;conditionals;constructor(e,t=[]){super(),this.defaultPrompt=e,this.conditionals=t}getPrompt(e){for(let[t,r]of this.conditionals)if(t(e))return r;return this.defaultPrompt}};function mO(e){return e._modelType()==="base_llm"}function hO(e){return e._modelType()==="base_chat_model"}function gO(e){return e.split(/\n| /).length}var _O=class yO extends Qs{examples=[];examplePrompt;getTextLength=gO;maxLength=2048;exampleTextLengths=[];constructor(t){super(t),this.examplePrompt=t.examplePrompt,this.maxLength=t.maxLength??2048,this.getTextLength=t.getTextLength??gO}async addExample(t){this.examples.push(t);let r=await this.examplePrompt.format(t);this.exampleTextLengths.push(this.getTextLength(r))}async calculateExampleTextLengths(t,r){if(t.length>0)return t;let{examples:i,examplePrompt:n}=r;return(await Promise.all(i.map(a=>n.format(a)))).map(a=>this.getTextLength(a))}async selectExamples(t){let r=Object.values(t).join(" "),i=this.maxLength-this.getTextLength(r),n=0,a=[];for(;i>0&&n<this.examples.length;){let o=i-this.exampleTextLengths[n];if(o<0)break;a.push(this.examples[n]),i=o,n+=1}return a}static async fromExamples(t,r){let i=new yO(r);return await Promise.all(t.map(n=>i.addExample(n))),i}};function Iw(e){return Object.keys(e).sort().map(t=>e[t])}var vO=class bO extends Qs{vectorStoreRetriever;exampleKeys;inputKeys;constructor(t){if(super(t),this.exampleKeys=t.exampleKeys,this.inputKeys=t.inputKeys,t.vectorStore!==void 0)this.vectorStoreRetriever=t.vectorStore.asRetriever({k:t.k??4,filter:t.filter});else if(t.vectorStoreRetriever)this.vectorStoreRetriever=t.vectorStoreRetriever;else throw new Error('You must specify one of "vectorStore" and "vectorStoreRetriever".')}async addExample(t){let r=Iw((this.inputKeys??Object.keys(t)).reduce((i,n)=>({...i,[n]:t[n]}),{})).join(" ");await this.vectorStoreRetriever.addDocuments([new Nr({pageContent:r,metadata:t})])}async selectExamples(t){let r=Iw((this.inputKeys??Object.keys(t)).reduce((n,a)=>({...n,[a]:t[a]}),{})).join(" "),i=(await this.vectorStoreRetriever.invoke(r)).map(n=>n.metadata);return this.exampleKeys?i.map(n=>this.exampleKeys.reduce((a,o)=>({...a,[o]:n[o]}),{})):i}static async fromExamples(t,r,i,n={}){let a=n.inputKeys??null,o=t.map(s=>Iw(a?a.reduce((c,l)=>({...c,[l]:s[l]}),{}):s).join(" "));return new bO({vectorStore:await i.fromTexts(o,t,r,n),k:n.k??4,exampleKeys:n.exampleKeys,inputKeys:n.inputKeys})}};var wO=T({BaseExampleSelector:()=>Qs,BasePromptSelector:()=>Ew,ConditionalPromptSelector:()=>pO,LengthBasedExampleSelector:()=>_O,SemanticSimilarityExampleSelector:()=>vO,isChatModel:()=>hO,isLLM:()=>mO});var Ll="10f90ea3-90a4-4962-bf75-83a0f3c1c62a",xO=class extends lt{lc_namespace=["langchain","recordmanagers"]};var Tw=class{uid;hash_;contentHash;metadataHash;pageContent;metadata;keyEncoder=Yo;constructor(e){this.uid=e.uid,this.pageContent=e.pageContent,this.metadata=e.metadata}makeDefaultKeyEncoder(e){this.keyEncoder=e}calculateHashes(){let e=["hash_","content_hash","metadata_hash"];for(let r of e)if(r in this.metadata)throw new Error(`Metadata cannot contain key ${r} as it is reserved for internal use. Restricted keys: [${e.join(", ")}]`);let t=this._hashStringToUUID(this.pageContent);try{let r=this._hashNestedDictToUUID(this.metadata);this.contentHash=t,this.metadataHash=r}catch(r){throw new Error(`Failed to hash metadata: ${r}. Please use a dict that can be serialized using json.`)}this.hash_=this._hashStringToUUID(this.contentHash+this.metadataHash),this.uid||(this.uid=this.hash_)}toDocument(){return new Nr({pageContent:this.pageContent,metadata:this.metadata})}static fromDocument(e,t){let r=new this({pageContent:e.pageContent,metadata:e.metadata,uid:t||e.uid});return r.calculateHashes(),r}_hashStringToUUID(e){return Jo(this.keyEncoder(e),Ll)}_hashNestedDictToUUID(e){let t=JSON.stringify(e,Object.keys(e).sort());return Jo(this.keyEncoder(t),Ll)}};function Cw(e,t){let r=[],i=[];return t.forEach(n=>{i.push(n),i.length>=e&&(r.push(i),i=[])}),i.length>0&&r.push(i),r}function Aw(e){let t=new Set,r=[];for(let i of e){if(!i.hash_)throw new Error("Hashed document does not have a hash");t.has(i.hash_)||(t.add(i.hash_),r.push(i))}return r}function Ow(e){if(e===null)return t=>null;if(typeof e=="string")return t=>t.metadata[e];if(typeof e=="function")return e;throw new Error(`sourceIdKey should be null, a string or a function, got ${typeof e}`)}var Pw=e=>"load"in e&&typeof e.load=="function"&&"loadAndSplit"in e&&typeof e.loadAndSplit=="function";async function SO(e){let{docsSource:t,recordManager:r,vectorStore:i,options:n}=e,{batchSize:a=100,cleanup:o,sourceIdKey:s,cleanupBatchSize:c=1e3,forceUpdate:l=!1}=n??{};if(o==="incremental"&&!s)throw new Error("sourceIdKey is required when cleanup mode is incremental. Please provide through 'options.sourceIdKey'.");let u=Pw(t)?await t.load():t,d=Ow(s??null),f=await r.getTime(),p=0,m=0,h=0,_=0,b=Cw(a??100,u);for(let w of b){let S=Aw(w.map(B=>Tw.fromDocument(B))),x=S.map(B=>d(B));o==="incremental"&&S.forEach((B,A)=>{if(x[A]===null)throw new Error("sourceIdKey must be provided when cleanup is incremental")});let E=await r.exists(S.map(B=>B.uid)),z=[],C=[],v=[],Z=new Set;if(S.forEach((B,A)=>{if(E[A])if(l)Z.add(B.uid);else{v.push(B.uid);return}z.push(B.uid),C.push(B.toDocument())}),v.length>0&&(await r.update(v,{timeAtLeast:f}),_+=v.length),C.length>0&&(await i.addDocuments(C,{ids:z}),p+=C.length-Z.size,h+=Z.size),await r.update(S.map(B=>B.uid),{timeAtLeast:f,groupIds:x}),o==="incremental"){x.forEach(A=>{if(!A)throw new Error("Source id cannot be null")});let B=await r.listKeys({before:f,groupIds:x});B.length>0&&(await i.delete({ids:B}),await r.deleteKeys(B),m+=B.length)}}if(o==="full"){let w=await r.listKeys({before:f,limit:c});for(;w.length>0;)await i.delete({ids:w}),await r.deleteKeys(w),m+=w.length,w=await r.listKeys({before:f,limit:c})}return{numAdded:p,numDeleted:m,numUpdated:h,numSkipped:_}}var kO=T({RecordManager:()=>xO,UUIDV5_NAMESPACE:()=>Ll,_HashedDocument:()=>Tw,_batch:()=>Cw,_deduplicateInOrder:()=>Aw,_getSourceIdAssigner:()=>Ow,_isBaseDocumentLoader:()=>Pw,index:()=>SO});var $O=T({BasePromptValue:()=>Up,ChatPromptValue:()=>Bl,ImagePromptValue:()=>Nw,StringPromptValue:()=>Fl}),Up=class extends lt{},Fl=class extends Up{static lc_name(){return"StringPromptValue"}lc_namespace=["langchain_core","prompt_values"];lc_serializable=!0;value;constructor(e){super({value:e}),this.value=e}toString(){return this.value}toChatMessages(){return[new rt(this.value)]}},Bl=class extends Up{lc_namespace=["langchain_core","prompt_values"];lc_serializable=!0;static lc_name(){return"ChatPromptValue"}messages;constructor(e){Array.isArray(e)&&(e={messages:e}),super(e),this.messages=e.messages}toString(){return as(this.messages)}toChatMessages(){return this.messages}},Nw=class extends Up{lc_namespace=["langchain_core","prompt_values"];lc_serializable=!0;static lc_name(){return"ImagePromptValue"}imageUrl;value;constructor(e){"imageUrl"in e||(e={imageUrl:e}),super(e),this.imageUrl=e.imageUrl}toString(){return this.imageUrl.url}toChatMessages(){return[new rt({content:[{type:"image_url",image_url:{detail:this.imageUrl.detail,url:this.imageUrl.url}}]})]}};var CO=zu(TO(),1),iF=Object.defineProperty,aF=(e,t,r)=>t in e?iF(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,oF=(e,t,r)=>(aF(e,typeof t!="symbol"?t+"":t,r),r);function sF(e,t){let r=Array.from({length:e.length},(i,n)=>({start:n,end:n+1}));for(;r.length>1;){let i=null;for(let n=0;n<r.length-1;n++){let a=e.slice(r[n].start,r[n+1].end),o=t.get(a.join(","));o!=null&&(i==null||o<i[0])&&(i=[o,n])}if(i!=null){let n=i[1];r[n]={start:r[n].start,end:r[n+1].end},r.splice(n+1,1)}else break}return r}function cF(e,t){return e.length===1?[t.get(e.join(","))]:sF(e,t).map(r=>t.get(e.slice(r.start,r.end).join(","))).filter(r=>r!=null)}function lF(e){return e.replace(/[\\^$*+?.()|[\]{}]/g,"\\$&")}var Mw=class{specialTokens;inverseSpecialTokens;patStr;textEncoder=new TextEncoder;textDecoder=new TextDecoder("utf-8");rankMap=new Map;textMap=new Map;constructor(e,t){this.patStr=e.pat_str;let r=e.bpe_ranks.split(`
248
- `).filter(Boolean).reduce((i,n)=>{let[a,o,...s]=n.split(" "),c=Number.parseInt(o,10);return s.forEach((l,u)=>i[l]=c+u),i},{});for(let[i,n]of Object.entries(r)){let a=CO.default.toByteArray(i);this.rankMap.set(a.join(","),n),this.textMap.set(n,a)}this.specialTokens={...e.special_tokens,...t},this.inverseSpecialTokens=Object.entries(this.specialTokens).reduce((i,[n,a])=>(i[a]=this.textEncoder.encode(n),i),{})}encode(e,t=[],r="all"){let i=new RegExp(this.patStr,"ug"),n=Mw.specialTokenRegex(Object.keys(this.specialTokens)),a=[],o=new Set(t==="all"?Object.keys(this.specialTokens):t),s=new Set(r==="all"?Object.keys(this.specialTokens).filter(l=>!o.has(l)):r);if(s.size>0){let l=Mw.specialTokenRegex([...s]),u=e.match(l);if(u!=null)throw new Error(`The text contains a special token that is not allowed: ${u[0]}`)}let c=0;for(;;){let l=null,u=c;for(;n.lastIndex=u,l=n.exec(e),!(l==null||o.has(l[0]));)u=l.index+1;let d=l?.index??e.length;for(let p of e.substring(c,d).matchAll(i)){let m=this.textEncoder.encode(p[0]),h=this.rankMap.get(m.join(","));if(h!=null){a.push(h);continue}a.push(...cF(m,this.rankMap))}if(l==null)break;let f=this.specialTokens[l[0]];a.push(f),c=l.index+l[0].length}return a}decode(e){let t=[],r=0;for(let a=0;a<e.length;++a){let o=e[a],s=this.textMap.get(o)??this.inverseSpecialTokens[o];s!=null&&(t.push(s),r+=s.length)}let i=new Uint8Array(r),n=0;for(let a of t)i.set(a,n),n+=a.length;return this.textDecoder.decode(i)}},Fp=Mw;oF(Fp,"specialTokenRegex",e=>new RegExp(e.map(t=>lF(t)).join("|"),"g"));function jw(e){switch(e){case"gpt2":return"gpt2";case"code-cushman-001":case"code-cushman-002":case"code-davinci-001":case"code-davinci-002":case"cushman-codex":case"davinci-codex":case"davinci-002":case"text-davinci-002":case"text-davinci-003":return"p50k_base";case"code-davinci-edit-001":case"text-davinci-edit-001":return"p50k_edit";case"ada":case"babbage":case"babbage-002":case"code-search-ada-code-001":case"code-search-babbage-code-001":case"curie":case"davinci":case"text-ada-001":case"text-babbage-001":case"text-curie-001":case"text-davinci-001":case"text-search-ada-doc-001":case"text-search-babbage-doc-001":case"text-search-curie-doc-001":case"text-search-davinci-doc-001":case"text-similarity-ada-001":case"text-similarity-babbage-001":case"text-similarity-curie-001":case"text-similarity-davinci-001":return"r50k_base";case"gpt-3.5-turbo-instruct-0914":case"gpt-3.5-turbo-instruct":case"gpt-3.5-turbo-16k-0613":case"gpt-3.5-turbo-16k":case"gpt-3.5-turbo-0613":case"gpt-3.5-turbo-0301":case"gpt-3.5-turbo":case"gpt-4-32k-0613":case"gpt-4-32k-0314":case"gpt-4-32k":case"gpt-4-0613":case"gpt-4-0314":case"gpt-4":case"gpt-3.5-turbo-1106":case"gpt-35-turbo":case"gpt-4-1106-preview":case"gpt-4-vision-preview":case"gpt-3.5-turbo-0125":case"gpt-4-turbo":case"gpt-4-turbo-2024-04-09":case"gpt-4-turbo-preview":case"gpt-4-0125-preview":case"text-embedding-ada-002":case"text-embedding-3-small":case"text-embedding-3-large":return"cl100k_base";case"gpt-4o":case"gpt-4o-2024-05-13":case"gpt-4o-2024-08-06":case"gpt-4o-2024-11-20":case"gpt-4o-mini-2024-07-18":case"gpt-4o-mini":case"gpt-4o-search-preview":case"gpt-4o-search-preview-2025-03-11":case"gpt-4o-mini-search-preview":case"gpt-4o-mini-search-preview-2025-03-11":case"gpt-4o-audio-preview":case"gpt-4o-audio-preview-2024-12-17":case"gpt-4o-audio-preview-2024-10-01":case"gpt-4o-mini-audio-preview":case"gpt-4o-mini-audio-preview-2024-12-17":case"o1":case"o1-2024-12-17":case"o1-mini":case"o1-mini-2024-09-12":case"o1-preview":case"o1-preview-2024-09-12":case"o1-pro":case"o1-pro-2025-03-19":case"o3":case"o3-2025-04-16":case"o3-mini":case"o3-mini-2025-01-31":case"o4-mini":case"o4-mini-2025-04-16":case"chatgpt-4o-latest":case"gpt-4o-realtime":case"gpt-4o-realtime-preview-2024-10-01":case"gpt-4o-realtime-preview-2024-12-17":case"gpt-4o-mini-realtime-preview":case"gpt-4o-mini-realtime-preview-2024-12-17":case"gpt-4.1":case"gpt-4.1-2025-04-14":case"gpt-4.1-mini":case"gpt-4.1-mini-2025-04-14":case"gpt-4.1-nano":case"gpt-4.1-nano-2025-04-14":case"gpt-4.5-preview":case"gpt-4.5-preview-2025-02-27":case"gpt-5":case"gpt-5-2025-08-07":case"gpt-5-nano":case"gpt-5-nano-2025-08-07":case"gpt-5-mini":case"gpt-5-mini-2025-08-07":case"gpt-5-chat-latest":return"o200k_base";default:throw new Error("Unknown model")}}var AO=T({encodingForModel:()=>Vp,getEncoding:()=>OO}),Bp={},uF=new hi({});async function OO(e){return e in Bp||(Bp[e]=uF.fetch(`https://tiktoken.pages.dev/js/${e}.json`).then(t=>t.json()).then(t=>new Fp(t)).catch(t=>{throw delete Bp[e],t})),await Bp[e]}async function Vp(e){return OO(jw(e))}var PO=T({BaseLangChain:()=>Hp,BaseLanguageModel:()=>Vl,calculateMaxTokens:()=>pF,getEmbeddingContextSize:()=>dF,getModelContextSize:()=>NO,getModelNameForTiktoken:()=>Zp,isOpenAITool:()=>fF}),Zp=e=>e.startsWith("gpt-5")?"gpt-5":e.startsWith("gpt-3.5-turbo-16k")?"gpt-3.5-turbo-16k":e.startsWith("gpt-3.5-turbo-")?"gpt-3.5-turbo":e.startsWith("gpt-4-32k")?"gpt-4-32k":e.startsWith("gpt-4-")?"gpt-4":e.startsWith("gpt-4o")?"gpt-4o":e,dF=e=>e==="text-embedding-ada-002"?8191:2046,NO=e=>{switch(Zp(e)){case"gpt-5":case"gpt-5-turbo":case"gpt-5-turbo-preview":return 4e5;case"gpt-4o":case"gpt-4o-mini":case"gpt-4o-2024-05-13":case"gpt-4o-2024-08-06":return 128e3;case"gpt-4-turbo":case"gpt-4-turbo-preview":case"gpt-4-turbo-2024-04-09":case"gpt-4-0125-preview":case"gpt-4-1106-preview":return 128e3;case"gpt-4-32k":case"gpt-4-32k-0314":case"gpt-4-32k-0613":return 32768;case"gpt-4":case"gpt-4-0314":case"gpt-4-0613":return 8192;case"gpt-3.5-turbo-16k":case"gpt-3.5-turbo-16k-0613":return 16384;case"gpt-3.5-turbo":case"gpt-3.5-turbo-0301":case"gpt-3.5-turbo-0613":case"gpt-3.5-turbo-1106":case"gpt-3.5-turbo-0125":return 4096;case"text-davinci-003":case"text-davinci-002":return 4097;case"text-davinci-001":return 2049;case"text-curie-001":case"text-babbage-001":case"text-ada-001":return 2048;case"code-davinci-002":case"code-davinci-001":return 8e3;case"code-cushman-001":return 2048;case"claude-3-5-sonnet-20241022":case"claude-3-5-sonnet-20240620":case"claude-3-opus-20240229":case"claude-3-sonnet-20240229":case"claude-3-haiku-20240307":case"claude-2.1":return 2e5;case"claude-2.0":case"claude-instant-1.2":return 1e5;case"gemini-1.5-pro":case"gemini-1.5-pro-latest":case"gemini-1.5-flash":case"gemini-1.5-flash-latest":return 1e6;case"gemini-pro":case"gemini-pro-vision":return 32768;default:return 4097}};function fF(e){return typeof e!="object"||!e?!1:!!("type"in e&&e.type==="function"&&"function"in e&&typeof e.function=="object"&&e.function&&"name"in e.function&&"parameters"in e.function)}var pF=async({prompt:e,modelName:t})=>{let r;try{r=(await Vp(Zp(t))).encode(e).length}catch{console.warn("Failed to calculate number of tokens, falling back to approximate count"),r=Math.ceil(e.length/4)}return NO(t)-r},mF=()=>!1,Hp=class extends ae{verbose;callbacks;tags;metadata;get lc_attributes(){return{callbacks:void 0,verbose:void 0}}constructor(e){super(e),this.verbose=e.verbose??mF(),this.callbacks=e.callbacks,this.tags=e.tags??[],this.metadata=e.metadata??{},this._addVersion("@langchain/core","1.1.49")}_addVersion(e,t){let r=this.metadata?.versions;this.metadata={...this.metadata,versions:{...typeof r=="object"&&r!==null?r:{},[e]:t}}}},Vl=class extends Hp{get callKeys(){return["stop","timeout","signal","tags","metadata","callbacks"]}caller;cache;constructor({callbacks:e,callbackManager:t,...r}){let{cache:i,...n}=r;super({callbacks:e??t,...n}),typeof i=="object"?this.cache=i:i?this.cache=tg.global():this.cache=void 0,this.caller=new hi(r??{})}_encoding;async getNumTokens(e){let t;typeof e=="string"?t=e:t=e.map(i=>typeof i=="string"?i:i.type==="text"&&"text"in i?i.text:"").join("");let r=Math.ceil(t.length/4);if(!this._encoding)try{this._encoding=await Vp("modelName"in this?Zp(this.modelName):"gpt2")}catch(i){console.warn("Failed to calculate number of tokens, falling back to approximate count",i)}if(this._encoding)try{r=this._encoding.encode(t).length}catch(i){console.warn("Failed to calculate number of tokens, falling back to approximate count",i)}return r}static _convertInputToPromptValue(e){return typeof e=="string"?new Fl(e):Array.isArray(e)?new Bl(e.map(yt)):e}_identifyingParams(){return{}}_getSerializedCacheKeyParametersForCall({config:e,...t}){let r={...this._identifyingParams(),...t,_type:this._llmType(),_model:this._modelType()};return Object.entries(r).filter(([i,n])=>n!==void 0).map(([i,n])=>`${i}:${JSON.stringify(n)}`).sort().join(",")}serialize(){return{...this._identifyingParams(),_type:this._llmType(),_model:this._modelType()}}static async deserialize(e){throw new Error("Use .toJSON() instead")}get profile(){return{}}_filterInvocationParamsForTracing(e){let{tools:t,functions:r,messages:i,response_format:n,...a}=e;return a}};var $i=class extends ae{static lc_name(){return"RunnablePassthrough"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;func;constructor(e){super(e),e&&(this.func=e.func)}async invoke(e,t){let r=we(t);return this.func&&await this.func(e,r),this._callWithConfig(i=>Promise.resolve(i),e,r)}async*transform(e,t){let r=we(t),i,n=!0;for await(let a of this._transformStreamWithConfig(e,o=>o,r))if(yield a,n)if(i===void 0)i=a;else try{i=Ir(i,a)}catch{i=void 0,n=!1}this.func&&i!==void 0&&await this.func(i,r)}static assign(e){return new Ul(new wa({steps:e}))}};var RO=class extends ae{static lc_name(){return"RouterRunnable"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;runnables;constructor(e){super(e),this.runnables=e.runnables}async invoke(e,t){let{key:r,input:i}=e,n=this.runnables[r];if(n===void 0)throw new Error(`No runnable associated with key "${r}".`);return n.invoke(i,we(t))}async batch(e,t,r){let i=e.map(u=>u.key),n=e.map(u=>u.input);if(i.find(u=>this.runnables[u]===void 0)!==void 0)throw new Error("One or more keys do not have a corresponding runnable.");let a=i.map(u=>this.runnables[u]),o=this._getOptionsList(t??{},e.length),s=o[0]?.maxConcurrency??r?.maxConcurrency,c=s&&s>0?s:e.length,l=[];for(let u=0;u<n.length;u+=c){let d=n.slice(u,u+c).map((p,m)=>a[m].invoke(p,o[m])),f=await Promise.all(d);l.push(f)}return l.flat()}async stream(e,t){let{key:r,input:i}=e,n=this.runnables[r];if(n===void 0)throw new Error(`No runnable associated with key "${r}".`);return n.stream(i,t)}};var MO=class extends ae{static lc_name(){return"RunnableBranch"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;default;branches;constructor(e){super(e),this.branches=e.branches,this.default=e.default}static from(e){if(e.length<1)throw new Error("RunnableBranch requires at least one branch");let t=e.slice(0,-1).map(([i,n])=>[tt(i),tt(n)]),r=tt(e[e.length-1]);return new this({branches:t,default:r})}async _invoke(e,t,r){let i;for(let n=0;n<this.branches.length;n+=1){let[a,o]=this.branches[n];if(await a.invoke(e,Se(t,{callbacks:r?.getChild(`condition:${n+1}`)}))){i=await o.invoke(e,Se(t,{callbacks:r?.getChild(`branch:${n+1}`)}));break}}return i||(i=await this.default.invoke(e,Se(t,{callbacks:r?.getChild("branch:default")}))),i}async invoke(e,t={}){return this._callWithConfig(this._invoke,e,t)}async*_streamIterator(e,t){let r=await(await Ft(t))?.handleChainStart(this.toJSON(),ft(e,"input"),t?.runId,void 0,void 0,void 0,t?.runName),i,n=!0,a;try{for(let o=0;o<this.branches.length;o+=1){let[s,c]=this.branches[o];if(await s.invoke(e,Se(t,{callbacks:r?.getChild(`condition:${o+1}`)}))){a=await c.stream(e,Se(t,{callbacks:r?.getChild(`branch:${o+1}`)}));for await(let l of a)if(yield l,n)if(i===void 0)i=l;else try{i=Ir(i,l)}catch{i=void 0,n=!1}break}}if(a===void 0){a=await this.default.stream(e,Se(t,{callbacks:r?.getChild("branch:default")}));for await(let o of a)if(yield o,n)if(i===void 0)i=o;else try{i=Ir(i,o)}catch{i=void 0,n=!1}}}catch(o){throw await r?.handleChainError(o),o}await r?.handleChainEnd(i??{})}};var jO=class extends Jr{runnable;inputMessagesKey;outputMessagesKey;historyMessagesKey;getMessageHistory;constructor(e){let t=Zt.from((a,o)=>this._enterHistory(a,o??{})).withConfig({runName:"loadHistory"}),r=e.historyMessagesKey??e.inputMessagesKey;r&&(t=$i.assign({[r]:t}).withConfig({runName:"insertHistory"}));let i=t.pipe(e.runnable.withListeners({onEnd:(a,o)=>this._exitHistory(a,o??{})})).withConfig({runName:"RunnableWithMessageHistory"}),n=e.config??{};super({...e,config:n,bound:i}),this.runnable=e.runnable,this.getMessageHistory=e.getMessageHistory,this.inputMessagesKey=e.inputMessagesKey,this.outputMessagesKey=e.outputMessagesKey,this.historyMessagesKey=e.historyMessagesKey}_getInputMessages(e){let t;if(typeof e=="object"&&!Array.isArray(e)&&!qe(e)){let r;this.inputMessagesKey?r=this.inputMessagesKey:Object.keys(e).length===1?r=Object.keys(e)[0]:r="input",Array.isArray(e[r])&&Array.isArray(e[r][0])?t=e[r][0]:t=e[r]}else t=e;if(typeof t=="string")return[new rt(t)];if(Array.isArray(t))return t;if(qe(t))return[t];throw new Error(`Expected a string, BaseMessage, or array of BaseMessages.
249
- Got ${JSON.stringify(t,null,2)}`)}_getOutputMessages(e){let t;if(!Array.isArray(e)&&!qe(e)&&typeof e!="string"){let r;this.outputMessagesKey!==void 0?r=this.outputMessagesKey:Object.keys(e).length===1?r=Object.keys(e)[0]:r="output",e.generations!==void 0?t=e.generations[0][0].message:t=e[r]}else t=e;if(typeof t=="string")return[new Ce(t)];if(Array.isArray(t))return t;if(qe(t))return[t];throw new Error(`Expected a string, BaseMessage, or array of BaseMessages. Received: ${JSON.stringify(t,null,2)}`)}async _enterHistory(e,t){let r=await(t?.configurable?.messageHistory).getMessages();return this.historyMessagesKey===void 0?r.concat(this._getInputMessages(e)):r}async _exitHistory(e,t){let r=t.configurable?.messageHistory,i;Array.isArray(e.inputs)&&Array.isArray(e.inputs[0])?i=e.inputs[0]:i=e.inputs;let n=this._getInputMessages(i);if(this.historyMessagesKey===void 0){let s=await r.getMessages();n=n.slice(s.length)}let a=e.outputs;if(!a)throw new Error(`Output values from 'Run' undefined. Run: ${JSON.stringify(e,null,2)}`);let o=this._getOutputMessages(a);await r.addMessages([...n,...o])}async _mergeConfig(...e){let t=await super._mergeConfig(...e);if(!t.configurable||!t.configurable.sessionId){let i={[this.inputMessagesKey??"input"]:"foo"};throw new Error(`sessionId is required. Pass it in as part of the config argument to .invoke() or .stream()
250
- eg. chain.invoke(${JSON.stringify(i)}, ${JSON.stringify({configurable:{sessionId:"123"}})})`)}let{sessionId:r}=t.configurable;return t.configurable.messageHistory=await this.getMessageHistory(r),t}};var zO=T({RouterRunnable:()=>RO,Runnable:()=>ae,RunnableAssign:()=>Ul,RunnableBinding:()=>Jr,RunnableBranch:()=>MO,RunnableEach:()=>VA,RunnableLambda:()=>Zt,RunnableMap:()=>wa,RunnableParallel:()=>JA,RunnablePassthrough:()=>$i,RunnablePick:()=>bw,RunnableRetry:()=>Mp,RunnableSequence:()=>Pr,RunnableToolLike:()=>Rp,RunnableWithFallbacks:()=>vw,RunnableWithMessageHistory:()=>jO,_coerceToRunnable:()=>tt,ensureConfig:()=>we,getCallbackManagerForConfig:()=>Ft,mergeConfigs:()=>vt,patchConfig:()=>Se,pickRunnableConfigKeys:()=>pr,raceWithSignal:()=>Er});var DO=T({applyPatch:()=>ea,compare:()=>ta});var ec=class extends ae{parseResultWithPrompt(e,t,r){return this.parseResult(e,r)}_baseMessageToString(e){return typeof e.content=="string"?e.content:this._baseMessageContentToString(e.content)}_baseMessageContentToString(e){return JSON.stringify(e)}async invoke(e,t){return typeof e=="string"?this._callWithConfig(async(r,i)=>this.parseResult([{text:r}],i?.callbacks),e,{...t,runType:"parser"}):this._callWithConfig(async(r,i)=>this.parseResult([{message:r,text:this._baseMessageToString(r)}],i?.callbacks),e,{...t,runType:"parser"})}},mn=class extends ec{parseResult(e,t){return this.parse(e[0].text,t)}async parseWithPrompt(e,t,r){return this.parse(e,r)}_type(){throw new Error("_type not implemented")}},Ht=class extends Error{llmOutput;observation;sendToLLM;constructor(e,t,r,i=!1){if(super(e),this.llmOutput=t,this.observation=r,this.sendToLLM=i,i&&(r===void 0||t===void 0))throw new Error("Arguments 'observation' & 'llmOutput' are required if 'sendToLlm' is true");ui(this,"OUTPUT_PARSING_FAILURE")}};var Ei=class extends mn{async*_transform(e){for await(let t of e)typeof t=="string"?yield this.parseResult([{text:t}]):yield this.parseResult([{message:t,text:this._baseMessageToString(t)}])}async*transform(e,t){yield*this._transformStreamWithConfig(e,this._transform.bind(this),{...t,runType:"parser"})}},Xn=class extends Ei{diff=!1;constructor(e){super(e),this.diff=e?.diff??this.diff}async*_transform(e){let t,r;for await(let i of e){if(typeof i!="string"&&typeof i.content!="string")throw new Error("Cannot handle non-string output.");let n;if(di(i)){if(typeof i.content!="string")throw new Error("Cannot handle non-string message output.");n=new ra({message:i,text:i.content})}else if(qe(i)){if(typeof i.content!="string")throw new Error("Cannot handle non-string message output.");n=new ra({message:Ja(i),text:i.content})}else n=new mi({text:i});r===void 0?r=n:r=r.concat(n);let a=await this.parsePartialResult([r]);a!=null&&!Jn(a,t)&&(this.diff?yield this._diff(t,a):yield a,t=a)}}getFormatInstructions(){return""}};var UO=class extends Ei{static lc_name(){return"BytesOutputParser"}lc_namespace=["langchain_core","output_parsers","bytes"];lc_serializable=!0;textEncoder=new TextEncoder;parse(e){return Promise.resolve(this.textEncoder.encode(e))}getFormatInstructions(){return""}};var tc=class extends Ei{re;async*_transform(e){let t="";for await(let r of e)if(typeof r=="string"?t+=r:t+=r.content,this.re){let i=[...t.matchAll(this.re)];if(i.length>1){let n=0;for(let a of i.slice(0,-1))yield[a[1]],n+=(a.index??0)+a[0].length;t=t.slice(n)}}else{let i=await this.parse(t);if(i.length>1){for(let n of i.slice(0,-1))yield[n];t=i[i.length-1]}}for(let r of await this.parse(t))yield[r]}},LO=class extends tc{static lc_name(){return"CommaSeparatedListOutputParser"}lc_namespace=["langchain_core","output_parsers","list"];lc_serializable=!0;async parse(e){try{return e.trim().split(",").map(t=>t.trim())}catch{throw new Ht(`Could not parse output: ${e}`,e)}}getFormatInstructions(){return"Your response should be a list of comma separated values, eg: `foo, bar, baz`"}},FO=class extends tc{lc_namespace=["langchain_core","output_parsers","list"];length;separator;constructor({length:e,separator:t}){super(...arguments),this.length=e,this.separator=t||","}async parse(e){try{let t=e.trim().split(this.separator).map(r=>r.trim());if(this.length!==void 0&&t.length!==this.length)throw new Ht(`Incorrect number of items. Expected ${this.length}, got ${t.length}.`);return t}catch(t){throw Object.getPrototypeOf(t)===Ht.prototype?t:new Ht(`Could not parse output: ${e}`)}}getFormatInstructions(){return`Your response should be a list of ${this.length===void 0?"":`${this.length} `}items separated by "${this.separator}" (eg: \`foo${this.separator} bar${this.separator} baz\`)`}},BO=class extends tc{static lc_name(){return"NumberedListOutputParser"}lc_namespace=["langchain_core","output_parsers","list"];lc_serializable=!0;getFormatInstructions(){return`Your response should be a numbered list with each item on a new line. For example:
251
-
252
- 1. foo
253
-
254
- 2. bar
255
-
256
- 3. baz`}re=/\d+\.\s([^\n]+)/g;async parse(e){return[...e.matchAll(this.re)??[]].map(t=>t[1])}},VO=class extends tc{static lc_name(){return"NumberedListOutputParser"}lc_namespace=["langchain_core","output_parsers","list"];lc_serializable=!0;getFormatInstructions(){return`Your response should be a numbered list with each item on a new line. For example:
257
-
258
- 1. foo
259
-
260
- 2. bar
261
-
262
- 3. baz`}re=/^\s*[-*]\s([^\n]+)$/gm;async parse(e){return[...e.matchAll(this.re)??[]].map(t=>t[1])}};var ZO=class extends Ei{static lc_name(){return"StrOutputParser"}lc_namespace=["langchain_core","output_parsers","string"];lc_serializable=!0;parse(e){return Promise.resolve(e)}getFormatInstructions(){return""}_textContentToString(e){return e.text}_imageUrlContentToString(e){throw new Error('Cannot coerce a multimodal "image_url" message part into a string.')}_messageContentToString(e){switch(e.type){case"text":case"text_delta":if("text"in e)return this._textContentToString(e);break;case"image_url":if("image_url"in e)return this._imageUrlContentToString(e);break;case"reasoning":case"thinking":case"redacted_thinking":return"";default:throw new Error(`Cannot coerce "${e.type}" message part into a string.`)}throw new Error(`Invalid content type: ${e.type}`)}_baseMessageContentToString(e){return e.reduce((t,r)=>t+this._messageContentToString(r),"")}};var Gp=class extends Xn{static lc_name(){return"JsonOutputParser"}lc_namespace=["langchain_core","output_parsers"];lc_serializable=!0;_concatOutputChunks(e,t){return this.diff?super._concatOutputChunks(e,t):t}_diff(e,t){if(t)return e?ta(e,t):[{op:"replace",path:"",value:t}]}async parsePartialResult(e){return Va(e[0].text)}async parse(e){return Va(e,JSON.parse)}getFormatInstructions(){return""}_baseMessageToString(e){return e.text}};var Wp=class extends mn{static lc_name(){return"StandardSchemaOutputParser"}lc_namespace=["langchain","output_parsers","standard_schema"];schema;constructor(e){super(),this.schema=e}static fromSerializableSchema(e){return new this(e)}async parse(e){try{let t=Va(e,JSON.parse),r=await this.schema["~standard"].validate(t);if(r.issues)throw new Error(`Validation failed: ${JSON.stringify(r.issues)}`);return r.value}catch(t){throw new Ht(`Failed to parse. Text: "${e}". Error: ${t}`,e)}}_baseMessageToString(e){return e.text}getFormatInstructions(){return""}};var Zl=class extends mn{static lc_name(){return"StructuredOutputParser"}lc_namespace=["langchain","output_parsers","structured"];toJSON(){return this.toJSONNotImplemented()}constructor(e){super(e),this.schema=e}static fromZodSchema(e){return new this(e)}static fromNamesAndDescriptions(e){let t=It.object(Object.fromEntries(Object.entries(e).map(([r,i])=>[r,It.string().describe(i)])));return new this(t)}getFormatInstructions(){return`You must format your output as a JSON value that adheres to a given "JSON Schema" instance.
263
-
264
- "JSON Schema" is a declarative language that allows you to annotate and validate JSON documents.
265
-
266
- For example, the example "JSON Schema" instance {{"properties": {{"foo": {{"description": "a list of test words", "type": "array", "items": {{"type": "string"}}}}}}, "required": ["foo"]}}
267
- would match an object with one required property, "foo". The "type" property specifies "foo" must be an "array", and the "description" property semantically describes it as "a list of test words". The items within "foo" must be strings.
268
- Thus, the object {{"foo": ["bar", "baz"]}} is a well-formatted instance of this example "JSON Schema". The object {{"properties": {{"foo": ["bar", "baz"]}}}} is not well-formatted.
269
-
270
- Your output will be parsed and type-checked according to the provided schema instance, so make sure all fields in your output match the schema exactly and there are no trailing commas!
271
-
272
- Here is the JSON Schema instance your output must adhere to. Include the enclosing markdown codeblock:
273
- \`\`\`json
274
- ${JSON.stringify(bt(this.schema))}
275
- \`\`\`
276
- `}async parse(e){try{let t=e.trim(),r=(t.match(/^```(?:json)?\s*([\s\S]*?)```/)?.[1]||t.match(/```json\s*([\s\S]*?)```/)?.[1]||t).replace(/"([^"\\]*(\\.[^"\\]*)*)"/g,(i,n)=>`"${n.replace(/\n/g,"\\n")}"`).replace(/\n/g,"");return await ma(this.schema,JSON.parse(r))}catch(t){throw new Ht(`Failed to parse. Text: "${e}". Error: ${t}`,e)}}_baseMessageToString(e){return e.text}},zw=class extends Zl{static lc_name(){return"JsonMarkdownStructuredOutputParser"}getFormatInstructions(e){let t=e?.interpolationDepth??1;if(t<1)throw new Error("f string interpolation depth must be at least 1");return`Return a markdown code snippet with a JSON object formatted to look like:
277
- \`\`\`json
278
- ${this._schemaToInstruction(bt(this.schema)).replaceAll("{","{".repeat(t)).replaceAll("}","}".repeat(t))}
279
- \`\`\``}_schemaToInstruction(e,t=2){let r=e;if("type"in r){let i=!1,n;if(Array.isArray(r.type)){let s=r.type.findIndex(c=>c==="null");s!==-1&&(i=!0,r.type.splice(s,1)),n=r.type.join(" | ")}else n=r.type;if(r.type==="object"&&r.properties){let s=r.description?` // ${r.description}`:"";return`{
280
- ${Object.entries(r.properties).map(([c,l])=>{let u=r.required?.includes(c)?"":" (optional)";return`${" ".repeat(t)}"${c}": ${this._schemaToInstruction(l,t+2)}${u}`}).join(`
281
- `)}
282
- ${" ".repeat(t-2)}}${s}`}if(r.type==="array"&&r.items){let s=r.description?` // ${r.description}`:"";return`array[
283
- ${" ".repeat(t)}${this._schemaToInstruction(r.items,t+2)}
284
- ${" ".repeat(t-2)}] ${s}`}let a=i?" (nullable)":"",o=r.description?` // ${r.description}`:"";return`${n}${o}${a}`}if("anyOf"in r)return r.anyOf.map(i=>this._schemaToInstruction(i,t)).join(`
285
- ${" ".repeat(t-2)}`);throw new Error("unsupported schema type")}static fromZodSchema(e){return new this(e)}static fromNamesAndDescriptions(e){let t=It.object(Object.fromEntries(Object.entries(e).map(([r,i])=>[r,It.string().describe(i)])));return new this(t)}},HO=class extends mn{structuredInputParser;constructor({inputSchema:e}){super(...arguments),this.structuredInputParser=new zw(e)}async parse(e){let t;try{t=await this.structuredInputParser.parse(e)}catch(r){throw new Ht(`Failed to parse. Text: "${e}". Error: ${r}`,e)}return this.outputProcessor(t)}getFormatInstructions(){return this.structuredInputParser.getFormatInstructions()}};var hF=function(){let e={};e.parser=function(y,g){return new r(y,g)},e.SAXParser=r,e.SAXStream=l,e.createStream=c,e.MAX_BUFFER_LENGTH=65536;let t=["comment","sgmlDecl","textNode","tagName","doctype","procInstName","procInstBody","entity","attribName","attribValue","cdata","script"];e.EVENTS=["text","processinginstruction","sgmldeclaration","doctype","comment","opentagstart","attribute","opentag","closetag","opencdata","cdata","closecdata","error","end","ready","script","opennamespace","closenamespace"];function r(y,g){if(!(this instanceof r))return new r(y,g);var P=this;n(P),P.q=P.c="",P.bufferCheckPosition=e.MAX_BUFFER_LENGTH,P.opt=g||{},P.opt.lowercase=P.opt.lowercase||P.opt.lowercasetags,P.looseCase=P.opt.lowercase?"toLowerCase":"toUpperCase",P.tags=[],P.closed=P.closedRoot=P.sawRoot=!1,P.tag=P.error=null,P.strict=!!y,P.noscript=!!(y||P.opt.noscript),P.state=v.BEGIN,P.strictEntities=P.opt.strictEntities,P.ENTITIES=P.strictEntities?Object.create(e.XML_ENTITIES):Object.create(e.ENTITIES),P.attribList=[],P.opt.xmlns&&(P.ns=Object.create(m)),P.trackPosition=P.opt.position!==!1,P.trackPosition&&(P.position=P.line=P.column=0),B(P,"onready")}Object.create||(Object.create=function(y){function g(){}return g.prototype=y,new g}),Object.keys||(Object.keys=function(y){var g=[];for(var P in y)y.hasOwnProperty(P)&&g.push(P);return g});function i(y){for(var g=Math.max(e.MAX_BUFFER_LENGTH,10),P=0,$=0,$e=t.length;$<$e;$++){var Me=y[t[$]].length;if(Me>g)switch(t[$]){case"textNode":L(y);break;case"cdata":A(y,"oncdata",y.cdata),y.cdata="";break;case"script":A(y,"onscript",y.script),y.script="";break;default:Y(y,"Max buffer length exceeded: "+t[$])}P=Math.max(P,Me)}y.bufferCheckPosition=e.MAX_BUFFER_LENGTH-P+y.position}function n(y){for(var g=0,P=t.length;g<P;g++)y[t[g]]=""}function a(y){L(y),y.cdata!==""&&(A(y,"oncdata",y.cdata),y.cdata=""),y.script!==""&&(A(y,"onscript",y.script),y.script="")}r.prototype={end:function(){Ie(this)},write:en,resume:function(){return this.error=null,this},close:function(){return this.write(null)},flush:function(){a(this)}};var o=ReadableStream;o||(o=function(){});var s=e.EVENTS.filter(function(y){return y!=="error"&&y!=="end"});function c(y,g){return new l(y,g)}function l(y,g){if(!(this instanceof l))return new l(y,g);o.apply(this),this._parser=new r(y,g),this.writable=!0,this.readable=!0;var P=this;this._parser.onend=function(){P.emit("end")},this._parser.onerror=function($){P.emit("error",$),P._parser.error=null},this._decoder=null,s.forEach(function($){Object.defineProperty(P,"on"+$,{get:function(){return P._parser["on"+$]},set:function($e){if(!$e)return P.removeAllListeners($),P._parser["on"+$]=$e,$e;P.on($,$e)},enumerable:!0,configurable:!1})})}l.prototype=Object.create(o.prototype,{constructor:{value:l}}),l.prototype.write=function(y){return this._parser.write(y.toString()),this.emit("data",y),!0},l.prototype.end=function(y){return y&&y.length&&this.write(y),this._parser.end(),!0},l.prototype.on=function(y,g){var P=this;return!P._parser["on"+y]&&s.indexOf(y)!==-1&&(P._parser["on"+y]=function(){var $=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);$.splice(0,0,y),P.emit.apply(P,$)}),o.prototype.on.call(P,y,g)};var u="[CDATA[",d="DOCTYPE",f="http://www.w3.org/XML/1998/namespace",p="http://www.w3.org/2000/xmlns/",m={xml:f,xmlns:p},h=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,_=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/,b=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,w=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;function S(y){return y===" "||y===`
286
- `||y==="\r"||y===" "}function x(y){return y==='"'||y==="'"}function E(y){return y===">"||S(y)}function z(y,g){return y.test(g)}function C(y,g){return!z(y,g)}var v=0;e.STATE={BEGIN:v++,BEGIN_WHITESPACE:v++,TEXT:v++,TEXT_ENTITY:v++,OPEN_WAKA:v++,SGML_DECL:v++,SGML_DECL_QUOTED:v++,DOCTYPE:v++,DOCTYPE_QUOTED:v++,DOCTYPE_DTD:v++,DOCTYPE_DTD_QUOTED:v++,COMMENT_STARTING:v++,COMMENT:v++,COMMENT_ENDING:v++,COMMENT_ENDED:v++,CDATA:v++,CDATA_ENDING:v++,CDATA_ENDING_2:v++,PROC_INST:v++,PROC_INST_BODY:v++,PROC_INST_ENDING:v++,OPEN_TAG:v++,OPEN_TAG_SLASH:v++,ATTRIB:v++,ATTRIB_NAME:v++,ATTRIB_NAME_SAW_WHITE:v++,ATTRIB_VALUE:v++,ATTRIB_VALUE_QUOTED:v++,ATTRIB_VALUE_CLOSED:v++,ATTRIB_VALUE_UNQUOTED:v++,ATTRIB_VALUE_ENTITY_Q:v++,ATTRIB_VALUE_ENTITY_U:v++,CLOSE_TAG:v++,CLOSE_TAG_SAW_WHITE:v++,SCRIPT:v++,SCRIPT_ENDING:v++},e.XML_ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'"},e.ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'",AElig:198,Aacute:193,Acirc:194,Agrave:192,Aring:197,Atilde:195,Auml:196,Ccedil:199,ETH:208,Eacute:201,Ecirc:202,Egrave:200,Euml:203,Iacute:205,Icirc:206,Igrave:204,Iuml:207,Ntilde:209,Oacute:211,Ocirc:212,Ograve:210,Oslash:216,Otilde:213,Ouml:214,THORN:222,Uacute:218,Ucirc:219,Ugrave:217,Uuml:220,Yacute:221,aacute:225,acirc:226,aelig:230,agrave:224,aring:229,atilde:227,auml:228,ccedil:231,eacute:233,ecirc:234,egrave:232,eth:240,euml:235,iacute:237,icirc:238,igrave:236,iuml:239,ntilde:241,oacute:243,ocirc:244,ograve:242,oslash:248,otilde:245,ouml:246,szlig:223,thorn:254,uacute:250,ucirc:251,ugrave:249,uuml:252,yacute:253,yuml:255,copy:169,reg:174,nbsp:160,iexcl:161,cent:162,pound:163,curren:164,yen:165,brvbar:166,sect:167,uml:168,ordf:170,laquo:171,not:172,shy:173,macr:175,deg:176,plusmn:177,sup1:185,sup2:178,sup3:179,acute:180,micro:181,para:182,middot:183,cedil:184,ordm:186,raquo:187,frac14:188,frac12:189,frac34:190,iquest:191,times:215,divide:247,OElig:338,oelig:339,Scaron:352,scaron:353,Yuml:376,fnof:402,circ:710,tilde:732,Alpha:913,Beta:914,Gamma:915,Delta:916,Epsilon:917,Zeta:918,Eta:919,Theta:920,Iota:921,Kappa:922,Lambda:923,Mu:924,Nu:925,Xi:926,Omicron:927,Pi:928,Rho:929,Sigma:931,Tau:932,Upsilon:933,Phi:934,Chi:935,Psi:936,Omega:937,alpha:945,beta:946,gamma:947,delta:948,epsilon:949,zeta:950,eta:951,theta:952,iota:953,kappa:954,lambda:955,mu:956,nu:957,xi:958,omicron:959,pi:960,rho:961,sigmaf:962,sigma:963,tau:964,upsilon:965,phi:966,chi:967,psi:968,omega:969,thetasym:977,upsih:978,piv:982,ensp:8194,emsp:8195,thinsp:8201,zwnj:8204,zwj:8205,lrm:8206,rlm:8207,ndash:8211,mdash:8212,lsquo:8216,rsquo:8217,sbquo:8218,ldquo:8220,rdquo:8221,bdquo:8222,dagger:8224,Dagger:8225,bull:8226,hellip:8230,permil:8240,prime:8242,Prime:8243,lsaquo:8249,rsaquo:8250,oline:8254,frasl:8260,euro:8364,image:8465,weierp:8472,real:8476,trade:8482,alefsym:8501,larr:8592,uarr:8593,rarr:8594,darr:8595,harr:8596,crarr:8629,lArr:8656,uArr:8657,rArr:8658,dArr:8659,hArr:8660,forall:8704,part:8706,exist:8707,empty:8709,nabla:8711,isin:8712,notin:8713,ni:8715,prod:8719,sum:8721,minus:8722,lowast:8727,radic:8730,prop:8733,infin:8734,ang:8736,and:8743,or:8744,cap:8745,cup:8746,int:8747,there4:8756,sim:8764,cong:8773,asymp:8776,ne:8800,equiv:8801,le:8804,ge:8805,sub:8834,sup:8835,nsub:8836,sube:8838,supe:8839,oplus:8853,otimes:8855,perp:8869,sdot:8901,lceil:8968,rceil:8969,lfloor:8970,rfloor:8971,lang:9001,rang:9002,loz:9674,spades:9824,clubs:9827,hearts:9829,diams:9830},Object.keys(e.ENTITIES).forEach(function(y){var g=e.ENTITIES[y],P=typeof g=="number"?String.fromCharCode(g):g;e.ENTITIES[y]=P});for(var Z in e.STATE)e.STATE[e.STATE[Z]]=Z;v=e.STATE;function B(y,g,P){y[g]&&y[g](P)}function A(y,g,P){y.textNode&&L(y),B(y,g,P)}function L(y){y.textNode=G(y.opt,y.textNode),y.textNode&&B(y,"ontext",y.textNode),y.textNode=""}function G(y,g){return y.trim&&(g=g.trim()),y.normalize&&(g=g.replace(/\s+/g," ")),g}function Y(y,g){return L(y),y.trackPosition&&(g+=`
287
- Line: `+y.line+`
288
- Column: `+y.column+`
289
- Char: `+y.c),g=new Error(g),y.error=g,B(y,"onerror",g),y}function Ie(y){return y.sawRoot&&!y.closedRoot&&me(y,"Unclosed root tag"),y.state!==v.BEGIN&&y.state!==v.BEGIN_WHITESPACE&&y.state!==v.TEXT&&Y(y,"Unexpected end"),L(y),y.c="",y.closed=!0,B(y,"onend"),r.call(y,y.strict,y.opt),y}function me(y,g){if(typeof y!="object"||!(y instanceof r))throw new Error("bad call to strictFail");y.strict&&Y(y,g)}function En(y){y.strict||(y.tagName=y.tagName[y.looseCase]());var g=y.tags[y.tags.length-1]||y,P=y.tag={name:y.tagName,attributes:{}};y.opt.xmlns&&(P.ns=g.ns),y.attribList.length=0,A(y,"onopentagstart",P)}function Rr(y,g){var P=y.indexOf(":")<0?["",y]:y.split(":"),$=P[0],$e=P[1];return g&&y==="xmlns"&&($="xmlns",$e=""),{prefix:$,local:$e}}function Na(y){if(y.strict||(y.attribName=y.attribName[y.looseCase]()),y.attribList.indexOf(y.attribName)!==-1||y.tag.attributes.hasOwnProperty(y.attribName)){y.attribName=y.attribValue="";return}if(y.opt.xmlns){var g=Rr(y.attribName,!0),P=g.prefix,$=g.local;if(P==="xmlns")if($==="xml"&&y.attribValue!==f)me(y,"xml: prefix must be bound to "+f+`
290
- Actual: `+y.attribValue);else if($==="xmlns"&&y.attribValue!==p)me(y,"xmlns: prefix must be bound to "+p+`
291
- Actual: `+y.attribValue);else{var $e=y.tag,Me=y.tags[y.tags.length-1]||y;$e.ns===Me.ns&&($e.ns=Object.create(Me.ns)),$e.ns[$]=y.attribValue}y.attribList.push([y.attribName,y.attribValue])}else y.tag.attributes[y.attribName]=y.attribValue,A(y,"onattribute",{name:y.attribName,value:y.attribValue});y.attribName=y.attribValue=""}function Qr(y,g){if(y.opt.xmlns){var P=y.tag,$=Rr(y.tagName);P.prefix=$.prefix,P.local=$.local,P.uri=P.ns[$.prefix]||"",P.prefix&&!P.uri&&(me(y,"Unbound namespace prefix: "+JSON.stringify(y.tagName)),P.uri=$.prefix);var $e=y.tags[y.tags.length-1]||y;P.ns&&$e.ns!==P.ns&&Object.keys(P.ns).forEach(function(Ra){A(y,"onopennamespace",{prefix:Ra,uri:P.ns[Ra]})});for(var Me=0,mt=y.attribList.length;Me<mt;Me++){var st=y.attribList[Me],Rt=st[0],Mr=st[1],ct=Rr(Rt,!0),In=ct.prefix,Go=ct.local,ju=In===""?"":P.ns[In]||"",q={name:Rt,value:Mr,prefix:In,local:Go,uri:ju};In&&In!=="xmlns"&&!ju&&(me(y,"Unbound namespace prefix: "+JSON.stringify(In)),q.uri=In),y.tag.attributes[Rt]=q,A(y,"onattribute",q)}y.attribList.length=0}y.tag.isSelfClosing=!!g,y.sawRoot=!0,y.tags.push(y.tag),A(y,"onopentag",y.tag),g||(!y.noscript&&y.tagName.toLowerCase()==="script"?y.state=v.SCRIPT:y.state=v.TEXT,y.tag=null,y.tagName=""),y.attribName=y.attribValue="",y.attribList.length=0}function oi(y){if(!y.tagName){me(y,"Weird empty close tag."),y.textNode+="</>",y.state=v.TEXT;return}if(y.script){if(y.tagName!=="script"){y.script+="</"+y.tagName+">",y.tagName="",y.state=v.SCRIPT;return}A(y,"onscript",y.script),y.script=""}var g=y.tags.length,P=y.tagName;y.strict||(P=P[y.looseCase]());for(var $=P;g--&&y.tags[g].name!==$;)me(y,"Unexpected close tag");if(g<0){me(y,"Unmatched closing tag: "+y.tagName),y.textNode+="</"+y.tagName+">",y.state=v.TEXT;return}y.tagName=P;for(var $e=y.tags.length;$e-- >g;){var Me=y.tag=y.tags.pop();y.tagName=y.tag.name,A(y,"onclosetag",y.tagName);var mt={};for(var st in Me.ns)mt[st]=Me.ns[st];var Rt=y.tags[y.tags.length-1]||y;y.opt.xmlns&&Me.ns!==Rt.ns&&Object.keys(Me.ns).forEach(function(Mr){var ct=Me.ns[Mr];A(y,"onclosenamespace",{prefix:Mr,uri:ct})})}g===0&&(y.closedRoot=!0),y.tagName=y.attribValue=y.attribName="",y.attribList.length=0,y.state=v.TEXT}function Oc(y){var g=y.entity,P=g.toLowerCase(),$,$e="";return y.ENTITIES[g]?y.ENTITIES[g]:y.ENTITIES[P]?y.ENTITIES[P]:(g=P,g.charAt(0)==="#"&&(g.charAt(1)==="x"?(g=g.slice(2),$=parseInt(g,16),$e=$.toString(16)):(g=g.slice(1),$=parseInt(g,10),$e=$.toString(10))),g=g.replace(/^0+/,""),isNaN($)||$e.toLowerCase()!==g?(me(y,"Invalid character entity"),"&"+y.entity+";"):String.fromCodePoint($))}function Pc(y,g){g==="<"?(y.state=v.OPEN_WAKA,y.startTagPosition=y.position):S(g)||(me(y,"Non-whitespace before first tag."),y.textNode=g,y.state=v.TEXT)}function Nc(y,g){var P="";return g<y.length&&(P=y.charAt(g)),P}function en(y){var g=this;if(this.error)throw this.error;if(g.closed)return Y(g,"Cannot write after close. Assign an onready handler.");if(y===null)return Ie(g);typeof y=="object"&&(y=y.toString());for(var P=0,$="";$=Nc(y,P++),g.c=$,!!$;)switch(g.trackPosition&&(g.position++,$===`
292
- `?(g.line++,g.column=0):g.column++),g.state){case v.BEGIN:if(g.state=v.BEGIN_WHITESPACE,$==="\uFEFF")continue;Pc(g,$);continue;case v.BEGIN_WHITESPACE:Pc(g,$);continue;case v.TEXT:if(g.sawRoot&&!g.closedRoot){for(var $e=P-1;$&&$!=="<"&&$!=="&";)$=Nc(y,P++),$&&g.trackPosition&&(g.position++,$===`
293
- `?(g.line++,g.column=0):g.column++);g.textNode+=y.substring($e,P-1)}$==="<"&&!(g.sawRoot&&g.closedRoot&&!g.strict)?(g.state=v.OPEN_WAKA,g.startTagPosition=g.position):(!S($)&&(!g.sawRoot||g.closedRoot)&&me(g,"Text data outside of root node."),$==="&"?g.state=v.TEXT_ENTITY:g.textNode+=$);continue;case v.SCRIPT:$==="<"?g.state=v.SCRIPT_ENDING:g.script+=$;continue;case v.SCRIPT_ENDING:$==="/"?g.state=v.CLOSE_TAG:(g.script+="<"+$,g.state=v.SCRIPT);continue;case v.OPEN_WAKA:if($==="!")g.state=v.SGML_DECL,g.sgmlDecl="";else if(!S($))if(z(h,$))g.state=v.OPEN_TAG,g.tagName=$;else if($==="/")g.state=v.CLOSE_TAG,g.tagName="";else if($==="?")g.state=v.PROC_INST,g.procInstName=g.procInstBody="";else{if(me(g,"Unencoded <"),g.startTagPosition+1<g.position){var Me=g.position-g.startTagPosition;$=new Array(Me).join(" ")+$}g.textNode+="<"+$,g.state=v.TEXT}continue;case v.SGML_DECL:(g.sgmlDecl+$).toUpperCase()===u?(A(g,"onopencdata"),g.state=v.CDATA,g.sgmlDecl="",g.cdata=""):g.sgmlDecl+$==="--"?(g.state=v.COMMENT,g.comment="",g.sgmlDecl=""):(g.sgmlDecl+$).toUpperCase()===d?(g.state=v.DOCTYPE,(g.doctype||g.sawRoot)&&me(g,"Inappropriately located doctype declaration"),g.doctype="",g.sgmlDecl=""):$===">"?(A(g,"onsgmldeclaration",g.sgmlDecl),g.sgmlDecl="",g.state=v.TEXT):(x($)&&(g.state=v.SGML_DECL_QUOTED),g.sgmlDecl+=$);continue;case v.SGML_DECL_QUOTED:$===g.q&&(g.state=v.SGML_DECL,g.q=""),g.sgmlDecl+=$;continue;case v.DOCTYPE:$===">"?(g.state=v.TEXT,A(g,"ondoctype",g.doctype),g.doctype=!0):(g.doctype+=$,$==="["?g.state=v.DOCTYPE_DTD:x($)&&(g.state=v.DOCTYPE_QUOTED,g.q=$));continue;case v.DOCTYPE_QUOTED:g.doctype+=$,$===g.q&&(g.q="",g.state=v.DOCTYPE);continue;case v.DOCTYPE_DTD:g.doctype+=$,$==="]"?g.state=v.DOCTYPE:x($)&&(g.state=v.DOCTYPE_DTD_QUOTED,g.q=$);continue;case v.DOCTYPE_DTD_QUOTED:g.doctype+=$,$===g.q&&(g.state=v.DOCTYPE_DTD,g.q="");continue;case v.COMMENT:$==="-"?g.state=v.COMMENT_ENDING:g.comment+=$;continue;case v.COMMENT_ENDING:$==="-"?(g.state=v.COMMENT_ENDED,g.comment=G(g.opt,g.comment),g.comment&&A(g,"oncomment",g.comment),g.comment=""):(g.comment+="-"+$,g.state=v.COMMENT);continue;case v.COMMENT_ENDED:$!==">"?(me(g,"Malformed comment"),g.comment+="--"+$,g.state=v.COMMENT):g.state=v.TEXT;continue;case v.CDATA:$==="]"?g.state=v.CDATA_ENDING:g.cdata+=$;continue;case v.CDATA_ENDING:$==="]"?g.state=v.CDATA_ENDING_2:(g.cdata+="]"+$,g.state=v.CDATA);continue;case v.CDATA_ENDING_2:$===">"?(g.cdata&&A(g,"oncdata",g.cdata),A(g,"onclosecdata"),g.cdata="",g.state=v.TEXT):$==="]"?g.cdata+="]":(g.cdata+="]]"+$,g.state=v.CDATA);continue;case v.PROC_INST:$==="?"?g.state=v.PROC_INST_ENDING:S($)?g.state=v.PROC_INST_BODY:g.procInstName+=$;continue;case v.PROC_INST_BODY:if(!g.procInstBody&&S($))continue;$==="?"?g.state=v.PROC_INST_ENDING:g.procInstBody+=$;continue;case v.PROC_INST_ENDING:$===">"?(A(g,"onprocessinginstruction",{name:g.procInstName,body:g.procInstBody}),g.procInstName=g.procInstBody="",g.state=v.TEXT):(g.procInstBody+="?"+$,g.state=v.PROC_INST_BODY);continue;case v.OPEN_TAG:z(_,$)?g.tagName+=$:(En(g),$===">"?Qr(g):$==="/"?g.state=v.OPEN_TAG_SLASH:(S($)||me(g,"Invalid character in tag name"),g.state=v.ATTRIB));continue;case v.OPEN_TAG_SLASH:$===">"?(Qr(g,!0),oi(g)):(me(g,"Forward-slash in opening tag not followed by >"),g.state=v.ATTRIB);continue;case v.ATTRIB:if(S($))continue;$===">"?Qr(g):$==="/"?g.state=v.OPEN_TAG_SLASH:z(h,$)?(g.attribName=$,g.attribValue="",g.state=v.ATTRIB_NAME):me(g,"Invalid attribute name");continue;case v.ATTRIB_NAME:$==="="?g.state=v.ATTRIB_VALUE:$===">"?(me(g,"Attribute without value"),g.attribValue=g.attribName,Na(g),Qr(g)):S($)?g.state=v.ATTRIB_NAME_SAW_WHITE:z(_,$)?g.attribName+=$:me(g,"Invalid attribute name");continue;case v.ATTRIB_NAME_SAW_WHITE:if($==="=")g.state=v.ATTRIB_VALUE;else{if(S($))continue;me(g,"Attribute without value"),g.tag.attributes[g.attribName]="",g.attribValue="",A(g,"onattribute",{name:g.attribName,value:""}),g.attribName="",$===">"?Qr(g):z(h,$)?(g.attribName=$,g.state=v.ATTRIB_NAME):(me(g,"Invalid attribute name"),g.state=v.ATTRIB)}continue;case v.ATTRIB_VALUE:if(S($))continue;x($)?(g.q=$,g.state=v.ATTRIB_VALUE_QUOTED):(me(g,"Unquoted attribute value"),g.state=v.ATTRIB_VALUE_UNQUOTED,g.attribValue=$);continue;case v.ATTRIB_VALUE_QUOTED:if($!==g.q){$==="&"?g.state=v.ATTRIB_VALUE_ENTITY_Q:g.attribValue+=$;continue}Na(g),g.q="",g.state=v.ATTRIB_VALUE_CLOSED;continue;case v.ATTRIB_VALUE_CLOSED:S($)?g.state=v.ATTRIB:$===">"?Qr(g):$==="/"?g.state=v.OPEN_TAG_SLASH:z(h,$)?(me(g,"No whitespace between attributes"),g.attribName=$,g.attribValue="",g.state=v.ATTRIB_NAME):me(g,"Invalid attribute name");continue;case v.ATTRIB_VALUE_UNQUOTED:if(!E($)){$==="&"?g.state=v.ATTRIB_VALUE_ENTITY_U:g.attribValue+=$;continue}Na(g),$===">"?Qr(g):g.state=v.ATTRIB;continue;case v.CLOSE_TAG:if(g.tagName)$===">"?oi(g):z(_,$)?g.tagName+=$:g.script?(g.script+="</"+g.tagName,g.tagName="",g.state=v.SCRIPT):(S($)||me(g,"Invalid tagname in closing tag"),g.state=v.CLOSE_TAG_SAW_WHITE);else{if(S($))continue;C(h,$)?g.script?(g.script+="</"+$,g.state=v.SCRIPT):me(g,"Invalid tagname in closing tag."):g.tagName=$}continue;case v.CLOSE_TAG_SAW_WHITE:if(S($))continue;$===">"?oi(g):me(g,"Invalid characters in closing tag");continue;case v.TEXT_ENTITY:case v.ATTRIB_VALUE_ENTITY_Q:case v.ATTRIB_VALUE_ENTITY_U:var mt,st;switch(g.state){case v.TEXT_ENTITY:mt=v.TEXT,st="textNode";break;case v.ATTRIB_VALUE_ENTITY_Q:mt=v.ATTRIB_VALUE_QUOTED,st="attribValue";break;case v.ATTRIB_VALUE_ENTITY_U:mt=v.ATTRIB_VALUE_UNQUOTED,st="attribValue";break}if($===";")if(g.opt.unparsedEntities){var Rt=Oc(g);g.entity="",g.state=mt,g.write(Rt)}else g[st]+=Oc(g),g.entity="",g.state=mt;else z(g.entity.length?w:b,$)?g.entity+=$:(me(g,"Invalid character in entity name"),g[st]+="&"+g.entity+$,g.entity="",g.state=mt);continue;default:throw new Error(g,"Unknown state: "+g.state)}return g.position>=g.bufferCheckPosition&&i(g),g}return String.fromCodePoint||(function(){var y=String.fromCharCode,g=Math.floor,P=function(){var $=16384,$e=[],Me,mt,st=-1,Rt=arguments.length;if(!Rt)return"";for(var Mr="";++st<Rt;){var ct=Number(arguments[st]);if(!isFinite(ct)||ct<0||ct>1114111||g(ct)!==ct)throw RangeError("Invalid code point: "+ct);ct<=65535?$e.push(ct):(ct-=65536,Me=(ct>>10)+55296,mt=ct%1024+56320,$e.push(Me,mt)),(st+1===Rt||$e.length>$)&&(Mr+=y.apply(null,$e),$e.length=0)}return Mr};Object.defineProperty?Object.defineProperty(String,"fromCodePoint",{value:P,configurable:!0,writable:!0}):String.fromCodePoint=P})(),e},GO=hF();var Jp=`The output should be formatted as a XML file.
294
- 1. Output should conform to the tags below.
295
- 2. If tags are not given, make them on your own.
296
- 3. Remember to always open and close all the tags.
297
-
298
- As an example, for the tags ["foo", "bar", "baz"]:
299
- 1. String "<foo>
300
- <bar>
301
- <baz></baz>
302
- </bar>
303
- </foo>" is a well-formatted instance of the schema.
304
- 2. String "<foo>
305
- <bar>
306
- </foo>" is a badly-formatted instance.
307
- 3. String "<foo>
308
- <tag>
309
- </tag>
310
- </foo>" is a badly-formatted instance.
311
-
312
- Here are the output tags:
313
- \`\`\`
314
- {tags}
315
- \`\`\``,WO=class extends Xn{tags;constructor(e){super(e),this.tags=e?.tags}static lc_name(){return"XMLOutputParser"}lc_namespace=["langchain_core","output_parsers"];lc_serializable=!0;_diff(e,t){if(t)return e?ta(e,t):[{op:"replace",path:"",value:t}]}async parsePartialResult(e){return Kp(e[0].text)}async parse(e){return Kp(e)}getFormatInstructions(){return this.tags&&this.tags.length>0?Jp.replace("{tags}",this.tags?.join(", ")??""):Jp}},gF=e=>e.split(`
316
- `).map(t=>t.replace(/^\s+/,"")).join(`
317
- `).trim(),JO=e=>{if(Object.keys(e).length===0)return{};let t={};return e.children.length>0?(t[e.name]=e.children.map(JO),t):(t[e.name]=e.text??void 0,t)};function Kp(e){let t=gF(e),r=GO.parser(!0),i={},n=[];r.onopentag=s=>{let c={name:s.name,attributes:s.attributes,children:[],text:"",isSelfClosing:s.isSelfClosing};n.length>0?n[n.length-1].children.push(c):i=c,s.isSelfClosing||n.push(c)},r.onclosetag=()=>{if(n.length>0){let s=n.pop();n.length===0&&s&&(i=s)}},r.ontext=s=>{if(n.length>0){let c=n[n.length-1];c.text+=s}},r.onattribute=s=>{if(n.length>0){let c=n[n.length-1];c.attributes[s.name]=s.value}};let a=/```(xml)?(.*)```/s.exec(t),o=a?a[2]:t;return r.write(o).close(),i&&i.name==="?xml"&&(i=i.children[0]),JO(i)}var KO=T({AsymmetricStructuredOutputParser:()=>HO,BaseCumulativeTransformOutputParser:()=>Xn,BaseLLMOutputParser:()=>ec,BaseOutputParser:()=>mn,BaseTransformOutputParser:()=>Ei,BytesOutputParser:()=>UO,CommaSeparatedListOutputParser:()=>LO,CustomListOutputParser:()=>FO,JsonMarkdownStructuredOutputParser:()=>zw,JsonOutputParser:()=>Gp,ListOutputParser:()=>tc,MarkdownListOutputParser:()=>VO,NumberedListOutputParser:()=>BO,OutputParserException:()=>Ht,StandardSchemaOutputParser:()=>Wp,StringOutputParser:()=>ZO,StructuredOutputParser:()=>Zl,XMLOutputParser:()=>WO,XML_FORMAT_INSTRUCTIONS:()=>Jp,parseJsonMarkdown:()=>Va,parsePartialJson:()=>Mn,parseXMLMarkdown:()=>Kp});var qO=T({extendInteropZodObject:()=>_p,getInteropZodDefaultGetter:()=>yp,getInteropZodObjectShape:()=>vi,getSchemaDescription:()=>bi,interopParse:()=>ha,interopParseAsync:()=>ma,interopSafeParse:()=>AC,interopSafeParseAsync:()=>gp,interopZodObjectMakeFieldsOptional:()=>PC,interopZodObjectPartial:()=>ga,interopZodObjectPassthrough:()=>hp,interopZodObjectStrict:()=>Bs,interopZodTransformInputSchema:()=>vp,isInteropZodError:()=>bp,isInteropZodLiteral:()=>CC,isInteropZodObject:()=>Bt,isInteropZodSchema:()=>gr,isShapelessZodSchema:()=>OC,isSimpleStringZodSchema:()=>Vs,isZodArrayV4:()=>Pl,isZodLiteralV3:()=>rw,isZodLiteralV4:()=>nw,isZodNullableV4:()=>aw,isZodObjectV3:()=>Ol,isZodObjectV4:()=>Zr,isZodOptionalV4:()=>iw,isZodSchema:()=>TC,isZodSchemaV3:()=>at,isZodSchemaV4:()=>Ve});function Dw(e,t){if(e.function===void 0)return;let r;if(t?.partial)try{r=Mn(e.function.arguments??"{}")}catch{return}else try{r=JSON.parse(e.function.arguments)}catch(n){throw new Ht([`Function "${e.function.name}" arguments:`,"",e.function.arguments,"","are not valid JSON.",`Error: ${n.message}`].join(`
318
- `))}let i={name:e.function.name,args:r,type:"tool_call"};return t?.returnId&&(i.id=e.id),i}function XO(e){if(e.id===void 0)throw new Error('All OpenAI tool calls must have an "id" field.');return{id:e.id,type:"function",function:{name:e.name,arguments:JSON.stringify(e.args)}}}function YO(e,t){return{name:e.function?.name,args:e.function?.arguments,id:e.id,error:t,type:"invalid_tool_call"}}var Uw=class extends Xn{static lc_name(){return"JsonOutputToolsParser"}returnId=!1;lc_namespace=["langchain","output_parsers","openai_tools"];lc_serializable=!0;constructor(e){super(e),this.returnId=e?.returnId??this.returnId}_diff(){throw new Error("Not supported.")}async parse(){throw new Error("Not implemented.")}async parseResult(e){return await this.parsePartialResult(e,!1)}async parsePartialResult(e,t=!0){let r=e[0].message,i;if(is(r)&&r.tool_calls?.length?i=r.tool_calls.map(a=>{let{id:o,...s}=a;return this.returnId?{id:o,...s}:s}):r.additional_kwargs.tool_calls!==void 0&&(i=JSON.parse(JSON.stringify(r.additional_kwargs.tool_calls)).map(a=>Dw(a,{returnId:this.returnId,partial:t}))),!i)return[];let n=[];for(let a of i)if(a!==void 0){let o={type:a.name,args:a.args,id:a.id};n.push(o)}return n}},qp=class extends Uw{static lc_name(){return"JsonOutputKeyToolsParser"}lc_namespace=["langchain","output_parsers","openai_tools"];lc_serializable=!0;returnId=!1;keyName;returnSingle=!1;zodSchema;serializableSchema;constructor(e){super(e),this.keyName=e.keyName,this.returnSingle=e.returnSingle??this.returnSingle,"zodSchema"in e&&(this.zodSchema=e.zodSchema),"serializableSchema"in e&&(this.serializableSchema=e.serializableSchema)}async _validateResult(e){if(this.serializableSchema!==void 0){let r=await this.serializableSchema["~standard"].validate(e);if(r.issues)throw new Ht(`Failed to parse. Text: "${JSON.stringify(e,null,2)}". Error: ${JSON.stringify(r.issues)}`,JSON.stringify(e,null,2));return r.value}if(this.zodSchema===void 0)return e;let t=await gp(this.zodSchema,e);if(t.success)return t.data;throw new Ht(`Failed to parse. Text: "${JSON.stringify(e,null,2)}". Error: ${JSON.stringify(t.error?.issues)}`,JSON.stringify(e,null,2))}async parsePartialResult(e){let t=(await super.parsePartialResult(e)).filter(i=>i.type===this.keyName),r=t;if(t.length)return this.returnId||(r=t.map(i=>i.args)),this.returnSingle?r[0]:r}async parseResult(e){let t=(await super.parsePartialResult(e,!1)).filter(i=>i.type===this.keyName),r=t;if(t.length)return this.returnId||(r=t.map(i=>i.args)),this.returnSingle?this._validateResult(r[0]):await Promise.all(r.map(i=>this._validateResult(i)))}};var QO=T({assembleStructuredOutputPipeline:()=>Lw,createContentParser:()=>_F,createFunctionCallingParser:()=>yF});function _F(e){return gr(e)?Zl.fromZodSchema(e):ao(e)?Wp.fromSerializableSchema(e):new Gp}function yF(e,t,r){let i=r??qp;return gr(e)?new i({returnSingle:!0,keyName:t,zodSchema:e}):ao(e)?new i({returnSingle:!0,keyName:t,serializableSchema:e}):new i({returnSingle:!0,keyName:t})}function Lw(e,t,r,i){if(!r){let c=e.pipe(t);return i?c.withConfig({runName:i}):c}let n=$i.assign({parsed:(c,l)=>t.invoke(c.raw,l)}),a=$i.assign({parsed:()=>null}),o=n.withFallbacks({fallbacks:[a]}),s=Pr.from([{raw:e},o]);return i?s.withConfig({runName:i}):s}var tP=T({ChatModelStream:()=>xa,ReasoningContentStream:()=>iP,TextContentStream:()=>rP,ToolCallsStream:()=>nP,UsageMetadataStream:()=>aP}),vF=class{events=[];finished=!1;waiters=[];error=null;push(e){this.events.push(e);let t=this.waiters.splice(0);for(let r of t)r()}finish(){this.finished=!0;let e=this.waiters.splice(0);for(let t of e)t()}setError(e){this.error=e,this.finished=!0;let t=this.waiters.splice(0);for(let r of t)r()}async*iterate(){if(this.finished){if(this.error)throw this.error;yield*this.events;return}let e=0;for(;;){for(;e<this.events.length;)yield this.events[e],e++;if(this.finished){if(this.error)throw this.error;return}await new Promise(t=>{if(e<this.events.length||this.finished){t();return}this.waiters.push(t)})}}};function bF(e,t){switch(t.type){case"text-delta":return e.type==="text"?{...e,text:(e.text??"")+t.text}:e;case"reasoning-delta":return e.type==="thinking"?{...e,thinking:(e.thinking??"")+t.reasoning}:e.type==="reasoning"?{...e,reasoning:(e.reasoning??"")+t.reasoning}:e;case"data-delta":return{...e,data:(e.data??"")+t.data};case"block-delta":return{...e,...t.fields};default:throw new Error(`Unknown delta type: ${JSON.stringify(t)}`)}}function Hl(e){if(e.event!=="content-block-delta")return;if("delta"in e&&e.delta)return e.delta;let t=e.content;if(t==null||typeof t!="object")return;let r=t;if(r.type==="text"&&typeof r.text=="string")return{type:"text-delta",text:r.text};if(r.type==="reasoning"&&typeof r.reasoning=="string")return{type:"reasoning-delta",reasoning:r.reasoning};if(r.type==="thinking"&&typeof r.thinking=="string")return{type:"reasoning-delta",reasoning:r.thinking};if(typeof r.data=="string")return{type:"data-delta",data:r.data,encoding:"base64"};if(typeof r.type=="string")return{type:"block-delta",fields:{...r,type:r.type}}}function eP(e){if(e==null||typeof e!="object")return;let t=e;if(t.type==="reasoning"&&typeof t.reasoning=="string")return t.reasoning;if(t.type==="thinking"&&typeof t.thinking=="string")return t.thinking}function Xp(e){if(e==null||typeof e!="object")return!1;let t=e.type;return t==="reasoning"||t==="thinking"}function rc(e){if(e)return{...e,input_tokens:e.input_tokens??0,output_tokens:e.output_tokens??0,total_tokens:e.total_tokens??0}}function wF(e){if(e!=null&&typeof e=="object"&&!Array.isArray(e))return e;if(typeof e!="string"||e.length===0)return{};try{let t=JSON.parse(e);return t!=null&&typeof t=="object"&&!Array.isArray(t)?t:{}}catch{return{}}}function xF(e){let t=e;if(e.type==="tool_call"||e.type!=="tool_call_chunk"&&e.type!=="tool_use"&&e.type!=="input_json_delta")return e;let r=typeof t.name=="string"?t.name:void 0;if(r==null)return e;let i=t.args??t.input;return{...t,type:"tool_call",name:r,args:wF(i)}}var rP=class{_buffer;constructor(e){this._buffer=e}get full(){let e=this._buffer;return{async*[Symbol.asyncIterator](){let t="";for await(let r of e.iterate()){let i=Hl(r);i?.type==="text-delta"&&(t+=i.text,yield t)}}}}[Symbol.asyncIterator](){let e=this._buffer;async function*t(){for await(let r of e.iterate()){let i=Hl(r);i?.type==="text-delta"&&(yield i.text)}}return t()}then(e,t){return(async()=>{let r="";for await(let i of this)r+=i;return r})().then(e,t)}},nP=class{_buffer;constructor(e){this._buffer=e}get full(){let e=this._buffer;return{async*[Symbol.asyncIterator](){let t=[];for await(let r of e.iterate())r.event==="content-block-finish"&&r.content.type==="tool_call"&&(t.push(r.content),yield[...t])}}}[Symbol.asyncIterator](){let e=this._buffer;async function*t(){for await(let r of e.iterate())r.event==="content-block-finish"&&r.content.type==="tool_call"&&(yield r.content)}return t()}then(e,t){return(async()=>{let r=[];for await(let i of this)r.push(i);return r})().then(e,t)}},iP=class{_buffer;constructor(e){this._buffer=e}get full(){let e=this._buffer;return{async*[Symbol.asyncIterator](){let t="",r=!1;for await(let i of e.iterate())if(i.event==="content-block-start"){if(!Xp(i.content)){if(r)return;continue}r=!0;let n=eP(i.content);if(n==null||n.length===0)continue;t+=n,yield t}else if(i.event==="content-block-delta"){let n=Hl(i);if(n?.type!=="reasoning-delta")continue;r=!0;let a=n.reasoning;if(a==null||a.length===0)continue;t+=a,yield t}else{if(i.event==="content-block-finish"&&Xp(i.content))return;if(i.event==="message-finish")return}}}}[Symbol.asyncIterator](){let e=this._buffer;async function*t(){let r=!1;for await(let i of e.iterate())if(i.event==="content-block-start"){if(!Xp(i.content)){if(r)return;continue}r=!0;let n=eP(i.content);n!=null&&n.length>0&&(yield n)}else if(i.event==="content-block-delta"){let n=Hl(i);if(n?.type!=="reasoning-delta")continue;r=!0;let a=n.reasoning;a!=null&&a.length>0&&(yield a)}else{if(i.event==="content-block-finish"&&Xp(i.content))return;if(i.event==="message-finish")return}}return t()}then(e,t){return(async()=>{let r="";for await(let i of this)r+=i;return r})().then(e,t)}},aP=class{_buffer;constructor(e){this._buffer=e}[Symbol.asyncIterator](){let e=this._buffer;async function*t(){for await(let r of e.iterate())if(r.event==="usage"){let i=rc(r.usage);i&&(yield i)}else if(r.event==="message-start"&&r.usage){let i=rc(r.usage);i&&(yield i)}else if(r.event==="message-finish"&&r.usage){let i=rc(r.usage);i&&(yield i)}}return t()}then(e,t){return(async()=>{let r;for await(let i of this)r=i;return r})().then(e,t)}},xa=class{_buffer;constructor(e){this._buffer=new vF,this._consume(e)}async _consume(e){try{for await(let t of e)this._buffer.push(t);this._buffer.finish()}catch(t){this._buffer.setError(t instanceof Error?t:new Error(String(t)))}}[Symbol.asyncIterator](){return this._buffer.iterate()}get text(){return new rP(this._buffer)}get toolCalls(){return new nP(this._buffer)}get reasoning(){return new iP(this._buffer)}get usage(){return new aP(this._buffer)}get output(){return this._assembleMessage()}then(e,t){return this._assembleMessage().then(e,t)}async _assembleMessage(){let e=[],t,r,i={},n;for await(let o of this._buffer.iterate())switch(o.event){case"message-start":t=o.id??t,o.usage&&(r=rc(o.usage));break;case"content-block-start":e[o.index]=o.content;break;case"content-block-delta":{let s=e[o.index],c=Hl(o);s&&c&&(e[o.index]=bF(s,c));break}case"content-block-finish":e[o.index]=o.content;break;case"usage":r=rc(o.usage);break;case"message-finish":n=o.reason,o.usage&&(r=rc(o.usage)),o.responseMetadata&&(i={...i,...o.responseMetadata});break;default:break}let a=e.filter(o=>o!=null).map(xF);return new Ce({id:t,content:a,usage_metadata:r,response_metadata:{...i,...n?{finish_reason:n}:{},output_version:"v1"}})}};var sP=T({convertChunksToEvents:()=>Fw,finalizeContentBlock:()=>lP}),SF={wav:"audio/wav",mp3:"audio/mpeg",flac:"audio/flac",opus:"audio/opus",aac:"audio/aac",pcm16:"audio/pcm"},kF={png:"image/png",jpeg:"image/jpeg",jpg:"image/jpeg",webp:"image/webp",gif:"image/gif"};function oP(e){let t=0;for(let r of e.keys())r>=t&&(t=r+1);return t}function cP(e){let t=e.additional_kwargs;return t!=null&&typeof t=="object"?t:{}}function $F(e){let t=cP(e).tool_outputs;if(!Array.isArray(t))return[];let r=[];for(let i of t){if(i==null||typeof i!="object")continue;let n=i;if(n.type!=="image_generation_call")continue;let a=typeof n.result=="string"?n.result:void 0,o=typeof n.url=="string"?n.url:void 0;if(a==null&&o==null)continue;let s=typeof n.output_format=="string"?n.output_format.toLowerCase():void 0,c=(s!=null?kF[s]:void 0)??"image/png";r.push({type:"image",...typeof n.id=="string"?{id:n.id}:{},...o!=null?{url:o}:{},...a!=null?{data:a}:{},mimeType:c})}return r}function EF(e){let t=cP(e).audio;if(t==null||typeof t!="object")return;let r=t,i=typeof r.data=="string"?r.data:void 0,n=typeof r.url=="string"?r.url:void 0,a=typeof r.transcript=="string"?r.transcript:void 0;if(i==null&&n==null&&a==null)return;let o=typeof r.mime_type=="string"?r.mime_type:typeof r.mimeType=="string"?r.mimeType:void 0,s=typeof r.format=="string"?r.format.toLowerCase():void 0,c=o??(s!=null?SF[s]:void 0)??(i!=null?"audio/wav":"audio/pcm");return{...typeof r.id=="string"?{id:r.id}:{},...i!=null?{data:i}:{},...n!=null?{url:n}:{},...a!=null?{transcript:a}:{},mimeType:c}}async function*Fw(e,t){let r=new Map,i=!1,n,a,o=new Set;for await(let s of e){t?.signal?.throwIfAborted();let c=s.message,l=!1;if(!i){i=!0;let f={event:"message-start",id:c.id??void 0};Qe.isInstance(c)&&c.usage_metadata&&(f.usage=c.usage_metadata,n={...c.usage_metadata},l=!0),yield f}let u=c.content;if(typeof u=="string"){if(u!==""){if(!r.has(0)){let m={type:"text",text:""};r.set(0,{type:"text",accumulated:m}),yield{event:"content-block-start",index:0,content:m}}let p=r.get(0);p.accumulated={...p.accumulated,text:(p.accumulated.text??"")+u},yield{event:"content-block-delta",index:0,delta:{type:"text-delta",text:u}}}}else if(Array.isArray(u))for(let f of u){let p=typeof f.index=="number"?f.index:r.size;if(!r.has(p))r.set(p,{type:f.type,accumulated:{...f}}),yield{event:"content-block-start",index:p,content:{...f}};else{let m=r.get(p),h=TF(f);m.accumulated=IF(m.accumulated,h),yield{event:"content-block-delta",index:p,delta:h}}}if(Qe.isInstance(c)&&c.tool_call_chunks&&c.tool_call_chunks.length>0)for(let f of c.tool_call_chunks){let p=typeof f.index=="number"?f.index:r.size;if(!r.has(p)){let h={type:"tool_call_chunk",id:f.id,name:f.name,args:"",index:p};r.set(p,{type:"tool_call_chunk",accumulated:h}),yield{event:"content-block-start",index:p,content:h}}let m=r.get(p).accumulated;f.id!=null&&(m.id=f.id),f.name!=null&&(m.name=f.name),m.args=(m.args??"")+(f.args??""),yield{event:"content-block-delta",index:p,delta:{type:"block-delta",fields:{type:"tool_call_chunk",..."id"in m&&m.id!=null?{id:m.id}:{},..."name"in m&&m.name!=null?{name:m.name}:{},args:m.args}}}}let d=EF(c);if(d!=null){if(a==null){let p=oP(r);a={index:p,id:d.id,mimeType:d.mimeType,transcript:""};let m={type:"audio",...d.id!=null?{id:d.id}:{},...d.url!=null?{url:d.url}:{},data:"",mimeType:d.mimeType};r.set(p,{type:"audio",accumulated:m}),yield{event:"content-block-start",index:p,content:m}}let f=r.get(a.index);if(f!=null){let p=f.accumulated;d.id!=null&&a.id==null&&(a.id=d.id,p.id=d.id),d.transcript!=null&&(a.transcript+=d.transcript,p.transcript=a.transcript,yield{event:"content-block-delta",index:a.index,delta:{type:"block-delta",fields:{type:"audio",transcript:a.transcript}}}),d.data!=null&&d.data.length>0&&(p.data=(p.data??"")+d.data,yield{event:"content-block-delta",index:a.index,delta:{type:"data-delta",data:d.data,encoding:"base64"}})}}for(let f of $F(c)){let p=f,m=p.id??p.url??(p.data!=null?`${p.data.length}:${p.data.slice(0,32)}`:void 0);if(m!=null&&o.has(m))continue;m!=null&&o.add(m);let h=oP(r);r.set(h,{type:"image",accumulated:f}),yield{event:"content-block-start",index:h,content:f}}if(!l&&Qe.isInstance(c)&&c.usage_metadata){let f=c.usage_metadata;n?n={input_tokens:n.input_tokens+f.input_tokens,output_tokens:n.output_tokens+f.output_tokens,total_tokens:n.total_tokens+f.total_tokens}:n={...f},yield{event:"usage",usage:{...n}}}}for(let[s,c]of r)yield{event:"content-block-finish",index:s,content:lP(c.accumulated)};yield{event:"message-finish",reason:"stop",...n?{usage:n}:{}}}function IF(e,t){switch(t.type){case"text-delta":return e.type==="text"?{...e,text:(e.text??"")+t.text}:e;case"reasoning-delta":return e.type==="thinking"?{...e,thinking:(e.thinking??"")+t.reasoning}:e.type==="reasoning"?{...e,reasoning:(e.reasoning??"")+t.reasoning}:e;case"data-delta":return{...e,data:(e.data??"")+t.data};case"block-delta":return{...e,...t.fields};default:throw new Error(`Unknown delta type: ${JSON.stringify(t)}`)}}function TF(e){if(e.type==="text")return{type:"text-delta",text:e.text};if(e.type==="reasoning")return{type:"reasoning-delta",reasoning:e.reasoning};if(e.type==="thinking"&&typeof e.thinking=="string")return{type:"reasoning-delta",reasoning:e.thinking};if(typeof e.data=="string")return{type:"data-delta",data:e.data,encoding:"base64"};if(typeof e.type=="string")return{type:"block-delta",fields:{...e}};throw new Error(`Unsupported content block delta: ${JSON.stringify(e)}`)}function lP(e){if(e.type==="tool_call_chunk"){let t=e,r;try{r=JSON.parse(t.args??"{}")}catch{return{type:"invalid_tool_call",id:t.id,name:t.name,args:t.args,error:"Failed to parse tool call arguments as JSON"}}return{type:"tool_call",id:t.id,name:t.name,args:r}}return e}var uP=e=>e();function Gl(e){let t=e.constructor;return new t({...e,content:e.contentBlocks,response_metadata:{...e.response_metadata,output_version:"v1"}})}var dP=T({BaseChatModel:()=>Sa,SimpleChatModel:()=>CF});function Bw(e){let t=[];for(let r of e){let i=r;if(Array.isArray(r.content))for(let n=0;n<r.content.length;n++){let a=r.content[n];(Qo(a)||es(a))&&i===r&&(i=new r.constructor({...i,content:[...r.content.slice(0,n),cd(a),...r.content.slice(n+1)]}))}t.push(i)}return t}var Sa=class Yn extends Vl{lc_namespace=["langchain","chat_models",this._llmType()];disableStreaming=!1;outputVersion;get callKeys(){return[...super.callKeys,"outputVersion"]}constructor(t){super(t),this.outputVersion=uP(()=>{let r=t.outputVersion??Qt("LC_OUTPUT_VERSION");return r&&["v0","v1"].includes(r)?r:"v0"})}_separateRunnableConfigFromCallOptionsCompat(t){let[r,i]=super._separateRunnableConfigFromCallOptions(t);return i.signal=r.signal,[r,i]}async invoke(t,r){let i=Yn._convertInputToPromptValue(t);return(await this.generatePrompt([i],r,r?.callbacks)).generations[0][0].message}async*_streamResponseChunks(t,r,i){throw new Error("Not implemented.")}async*_streamChatModelEvents(t,r,i){yield*Fw(this._streamResponseChunks(t,r,i),{signal:r.signal})}streamV2(t,r){let i=Yn._convertInputToPromptValue(t).toChatMessages(),[,n]=this._separateRunnableConfigFromCallOptionsCompat(r);return new xa(this._streamChatModelEvents(i,n))}async*_streamIterator(t,r){if(this._streamResponseChunks===Yn.prototype._streamResponseChunks||this.disableStreaming)yield this.invoke(t,r);else{let i=Yn._convertInputToPromptValue(t).toChatMessages(),[n,a]=this._separateRunnableConfigFromCallOptionsCompat(r),o={...n.metadata,...this.getLsParamsWithDefaults(a)},s=this.invocationParams(a),c=await et.configure(n.callbacks,this.callbacks,n.tags,this.tags,o,this.metadata,{verbose:this.verbose,tracerInheritableMetadata:this._filterInvocationParamsForTracing(s)}),l={options:a,invocation_params:s,batch_size:1},u=a.outputVersion??this.outputVersion,d=await c?.handleChatModelStart(this.toJSON(),[Bw(i)],n.runId,void 0,l,void 0,void 0,n.runName),f,p;try{for await(let m of this._streamResponseChunks(i,a,d?.[0])){if(a.signal?.throwIfAborted(),m.message.id==null){let h=d?.at(0)?.runId;h!=null&&m.message._updateId(`run-${h}`)}m.message.response_metadata={...m.generationInfo,...m.message.response_metadata},u==="v1"?yield Gl(m.message):yield m.message,f?f=f.concat(m):f=m,Jc(m.message)&&m.message.usage_metadata!==void 0&&(p={tokenUsage:{promptTokens:m.message.usage_metadata.input_tokens,completionTokens:m.message.usage_metadata.output_tokens,totalTokens:m.message.usage_metadata.total_tokens}})}a.signal?.throwIfAborted()}catch(m){throw await Promise.all((d??[]).map(h=>h?.handleLLMError(m))),m}await Promise.all((d??[]).map(m=>m?.handleLLMEnd({generations:[[f]],llmOutput:p})))}}getLsParams(t){let r=this.getName().startsWith("Chat")?this.getName().replace("Chat",""):this.getName();return{ls_model_type:"chat",ls_stop:t.stop,ls_provider:r}}getLsParamsWithDefaults(t){return{...this.getLsParams(t),ls_integration:"langchain_chat_model"}}async _generateUncached(t,r,i,n){let a=t.map(p=>p.map(yt)),o;if(n!==void 0&&n.length===a.length)o=n;else{let p={...i.metadata,...this.getLsParamsWithDefaults(r)},m=this.invocationParams(r),h=await et.configure(i.callbacks,this.callbacks,i.tags,this.tags,p,this.metadata,{verbose:this.verbose,tracerInheritableMetadata:this._filterInvocationParamsForTracing(m)}),_={options:r,invocation_params:m,batch_size:1};o=await h?.handleChatModelStart(this.toJSON(),a.map(Bw),i.runId,void 0,_,void 0,void 0,i.runName)}let s=r.outputVersion??this.outputVersion,c=[],l=[],u=!!o?.[0].handlers.find(rg),d=!!o?.[0].handlers.find(qc);if(u&&!this.disableStreaming&&a.length===1&&(this._streamChatModelEvents!==Yn.prototype._streamChatModelEvents||this._streamResponseChunks!==Yn.prototype._streamResponseChunks))try{let p=!1,m=o?.[0],h=this._streamChatModelEvents(a[0],r),_=await new xa({async*[Symbol.asyncIterator](){for await(let S of h){r.signal?.throwIfAborted(),p=!0;let x=S.event==="message-start"&&S.id==null&&m?.runId!=null?{...S,id:`run-${m.runId}`}:S;await m?.handleChatModelStreamEvent(x),yield x}}});if(r.signal?.throwIfAborted(),!p)throw new Error("Received empty response from chat model call.");if(_.id==null){let S=o?.at(0)?.runId;S!=null&&_._updateId(`run-${S}`)}let b={text:_.text,message:_};c.push([b]);let w=_.usage_metadata!==void 0?{tokenUsage:{promptTokens:_.usage_metadata.input_tokens,completionTokens:_.usage_metadata.output_tokens,totalTokens:_.usage_metadata.total_tokens}}:void 0;await o?.[0].handleLLMEnd({generations:c,llmOutput:w})}catch(p){throw await o?.[0].handleLLMError(p),p}else if(d&&!this.disableStreaming&&a.length===1&&this._streamResponseChunks!==Yn.prototype._streamResponseChunks)try{let p=await this._streamResponseChunks(a[0],r,o?.[0]),m,h;for await(let _ of p){if(r.signal?.aborted){let b=m?.message;throw new od("Model invocation was aborted.",b)}if(_.message.id==null){let b=o?.at(0)?.runId;b!=null&&_.message._updateId(`run-${b}`)}m===void 0?m=_:m=Ir(m,_),Jc(_.message)&&_.message.usage_metadata!==void 0&&(h={tokenUsage:{promptTokens:_.message.usage_metadata.input_tokens,completionTokens:_.message.usage_metadata.output_tokens,totalTokens:_.message.usage_metadata.total_tokens}})}if(r.signal?.aborted){let _=m?.message;throw new od("Model invocation was aborted.",_)}if(m===void 0)throw new Error("Received empty response from chat model call.");s==="v1"&&(m.message=Gl(m.message)),c.push([m]),await o?.[0].handleLLMEnd({generations:c,llmOutput:h})}catch(p){throw await o?.[0].handleLLMError(p),p}else{let p=await Promise.allSettled(a.map(async(m,h)=>{let _=await this._generate(m,{...r,promptIndex:h},o?.[h]);if(s==="v1")for(let b of _.generations)b.message=Gl(b.message);return _}));await Promise.all(p.map(async(m,h)=>{if(m.status==="fulfilled"){let _=m.value;for(let b of _.generations){if(b.message.id==null){let w=o?.at(0)?.runId;w!=null&&b.message._updateId(`run-${w}`)}b.message.response_metadata={...b.generationInfo,...b.message.response_metadata}}return _.generations.length===1&&(_.generations[0].message.response_metadata={..._.llmOutput,..._.generations[0].message.response_metadata}),c[h]=_.generations,l[h]=_.llmOutput,o?.[h]?.handleLLMEnd({generations:[_.generations],llmOutput:_.llmOutput})}else return await o?.[h]?.handleLLMError(m.reason),Promise.reject(m.reason)}))}let f={generations:c,llmOutput:l.length?this._combineLLMOutput?.(...l):void 0};return Object.defineProperty(f,io,{value:o?{runIds:o?.map(p=>p.runId)}:void 0,configurable:!0}),f}async _generateCached({messages:t,cache:r,llmStringKey:i,parsedOptions:n,handledOptions:a}){let o=t.map(b=>b.map(yt)),s={...a.metadata,...this.getLsParamsWithDefaults(n)},c=this.invocationParams(n),l=await et.configure(a.callbacks,this.callbacks,a.tags,this.tags,s,this.metadata,{verbose:this.verbose,tracerInheritableMetadata:this._filterInvocationParamsForTracing(c)}),u={options:n,invocation_params:c,batch_size:1},d=await l?.handleChatModelStart(this.toJSON(),o.map(Bw),a.runId,void 0,u,void 0,void 0,a.runName),f=[],p=(await Promise.allSettled(o.map(async(b,w)=>{let S=Yn._convertInputToPromptValue(b).toString(),x=await r.lookup(S,i);return x==null&&f.push(w),x}))).map((b,w)=>({result:b,runManager:d?.[w]})).filter(({result:b})=>b.status==="fulfilled"&&b.value!=null||b.status==="rejected"),m=n.outputVersion??this.outputVersion,h=[];await Promise.all(p.map(async({result:b,runManager:w},S)=>{if(b.status==="fulfilled"){let x=b.value;return h[S]=x.map(E=>("message"in E&&qe(E.message)&&is(E.message)&&(E.message.usage_metadata={input_tokens:0,output_tokens:0,total_tokens:0},m==="v1"&&(E.message=Gl(E.message))),E.generationInfo={...E.generationInfo,tokenUsage:{}},E)),x.length&&await w?.handleLLMNewToken(x[0].text),w?.handleLLMEnd({generations:[x]},void 0,void 0,void 0,{cached:!0})}else return await w?.handleLLMError(b.reason,void 0,void 0,void 0,{cached:!0}),Promise.reject(b.reason)}));let _={generations:h,missingPromptIndices:f,startedRunManagers:d};return Object.defineProperty(_,io,{value:d?{runIds:d?.map(b=>b.runId)}:void 0,configurable:!0}),_}async generate(t,r,i){let n;Array.isArray(r)?n={stop:r}:n=r;let a=t.map(m=>m.map(yt)),[o,s]=this._separateRunnableConfigFromCallOptionsCompat(n);if(o.callbacks=o.callbacks??i,!this.cache)return this._generateUncached(a,s,o);let{cache:c}=this,l=this._getSerializedCacheKeyParametersForCall(s),{generations:u,missingPromptIndices:d,startedRunManagers:f}=await this._generateCached({messages:a,cache:c,llmStringKey:l,parsedOptions:s,handledOptions:o}),p={};if(d.length>0){let m=await this._generateUncached(d.map(h=>a[h]),s,o,f!==void 0?d.map(h=>f?.[h]):void 0);await Promise.all(m.generations.map(async(h,_)=>{let b=d[_];u[b]=h;let w=Yn._convertInputToPromptValue(a[b]).toString();return c.update(w,l,h)})),p=m.llmOutput??{}}return{generations:u,llmOutput:p}}invocationParams(t){return{}}_modelType(){return"base_chat_model"}async generatePrompt(t,r,i){let n=t.map(a=>a.toChatMessages());return this.generate(n,r,i)}withStructuredOutput(t,r){if(typeof this.bindTools!="function")throw new Error('Chat model must implement ".bindTools()" to use withStructuredOutput.');if(r?.strict)throw new Error('"strict" mode is not supported for this model by default.');let i=t,n=r?.name,a=bi(i)??"A function available to call.",o=r?.method,s=r?.includeRaw;if(o==="jsonMode")throw new Error('Base withStructuredOutput implementation only supports "functionCalling" as a method.');let c=n??"extract";!gr(i)&&!ao(i)&&"name"in i&&(c=i.name);let l=gr(i)||ao(i)?bt(i):i,u=[{type:"function",function:{name:c,description:a,parameters:l}}];return Lw(this.bindTools(u),Zt.from(d=>{if(!Qe.isInstance(d))throw new Error("Input is not an AIMessageChunk.");if(!d.tool_calls||d.tool_calls.length===0)throw new Error("No tool calls found in the response.");let f=d.tool_calls.find(p=>p.name===c);if(!f)throw new Error(`No tool call found with name ${c}.`);return f.args}),s,s?"StructuredOutputRunnable":"StructuredOutput")}},CF=class extends Sa{async _generate(e,t,r){let i=new Ce(await this._call(e,t,r));if(typeof i.content!="string")throw new Error("Cannot generate with a simple chat model when output is not a string.");return{generations:[{text:i.content,message:i}]}}};var fP=T({});var pP=T({BaseLLM:()=>mP,LLM:()=>Yp}),mP=class Wl extends Vl{lc_namespace=["langchain","llms",this._llmType()];async invoke(t,r){let i=Wl._convertInputToPromptValue(t);return(await this.generatePrompt([i],r,r?.callbacks)).generations[0][0].text}async*_streamResponseChunks(t,r,i){throw new Error("Not implemented.")}_separateRunnableConfigFromCallOptionsCompat(t){let[r,i]=super._separateRunnableConfigFromCallOptions(t);return i.signal=r.signal,[r,i]}async*_streamIterator(t,r){if(this._streamResponseChunks===Wl.prototype._streamResponseChunks)yield this.invoke(t,r);else{let i=Wl._convertInputToPromptValue(t),[n,a]=this._separateRunnableConfigFromCallOptionsCompat(r),o=this.invocationParams(a),s=await et.configure(n.callbacks,this.callbacks,n.tags,this.tags,n.metadata,this.metadata,{verbose:this.verbose,tracerInheritableMetadata:this._filterInvocationParamsForTracing(o)}),c={options:a,invocation_params:o,batch_size:1},l=await s?.handleLLMStart(this.toJSON(),[i.toString()],n.runId,void 0,c,void 0,void 0,n.runName),u=new mi({text:""});try{for await(let d of this._streamResponseChunks(i.toString(),a,l?.[0]))u?u=u.concat(d):u=d,typeof d.text=="string"&&(yield d.text)}catch(d){throw await Promise.all((l??[]).map(f=>f?.handleLLMError(d))),d}await Promise.all((l??[]).map(d=>d?.handleLLMEnd({generations:[[u]]})))}}async generatePrompt(t,r,i){let n=t.map(a=>a.toString());return this.generate(n,r,i)}invocationParams(t){return{}}_flattenLLMResult(t){let r=[];for(let i=0;i<t.generations.length;i+=1){let n=t.generations[i];if(i===0)r.push({generations:[n],llmOutput:t.llmOutput});else{let a=t.llmOutput?{...t.llmOutput,tokenUsage:{}}:void 0;r.push({generations:[n],llmOutput:a})}}return r}async _generateUncached(t,r,i,n){let a;if(n!==void 0&&n.length===t.length)a=n;else{let l=this.invocationParams(r),u=await et.configure(i.callbacks,this.callbacks,i.tags,this.tags,i.metadata,this.metadata,{verbose:this.verbose,tracerInheritableMetadata:this._filterInvocationParamsForTracing(l)}),d={options:r,invocation_params:l,batch_size:t.length};a=await u?.handleLLMStart(this.toJSON(),t,i.runId,void 0,d,void 0,void 0,i?.runName)}let o=!!a?.[0].handlers.find(qc),s;if(o&&t.length===1&&this._streamResponseChunks!==Wl.prototype._streamResponseChunks)try{let l=await this._streamResponseChunks(t[0],r,a?.[0]),u;for await(let d of l)u===void 0?u=d:u=Ir(u,d);if(u===void 0)throw new Error("Received empty response from chat model call.");s={generations:[[u]],llmOutput:{}},await a?.[0].handleLLMEnd(s)}catch(l){throw await a?.[0].handleLLMError(l),l}else{try{s=await this._generate(t,r,a?.[0])}catch(u){throw await Promise.all((a??[]).map(d=>d?.handleLLMError(u))),u}let l=this._flattenLLMResult(s);await Promise.all((a??[]).map((u,d)=>u?.handleLLMEnd(l[d])))}let c=a?.map(l=>l.runId)||void 0;return Object.defineProperty(s,io,{value:c?{runIds:c}:void 0,configurable:!0}),s}async _generateCached({prompts:t,cache:r,llmStringKey:i,parsedOptions:n,handledOptions:a,runId:o}){let s=this.invocationParams(n),c=await et.configure(a.callbacks,this.callbacks,a.tags,this.tags,a.metadata,this.metadata,{verbose:this.verbose,tracerInheritableMetadata:this._filterInvocationParamsForTracing(s)}),l={options:n,invocation_params:s,batch_size:t.length},u=await c?.handleLLMStart(this.toJSON(),t,o,void 0,l,void 0,void 0,a?.runName),d=[],f=(await Promise.allSettled(t.map(async(h,_)=>{let b=await r.lookup(h,i);return b==null&&d.push(_),b}))).map((h,_)=>({result:h,runManager:u?.[_]})).filter(({result:h})=>h.status==="fulfilled"&&h.value!=null||h.status==="rejected"),p=[];await Promise.all(f.map(async({result:h,runManager:_},b)=>{if(h.status==="fulfilled"){let w=h.value;return p[b]=w.map(S=>(S.generationInfo={...S.generationInfo,tokenUsage:{}},S)),w.length&&await _?.handleLLMNewToken(w[0].text),_?.handleLLMEnd({generations:[w]},void 0,void 0,void 0,{cached:!0})}else return await _?.handleLLMError(h.reason,void 0,void 0,void 0,{cached:!0}),Promise.reject(h.reason)}));let m={generations:p,missingPromptIndices:d,startedRunManagers:u};return Object.defineProperty(m,io,{value:u?{runIds:u?.map(h=>h.runId)}:void 0,configurable:!0}),m}async generate(t,r,i){if(!Array.isArray(t))throw new Error("Argument 'prompts' is expected to be a string[]");let n;Array.isArray(r)?n={stop:r}:n=r;let[a,o]=this._separateRunnableConfigFromCallOptionsCompat(n);if(a.callbacks=a.callbacks??i,!this.cache)return this._generateUncached(t,o,a);let{cache:s}=this,c=this._getSerializedCacheKeyParametersForCall(o),{generations:l,missingPromptIndices:u,startedRunManagers:d}=await this._generateCached({prompts:t,cache:s,llmStringKey:c,parsedOptions:o,handledOptions:a,runId:a.runId}),f={};if(u.length>0){let p=await this._generateUncached(u.map(m=>t[m]),o,a,d!==void 0?u.map(m=>d?.[m]):void 0);await Promise.all(p.generations.map(async(m,h)=>{let _=u[h];return l[_]=m,s.update(t[_],c,m)})),f=p.llmOutput??{}}return{generations:l,llmOutput:f}}_identifyingParams(){return{}}_modelType(){return"base_llm"}},Yp=class extends mP{async _generate(e,t,r){return{generations:await Promise.all(e.map((i,n)=>this._call(i,{...t,promptIndex:n},r).then(a=>[{text:a}])))}}};var hP=T({});var gP=T({BaseMemory:()=>AF,getInputValue:()=>OF,getOutputValue:()=>PF,getPromptInputKey:()=>NF}),AF=class{},_P=(e,t)=>{if(t!==void 0)return e[t];let r=Object.keys(e);if(r.length===1)return e[r[0]]},OF=(e,t)=>{let r=_P(e,t);if(!r)throw new Error(`input values have ${Object.keys(e).length} keys, you must specify an input key or pass only 1 key as input`);return r},PF=(e,t)=>{let r=_P(e,t);if(!r&&r!=="")throw new Error(`output values have ${Object.keys(e).length} keys, you must specify an output key or pass only 1 key as output`);return r};function NF(e,t){let r=Object.keys(e).filter(i=>!t.includes(i)&&i!=="stop");if(r.length!==1)throw new Error(`One input key expected, but got ${r.length}`);return r[0]}var Vw=class extends ec{static lc_name(){return"OutputFunctionsParser"}lc_namespace=["langchain","output_parsers","openai_functions"];lc_serializable=!0;argsOnly=!0;constructor(e){super(),this.argsOnly=e?.argsOnly??this.argsOnly}async parseResult(e){if("message"in e[0]){let t=e[0].message.additional_kwargs.function_call;if(!t)throw new Error(`No function_call in message ${JSON.stringify(e)}`);if(!t.arguments)throw new Error(`No arguments in function_call ${JSON.stringify(e)}`);return this.argsOnly?t.arguments:JSON.stringify(t)}else throw new Error(`No message in generations ${JSON.stringify(e)}`)}},Zw=class extends Xn{static lc_name(){return"JsonOutputFunctionsParser"}lc_namespace=["langchain","output_parsers","openai_functions"];lc_serializable=!0;outputParser;argsOnly=!0;constructor(e){super(e),this.argsOnly=e?.argsOnly??this.argsOnly,this.outputParser=new Vw(e)}_diff(e,t){if(t)return ta(e??{},t)}async parsePartialResult(e){let t=e[0];if(!t.message)return;let{message:r}=t,i=r.additional_kwargs.function_call;if(i)return this.argsOnly?Mn(i.arguments):{...i,arguments:Mn(i.arguments)}}async parseResult(e){let t=await this.outputParser.parseResult(e);if(!t)throw new Error(`No result from "OutputFunctionsParser" ${JSON.stringify(e)}`);return this.parse(t)}async parse(e){let t=JSON.parse(e);return this.argsOnly||(t.arguments=JSON.parse(t.arguments)),t}getFormatInstructions(){return""}},yP=class extends ec{static lc_name(){return"JsonKeyOutputFunctionsParser"}lc_namespace=["langchain","output_parsers","openai_functions"];lc_serializable=!0;outputParser=new Zw;attrName;get lc_aliases(){return{attrName:"key_name"}}constructor(e){super(e),this.attrName=e.attrName}async parseResult(e){return(await this.outputParser.parseResult(e))[this.attrName]}};var vP=T({JsonKeyOutputFunctionsParser:()=>yP,JsonOutputFunctionsParser:()=>Zw,OutputFunctionsParser:()=>Vw});var bP=T({JsonOutputKeyToolsParser:()=>qp,JsonOutputToolsParser:()=>Uw,convertLangChainToolCallToOpenAI:()=>XO,makeInvalidToolCall:()=>YO,parseToolCall:()=>Dw});var Qn=class extends ae{lc_serializable=!0;lc_namespace=["langchain_core","prompts",this._getPromptType()];get lc_attributes(){return{partialVariables:void 0}}inputVariables;outputParser;partialVariables;metadata;tags;constructor(e){super(e);let{inputVariables:t}=e;if(t.includes("stop"))throw new Error("Cannot have an input variable named 'stop', as it is used internally, please rename.");Object.assign(this,e)}async mergePartialAndUserVariables(e){let t=this.partialVariables??{},r={};for(let[i,n]of Object.entries(t))typeof n=="string"?r[i]=n:r[i]=await n();return{...r,...e}}async invoke(e,t){let r={...this.metadata,...t?.metadata},i=[...this.tags??[],...t?.tags??[]];return this._callWithConfig(n=>this.formatPromptValue(n),e,{...t,tags:i,metadata:r,runType:"prompt"})}};var Ii=class extends Qn{async formatPromptValue(e){return new Fl(await this.format(e))}};var RF=Object.prototype.toString,ic=Array.isArray||function(t){return RF.call(t)==="[object Array]"};function Gw(e){return typeof e=="function"}function MF(e){return ic(e)?"array":typeof e}function Hw(e){return e.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function wP(e,t){return e!=null&&typeof e=="object"&&t in e}function jF(e,t){return e!=null&&typeof e!="object"&&e.hasOwnProperty&&e.hasOwnProperty(t)}var zF=RegExp.prototype.test;function DF(e,t){return zF.call(e,t)}var UF=/\S/;function LF(e){return!DF(UF,e)}var FF={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"};function BF(e){return String(e).replace(/[&<>"'`=\/]/g,function(r){return FF[r]})}var VF=/\s*/,ZF=/\s+/,xP=/\s*=/,HF=/\s*\}/,GF=/#|\^|\/|>|\{|&|=|!/;function WF(e,t){if(!e)return[];var r=!1,i=[],n=[],a=[],o=!1,s=!1,c="",l=0;function u(){if(o&&!s)for(;a.length;)delete n[a.pop()];else a=[];o=!1,s=!1}var d,f,p;function m(v){if(typeof v=="string"&&(v=v.split(ZF,2)),!ic(v)||v.length!==2)throw new Error("Invalid tags: "+v);d=new RegExp(Hw(v[0])+"\\s*"),f=new RegExp("\\s*"+Hw(v[1])),p=new RegExp("\\s*"+Hw("}"+v[1]))}m(t||qr.tags);for(var h=new Kl(e),_,b,w,S,x,E;!h.eos();){if(_=h.pos,w=h.scanUntil(d),w)for(var z=0,C=w.length;z<C;++z)S=w.charAt(z),LF(S)?(a.push(n.length),c+=S):(s=!0,r=!0,c+=" "),n.push(["text",S,_,_+1]),_+=1,S===`
319
- `&&(u(),c="",l=0,r=!1);if(!h.scan(d))break;if(o=!0,b=h.scan(GF)||"name",h.scan(VF),b==="="?(w=h.scanUntil(xP),h.scan(xP),h.scanUntil(f)):b==="{"?(w=h.scanUntil(p),h.scan(HF),h.scanUntil(f),b="&"):w=h.scanUntil(f),!h.scan(f))throw new Error("Unclosed tag at "+h.pos);if(b==">"?x=[b,w,_,h.pos,c,l,r]:x=[b,w,_,h.pos],l++,n.push(x),b==="#"||b==="^")i.push(x);else if(b==="/"){if(E=i.pop(),!E)throw new Error('Unopened section "'+w+'" at '+_);if(E[1]!==w)throw new Error('Unclosed section "'+E[1]+'" at '+_)}else b==="name"||b==="{"||b==="&"?s=!0:b==="="&&m(w)}if(u(),E=i.pop(),E)throw new Error('Unclosed section "'+E[1]+'" at '+h.pos);return KF(JF(n))}function JF(e){for(var t=[],r,i,n=0,a=e.length;n<a;++n)r=e[n],r&&(r[0]==="text"&&i&&i[0]==="text"?(i[1]+=r[1],i[3]=r[3]):(t.push(r),i=r));return t}function KF(e){for(var t=[],r=t,i=[],n,a,o=0,s=e.length;o<s;++o)switch(n=e[o],n[0]){case"#":case"^":r.push(n),i.push(n),r=n[4]=[];break;case"/":a=i.pop(),a[5]=n[2],r=i.length>0?i[i.length-1][4]:t;break;default:r.push(n)}return t}function Kl(e){this.string=e,this.tail=e,this.pos=0}Kl.prototype.eos=function(){return this.tail===""};Kl.prototype.scan=function(t){var r=this.tail.match(t);if(!r||r.index!==0)return"";var i=r[0];return this.tail=this.tail.substring(i.length),this.pos+=i.length,i};Kl.prototype.scanUntil=function(t){var r=this.tail.search(t),i;switch(r){case-1:i=this.tail,this.tail="";break;case 0:i="";break;default:i=this.tail.substring(0,r),this.tail=this.tail.substring(r)}return this.pos+=i.length,i};function nc(e,t){this.view=e,this.cache={".":this.view},this.parent=t}nc.prototype.push=function(t){return new nc(t,this)};nc.prototype.lookup=function(t){var r=this.cache,i;if(r.hasOwnProperty(t))i=r[t];else{for(var n=this,a,o,s,c=!1;n;){if(t.indexOf(".")>0)for(a=n.view,o=t.split("."),s=0;a!=null&&s<o.length;)s===o.length-1&&(c=wP(a,o[s])||jF(a,o[s])),a=a[o[s++]];else a=n.view[t],c=wP(n.view,t);if(c){i=a;break}n=n.parent}r[t]=i}return Gw(i)&&(i=i.call(this.view)),i};function cr(){this.templateCache={_cache:{},set:function(t,r){this._cache[t]=r},get:function(t){return this._cache[t]},clear:function(){this._cache={}}}}cr.prototype.clearCache=function(){typeof this.templateCache<"u"&&this.templateCache.clear()};cr.prototype.parse=function(t,r){var i=this.templateCache,n=t+":"+(r||qr.tags).join(":"),a=typeof i<"u",o=a?i.get(n):void 0;return o==null&&(o=WF(t,r),a&&i.set(n,o)),o};cr.prototype.render=function(t,r,i,n){var a=this.getConfigTags(n),o=this.parse(t,a),s=r instanceof nc?r:new nc(r,void 0);return this.renderTokens(o,s,i,t,n)};cr.prototype.renderTokens=function(t,r,i,n,a){for(var o="",s,c,l,u=0,d=t.length;u<d;++u)l=void 0,s=t[u],c=s[0],c==="#"?l=this.renderSection(s,r,i,n,a):c==="^"?l=this.renderInverted(s,r,i,n,a):c===">"?l=this.renderPartial(s,r,i,a):c==="&"?l=this.unescapedValue(s,r):c==="name"?l=this.escapedValue(s,r,a):c==="text"&&(l=this.rawValue(s)),l!==void 0&&(o+=l);return o};cr.prototype.renderSection=function(t,r,i,n,a){var o=this,s="",c=r.lookup(t[1]);function l(f){return o.render(f,r,i,a)}if(c){if(ic(c))for(var u=0,d=c.length;u<d;++u)s+=this.renderTokens(t[4],r.push(c[u]),i,n,a);else if(typeof c=="object"||typeof c=="string"||typeof c=="number")s+=this.renderTokens(t[4],r.push(c),i,n,a);else if(Gw(c)){if(typeof n!="string")throw new Error("Cannot use higher-order sections without the original template");c=c.call(r.view,n.slice(t[3],t[5]),l),c!=null&&(s+=c)}else s+=this.renderTokens(t[4],r,i,n,a);return s}};cr.prototype.renderInverted=function(t,r,i,n,a){var o=r.lookup(t[1]);if(!o||ic(o)&&o.length===0)return this.renderTokens(t[4],r,i,n,a)};cr.prototype.indentPartial=function(t,r,i){for(var n=r.replace(/[^ \t]/g,""),a=t.split(`
320
- `),o=0;o<a.length;o++)a[o].length&&(o>0||!i)&&(a[o]=n+a[o]);return a.join(`
321
- `)};cr.prototype.renderPartial=function(t,r,i,n){if(i){var a=this.getConfigTags(n),o=Gw(i)?i(t[1]):i[t[1]];if(o!=null){var s=t[6],c=t[5],l=t[4],u=o;c==0&&l&&(u=this.indentPartial(o,l,s));var d=this.parse(u,a);return this.renderTokens(d,r,i,u,n)}}};cr.prototype.unescapedValue=function(t,r){var i=r.lookup(t[1]);if(i!=null)return i};cr.prototype.escapedValue=function(t,r,i){var n=this.getConfigEscape(i)||qr.escape,a=r.lookup(t[1]);if(a!=null)return typeof a=="number"&&n===qr.escape?String(a):n(a)};cr.prototype.rawValue=function(t){return t[1]};cr.prototype.getConfigTags=function(t){return ic(t)?t:t&&typeof t=="object"?t.tags:void 0};cr.prototype.getConfigEscape=function(t){if(t&&typeof t=="object"&&!ic(t))return t.escape};var qr={name:"mustache.js",version:"4.2.0",tags:["{{","}}"],clearCache:void 0,escape:void 0,parse:void 0,render:void 0,Scanner:void 0,Context:void 0,Writer:void 0,set templateCache(e){Jl.templateCache=e},get templateCache(){return Jl.templateCache}},Jl=new cr;qr.clearCache=function(){return Jl.clearCache()};qr.parse=function(t,r){return Jl.parse(t,r)};qr.render=function(t,r,i,n){if(typeof t!="string")throw new TypeError('Invalid template! Template should be a "string" but "'+MF(t)+'" was given as the first argument for mustache#render(template, view, partials)');return Jl.render(t,r,i,n)};qr.escape=BF;qr.Scanner=Kl;qr.Context=nc;qr.Writer=cr;var Qp=qr;function SP(){Qp.escape=e=>e}var jo=e=>{let t=e.split(""),r=[],i=(a,o)=>{for(let s=o;s<t.length;s+=1)if(a.includes(t[s]))return s;return-1},n=0;for(;n<t.length;)if(t[n]==="{"&&n+1<t.length&&t[n+1]==="{")r.push({type:"literal",text:"{"}),n+=2;else if(t[n]==="}"&&n+1<t.length&&t[n+1]==="}")r.push({type:"literal",text:"}"}),n+=2;else if(t[n]==="{"){let a=i("}",n);if(a<0)throw new Error("Unclosed '{' in template.");r.push({type:"variable",name:t.slice(n+1,a).join("")}),n=a+1}else{if(t[n]==="}")throw new Error("Single '}' in template.");{let a=i("{}",n),o=(a<0?t.slice(n):t.slice(n,a)).join("");r.push({type:"literal",text:o}),n=a<0?t.length:a}}return r},kP=(e,t=[])=>{let r=[];for(let i of e)if(i[0]==="name"){let n=i[1].includes(".")?i[1].split(".")[0]:i[1];r.push({type:"variable",name:n})}else if(["#","&","^",">"].includes(i[0])){if(r.push({type:"variable",name:i[1]}),i[0]==="#"&&i.length>4&&Array.isArray(i[4])){let n=[...t,i[1]],a=kP(i[4],n);r.push(...a)}}else r.push({type:"literal",text:i[1]});return r},ac=e=>(SP(),kP(Qp.parse(e))),Ww=(e,t)=>jo(e).reduce((r,i)=>{if(i.type==="variable"){if(i.name in t)return r+(typeof t[i.name]=="string"?t[i.name]:JSON.stringify(t[i.name]));throw new Error(`(f-string) Missing value for input ${i.name}`)}return r+i.text},""),Jw=(e,t)=>(SP(),Qp.render(e,t)),ql={"f-string":Ww,mustache:Jw},Kw={"f-string":jo,mustache:ac},Gt=(e,t,r)=>{try{return ql[t](e,r)}catch(i){throw ui(i,"INVALID_PROMPT_INPUT")}},zo=(e,t)=>Kw[t](e),Ti=(e,t,r)=>{if(!(t in ql))throw new Error(`Invalid template format. Got \`${t}\`;
322
- should be one of ${Object.keys(ql)}`);try{let i=Object.fromEntries(r.map(n=>[n,"foo"]));Array.isArray(e)?e.forEach(n=>{if(n.type==="text"&&"text"in n&&typeof n.text=="string")Gt(n.text,t,i);else if(n.type==="image_url"){if(typeof n.image_url=="string")Gt(n.image_url,t,i);else if(typeof n.image_url=="object"&&n.image_url!==null&&"url"in n.image_url&&typeof n.image_url.url=="string"){let a=n.image_url.url;Gt(a,t,i)}}else throw new Error(`Invalid message template received. ${JSON.stringify(n,null,2)}`)}):Gt(e,t,i)}catch(i){throw new Error(`Invalid prompt schema: ${i.message}`)}};var hn=class Xl extends Ii{static lc_name(){return"PromptTemplate"}template;templateFormat="f-string";validateTemplate=!0;additionalContentFields;constructor(t){if(super(t),t.templateFormat==="mustache"&&t.validateTemplate===void 0&&(this.validateTemplate=!1),Object.assign(this,t),this.validateTemplate){if(this.templateFormat==="mustache")throw new Error("Mustache templates cannot be validated.");let r=this.inputVariables;this.partialVariables&&(r=r.concat(Object.keys(this.partialVariables))),Ti(this.template,this.templateFormat,r)}}_getPromptType(){return"prompt"}async format(t){let r=await this.mergePartialAndUserVariables(t);return Gt(this.template,this.templateFormat,r)}static fromExamples(t,r,i,n=`
323
-
324
- `,a=""){return new Xl({inputVariables:i,template:[a,...t,r].join(n)})}static fromTemplate(t,r){let{templateFormat:i="f-string",...n}=r??{},a=new Set;return zo(t,i).forEach(o=>{o.type==="variable"&&a.add(o.name)}),new Xl({inputVariables:[...a],templateFormat:i,template:t,...n})}async partial(t){let r=this.inputVariables.filter(n=>!(n in t)),i={...this.partialVariables??{},...t};return new Xl({...this,inputVariables:r,partialVariables:i})}serialize(){if(this.outputParser!==void 0)throw new Error("Cannot serialize a prompt template with an output parser");return{_type:this._getPromptType(),input_variables:this.inputVariables,template:this.template,template_format:this.templateFormat}}static async deserialize(t){if(!t.template)throw new Error("Prompt template must have a template");return new Xl({inputVariables:t.input_variables,template:t.template,templateFormat:t.template_format})}};var oc=class $P extends Qn{static lc_name(){return"ImagePromptTemplate"}lc_namespace=["langchain_core","prompts","image"];template;templateFormat="f-string";validateTemplate=!0;additionalContentFields;constructor(t){if(super(t),this.template=t.template,this.templateFormat=t.templateFormat??this.templateFormat,this.validateTemplate=t.validateTemplate??this.validateTemplate,this.additionalContentFields=t.additionalContentFields,this.validateTemplate){let r=this.inputVariables;this.partialVariables&&(r=r.concat(Object.keys(this.partialVariables))),Ti([{type:"image_url",image_url:this.template}],this.templateFormat,r)}}_getPromptType(){return"prompt"}async partial(t){let r=this.inputVariables.filter(n=>!(n in t)),i={...this.partialVariables??{},...t};return new $P({...this,inputVariables:r,partialVariables:i})}async format(t){let r={};for(let[o,s]of Object.entries(this.template))typeof s=="string"?r[o]=Gt(s,this.templateFormat,t):r[o]=s;let i=t.url||r.url,n=t.detail||r.detail;if(!i)throw new Error("Must provide either an image URL.");if(typeof i!="string")throw new Error("url must be a string.");let a={url:i};return n&&(a.detail=n),a}async formatPromptValue(t){return new Nw(await this.format(t))}};var Yl=class extends ae{lc_namespace=["langchain_core","prompts","dict"];lc_serializable=!0;template;templateFormat;inputVariables;static lc_name(){return"DictPromptTemplate"}constructor(e){let t=e.templateFormat??"f-string",r=qw(e.template,t);super({inputVariables:r,...e}),this.template=e.template,this.templateFormat=t,this.inputVariables=r}async format(e){return Xw(this.template,e,this.templateFormat)}async invoke(e){return await this._callWithConfig(this.format.bind(this),e,{runType:"prompt"})}};function qw(e,t){let r=[];for(let i of Object.values(e))if(typeof i=="string")zo(i,t).forEach(n=>{n.type==="variable"&&r.push(n.name)});else if(Array.isArray(i))for(let n of i)typeof n=="string"?zo(n,t).forEach(a=>{a.type==="variable"&&r.push(a.name)}):typeof n=="object"&&r.push(...qw(n,t));else typeof i=="object"&&i!==null&&r.push(...qw(i,t));return Array.from(new Set(r))}function Xw(e,t,r){let i={};for(let[n,a]of Object.entries(e))if(typeof a=="string")i[n]=Gt(a,r,t);else if(Array.isArray(a)){let o=[];for(let s of a)typeof s=="string"?o.push(Gt(s,r,t)):typeof s=="object"&&o.push(Xw(s,t,r));i[n]=o}else typeof a=="object"&&a!==null?i[n]=Xw(a,t,r):i[n]=a;return i}var Ql=class extends ae{lc_namespace=["langchain_core","prompts","chat"];lc_serializable=!0;async invoke(e,t){return this._callWithConfig(r=>this.formatMessages(r),e,{...t,runType:"prompt"})}},tm=class extends Ql{static lc_name(){return"MessagesPlaceholder"}variableName;optional;constructor(e){typeof e=="string"&&(e={variableName:e}),super(e),this.variableName=e.variableName,this.optional=e.optional??!1}get inputVariables(){return[this.variableName]}async formatMessages(e){let t=e[this.variableName];if(this.optional&&!t)return[];if(!t){let i=new Error(`Field "${this.variableName}" in prompt uses a MessagesPlaceholder, which expects an array of BaseMessages as an input value. Received: undefined`);throw i.name="InputFormatError",i}let r;try{Array.isArray(t)?r=t.map(yt):r=[yt(t)]}catch(i){let n=typeof t=="string"?t:JSON.stringify(t,null,2),a=new Error([`Field "${this.variableName}" in prompt uses a MessagesPlaceholder, which expects an array of BaseMessages or coerceable values as input.`,`Received value: ${n}`,`Additional message: ${i.message}`].join(`
325
-
326
- `));throw a.name="InputFormatError",a.lc_error_code=i.lc_error_code,a}return r}},Yw=class extends Ql{prompt;constructor(e){"prompt"in e||(e={prompt:e}),super(e),this.prompt=e.prompt}get inputVariables(){return this.prompt.inputVariables}async formatMessages(e){return[await this.format(e)]}},eu=class extends Qn{constructor(e){super(e)}async format(e){return(await this.formatPromptValue(e)).toString()}async formatPromptValue(e){return new Bl(await this.formatMessages(e))}},Qw=class extends Yw{static lc_name(){return"ChatMessagePromptTemplate"}role;constructor(e,t){"prompt"in e||(e={prompt:e,role:t}),super(e),this.role=e.role}async format(e){return new an(await this.prompt.format(e),this.role)}static fromTemplate(e,t,r){return new this(hn.fromTemplate(e,{templateFormat:r?.templateFormat}),t)}};function qF(e){return e===null||typeof e!="object"||Array.isArray(e)?!1:Object.keys(e).length===1&&"text"in e&&typeof e.text=="string"}function XF(e){return e===null||typeof e!="object"||Array.isArray(e)?!1:"image_url"in e&&(typeof e.image_url=="string"||typeof e.image_url=="object"&&e.image_url!==null&&"url"in e.image_url&&typeof e.image_url.url=="string")}var ex=class extends Ql{lc_namespace=["langchain_core","prompts","chat"];lc_serializable=!0;inputVariables=[];additionalOptions={};prompt;messageClass;static _messageClass(){throw new Error("Can not invoke _messageClass from inside _StringImageMessagePromptTemplate")}chatMessageClass;constructor(e,t){if("prompt"in e||(e={prompt:e}),super(e),this.prompt=e.prompt,Array.isArray(this.prompt)){let r=[];this.prompt.forEach(i=>{"inputVariables"in i&&(r=r.concat(i.inputVariables))}),this.inputVariables=r}else this.inputVariables=this.prompt.inputVariables;this.additionalOptions=t??this.additionalOptions}createMessage(e){let t=this.constructor;if(t._messageClass())return new(t._messageClass())({content:e});if(t.chatMessageClass){let r=t.chatMessageClass();return new r({content:e,role:this.getRoleFromMessageClass(r.lc_name())})}else throw new Error("No message class defined")}getRoleFromMessageClass(e){switch(e){case"HumanMessage":return"human";case"AIMessage":return"ai";case"SystemMessage":return"system";case"ChatMessage":return"chat";default:throw new Error("Invalid message class name")}}static fromTemplate(e,t){if(typeof e=="string")return new this(hn.fromTemplate(e,t));let r=[];for(let i of e)if(typeof i=="string")r.push(hn.fromTemplate(i,t));else if(i!==null)if(qF(i)){let n="";typeof i.text=="string"&&(n=i.text??"");let a={...t,additionalContentFields:i};r.push(hn.fromTemplate(n,a))}else if(XF(i)){let n=i.image_url??"",a,o=[];if(typeof n=="string"){let s;t?.templateFormat==="mustache"?s=ac(n):s=jo(n);let c=s.flatMap(l=>l.type==="variable"?[l.name]:[]);if((c?.length??0)>0){if(c.length>1)throw new Error(`Only one format variable allowed per image template.
327
- Got: ${c}
328
- From: ${n}`);o=[c[0]]}else o=[];n={url:n},a=new oc({template:n,inputVariables:o,templateFormat:t?.templateFormat,additionalContentFields:i})}else if(typeof n=="object"){if("url"in n){let s;t?.templateFormat==="mustache"?s=ac(n.url):s=jo(n.url),o=s.flatMap(c=>c.type==="variable"?[c.name]:[])}else o=[];a=new oc({template:n,inputVariables:o,templateFormat:t?.templateFormat,additionalContentFields:i})}else throw new Error("Invalid image template");r.push(a)}else typeof i=="object"&&r.push(new Yl({template:i,templateFormat:t?.templateFormat}));return new this({prompt:r,additionalOptions:t})}async format(e){if(this.prompt instanceof Ii){let t=await this.prompt.format(e);return this.createMessage(t)}else{let t=[];for(let r of this.prompt){let i={};if(!("inputVariables"in r))throw new Error(`Prompt ${r} does not have inputVariables defined.`);for(let n of r.inputVariables)i||(i={[n]:e[n]}),i={...i,[n]:e[n]};if(r instanceof Ii){let n=await r.format(i),a;"additionalContentFields"in r&&(a=r.additionalContentFields),n!==""&&t.push({...a,type:"text",text:n})}else if(r instanceof oc){let n=await r.format(i),a;"additionalContentFields"in r&&(a=r.additionalContentFields),t.push({...a,type:"image_url",image_url:n})}else if(r instanceof Yl){let n=await r.format(i),a;"additionalContentFields"in r&&(a=r.additionalContentFields),t.push({...a,...n})}}return this.createMessage(t)}}async formatMessages(e){return[await this.format(e)]}},rm=class extends ex{static _messageClass(){return rt}static lc_name(){return"HumanMessagePromptTemplate"}},tx=class extends ex{static _messageClass(){return Ce}static lc_name(){return"AIMessagePromptTemplate"}},rx=class extends ex{static _messageClass(){return er}static lc_name(){return"SystemMessagePromptTemplate"}};function YF(e){return typeof e.formatMessages=="function"}function QF(e,t){if(YF(e)||qe(e))return e;if(Array.isArray(e)&&e[0]==="placeholder"){let n=e[1];if(t?.templateFormat==="mustache"&&typeof n=="string"&&n.slice(0,2)==="{{"&&n.slice(-2)==="}}")return new tm({variableName:n.slice(2,-2),optional:!0});if(typeof n=="string"&&n[0]==="{"&&n[n.length-1]==="}")return new tm({variableName:n.slice(1,-1),optional:!0});throw new Error(`Invalid placeholder template for format ${t?.templateFormat??'"f-string"'}: "${e[1]}". Expected a variable name surrounded by ${t?.templateFormat==="mustache"?"double":"single"} curly braces.`)}let r=yt(e),i;if(typeof r.content=="string"?i=r.content:i=r.content.map(n=>"text"in n?{...n,text:n.text}:"image_url"in n?{...n,image_url:n.image_url}:n),r._getType()==="human")return rm.fromTemplate(i,t);if(r._getType()==="ai")return tx.fromTemplate(i,t);if(r._getType()==="system")return rx.fromTemplate(i,t);if(an.isInstance(r))return Qw.fromTemplate(r.content,r.role,t);throw new Error(`Could not coerce message prompt template from input. Received message type: "${r._getType()}".`)}function eB(e){return e.constructor.lc_name()==="MessagesPlaceholder"}var sc=class em extends eu{static lc_name(){return"ChatPromptTemplate"}get lc_aliases(){return{promptMessages:"messages"}}promptMessages;validateTemplate=!0;templateFormat="f-string";constructor(t){if(super(t),t.templateFormat==="mustache"&&t.validateTemplate===void 0&&(this.validateTemplate=!1),Object.assign(this,t),this.validateTemplate){let r=new Set;for(let s of this.promptMessages)if(!(s instanceof Te))for(let c of s.inputVariables)r.add(c);let i=this.inputVariables,n=new Set(this.partialVariables?i.concat(Object.keys(this.partialVariables)):i),a=new Set([...n].filter(s=>!r.has(s)));if(a.size>0)throw new Error(`Input variables \`${[...a]}\` are not used in any of the prompt messages.`);let o=new Set([...r].filter(s=>!n.has(s)));if(o.size>0)throw new Error(`Input variables \`${[...o]}\` are used in prompt messages but not in the prompt template.`)}}_getPromptType(){return"chat"}async _parseImagePrompts(t,r){return typeof t.content=="string"||(t.content=await Promise.all(t.content.map(async i=>{if(i.type!=="image_url")return i;let n="";typeof i.image_url=="string"?n=i.image_url:typeof i.image_url=="object"&&i.image_url!==null&&"url"in i.image_url&&typeof i.image_url.url=="string"&&(n=i.image_url.url);let a=await hn.fromTemplate(n,{templateFormat:this.templateFormat}).format(r);return typeof i.image_url=="object"&&i.image_url!==null&&"url"in i.image_url?i.image_url.url=a:i.image_url=a,i}))),t}async formatMessages(t){let r=await this.mergePartialAndUserVariables(t),i=[];for(let n of this.promptMessages)if(n instanceof Te)i.push(await this._parseImagePrompts(n,r));else{let a;this.templateFormat==="mustache"?a={...r}:a=n.inputVariables.reduce((s,c)=>{if(!(c in r)&&!(eB(n)&&n.optional))throw ui(new Error(`Missing value for input variable \`${c.toString()}\``),"INVALID_PROMPT_INPUT");return s[c]=r[c],s},{});let o=await n.formatMessages(a);i=i.concat(o)}return i}async partial(t){let r=this.inputVariables.filter(n=>!(n in t)),i={...this.partialVariables??{},...t};return new em({...this,inputVariables:r,partialVariables:i})}static fromTemplate(t,r){let i=new rm({prompt:hn.fromTemplate(t,r)});return this.fromMessages([i])}static fromMessages(t,r){let i=t.reduce((o,s)=>o.concat(s instanceof em?s.promptMessages:[QF(s,r)]),[]),n=t.reduce((o,s)=>s instanceof em?Object.assign(o,s.partialVariables):o,Object.create(null)),a=new Set;for(let o of i)if(!(o instanceof Te))for(let s of o.inputVariables)s in n||a.add(s);return new this({...r,inputVariables:[...a],promptMessages:i,partialVariables:n,templateFormat:r?.templateFormat})}};var EP=class nx extends Ii{lc_serializable=!1;examples;exampleSelector;examplePrompt;suffix="";exampleSeparator=`
329
-
330
- `;prefix="";templateFormat="f-string";validateTemplate=!0;constructor(t){if(super(t),Object.assign(this,t),this.examples!==void 0&&this.exampleSelector!==void 0)throw new Error("Only one of 'examples' and 'example_selector' should be provided");if(this.examples===void 0&&this.exampleSelector===void 0)throw new Error("One of 'examples' and 'example_selector' should be provided");if(this.validateTemplate){let r=this.inputVariables;this.partialVariables&&(r=r.concat(Object.keys(this.partialVariables))),Ti(this.prefix+this.suffix,this.templateFormat,r)}}_getPromptType(){return"few_shot"}static lc_name(){return"FewShotPromptTemplate"}async getExamples(t){if(this.examples!==void 0)return this.examples;if(this.exampleSelector!==void 0)return this.exampleSelector.selectExamples(t);throw new Error("One of 'examples' and 'example_selector' should be provided")}async partial(t){let r=this.inputVariables.filter(n=>!(n in t)),i={...this.partialVariables??{},...t};return new nx({...this,inputVariables:r,partialVariables:i})}async format(t){let r=await this.mergePartialAndUserVariables(t),i=await this.getExamples(r),n=await Promise.all(i.map(a=>this.examplePrompt.format(a)));return Gt([this.prefix,...n,this.suffix].join(this.exampleSeparator),this.templateFormat,r)}serialize(){if(this.exampleSelector||!this.examples)throw new Error("Serializing an example selector is not currently supported");if(this.outputParser!==void 0)throw new Error("Serializing an output parser is not currently supported");return{_type:this._getPromptType(),input_variables:this.inputVariables,example_prompt:this.examplePrompt.serialize(),example_separator:this.exampleSeparator,suffix:this.suffix,prefix:this.prefix,template_format:this.templateFormat,examples:this.examples}}static async deserialize(t){let{example_prompt:r}=t;if(!r)throw new Error("Missing example prompt");let i=await hn.deserialize(r),n;if(Array.isArray(t.examples))n=t.examples;else throw new Error("Invalid examples format. Only list or string are supported.");return new nx({inputVariables:t.input_variables,examplePrompt:i,examples:n,exampleSeparator:t.example_separator,prefix:t.prefix,suffix:t.suffix,templateFormat:t.template_format})}},IP=class TP extends eu{lc_serializable=!0;examples;exampleSelector;examplePrompt;suffix="";exampleSeparator=`
331
-
332
- `;prefix="";templateFormat="f-string";validateTemplate=!0;_getPromptType(){return"few_shot_chat"}static lc_name(){return"FewShotChatMessagePromptTemplate"}constructor(t){if(super(t),this.examples=t.examples,this.examplePrompt=t.examplePrompt,this.exampleSeparator=t.exampleSeparator??`
333
-
334
- `,this.exampleSelector=t.exampleSelector,this.prefix=t.prefix??"",this.suffix=t.suffix??"",this.templateFormat=t.templateFormat??"f-string",this.validateTemplate=t.validateTemplate??!0,this.examples!==void 0&&this.exampleSelector!==void 0)throw new Error("Only one of 'examples' and 'example_selector' should be provided");if(this.examples===void 0&&this.exampleSelector===void 0)throw new Error("One of 'examples' and 'example_selector' should be provided");if(this.validateTemplate){let r=this.inputVariables;this.partialVariables&&(r=r.concat(Object.keys(this.partialVariables))),Ti(this.prefix+this.suffix,this.templateFormat,r)}}async getExamples(t){if(this.examples!==void 0)return this.examples;if(this.exampleSelector!==void 0)return this.exampleSelector.selectExamples(t);throw new Error("One of 'examples' and 'example_selector' should be provided")}async formatMessages(t){let r=await this.mergePartialAndUserVariables(t),i=await this.getExamples(r);i=i.map(a=>{let o={};return this.examplePrompt.inputVariables.forEach(s=>{o[s]=a[s]}),o});let n=[];for(let a of i){let o=await this.examplePrompt.formatMessages(a);n.push(...o)}return n}async format(t){let r=await this.mergePartialAndUserVariables(t),i=await this.getExamples(r),n=(await Promise.all(i.map(a=>this.examplePrompt.formatMessages(a)))).flat().map(a=>a.content);return Gt([this.prefix,...n,this.suffix].join(this.exampleSeparator),this.templateFormat,r)}async partial(t){let r=this.inputVariables.filter(n=>!(n in t)),i={...this.partialVariables??{},...t};return new TP({...this,inputVariables:r,partialVariables:i})}};var CP=class nm extends Qn{static lc_name(){return"PipelinePromptTemplate"}pipelinePrompts;finalPrompt;constructor(t){super({...t,inputVariables:[]}),this.pipelinePrompts=t.pipelinePrompts,this.finalPrompt=t.finalPrompt,this.inputVariables=this.computeInputValues()}computeInputValues(){let t=this.pipelinePrompts.map(i=>i.name),r=this.pipelinePrompts.map(i=>i.prompt.inputVariables.filter(n=>!t.includes(n))).flat();return[...new Set(r)]}static extractRequiredInputValues(t,r){return r.reduce((i,n)=>(i[n]=t[n],i),{})}async formatPipelinePrompts(t){let r=await this.mergePartialAndUserVariables(t);for(let{name:i,prompt:n}of this.pipelinePrompts){let a=nm.extractRequiredInputValues(r,n.inputVariables);n instanceof sc?r[i]=await n.formatMessages(a):r[i]=await n.format(a)}return nm.extractRequiredInputValues(r,this.finalPrompt.inputVariables)}async formatPromptValue(t){return this.finalPrompt.formatPromptValue(await this.formatPipelinePrompts(t))}async format(t){return this.finalPrompt.format(await this.formatPipelinePrompts(t))}async partial(t){let r={...this};return r.inputVariables=this.inputVariables.filter(i=>!(i in t)),r.partialVariables={...this.partialVariables??{},...t},new nm(r)}serialize(){throw new Error("Not implemented.")}_getPromptType(){return"pipeline"}};function AP(e){return typeof e=="object"&&e!=null&&"withStructuredOutput"in e&&typeof e.withStructuredOutput=="function"}function tB(e){return typeof e=="object"&&e!=null&&"lc_id"in e&&Array.isArray(e.lc_id)&&e.lc_id.join("/")==="langchain_core/runnables/RunnableBinding"}var OP=class PP extends sc{schema;method;lc_namespace=["langchain_core","prompts","structured"];get lc_aliases(){return{...super.lc_aliases,schema:"schema_"}}constructor(t){super(t),this.schema=t.schema,this.method=t.method}pipe(t){if(AP(t))return super.pipe(t.withStructuredOutput(this.schema));if(tB(t)&&AP(t.bound))return super.pipe(new Jr({bound:t.bound.withStructuredOutput(this.schema,...this.method?[{method:this.method}]:[]),kwargs:t.kwargs??{},config:t.config,configFactories:t.configFactories}));throw new Error('Structured prompts need to be piped to a language model that supports the "withStructuredOutput()" method.')}static fromMessagesAndSchema(t,r,i){return PP.fromMessages(t,{schema:r,method:i})}};var NP=T({AIMessagePromptTemplate:()=>tx,BaseChatPromptTemplate:()=>eu,BaseMessagePromptTemplate:()=>Ql,BaseMessageStringPromptTemplate:()=>Yw,BasePromptTemplate:()=>Qn,BaseStringPromptTemplate:()=>Ii,ChatMessagePromptTemplate:()=>Qw,ChatPromptTemplate:()=>sc,DEFAULT_FORMATTER_MAPPING:()=>ql,DEFAULT_PARSER_MAPPING:()=>Kw,DictPromptTemplate:()=>Yl,FewShotChatMessagePromptTemplate:()=>IP,FewShotPromptTemplate:()=>EP,HumanMessagePromptTemplate:()=>rm,ImagePromptTemplate:()=>oc,MessagesPlaceholder:()=>tm,PipelinePromptTemplate:()=>CP,PromptTemplate:()=>hn,StructuredPrompt:()=>OP,SystemMessagePromptTemplate:()=>rx,checkValidTemplate:()=>Ti,interpolateFString:()=>Ww,interpolateMustache:()=>Jw,parseFString:()=>jo,parseMustache:()=>ac,parseTemplate:()=>zo,renderTemplate:()=>Gt});var RP=T({BaseDocumentCompressor:()=>rB}),rB=class{static isBaseDocumentCompressor(e){return e?.compressDocuments!==void 0}};var MP=T({BaseRetriever:()=>tu}),tu=class extends ae{callbacks;tags;metadata;verbose;constructor(e){super(e),this.callbacks=e?.callbacks,this.tags=e?.tags??[],this.metadata=e?.metadata??{},this.verbose=e?.verbose??!1}_getRelevantDocuments(e,t){throw new Error("Not implemented!")}async invoke(e,t){let r=we(to(t)),i=await(await et.configure(r.callbacks,this.callbacks,r.tags,this.tags,r.metadata,this.metadata,{verbose:this.verbose}))?.handleRetrieverStart(this.toJSON(),e,r.runId,void 0,void 0,void 0,r.runName);try{let n=await this._getRelevantDocuments(e,i);return await i?.handleRetrieverEnd(n),n}catch(n){throw await i?.handleRetrieverError(n),n}}};var jP=T({BaseStore:()=>zP,InMemoryStore:()=>nB}),zP=class extends lt{},nB=class extends zP{lc_namespace=["langchain","storage"];store={};async mget(e){return e.map(t=>this.store[t])}async mset(e){for(let[t,r]of e)this.store[t]=r}async mdelete(e){for(let t of e)delete this.store[t]}async*yieldKeys(e){let t=Object.keys(this.store);for(let r of t)(e===void 0||r.startsWith(e))&&(yield r)}};var gn={and:"and",or:"or",not:"not"},ke={eq:"eq",ne:"ne",lt:"lt",gt:"gt",lte:"lte",gte:"gte"},im=class{},am=class{accept(e){if(this.exprName==="Operation")return e.visitOperation(this);if(this.exprName==="Comparison")return e.visitComparison(this);if(this.exprName==="StructuredQuery")return e.visitStructuredQuery(this);throw new Error("Unknown Expression type")}},om=class extends am{},DP=class extends om{exprName="Comparison";constructor(e,t,r){super(),this.comparator=e,this.attribute=t,this.value=r}},UP=class extends om{exprName="Operation";constructor(e,t){super(),this.operator=e,this.args=t}},LP=class extends am{exprName="StructuredQuery";constructor(e,t){super(),this.query=e,this.filter=t}};function ix(e){return e&&typeof e=="object"&&!Array.isArray(e)}function vr(e){return e?typeof e=="string"&&e.length>0||typeof e=="function"?!1:ix(e)&&Object.keys(e).length===0:!0}function ax(e){if(typeof e=="number")return e%1===0;if(typeof e=="string"){let t=parseInt(e,10);return!Number.isNaN(t)&&t%1===0&&t.toString()===e}return!1}function ox(e){if(typeof e=="number")return e%1!==0;if(typeof e=="string"){let t=parseFloat(e);return!Number.isNaN(t)&&t%1!==0&&t.toString()===e}return!1}function sx(e){return typeof e=="string"&&(Number.isNaN(parseFloat(e))||parseFloat(e).toString()!==e)}function cx(e){return typeof e=="boolean"}function cc(e){let t;if(sx(e))t=e;else if(ax(e))t=parseInt(e,10);else if(ox(e))t=parseFloat(e);else if(cx(e))t=!!e;else throw new Error("Unsupported value type");return t}var ru=class extends im{},FP=class extends ru{allowedOperators;allowedComparators;constructor(e){super(),this.allowedOperators=e?.allowedOperators??[gn.and,gn.or],this.allowedComparators=e?.allowedComparators??[ke.eq,ke.ne,ke.gt,ke.gte,ke.lt,ke.lte]}formatFunction(e){if(e in ke){if(this.allowedComparators.length>0&&this.allowedComparators.indexOf(e)===-1)throw new Error(`Comparator ${e} not allowed. Allowed comparators: ${this.allowedComparators.join(", ")}`)}else if(e in gn){if(this.allowedOperators.length>0&&this.allowedOperators.indexOf(e)===-1)throw new Error(`Operator ${e} not allowed. Allowed operators: ${this.allowedOperators.join(", ")}`)}else throw new Error("Unknown comparator or operator");return`$${e}`}visitOperation(e){let t=e.args?.map(r=>r.accept(this));return{[this.formatFunction(e.operator)]:t}}visitComparison(e){return{[e.attribute]:{[this.formatFunction(e.comparator)]:cc(e.value)}}}visitStructuredQuery(e){let t={};return e.filter&&(t={filter:e.filter.accept(this)}),t}mergeFilters(e,t,r="and",i=!1){if(!(vr(e)&&vr(t))){if(vr(e)||r==="replace")return vr(t)?void 0:t;if(vr(t))return i?e:r==="and"?void 0:e;if(r==="and")return{$and:[e,t]};if(r==="or")return{$or:[e,t]};throw new Error("Unknown merge type")}}};var BP=class extends ru{allowedOperators=[gn.and,gn.or];allowedComparators=[ke.eq,ke.ne,ke.gt,ke.gte,ke.lt,ke.lte];formatFunction(){throw new Error("Not implemented")}getAllowedComparatorsForType(e){switch(e){case"string":return[ke.eq,ke.ne,ke.gt,ke.gte,ke.lt,ke.lte];case"number":return[ke.eq,ke.ne,ke.gt,ke.gte,ke.lt,ke.lte];case"boolean":return[ke.eq,ke.ne];default:throw new Error(`Unsupported data type: ${e}`)}}getComparatorFunction(e){switch(e){case ke.eq:return(t,r)=>t===r;case ke.ne:return(t,r)=>t!==r;case ke.gt:return(t,r)=>t>r;case ke.gte:return(t,r)=>t>=r;case ke.lt:return(t,r)=>t<r;case ke.lte:return(t,r)=>t<=r;default:throw new Error("Unknown comparator")}}getOperatorFunction(e){switch(e){case gn.and:return(t,r)=>t&&r;case gn.or:return(t,r)=>t||r;default:throw new Error("Unknown operator")}}visitOperation(e){let{operator:t,args:r}=e;if(this.allowedOperators.includes(t)){let i=this.getOperatorFunction(t);return n=>r?r.reduce((a,o)=>{let s=o.accept(this);if(typeof s=="function")return i(a,s(n));throw new Error("Filter is not a function")},!0):!0}else throw new Error("Operator not allowed")}visitComparison(e){let{comparator:t,attribute:r,value:i}=e,n=[ke.ne];if(this.allowedComparators.includes(t)){if(!this.getAllowedComparatorsForType(typeof i).includes(t))throw new Error(`'${t}' comparator not allowed to be used with ${typeof i}`);let a=this.getComparatorFunction(t);return o=>{let s=o.metadata[r];return s===void 0?!!n.includes(t):a(s,cc(i))}}else throw new Error("Comparator not allowed")}visitStructuredQuery(e){if(!e.filter)return{};let t=e.filter?.accept(this);if(typeof t!="function")throw new Error("Structured query filter is not a function");return{filter:t}}mergeFilters(e,t,r="and"){if(!(vr(e)&&vr(t))){if(vr(e)||r==="replace")return vr(t)?void 0:t;if(vr(t))return r==="and"?void 0:e;if(r==="and")return i=>e(i)&&t(i);if(r==="or")return i=>e(i)||t(i);throw new Error("Unknown merge type")}}};var VP=T({BaseTranslator:()=>ru,BasicTranslator:()=>FP,Comparators:()=>ke,Comparison:()=>DP,Expression:()=>am,FilterDirective:()=>om,FunctionalTranslator:()=>BP,Operation:()=>UP,Operators:()=>gn,StructuredQuery:()=>LP,Visitor:()=>im,castValue:()=>cc,isBoolean:()=>cx,isFilterEmpty:()=>vr,isFloat:()=>ox,isInt:()=>ax,isObject:()=>ix,isString:()=>sx});function nu(e){return Te.isInstance(e)?e.constructor.name||e.type:typeof e}function sm(e,t){return function(r,i){let{isNot:n,utils:a}=this;if(!t(r))return{pass:!1,message:()=>`${a.matcherHint(`toBe${e}`,void 0,void 0)}
335
-
336
- Expected: ${n?"not ":""}${e}
337
- Received: ${nu(r)}`,actual:nu(r),expected:e};if(i===void 0)return{pass:!0,message:()=>`${a.matcherHint(`toBe${e}`,void 0,void 0)}
338
-
339
- Expected: not ${e}
340
- Received: ${e}`};let o=r;return typeof i=="string"?{pass:o.content===i,message:()=>`${a.matcherHint(`toBe${e}`,void 0,void 0)}
341
-
342
- Expected: ${e} with content ${a.printExpected(i)}
343
- Received: ${e} with content ${a.printReceived(o.content)}`,actual:o.content,expected:i}:{pass:Object.entries(i).every(([s,c])=>this.equals(o[s],c)),message:()=>{let s={};for(let c of Object.keys(i))s[c]=o[c];return`${a.matcherHint(`toBe${e}`,void 0,void 0)}
344
-
345
- Expected: ${e} matching ${a.printExpected(i)}
346
- Received: ${e} with ${a.printReceived(s)}`},actual:(()=>{let s={};for(let c of Object.keys(i))s[c]=o[c];return s})(),expected:i}}}var lx=sm("HumanMessage",rt.isInstance),ux=sm("AIMessage",Ce.isInstance),dx=sm("SystemMessage",er.isInstance),fx=sm("ToolMessage",_t.isInstance);function px(e,t){let{isNot:r,utils:i}=this;if(!Ce.isInstance(e))return{pass:!1,message:()=>`${i.matcherHint("toHaveToolCalls")}
347
-
348
- Expected: AIMessage
349
- Received: ${nu(e)}`};let n=e.tool_calls??[];if(n.length!==t.length)return{pass:!1,message:()=>`${i.matcherHint("toHaveToolCalls")}
350
-
351
- Expected ${r?"not ":""}${t.length} tool call(s), received ${n.length}`,actual:n.length,expected:t.length};let a=t.filter(o=>!n.some(s=>Object.entries(o).every(([c,l])=>this.equals(s[c],l))));return a.length>0?{pass:!1,message:()=>`${i.matcherHint("toHaveToolCalls")}
352
-
353
- Could not find matching tool call(s) for:
354
- ${i.printExpected(a)}
355
- Received tool calls: ${i.printReceived(n.map(o=>({name:o.name,id:o.id,args:o.args})))}`,actual:n.map(o=>({name:o.name,id:o.id,args:o.args})),expected:t}:{pass:!0,message:()=>`${i.matcherHint("toHaveToolCalls")}
356
-
357
- Expected AIMessage not to have matching tool calls`}}function mx(e,t){let{isNot:r,utils:i}=this;if(!Ce.isInstance(e))return{pass:!1,message:()=>`${i.matcherHint("toHaveToolCallCount")}
358
-
359
- Expected: AIMessage
360
- Received: ${nu(e)}`};let n=e.tool_calls?.length??0;return{pass:n===t,message:()=>`${i.matcherHint("toHaveToolCallCount")}
361
-
362
- Expected ${r?"not ":""}${t} tool call(s)
363
- Received: ${n}`,actual:n,expected:t}}function hx(e,t){let{isNot:r,utils:i}=this;if(!Ce.isInstance(e))return{pass:!1,message:()=>`${i.matcherHint("toContainToolCall")}
364
-
365
- Expected: AIMessage
366
- Received: ${nu(e)}`};let n=e.tool_calls??[];return{pass:n.some(a=>Object.entries(t).every(([o,s])=>this.equals(a[o],s))),message:()=>`${i.matcherHint("toContainToolCall")}
367
-
368
- Expected AIMessage ${r?"not ":""}to contain a tool call matching ${i.printExpected(t)}
369
- Received tool calls: ${i.printReceived(n.map(a=>({name:a.name,id:a.id})))}`,actual:n.map(a=>({name:a.name,id:a.id})),expected:t}}function gx(e,t){let{isNot:r,utils:i}=this;if(!Array.isArray(e))return{pass:!1,message:()=>`${i.matcherHint("toHaveToolMessages")}
370
-
371
- Expected an array of messages
372
- Received: ${typeof e}`};let n=e.filter(_t.isInstance);if(n.length!==t.length)return{pass:!1,message:()=>`${i.matcherHint("toHaveToolMessages")}
373
-
374
- Expected ${r?"not ":""}${t.length} tool message(s), found ${n.length}`,actual:n.length,expected:t.length};for(let a=0;a<t.length;a++)if(!Object.entries(t[a]).every(([o,s])=>this.equals(n[a][o],s)))return{pass:!1,message:()=>{let o={};for(let s of Object.keys(t[a]))o[s]=n[a][s];return`${i.matcherHint("toHaveToolMessages")}
375
-
376
- Tool message at index ${a} did not match:
377
- Expected: ${i.printExpected(t[a])}
378
- Received: ${i.printReceived(o)}`},actual:n[a],expected:t[a]};return{pass:!0,message:()=>`${i.matcherHint("toHaveToolMessages")}
379
-
380
- Expected messages not to contain matching tool messages`}}function _x(e,t){let{isNot:r,utils:i}=this,n=e?.__interrupt__;if(!(Array.isArray(n)&&n.length>0))return{pass:!1,message:()=>`${i.matcherHint("toHaveBeenInterrupted")}
381
-
382
- Expected result ${r?"not ":""}to have been interrupted
383
- Received __interrupt__: ${i.printReceived(n)}`};if(t===void 0)return{pass:!0,message:()=>`${i.matcherHint("toHaveBeenInterrupted")}
384
-
385
- Expected result not to have been interrupted
386
- Received ${n.length} interrupt(s)`};let a=n[0]?.value;return{pass:this.equals(a,t),message:()=>`${i.matcherHint("toHaveBeenInterrupted")}
387
-
388
- Expected interrupt value: ${i.printExpected(t)}
389
- Received interrupt value: ${i.printReceived(a)}`,actual:a,expected:t}}function yx(e,t){let{isNot:r,utils:i}=this,n=e?.structuredResponse;return n===void 0?{pass:!1,message:()=>`${i.matcherHint("toHaveStructuredResponse")}
390
-
391
- Expected result ${r?"not ":""}to have a structured response
392
- Received structuredResponse: undefined`}:t===void 0?{pass:!0,message:()=>`${i.matcherHint("toHaveStructuredResponse")}
393
-
394
- Expected result not to have a structured response`}:{pass:Object.entries(t).every(([a,o])=>this.equals(n[a],o)),message:()=>`${i.matcherHint("toHaveStructuredResponse")}
395
-
396
- Expected structured response: ${i.printExpected(t)}
397
- Received structured response: ${i.printReceived(n)}`,actual:n,expected:t}}var ZP={toBeHumanMessage:lx,toBeAIMessage:ux,toBeSystemMessage:dx,toBeToolMessage:fx,toHaveToolCalls:px,toHaveToolCallCount:mx,toContainToolCall:hx,toHaveToolMessages:gx,toHaveBeenInterrupted:_x,toHaveStructuredResponse:yx};function iB(e){return e.map(t=>t.text).filter(Boolean).join("-")}var HP=0;function aB(){return HP+=1,`fake_tc_${HP}`}var vx=class GP extends Sa{queue=[];_alwaysThrowError;_structuredResponseValue;_tools=[];_state={callIndex:0,calls:[]};get calls(){return this._state.calls}get callCount(){return this._state.calls.length}constructor(){super({})}_llmType(){return"fake-model-builder"}_combineLLMOutput(){return[]}respond(t){return typeof t=="function"?this.queue.push({kind:"factory",factory:t}):Te.isInstance(t)?this.queue.push({kind:"message",message:t}):this.queue.push({kind:"error",error:t}),this}respondWithTools(t){return this.queue.push({kind:"toolCalls",toolCalls:t.map(r=>({name:r.name,args:r.args,id:r.id??aB(),type:"tool_call"}))}),this}alwaysThrow(t){return this._alwaysThrowError=t,this}structuredResponse(t){return this._structuredResponseValue=t,this}bindTools(t){let r=[...this._tools,...t],i=new GP;return i.queue=this.queue,i._alwaysThrowError=this._alwaysThrowError,i._structuredResponseValue=this._structuredResponseValue,i._tools=r,i._state=this._state,i.withConfig({})}withStructuredOutput(t,r){let{_structuredResponseValue:i}=this;return Zt.from(async()=>i)}async _generate(t,r,i){this._state.calls.push({messages:[...t],options:r});let n=this._state.callIndex;if(this._state.callIndex+=1,this._alwaysThrowError)throw this._alwaysThrowError;let a=this.queue[n];if(!a)throw new Error(`FakeModel: no response queued for invocation ${n} (${this.queue.length} total queued).`);if(a.kind==="error")throw a.error;if(a.kind==="factory"){let s=a.factory(t);if(!Te.isInstance(s))throw s;return{generations:[{text:"",message:s}]}}if(a.kind==="message")return{generations:[{text:"",message:a.message}]};let o=iB(t);return{generations:[{text:o,message:new Ce({content:o,id:n.toString(),tool_calls:a.toolCalls.length>0?a.toolCalls.map(s=>({...s,type:"tool_call"})):void 0})}],llmOutput:{}}}};function WP(){return new vx}var JP=T({FakeBuiltModel:()=>vx,fakeModel:()=>WP,langchainMatchers:()=>ZP,toBeAIMessage:()=>ux,toBeHumanMessage:()=>lx,toBeSystemMessage:()=>dx,toBeToolMessage:()=>fx,toContainToolCall:()=>hx,toHaveBeenInterrupted:()=>_x,toHaveStructuredResponse:()=>yx,toHaveToolCallCount:()=>mx,toHaveToolCalls:()=>px,toHaveToolMessages:()=>gx});function iu(e){return e!==void 0&&Array.isArray(e.lc_namespace)}function au(e){return e!==void 0&&ae.isRunnable(e)&&"lc_name"in e.constructor&&typeof e.constructor.lc_name=="function"&&e.constructor.lc_name()==="RunnableToolLike"}function ou(e){return!!e&&typeof e=="object"&&"name"in e&&"schema"in e&&(gr(e.schema)||e.schema!=null&&typeof e.schema=="object"&&"type"in e.schema&&typeof e.schema.type=="string"&&["null","boolean","object","array","number","string"].includes(e.schema.type))}function su(e){return ou(e)||au(e)||iu(e)}var Xr={};Tn(Xr,{$brand:()=>h_,$input:()=>Rv,$output:()=>Nv,NEVER:()=>m_,TimePrecision:()=>Dv,ZodAny:()=>Vx,ZodArray:()=>Wx,ZodBase64:()=>Tm,ZodBase64URL:()=>Cm,ZodBigInt:()=>gc,ZodBigIntFormat:()=>Pm,ZodBoolean:()=>hc,ZodCIDRv4:()=>Em,ZodCIDRv6:()=>Im,ZodCUID:()=>vm,ZodCUID2:()=>bm,ZodCatch:()=>h0,ZodCodec:()=>bu,ZodCustom:()=>wu,ZodCustomStringFormat:()=>pc,ZodDate:()=>hu,ZodDefault:()=>l0,ZodDiscriminatedUnion:()=>Kx,ZodE164:()=>Am,ZodEmail:()=>gm,ZodEmoji:()=>_m,ZodEnum:()=>dc,ZodError:()=>oB,ZodExactOptional:()=>o0,ZodFile:()=>i0,ZodFirstPartyTypeKind:()=>T0,ZodFunction:()=>$0,ZodGUID:()=>uu,ZodIPv4:()=>km,ZodIPv6:()=>$m,ZodISODate:()=>um,ZodISODateTime:()=>lm,ZodISODuration:()=>fm,ZodISOTime:()=>dm,ZodIntersection:()=>qx,ZodIssueCode:()=>cB,ZodJWT:()=>Om,ZodKSUID:()=>Sm,ZodLazy:()=>x0,ZodLiteral:()=>n0,ZodMAC:()=>jx,ZodMap:()=>t0,ZodNaN:()=>_0,ZodNanoID:()=>ym,ZodNever:()=>Hx,ZodNonOptional:()=>Dm,ZodNull:()=>Fx,ZodNullable:()=>c0,ZodNumber:()=>mc,ZodNumberFormat:()=>Uo,ZodObject:()=>_u,ZodOptional:()=>zm,ZodPipe:()=>vu,ZodPrefault:()=>d0,ZodPreprocess:()=>y0,ZodPromise:()=>k0,ZodReadonly:()=>v0,ZodRealError:()=>br,ZodRecord:()=>uc,ZodSet:()=>r0,ZodString:()=>fc,ZodStringFormat:()=>De,ZodSuccess:()=>m0,ZodSymbol:()=>Ux,ZodTemplateLiteral:()=>w0,ZodTransform:()=>a0,ZodTuple:()=>Yx,ZodType:()=>ge,ZodULID:()=>wm,ZodURL:()=>mu,ZodUUID:()=>ei,ZodUndefined:()=>Lx,ZodUnion:()=>yu,ZodUnknown:()=>Zx,ZodVoid:()=>Gx,ZodXID:()=>xm,ZodXor:()=>Jx,_ZodString:()=>hm,_default:()=>u0,_function:()=>n1,any:()=>RN,array:()=>gu,base64:()=>_N,base64url:()=>yN,bigint:()=>CN,boolean:()=>Dx,catch:()=>g0,check:()=>i1,cidrv4:()=>hN,cidrv6:()=>gN,clone:()=>We,codec:()=>QN,coerce:()=>C0,config:()=>it,core:()=>yi,cuid:()=>sN,cuid2:()=>cN,custom:()=>a1,date:()=>jN,decode:()=>Cx,decodeAsync:()=>Ox,describe:()=>o1,discriminatedUnion:()=>BN,e164:()=>vN,email:()=>XP,emoji:()=>aN,encode:()=>Tx,encodeAsync:()=>Ax,endsWith:()=>Ns,enum:()=>Mm,exactOptional:()=>s0,file:()=>KN,flattenError:()=>hl,float32:()=>$N,float64:()=>EN,formatError:()=>gl,fromJSONSchema:()=>p1,function:()=>n1,getErrorMap:()=>uB,globalRegistry:()=>Ne,gt:()=>Vn,gte:()=>ar,guid:()=>YP,hash:()=>kN,hex:()=>SN,hostname:()=>xN,httpUrl:()=>iN,includes:()=>Os,instanceof:()=>c1,int:()=>pm,int32:()=>IN,int64:()=>AN,intersection:()=>Xx,invertCodec:()=>e1,ipv4:()=>fN,ipv6:()=>mN,iso:()=>lc,json:()=>u1,jwt:()=>bN,keyof:()=>zN,ksuid:()=>dN,lazy:()=>S0,length:()=>ho,literal:()=>JN,locales:()=>El,looseObject:()=>LN,looseRecord:()=>ZN,lowercase:()=>Cs,lt:()=>Bn,lte:()=>Ar,mac:()=>pN,map:()=>HN,maxLength:()=>mo,maxSize:()=>ua,meta:()=>s1,mime:()=>Rs,minLength:()=>_i,minSize:()=>Zn,multipleOf:()=>la,nan:()=>YN,nanoid:()=>oN,nativeEnum:()=>WN,negative:()=>sp,never:()=>Nm,nonnegative:()=>lp,nonoptional:()=>p0,nonpositive:()=>cp,normalize:()=>Ms,null:()=>Bx,nullable:()=>fu,nullish:()=>qN,number:()=>zx,object:()=>DN,optional:()=>du,overwrite:()=>ln,parse:()=>kx,parseAsync:()=>$x,partialRecord:()=>VN,pipe:()=>mm,positive:()=>op,prefault:()=>f0,preprocess:()=>d1,prettifyError:()=>T_,promise:()=>r1,property:()=>up,readonly:()=>b0,record:()=>e0,refine:()=>E0,regex:()=>Ts,regexes:()=>Cr,registry:()=>Uf,safeDecode:()=>Nx,safeDecodeAsync:()=>Mx,safeEncode:()=>Px,safeEncodeAsync:()=>Rx,safeParse:()=>Ex,safeParseAsync:()=>Ix,set:()=>GN,setErrorMap:()=>lB,size:()=>po,slugify:()=>Us,startsWith:()=>Ps,strictObject:()=>UN,string:()=>lu,stringFormat:()=>wN,stringbool:()=>l1,success:()=>XN,superRefine:()=>I0,symbol:()=>PN,templateLiteral:()=>t1,toJSONSchema:()=>go,toLowerCase:()=>zs,toUpperCase:()=>Ds,transform:()=>jm,treeifyError:()=>I_,trim:()=>js,tuple:()=>Qx,uint32:()=>TN,uint64:()=>ON,ulid:()=>lN,undefined:()=>NN,union:()=>Rm,unknown:()=>Do,uppercase:()=>As,url:()=>nN,util:()=>j,uuid:()=>QP,uuidv4:()=>eN,uuidv6:()=>tN,uuidv7:()=>rN,void:()=>MN,xid:()=>uN,xor:()=>FN});var cu={};Tn(cu,{ZodAny:()=>Vx,ZodArray:()=>Wx,ZodBase64:()=>Tm,ZodBase64URL:()=>Cm,ZodBigInt:()=>gc,ZodBigIntFormat:()=>Pm,ZodBoolean:()=>hc,ZodCIDRv4:()=>Em,ZodCIDRv6:()=>Im,ZodCUID:()=>vm,ZodCUID2:()=>bm,ZodCatch:()=>h0,ZodCodec:()=>bu,ZodCustom:()=>wu,ZodCustomStringFormat:()=>pc,ZodDate:()=>hu,ZodDefault:()=>l0,ZodDiscriminatedUnion:()=>Kx,ZodE164:()=>Am,ZodEmail:()=>gm,ZodEmoji:()=>_m,ZodEnum:()=>dc,ZodExactOptional:()=>o0,ZodFile:()=>i0,ZodFunction:()=>$0,ZodGUID:()=>uu,ZodIPv4:()=>km,ZodIPv6:()=>$m,ZodIntersection:()=>qx,ZodJWT:()=>Om,ZodKSUID:()=>Sm,ZodLazy:()=>x0,ZodLiteral:()=>n0,ZodMAC:()=>jx,ZodMap:()=>t0,ZodNaN:()=>_0,ZodNanoID:()=>ym,ZodNever:()=>Hx,ZodNonOptional:()=>Dm,ZodNull:()=>Fx,ZodNullable:()=>c0,ZodNumber:()=>mc,ZodNumberFormat:()=>Uo,ZodObject:()=>_u,ZodOptional:()=>zm,ZodPipe:()=>vu,ZodPrefault:()=>d0,ZodPreprocess:()=>y0,ZodPromise:()=>k0,ZodReadonly:()=>v0,ZodRecord:()=>uc,ZodSet:()=>r0,ZodString:()=>fc,ZodStringFormat:()=>De,ZodSuccess:()=>m0,ZodSymbol:()=>Ux,ZodTemplateLiteral:()=>w0,ZodTransform:()=>a0,ZodTuple:()=>Yx,ZodType:()=>ge,ZodULID:()=>wm,ZodURL:()=>mu,ZodUUID:()=>ei,ZodUndefined:()=>Lx,ZodUnion:()=>yu,ZodUnknown:()=>Zx,ZodVoid:()=>Gx,ZodXID:()=>xm,ZodXor:()=>Jx,_ZodString:()=>hm,_default:()=>u0,_function:()=>n1,any:()=>RN,array:()=>gu,base64:()=>_N,base64url:()=>yN,bigint:()=>CN,boolean:()=>Dx,catch:()=>g0,check:()=>i1,cidrv4:()=>hN,cidrv6:()=>gN,codec:()=>QN,cuid:()=>sN,cuid2:()=>cN,custom:()=>a1,date:()=>jN,describe:()=>o1,discriminatedUnion:()=>BN,e164:()=>vN,email:()=>XP,emoji:()=>aN,enum:()=>Mm,exactOptional:()=>s0,file:()=>KN,float32:()=>$N,float64:()=>EN,function:()=>n1,guid:()=>YP,hash:()=>kN,hex:()=>SN,hostname:()=>xN,httpUrl:()=>iN,instanceof:()=>c1,int:()=>pm,int32:()=>IN,int64:()=>AN,intersection:()=>Xx,invertCodec:()=>e1,ipv4:()=>fN,ipv6:()=>mN,json:()=>u1,jwt:()=>bN,keyof:()=>zN,ksuid:()=>dN,lazy:()=>S0,literal:()=>JN,looseObject:()=>LN,looseRecord:()=>ZN,mac:()=>pN,map:()=>HN,meta:()=>s1,nan:()=>YN,nanoid:()=>oN,nativeEnum:()=>WN,never:()=>Nm,nonoptional:()=>p0,null:()=>Bx,nullable:()=>fu,nullish:()=>qN,number:()=>zx,object:()=>DN,optional:()=>du,partialRecord:()=>VN,pipe:()=>mm,prefault:()=>f0,preprocess:()=>d1,promise:()=>r1,readonly:()=>b0,record:()=>e0,refine:()=>E0,set:()=>GN,strictObject:()=>UN,string:()=>lu,stringFormat:()=>wN,stringbool:()=>l1,success:()=>XN,superRefine:()=>I0,symbol:()=>PN,templateLiteral:()=>t1,transform:()=>jm,tuple:()=>Qx,uint32:()=>TN,uint64:()=>ON,ulid:()=>lN,undefined:()=>NN,union:()=>Rm,unknown:()=>Do,url:()=>nN,uuid:()=>QP,uuidv4:()=>eN,uuidv6:()=>tN,uuidv7:()=>rN,void:()=>MN,xid:()=>uN,xor:()=>FN});var cm={};Tn(cm,{endsWith:()=>Ns,gt:()=>Vn,gte:()=>ar,includes:()=>Os,length:()=>ho,lowercase:()=>Cs,lt:()=>Bn,lte:()=>Ar,maxLength:()=>mo,maxSize:()=>ua,mime:()=>Rs,minLength:()=>_i,minSize:()=>Zn,multipleOf:()=>la,negative:()=>sp,nonnegative:()=>lp,nonpositive:()=>cp,normalize:()=>Ms,overwrite:()=>ln,positive:()=>op,property:()=>up,regex:()=>Ts,size:()=>po,slugify:()=>Us,startsWith:()=>Ps,toLowerCase:()=>zs,toUpperCase:()=>Ds,trim:()=>js,uppercase:()=>As});var lc={};Tn(lc,{ZodISODate:()=>um,ZodISODateTime:()=>lm,ZodISODuration:()=>fm,ZodISOTime:()=>dm,date:()=>wx,datetime:()=>bx,duration:()=>Sx,time:()=>xx});var lm=k("ZodISODateTime",(e,t)=>{zy.init(e,t),De.init(e,t)});function bx(e){return Uv(lm,e)}var um=k("ZodISODate",(e,t)=>{Dy.init(e,t),De.init(e,t)});function wx(e){return Lv(um,e)}var dm=k("ZodISOTime",(e,t)=>{Uy.init(e,t),De.init(e,t)});function xx(e){return Fv(dm,e)}var fm=k("ZodISODuration",(e,t)=>{Ly.init(e,t),De.init(e,t)});function Sx(e){return Bv(fm,e)}var KP=(e,t)=>{ml.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>gl(e,r)},flatten:{value:r=>hl(e,r)},addIssue:{value:r=>{e.issues.push(r),e.message=JSON.stringify(e.issues,vs,2)}},addIssues:{value:r=>{e.issues.push(...r),e.message=JSON.stringify(e.issues,vs,2)}},isEmpty:{get(){return e.issues.length===0}}})},oB=k("ZodError",KP),br=k("ZodError",KP,{Parent:Error});var kx=xs(br),$x=Ss(br),Ex=ks(br),Ix=$s(br),Tx=hf(br),Cx=gf(br),Ax=_f(br),Ox=yf(br),Px=vf(br),Nx=bf(br),Rx=wf(br),Mx=xf(br);var qP=new WeakMap;function pu(e,t,r){let i=Object.getPrototypeOf(e),n=qP.get(i);if(n||(n=new Set,qP.set(i,n)),!n.has(t)){n.add(t);for(let a in r){let o=r[a];Object.defineProperty(i,a,{configurable:!0,enumerable:!1,get(){let s=o.bind(this);return Object.defineProperty(this,a,{configurable:!0,writable:!0,enumerable:!0,value:s}),s},set(s){Object.defineProperty(this,a,{configurable:!0,writable:!0,enumerable:!0,value:s})}})}}}var ge=k("ZodType",(e,t)=>(de.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Fs(e,"input"),output:Fs(e,"output")}}),e.toJSONSchema=yb(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(r,i)=>kx(e,r,i,{callee:e.parse}),e.safeParse=(r,i)=>Ex(e,r,i),e.parseAsync=async(r,i)=>$x(e,r,i,{callee:e.parseAsync}),e.safeParseAsync=async(r,i)=>Ix(e,r,i),e.spa=e.safeParseAsync,e.encode=(r,i)=>Tx(e,r,i),e.decode=(r,i)=>Cx(e,r,i),e.encodeAsync=async(r,i)=>Ax(e,r,i),e.decodeAsync=async(r,i)=>Ox(e,r,i),e.safeEncode=(r,i)=>Px(e,r,i),e.safeDecode=(r,i)=>Nx(e,r,i),e.safeEncodeAsync=async(r,i)=>Rx(e,r,i),e.safeDecodeAsync=async(r,i)=>Mx(e,r,i),pu(e,"ZodType",{check(...r){let i=this.def;return this.clone(j.mergeDefs(i,{checks:[...i.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...r){return this.check(...r)},clone(r,i){return We(this,r,i)},brand(){return this},register(r,i){return r.add(this,i),this},refine(r,i){return this.check(E0(r,i))},superRefine(r,i){return this.check(I0(r,i))},overwrite(r){return this.check(ln(r))},optional(){return du(this)},exactOptional(){return s0(this)},nullable(){return fu(this)},nullish(){return du(fu(this))},nonoptional(r){return p0(this,r)},array(){return gu(this)},or(r){return Rm([this,r])},and(r){return Xx(this,r)},transform(r){return mm(this,jm(r))},default(r){return u0(this,r)},prefault(r){return f0(this,r)},catch(r){return g0(this,r)},pipe(r){return mm(this,r)},readonly(){return b0(this)},describe(r){let i=this.clone();return Ne.add(i,{description:r}),i},meta(...r){if(r.length===0)return Ne.get(this);let i=this.clone();return Ne.add(i,r[0]),i},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(r){return r(this)}}),Object.defineProperty(e,"description",{get(){return Ne.get(e)?.description},configurable:!0}),e)),hm=k("_ZodString",(e,t)=>{uo.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(i,n,a)=>vb(e,i,n,a);let r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,pu(e,"_ZodString",{regex(...i){return this.check(Ts(...i))},includes(...i){return this.check(Os(...i))},startsWith(...i){return this.check(Ps(...i))},endsWith(...i){return this.check(Ns(...i))},min(...i){return this.check(_i(...i))},max(...i){return this.check(mo(...i))},length(...i){return this.check(ho(...i))},nonempty(...i){return this.check(_i(1,...i))},lowercase(i){return this.check(Cs(i))},uppercase(i){return this.check(As(i))},trim(){return this.check(js())},normalize(...i){return this.check(Ms(...i))},toLowerCase(){return this.check(zs())},toUpperCase(){return this.check(Ds())},slugify(){return this.check(Us())}})}),fc=k("ZodString",(e,t)=>{uo.init(e,t),hm.init(e,t),e.email=r=>e.check(Lf(gm,r)),e.url=r=>e.check(Tl(mu,r)),e.jwt=r=>e.check(ap(Om,r)),e.emoji=r=>e.check(Hf(_m,r)),e.guid=r=>e.check(Il(uu,r)),e.uuid=r=>e.check(Ff(ei,r)),e.uuidv4=r=>e.check(Bf(ei,r)),e.uuidv6=r=>e.check(Vf(ei,r)),e.uuidv7=r=>e.check(Zf(ei,r)),e.nanoid=r=>e.check(Gf(ym,r)),e.guid=r=>e.check(Il(uu,r)),e.cuid=r=>e.check(Wf(vm,r)),e.cuid2=r=>e.check(Jf(bm,r)),e.ulid=r=>e.check(Kf(wm,r)),e.base64=r=>e.check(rp(Tm,r)),e.base64url=r=>e.check(np(Cm,r)),e.xid=r=>e.check(qf(xm,r)),e.ksuid=r=>e.check(Xf(Sm,r)),e.ipv4=r=>e.check(Yf(km,r)),e.ipv6=r=>e.check(Qf($m,r)),e.cidrv4=r=>e.check(ep(Em,r)),e.cidrv6=r=>e.check(tp(Im,r)),e.e164=r=>e.check(ip(Am,r)),e.datetime=r=>e.check(bx(r)),e.date=r=>e.check(wx(r)),e.time=r=>e.check(xx(r)),e.duration=r=>e.check(Sx(r))});function lu(e){return Mv(fc,e)}var De=k("ZodStringFormat",(e,t)=>{ze.init(e,t),hm.init(e,t)}),gm=k("ZodEmail",(e,t)=>{Ty.init(e,t),De.init(e,t)});function XP(e){return Lf(gm,e)}var uu=k("ZodGUID",(e,t)=>{Ey.init(e,t),De.init(e,t)});function YP(e){return Il(uu,e)}var ei=k("ZodUUID",(e,t)=>{Iy.init(e,t),De.init(e,t)});function QP(e){return Ff(ei,e)}function eN(e){return Bf(ei,e)}function tN(e){return Vf(ei,e)}function rN(e){return Zf(ei,e)}var mu=k("ZodURL",(e,t)=>{Cy.init(e,t),De.init(e,t)});function nN(e){return Tl(mu,e)}function iN(e){return Tl(mu,{protocol:Cr.httpProtocol,hostname:Cr.domain,...j.normalizeParams(e)})}var _m=k("ZodEmoji",(e,t)=>{Ay.init(e,t),De.init(e,t)});function aN(e){return Hf(_m,e)}var ym=k("ZodNanoID",(e,t)=>{Oy.init(e,t),De.init(e,t)});function oN(e){return Gf(ym,e)}var vm=k("ZodCUID",(e,t)=>{Py.init(e,t),De.init(e,t)});function sN(e){return Wf(vm,e)}var bm=k("ZodCUID2",(e,t)=>{Ny.init(e,t),De.init(e,t)});function cN(e){return Jf(bm,e)}var wm=k("ZodULID",(e,t)=>{Ry.init(e,t),De.init(e,t)});function lN(e){return Kf(wm,e)}var xm=k("ZodXID",(e,t)=>{My.init(e,t),De.init(e,t)});function uN(e){return qf(xm,e)}var Sm=k("ZodKSUID",(e,t)=>{jy.init(e,t),De.init(e,t)});function dN(e){return Xf(Sm,e)}var km=k("ZodIPv4",(e,t)=>{Fy.init(e,t),De.init(e,t)});function fN(e){return Yf(km,e)}var jx=k("ZodMAC",(e,t)=>{Vy.init(e,t),De.init(e,t)});function pN(e){return zv(jx,e)}var $m=k("ZodIPv6",(e,t)=>{By.init(e,t),De.init(e,t)});function mN(e){return Qf($m,e)}var Em=k("ZodCIDRv4",(e,t)=>{Zy.init(e,t),De.init(e,t)});function hN(e){return ep(Em,e)}var Im=k("ZodCIDRv6",(e,t)=>{Hy.init(e,t),De.init(e,t)});function gN(e){return tp(Im,e)}var Tm=k("ZodBase64",(e,t)=>{Wy.init(e,t),De.init(e,t)});function _N(e){return rp(Tm,e)}var Cm=k("ZodBase64URL",(e,t)=>{Jy.init(e,t),De.init(e,t)});function yN(e){return np(Cm,e)}var Am=k("ZodE164",(e,t)=>{Ky.init(e,t),De.init(e,t)});function vN(e){return ip(Am,e)}var Om=k("ZodJWT",(e,t)=>{qy.init(e,t),De.init(e,t)});function bN(e){return ap(Om,e)}var pc=k("ZodCustomStringFormat",(e,t)=>{Xy.init(e,t),De.init(e,t)});function wN(e,t,r={}){return Ls(pc,e,t,r)}function xN(e){return Ls(pc,"hostname",Cr.hostname,e)}function SN(e){return Ls(pc,"hex",Cr.hex,e)}function kN(e,t){let r=t?.enc??"hex",i=`${e}_${r}`,n=Cr[i];if(!n)throw new Error(`Unrecognized hash format: ${i}`);return Ls(pc,i,n,t)}var mc=k("ZodNumber",(e,t)=>{Of.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(i,n,a)=>bb(e,i,n,a),pu(e,"ZodNumber",{gt(i,n){return this.check(Vn(i,n))},gte(i,n){return this.check(ar(i,n))},min(i,n){return this.check(ar(i,n))},lt(i,n){return this.check(Bn(i,n))},lte(i,n){return this.check(Ar(i,n))},max(i,n){return this.check(Ar(i,n))},int(i){return this.check(pm(i))},safe(i){return this.check(pm(i))},positive(i){return this.check(Vn(0,i))},nonnegative(i){return this.check(ar(0,i))},negative(i){return this.check(Bn(0,i))},nonpositive(i){return this.check(Ar(0,i))},multipleOf(i,n){return this.check(la(i,n))},step(i,n){return this.check(la(i,n))},finite(){return this}});let r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),e.isFinite=!0,e.format=r.format??null});function zx(e){return Vv(mc,e)}var Uo=k("ZodNumberFormat",(e,t)=>{Yy.init(e,t),mc.init(e,t)});function pm(e){return Hv(Uo,e)}function $N(e){return Gv(Uo,e)}function EN(e){return Wv(Uo,e)}function IN(e){return Jv(Uo,e)}function TN(e){return Kv(Uo,e)}var hc=k("ZodBoolean",(e,t)=>{bl.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,i,n)=>wb(e,r,i,n)});function Dx(e){return qv(hc,e)}var gc=k("ZodBigInt",(e,t)=>{Pf.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(i,n,a)=>xb(e,i,n,a),e.gte=(i,n)=>e.check(ar(i,n)),e.min=(i,n)=>e.check(ar(i,n)),e.gt=(i,n)=>e.check(Vn(i,n)),e.gte=(i,n)=>e.check(ar(i,n)),e.min=(i,n)=>e.check(ar(i,n)),e.lt=(i,n)=>e.check(Bn(i,n)),e.lte=(i,n)=>e.check(Ar(i,n)),e.max=(i,n)=>e.check(Ar(i,n)),e.positive=i=>e.check(Vn(BigInt(0),i)),e.negative=i=>e.check(Bn(BigInt(0),i)),e.nonpositive=i=>e.check(Ar(BigInt(0),i)),e.nonnegative=i=>e.check(ar(BigInt(0),i)),e.multipleOf=(i,n)=>e.check(la(i,n));let r=e._zod.bag;e.minValue=r.minimum??null,e.maxValue=r.maximum??null,e.format=r.format??null});function CN(e){return Yv(gc,e)}var Pm=k("ZodBigIntFormat",(e,t)=>{Qy.init(e,t),gc.init(e,t)});function AN(e){return eb(Pm,e)}function ON(e){return tb(Pm,e)}var Ux=k("ZodSymbol",(e,t)=>{ev.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Sb(e,r,i,n)});function PN(e){return rb(Ux,e)}var Lx=k("ZodUndefined",(e,t)=>{tv.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,i,n)=>$b(e,r,i,n)});function NN(e){return nb(Lx,e)}var Fx=k("ZodNull",(e,t)=>{rv.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,i,n)=>kb(e,r,i,n)});function Bx(e){return ib(Fx,e)}var Vx=k("ZodAny",(e,t)=>{nv.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Tb(e,r,i,n)});function RN(){return ab(Vx)}var Zx=k("ZodUnknown",(e,t)=>{wl.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Cb(e,r,i,n)});function Do(){return Cl(Zx)}var Hx=k("ZodNever",(e,t)=>{xl.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Ib(e,r,i,n)});function Nm(e){return Al(Hx,e)}var Gx=k("ZodVoid",(e,t)=>{iv.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Eb(e,r,i,n)});function MN(e){return ob(Gx,e)}var hu=k("ZodDate",(e,t)=>{av.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(i,n,a)=>Ab(e,i,n,a),e.min=(i,n)=>e.check(ar(i,n)),e.max=(i,n)=>e.check(Ar(i,n));let r=e._zod.bag;e.minDate=r.minimum?new Date(r.minimum):null,e.maxDate=r.maximum?new Date(r.maximum):null});function jN(e){return sb(hu,e)}var Wx=k("ZodArray",(e,t)=>{ov.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Bb(e,r,i,n),e.element=t.element,pu(e,"ZodArray",{min(r,i){return this.check(_i(r,i))},nonempty(r){return this.check(_i(1,r))},max(r,i){return this.check(mo(r,i))},length(r,i){return this.check(ho(r,i))},unwrap(){return this.element}})});function gu(e,t){return ub(Wx,e,t)}function zN(e){let t=e._zod.def.shape;return Mm(Object.keys(t))}var _u=k("ZodObject",(e,t)=>{sv.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Vb(e,r,i,n),j.defineLazy(e,"shape",()=>t.shape),pu(e,"ZodObject",{keyof(){return Mm(Object.keys(this._zod.def.shape))},catchall(r){return this.clone({...this._zod.def,catchall:r})},passthrough(){return this.clone({...this._zod.def,catchall:Do()})},loose(){return this.clone({...this._zod.def,catchall:Do()})},strict(){return this.clone({...this._zod.def,catchall:Nm()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(r){return j.extend(this,r)},safeExtend(r){return j.safeExtend(this,r)},merge(r){return j.merge(this,r)},pick(r){return j.pick(this,r)},omit(r){return j.omit(this,r)},partial(...r){return j.partial(zm,this,r[0])},required(...r){return j.required(Dm,this,r[0])}})});function DN(e,t){let r={type:"object",shape:e??{},...j.normalizeParams(t)};return new _u(r)}function UN(e,t){return new _u({type:"object",shape:e,catchall:Nm(),...j.normalizeParams(t)})}function LN(e,t){return new _u({type:"object",shape:e,catchall:Do(),...j.normalizeParams(t)})}var yu=k("ZodUnion",(e,t)=>{Sl.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,i,n)=>fp(e,r,i,n),e.options=t.options});function Rm(e,t){return new yu({type:"union",options:e,...j.normalizeParams(t)})}var Jx=k("ZodXor",(e,t)=>{yu.init(e,t),cv.init(e,t),e._zod.processJSONSchema=(r,i,n)=>fp(e,r,i,n),e.options=t.options});function FN(e,t){return new Jx({type:"union",options:e,inclusive:!1,...j.normalizeParams(t)})}var Kx=k("ZodDiscriminatedUnion",(e,t)=>{yu.init(e,t),lv.init(e,t)});function BN(e,t,r){return new Kx({type:"union",options:t,discriminator:e,...j.normalizeParams(r)})}var qx=k("ZodIntersection",(e,t)=>{uv.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Zb(e,r,i,n)});function Xx(e,t){return new qx({type:"intersection",left:e,right:t})}var Yx=k("ZodTuple",(e,t)=>{Nf.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Hb(e,r,i,n),e.rest=r=>e.clone({...e._zod.def,rest:r})});function Qx(e,t,r){let i=t instanceof de,n=i?r:t,a=i?t:null;return new Yx({type:"tuple",items:e,rest:a,...j.normalizeParams(n)})}var uc=k("ZodRecord",(e,t)=>{dv.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Gb(e,r,i,n),e.keyType=t.keyType,e.valueType=t.valueType});function e0(e,t,r){return!t||!t._zod?new uc({type:"record",keyType:lu(),valueType:e,...j.normalizeParams(t)}):new uc({type:"record",keyType:e,valueType:t,...j.normalizeParams(r)})}function VN(e,t,r){let i=We(e);return i._zod.values=void 0,new uc({type:"record",keyType:i,valueType:t,...j.normalizeParams(r)})}function ZN(e,t,r){return new uc({type:"record",keyType:e,valueType:t,mode:"loose",...j.normalizeParams(r)})}var t0=k("ZodMap",(e,t)=>{fv.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Lb(e,r,i,n),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...r)=>e.check(Zn(...r)),e.nonempty=r=>e.check(Zn(1,r)),e.max=(...r)=>e.check(ua(...r)),e.size=(...r)=>e.check(po(...r))});function HN(e,t,r){return new t0({type:"map",keyType:e,valueType:t,...j.normalizeParams(r)})}var r0=k("ZodSet",(e,t)=>{pv.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Fb(e,r,i,n),e.min=(...r)=>e.check(Zn(...r)),e.nonempty=r=>e.check(Zn(1,r)),e.max=(...r)=>e.check(ua(...r)),e.size=(...r)=>e.check(po(...r))});function GN(e,t){return new r0({type:"set",valueType:e,...j.normalizeParams(t)})}var dc=k("ZodEnum",(e,t)=>{mv.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(i,n,a)=>Ob(e,i,n,a),e.enum=t.entries,e.options=Object.values(t.entries);let r=new Set(Object.keys(t.entries));e.extract=(i,n)=>{let a={};for(let o of i)if(r.has(o))a[o]=t.entries[o];else throw new Error(`Key ${o} not found in enum`);return new dc({...t,checks:[],...j.normalizeParams(n),entries:a})},e.exclude=(i,n)=>{let a={...t.entries};for(let o of i)if(r.has(o))delete a[o];else throw new Error(`Key ${o} not found in enum`);return new dc({...t,checks:[],...j.normalizeParams(n),entries:a})}});function Mm(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(i=>[i,i])):e;return new dc({type:"enum",entries:r,...j.normalizeParams(t)})}function WN(e,t){return new dc({type:"enum",entries:e,...j.normalizeParams(t)})}var n0=k("ZodLiteral",(e,t)=>{hv.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Pb(e,r,i,n),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function JN(e,t){return new n0({type:"literal",values:Array.isArray(e)?e:[e],...j.normalizeParams(t)})}var i0=k("ZodFile",(e,t)=>{gv.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Mb(e,r,i,n),e.min=(r,i)=>e.check(Zn(r,i)),e.max=(r,i)=>e.check(ua(r,i)),e.mime=(r,i)=>e.check(Rs(Array.isArray(r)?r:[r],i))});function KN(e){return db(i0,e)}var a0=k("ZodTransform",(e,t)=>{_v.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Ub(e,r,i,n),e._zod.parse=(r,i)=>{if(i.direction==="backward")throw new na(e.constructor.name);r.addIssue=a=>{if(typeof a=="string")r.issues.push(j.issue(a,r.value,t));else{let o=a;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=r.value),o.inst??(o.inst=e),r.issues.push(j.issue(o))}};let n=t.transform(r.value,r);return n instanceof Promise?n.then(a=>(r.value=a,r.fallback=!0,r)):(r.value=n,r.fallback=!0,r)}});function jm(e){return new a0({type:"transform",transform:e})}var zm=k("ZodOptional",(e,t)=>{fo.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,i,n)=>pp(e,r,i,n),e.unwrap=()=>e._zod.def.innerType});function du(e){return new zm({type:"optional",innerType:e})}var o0=k("ZodExactOptional",(e,t)=>{yv.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,i,n)=>pp(e,r,i,n),e.unwrap=()=>e._zod.def.innerType});function s0(e){return new o0({type:"optional",innerType:e})}var c0=k("ZodNullable",(e,t)=>{vv.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Wb(e,r,i,n),e.unwrap=()=>e._zod.def.innerType});function fu(e){return new c0({type:"nullable",innerType:e})}function qN(e){return du(fu(e))}var l0=k("ZodDefault",(e,t)=>{bv.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Kb(e,r,i,n),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function u0(e,t){return new l0({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():j.shallowClone(t)}})}var d0=k("ZodPrefault",(e,t)=>{wv.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,i,n)=>qb(e,r,i,n),e.unwrap=()=>e._zod.def.innerType});function f0(e,t){return new d0({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():j.shallowClone(t)}})}var Dm=k("ZodNonOptional",(e,t)=>{xv.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Jb(e,r,i,n),e.unwrap=()=>e._zod.def.innerType});function p0(e,t){return new Dm({type:"nonoptional",innerType:e,...j.normalizeParams(t)})}var m0=k("ZodSuccess",(e,t)=>{Sv.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,i,n)=>jb(e,r,i,n),e.unwrap=()=>e._zod.def.innerType});function XN(e){return new m0({type:"success",innerType:e})}var h0=k("ZodCatch",(e,t)=>{kv.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Xb(e,r,i,n),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function g0(e,t){return new h0({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}var _0=k("ZodNaN",(e,t)=>{$v.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Nb(e,r,i,n)});function YN(e){return lb(_0,e)}var vu=k("ZodPipe",(e,t)=>{Rf.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Yb(e,r,i,n),e.in=t.in,e.out=t.out});function mm(e,t){return new vu({type:"pipe",in:e,out:t})}var bu=k("ZodCodec",(e,t)=>{vu.init(e,t),kl.init(e,t)});function QN(e,t,r){return new bu({type:"pipe",in:e,out:t,transform:r.decode,reverseTransform:r.encode})}function e1(e){let t=e._zod.def;return new bu({type:"pipe",in:t.out,out:t.in,transform:t.reverseTransform,reverseTransform:t.transform})}var y0=k("ZodPreprocess",(e,t)=>{vu.init(e,t),Ev.init(e,t)}),v0=k("ZodReadonly",(e,t)=>{Iv.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Qb(e,r,i,n),e.unwrap=()=>e._zod.def.innerType});function b0(e){return new v0({type:"readonly",innerType:e})}var w0=k("ZodTemplateLiteral",(e,t)=>{Tv.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Rb(e,r,i,n)});function t1(e,t){return new w0({type:"template_literal",parts:e,...j.normalizeParams(t)})}var x0=k("ZodLazy",(e,t)=>{Ov.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,i,n)=>tw(e,r,i,n),e.unwrap=()=>e._zod.def.getter()});function S0(e){return new x0({type:"lazy",getter:e})}var k0=k("ZodPromise",(e,t)=>{Av.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,i,n)=>ew(e,r,i,n),e.unwrap=()=>e._zod.def.innerType});function r1(e){return new k0({type:"promise",innerType:e})}var $0=k("ZodFunction",(e,t)=>{Cv.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Db(e,r,i,n)});function n1(e){return new $0({type:"function",input:Array.isArray(e?.input)?Qx(e?.input):e?.input??gu(Do()),output:e?.output??Do()})}var wu=k("ZodCustom",(e,t)=>{Pv.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,i,n)=>zb(e,r,i,n)});function i1(e){let t=new Le({check:"custom"});return t._zod.check=e,t}function a1(e,t){return fb(wu,e??(()=>!0),t)}function E0(e,t={}){return pb(wu,e,t)}function I0(e,t){return mb(e,t)}var o1=hb,s1=gb;function c1(e,t={}){let r=new wu({type:"custom",check:"custom",fn:i=>i instanceof e,abort:!0,...j.normalizeParams(t)});return r._zod.bag.Class=e,r._zod.check=i=>{i.value instanceof e||i.issues.push({code:"invalid_type",expected:e.name,input:i.value,inst:r,path:[...r._zod.def.path??[]]})},r}var l1=(...e)=>_b({Codec:bu,Boolean:hc,String:fc},...e);function u1(e){let t=S0(()=>Rm([lu(e),zx(),Dx(),Bx(),gu(t),e0(lu(),t)]));return t}function d1(e,t){return new y0({type:"pipe",in:jm(e),out:t})}var cB={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};function lB(e){it({customError:e})}function uB(){return it().customError}var T0;T0||(T0={});var W={...cu,...cm,iso:lc},dB=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"]);function fB(e,t){let r=e.$schema;return r==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":r==="http://json-schema.org/draft-07/schema#"?"draft-7":r==="http://json-schema.org/draft-04/schema#"?"draft-4":t??"draft-2020-12"}function pB(e,t){if(!e.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");let r=e.slice(1).split("/").filter(Boolean);if(r.length===0)return t.rootSchema;let i=t.version==="draft-2020-12"?"$defs":"definitions";if(r[0]===i){let n=r[1];if(!n||!t.defs[n])throw new Error(`Reference not found: ${e}`);return t.defs[n]}throw new Error(`Reference not found: ${e}`)}function f1(e,t){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return W.never();throw new Error("not is not supported in Zod (except { not: {} } for never)")}if(e.unevaluatedItems!==void 0)throw new Error("unevaluatedItems is not supported");if(e.unevaluatedProperties!==void 0)throw new Error("unevaluatedProperties is not supported");if(e.if!==void 0||e.then!==void 0||e.else!==void 0)throw new Error("Conditional schemas (if/then/else) are not supported");if(e.dependentSchemas!==void 0||e.dependentRequired!==void 0)throw new Error("dependentSchemas and dependentRequired are not supported");if(e.$ref){let n=e.$ref;if(t.refs.has(n))return t.refs.get(n);if(t.processing.has(n))return W.lazy(()=>{if(!t.refs.has(n))throw new Error(`Circular reference not resolved: ${n}`);return t.refs.get(n)});t.processing.add(n);let a=pB(n,t),o=Wt(a,t);return t.refs.set(n,o),t.processing.delete(n),o}if(e.enum!==void 0){let n=e.enum;if(t.version==="openapi-3.0"&&e.nullable===!0&&n.length===1&&n[0]===null)return W.null();if(n.length===0)return W.never();if(n.length===1)return W.literal(n[0]);if(n.every(o=>typeof o=="string"))return W.enum(n);let a=n.map(o=>W.literal(o));return a.length<2?a[0]:W.union([a[0],a[1],...a.slice(2)])}if(e.const!==void 0)return W.literal(e.const);let r=e.type;if(Array.isArray(r)){let n=r.map(a=>{let o={...e,type:a};return f1(o,t)});return n.length===0?W.never():n.length===1?n[0]:W.union(n)}if(!r)return W.any();let i;switch(r){case"string":{let n=W.string();if(e.format){let a=e.format;a==="email"?n=n.check(W.email()):a==="uri"||a==="uri-reference"?n=n.check(W.url()):a==="uuid"||a==="guid"?n=n.check(W.uuid()):a==="date-time"?n=n.check(W.iso.datetime()):a==="date"?n=n.check(W.iso.date()):a==="time"?n=n.check(W.iso.time()):a==="duration"?n=n.check(W.iso.duration()):a==="ipv4"?n=n.check(W.ipv4()):a==="ipv6"?n=n.check(W.ipv6()):a==="mac"?n=n.check(W.mac()):a==="cidr"?n=n.check(W.cidrv4()):a==="cidr-v6"?n=n.check(W.cidrv6()):a==="base64"?n=n.check(W.base64()):a==="base64url"?n=n.check(W.base64url()):a==="e164"?n=n.check(W.e164()):a==="jwt"?n=n.check(W.jwt()):a==="emoji"?n=n.check(W.emoji()):a==="nanoid"?n=n.check(W.nanoid()):a==="cuid"?n=n.check(W.cuid()):a==="cuid2"?n=n.check(W.cuid2()):a==="ulid"?n=n.check(W.ulid()):a==="xid"?n=n.check(W.xid()):a==="ksuid"&&(n=n.check(W.ksuid()))}typeof e.minLength=="number"&&(n=n.min(e.minLength)),typeof e.maxLength=="number"&&(n=n.max(e.maxLength)),e.pattern&&(n=n.regex(new RegExp(e.pattern))),i=n;break}case"number":case"integer":{let n=r==="integer"?W.number().int():W.number();typeof e.minimum=="number"&&(n=n.min(e.minimum)),typeof e.maximum=="number"&&(n=n.max(e.maximum)),typeof e.exclusiveMinimum=="number"?n=n.gt(e.exclusiveMinimum):e.exclusiveMinimum===!0&&typeof e.minimum=="number"&&(n=n.gt(e.minimum)),typeof e.exclusiveMaximum=="number"?n=n.lt(e.exclusiveMaximum):e.exclusiveMaximum===!0&&typeof e.maximum=="number"&&(n=n.lt(e.maximum)),typeof e.multipleOf=="number"&&(n=n.multipleOf(e.multipleOf)),i=n;break}case"boolean":{i=W.boolean();break}case"null":{i=W.null();break}case"object":{let n={},a=e.properties||{},o=new Set(e.required||[]);for(let[c,l]of Object.entries(a)){let u=Wt(l,t);n[c]=o.has(c)?u:u.optional()}if(e.propertyNames){let c=Wt(e.propertyNames,t),l=e.additionalProperties&&typeof e.additionalProperties=="object"?Wt(e.additionalProperties,t):W.any();if(Object.keys(n).length===0){i=W.record(c,l);break}let u=W.object(n).passthrough(),d=W.looseRecord(c,l);i=W.intersection(u,d);break}if(e.patternProperties){let c=e.patternProperties,l=Object.keys(c),u=[];for(let f of l){let p=Wt(c[f],t),m=W.string().regex(new RegExp(f));u.push(W.looseRecord(m,p))}let d=[];if(Object.keys(n).length>0&&d.push(W.object(n).passthrough()),d.push(...u),d.length===0)i=W.object({}).passthrough();else if(d.length===1)i=d[0];else{let f=W.intersection(d[0],d[1]);for(let p=2;p<d.length;p++)f=W.intersection(f,d[p]);i=f}break}let s=W.object(n);e.additionalProperties===!1?i=s.strict():typeof e.additionalProperties=="object"?i=s.catchall(Wt(e.additionalProperties,t)):i=s.passthrough();break}case"array":{let n=e.prefixItems,a=e.items;if(n&&Array.isArray(n)){let o=n.map(c=>Wt(c,t)),s=a&&typeof a=="object"&&!Array.isArray(a)?Wt(a,t):void 0;s?i=W.tuple(o).rest(s):i=W.tuple(o),typeof e.minItems=="number"&&(i=i.check(W.minLength(e.minItems))),typeof e.maxItems=="number"&&(i=i.check(W.maxLength(e.maxItems)))}else if(Array.isArray(a)){let o=a.map(c=>Wt(c,t)),s=e.additionalItems&&typeof e.additionalItems=="object"?Wt(e.additionalItems,t):void 0;s?i=W.tuple(o).rest(s):i=W.tuple(o),typeof e.minItems=="number"&&(i=i.check(W.minLength(e.minItems))),typeof e.maxItems=="number"&&(i=i.check(W.maxLength(e.maxItems)))}else if(a!==void 0){let o=Wt(a,t),s=W.array(o);typeof e.minItems=="number"&&(s=s.min(e.minItems)),typeof e.maxItems=="number"&&(s=s.max(e.maxItems)),i=s}else i=W.array(W.any());break}default:throw new Error(`Unsupported type: ${r}`)}return i}function Wt(e,t){if(typeof e=="boolean")return e?W.any():W.never();let r=f1(e,t),i=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){let s=e.anyOf.map(l=>Wt(l,t)),c=W.union(s);r=i?W.intersection(r,c):c}if(e.oneOf&&Array.isArray(e.oneOf)){let s=e.oneOf.map(l=>Wt(l,t)),c=W.xor(s);r=i?W.intersection(r,c):c}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)r=i?r:W.any();else{let s=i?r:Wt(e.allOf[0],t),c=i?0:1;for(let l=c;l<e.allOf.length;l++)s=W.intersection(s,Wt(e.allOf[l],t));r=s}e.nullable===!0&&t.version==="openapi-3.0"&&(r=W.nullable(r)),e.readOnly===!0&&(r=W.readonly(r)),e.default!==void 0&&(r=r.default(e.default));let n={},a=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let s of a)s in e&&(n[s]=e[s]);let o=["contentEncoding","contentMediaType","contentSchema"];for(let s of o)s in e&&(n[s]=e[s]);for(let s of Object.keys(e))dB.has(s)||(n[s]=e[s]);return Object.keys(n).length>0&&t.registry.add(r,n),e.description&&(r=r.describe(e.description)),r}function p1(e,t){if(typeof e=="boolean")return e?W.any():W.never();let r;try{r=JSON.parse(JSON.stringify(e))}catch{throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas")}let i=fB(r,t?.defaultTarget),n=r.$defs||r.definitions||{},a={version:i,defs:n,refs:new Map,processing:new Set,rootSchema:r,registry:t?.registry??Ne};return Wt(r,a)}var C0={};Tn(C0,{bigint:()=>_B,boolean:()=>gB,date:()=>yB,number:()=>hB,string:()=>mB});function mB(e){return jv(fc,e)}function hB(e){return Zv(mc,e)}function gB(e){return Xv(hc,e)}function _B(e){return Qv(gc,e)}function yB(e){return cb(hu,e)}it(Mf());var m1=T({BaseToolkit:()=>vB,DynamicStructuredTool:()=>_1,DynamicTool:()=>g1,StructuredTool:()=>xu,Tool:()=>h1,ToolInputParsingException:()=>rs,isLangChainTool:()=>su,isRunnableToolLike:()=>au,isStructuredTool:()=>iu,isStructuredToolParams:()=>ou,tool:()=>bB}),xu=class extends Hp{extras;returnDirect=!1;verboseParsingErrors=!1;get lc_namespace(){return["langchain","tools"]}responseFormat="content";defaultConfig;constructor(e){super(e??{}),this.verboseParsingErrors=e?.verboseParsingErrors??this.verboseParsingErrors,this.responseFormat=e?.responseFormat??this.responseFormat,this.defaultConfig=e?.defaultConfig??this.defaultConfig,this.metadata=e?.metadata??this.metadata,this.extras=e?.extras??this.extras}async invoke(e,t){let r,i=we(vt(this.defaultConfig,t));return Gi(e)?(r=e.args,i={...i,toolCall:e}):r=e,this.call(r,i)}async call(e,t,r){let i=Gi(e)?e.args:e,n;if(gr(this.schema))try{n=await ma(this.schema,i)}catch(p){let m="Received tool input did not match expected schema";throw this.verboseParsingErrors&&(m=`${m}
398
- Details: ${p.message}`),bp(p)&&(m=`${m}
399
-
400
- ${Xr.prettifyError(p)}`),new rs(m,JSON.stringify(e))}else{let p=Ze(i,this.schema);if(!p.valid){let m="Received tool input did not match expected schema";throw this.verboseParsingErrors&&(m=`${m}
401
- Details: ${p.errors.map(h=>`${h.keywordLocation}: ${h.error}`).join(`
402
- `)}`),new rs(m,JSON.stringify(e))}n=i}let a=to(t),o=et.configure(a.callbacks,this.callbacks,a.tags||r,this.tags,a.metadata,this.metadata,{verbose:this.verbose}),s;Gi(e)&&(s=e.id),!s&&Fk(a)&&(s=a.toolCall.id);let c=await o?.handleToolStart(this.toJSON(),typeof e=="string"?e:JSON.stringify(e),a.runId,void 0,void 0,void 0,a.runName,s);delete a.runId;let l;try{let p=await this._call(n,c,a);l=_w(p)?await FA(p,async m=>{try{await c?.handleToolEvent(m)}catch(h){await c?.handleToolError(h)}}):p}catch(p){throw await c?.handleToolError(p),p}let u,d;if(this.responseFormat==="content_and_artifact")if(Array.isArray(l)&&l.length===2)[u,d]=l;else throw new Error(`Tool response format is "content_and_artifact" but the output was not a two-tuple.
403
- Result: ${JSON.stringify(l)}`);else u=l;let f=wB({content:u,artifact:d,toolCallId:s,name:this.name,metadata:this.metadata});return await c?.handleToolEnd(f),f}},h1=class extends xu{schema=It.object({input:It.string().optional()}).transform(e=>e.input);constructor(e){super(e)}call(e,t){let r=typeof e=="string"||e==null?{input:e}:e;return super.call(r,t)}},g1=class extends h1{static lc_name(){return"DynamicTool"}name;description;func;constructor(e){super(e),this.name=e.name,this.description=e.description,this.func=e.func,this.returnDirect=e.returnDirect??this.returnDirect}async call(e,t){let r=to(t);return r.runName===void 0&&(r.runName=this.name),super.call(e,r)}_call(e,t,r){return this.func(e,t,r)}},_1=class extends xu{static lc_name(){return"DynamicStructuredTool"}description;func;schema;constructor(e){super(e),this.name=e.name,this.description=e.description,this.func=e.func,this.returnDirect=e.returnDirect??this.returnDirect,this.schema=e.schema}async call(e,t,r){let i=to(t);return i.runName===void 0&&(i.runName=this.name),super.call(e,i,r)}_call(e,t,r){return this.func(e,t,r)}},vB=class{getTools(){return this.tools}};function bB(e,t){let r=Vs(t.schema),i=Ys(t.schema);if(!t.schema||r||i)return new g1({...t,description:t.description??t.schema?.description??`${t.name} tool`,func:async(o,s,c)=>new Promise((l,u)=>{let d=Se(c,{callbacks:s?.getChild()});Ae.runWithConfig(pr(d),async()=>{try{l(e(o,d))}catch(f){u(f)}})})});let n=t.schema,a=t.description??t.schema.description??`${t.name} tool`;return new _1({...t,description:a,schema:n,func:async(o,s,c)=>new Promise((l,u)=>{let d,f=()=>{c?.signal&&d&&c.signal.removeEventListener("abort",d)};c?.signal&&(d=()=>{f(),u(Yi(c.signal))},c.signal.addEventListener("abort",d,{once:!0}));let p=Se(c,{callbacks:s?.getChild()});Ae.runWithConfig(pr(p),async()=>{try{let m=await e(o,p);if(_w(m)){l(m);return}if(c?.signal?.aborted){f();return}f(),l(m)}catch(m){f(),u(m)}})})})}function wB(e){let{content:t,artifact:r,toolCallId:i,metadata:n}=e;return i&&!Hc(t)?typeof t=="string"||Array.isArray(t)&&t.every(a=>typeof a=="object")?new _t({status:"success",content:t,artifact:r,tool_call_id:i,name:e.name,metadata:n}):new _t({status:"success",content:xB(t),artifact:r,tool_call_id:i,name:e.name,metadata:n}):t}function xB(e){try{return JSON.stringify(e)??""}catch{return`${e}`}}var y1=T({RunCollectorCallbackHandler:()=>SB}),SB=class extends Ot{name="run_collector";exampleId;tracedRuns;constructor({exampleId:e}={}){super({_awaitHandler:!0}),this.exampleId=e,this.tracedRuns=[]}async persistRun(e){let t={...e};t.reference_example_id=this.exampleId,this.tracedRuns.push(t)}};var v1=T({});var b1=T({chunkArray:()=>kB}),kB=(e,t)=>e.reduce((r,i,n)=>{let a=Math.floor(n/t);return r[a]=(r[a]||[]).concat([i]),r},[]);var w1=T({context:()=>$B});function $B(e,...t){let r=e.raw,i="";for(let n=0;n<r.length;n++){let a=r[n].replace(/\\\n[ \t]*/g,"").replace(/\\`/g,"`").replace(/\\\$/g,"$").replace(/\\\{/g,"{");if(i+=a,n<t.length){let o=EB(t[n],i);i+=typeof o=="string"?o:JSON.stringify(o)}}return i=IB(i),i=i.trim(),i=i.replace(/\\n/g,`
404
- `),i}function EB(e,t){if(typeof e!="string"||!e.includes(`
405
- `))return e;let r=t.slice(t.lastIndexOf(`
406
- `)+1).match(/^(\s+)/);if(r){let i=r[1];return e.replace(/\n/g,`
407
- ${i}`)}return e}function IB(e){let t=e.split(`
408
- `),r=null;for(let i of t){let n=i.match(/^(\s+)\S+/);if(n){let a=n[1].length;r===null?r=a:r=Math.min(r,a)}}return r===null?e:t.map(i=>i[0]===" "||i[0]===" "?i.slice(r):i).join(`
409
- `)}var x1=T({EventStreamContentType:()=>TB,convertEventStreamToIterableReadableDataStream:()=>AB,getBytes:()=>S1,getLines:()=>k1,getMessages:()=>$1}),TB="text/event-stream";async function S1(e,t){if(e instanceof ReadableStream){let r=e.getReader();for(;;){let i=await r.read();if(i.done){t(new Uint8Array,!0);break}t(i.value)}}else try{for await(let r of e)t(new Uint8Array(r));t(new Uint8Array,!0)}catch(r){throw new Error(["Parsing event source stream failed.","Ensure your implementation of fetch returns a web or Node readable stream.",`Error: ${r.message}`].join(`
410
- `))}}function k1(e){let t,r,i,n=!1;return function(o,s){if(s){e(o,0,!0);return}t===void 0?(t=o,r=0,i=-1):t=CB(t,o);let c=t.length,l=0;for(;r<c;){n&&(t[r]===10&&(l=++r),n=!1);let u=-1;for(;r<c&&u===-1;++r)switch(t[r]){case 58:i===-1&&(i=r-l);break;case 13:n=!0;case 10:u=r;break}if(u===-1)break;e(t.subarray(l,u),i),l=r,i=-1}l===c?t=void 0:l!==0&&(t=t.subarray(l),r-=l)}}function $1(e,t,r){let i=A0(),n=new TextDecoder;return function(o,s,c){if(c){OB(i)||(e?.(i),i=A0());return}if(o.length===0)e?.(i),i=A0();else if(s>0){let l=n.decode(o.subarray(0,s)),u=s+(o[s+1]===32?2:1),d=n.decode(o.subarray(u));switch(l){case"data":i.data=i.data?i.data+`
411
- `+d:d;break;case"event":i.event=d;break;case"id":t?.(i.id=d);break;case"retry":{let f=parseInt(d,10);Number.isNaN(f)||r?.(i.retry=f);break}}}}}function CB(e,t){let r=new Uint8Array(e.length+t.length);return r.set(e),r.set(t,e.length),r}function A0(){return{data:"",event:"",id:"",retry:void 0}}function AB(e,t){let r=new ReadableStream({async start(i){let n=$1(o=>{if(o.event==="error")throw new Error(o.data??"Unspecified event streaming error.");o.event==="metadata"?t?.(o):o.data&&i.enqueue(o.data)});await S1(e,k1((o,s,c)=>{n(o,s,c),c&&i.close()}))}});return dt.fromReadableStream(r)}function OB(e){return e.data===""&&e.event===""&&e.id===""&&e.retry===void 0}var E1=T({});var I1=T({convertToOpenAIFunction:()=>T1,convertToOpenAITool:()=>PB,isLangChainTool:()=>su,isRunnableToolLike:()=>au,isStructuredTool:()=>iu,isStructuredToolParams:()=>ou});function T1(e,t){let r=typeof t=="number"?void 0:t;return{name:e.name,description:e.description,parameters:bt(e.schema),...r?.strict!==void 0?{strict:r.strict}:{}}}function PB(e,t){let r=typeof t=="number"?void 0:t,i;return su(e)?i={type:"function",function:T1(e)}:i=e,r?.strict!==void 0&&(i.function.strict=r.strict),i}function Um(e,t){let r=0,i=0,n=0;for(let a=0;a<e.length;a++)r+=e[a]*t[a],i+=e[a]*e[a],n+=t[a]*t[a];return r/(Math.sqrt(i)*Math.sqrt(n))}function C1(e,t){let r=0;for(let i=0;i<e.length;i++)r+=e[i]*t[i];return r}function NB(e,t){let r=0;for(let i=0;i<e.length;i++)r+=(e[i]-t[i])*(e[i]-t[i]);return r}function A1(e,t){return Math.sqrt(NB(e,t))}var O1=T({cosineSimilarity:()=>O0,euclideanDistance:()=>jB,innerProduct:()=>MB,matrixFunc:()=>Lm,maximalMarginalRelevance:()=>zB,normalize:()=>RB});function Lm(e,t,r){if(e.length===0||e[0].length===0||t.length===0||t[0].length===0)return[[]];if(e[0].length!==t[0].length)throw new Error(`Number of columns in X and Y must be the same. X has shape ${[e.length,e[0].length]} and Y has shape ${[t.length,t[0].length]}.`);return e.map(i=>t.map(n=>r(i,n)).map(n=>Number.isNaN(n)?0:n))}function RB(e,t=!1){let r=DB(e);return e.map(i=>i.map(n=>t?1-n/r:n/r))}function O0(e,t){return Lm(e,t,Um)}function MB(e,t){return Lm(e,t,C1)}function jB(e,t){return Lm(e,t,A1)}function zB(e,t,r=.5,i=4){if(Math.min(i,t.length)<=0)return[];let n=O0(Array.isArray(e[0])?e:[e],t)[0],a=P1(n).maxIndex,o=[t[a]],s=[a];for(;s.length<Math.min(i,t.length);){let c=-1/0,l=-1,u=O0(t,o);n.forEach((d,f)=>{if(s.includes(f))return;let p=Math.max(...u[f]),m=r*d-(1-r)*p;m>c&&(c=m,l=f)}),o.push(t[l]),s.push(l)}return s}function P1(e){if(e.length===0)return{maxIndex:-1,maxValue:NaN};let t=e[0],r=0;for(let i=1;i<e.length;i+=1)e[i]>t&&(r=i,t=e[i]);return{maxIndex:r,maxValue:t}}function DB(e){return e.reduce((t,r)=>Math.max(t,P1(r).maxValue),0)}var N1=T({isCloudMetadata:()=>P0,isLocalhost:()=>N0,isPrivateIp:()=>D1,isSafeUrl:()=>GB,isSameOrigin:()=>WB,validateSafeUrl:()=>U1}),UB=["10.0.0.0/8","172.16.0.0/12","192.168.0.0/16","127.0.0.0/8","169.254.0.0/16","0.0.0.0/8","::1/128","fc00::/7","fe80::/10","ff00::/8"],LB=["169.254.169.254","169.254.170.2","100.100.100.200"],FB=["metadata.google.internal","metadata","instance-data"],BB=["localhost","localhost.localdomain"],VB=/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/;function R1(e){return VB.test(e)}function Fm(e){return z1(e)!==null}function M1(e){return R1(e)||Fm(e)}function j1(e){if(R1(e))return e.split(".").map(t=>parseInt(t,10));if(Fm(e)){let t=z1(e);if(!t)return null;let r=t.split(":"),i=[];for(let n of r)i.push(parseInt(n,16));return i}return null}function z1(e){if(!e||typeof e!="string"||!e.includes(":")||!/^[0-9a-fA-F:]+$/.test(e))return null;let t=e;if(t.includes("::")){let i=t.split("::");if(i.length>2)return null;let[n,a]=i,o=n?n.split(":"):[],s=a?a.split(":"):[],c=8-(o.length+s.length);if(c<0)return null;let l=Array(c).fill("0");t=[...o,...l,...s].filter(u=>u!=="").join(":")}let r=t.split(":");if(r.length!==8)return null;for(let i of r)if(i.length===0||i.length>4||!/^[0-9a-fA-F]+$/.test(i))return null;return r.map(i=>i.padStart(4,"0").toLowerCase()).join(":")}function ZB(e){let[t,r]=e.split("/");if(!t||!r)return null;let i=j1(t);if(!i)return null;let n=parseInt(r,10);if(isNaN(n))return null;let a=Fm(t);return a&&n>128||!a&&n>32?null:{addr:i,prefixLen:n,isIpv6:a}}function HB(e,t){let r=j1(e);if(!r)return!1;let i=ZB(t);if(!i)return!1;let n=Fm(e);if(n!==i.isIpv6)return!1;let{addr:a,prefixLen:o}=i;if(n)for(let s=0;s<Math.ceil(o/16);s++){let c=65535<<16-Math.min(16,o-s*16)&65535;if((r[s]&c)!==(a[s]&c))return!1}else for(let s=0;s<Math.ceil(o/8);s++){let c=255<<8-Math.min(8,o-s*8)&255;if((r[s]&c)!==(a[s]&c))return!1}return!0}function D1(e){if(!M1(e))return!1;for(let t of UB)if(HB(e,t))return!0;return!1}function P0(e,t){if(LB.includes(t||""))return!0;let r=e.toLowerCase();return!!FB.includes(r)}function N0(e,t){if(t&&(t==="127.0.0.1"||t==="::1"||t==="0.0.0.0"||t.startsWith("127.")))return!0;let r=e.toLowerCase();return!!BB.includes(r)}function U1(e,t){let r=t?.allowPrivate??!1,i=t?.allowHttp??!1;try{let n;try{n=new URL(e)}catch{throw new Error(`Invalid URL: ${e}`)}let a=n.hostname;if(!a)throw new Error("URL missing hostname.");if(P0(a))throw new Error(`URL points to cloud metadata endpoint: ${a}`);if(N0(a)){if(!r)throw new Error(`URL points to localhost: ${a}`);return e}let o=n.protocol;if(o!=="http:"&&o!=="https:")throw new Error(`Invalid URL scheme: ${o}. Only http and https are allowed.`);if(o==="http:"&&!i)throw new Error("HTTP scheme not allowed. Use HTTPS or set allowHttp: true.");if(M1(a)){let s=a;if(N0(a,s)){if(!r)throw new Error(`URL points to localhost: ${a}`);return e}if(P0(a,s))throw new Error(`URL resolves to cloud metadata IP: ${s} (${a})`);if(D1(s)&&!r)throw new Error(`URL resolves to private IP: ${s} (${a}). Set allowPrivate: true to allow.`);return e}return e}catch(n){throw n&&typeof n=="object"&&"message"in n?n:new Error(`URL validation failed: ${n}`)}}function GB(e,t){try{return U1(e,t),!0}catch{return!1}}function WB(e,t){try{return new URL(e).origin===new URL(t).origin}catch{return!1}}var L1=T({SaveableVectorStore:()=>JB,VectorStore:()=>Vm,VectorStoreRetriever:()=>Bm}),Bm=class extends tu{static lc_name(){return"VectorStoreRetriever"}get lc_namespace(){return["langchain_core","vectorstores"]}vectorStore;k=4;searchType="similarity";searchKwargs;filter;_vectorstoreType(){return this.vectorStore._vectorstoreType()}constructor(e){super(e),this.vectorStore=e.vectorStore,this.k=e.k??this.k,this.searchType=e.searchType??this.searchType,this.filter=e.filter,e.searchType==="mmr"&&(this.searchKwargs=e.searchKwargs)}async _getRelevantDocuments(e,t){if(this.searchType==="mmr"){if(typeof this.vectorStore.maxMarginalRelevanceSearch!="function")throw new Error(`The vector store backing this retriever, ${this._vectorstoreType()} does not support max marginal relevance search.`);return this.vectorStore.maxMarginalRelevanceSearch(e,{k:this.k,filter:this.filter,...this.searchKwargs},t?.getChild("vectorstore"))}return this.vectorStore.similaritySearch(e,this.k,this.filter,t?.getChild("vectorstore"))}async addDocuments(e,t){return this.vectorStore.addDocuments(e,t)}},Vm=class extends lt{lc_namespace=["langchain","vectorstores",this._vectorstoreType()];embeddings;constructor(e,t){super(t),this.embeddings=e}async delete(e){throw new Error("Not implemented.")}async similaritySearch(e,t=4,r=void 0,i=void 0){return(await this.similaritySearchVectorWithScore(await this.embeddings.embedQuery(e),t,r)).map(n=>n[0])}async similaritySearchWithScore(e,t=4,r=void 0,i=void 0){return this.similaritySearchVectorWithScore(await this.embeddings.embedQuery(e),t,r)}static fromTexts(e,t,r,i){throw new Error("the Langchain vectorstore implementation you are using forgot to override this, please report a bug")}static fromDocuments(e,t,r){throw new Error("the Langchain vectorstore implementation you are using forgot to override this, please report a bug")}asRetriever(e,t,r,i,n,a){if(typeof e=="number")return new Bm({vectorStore:this,k:e,filter:t,tags:[...i??[],this._vectorstoreType()],metadata:n,verbose:a,callbacks:r});{let o={vectorStore:this,k:e?.k,filter:e?.filter,tags:[...e?.tags??[],this._vectorstoreType()],metadata:e?.metadata,verbose:e?.verbose,callbacks:e?.callbacks,searchType:e?.searchType};return e?.searchType==="mmr"?new Bm({...o,searchKwargs:e.searchKwargs}):new Bm({...o})}}},JB=class extends Vm{static load(e,t){throw new Error("Not implemented")}};var F1=class extends Sa{_combineLLMOutput(){return[]}_llmType(){return"fake"}async _generate(e,t,r){if(t?.stop?.length)return{generations:[{message:new Ce(t.stop[0]),text:t.stop[0]}]};let i=e.map(n=>typeof n.content=="string"?n.content:JSON.stringify(n.content,null,2)).join(`
412
- `);return await r?.handleLLMNewToken(i),{generations:[{message:new Ce(i),text:i}],llmOutput:{}}}},B1=class V1 extends Sa{sleep=50;responses=[];chunks=[];toolStyle="openai";thrownErrorString;tools=[];constructor({sleep:t=50,responses:r=[],chunks:i=[],toolStyle:n="openai",thrownErrorString:a,...o}){super(o),this.sleep=t,this.responses=r,this.chunks=i,this.toolStyle=n,this.thrownErrorString=a}_llmType(){return"fake"}bindTools(t){let r=[...this.tools,...t],i=r.map(o=>{switch(this.toolStyle){case"openai":return{type:"function",function:{name:o.name,description:o.description,parameters:bt(o.schema)}};case"anthropic":return{name:o.name,description:o.description,input_schema:bt(o.schema)};case"bedrock":return{toolSpec:{name:o.name,description:o.description,inputSchema:bt(o.schema)}};case"google":return{name:o.name,description:o.description,parameters:bt(o.schema)};default:throw new Error(`Unsupported tool style: ${this.toolStyle}`)}}),n=this.toolStyle==="google"?[{functionDeclarations:i}]:i,a=new V1({sleep:this.sleep,responses:this.responses,chunks:this.chunks,toolStyle:this.toolStyle,thrownErrorString:this.thrownErrorString});return a.tools=r,a.withConfig({tools:n})}async _generate(t,r,i){if(this.thrownErrorString)throw new Error(this.thrownErrorString);return{generations:[{text:"",message:new Ce({content:this.responses?.[0]?.content??t[0].content??"",tool_calls:this.chunks?.[0]?.tool_calls})}]}}async*_streamResponseChunks(t,r,i){if(this.thrownErrorString)throw new Error(this.thrownErrorString);if(this.chunks?.length){for(let o of this.chunks){let s=new ra({message:new Qe({content:o.content,tool_calls:o.tool_calls,additional_kwargs:o.additional_kwargs??{}}),text:o.content?.toString()??""});if(r.signal?.aborted)break;yield s,await i?.handleLLMNewToken(o.content,void 0,void 0,void 0,void 0,{chunk:s})}return}let n=this.responses?.[0]??new Ce(typeof t[0].content=="string"?t[0].content:""),a=typeof n.content=="string"?n.content:"";for(let o of a){await new Promise(c=>setTimeout(c,this.sleep));let s=new ra({message:new Qe({content:o}),text:o});if(r.signal?.aborted)break;yield s,await i?.handleLLMNewToken(o,void 0,void 0,void 0,void 0,{chunk:s})}}},Z1=class H1 extends Sa{static lc_name(){return"FakeListChatModel"}lc_serializable=!0;responses;i=0;sleep;emitCustomEvent=!1;generationInfo;tools=[];toolStyle="openai";constructor(t){super(t);let{responses:r,sleep:i,emitCustomEvent:n,generationInfo:a}=t;this.responses=r,this.sleep=i,this.emitCustomEvent=n??this.emitCustomEvent,this.generationInfo=a}_combineLLMOutput(){return[]}_llmType(){return"fake-list"}async _generate(t,r,i){if(await this._sleepIfRequested(),r?.thrownErrorString)throw new Error(r.thrownErrorString);if(this.emitCustomEvent&&await i?.handleCustomEvent("some_test_event",{someval:!0}),r?.stop?.length)return{generations:[this._formatGeneration(r.stop[0])]};{let n=this._currentResponse();return this._incrementResponse(),{generations:[this._formatGeneration(n)],llmOutput:{}}}}_formatGeneration(t){return{message:new Ce(t),text:t}}async*_streamResponseChunks(t,r,i){let n=this._currentResponse();this._incrementResponse(),this.emitCustomEvent&&await i?.handleCustomEvent("some_test_event",{someval:!0});let a=[...n];for(let o=0;o<a.length;o++){let s=a[o],c=o===a.length-1;if(await this._sleepIfRequested(),r?.thrownErrorString)throw new Error(r.thrownErrorString);let l=this._createResponseChunk(s,c?this.generationInfo:void 0);if(r.signal?.aborted)break;yield l,i?.handleLLMNewToken(s)}}async _sleepIfRequested(){this.sleep!==void 0&&await this._sleep()}async _sleep(){return new Promise(t=>{setTimeout(()=>t(),this.sleep)})}_createResponseChunk(t,r){return new ra({message:new Qe({content:t}),text:t,generationInfo:r})}_currentResponse(){return this.responses[this.i]}_incrementResponse(){this.i<this.responses.length-1?this.i+=1:this.i=0}bindTools(t){let r=[...this.tools,...t],i=r.map(o=>{switch(this.toolStyle){case"openai":return{type:"function",function:{name:o.name,description:o.description,parameters:bt(o.schema)}};case"anthropic":return{name:o.name,description:o.description,input_schema:bt(o.schema)};case"bedrock":return{toolSpec:{name:o.name,description:o.description,inputSchema:bt(o.schema)}};case"google":return{name:o.name,description:o.description,parameters:bt(o.schema)};default:throw new Error(`Unsupported tool style: ${this.toolStyle}`)}}),n=this.toolStyle==="google"?[{functionDeclarations:i}]:i,a=new H1({responses:this.responses,sleep:this.sleep,emitCustomEvent:this.emitCustomEvent,generationInfo:this.generationInfo});return a.tools=r,a.toolStyle=this.toolStyle,a.i=this.i,a.withConfig({tools:n})}withStructuredOutput(t,r){return Zt.from(async i=>{let n=await this.invoke(i);if(n.tool_calls?.[0]?.args)return n.tool_calls[0].args;if(typeof n.content=="string")return JSON.parse(n.content);throw new Error("No structured output found")})}};var G1=class extends Dp{vectorSize;constructor(e){super(e??{}),this.vectorSize=e?.vectorSize??4}async embedDocuments(e){return Promise.all(e.map(t=>this.embedQuery(t)))}async embedQuery(e){let t=e;t=t.toLowerCase().replaceAll(/[^a-z ]/g,"");let r=t.length%this.vectorSize,i=r===0?0:this.vectorSize-r,n=t.length+i;t=t.padEnd(n," ");let a=t.length/this.vectorSize,o=[];for(let s=0;s<t.length;s+=a)o.push(t.slice(s,s+a));return o.map(s=>{let c=0;for(let l=0;l<s.length;l+=1)c+=s===" "?0:s.charCodeAt(l);return c%26/26})}},W1=class extends Dp{constructor(e){super(e??{})}embedDocuments(e){return Promise.resolve(e.map(()=>[.1,.2,.3,.4]))}embedQuery(e){return Promise.resolve([.1,.2,.3,.4])}};var J1=class extends Yp{response;thrownErrorString;constructor(e){super(e),this.response=e.response,this.thrownErrorString=e.thrownErrorString}_llmType(){return"fake"}async _call(e,t,r){if(this.thrownErrorString)throw new Error(this.thrownErrorString);let i=this.response??e;return await r?.handleLLMNewToken(i),i}},K1=class extends Yp{sleep=50;responses;thrownErrorString;constructor(e){super(e),this.sleep=e.sleep??this.sleep,this.responses=e.responses,this.thrownErrorString=e.thrownErrorString}_llmType(){return"fake"}async _call(e){if(this.thrownErrorString)throw new Error(this.thrownErrorString);let t=this.responses?.[0];return this.responses=this.responses?.slice(1),t??e}async*_streamResponseChunks(e,t,r){if(this.thrownErrorString)throw new Error(this.thrownErrorString);let i=this.responses?.[0];this.responses=this.responses?.slice(1);for(let n of i??e)await new Promise(a=>setTimeout(a,this.sleep)),yield{text:n,generationInfo:{}},await r?.handleLLMNewToken(n)}};var q1=class extends Sw{lc_namespace=["langchain_core","message","fake"];messages=[];constructor(){super()}async getMessages(){return this.messages}async addMessage(e){this.messages.push(e)}async addUserMessage(e){this.messages.push(new rt(e))}async addAIMessage(e){this.messages.push(new Ce(e))}async clear(){this.messages=[]}},X1=class extends zp{lc_namespace=["langchain_core","message","fake"];messages=[];constructor(){super()}async addMessage(e){this.messages.push(e)}async getMessages(){return this.messages}},Y1=class extends Ot{name="fake_tracer";runs=[];constructor(){super()}persistRun(e){return this.runs.push(e),Promise.resolve()}};var Q1=class extends mn{lc_namespace=["tests","fake"];getFormatInstructions(){return""}async parse(e){return e.split(",").map(t=>t.trim())}};var eR=class extends tu{lc_namespace=["test","fake"];output=[new Nr({pageContent:"foo"}),new Nr({pageContent:"bar"})];constructor(e){super(),this.output=e?.output??this.output}async _getRelevantDocuments(e){return this.output}};var tR=class extends ae{lc_namespace=["tests","fake"];returnOptions;constructor(e){super(e),this.returnOptions=e.returnOptions}async invoke(e,t){return this.returnOptions?t??{}:{input:e}}};var rR=class extends xu{name;description;schema;constructor(e){super(e),this.name=e.name,this.description=e.description,this.schema=e.schema}async _call(e,t){return JSON.stringify(e)}};var nR=class extends Ot{runPromiseResolver;runPromise;name="single_run_extractor";constructor(){super(),this.runPromise=new Promise(e=>{this.runPromiseResolver=e})}async persistRun(e){this.runPromiseResolver(e)}async extract(){return this.runPromise}};var iR=class aR extends Vm{memoryVectors=[];similarity;_vectorstoreType(){return"memory"}constructor(t,{similarity:r,...i}={}){super(t,i),this.similarity=r??Um}async addDocuments(t){let r=t.map(({pageContent:i})=>i);return this.addVectors(await this.embeddings.embedDocuments(r),t)}async addVectors(t,r){let i=t.map((n,a)=>({content:r[a].pageContent,embedding:n,metadata:r[a].metadata}));this.memoryVectors=this.memoryVectors.concat(i)}async similaritySearchVectorWithScore(t,r,i){let n=o=>i?i(new Nr({metadata:o.metadata,pageContent:o.content})):!0,a=this.memoryVectors.filter(n);return a.map((o,s)=>({similarity:this.similarity(t,o.embedding),index:s})).sort((o,s)=>o.similarity>s.similarity?-1:0).slice(0,r).map(o=>[new Nr({metadata:a[o.index].metadata,pageContent:a[o.index].content}),o.similarity])}static async fromTexts(t,r,i,n){let a=[];for(let o=0;o<t.length;o+=1){let s=Array.isArray(r)?r[o]:r,c=new Nr({pageContent:t[o],metadata:s});a.push(c)}return aR.fromDocuments(a,i,n)}static async fromDocuments(t,r,i){let n=new this(r,i);return await n.addDocuments(t),n}static async fromExistingIndex(t,r){return new this(t,r)}};var oR=T({FakeChatMessageHistory:()=>q1,FakeChatModel:()=>F1,FakeEmbeddings:()=>W1,FakeLLM:()=>J1,FakeListChatMessageHistory:()=>X1,FakeListChatModel:()=>Z1,FakeRetriever:()=>eR,FakeRunnable:()=>tR,FakeSplitIntoListParser:()=>Q1,FakeStreamingChatModel:()=>B1,FakeStreamingLLM:()=>K1,FakeTool:()=>rR,FakeTracer:()=>Y1,FakeVectorStore:()=>iR,SingleRunExtractor:()=>nR,SyntheticEmbeddings:()=>G1});var sR=T({agents:()=>hk,caches:()=>v$,callbacks__base:()=>S$,callbacks__manager:()=>kI,callbacks__promises:()=>wI,chat_history:()=>sO,document_loaders__base:()=>uO,document_loaders__langsmith:()=>dO,documents:()=>lO,embeddings:()=>fO,errors:()=>vk,example_selectors:()=>wO,index:()=>mk,indexing:()=>kO,language_models__base:()=>PO,language_models__chat_models:()=>dP,language_models__compat:()=>sP,language_models__event:()=>fP,language_models__llms:()=>pP,language_models__profile:()=>hP,language_models__stream:()=>tP,language_models__structured_output:()=>QO,load__serializable:()=>ak,memory:()=>gP,messages:()=>oO,messages__tool:()=>Lk,output_parsers:()=>KO,output_parsers__openai_functions:()=>vP,output_parsers__openai_tools:()=>bP,outputs:()=>FI,prompt_values:()=>$O,prompts:()=>NP,retrievers:()=>MP,retrievers__document_compressors:()=>RP,runnables:()=>zO,runnables__graph:()=>MA,singletons:()=>AI,stores:()=>jP,structured_query:()=>VP,testing:()=>JP,tools:()=>m1,tracers__base:()=>dI,tracers__console:()=>pI,tracers__log_stream:()=>LI,tracers__run_collector:()=>y1,tracers__tracer_langchain:()=>_I,types__stream:()=>v1,utils__async_caller:()=>GI,utils__chunk_array:()=>b1,utils__context:()=>w1,utils__env:()=>sk,utils__event_source_parse:()=>x1,utils__format:()=>E1,utils__function_calling:()=>I1,utils__hash:()=>gk,utils__json_patch:()=>DO,utils__json_schema:()=>TA,utils__math:()=>O1,utils__ssrf:()=>N1,utils__standard_schema:()=>WI,utils__stream:()=>OI,utils__testing:()=>oR,utils__tiktoken:()=>AO,utils__types:()=>qO,utils__uuid:()=>XS,vectorstores:()=>L1});var KB=50;function qB(e){let t={};for(let r=e;r&&r.prototype;r=Object.getPrototypeOf(r))Object.assign(t,Reflect.get(r.prototype,"lc_aliases"));return Object.entries(t).reduce((r,[i,n])=>(r[n]=i,r),{})}async function Zm(e){let{optionalImportsMap:t,optionalImportEntrypoints:r,importMap:i,secretsMap:n,secretsFromEnv:a,path:o,depth:s,maxDepth:c}=this,l=o.join(".");if(s>c)throw new Error(`Maximum recursion depth (${c}) exceeded during deserialization. This may indicate a malicious payload or you may need to increase maxDepth.`);if(typeof e!="object"||e==null)return e;if(Array.isArray(e))return Promise.all(e.map((f,p)=>Zm.call({...this,path:[...o,`${p}`],depth:s+1},f)));let u=e;if(Zh(u))return rd(u);if("lc"in u&&"type"in u&&"id"in u&&u.lc===1&&u.type==="secret"){let[f]=u.id;if(f in n)return n[f];if(a){let p=Qt(f);if(p)return p}throw new Error(`Missing secret "${f}" at ${l}`)}if("lc"in u&&"type"in u&&"id"in u&&u.lc===1&&u.type==="not_implemented"){let f=JSON.stringify(u);throw new Error(`Trying to load an object that doesn't implement serialization: ${l} -> ${f}`)}if("lc"in u&&"type"in u&&"id"in u&&"kwargs"in u&&u.lc===1&&u.type==="constructor"){let f=u,p=JSON.stringify(f),[m,...h]=f.id.slice().reverse(),_=h.reverse(),b={langchain_core:sR,langchain:i},w=null,S=[_.join("/")];_[0]==="langchain_community"&&S.push(["langchain",..._.slice(1)].join("/"));let x=S.find(C=>C in t);if(pk.concat(r).includes(_.join("/"))||x)if(x!==void 0)w=await t[x];else throw new Error(`Missing key "${_.join("/")}" for ${l} in load(optionalImportsMap={})`);else{let C;if(_[0]==="langchain"||_[0]==="langchain_core")C=b[_[0]],_.shift();else throw new Error(`Invalid namespace: ${l} -> ${p}`);if(_.length===0)throw new Error(`Invalid namespace: ${l} -> ${p}`);let v;do{if(v=_.join("__"),v in C)break;_.pop()}while(_.length>0);v in C&&(w=C[v])}if(typeof w!="object"||w===null)throw new Error(`Invalid namespace: ${l} -> ${p}`);let E=w[m]??Object.values(w).find(C=>typeof C=="function"&&Xo(C)===m);if(typeof E!="function")throw new Error(`Invalid identifer: ${l} -> ${p}`);let z=new E(ed(await Zm.call({...this,path:[...o,"kwargs"],depth:s+1},f.kwargs),rk,qB(E)));return Object.defineProperty(z.constructor,"name",{value:m}),z}let d={};for(let[f,p]of Object.entries(u))d[f]=await Zm.call({...this,path:[...o,f],depth:s+1},p);return d}async function cR(e,t){let r=JSON.parse(e),i={optionalImportsMap:t?.optionalImportsMap??{},optionalImportEntrypoints:t?.optionalImportEntrypoints??[],secretsMap:t?.secretsMap??{},secretsFromEnv:t?.secretsFromEnv??!1,importMap:t?.importMap??{},path:["$"],depth:0,maxDepth:t?.maxDepth??KB};return Zm.call(i,r)}function XB(e){return e!==null&&e.lc===1&&e.type==="constructor"&&Array.isArray(e.id)}async function R0(e){if(e&&typeof e=="object"){if(Array.isArray(e))return await Promise.all(e.map(t=>R0(t)));{let t={};for(let[r,i]of Object.entries(e))t[r]=await R0(i);if(t.lc===2&&t.type==="undefined")return;if(t.lc===2&&t.type==="delta_snapshot")return new Ko(t.value);if(t.lc===2&&t.type==="constructor"&&Array.isArray(t.id))try{let r=t.id[t.id.length-1],i;switch(r){case"Set":i=Set;break;case"Map":i=Map;break;case"RegExp":i=RegExp;break;case"Error":i=Error;break;case"Uint8Array":i=Uint8Array;break;default:return t}return t.method?i[t.method](...t.args||[]):new i(...t.args||[])}catch{return t}else if(XB(t))return cR(JSON.stringify(t));return t}}return e}function Hm(e,t,r,i){return{lc:2,type:"constructor",id:[e.name],method:t??null,args:r??[],kwargs:i??{}}}function YB(e){return e===void 0?{lc:2,type:"undefined"}:e instanceof Ko?{lc:2,type:"delta_snapshot",value:e.value}:e instanceof Set||e instanceof Map?Hm(e.constructor,void 0,[Array.from(e)]):e instanceof RegExp?Hm(RegExp,void 0,[e.source,e.flags]):e instanceof Error?Hm(e.constructor,void 0,[e.message]):e?.lg_name==="Send"?{node:e.node,args:e.args,...e.timeout!==void 0?{timeout:e.timeout}:{}}:e instanceof Uint8Array?Hm(Uint8Array,"from",[Array.from(e)]):e}var Gm=class{_dumps(e){return new TextEncoder().encode(QS(e,(t,r)=>YB(r)))}async dumpsTyped(e){return e instanceof Uint8Array?["bytes",e]:["json",this._dumps(e)]}async _loads(e){return R0(JSON.parse(e))}async loadsTyped(e,t){if(e==="bytes")return typeof t=="string"?new TextEncoder().encode(t):t;if(e==="json")return this._loads(typeof t=="string"?t:new TextDecoder().decode(t));throw new Error(`Unknown serialization type: ${e}`)}};function M0(e){if(typeof e!="object"||e===null)return e;let t=Array.isArray(e)?[]:{};for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=M0(e[r]));return t}function Lo(){return{v:4,id:Bc(0),ts:new Date().toISOString(),channel_values:{},channel_versions:{},versions_seen:{}}}function _n(e){return{v:e.v,id:e.id,ts:e.ts,channel_values:{...e.channel_values},channel_versions:{...e.channel_versions},versions_seen:M0(e.versions_seen)}}var Wm=class{serde=new Gm;constructor(e){this.serde=e||this.serde}async get(e){let t=await this.getTuple(e);return t?t.checkpoint:void 0}async getDeltaChannelHistory(e){let{config:t,channels:r}=e;if(r.length===0)return{};let i={},n={},a=new Set(r);for(let c of r)i[c]=[];let o=(await this.getTuple(t))?.parentConfig;for(;o!=null&&a.size>0;){let c=await this.getTuple(o);if(c===void 0)break;if(c.pendingWrites&&c.pendingWrites.length>0)for(let l=c.pendingWrites.length-1;l>=0;l-=1){let u=c.pendingWrites[l],d=u[1];a.has(d)&&i[d].push(u)}for(let l of Array.from(a))Object.prototype.hasOwnProperty.call(c.checkpoint.channel_values,l)&&(n[l]=c.checkpoint.channel_values[l],a.delete(l));o=c.parentConfig}let s={};for(let c of r){let l={writes:i[c].slice().reverse()};Object.prototype.hasOwnProperty.call(n,c)&&(l.seed=n[c]),s[c]=l}return s}getNextVersion(e){if(typeof e=="string")throw new Error("Please override this method to use string versions.");return e!==void 0&&typeof e=="number"?e+1:1}};function Jm(e,t){return typeof e=="number"&&typeof t=="number"?Math.sign(e-t):String(e).localeCompare(String(t))}function Su(...e){return e.reduce((t,r,i)=>i===0?r:Jm(t,r)>=0?t:r)}var ku={[Dh]:-1,[Ba]:-2,[Uh]:-3,[Lh]:-4};function Km(e){return e.configurable?.checkpoint_id||e.configurable?.thread_ts||""}var QB=new Set(["__proto__","constructor","prototype"]);function Nt(e,t,r={}){let{allowEmpty:i=!1}=r;if(typeof t!="string"){let n=t===null?"null":t===void 0?"undefined":Array.isArray(t)?"array":typeof t;throw new Error(`Invalid configurable value for key "${e}": expected a string identifier (got ${n}). This guard protects MemorySaver from prototype pollution.`)}if(!i&&t==="")throw new Error(`Invalid configurable value for key "${e}": empty string is not permitted as an in-memory storage key.`);if(QB.has(t))throw new Error(`Invalid configurable value for key "${e}": value "${t}" is reserved (would mutate Object.prototype). This guard protects MemorySaver from prototype pollution.`)}function _c(e,t,r){return JSON.stringify([e,t,r])}function eV(e){let[t,r,i]=JSON.parse(e);return{threadId:t,checkpointNamespace:r,checkpointId:i}}var lR=class extends Wm{storage=Object.create(null);writes=Object.create(null);constructor(e){super(e)}async _migratePendingSends(e,t,r,i){let n=e,a=_c(t,r,i),o=await Promise.all(Object.values(this.writes[a]??{}).filter(([s,c])=>c===Vc).map(async([s,c,l])=>await this.serde.loadsTyped("json",l)));n.channel_values??={},n.channel_values[Vc]=o,n.channel_versions??={},n.channel_versions[Vc]=Object.keys(n.channel_versions).length>0?Su(...Object.values(n.channel_versions)):this.getNextVersion(void 0)}async getTuple(e){let t=e.configurable?.thread_id,r=e.configurable?.checkpoint_ns??"",i=Km(e);if(t!==void 0&&Nt("thread_id",t),Nt("checkpoint_ns",r,{allowEmpty:!0}),i&&Nt("checkpoint_id",i),i){let n=this.storage[t]?.[r]?.[i];if(n!==void 0){let[a,o,s]=n,c=_c(t,r,i),l=await this.serde.loadsTyped("json",a);l.v<4&&s!==void 0&&await this._migratePendingSends(l,t,r,s);let u=await Promise.all(Object.values(this.writes[c]||{}).map(async([f,p,m])=>[f,p,await this.serde.loadsTyped("json",m)])),d={config:e,checkpoint:l,metadata:await this.serde.loadsTyped("json",o),pendingWrites:u};return s!==void 0&&(d.parentConfig={configurable:{thread_id:t,checkpoint_ns:r,checkpoint_id:s}}),d}}else{let n=this.storage[t]?.[r];if(n!==void 0){i=Object.keys(n).sort((f,p)=>p.localeCompare(f))[0];let[a,o,s]=n[i],c=_c(t,r,i),l=await this.serde.loadsTyped("json",a);l.v<4&&s!==void 0&&await this._migratePendingSends(l,t,r,s);let u=await Promise.all(Object.values(this.writes[c]||{}).map(async([f,p,m])=>[f,p,await this.serde.loadsTyped("json",m)])),d={config:{configurable:{thread_id:t,checkpoint_id:i,checkpoint_ns:r}},checkpoint:l,metadata:await this.serde.loadsTyped("json",o),pendingWrites:u};return s!==void 0&&(d.parentConfig={configurable:{thread_id:t,checkpoint_ns:r,checkpoint_id:s}}),d}}}async*list(e,t){let{before:r,limit:i,filter:n}=t??{};e.configurable?.thread_id!==void 0&&Nt("thread_id",e.configurable.thread_id),e.configurable?.checkpoint_ns!==void 0&&Nt("checkpoint_ns",e.configurable.checkpoint_ns,{allowEmpty:!0}),e.configurable?.checkpoint_id&&Nt("checkpoint_id",e.configurable.checkpoint_id),r?.configurable?.checkpoint_id&&Nt("checkpoint_id",r.configurable.checkpoint_id);let a=e.configurable?.thread_id?[e.configurable?.thread_id]:Object.keys(this.storage),o=e.configurable?.checkpoint_ns,s=e.configurable?.checkpoint_id;for(let c of a)for(let l of Object.keys(this.storage[c]??{})){if(o!==void 0&&l!==o)continue;let u=this.storage[c]?.[l]??{},d=Object.entries(u).sort((f,p)=>p[0].localeCompare(f[0]));for(let[f,[p,m,h]]of d){if(s&&f!==s||r&&r.configurable?.checkpoint_id&&f>=r.configurable.checkpoint_id)continue;let _=await this.serde.loadsTyped("json",m);if(n&&!Object.entries(n).every(([z,C])=>_[z]===C))continue;if(i!==void 0){if(i<=0)break;i-=1}let b=_c(c,l,f),w=Object.values(this.writes[b]||{}),S=await Promise.all(w.map(async([z,C,v])=>[z,C,await this.serde.loadsTyped("json",v)])),x=await this.serde.loadsTyped("json",p);x.v<4&&h!==void 0&&await this._migratePendingSends(x,c,l,h);let E={config:{configurable:{thread_id:c,checkpoint_ns:l,checkpoint_id:f}},checkpoint:x,metadata:_,pendingWrites:S};h!==void 0&&(E.parentConfig={configurable:{thread_id:c,checkpoint_ns:l,checkpoint_id:h}}),yield E}}}async put(e,t,r){let i=_n(t),n=e.configurable?.thread_id,a=e.configurable?.checkpoint_ns??"";if(n===void 0)throw new Error('Failed to put checkpoint. The passed RunnableConfig is missing a required "thread_id" field in its "configurable" property. When using a checkpointer, you must pass a "thread_id" so the checkpointer knows which conversation thread to persist state for. Example: graph.stream(input, { configurable: { thread_id: "my-thread-id" } })');Nt("thread_id",n),Nt("checkpoint_ns",a,{allowEmpty:!0}),Nt("checkpoint_id",t.id),this.storage[n]||(this.storage[n]=Object.create(null)),this.storage[n][a]||(this.storage[n][a]=Object.create(null));let[[,o],[,s]]=await Promise.all([this.serde.dumpsTyped(i),this.serde.dumpsTyped(r)]);return this.storage[n][a][t.id]=[o,s,e.configurable?.checkpoint_id],{configurable:{thread_id:n,checkpoint_ns:a,checkpoint_id:t.id}}}async putWrites(e,t,r){let i=e.configurable?.thread_id,n=e.configurable?.checkpoint_ns,a=e.configurable?.checkpoint_id;if(i===void 0)throw new Error('Failed to put writes. The passed RunnableConfig is missing a required "thread_id" field in its "configurable" property. When using a checkpointer, you must pass a "thread_id" so the checkpointer knows which conversation thread to persist state for. Example: graph.stream(input, { configurable: { thread_id: "my-thread-id" } })');if(a===void 0)throw new Error('Failed to put writes. The passed RunnableConfig is missing a required "checkpoint_id" field in its "configurable" property.');Nt("thread_id",i),Nt("checkpoint_ns",n,{allowEmpty:!0}),Nt("checkpoint_id",a),Nt("task_id",r);let o=_c(i,n,a),s=this.writes[o];this.writes[o]===void 0&&(this.writes[o]=Object.create(null)),await Promise.all(t.map(async([c,l],u)=>{let[,d]=await this.serde.dumpsTyped(l),f=[r,ku[c]||u],p=`${f[0]},${f[1]}`;f[1]>=0&&s&&p in s||(this.writes[o][p]=[r,c,d])}))}async deleteThread(e){Nt("thread_id",e),delete this.storage[e];for(let t of Object.keys(this.writes))eV(t).threadId===e&&delete this.writes[t]}async getDeltaChannelHistory(e){let{config:t,channels:r}=e;if(r.length===0)return{};let i=t.configurable?.thread_id,n=t.configurable?.checkpoint_ns??"",a=Km(t);i!==void 0&&Nt("thread_id",i),Nt("checkpoint_ns",n,{allowEmpty:!0});let o=this.storage[i]?.[n]??{},s=[],c=(a?o[a]:void 0)?.[2];for(;c!==void 0;){let p=o[c];if(p===void 0)break;s.push(c),c=p[2]}let l={},u={},d=new Set(r);for(let p of r)l[p]=[];for(let p of s){if(d.size===0)break;let m=o[p],h=m!==void 0?await this.serde.loadsTyped("json",m[0]):void 0,_={},b=new Set;if(h!==void 0)for(let x of d)Object.prototype.hasOwnProperty.call(h.channel_values,x)&&h.channel_values[x]!==void 0&&(_[x]=h.channel_values[x],b.add(x));let w=_c(i,n,p),S=Object.entries(this.writes[w]??{});S.sort(([x],[E])=>{let[z,C]=x.split(","),[v,Z]=E.split(",");return z!==v?z<v?1:-1:Number(Z)-Number(C)});for(let[,[x,E,z]]of S)d.has(E)&&l[E].push([x,E,await this.serde.loadsTyped("json",z)]);for(let x of b)u[x]=_[x],d.delete(x)}let f={};for(let p of r){let m={writes:l[p].slice().reverse()};Object.prototype.hasOwnProperty.call(u,p)&&(m.seed=u[p]),f[p]=m}return f}};var yc=class extends Error{constructor(e){super(e),this.name="InvalidNamespaceError"}};function tV(e){if(e.length===0)throw new yc("Namespace cannot be empty.");for(let t of e){if(typeof t!="string")throw new yc(`Invalid namespace label '${t}' found in ${e}. Namespace labels must be strings, but got ${typeof t}.`);if(t.includes("."))throw new yc(`Invalid namespace label '${t}' found in ${e}. Namespace labels cannot contain periods ('.').`);if(t==="")throw new yc(`Namespace labels cannot be empty strings. Got ${t} in ${e}`)}if(e[0]==="langgraph")throw new yc(`Root label for namespace cannot be "langgraph". Got: ${e}`)}var vc=class{async get(e,t){return(await this.batch([{namespace:e,key:t}]))[0]}async search(e,t={}){let{filter:r,limit:i=10,offset:n=0,query:a}=t;return(await this.batch([{namespacePrefix:e,filter:r,limit:i,offset:n,query:a}]))[0]}async put(e,t,r,i){tV(e),await this.batch([{namespace:e,key:t,value:r,index:i}])}async delete(e,t){await this.batch([{namespace:e,key:t,value:null}])}async listNamespaces(e={}){let{prefix:t,suffix:r,maxDepth:i,limit:n=100,offset:a=0}=e,o=[];return t&&o.push({matchType:"prefix",path:t}),r&&o.push({matchType:"suffix",path:r}),(await this.batch([{matchConditions:o.length?o:void 0,maxDepth:i,limit:n,offset:a}]))[0]}start(){}stop(){}};var rV=e=>"lg_name"in e&&e.lg_name==="AsyncBatchedStore"?e.store:e,qm=class extends vc{lg_name="AsyncBatchedStore";store;queue=new Map;nextKey=0;running=!1;processingTask=null;constructor(e){super(),this.store=rV(e)}get isRunning(){return this.running}async batch(e){throw new Error("The `batch` method is not implemented on `AsyncBatchedStore`.\n Instead, it calls the `batch` method on the wrapped store.\n If you are seeing this error, something is wrong.")}async get(e,t){return this.enqueueOperation({namespace:e,key:t})}async search(e,t){let{filter:r,limit:i=10,offset:n=0,query:a}=t||{};return this.enqueueOperation({namespacePrefix:e,filter:r,limit:i,offset:n,query:a})}async put(e,t,r){return this.enqueueOperation({namespace:e,key:t,value:r})}async delete(e,t){return this.enqueueOperation({namespace:e,key:t,value:null})}start(){this.running||(this.running=!0,this.processingTask=this.processBatchQueue())}async stop(){this.running=!1,this.processingTask&&await this.processingTask}enqueueOperation(e){return new Promise((t,r)=>{let i=this.nextKey;this.nextKey+=1,this.queue.set(i,{operation:e,resolve:t,reject:r})})}async processBatchQueue(){for(;this.running;){if(await new Promise(t=>{setTimeout(t,0)}),this.queue.size===0)continue;let e=new Map(this.queue);this.queue.clear();try{let t=Array.from(e.values()).map(({operation:i})=>i),r=await this.store.batch(t);e.forEach(({resolve:i},n)=>{i(r[Array.from(e.keys()).indexOf(n)])})}catch(t){e.forEach(({reject:r})=>{r(t)})}}}toJSON(){return{queue:this.queue,nextKey:this.nextKey,running:this.running,store:"[LangGraphStore]"}}};function $u(e){if(!e)return[];let t=[],r=[],i=0;for(;i<e.length;){let n=e[i];if(n==="["){r.length&&(t.push(r.join("")),r=[]);let a=1,o=["["];for(i+=1;i<e.length&&a>0;)e[i]==="["?a+=1:e[i]==="]"&&(a-=1),o.push(e[i]),i+=1;t.push(o.join(""));continue}else if(n==="{"){r.length&&(t.push(r.join("")),r=[]);let a=1,o=["{"];for(i+=1;i<e.length&&a>0;)e[i]==="{"?a+=1:e[i]==="}"&&(a-=1),o.push(e[i]),i+=1;t.push(o.join(""));continue}else n==="."?r.length&&(t.push(r.join("")),r=[]):r.push(n);i+=1}return r.length&&t.push(r.join("")),t}function nV(e){return typeof e=="object"&&e!==null&&Object.keys(e).every(t=>t==="$eq"||t==="$ne"||t==="$gt"||t==="$gte"||t==="$lt"||t==="$lte"||t==="$in"||t==="$nin")}function uR(e,t){return nV(t)?Object.keys(t).filter(r=>r.startsWith("$")).every(r=>{let i=t[r];switch(r){case"$eq":return e===i;case"$ne":return e!==i;case"$gt":return Number(e)>Number(i);case"$gte":return Number(e)>=Number(i);case"$lt":return Number(e)<Number(i);case"$lte":return Number(e)<=Number(i);case"$in":return Array.isArray(i)?i.includes(e):!1;case"$nin":return Array.isArray(i)?!i.includes(e):!0;default:return!1}}):e===t}function dR(e,t){if(!t||t==="$")return[JSON.stringify(e,null,2)];let r=Array.isArray(t)?t:$u(t);function i(n,a,o){if(o>=a.length)return typeof n=="string"||typeof n=="number"||typeof n=="boolean"?[String(n)]:n==null?[]:Array.isArray(n)||typeof n=="object"?[JSON.stringify(n,null,2)]:[];let s=a[o],c=[];if(o===0&&s==="$"&&c.push(JSON.stringify(n,null,2)),s.startsWith("[")&&s.endsWith("]")){if(!Array.isArray(n))return[];let l=s.slice(1,-1);if(l==="*")for(let u of n)c.push(...i(u,a,o+1));else try{let u=parseInt(l,10);u<0&&(u=n.length+u),u>=0&&u<n.length&&c.push(...i(n[u],a,o+1))}catch{return[]}}else if(s.startsWith("{")&&s.endsWith("}")){if(typeof n!="object"||n===null)return[];let l=s.slice(1,-1).split(",").map(u=>u.trim());for(let u of l){let d=$u(u);if(d.length){let f=n;for(let p of d)if(f&&typeof f=="object"&&p in f)f=f[p];else{f=void 0;break}f!==void 0&&(typeof f=="string"||typeof f=="number"||typeof f=="boolean"?c.push(String(f)):(Array.isArray(f)||typeof f=="object")&&c.push(JSON.stringify(f,null,2)))}}}else if(s==="*"){if(Array.isArray(n))for(let l of n)c.push(...i(l,a,o+1));else if(typeof n=="object"&&n!==null)for(let l of Object.values(n))c.push(...i(l,a,o+1))}else typeof n=="object"&&n!==null&&s in n&&c.push(...i(n[s],a,o+1));return c}return i(e,r,0)}var fR=class extends vc{data=new Map;vectors=new Map;_indexConfig;constructor(e){super(),e?.index&&(this._indexConfig={...e.index,__tokenizedFields:(e.index.fields??["$"]).map(t=>[t,t==="$"?[t]:$u(t)])})}async batch(e){let t=[],r=new Map,i=new Map;for(let n=0;n<e.length;n+=1){let a=e[n];if("key"in a&&"namespace"in a&&!("value"in a))t.push(this.getOperation(a));else if("namespacePrefix"in a){let o=this.filterItems(a);i.set(n,[a,o]),t.push(null)}else if("value"in a){let o=`${a.namespace.join(":")}:${a.key}`;r.set(o,a),t.push(null)}else"matchConditions"in a&&t.push(this.listNamespacesOperation(a))}if(i.size>0)if(this._indexConfig?.embeddings){let n=new Set;for(let[s]of i.values())s.query&&n.add(s.query);let a=n.size>0?await Promise.all(Array.from(n).map(s=>this._indexConfig.embeddings.embedQuery(s))):[],o=Object.fromEntries(Array.from(n).map((s,c)=>[s,a[c]]));for(let[s,[c,l]]of i.entries())if(c.query&&o[c.query]){let u=o[c.query];t[s]=this.scoreResults(l,u,c.offset??0,c.limit??10)}else t[s]=this.paginateResults(l.map(u=>({...u,score:void 0})),c.offset??0,c.limit??10)}else for(let[n,[a,o]]of i.entries())t[n]=this.paginateResults(o.map(s=>({...s,score:void 0})),a.offset??0,a.limit??10);if(r.size>0&&this._indexConfig?.embeddings){let n=this.extractTexts(Array.from(r.values()));if(Object.keys(n).length>0){let a=await this._indexConfig.embeddings.embedDocuments(Object.keys(n));this.insertVectors(n,a)}}for(let n of r.values())this.putOperation(n);return t}getOperation(e){let t=e.namespace.join(":");return this.data.get(t)?.get(e.key)??null}putOperation(e){let t=e.namespace.join(":");this.data.has(t)||this.data.set(t,new Map);let r=this.data.get(t);if(e.value===null)r.delete(e.key);else{let i=new Date;if(r.has(e.key)){let n=r.get(e.key);n.value=e.value,n.updatedAt=i}else r.set(e.key,{value:e.value,key:e.key,namespace:e.namespace,createdAt:i,updatedAt:i})}}listNamespacesOperation(e){let t=Array.from(this.data.keys()).map(r=>r.split(":"));return e.matchConditions&&e.matchConditions.length>0&&(t=t.filter(r=>e.matchConditions.every(i=>this.doesMatch(i,r)))),e.maxDepth!==void 0&&(t=Array.from(new Set(t.map(r=>r.slice(0,e.maxDepth).join(":")))).map(r=>r.split(":"))),t.sort((r,i)=>r.join(":").localeCompare(i.join(":"))),t.slice(e.offset??0,(e.offset??0)+(e.limit??t.length))}doesMatch(e,t){let{matchType:r,path:i}=e;if(r==="prefix")return i.length>t.length?!1:i.every((n,a)=>{let o=t[a];return n==="*"||o===n});if(r==="suffix")return i.length>t.length?!1:i.every((n,a)=>{let o=t[t.length-i.length+a];return n==="*"||o===n});throw new Error(`Unsupported match type: ${r}`)}filterItems(e){let t=[];for(let[i,n]of this.data.entries())i.startsWith(e.namespacePrefix.join(":"))&&t.push(...n.values());let r=t;return e.filter&&(r=t.filter(i=>Object.entries(e.filter).every(([n,a])=>uR(i.value[n],a)))),r}scoreResults(e,t,r=0,i=10){let n=[],a=[],o=[];for(let u of e){let d=this.getVectors(u);if(d.length)for(let f of d)n.push(u),a.push(f);else o.push(u)}let s=this.cosineSimilarity(t,a).map((u,d)=>[u,n[d]]).sort((u,d)=>d[0]-u[0]),c=new Set,l=[];for(let[u,d]of s){let f=`${d.namespace.join(":")}:${d.key}`;if(c.has(f))continue;let p=c.size;if(p>=r+i)break;if(p<r){c.add(f);continue}c.add(f),l.push([u,d])}if(o.length&&l.length<i)for(let u of o.slice(0,i-l.length)){let d=`${u.namespace.join(":")}:${u.key}`;c.has(d)||(c.add(d),l.push([void 0,u]))}return l.map(([u,d])=>({...d,score:u}))}paginateResults(e,t,r){return e.slice(t,t+r)}extractTexts(e){if(!e.length||!this._indexConfig)return{};let t={};for(let r of e)if(r.value!==null&&r.index!==!1){let i=r.index===null||r.index===void 0?this._indexConfig.__tokenizedFields??[]:r.index.map(n=>[n,$u(n)]);for(let[n,a]of i){let o=dR(r.value,a);o.length&&(o.length>1?o.forEach((s,c)=>{t[s]||(t[s]=[]),t[s].push([r.namespace,r.key,`${n}.${c}`])}):(t[o[0]]||(t[o[0]]=[]),t[o[0]].push([r.namespace,r.key,n])))}}return t}insertVectors(e,t){for(let[r,i]of Object.entries(e)){let n=t.shift();if(!n)throw new Error(`No embedding found for text: ${r}`);for(let[a,o,s]of i){let c=a.join(":");this.vectors.has(c)||this.vectors.set(c,new Map);let l=this.vectors.get(c);l.has(o)||l.set(o,new Map),l.get(o).set(s,n)}}}getVectors(e){let t=e.namespace.join(":"),r=e.key;if(!this.vectors.has(t))return[];let i=this.vectors.get(t);if(!i.has(r))return[];let n=i.get(r),a=Array.from(n.values());return a.length?a:[]}cosineSimilarity(e,t){if(!t.length)return[];let r=t.map(a=>a.reduce((o,s,c)=>o+s*e[c],0)),i=Math.sqrt(e.reduce((a,o)=>a+o*o,0)),n=t.map(a=>Math.sqrt(a.reduce((o,s)=>o+s*s,0)));return r.map((a,o)=>{let s=n[o];return i&&s?a/(i*s):0})}get indexConfig(){return this._indexConfig}};var Xm=class{serde=new Gm;constructor(e){this.serde=e||this.serde}};function yn(e){return e!=null&&e.lc_graph_name==="DeltaChannel"}function z0(e){return e!=null&&e.lg_is_channel===!0}var pt=class{ValueType;UpdateType;lg_is_channel=!0;consume(){return!1}finish(){return!1}isAvailable(){try{return this.get(),!0}catch(e){if(e.name===Pe.unminifiable_name)return!1;throw e}}equals(e){return this===e}},j0=Symbol.for("LG_IS_ONLY_BASE_CHANNEL");function bc(e){if(e[j0]===!0)return e;let t={};for(let r in e){if(!Object.prototype.hasOwnProperty.call(e,r))continue;let i=e[r];z0(i)&&(t[r]=i)}return Object.assign(t,{[j0]:!0}),t}function Ym(e,t){let r=bc(e),i={};for(let n in r){if(!Object.prototype.hasOwnProperty.call(r,n))continue;let a=t.channel_values[n];i[n]=r[n].fromCheckpoint(a)}return Object.assign(i,{[j0]:!0}),i}function Qm(e,t){let r=new Set,i=AS();for(let n in e){if(!Object.prototype.hasOwnProperty.call(e,n))continue;let a=e[n];if(!yn(a)||!a.isAvailable())continue;let[o,s]=t[n]??[0,0];(o>=a.snapshotFrequency||s>=i)&&r.add(n)}return r}function vn(e,t,r,i){let n=i?.channelsToSnapshot??new Set,{updatedChannels:a,getNextVersion:o}=i??{},s,c=e.channel_versions;if(t===void 0)s=e.channel_values;else{s={},c={...e.channel_versions};for(let l in t){if(!Object.prototype.hasOwnProperty.call(t,l))continue;let u=t[l];if(n.has(l)){o!==void 0&&(a===void 0||!a.has(l))&&(c[l]=o(c[l])),s[l]=new Ko(u.get());continue}if(!yn(u))try{s[l]=u.checkpoint()}catch(d){if(d.name!==Pe.unminifiable_name)throw d}}}return{v:4,id:i?.id??Bc(r),ts:new Date().toISOString(),channel_values:s,channel_versions:c,versions_seen:e.versions_seen}}async function wc(e,t,r){let i=Ym(e,t),{saver:n,config:a}=r??{},o=bc(e),s=[];for(let l in o)Object.prototype.hasOwnProperty.call(o,l)&&yn(o[l])&&!Object.prototype.hasOwnProperty.call(t.channel_values,l)&&s.push(l);if(s.length===0||n===void 0||a===void 0)return i;let c=await n.getDeltaChannelHistory({config:a,channels:s});for(let l of s){let u=c[l];if(u===void 0)continue;let d=o[l].fromCheckpoint(u.seed);d.replayWrites(u.writes),i[l]=d}return i}var iV=e=>e!=null&&e.lc_graph_name==="BinaryOperatorAggregate",Ci=class pR extends pt{lc_graph_name="BinaryOperatorAggregate";value;operator;initialValueFactory;constructor(t,r){super(),this.operator=t,this.initialValueFactory=r,this.value=r?.()}fromCheckpoint(t){let r=new pR(this.operator,this.initialValueFactory);return typeof t<"u"&&(r.value=t),r}update(t){let r=t;if(!r.length)return!1;if(this.value===void 0){let n=r[0],[a,o]=tn(n);a?this.value=o:this.value=n,r=r.slice(1)}let i=!1;for(let n of r)if(Bu(n)){if(i)throw new _e("Can receive only one Overwrite value per step.");let[,a]=tn(n);this.value=a,i=!0;continue}else!i&&this.value!==void 0&&(this.value=this.operator(this.value,n));return!0}get(){if(this.value===void 0)throw new Pe;return this.value}checkpoint(){if(this.value===void 0)throw new Pe;return this.value}isAvailable(){return this.value!==void 0}equals(t){return this===t?!0:iV(t)?this.operator===t.operator:!1}};var bn=class mR extends pt{lc_graph_name="LastValue";value=[];constructor(t){super(),this.initialValueFactory=t,t&&(this.value=[t()])}fromCheckpoint(t){let r=new mR(this.initialValueFactory);return typeof t<"u"&&(r.value=[t]),r}update(t){if(t.length===0)return!1;if(t.length!==1)throw new _e("LastValue can only receive one value per step.",{lc_error_code:"INVALID_CONCURRENT_GRAPH_UPDATE"});return this.value=[t[t.length-1]],!0}get(){if(this.value.length===0)throw new Pe;return this.value[0]}checkpoint(){if(this.value.length===0)throw new Pe;return this.value[0]}isAvailable(){return this.value.length!==0}},D0=class hR extends pt{lc_graph_name="LastValueAfterFinish";value=[];finished=!1;fromCheckpoint(t){let r=new hR;if(typeof t<"u"){let[i,n]=t;r.value=[i],r.finished=n}return r}update(t){return t.length===0?!1:(this.finished=!1,this.value=[t[t.length-1]],!0)}get(){if(this.value.length===0||!this.finished)throw new Pe;return this.value[0]}checkpoint(){if(this.value.length!==0)return[this.value[0],this.finished]}consume(){return this.finished?(this.finished=!1,this.value=[],!0):!1}finish(){return!this.finished&&this.value.length>0?(this.finished=!0,!0):!1}isAvailable(){return this.value.length!==0&&this.finished}};var eh=class{lc_graph_name="AnnotationRoot";spec;constructor(e){this.spec=e}static isInstance(e){return typeof e=="object"&&e!==null&&"lc_graph_name"in e&&e.lc_graph_name==="AnnotationRoot"}},Eu=function(e){return e?th(e):new bn};Eu.Root=e=>new eh(e);function th(e){return typeof e=="object"&&e&&"reducer"in e&&e.reducer?new Ci(e.reducer,e.default):typeof e=="object"&&e&&"value"in e&&e.value?new Ci(e.value,e.default):new bn}var aV=["tags","metadata","callbacks","configurable"],oV=["tags","metadata","callbacks","runName","maxConcurrency","recursionLimit","configurable","runId","outputKeys","streamMode","store","writer","interrupt","context","interruptBefore","interruptAfter","checkpointDuring","durability","signal","heartbeat","executionInfo","serverInfo","control"],sV=25,cV=new Set(["thread_id","checkpoint_id","checkpoint_ns","task_id","run_id","assistant_id","graph_id"]);function lV(e,t){if(!e)return t;let r=t??{};for(let i of cV){if(i in r)continue;let n=e[i];n!==void 0&&(r[i]=n)}return r}function xc(...e){let t={tags:[],metadata:{},callbacks:void 0,recursionLimit:sV,configurable:{}},r=Ae.getRunnableConfig();if(r!==void 0){for(let[i,n]of Object.entries(r))if(n!==void 0)if(aV.includes(i)){let a;Array.isArray(n)?a=[...n]:typeof n=="object"?i==="callbacks"&&"copy"in n&&typeof n.copy=="function"?a=n.copy():a={...n}:a=n,t[i]=a}else t[i]=n}for(let i of e)if(i!==void 0)for(let[n,a]of Object.entries(i))a!==void 0&&oV.includes(n)&&(t[n]=a);return t.metadata=lV(t.configurable,t.metadata)??{},t}function uV(e){let t=e??Ae.getRunnableConfig();if(t===void 0)throw new Error(["Config not retrievable. This is likely because you are running in an environment without support for AsyncLocalStorage.","If you're running `getStore` in such environment, pass the `config` from the node function directly."].join(`
413
- `));return t?.store}function dV(e){let t=e??Ae.getRunnableConfig();if(t===void 0)throw new Error(["Config not retrievable. This is likely because you are running in an environment without support for AsyncLocalStorage.","If you're running `getWriter` in such environment, pass the `config` from the node function directly."].join(`
414
- `));return t?.writer||t?.configurable?.writer}function U0(){return Ae.getRunnableConfig()}function fV(e){let t=e??Ae.getRunnableConfig();if(t===void 0)throw new Error(["Config not retrievable. This is likely because you are running in an environment without support for AsyncLocalStorage.","If you're running `getCurrentTaskInput` in such environment, pass the `config` from the node function directly."].join(`
415
- `));if(t.configurable?.__pregel_scratchpad?.currentTaskInput===void 0)throw new Error("BUG: internal scratchpad not initialized.");return t.configurable[Kt].currentTaskInput}function rh(e){return e.split("|").filter(t=>!t.match(/^\d+$/)).map(t=>t.split(":")[0]).join("|")}function gR(e){let t=e.split("|");for(;t.length>1&&t[t.length-1].match(/^\d+$/);)t.pop();return t.slice(0,-1).join("|")}var L0=class{#e=void 0;requestDrain(e="shutdown"){this.#e=e}get drainRequested(){return this.#e!==void 0}get drainReason(){return this.#e}};var F0=["values","updates","messages","tools","custom","tasks"];function Sc(e){if(e==null||typeof e!="object")return!1;let t=e;return typeof t.id=="string"&&("source"in t||typeof t.step=="number")&&!("values"in t)&&!("config"in t)}function pV(e){if(!Array.isArray(e)||e.length!==2)return{data:e};let[t,r]=e;if(r==null||typeof r!="object")return{data:e};let i=r,n=typeof i.langgraph_node=="string"?i.langgraph_node:void 0,a=typeof i.run_id=="string"?i.run_id:void 0;return{data:a!=null&&t!=null&&typeof t=="object"?{...t,run_id:a}:t,node:n}}function B0({namespace:e,mode:t,payload:r,seq:i}){let n=Date.now(),a={type:"event"};switch(t){case"messages":{let{data:o,node:s}=pV(r);return[{...a,seq:i,method:"messages",params:{namespace:e,timestamp:n,...s?{node:s}:{},data:o}}]}case"tools":return[{...a,seq:i,method:"tools",params:{namespace:e,timestamp:n,data:mV(r)}}];case"checkpoints":return Sc(r)?[{...a,seq:i,method:"checkpoints",params:{namespace:e,timestamp:n,data:r}}]:[];case"values":return[{...a,seq:i,method:"values",params:{namespace:e,timestamp:n,data:r}}];case"updates":{let o=hV(r);return[{...a,seq:i,method:"updates",params:{namespace:e,timestamp:n,...typeof o.node=="string"?{node:o.node}:{},data:o}}]}case"custom":{let o=typeof r=="object"&&r!==null&&!Array.isArray(r)&&"name"in r?r:{payload:r};return[{...a,seq:i,method:"custom",params:{namespace:e,timestamp:n,data:o}}]}case"tasks":return[{...a,seq:i,method:"tasks",params:{namespace:e,timestamp:n,data:r}}];default:return[]}}function mV(e){if(typeof e!="object"||e===null)return{event:"tool-error",tool_call_id:"",message:"Unexpected tools payload shape"};let t=e,r=String(t.toolCallId??"");switch(t.event){case"on_tool_start":return{event:"tool-started",tool_call_id:r,tool_name:String(t.name??"unknown"),input:t.input};case"on_tool_event":return{event:"tool-output-delta",tool_call_id:r,delta:typeof t.data=="string"?t.data:JSON.stringify(t.data??"")};case"on_tool_end":return{event:"tool-finished",tool_call_id:r,output:t.output};case"on_tool_error":{let i=t.error;return{event:"tool-error",tool_call_id:r,message:typeof i=="object"&&i!==null&&"message"in i&&typeof i.message=="string"?i.message:String(i??"unknown error")}}default:return{event:"tool-error",tool_call_id:"",message:`Unknown tool event: ${String(t.event)}`}}}function hV(e){if(typeof e!="object"||e===null)return{values:{}};let t=Object.entries(e);if(t.length===0)return{values:{}};let[r,i]=t[0];return{node:r,values:typeof i=="object"&&i!==null?i:{value:i}}}var V0=Symbol.for("langgraph.stream_channel"),Yr=class Z0{[V0]=!0;channelName;#e=[];#t=[];#n=!1;#a;#i;constructor(t){this.channelName=t}static local(){return new Z0}static remote(t){return new Z0(t)}static isInstance(t){return typeof t=="object"&&t!==null&&V0 in t&&t[V0]===!0}push(t){this.#e.push(t),this.#r(),this.#i?.(t)}iterate(t=0){let r=t;return{next:async()=>{for(;;){if(r<this.#e.length)return{value:this.#e[r++],done:!1};if(this.#n){if(this.#a)throw this.#a;return{value:void 0,done:!0}}await new Promise(i=>this.#t.push(i))}}}}toAsyncIterable(t=0){return{[Symbol.asyncIterator]:()=>this.iterate(t)}}toEventStream(t={}){let r=new TextEncoder,i=this.iterate(t.startAt),n=t.event??this.channelName,a=t.serialize??(o=>JSON.stringify(o)??"null");return new ReadableStream({async pull(o){try{let s=await i.next();if(s.done){o.close();return}let c=[];n!=null&&c.push(`event: ${n}`);for(let l of a(s.value).split(/\r\n|\r|\n/))c.push(`data: ${l}`);o.enqueue(r.encode(`${c.join(`
416
- `)}
417
-
418
- `))}catch(s){o.error(s)}},async cancel(){await i.return?.()}})}get(t){if(t<0||t>=this.#e.length)throw new RangeError(`StreamChannel index ${t} out of bounds (size=${this.#e.length})`);return this.#e[t]}get size(){return this.#e.length}get done(){return this.#n}close(){this.#n=!0,this.#r()}fail(t){this.#a=t,this.#n=!0,this.#r()}_wire(t){this.#i=t}_close(){this.close()}_fail(t){this.fail(t)}[Symbol.asyncIterator](){return this.iterate()}#r(){let t=this.#t.splice(0);for(let r of t)r()}};function _R(e){return Yr.isInstance(e)}var gV="custom:";function _V(e){return`${gV}${e}`}function yV(e){return e!=null&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"}var nh=Symbol("resolveValues"),H0=Symbol("rejectValues"),yR=class{_events=Yr.local();_discoveries=Yr.local();#e=0;#t=!1;#n;#a=!1;#i=[];#r=[];#s=[];#o=new Map;#l=new Map;#c=[];#u=[];register(e,t){this.#o.set(Jt(e),t)}addTransformer(e){let t=this._events.size;this.#r.push(e),e.onRegister&&e.onRegister({push:(r,i)=>this.push(r,i)});for(let r=0;r<t;r+=1)e.process(this._events.get(r));this.#t&&(this.#n!==void 0?e.fail?.(this.#n):e.finalize?.())}wireChannels(e){for(let[t,r]of Object.entries(e)){if(_R(r)){if(this.#s.push(r),typeof r.channelName!="string")continue;let i=_V(r.channelName);r._wire(n=>{this._events.push({type:"event",seq:this.#e++,method:i,params:{namespace:this.#i,timestamp:Date.now(),data:n}})});continue}yV(r)&&this.#u.push({name:t,promise:Promise.resolve(r)})}}push(e,t){t.method==="values"&&this.#l.set(Jt(e),t.params.data);let r=this.#i;this.#i=e;let i=!0;for(let n of this.#r)n.process(t)||(i=!1);this.#i=r,i&&this._events.push({...t,seq:this.#e++})}close(){this.#t=!0;for(let[r,i]of this.#l.entries()){let n=r?r.split("\0"):[];this.#o.get(Jt(n))?.[nh](i)}let e=[];for(let r of this.#r){let i=r.finalize?.();i!=null&&typeof i.then=="function"&&e.push(i)}for(let r of this.#s)r._close();let t=this.#u;t.length===0&&e.length===0?(this._events.close(),this._discoveries.close()):Promise.allSettled([...e,...t.map(async({name:r,promise:i})=>{try{let n=await i;this._events.done||this._events.push({type:"event",seq:this.#e++,method:"custom",params:{namespace:[],timestamp:Date.now(),data:{name:r,payload:n}}})}catch{}})]).then(()=>{this._events.close(),this._discoveries.close()});for(let r of this.#o.values())r[nh](void 0)}fail(e){this.#t=!0,this.#n=e;for(let t of this.#r)t.fail?.(e);for(let t of this.#s)t._fail(e);this._events.fail(e),this._discoveries.fail(e);for(let t of this.#o.values())t[H0](e)}markInterrupted(e){this.#a=!0,this.#c.push(...e)}get interrupted(){return this.#a}get interrupts(){return this.#c}subscribeEvents(e,t=0){let r=this._events.iterate(t);return{async next(){for(;;){let i=await r.next();if(i.done||ti(i.value.params.namespace,e))return i}}}}};async function vR(e,t){let r=0;try{for await(let i of e){let[n,a,o]=i;if(a==="values"&&Ua(o)){let c=o[je];t.markInterrupted(c.map(l=>({interruptId:l.id??"",payload:l.value})))}let s=B0({namespace:n,mode:a,payload:o,seq:r});r+=s.length;for(let c of s)t.push(n,c)}}catch(i){t.fail(i);return}t.close()}function Jt(e){return e.join("\0")}function ti(e,t){if(t.length>e.length)return!1;for(let r=0;r<t.length;r+=1)if(e[r]!==t[r])return!1;return!0}function ah(e,t,r=0){return{[Symbol.asyncIterator](){let i=e.iterate(r);return{async next(){for(;;){let n=await i.next();if(n.done)return{value:void 0,done:!0};if(ti(n.value.namespace,t))return{value:n.value,done:!1}}}}}}}var bR="root";function vV(e){if(e.length===0)return bR;let t=e[e.length-1],r=t.indexOf(":");return r===-1?t:t.slice(0,r)}function bV(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function ih(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function wV(e){if(!ih(e)||e.event!=="started")return;let t=e.cause;if(ih(t)&&typeof t.type=="string")return t}function xV(e){if(ih(e)&&"result"in e&&typeof e.name=="string"&&typeof e.id=="string"&&!e.name.startsWith("__"))return{name:e.name,id:e.id}}function G0(e={}){let t=e.rootGraphName??bR,r=e.initialStatus??"running",i=e.emitRootOnRegister??!0,n=e.getGraphName??vV,a=e.serializeError??bV,o=e.getTerminalStatusOverride,s=Yr.local(),c=new Map,l=new Map,u=new Set,d=[],f,p=0,m=!1,h=A=>A.length===0?t:n(A),_=(A,L,G)=>{let Y=Jt(A),Ie=c.get(Y),me=Ie?.graphName??h(A);if(Ie!=null&&Ie.status===L&&Ie.graphName===me&&G?.error==null)return;Ie==null?(Ie={namespace:A,graphName:me,status:L},c.set(Y,Ie)):Ie.status=L;let En={event:L,graph_name:me,...G?.cause!=null?{cause:G.cause}:{},...G?.error!=null?{error:G.error}:{}},Rr=Date.now();if(s.push({namespace:A,timestamp:Rr,...En}),!(A.length===0&&!i)&&f!=null){p+=1;try{f.push(A,{type:"event",seq:0,method:"lifecycle",params:{namespace:A,timestamp:Rr,data:En}})}finally{p-=1}}},b=A=>{let L=Jt(A),G=c.get(L);return G==null&&(G={namespace:A,graphName:h(A),status:void 0},c.set(L,G)),G},w=()=>{if(d.length===0)return;let A=d.splice(0,d.length);for(let L of A){let G=Jt(L.namespace),Y=c.get(G);Y==null||Y.status!=="started"||_(L.namespace,"completed")}},S=A=>{let L=Jt(A.namespace),G=c.get(L);G==null||G.status!=="started"||d.some(Y=>Jt(Y.namespace)===L)||d.push(A)},x=(A,L)=>{for(let G=d.length-1;G>=0;G-=1){let Y=d[G];Y.source.type==="node"&&Y.source.node===L&&Jt(Y.source.parent)===Jt(A)&&d.splice(G,1)}},E=A=>{for(let L=1;L<=A.length;L+=1){let G=A.slice(0,L),Y=Jt(G);if(c.has(Y))continue;b(G);let Ie=l.get(Y);_(G,"started",Ie!=null?{cause:Ie}:void 0)}},z=()=>u.size>0?"interrupted":"completed",C=A=>{for(let L of c.values())L.namespace.length!==0&&L.status==="started"&&_(L.namespace,A);_([],A),s.close()},v=async()=>{if(o==null)return z();try{return await o()??z()}catch{return z()}},Z=(A,L)=>{let G=`${L}:`;for(let Y of c.values()){if(Y.namespace.length!==A.length+1||Y.status!=="started"||!ti(Y.namespace,A))continue;let Ie=Y.namespace[Y.namespace.length-1];if(Ie===L||Ie.startsWith(G))return Y.namespace}},B=(A,L)=>{let G=[...A,`${L.name}:${L.id}`];return c.get(Jt(G))?.status==="started"?G:void 0};return{__native:!0,init(){return{_lifecycleLog:s,lifecycle:ah(s,[],0)}},onRegister(A){f=A,b([]),i&&_([],r)},process(A){let L=A.params.namespace;if(p>0)return!0;let G=A.method==="tasks"?xV(A.params.data):void 0;if(G!=null&&x(L,G.name),w(),A.method==="lifecycle"){let Y=wV(A.params.data);return Y!=null&&l.set(Jt(L),Y),E(L),!1}if(E(L),A.method==="input"&&ih(A.params.data)&&A.params.data.event==="requested"){let Y=A.params.data.id;typeof Y=="string"&&u.add(Y)}if(G!=null){let Y=B(L,G);Y!=null&&S({namespace:Y,source:{type:"task"}})}if(A.method==="updates"){let Y=A.params.node;if(typeof Y=="string"&&!Y.startsWith("__")){let Ie=Z(L,Y);Ie!=null&&S({namespace:Ie,source:{type:"node",parent:L,node:Y}})}}return!0},finalize(){if(!m){if(m=!0,w(),o==null){C(z());return}return v().then(C).catch(A=>{s.fail(A)})}},fail(A){if(m)return;m=!0;let L=a(A);for(let G of c.values())G.namespace.length!==0&&G.status==="started"&&_(G.namespace,"failed");_([],"failed",{error:L}),s.fail(A)}}}function kc(e){let t=e;return typeof t.run_id=="string"?`run:${t.run_id}`:e.event==="message-start"&&typeof t.id=="string"?`message:${t.id}`:"__default__"}function Iu(e,t){let r=Yr.local(),i=new Map,n=new Set;return{init:()=>({messages:r.toAsyncIterable()}),process(a){if(a.method!=="messages"||!ti(a.params.namespace,e)||a.params.namespace.length!==e.length+1||t!==void 0&&a.params.node!==t)return!0;let o=a.params.data;switch(o.event){case"message-start":{let s=kc(o);if(o.role==="tool"){n.add(s);break}let c=Yr.local(),l=Object.assign(new xa(c.toAsyncIterable()),{namespace:a.params.namespace,node:a.params.node});i.set(s,{source:c,stream:l}),c.push(o),r.push(l);break}case"content-block-start":case"content-block-delta":case"content-block-finish":if(n.has(kc(o)))break;i.get(kc(o))?.source.push(o);break;case"message-finish":{let s=kc(o);if(n.delete(s))break;let c=i.get(s);c&&(c.source.push(o),c.source.close(),i.delete(s));break}case"error":if(n.has(kc(o)))break;i.get(kc(o))?.source.push(o);break}return!0},finalize(){for(let[a,o]of i)o.source.push({event:"message-finish"}),o.source.close(),i.delete(a);n.clear(),r.close()},fail(a){for(let[o,s]of i)s.source.fail(a),i.delete(o);n.clear(),r.fail(a)}}}function Tu(e,t,r=0){let i=t.length+1;return{[Symbol.asyncIterator](){let n=e.iterate(r);return{async next(){for(;;){let a=await n.next();if(a.done)return{value:void 0,done:!0};let{ns:o,stream:s}=a.value;if(o.length===i&&ti(o,t))return{value:s,done:!1}}}}}}}function W0(e,t){let{createStream:r}=t,i=new Set;return{__native:!0,init(){return{_discoveries:e._discoveries,subgraphs:Tu(e._discoveries,[],0)}},process(n){let a=n.params.namespace;if(a.length===0)return!0;let o=a.slice(0,1),s=Jt(o);if(i.has(s))return!0;i.add(s);let c=r(o,e._discoveries.size,e._events.size);return e.register(o,c),e._discoveries.push({ns:o,stream:c}),!0}}}function J0(e){let t=Yr.local();return{init:()=>({_valuesLog:t}),process(r){return r.method!=="values"||r.params.namespace.length!==e.length||!ti(r.params.namespace,e)||t.push(r.params.data),!0},finalize(){t.close()},fail(r){t.fail(r)}}}function oh(e){return"__native"in e&&e.__native===!0}var wR=Symbol("setValuesLog"),xR=Symbol("setMessagesIterable"),K0=Symbol("setLifecycleIterable"),q0=Symbol("setSubgraphsIterable"),SV={[Symbol.asyncIterator](){return{next:()=>Promise.resolve({value:void 0,done:!0})}}},X0=class{path;extensions;_mux;#e;#t;#n;#a;#i;#r;#s;#o;#l;#c;constructor(e,t,r=0,i=0,n,a){this.path=e,this._mux=t,this.#t=r,this.#e=i,this.extensions=n??{},this.#n=a??new AbortController,this.#r=new Promise((o,s)=>{this.#a=o,this.#i=s}),this.#r.catch(()=>{})}[Symbol.asyncIterator](){return this._mux.subscribeEvents(this.path,this.#e)}get subgraphs(){return this.#c?this.#c:Tu(this._mux._discoveries,this.path,this.#t)}get values(){let e=this.#s,t=this.#r,r=this._mux,i=this.#e,n=this.path,a=e?e.toAsyncIterable():{[Symbol.asyncIterator]:()=>{let o=r.subscribeEvents(n,i);return{async next(){for(;;){let s=await o.next();if(s.done)return{value:void 0,done:!0};if(s.value.method==="values"&&s.value.params.namespace.length===n.length)return{value:s.value.params.data,done:!1}}}}}};return{[Symbol.asyncIterator]:()=>a[Symbol.asyncIterator](),then:t.then.bind(t)}}get messages(){if(this.#o)return this.#o;let e=Iu(this.path),t=e.init();return this._mux.addTransformer(e),this.#o=t.messages,this.#o}get lifecycle(){return this.#l??SV}messagesFrom(e){let t=Iu(this.path,e),r=t.init();return this._mux.addTransformer(t),r.messages}get output(){return this.#r}get interrupted(){return this._mux.interrupted}get interrupts(){return this._mux.interrupts}abort(e){this.#n.abort(e)}get signal(){return this.#n.signal}[nh](e){this.#a?.(e),this.#a=void 0}[H0](e){this.#i?.(e),this.#i=void 0}[wR](e){this.#s=e}[xR](e){this.#o=e}[K0](e){this.#l=e}[q0](e){this.#c=e}},SR=class extends X0{name;index;constructor(e,t,r=0,i=0,n,a){super(e,t,r,i,n,a);let o=e[e.length-1]??"",s=o.lastIndexOf(":");if(s>=0){this.name=o.slice(0,s);let c=o.slice(s+1);this.index=/^\d+$/.test(c)?Number(c):0}else this.name=o,this.index=0}};function Y0(e,t=[],r){let{abortController:i}=r instanceof AbortController?{abortController:r}:r??{},n=new yR,a=G0(),o=a.init(),s=o._lifecycleLog,c=W0(n,{createStream:(b,w,S)=>{let x=new SR(b,n,w,S);return x[q0](Tu(n._discoveries,b,w)),x[K0](ah(s,b,s.size)),x}}),l=c.init();n.addTransformer(c),n.addTransformer(a);let u=J0([]),d=Iu([]);n.addTransformer(u),n.addTransformer(d);let f={},p=[];for(let b of t){let w=b();n.addTransformer(w);let S=w.init();oh(w)?p.push(S):Object.assign(f,S),typeof S=="object"&&S!==null&&!oh(w)&&n.wireChannels(S)}let m=new X0([],n,0,0,f,i);for(let b of p)Object.assign(m,b);let h=u.init();m[wR](h._valuesLog);let _=d.init();return m[xR](_.messages),m[K0](o.lifecycle),m[q0](l.subgraphs),n.register([],m),vR(e,n).catch(b=>{}),m}var V=e=>BigInt(e),Ue=(e,t=0)=>new DataView(e.buffer,e.byteOffset+t,e.byteLength-t),IR=V("0x9E3779B1"),TR=V("0x85EBCA77"),kV=V("0xC2B2AE3D"),ka=V("0x9E3779B185EBCA87"),Fo=V("0xC2B2AE3D27D4EB4F"),CR=V("0x165667B19E3779F9"),tS=V("0x85EBCA77C2B2AE63"),$V=V("0x27D4EB2F165667C5"),EV=V("0x165667919E3779F9"),IV=V("0x9FB21C651E98DF25"),TV=e=>{let t=e.length;if(t%2!==0)throw new Error("String should have an even number of characters");let r=t/2,i=new Uint8Array(r),n=0,a=0;for(;a<r;){let o=e.slice(n,n+=2);i[a]=Number.parseInt(o,16),a+=1}return Ue(i)},ri=TV("b8fe6c3923a44bbe7c01812cf721ad1cded46de9839097db7240a4a4b7b3671fcb79e64eccc0e578825ad07dccff7221b8084674f743248ee03590e6813a264c3c2852bb91c300cb88d0658b1b532ea371644897a20df94e3819ef46a9deacd8a8fa763fe39c343ff9dcbbc7c70b4f1d8a51e04bcdb45931c89f7ec9d9787364eac5ac8334d3ebc3c581a0fffa1363eb170ddd51b7f0da49d316552629d4689e2b16be587d47a1fc8ff8b8d17ad031ce45cb3a8f95160428afd7fbcabb4b407e"),$c=(V(1)<<V(128))-V(1),be=(V(1)<<V(64))-V(1),uh=(V(1)<<V(32))-V(1),Ai=64,AR=Ai/8,CV=8,sh=4;function Ec(e){if(!e)throw new Error("Assert failed")}function AV(e){let t=new DataView(new ArrayBuffer(8));return t.setBigUint64(0,e,!0),t.getBigUint64(0,!1)}function OV(e){let t=e;return t=(t&V(65535))<<V(16)|(t&V(4294901760))>>V(16),t=(t&V(16711935))<<V(8)|(t&V(4278255360))>>V(8),t}function PV(e,t){return(e&uh)*(t&uh)&be}function NV(e,t){return(e<<t|e>>V(32)-t)&uh}function OR(e,t,r){for(let i=0;i<AR;i+=1){let n=t.getBigUint64(i*8,!0),a=n^r.getBigUint64(i*8,!0);e[i^1]+=n,e[i]+=PV(a,a>>V(32))}return e}function kR(e,t,r,i){for(let n=0;n<i;n+=1)OR(e,Ue(t,n*Ai),Ue(r,n*8));return e}function RV(e,t){for(let r=0;r<AR;r+=1){let i=t.getBigUint64(r*8,!0),n=e[r];n=Q0(n,V(47)),n^=i,n*=IR,e[r]=n&be}return e}function ch(e,t){return PR(e[0]^t.getBigUint64(0,!0),e[1]^t.getBigUint64(CV,!0))}function $R(e,t,r){let i=r;return i+=ch(e.slice(0),Ue(t,0*sh)),i+=ch(e.slice(2),Ue(t,4*sh)),i+=ch(e.slice(4),Ue(t,8*sh)),i+=ch(e.slice(6),Ue(t,12*sh)),ni(i&be)}function MV(e,t,r,i,n){let a=e,o=Math.floor((r.byteLength-Ai)/8),s=Ai*o,c=Math.floor((t.byteLength-1)/s);for(let l=0;l<c;l+=1)a=kR(a,Ue(t,l*s),r,o),a=n(a,Ue(r,r.byteLength-Ai));{let l=Math.floor((t.byteLength-1-s*c)/Ai);a=kR(a,Ue(t,c*s),r,l),a=i(a,Ue(t,t.byteLength-Ai),Ue(r,r.byteLength-Ai-7))}return a}function jV(e,t){let r=new BigUint64Array([kV,ka,Fo,CR,tS,TR,$V,IR]);Ec(e.byteLength>128),r=MV(r,e,t,OR,RV),Ec(r.length*8===64);{let i=$R(r,Ue(t,11),V(e.byteLength)*ka&be);return $R(r,Ue(t,t.byteLength-Ai-11),~(V(e.byteLength)*Fo)&be)<<V(64)|i}}function PR(e,t){let r=e*t&$c;return r&be^r>>V(64)}function ER(e,t,r){return PR((e.getBigUint64(0,!0)^t.getBigUint64(0,!0)+r)&be,(e.getBigUint64(8,!0)^t.getBigUint64(8,!0)-r)&be)}function lh(e,t,r,i,n){let a=e&be,o=e>>V(64)&be;return a+=ER(t,i,n),a^=r.getBigUint64(0,!0)+r.getBigUint64(8,!0),a&=be,o+=ER(r,Ue(i,16),n),o^=t.getBigUint64(0,!0)+t.getBigUint64(8,!0),o&=be,o<<V(64)|a}function ni(e){let t=e;return t^=t>>V(37),t*=EV,t&=be,t^=t>>V(32),t}function dh(e){let t=e;return t^=t>>V(33),t*=Fo,t&=be,t^=t>>V(29),t*=CR,t&=be,t^=t>>V(32),t}function zV(e,t,r){let i=e.byteLength;Ec(i>0&&i<=3);let n=V(e.getUint8(i-1))|V(i<<8)|V(e.getUint8(0)<<16)|V(e.getUint8(i>>1)<<24),a=(n^(V(t.getUint32(0,!0))^V(t.getUint32(4,!0)))+r)&be,o=(V(t.getUint32(8,!0))^V(t.getUint32(12,!0)))-r;return(dh((NV(OV(n),V(13))^o)&be)&be)<<V(64)|dh(a)}function Q0(e,t){return e^e>>t}function DV(e,t,r){let i=e.byteLength;Ec(i>=4&&i<=8);{let n=e.getUint32(0,!0),a=e.getUint32(i-4,!0),o=((V(n)|V(a)<<V(32))^(t.getBigUint64(16,!0)^t.getBigUint64(24,!0))+r&be)*(ka+(V(i)<<V(2)))&$c;return o+=(o&be)<<V(65),o&=$c,o^=o>>V(67),Q0(Q0(o&be,V(35))*IV&be,V(28))|ni(o>>V(64))<<V(64)}}function UV(e,t,r){let i=e.byteLength;Ec(i>=9&&i<=16);{let n=(t.getBigUint64(32,!0)^t.getBigUint64(40,!0))+r&be,a=(t.getBigUint64(48,!0)^t.getBigUint64(56,!0))-r&be,o=e.getBigUint64(0,!0),s=e.getBigUint64(i-8,!0),c=(o^s^n)*ka,l=(c&be)+(V(i-1)<<V(54));c=c&($c^be)|l,s^=a,c+=s+(s&uh)*(TR-V(1))<<V(64),c&=$c,c^=AV(c>>V(64));let u=(c&be)*Fo;return u+=(c>>V(64))*Fo<<V(64),u&=$c,ni(u&be)|ni(u>>V(64))<<V(64)}}function LV(e,t){let r=e.byteLength;return Ec(r<=16),r>8?UV(e,ri,t):r>=4?DV(e,ri,t):r>0?zV(e,ri,t):dh(t^ri.getBigUint64(64,!0)^ri.getBigUint64(72,!0))|dh(t^ri.getBigUint64(80,!0)^ri.getBigUint64(88,!0))<<V(64)}function eS(e){return~e+V(1)&be}function FV(e,t,r){let i=V(e.byteLength)*ka&be,n=V(e.byteLength-1)/V(32);for(;n>=0;){let s=Number(n);i=lh(i,Ue(e,16*s),Ue(e,e.byteLength-16*(s+1)),Ue(t,32*s),r),n-=V(1)}let a=i+(i>>V(64))&be;a=ni(a);let o=(i&be)*ka+(i>>V(64))*tS+(V(e.byteLength)-r&be)*Fo;return o&=be,o=eS(ni(o)),a|o<<V(64)}function BV(e,t,r){let i=V(e.byteLength)*ka&be;for(let o=32;o<160;o+=32)i=lh(i,Ue(e,o-32),Ue(e,o-16),Ue(t,o-32),r);i=ni(i&be)|ni(i>>V(64))<<V(64);for(let o=160;o<=e.byteLength;o+=32)i=lh(i,Ue(e,o-32),Ue(e,o-16),Ue(t,3+o-160),r);i=lh(i,Ue(e,e.byteLength-16),Ue(e,e.byteLength-32),Ue(t,103),eS(r));let n=i+(i>>V(64))&be;n=ni(n);let a=(i&be)*ka+(i>>V(64))*tS+(V(e.byteLength)-r&be)*Fo;return a&=be,a=eS(ni(a)),n|a<<V(64)}function ii(e,t=V(0)){let r=new TextEncoder,i=Ue(typeof e=="string"?r.encode(e):e),n=i.byteLength,a=o=>o.toString(16).padStart(32,"0");return n<=16?a(LV(i,t)):n<=128?a(FV(i,ri,t)):n<=240?a(BV(i,ri,t)):a(jV(i,ri))}function fh(e){return/^[0-9a-f]{32}$/.test(e)}function rS(e){let t=Ae.getRunnableConfig();if(!t)throw new Error("Called interrupt() outside the context of a graph.");let r=t.configurable;if(!r)throw new Error("No configurable found in config");if(!r.__pregel_checkpointer)throw new La("No checkpointer set",{lc_error_code:"MISSING_CHECKPOINTER"});let i=r[Kt];i.interruptCounter+=1;let n=i.interruptCounter;if(i.resume.length>0&&n<i.resume.length)return r[Mt]?.([[qt,i.resume]]),i.resume[n];if(i.nullResume!==void 0){if(i.resume.length!==n)throw new Error(`Resume length mismatch: ${i.resume.length} !== ${n}`);let o=i.consumeNullResume();return i.resume.push(o),r[Mt]?.([[qt,i.resume]]),o}let a=r[xr]?.split("|");throw new si([{id:a?ii(a.join("|")):void 0,value:e}])}var Tt=class extends ae{lc_namespace=["langgraph"];func;tags;config;trace=!0;recurse=!0;constructor(e){super(),this.name=e.name??e.func.name,this.func=e.func,this.config=e.tags?{tags:e.tags}:void 0,this.trace=e.trace??this.trace,this.recurse=e.recurse??this.recurse}async _tracedInvoke(e,t,r){return new Promise((i,n)=>{let a=Se(t,{callbacks:r?.getChild()});Ae.runWithConfig(a,async()=>{try{i(await this.func(e,a))}catch(o){n(o)}})})}async invoke(e,t){let r,i=xc(t),n=vt(this.config,i);return this.trace?r=await this._callWithConfig(this._tracedInvoke,e,n):r=await Ae.runWithConfig(n,async()=>this.func(e,n)),ae.isRunnable(r)&&this.recurse?await Ae.runWithConfig(n,async()=>r.invoke(e,n)):r}};function*ai(e,t){if(t===void 0)yield*e;else for(let r of e)yield[t,r]}async function wn(e){let t=[];for await(let r of await e)t.push(r);return t}function $a(e){let t=[];for(let r of e)t.push(r);return t}function Bo(e,t){return e?"configurable"in e?{...e,configurable:{...e.configurable,...t}}:{...e,configurable:t}:{configurable:t}}function nS(e){return e!=null&&typeof e=="function"&&e instanceof Object.getPrototypeOf(async function*(){}).constructor}function iS(e){return e!=null&&typeof e=="function"&&e instanceof Object.getPrototypeOf(function*(){}).constructor}function VV(e){return typeof e=="object"&&e?.[Symbol.for("LG_SKIP_WRITE")]!==void 0}var wr={[Symbol.for("LG_PASSTHROUGH")]:!0};function ph(e){return typeof e=="object"&&e?.[Symbol.for("LG_PASSTHROUGH")]!==void 0}var aS=Symbol("IS_WRITER"),ot=class sS extends Tt{writes;constructor(t,r){let i=`ChannelWrite<${t.map(n=>ht(n)?n.node:"channel"in n?n.channel:"...").join(",")}>`;super({writes:t,name:i,tags:r,trace:!1,func:async(n,a)=>this._write(n,a??{})}),this.writes=t}async _write(t,r){let i=this.writes.map(n=>oS(n)&&ph(n.value)?{mapper:n.mapper,value:t}:mh(n)&&ph(n.value)?{channel:n.channel,value:t,skipNone:n.skipNone,mapper:n.mapper}:n);return await sS.doWrite(r,i),t}static async doWrite(t,r){for(let a of r){if(mh(a)){if(a.channel==="__pregel_tasks")throw new _e("Cannot write to the reserved channel TASKS");if(ph(a.value))throw new _e("PASSTHROUGH value must be replaced")}if(oS(a)&&ph(a.value))throw new _e("PASSTHROUGH value must be replaced")}let i=[];for(let a of r)if(ht(a))i.push([Pn,a]);else if(oS(a)){let o=await a.mapper.invoke(a.value,t);o!=null&&o.length>0&&i.push(...o)}else if(mh(a)){let o=a.mapper!==void 0?await a.mapper.invoke(a.value,t):a.value;if(VV(o)||a.skipNone&&o===void 0)continue;i.push([a.channel,o])}else throw new Error(`Invalid write entry: ${JSON.stringify(a)}`);let n=t.configurable?.[Mt];n(i)}static isWriter(t){return t instanceof sS||aS in t&&!!t[aS]}static registerWriter(t){return Object.defineProperty(t,aS,{value:!0})}};function mh(e){return e!==void 0&&typeof e.channel=="string"}function oS(e){return e!==void 0&&!mh(e)&&ae.isRunnable(e.mapper)}var NR=class RR extends Tt{lc_graph_name="ChannelRead";channel;fresh=!1;mapper;constructor(t,r,i=!1){super({trace:!1,func:(n,a)=>RR.doRead(a,this.channel,this.fresh,this.mapper)}),this.fresh=i,this.mapper=r,this.channel=t,this.name=Array.isArray(t)?`ChannelRead<${t.join(",")}>`:`ChannelRead<${t}>`}static doRead(t,r,i,n){let a=t.configurable?.[jr];if(!a)throw new Error("Runnable is not configured with a read function. Make sure to call in the context of a Pregel process");return n?n(a(r,i)):a(r,i)}},Ic=new $i,xn=class Cu extends Jr{lc_graph_name="PregelNode";channels;triggers=[];mapper;writers=[];bound=Ic;kwargs={};metadata={};tags=[];retryPolicy;cachePolicy;timeout;subgraphs;ends;isErrorHandler;errorHandlerNode;constructor(t){let{channels:r,triggers:i,mapper:n,writers:a,bound:o,kwargs:s,metadata:c,retryPolicy:l,cachePolicy:u,timeout:d,tags:f,subgraphs:p,ends:m,isErrorHandler:h,errorHandlerNode:_}=t,b=[...t.config?.tags?t.config.tags:[],...f??[]];super({...t,bound:t.bound??Ic,config:{...t.config?t.config:{},tags:b}}),this.channels=r,this.triggers=i,this.mapper=n,this.writers=a??this.writers,this.bound=o??this.bound,this.kwargs=s??this.kwargs,this.metadata=c??this.metadata,this.tags=b,this.retryPolicy=l,this.cachePolicy=u,this.timeout=d,this.subgraphs=p,this.ends=m,this.isErrorHandler=h,this.errorHandlerNode=_}getWriters(){let t=[...this.writers];for(;t.length>1&&t[t.length-1]instanceof ot&&t[t.length-2]instanceof ot;){let r=t.slice(-2),i=r[0].writes.concat(r[1].writes);t[t.length-2]=new ot(i,r[0].config?.tags),t.pop()}return t}getNode(){let t=this.getWriters();if(!(this.bound===Ic&&t.length===0))return this.bound===Ic&&t.length===1?t[0]:this.bound===Ic?new Pr({first:t[0],middle:t.slice(1,t.length-1),last:t[t.length-1],omitSequenceTags:!0}):t.length>0?new Pr({first:this.bound,middle:t.slice(0,t.length-1),last:t[t.length-1],omitSequenceTags:!0}):this.bound}join(t){if(!Array.isArray(t))throw new Error("channels must be a list");if(typeof this.channels!="object")throw new Error("all channels must be named when using .join()");return new Cu({channels:{...this.channels,...Object.fromEntries(t.map(r=>[r,r]))},triggers:this.triggers,mapper:this.mapper,writers:this.writers,bound:this.bound,kwargs:this.kwargs,config:this.config,retryPolicy:this.retryPolicy,cachePolicy:this.cachePolicy,timeout:this.timeout})}pipe(t){return ot.isWriter(t)?new Cu({channels:this.channels,triggers:this.triggers,mapper:this.mapper,writers:[...this.writers,t],bound:this.bound,config:this.config,kwargs:this.kwargs,retryPolicy:this.retryPolicy,cachePolicy:this.cachePolicy,timeout:this.timeout}):this.bound===Ic?new Cu({channels:this.channels,triggers:this.triggers,mapper:this.mapper,writers:this.writers,bound:tt(t),config:this.config,kwargs:this.kwargs,retryPolicy:this.retryPolicy,cachePolicy:this.cachePolicy,timeout:this.timeout}):new Cu({channels:this.channels,triggers:this.triggers,mapper:this.mapper,writers:this.writers,bound:this.bound.pipe(t),config:this.config,kwargs:this.kwargs,retryPolicy:this.retryPolicy,cachePolicy:this.cachePolicy,timeout:this.timeout})}};function ZV(e){return"steps"in e&&Array.isArray(e.steps)}function Au(e){return"lg_is_pregel"in e&&e.lg_is_pregel===!0}function hh(e){let t=[e];for(let r of t){if(Au(r))return r;ZV(r)&&t.push(...r.steps)}}function Vo(e,t,r=!0,i=!1){try{return e[t].get()}catch(n){if(n.name===Pe.unminifiable_name){if(i)return n;if(r)return null}throw n}}function Sn(e,t,r=!0){if(Array.isArray(t)){let i={};for(let n of t)try{i[n]=Vo(e,n,!r)}catch(a){if(a.name===Pe.unminifiable_name)continue}return i}else return Vo(e,t)}function*MR(e,t){if(e.graph===dr.PARENT)throw new _e("There is no parent graph.");if(e.goto){let r;Array.isArray(e.goto)?r=e.goto:r=[e.goto];for(let i of r)if(ht(i))yield[Yt,Pn,i];else if(typeof i=="string")yield[Yt,`branch:to:${i}`,"__start__"];else throw new Error(`In Command.send, expected Send or string, got ${typeof i}`)}if(e.resume)if(typeof e.resume=="object"&&Object.keys(e.resume).length&&Object.keys(e.resume).every(fh))for(let[r,i]of Object.entries(e.resume)){let n=t.filter(a=>a[0]===r&&a[1]==="__resume__").map(a=>a[2]).slice(0,1)??[];n.push(i),yield[r,qt,n]}else yield[Yt,qt,e.resume];if(e.update){if(typeof e.update!="object"||!e.update)throw new Error("Expected cmd.update to be a dict mapping channel names to update values");if(Array.isArray(e.update))for(let[r,i]of e.update)yield[Yt,r,i];else for(let[r,i]of Object.entries(e.update))yield[Yt,r,i]}}function*gh(e,t){if(t!=null)if(Array.isArray(e)&&typeof t=="object"&&!Array.isArray(t))for(let r in t)e.includes(r)&&(yield[r,t[r]]);else{if(Array.isArray(e))throw new Error('Input chunk must be an object when "inputChannels" is an array');yield[e,t]}}function*_h(e,t,r){Array.isArray(e)?(t===!0||t.find(([i,n])=>e.includes(i)))&&(yield Sn(r,e)):(t===!0||t.some(([i,n])=>i===e))&&(yield Vo(r,e))}function*jR(e,t,r){let i=t.filter(([s,c])=>(s.config===void 0||!s.config.tags?.includes("langsmith:hidden"))&&c[0][0]!=="__error__"&&c[0][0]!=="__interrupt__");if(!i.length)return;let n;i.some(([s])=>s.writes.some(([c,l])=>c==="__return__"))?n=i.flatMap(([s])=>s.writes.filter(([c,l])=>c===Ui).map(([c,l])=>[s.name,l])):Array.isArray(e)?n=i.flatMap(([s])=>{let{writes:c}=s,l={};for(let[u]of c)e.includes(u)&&(l[u]=(l[u]||0)+1);return Object.values(l).some(u=>u>1)?c.filter(([u])=>e.includes(u)).map(([u,d])=>[s.name,{[u]:d}]):[[s.name,Object.fromEntries(c.filter(([u])=>e.includes(u)))]]}):n=i.flatMap(([s])=>s.writes.filter(([c,l])=>c===e).map(([c,l])=>[s.name,l]));let a={};for(let[s,c]of n)s in a||(a[s]=[]),a[s].push(c);let o={};for(let s in a)if(a[s].length===1){let[c]=a[s];o[s]=c}else o[s]=a[s];r&&(o.__metadata__={cached:r}),yield o}function yh(e){let t=typeof e[He];if(t==="number")return 0;if(t==="string")return"";for(let r in e){if(!Object.prototype.hasOwnProperty.call(e,r))continue;let i=typeof e[r];if(i==="number")return 0;if(i==="string")return"";break}}function Tc(e,t){if(Object.keys(e).length>0){let r=yh(t);return Object.fromEntries(Object.entries(t).filter(([i,n])=>n>(e[i]??r)))}else return t}function zR(e,t){return e&&!Array.isArray(e)&&!(e instanceof Date)&&typeof e=="object"?e:{[t]:e}}function wt(e,t){return e===null?{configurable:t}:e?.configurable===void 0?{...e,configurable:t}:{...e,configurable:{...e.configurable,...t}}}function Ea(e,t){let r=t?.parents??{};return Object.keys(r).length>0?wt(e,{[jt]:{...r,[e.configurable?.checkpoint_ns??""]:e.configurable?.checkpoint_id}}):e}function Ia(...e){let t=[...new Set(e.filter(Boolean))];if(t.length===0)return{signal:void 0,dispose:void 0};if(t.length===1)return{signal:t[0],dispose:void 0};let r=new AbortController,i=()=>{let a=t.find(o=>o.aborted)?.reason;r.abort(a),t.forEach(o=>o.removeEventListener("abort",i))};t.forEach(a=>a.addEventListener("abort",i,{once:!0}));let n=t.find(a=>a.aborted);return n&&r.abort(n.reason),{signal:r.signal,dispose:()=>{t.forEach(a=>a.removeEventListener("abort",i))}}}var DR=(e,t)=>{if(!(!e&&!t))return e?t?Array.isArray(e)&&Array.isArray(t)?[...e,...t]:Array.isArray(e)?[...e,t]:Array.isArray(t)?[e,...t]:[e,t]:e:t};var UR=class{func;name;input;retry;cache;timeout;callbacks;__lg_type="call";constructor({func:e,name:t,input:r,retry:i,cache:n,timeout:a,callbacks:o}){this.func=e,this.name=t,this.input=r,this.retry=i,this.cache=n,this.timeout=a,this.callbacks=o}};function LR(e){return typeof e=="object"&&e!==null&&"__lg_type"in e&&e.__lg_type==="call"}function FR(e,t){return new Pr({name:e,first:new Tt({func:r=>t(...r),name:e,trace:!1,recurse:!1}),last:new ot([{channel:Ui,value:wr}],[ut])})}function BR(e,t){return new Tt({func:(r,i)=>t(r,i),name:e,trace:!1,recurse:!1})}function VR({func:e,name:t,cache:r,retry:i,timeout:n},...a){let o=Ae.getRunnableConfig();if(typeof o.configurable?.__pregel_call=="function")return o.configurable[On](e,t,a,{retry:i,cache:r,timeout:n,callbacks:o.callbacks});throw new Error("Async local storage not initialized. Please call initializeAsyncLocalStorageSingleton() before using this function.")}var ZR=e=>e!==void 0?e+1:1;function HV(e,t){if(t==null)return!1;for(let r of e)if(t[r])return!0;return!1}function GV(e){let t;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t==null?t=e[r]:t=Su(t,e[r]));return t}function Ou(e,t,r){let i=yh(e.channel_versions),n=e.versions_seen.__interrupt__??{},a=!1;if((e.channel_versions.__start__??i)>(n.__start__??i))a=!0;else for(let s in e.channel_versions)if(Object.prototype.hasOwnProperty.call(e.channel_versions,s)&&e.channel_versions[s]>(n[s]??i)){a=!0;break}let o=r.some(s=>t==="*"?!s.config?.tags?.includes(ut):t.includes(s.name));return a&&o}function Cc(e,t,r,i,n=!1){let a=new Set;if(Array.isArray(i))a=new Set(i.filter(s=>r.writes.some(([c,l])=>c===s)));else{for(let[s]of r.writes)if(s===i){a=new Set([s]);break}a=a||new Set}let o;if(n&&a.size>0){let s=Object.fromEntries(Object.entries(t).filter(([d,f])=>a.has(d))),c=new Set;for(let d in s){if(!Object.prototype.hasOwnProperty.call(s,d))continue;let f=s[d];yn(f)&&f.isAvailable()&&c.add(d)}let l=vn(e,s,-1,{channelsToSnapshot:c}),u=Ym(s,l);lr(_n(l),u,[r],void 0,void 0),o=Sn({...t,...u},i)}else o=Sn(t,i);return o}function vh(e,t,r){for(let[i,n]of r)if(["__pregel_push","__pregel_tasks"].includes(i)&&n!=null){if(!ht(n))throw new _e(`Invalid packet type, expected SendProtocol, got ${JSON.stringify(n)}`);if(!(n.node in t))throw new _e(`Invalid node name "${n.node}" in Send packet`)}e(r)}var WV=new Set([Dc,Xt,qt,je,Ui,ji,Mc]),JV=new Set(NS);function lr(e,t,r,i,n){let a=new Map;for(let p of r)a.set(p,p.path?.slice(0,3)||[]);r.sort((p,m)=>{let h=a.get(p),_=a.get(m);for(let b=0;b<Math.min(h.length,_.length);b+=1){if(h[b]<_[b])return-1;if(h[b]>_[b])return 1}return h.length-_.length});let o=bc(t),s=!1,c=new Set;for(let p of r){p.triggers.length>0&&(s=!0),e.versions_seen[p.name]??={};for(let m of p.triggers)m in e.channel_versions&&(e.versions_seen[p.name][m]=e.channel_versions[m]),JV.has(m)||c.add(m)}let l=GV(e.channel_versions),u=!1;for(let p of c)p in o&&o[p].consume()&&i!==void 0&&(e.channel_versions[p]=i(l),u=!0);let d={};for(let p of r)for(let[m,h]of p.writes)WV.has(m)||m in o&&(d[m]??=[],d[m].push(h));l!=null&&i!=null&&(l=u?i(l):l);let f=new Set;for(let[p,m]of Object.entries(d))if(p in o){let h=o[p],_;try{_=h.update(m)}catch(b){if(b.name===_e.unminifiable_name){let w=new _e(`Invalid update for channel "${p}" with values ${JSON.stringify(m)}: ${b.message}`);throw w.lc_error_code=b.lc_error_code,w}else throw b}_&&i!==void 0&&(e.channel_versions[p]=i(l),h.isAvailable()&&f.add(p))}if(s)for(let p in o){if(!Object.prototype.hasOwnProperty.call(o,p))continue;let m=o[p];m.isAvailable()&&!f.has(p)&&m.update([])&&i!==void 0&&(e.channel_versions[p]=i(l),m.isAvailable()&&f.add(p))}if(s&&!HV(f,n))for(let p in o){if(!Object.prototype.hasOwnProperty.call(o,p))continue;let m=o[p];m.finish()&&i!==void 0&&(e.channel_versions[p]=i(l),m.isAvailable()&&f.add(p))}return f}function*KV(e,t,r){if(r.updatedChannels!=null&&r.triggerToNodes!=null){let i=new Set;for(let n of r.updatedChannels){let a=r.triggerToNodes[n];for(let o of a??[])i.add(o)}yield*[...i].sort();return}if(!(()=>{for(let i in e.channel_versions)if(e.channel_versions[i]!==null)return!1;return!0})())for(let i in t)Object.prototype.hasOwnProperty.call(t,i)&&(yield i)}function qV(e){let t,r=new Map,i=new Set;if(e)for(let[n,a,o]of e){if(n==="00000000-0000-0000-0000-000000000000"&&a==="__resume__"&&t===void 0&&(t=o),a==="__resume__"&&n!=="00000000-0000-0000-0000-000000000000"){let s=r.get(n);s||(s=[],r.set(n,s)),s.push(o)}a!=="__error__"&&i.add(n)}return{nullResume:t,resumeByTaskId:r,successfulWriteTaskIds:i}}function Ta(e,t,r,i,n,a,o){let s={},c=o.pendingWritesIndex?o:{...o,pendingWritesIndex:qV(t)},l=i[Pn];if(l?.isAvailable()){let u=l.get().length;for(let d=0;d<u;d+=1){let f=wh([Xt,d],e,t,r,i,n,a,c);f!==void 0&&(s[f.id]=f)}}for(let u of KV(e,r,c)){let d=wh([Lu,u],e,t,r,i,n,a,c);d!==void 0&&(s[d.id]=d)}return s}function wh(e,t,r,i,n,a,o,s){let{step:c,checkpointer:l,manager:u}=s,d=a.configurable??{},f=d.checkpoint_ns??"";if(e[0]==="__pregel_push"&&LR(e[e.length-1])){let p=e[e.length-1],m=FR(p.name,p.func),h=[Xt],_=f===""?p.name:`${f}|${p.name}`,b=Nn(JSON.stringify([_,c.toString(),p.name,Xt,e[1],e[2]]),t.id),w=`${_}:${b}`,S=[...e.slice(0,3),!0],x={langgraph_step:c,langgraph_node:p.name,langgraph_triggers:h,langgraph_path:S,langgraph_checkpoint_ns:w,checkpoint_ns:w};if(o){let E=[],z={checkpointId:t.id,checkpointNs:w,taskId:b,threadId:d.thread_id,runId:a.runId!=null?String(a.runId):void 0,nodeAttempt:1};return{name:p.name,input:p.input,proc:m,writes:E,config:{...Se(vt(a,{metadata:x,store:s.store??a.store}),{runName:p.name,callbacks:u?.getChild(`graph:step:${c}`),configurable:{[Wo]:b,[Mt]:C=>vh(v=>E.push(...v),i,C),[jr]:(C,v=!1)=>Cc(t,n,{name:p.name,writes:E,triggers:h,path:S},C,v),[zr]:l??d.__pregel_checkpointer,[jt]:{...d[jt],[f]:t.id},[Kt]:bh({pendingWrites:r??[],taskId:b,currentTaskInput:p.input,resumeMap:a.configurable?.[Da],namespaceHash:ii(w),pendingWritesIndex:s.pendingWritesIndex}),[zi]:t.channel_values[Li],checkpoint_id:void 0,checkpoint_ns:w}}),executionInfo:z},triggers:h,retry_policy:p.retry,cache_key:p.cache?{key:ii((p.cache.keyFunc??JSON.stringify)([p.input])),ns:[Du,p.name??"__dynamic__"],ttl:p.cache.ttl}:void 0,id:b,path:S,writers:[],timeout:p.timeout}}else return{id:b,name:p.name,interrupts:[],path:S}}else if(e[0]==="__pregel_push"){let p=typeof e[1]=="number"?e[1]:parseInt(e[1],10);if(!n.__pregel_tasks?.isAvailable())return;let m=n[Pn].get();if(p<0||p>=m.length)return;let h=Fu(m[p])&&!ht(m[p])?new ja(m[p].node,m[p].args,m[p].timeout!==void 0?{timeout:m[p].timeout}:void 0):m[p];if(!Fu(h)){console.warn(`Ignoring invalid packet ${JSON.stringify(h)} in pending sends.`);return}if(!(h.node in i)){console.warn(`Ignoring unknown node name ${h.node} in pending sends.`);return}let _=[Xt],b=f===""?h.node:`${f}|${h.node}`,w=Nn(JSON.stringify([b,c.toString(),h.node,Xt,p.toString()]),t.id),S=`${b}:${w}`,x={langgraph_step:c,langgraph_node:h.node,langgraph_triggers:_,langgraph_path:e.slice(0,3),langgraph_checkpoint_ns:S,checkpoint_ns:S};if(o){let E=i[h.node],z=E.getNode();if(z!==void 0){E.metadata!==void 0&&(x={...x,...E.metadata});let C=[],v={checkpointId:t.id,checkpointNs:S,taskId:w,threadId:d.thread_id,runId:a.runId!=null?String(a.runId):void 0,nodeAttempt:1};return{name:h.node,input:h.args,proc:z,subgraphs:E.subgraphs,writes:C,config:{...Se(vt(a,{metadata:x,tags:E.tags,store:s.store??a.store}),{runName:h.node,callbacks:u?.getChild(`graph:step:${c}`),configurable:{[Wo]:w,[Mt]:Z=>vh(B=>C.push(...B),i,Z),[jr]:(Z,B=!1)=>Cc(t,n,{name:h.node,writes:C,triggers:_,path:e},Z,B),[zr]:l??d.__pregel_checkpointer,[jt]:{...d[jt],[f]:t.id},[Kt]:bh({pendingWrites:r??[],taskId:w,currentTaskInput:h.args,resumeMap:a.configurable?.[Da],namespaceHash:ii(S),pendingWritesIndex:s.pendingWritesIndex}),[zi]:t.channel_values[Li],checkpoint_id:void 0,checkpoint_ns:S}}),executionInfo:v},triggers:_,retry_policy:E.retryPolicy,cache_key:E.cachePolicy?{key:ii((E.cachePolicy.keyFunc??JSON.stringify)([h.args])),ns:[Du,E.name??"__dynamic__",h.node],ttl:E.cachePolicy.ttl}:void 0,id:w,path:e,writers:E.getWriters(),timeout:h.timeout??E.timeout}}}else return{id:w,name:h.node,interrupts:[],path:e}}else if(e[0]==="__pregel_pull"){let p=e[1].toString(),m=i[p];if(m===void 0)return;if(r?.length){let w=f===""?p:`${f}|${p}`,S=Nn(JSON.stringify([w,c.toString(),p,Lu,p]),t.id);if(s.pendingWritesIndex?s.pendingWritesIndex.successfulWriteTaskIds.has(S):r.some(x=>x[0]===S&&x[1]!=="__error__"))return}let h=yh(t.channel_versions);if(h===void 0)return;let _=t.versions_seen[p]??{},b=m.triggers.find(w=>n[w].isAvailable()?(t.channel_versions[w]??h)>(_[w]??h):!1);if(b!==void 0){let w=XV(m,n,o);if(w===void 0)return;let S=f===""?p:`${f}|${p}`,x=Nn(JSON.stringify([S,c.toString(),p,Lu,[b]]),t.id),E=`${S}:${x}`,z={langgraph_step:c,langgraph_node:p,langgraph_triggers:[b],langgraph_path:e,langgraph_checkpoint_ns:E,checkpoint_ns:E};if(o){let C=m.getNode();if(C!==void 0){m.metadata!==void 0&&(z={...z,...m.metadata});let v=[],Z={checkpointId:t.id,checkpointNs:E,taskId:x,threadId:d.thread_id,runId:a.runId!=null?String(a.runId):void 0,nodeAttempt:1};return{name:p,input:w,proc:C,subgraphs:m.subgraphs,writes:v,config:{...Se(vt(a,{metadata:z,tags:m.tags,store:s.store??a.store}),{runName:p,callbacks:u?.getChild(`graph:step:${c}`),configurable:{[Wo]:x,[Mt]:B=>vh(A=>{v.push(...A)},i,B),[jr]:(B,A=!1)=>Cc(t,n,{name:p,writes:v,triggers:[b],path:e},B,A),[zr]:l??d.__pregel_checkpointer,[jt]:{...d[jt],[f]:t.id},[Kt]:bh({pendingWrites:r??[],taskId:x,currentTaskInput:w,resumeMap:a.configurable?.[Da],namespaceHash:ii(E),pendingWritesIndex:s.pendingWritesIndex}),[zi]:t.channel_values[Li],checkpoint_id:void 0,checkpoint_ns:E}}),executionInfo:Z},triggers:[b],retry_policy:m.retryPolicy,cache_key:m.cachePolicy?{key:ii((m.cachePolicy.keyFunc??JSON.stringify)([w])),ns:[Du,m.name??"__dynamic__",p],ttl:m.cachePolicy.ttl}:void 0,id:x,path:e,writers:m.getWriters(),timeout:m.timeout}}}else return{id:x,name:p,interrupts:[],path:e}}}}function HR(e,t,r,i,n,a,o,s,c){let{step:l,checkpointer:u,manager:d}=c,f=a[t];if(f===void 0)return;let p=f.getNode();if(p===void 0)return;let m=s.configurable??{},h=m.checkpoint_ns??"",_=[Xt],b=h===""?t:`${h}|${t}`,w=Nn(JSON.stringify([b,l.toString(),t,Xt,"node_error_handler",e.id]),i.id),S=`${b}:${w}`,x=[Xt,String(e.name),t,!1],E={langgraph_step:l,langgraph_node:t,langgraph_triggers:_,langgraph_path:x,langgraph_checkpoint_ns:S,checkpoint_ns:S};f.metadata!==void 0&&(E={...E,...f.metadata});let z=[],C={checkpointId:i.id,checkpointNs:S,taskId:w,threadId:m.thread_id,runId:s.runId!=null?String(s.runId):void 0,nodeAttempt:1};return{name:t,input:e.input,proc:p,subgraphs:f.subgraphs,writes:z,config:{...Se(vt(s,{metadata:E,tags:f.tags,store:c.store??s.store}),{runName:t,callbacks:d?.getChild(`graph:step:${l}`),configurable:{[Wo]:w,[Mt]:v=>vh(Z=>z.push(...Z),a,v),[jr]:(v,Z=!1)=>Cc(i,o,{name:t,writes:z,triggers:_,path:x},v,Z),[zr]:u??m.__pregel_checkpointer,[jt]:{...m[jt],[h]:i.id},[Kt]:bh({pendingWrites:n??[],taskId:w,currentTaskInput:e.input,resumeMap:s.configurable?.[Da],namespaceHash:ii(S)}),[zi]:i.channel_values[Li],[zc]:new Wu(String(e.name),r),checkpoint_id:void 0,checkpoint_ns:S}}),executionInfo:C},triggers:_,retry_policy:f.retryPolicy,cache_key:void 0,id:w,path:x,writers:f.getWriters()}}function XV(e,t,r){let i;if(typeof e.channels=="object"&&!Array.isArray(e.channels)){i={};for(let[n,a]of Object.entries(e.channels))if(e.triggers.includes(a))try{i[n]=Vo(t,a,!1)}catch(o){if(o.name===Pe.unminifiable_name)return;throw o}else if(a in t)try{i[n]=Vo(t,a,!1)}catch(o){if(o.name===Pe.unminifiable_name)continue;throw o}}else if(Array.isArray(e.channels)){let n=!1;for(let a of e.channels)try{i=Vo(t,a,!1),n=!0;break}catch(o){if(o.name===Pe.unminifiable_name)continue;throw o}if(!n)return}else throw new Error(`Invalid channels type, expected list or dict, got ${e.channels}`);return r&&e.mapper!==void 0&&(i=e.mapper(i)),i}function GR(e,t){if(typeof e.args!="object"||e.args===null)return e;let r={};for(let[i,n]of Object.entries(e.args)){let a=t[i];(!a||a.lc_graph_name!=="UntrackedValue")&&(r[i]=n)}return new ja(e.node,r)}function bh({pendingWrites:e,taskId:t,currentTaskInput:r,resumeMap:i,namespaceHash:n,pendingWritesIndex:a}){let o=a?a.nullResume:e.find(([c,l])=>c==="00000000-0000-0000-0000-000000000000"&&l==="__resume__")?.[2],s={callCounter:0,interruptCounter:-1,resume:(()=>{let c=a?(a.resumeByTaskId.get(t)??[]).flat():e.filter(([l,u])=>l===t&&u==="__resume__").flatMap(([l,u,d])=>d);if(i!=null&&n in i){let l=i[n];c.push(l)}return c})(),nullResume:o,subgraphCounter:0,currentTaskInput:r,consumeNullResume:()=>{if(s.nullResume)return delete s.nullResume,e.splice(e.findIndex(([c,l])=>c==="00000000-0000-0000-0000-000000000000"&&l==="__resume__"),1),o}};return s}var Pu={blue:{start:"\x1B[34m",end:"\x1B[0m"},green:{start:"\x1B[32m",end:"\x1B[0m"},yellow:{start:"\x1B[33;1m",end:"\x1B[0m"}},Nu=(e,t)=>`${e.start}${t}${e.end}`;function*xh(e){for(let{id:t,name:r,input:i,config:n,triggers:a,writes:o}of e)n?.tags?.includes("langsmith:hidden")||(yield{id:t,name:r,input:i,triggers:a,interrupts:o.filter(([s,c])=>s===t&&c==="__interrupt__").map(([,s])=>s)})}function YV(e){return typeof e!="object"||e===null?!1:"$writes"in e&&Array.isArray(e.$writes)}function WR(e){let t={};for(let[r,i]of e){let n=String(r);if(n in t){let a=YV(t[n])?t[n].$writes:[t[n]];a.push(i),t[n]={$writes:a}}else t[n]=i}return t}function*JR(e,t){for(let[{id:r,name:i,config:n},a]of e)n?.tags?.includes("langsmith:hidden")||(yield{id:r,name:i,result:WR(a.filter(([o])=>Array.isArray(t)?t.includes(o):o===t)),interrupts:a.filter(o=>o[0]===je).map(o=>o[1])})}function*KR(e,t,r,i,n,a,o,s){function c(d){let f={};return d.callbacks!=null&&(f.callbacks=d.callbacks),d.configurable!=null&&(f.configurable=d.configurable),d.maxConcurrency!=null&&(f.max_concurrency=d.maxConcurrency),d.metadata!=null&&(f.metadata=d.metadata),d.recursionLimit!=null&&(f.recursion_limit=d.recursionLimit),d.runId!=null&&(f.run_id=d.runId),d.runName!=null&&(f.run_name=d.runName),d.tags!=null&&(f.tags=d.tags),f}let l=e.configurable?.checkpoint_ns,u={};for(let d of n){if(!(d.subgraphs?.length?d.subgraphs:[d.proc]).find(hh))continue;let f=`${d.name}:${d.id}`;l&&(f=`${l}|${f}`),u[d.id]={configurable:{thread_id:e.configurable?.thread_id,checkpoint_ns:f}}}yield{config:c(e),values:Sn(t,r),metadata:i,next:n.map(d=>d.name),tasks:cS(n,a,u,s),parentConfig:o?c(o):void 0}}function cS(e,t,r,i){return e.map(n=>{let a=t.find(([l,u])=>l===n.id&&u==="__error__")?.[2],o=t.filter(([l,u])=>l===n.id&&u==="__interrupt__").map(([,,l])=>l),s=(()=>{if(a||o.length||!t.length)return;let l=t.findIndex(([u,d])=>u===n.id&&d==="__return__");if(l>=0)return t[l][2];if(typeof i=="string")return t.find(([u,d])=>u===n.id&&d===i)?.[2];if(Array.isArray(i)){let u=t.filter(([d,f])=>d===n.id&&i.includes(f)).map(([,d,f])=>[d,f]);return u.length?WR(u):void 0}})();if(a)return{id:n.id,name:n.name,path:n.path,error:a,interrupts:o,result:s};let c=r?.[n.id];return{id:n.id,name:n.name,path:n.path,interrupts:o,...c!==void 0?{state:c}:{},result:s}})}function qR(e,t,r){console.log([`${Nu(Pu.blue,`[${e}:checkpoint]`)}`,`\x1B[1m State at the end of step ${e}:\x1B[0m
419
- `,JSON.stringify(Sn(t,r),null,2)].join(""))}function Ru(e,t){let r=t.length;console.log([`${Nu(Pu.blue,`[${e}:tasks]`)}`,`\x1B[1m Starting step ${e} with ${r} task${r===1?"":"s"}:\x1B[0m
420
- `,t.map(i=>`- ${Nu(Pu.green,String(i.name))} -> ${JSON.stringify(i.input,null,2)}`).join(`
421
- `)].join(""))}function XR(e,t,r){let i={};for(let[n,a]of t)r.includes(n)&&(i[n]||(i[n]=[]),i[n].push(a));console.log([`${Nu(Pu.blue,`[${e}:writes]`)}`,`\x1B[1m Finished step ${e} with writes to ${Object.keys(i).length} channel${Object.keys(i).length!==1?"s":""}:\x1B[0m
422
- `,Object.entries(i).map(([n,a])=>`- ${Nu(Pu.yellow,n)} -> ${a.map(o=>JSON.stringify(o)).join(", ")}`).join(`
423
- `)].join(""))}var Sh=class extends dt{_abortController;_innerReader;constructor(e,t){let r=e.getReader(),i=t??new AbortController;super({start(n){return a();function a(){return r.read().then(({done:o,value:s})=>{if(o){n.close();return}return n.enqueue(s),a()})}}}),this._abortController=i,this._innerReader=r}async cancel(e){this._abortController.abort(e),this._innerReader.releaseLock()}get signal(){return this._abortController.signal}},uS=class extends dt{modes;controller;passthroughFn;_closed=!1;get closed(){return this._closed}constructor(e){let t,r=new Promise(i=>{t=i});super({start:i=>{t(i)}}),r.then(i=>{this.controller=i}),this.passthroughFn=e.passthroughFn,this.modes=e.modes}push(e){this._closed||!this.controller||(this.passthroughFn?.(e),this.controller.enqueue(e))}close(){try{this.controller.close()}catch{}finally{this._closed=!0}}error(e){try{this.controller?.error(e)}finally{this._closed=!0}}},eM=class extends tr{name="StreamToolsHandler";awaitHandlers=!0;streamFn;runs={};constructor(e){super(),this.streamFn=e}handleToolStart(e,t,r,i,n,a,o,s){if(!a||n&&n.includes("langsmith:hidden"))return;let c=a.langgraph_checkpoint_ns?.split("|")??[],l={ns:c,toolCallId:s,toolName:o??"unknown",input:t};this.runs[r]=l,this.streamFn([c,"tools",{event:"on_tool_start",toolCallId:l.toolCallId,name:l.toolName,input:t}])}handleToolEvent(e,t){let r=this.runs[t];r&&this.streamFn([r.ns,"tools",{event:"on_tool_event",toolCallId:r.toolCallId,name:r.toolName,data:e}])}handleToolEnd(e,t){let r=this.runs[t];delete this.runs[t],r&&this.streamFn([r.ns,"tools",{event:"on_tool_end",toolCallId:r.toolCallId,name:r.toolName,output:e}])}handleToolError(e,t){let r=this.runs[t];delete this.runs[t],r&&this.streamFn([r.ns,"tools",{event:"on_tool_error",toolCallId:r.toolCallId,name:r.toolName,error:e}])}};function QV(e){return JSON.stringify(e,function(t,r){let i=this[t];if(i!=null&&typeof i=="object"&&"toDict"in i&&typeof i.toDict=="function"){let{type:n,data:a}=i.toDict();return{...a,type:n}}return r})}function e9(e){return e instanceof Error?{error:e.name,message:e.message}:{error:"Error",message:JSON.stringify(e)}}function dS(e){return typeof e!="object"||e==null?!1:"configurable"in e&&typeof e.configurable=="object"&&e.configurable!=null}function lS(e){return!dS(e)||!e.configurable.thread_id?null:{thread_id:e.configurable.thread_id,checkpoint_ns:e.configurable.checkpoint_ns||"",checkpoint_id:e.configurable.checkpoint_id||null,checkpoint_map:e.configurable.checkpoint_map||null}}function YR(e){if(dS(e)){let t=Object.fromEntries(Object.entries(e.configurable).filter(([i])=>!i.startsWith("__"))),r={...e,configurable:t};return delete r.callbacks,r}return e}function QR(e){let t={...e,checkpoint:lS(e.config),parent_checkpoint:lS(e.parentConfig),config:YR(e.config),parent_config:YR(e.parentConfig),tasks:e.tasks.map(r=>{if(dS(r.state)){let i=lS(r.state);if(i!=null){let n={...r,checkpoint:i};return delete n.state,n}}return r})};return delete t.parentConfig,t}function tM(e){let t=new TextEncoder;return new ReadableStream({async start(r){let i=n=>{r.enqueue(t.encode(`event: ${n.event}
424
- data: ${QV(n.data)}
425
-
426
- `))};try{for await(let n of e){let[a,o,s]=n,c=s;if(o==="debug"){let l=s;l.type==="checkpoint"&&(c={...l,payload:QR(l.payload)})}o==="checkpoints"&&(c=QR(s)),i({event:a?.length?`${o}|${a.join("|")}`:o,data:c})}}catch(n){i({event:"error",data:e9(n)})}r.close()}})}function rM(...e){return new uS({passthroughFn:t=>{let r=t[1]==="checkpoints"&&Sc(t[2]);for(let i of e)(i.modes.has(t[1])||r)&&i.push(t)},modes:new Set(e.flatMap(t=>Array.from(t.modes)))})}var nM=class{checkpointId;#e=new Set;constructor(e){this.checkpointId=e}#t(e){let t=e.includes(":")?e.slice(0,e.lastIndexOf(":")):e;return this.#e.has(t)?!1:(this.#e.add(t),!0)}async getCheckpoint(e,t,r){if(this.#t(e)){let i=[];for await(let n of t.list(r,{before:{configurable:{checkpoint_id:this.checkpointId}},limit:1}))i.push(n);return i.length>0?i[0]:void 0}return await t.getTuple(r)??void 0}};var kh=Symbol.for("INPUT_DONE"),fS=Symbol.for("INPUT_RESUMING"),t9=25;function iM(e){if(!(e==null||typeof e!="object")){if(Te.isInstance(e)){let t=e;t.id==null&&(t.id=Zi(),t.lc_kwargs!=null&&(t.lc_kwargs.id=t.id));return}if(Array.isArray(e)){for(let t of e)iM(t);return}}}function aM(e){return e===void 0||e===""?[]:e.split("|")}function r9(e){if(!e)return[];let t="";for(let r of Object.keys(e))r!==""&&r.length>t.length&&(t=r);return aM(t)}var n9=class extends Xm{cache;queue=Promise.resolve();constructor(e){super(),this.cache=e}async get(e){return this.enqueueOperation("get",e)}async set(e){return this.enqueueOperation("set",e)}async clear(e){return this.enqueueOperation("clear",e)}async stop(){await this.queue}enqueueOperation(e,...t){let r=this.queue.then(()=>this.cache[e](...t));return this.queue=r.then(()=>{},()=>{}),r}},oM=class sM{input;output;config;checkpointer;checkpointerGetNextVersion;channels;checkpoint;checkpointIdSaved;_exitDeltaWrites;_hasPersistedParent=!1;_initialCheckpointConfig;checkpointConfig;checkpointMetadata;checkpointNamespace;checkpointPendingWrites=[];checkpointPreviousVersions;step;stop;durability;outputKeys;streamKeys;nodes;skipDoneTasks;prevCheckpointConfig;updatedChannels;status="pending";control;tasks={};stream;checkpointerPromises=new Set;isNested;resumeAtHead;_checkpointerChainedPromise=Promise.resolve();_trackCheckpointerPromise(t){let r=t.then(i=>(this.checkpointerPromises.delete(r),i),i=>{throw i});this.checkpointerPromises.add(r)}store;cache;manager;interruptAfter;interruptBefore;toInterrupt=[];debug=!1;triggerToNodes;get isResuming(){let t=!1;if("__start__"in this.checkpoint.channel_versions)t=!0;else for(let s in this.checkpoint.channel_versions)if(Object.prototype.hasOwnProperty.call(this.checkpoint.channel_versions,s)){t=!0;break}let r=this.config.configurable?.__pregel_resuming!==void 0&&this.config.configurable?.__pregel_resuming,i=this.input===null||this.input===void 0,n=St(this.input)&&this.input.resume!=null,a=this.input===fS,o=!this.isNested&&this.config.metadata?.run_id!==void 0&&this.checkpointMetadata?.run_id!==void 0&&this.config.metadata.run_id===this.checkpointMetadata?.run_id;return t&&(r||i||n||a||o)}get isReplaying(){return!this.skipDoneTasks}constructor(t){this.input=t.input,this.checkpointer=t.checkpointer,this.checkpointer!==void 0?this.checkpointerGetNextVersion=this.checkpointer.getNextVersion.bind(this.checkpointer):this.checkpointerGetNextVersion=ZR,this.checkpoint=t.checkpoint,this.checkpointMetadata=t.checkpointMetadata,this.checkpointPreviousVersions=t.checkpointPreviousVersions,this.channels=t.channels,this.checkpointPendingWrites=t.checkpointPendingWrites,this.step=t.step,this.stop=t.stop,this.config=t.config,this.checkpointConfig=t.checkpointConfig,this.isNested=t.isNested,this.resumeAtHead=t.resumeAtHead,this.manager=t.manager,this.outputKeys=t.outputKeys,this.streamKeys=t.streamKeys,this.nodes=t.nodes,this.skipDoneTasks=t.skipDoneTasks,this.store=t.store,this.cache=t.cache?new n9(t.cache):void 0,this.stream=t.stream,this.checkpointNamespace=t.checkpointNamespace,this.prevCheckpointConfig=t.prevCheckpointConfig,this.interruptAfter=t.interruptAfter,this.interruptBefore=t.interruptBefore,this.durability=t.durability,this.debug=t.debug,this.triggerToNodes=t.triggerToNodes,this.control=this.config.control,this._exitDeltaWrites=this.durability==="exit"&&this.checkpointer!=null?[]:void 0,this._hasPersistedParent=t.hasPersistedParent??!1,this._initialCheckpointConfig=t.checkpointConfig,this.checkpointIdSaved=t.checkpoint.id}static async initialize(t){let{config:r,stream:i}=t;i!==void 0&&r.configurable?.__pregel_stream!==void 0&&(i=rM(i,r.configurable[jc]));let n=r.configurable?!("checkpoint_id"in r.configurable):!0,a=r.configurable?.[Kt];r.configurable&&a&&(a.subgraphCounter>0&&(r=wt(r,{[xr]:[r.configurable[xr],a.subgraphCounter.toString()].join("|")})),a.subgraphCounter+=1);let o=r.configurable?.checkpoint_id,s=jr in(r.configurable??{});!s&&r.configurable?.checkpoint_ns!==void 0&&r.configurable?.checkpoint_ns!==""&&(r=wt(r,{checkpoint_ns:"",checkpoint_id:void 0}));let c=r;r.configurable?.checkpoint_id===void 0&&r.configurable?.checkpoint_map!==void 0&&r.configurable?.checkpoint_map?.[r.configurable?.checkpoint_ns]&&(c=wt(r,{checkpoint_id:r.configurable[jt][r.configurable?.checkpoint_ns]}));let l=aM(r.configurable?.checkpoint_ns),u;t.checkpointer?c.configurable?.checkpoint_id?u=await t.checkpointer.getTuple(c):r.configurable?.__pregel_replay_state?(u=await r.configurable[Uu].getCheckpoint(r.configurable?.checkpoint_ns??"",t.checkpointer,c),r.configurable&&delete r.configurable[za]):u=await t.checkpointer.getTuple(c):u=void 0;let d=u!==void 0;u||(u={config:r,checkpoint:Lo(),metadata:{source:"input",step:-2,parents:{}},pendingWrites:[]}),c={...r,...u.config,configurable:{checkpoint_ns:"",...r.configurable,...u.config.configurable}};let f=u.parentConfig,p=_n(u.checkpoint),m={...u.metadata},h=u.pendingWrites??[],_=r.configurable?.checkpoint_ns,b=r.configurable?.[jt];typeof _=="string"&&_!==""&&typeof b=="object"&&b!==null&&_ in b&&h.length>0&&(h=h.filter(([,B])=>B!==qt));let w=!1,S=c.configurable?.thread_id,x=c.configurable?.checkpoint_ns??"";t.checkpointer&&o&&typeof S=="string"&&(w=(await t.checkpointer.getTuple({configurable:{thread_id:S,checkpoint_ns:x}}))?.config.configurable?.checkpoint_id===o&&m.source!=="update"&&m.source!=="fork");let E=await wc(t.channelSpecs,p,{saver:t.checkpointer,config:c}),z=(m.step??0)+1,C=z+(r.recursionLimit??t9)+1,v={...p.channel_versions},Z=t.store?new qm(t.store):void 0;return Z&&await Z.start(),new sM({input:t.input,config:r,checkpointer:t.checkpointer,checkpoint:p,checkpointMetadata:m,checkpointConfig:c,prevCheckpointConfig:f,checkpointNamespace:l,channels:E,isNested:s,resumeAtHead:w,manager:t.manager,skipDoneTasks:n,step:z,stop:C,checkpointPreviousVersions:v,checkpointPendingWrites:h,outputKeys:t.outputKeys??[],streamKeys:t.streamKeys??[],nodes:t.nodes,stream:i,store:Z,cache:t.cache,interruptAfter:t.interruptAfter,interruptBefore:t.interruptBefore,durability:t.durability,debug:t.debug,triggerToNodes:t.triggerToNodes,hasPersistedParent:d})}_checkpointerPutAfterPrevious(t){this._checkpointerChainedPromise=this._checkpointerChainedPromise.then(()=>this.checkpointer?.put(t.config,t.checkpoint,t.metadata,t.newVersions)),this._trackCheckpointerPromise(this._checkpointerChainedPromise)}putWrites(t,r){let i=r;if(i.length===0)return;i.every(([c])=>c in ku)&&(i=Array.from(new Map(i.map(c=>[c[0],c])).values()));let n=!1;for(let c in this.channels)if(Object.prototype.hasOwnProperty.call(this.channels,c)&&this.channels[c].lc_graph_name==="UntrackedValue"){n=!0;break}let a=i;n&&(a=i.filter(([c])=>{let l=this.channels[c];return!l||l.lc_graph_name!=="UntrackedValue"}).map(([c,l])=>c==="__pregel_tasks"&&ht(l)?[c,GR(l,this.channels)]:[c,l])),this.checkpointPendingWrites=this.checkpointPendingWrites.filter(c=>c[0]!==t);for(let[c,l]of a)this.checkpointPendingWrites.push([t,c,l]);for(let[c,l]of a){let u=this.channels[c];u!=null&&yn(u)&&iM(l)}let o=wt(this.checkpointConfig,{[xr]:this.config.configurable?.checkpoint_ns??"",[Di]:this.checkpoint.id});if(this.durability!=="exit"&&this.checkpointer!=null&&this._trackCheckpointerPromise(this.checkpointer.putWrites(o,a,t)),this.tasks&&this._outputWrites(t,i),!r.length||!this.cache||!this.tasks)return;let s=this.tasks[t];s==null||s.cache_key==null||r[0][0]==="__error__"||r[0][0]==="__interrupt__"||this.cache.set([{key:[s.cache_key.ns,s.cache_key.key],value:s.writes,ttl:s.cache_key.ttl}])}_outputWrites(t,r,i=!1){let n=this.tasks[t];if(n!==void 0){if(n.config!==void 0&&(n.config.tags??[]).includes("langsmith:hidden"))return;if(r.length>0)if(r[0][0]==="__interrupt__"){if(n.path?.[0]==="__pregel_push"&&n.path?.[n.path.length-1]===!0)return;let a=r.filter(o=>o[0]===je).flatMap(o=>o[1]);this._emit([["updates",{[je]:a}],["values",{[je]:a}]])}else r[0][0]!=="__error__"&&this._emit($a(ai(jR(this.outputKeys,[[n,r]],i),"updates")));i||this._emit($a(ai(JR([[n,r]],this.streamKeys),"tasks")))}}async _matchCachedWrites(){if(!this.cache)return[];let t=[],r=([o,s])=>`ns:${o.join(",")}|key:${s}`,i=[],n={};for(let o of Object.values(this.tasks))o.cache_key!=null&&!o.writes.length&&(i.push([o.cache_key.ns,o.cache_key.key]),n[r([o.cache_key.ns,o.cache_key.key])]=o);if(i.length===0)return[];let a=await this.cache.get(i);for(let{key:o,value:s}of a){let c=n[r(o)];c!=null&&(c.writes.push(...s),t.push({task:c,result:s}))}return t}async tick(t){this.store&&!this.store.isRunning&&await this.store?.start();let{inputKeys:r=[]}=t;if(this.status!=="pending")throw new Error(`Cannot tick when status is no longer "pending". Current status: "${this.status}"`);if(![kh,fS].includes(this.input))await this._first(r);else{if(this.toInterrupt.length>0)throw this.status="interrupt_before",new si;if(Object.values(this.tasks).every(n=>n.writes.length>0)){let n=Object.values(this.tasks),a=n.flatMap(s=>s.writes);this.updatedChannels=lr(this.checkpoint,this.channels,n,this.checkpointerGetNextVersion,this.triggerToNodes);let o=await wn(ai(_h(this.outputKeys,a,this.channels),"values"));if(this._exitDeltaWrites!==void 0)for(let[s,c,l]of this.checkpointPendingWrites){let u=this.channels[c];u!=null&&yn(u)&&this._exitDeltaWrites.push([this.step,s,c,l])}if(this.checkpointPendingWrites=[],await this._putCheckpoint({source:"loop"}),this._emitValuesWithCheckpointMeta(o),Ou(this.checkpoint,this.interruptAfter,n))throw this.status="interrupt_after",new si;this.config.configurable?.__pregel_resuming!==void 0&&delete this.config.configurable?.[za]}else return!1}if(this.step>this.stop)return this.status="out_of_steps",!1;this.tasks=Ta(this.checkpoint,this.checkpointPendingWrites,this.nodes,this.channels,this.config,!0,{step:this.step,checkpointer:this.checkpointer,isResuming:this.isResuming,manager:this.manager,store:this.store,stream:this.stream,triggerToNodes:this.triggerToNodes,updatedChannels:this.updatedChannels});let i=Object.values(this.tasks);if(this.checkpointer&&(this.stream.modes.has("checkpoints")||this.stream.modes.has("debug"))&&this._emit(await wn(ai(KR(this.checkpointConfig,this.channels,this.streamKeys,this.checkpointMetadata,i,this.checkpointPendingWrites,this.prevCheckpointConfig,this.outputKeys),"checkpoints"))),i.length===0)return this.status="done",!1;if(this.control!=null&&this.control.drainRequested)return this.status="draining",!1;if(this.skipDoneTasks&&this.checkpointPendingWrites.length>0){for(let[n,a,o]of this.checkpointPendingWrites){if(a==="__error__"||a==="__error_source_node__"||a==="__interrupt__"||a==="__resume__")continue;let s=i.find(c=>c.id===n);s&&s.writes.push([a,o])}this._resumeErrorHandlersIfApplicable(),i=Object.values(this.tasks);for(let n of i)n.writes.length>0&&this._outputWrites(n.id,n.writes,!0)}if(i.every(n=>n.writes.length>0))return this.tick({inputKeys:r});if(Ou(this.checkpoint,this.interruptBefore,i))throw this.status="interrupt_before",new si;if(this.stream.modes.has("tasks")||this.stream.modes.has("debug")){let n=await wn(ai(xh(i),"tasks"));this._emit(n)}return!0}async finishAndHandleError(t){this.durability==="exit"&&(!this.isNested||typeof t<"u"||this.checkpointNamespace.every(i=>!i.includes(":")))&&(await this._putExitDeltaWrites(),this._putCheckpoint(this.checkpointMetadata),this._flushPendingWrites());let r=this._suppressInterrupt(t);return(r||t===void 0)&&(this.output=Sn(this.channels,this.outputKeys)),r&&(this.tasks!==void 0&&this.checkpointPendingWrites.length>0&&Object.values(this.tasks).some(i=>i.writes.length>0)&&(this.updatedChannels=lr(this.checkpoint,this.channels,Object.values(this.tasks),this.checkpointerGetNextVersion,this.triggerToNodes),this._emitValuesWithCheckpointMeta($a(ai(_h(this.outputKeys,Object.values(this.tasks).flatMap(i=>i.writes),this.channels),"values")))),ci(t)&&!t.interrupts.length&&this._emit([["updates",{[je]:[]}],["values",{[je]:[]}]],this.#e())),r}async acceptPush(t,r,i){if(this.interruptAfter?.length>0&&Ou(this.checkpoint,this.interruptAfter,[t])){this.toInterrupt.push(t);return}let n=wh([Xt,t.path??[],r,t.id,i],this.checkpoint,this.checkpointPendingWrites,this.nodes,this.channels,t.config??{},!0,{step:this.step,checkpointer:this.checkpointer,manager:this.manager,store:this.store,stream:this.stream});if(!n)return;if(this.interruptBefore?.length>0&&Ou(this.checkpoint,this.interruptBefore,[n])){this.toInterrupt.push(n);return}(this.stream.modes.has("tasks")||this.stream.modes.has("debug"))&&this._emit($a(ai(xh([n]),"tasks"))),this.debug&&Ru(this.step,[n]),this.tasks[n.id]=n,this.skipDoneTasks&&this._matchWrites({[n.id]:n});let a=await this._matchCachedWrites();for(let{task:o}of a)this._outputWrites(o.id,o.writes,!0);return n}getErrorHandlerNode(t){return this.nodes[t]?.errorHandlerNode}isErrorHandlerNode(t){return this.nodes[t]?.isErrorHandler===!0}scheduleErrorHandler(t,r){let i=this.getErrorHandlerNode(String(t.name));if(!i)return;let n=HR(t,i,r,this.checkpoint,this.checkpointPendingWrites,this.nodes,this.channels,t.config??this.config,{step:this.step,checkpointer:this.checkpointer,manager:this.manager,store:this.store,stream:this.stream});if(n!==void 0)return this.tasks[n.id]=n,this._emit($a(ai(xh([n]),"tasks"))),this.debug&&Ru(this.step,[n]),n}_resumeErrorHandlersIfApplicable(){let t=new Map;for(let[r,i]of this.checkpointPendingWrites){if(i!=="__error_source_node__")continue;let n=this.checkpointPendingWrites.find(([s,c])=>s===r&&c==="__error__");if(n===void 0)continue;let a=n[2],o=new Error(a?.message??String(a));a?.name&&(o.name=a.name),t.set(r,o)}for(let[r,i]of t){let n=this.tasks[r];n!==void 0&&this.getErrorHandlerNode(String(n.name))&&(n.writes.length===0&&n.writes.push([ji,{message:i.message,name:i.name}]),this.scheduleErrorHandler(n,i))}}_suppressInterrupt(t){return ci(t)&&!this.isNested}async _first(t){let{configurable:r}=this.config,i=r?.[Kt];if(i&&i.nullResume!==void 0&&this.putWrites(Yt,[[qt,i.nullResume]]),St(this.input)){let l=this.input.resume!=null;if(this.input.resume!=null&&typeof this.input.resume=="object"&&Object.keys(this.input.resume).every(fh)&&(this.config.configurable??={},this.config.configurable[Da]=this.input.resume),l&&this.checkpointer==null)throw new Error("Cannot use Command(resume=...) without checkpointer");let u={};for(let[d,f,p]of MR(this.input,this.checkpointPendingWrites))u[d]??=[],u[d].push([f,p]);if(Object.keys(u).length===0)throw new qu("Received empty Command input");for(let[d,f]of Object.entries(u))this.putWrites(d,f)}let n=(this.checkpointPendingWrites??[]).filter(l=>l[0]===Yt).map(l=>l.slice(1));n.length>0&&lr(this.checkpoint,this.channels,[{name:An,writes:n,triggers:[]}],this.checkpointerGetNextVersion,this.triggerToNodes);let a=St(this.input),o=a&&n.length>0,s=this.isReplaying&&(this.isNested&&r?.checkpoint_ns!==void 0&&r?.checkpoint_ns!==""&&r?.checkpoint_map!==void 0&&r.checkpoint_ns in r.checkpoint_map||!(a&&this.input.resume!=null||r?.__pregel_resuming===!0||this.resumeAtHead));s&&(this.checkpointPendingWrites=this.checkpointPendingWrites.filter(l=>l[1]!==qt));let c=this.isResuming;if(c||o){let l={...this.checkpoint.versions_seen[je]};for(let d in this.channels)Object.prototype.hasOwnProperty.call(this.channels,d)&&this.checkpoint.channel_versions[d]!==void 0&&(l[d]=this.checkpoint.channel_versions[d]);this.checkpoint.versions_seen[je]=l,s&&this.checkpointMetadata.source!=="update"&&this.checkpointMetadata.source!=="fork"&&(this.checkpointPendingWrites=this.checkpointPendingWrites.filter(d=>d[1]!==je),await this._putCheckpoint({source:"fork"}));let u=await wn(ai(_h(this.outputKeys,!0,this.channels),"values"));c?this.input=fS:o&&(await this._putCheckpoint({source:"input"}),this.input=kh),this._emitValuesWithCheckpointMeta(u)}else{let l=await wn(gh(t,this.input));if(l.length>0){let u=Ta(this.checkpoint,this.checkpointPendingWrites,this.nodes,this.channels,this.config,!0,{step:this.step});this.updatedChannels=lr(this.checkpoint,this.channels,Object.values(u).concat([{name:An,writes:l,triggers:[]}]),this.checkpointerGetNextVersion,this.triggerToNodes);let d=l.filter(([f])=>{let p=this.channels[f];return p!=null&&yn(p)});if(d.length>0)if(this._exitDeltaWrites!==void 0)for(let[f,p]of d)this._exitDeltaWrites.push([this.step,Yt,f,p]);else this.checkpointer!=null&&this.putWrites(Yt,d);await this._putCheckpoint({source:"input"}),this.input=kh}else if("__pregel_resuming"in(this.config.configurable??{}))this.input=kh;else throw new qu(`Received no input writes for ${JSON.stringify(t,null,2)}`)}if(!this.isNested){let l;if(s){let u=this.checkpoint.id;(this.checkpointMetadata.source==="update"||this.checkpointMetadata.source==="fork")&&this.prevCheckpointConfig&&(u=this.prevCheckpointConfig.configurable?.checkpoint_id??u),l=new nM(u)}this.config=wt(this.config,{[za]:this.isResuming,[Uu]:l})}}#e(){let t=this.checkpointNamespace;if(!(t.length===0||t.length===1&&t[0]==="")||this.config.configurable?.__pregel_stream===void 0)return t;let r=r9(this.config.configurable?.[jt]);return r.length>0?r:t}_emit(t,r=this.checkpointNamespace){for(let[i,n]of t)if(this.stream.modes.has(i)&&this.stream.push([r,i,n]),(i==="checkpoints"||i==="tasks")&&this.stream.modes.has("debug")){let a=i==="checkpoints"?this.step-1:this.step,o=new Date().toISOString(),s=i==="checkpoints"?"checkpoint":typeof n=="object"&&n!=null&&"result"in n?"task_result":"task";this.stream.push([r,"debug",{step:a,type:s,timestamp:o,payload:n}])}}_currentCheckpointMeta(){if(!this.checkpointMetadata||!this.checkpoint?.id)return;let t=this.prevCheckpointConfig?.configurable?.checkpoint_id;return{checkpoint:{id:this.checkpoint.id,...t?{parent_id:t}:{},step:this.checkpointMetadata.step,source:this.checkpointMetadata.source}}}_emitValuesWithCheckpointMeta(t){let r=this._currentCheckpointMeta();for(let[i,n]of t)i==="values"&&r?.checkpoint!=null&&!this.stream.modes.has("checkpoints")&&this.stream.push([this.checkpointNamespace,"checkpoints",r.checkpoint]),this.stream.modes.has(i)&&this.stream.push([this.checkpointNamespace,i,n])}_putCheckpoint(t){let r=this.checkpointMetadata===t,i=this.checkpointer!=null&&(this.durability!=="exit"||r),n=c=>{this.prevCheckpointConfig=this.checkpointConfig?.configurable?.checkpoint_id?this.checkpointConfig:void 0,this.checkpointConfig=wt(this.checkpointConfig,{[xr]:this.config.configurable?.checkpoint_ns??""});let l={...this.checkpoint.channel_versions},u=Tc(this.checkpointPreviousVersions,l);this.checkpointPreviousVersions=l,this._checkpointerPutAfterPrevious({config:{...this.checkpointConfig},checkpoint:_n(c),metadata:{...this.checkpointMetadata},newVersions:u}),this.checkpointConfig={...this.checkpointConfig,configurable:{...this.checkpointConfig.configurable,checkpoint_id:this.checkpoint.id}}},a;if(r)a={...this.checkpointMetadata.counters_since_delta_snapshot??{}};else{let c=this.checkpointMetadata.counters_since_delta_snapshot??{};a={};let l=this.updatedChannels??new Set;for(let u in this.channels){if(!Object.prototype.hasOwnProperty.call(this.channels,u)||!yn(this.channels[u]))continue;let[d,f]=c[u]??[0,0];a[u]=[l.has(u)?d+1:d,f+1]}this.checkpointMetadata={...t,step:this.step,parents:this.config.configurable?.checkpoint_map??{}}}let o=i?Qm(this.channels,a):new Set;this.checkpoint=vn(this.checkpoint,i?this.channels:void 0,this.step,{id:r?this.checkpoint.id:void 0,channelsToSnapshot:o,updatedChannels:this.updatedChannels,getNextVersion:i?c=>this.checkpointerGetNextVersion(c):void 0});for(let c of o)a[c]=[0,0];let s={};for(let c in a){if(!Object.prototype.hasOwnProperty.call(a,c))continue;let[l,u]=a[c];(l!==0||u!==0)&&(s[c]=[l,u])}Object.keys(s).length>0?this.checkpointMetadata.counters_since_delta_snapshot=s:delete this.checkpointMetadata.counters_since_delta_snapshot,i&&n(this.checkpoint),r||(this.step+=1)}async _putExitDeltaWrites(){if(this._exitDeltaWrites===void 0||this._exitDeltaWrites.length===0||this.checkpointer==null||this._initialCheckpointConfig===void 0)return;let t=this.checkpointMetadata.counters_since_delta_snapshot??{},r=Qm(this.channels,t),i=this._exitDeltaWrites.filter(([,,c])=>!r.has(c));if(i.length===0)return;let n;if(this._hasPersistedParent)n=this._initialCheckpointConfig;else{let c=Lo();c.id=this.checkpointIdSaved??c.id,c.ts=new Date().toISOString();let l=wt(this._initialCheckpointConfig,{[Di]:void 0});n=wt(this._initialCheckpointConfig,{[Di]:c.id}),this._trackCheckpointerPromise(this.checkpointer.put(l,c,{source:"loop",step:-2,parents:{}},{})),this.checkpointConfig=n}let a=wt(n,{[xr]:this.config.configurable?.checkpoint_ns??"",[Di]:n.configurable?.[Di]}),o=new Map,s=[];for(let[c,l,u,d]of i){let f=`${c}\0${l}`,p=o.get(f);p===void 0&&(p=[],o.set(f,p),s.push({key:f,step:c,tid:l})),p.push([u,d])}for(let{key:c,step:l,tid:u}of s){let d=`${String(l).padStart(8,"0")}-${u}`;this._trackCheckpointerPromise(this.checkpointer.putWrites(a,o.get(c),d))}}_flushPendingWrites(){if(this.checkpointer==null||this.checkpointPendingWrites.length===0)return;let t=wt(this.checkpointConfig,{[xr]:this.config.configurable?.checkpoint_ns??"",[Di]:this.checkpoint.id}),r={};for(let[i,n,a]of this.checkpointPendingWrites)r[i]??=[],r[i].push([n,a]);for(let[i,n]of Object.entries(r))this._trackCheckpointerPromise(this.checkpointer.putWrites(t,n,i))}_matchWrites(t){for(let[r,i,n]of this.checkpointPendingWrites){if(i==="__error__"||i==="__interrupt__"||i==="__resume__")continue;let a=Object.values(t).find(o=>o.id===r);a&&a.writes.push([i,n])}for(let r of Object.values(t))r.writes.length>0&&this._outputWrites(r.id,r.writes,!0)}};function i9(e){return qe(e?.message)}function cM(e,t,r){if(!e)return;let i=e.langgraph_checkpoint_ns,n=e.checkpoint_ns,a=i??n;if(a)return[a.split("|"),{tags:t,name:r,...e}]}var lM=class extends tr{name="StreamMessagesHandler";streamFn;metadatas={};seen={};emittedChatModelRunIds={};stableMessageIdMap={};lc_prefer_streaming=!0;constructor(e){super(),this.streamFn=e}_emit(e,t,r,i=!1){if(i&&t.id!==void 0&&this.seen[t.id]!==void 0)return;let n=t.id;r!=null&&(Wc(t)?n??=`run-${r}-tool-${t.tool_call_id}`:((n==null||n===`run-${r}`)&&(n=this.stableMessageIdMap[r]??n??`run-${r}`),this.stableMessageIdMap[r]??=n)),n!==t.id&&(t.id=n,t.lc_kwargs.id=n),t.id!=null&&(this.seen[t.id]=t),this.streamFn([e[0],"messages",[t,e[1]]])}handleChatModelStart(e,t,r,i,n,a,o,s){o&&(!a||!a.includes("langsmith:nostream")&&!a.includes("nostream"))&&(this.metadatas[r]=cM(o,a,s))}handleLLMNewToken(e,t,r,i,n,a){let o=a?.chunk;this.emittedChatModelRunIds[r]=!0,this.metadatas[r]!==void 0&&(i9(o)?this._emit(this.metadatas[r],o.message,r):this._emit(this.metadatas[r],new Qe({content:e}),r))}handleLLMEnd(e,t){if(this.metadatas[t]!==void 0){if(!this.emittedChatModelRunIds[t]){let r=e.generations?.[0]?.[0];qe(r?.message)&&this._emit(this.metadatas[t],r?.message,t,!0),delete this.emittedChatModelRunIds[t]}delete this.metadatas[t],delete this.stableMessageIdMap[t]}}handleLLMError(e,t){delete this.metadatas[t]}handleChainStart(e,t,r,i,n,a,o,s){if(a!==void 0&&s===a.langgraph_node&&(n===void 0||!n.includes("langsmith:hidden"))&&(this.metadatas[r]=cM(a,n,s),typeof t=="object")){for(let c of Object.values(t))if((qe(c)||di(c))&&c.id!==void 0)this.seen[c.id]=c;else if(Array.isArray(c))for(let l of c)(qe(l)||di(l))&&l.id!==void 0&&(this.seen[l.id]=l)}}handleChainEnd(e,t){let r=this.metadatas[t];if(delete this.metadatas[t],r!==void 0){if(qe(e))this._emit(r,e,t,!0);else if(Array.isArray(e))for(let i of e)qe(i)&&this._emit(r,i,t,!0);else if(e!=null&&typeof e=="object"){for(let i of Object.values(e))if(qe(i))this._emit(r,i,t,!0);else if(Array.isArray(i))for(let n of i)qe(n)&&this._emit(r,n,t,!0)}}}handleChainError(e,t){delete this.metadatas[t]}};function uM(e){if("response_metadata"in e&&typeof e.response_metadata=="object"&&e.response_metadata!=null)return e.response_metadata}function dM(e){if("usage_metadata"in e&&typeof e.usage_metadata=="object"&&e.usage_metadata!=null)return e.usage_metadata}function a9(e){switch(e.type){case"text":return{type:"text",text:""};case"reasoning":return{type:"reasoning",reasoning:""};case"tool_call":case"tool_call_chunk":return{type:"tool_call_chunk",...e.id!=null?{id:e.id}:{},...e.name!=null?{name:e.name}:{},args:""};default:return e}}function o9(e){switch(e.type){case"text":{let t=typeof e.text=="string"?e.text:"";return t.length>0?{event:"content-block-delta",index:typeof e.index=="number"?e.index:0,delta:{type:"text-delta",text:t}}:void 0}case"reasoning":{let t=typeof e.reasoning=="string"?e.reasoning:"";return t.length>0?{event:"content-block-delta",index:typeof e.index=="number"?e.index:0,delta:{type:"reasoning-delta",reasoning:t}}:void 0}case"tool_call_chunk":return{event:"content-block-delta",index:typeof e.index=="number"?e.index:0,delta:{type:"block-delta",fields:{...e,type:"tool_call_chunk"}}};default:return}}var fM=class extends tr{name="StreamProtocolMessagesHandler";streamFn;metadatas={};seen={};streamedRunIds=new Set;stableMessageIdMap={};lc_prefer_chat_model_stream_events=!0;constructor(e){super(),this.streamFn=e}normalizeMessageId(e,t){let r=e.id;return t!=null&&(_t.isInstance(e)?r??=`run-${t}-tool-${e.tool_call_id}`:((r==null||r===`run-${t}`)&&(r=this.stableMessageIdMap[t]??r??`run-${t}`),this.stableMessageIdMap[t]??=r)),r!==e.id&&(e.id=r,e.lc_kwargs.id=r),e.id!=null&&(this.seen[e.id]=e),e.id}emit(e,t,r){let i=r!=null?{...e[1],run_id:r}:e[1];this.streamFn([e[0],"messages",[t,i]])}emitFinalMessage(e,t,r,i=!1){let n=t.id??(r!=null?this.stableMessageIdMap[r]:void 0);if(i&&n!=null&&this.seen[n]!==void 0)return;let a=this.normalizeMessageId(t,r),o=t.type==="human"?"human":t.type==="system"?"system":t.type==="tool"?"tool":"ai",s=o==="tool"&&_t.isInstance(t)?t.tool_call_id:void 0;this.emit(e,{event:"message-start",...a!=null?{id:a}:{},...o!=="ai"?{role:o}:{},...typeof s=="string"?{tool_call_id:s}:{}},r),(Array.isArray(t.content)?t.content:typeof t.content=="string"&&t.content.length>0?[{type:"text",text:t.content}]:[]).forEach((c,l)=>{let u=typeof c.index=="number"?c.index:l;this.emit(e,{event:"content-block-start",index:u,content:a9(c)},r);let d=o9({...c,index:u});d!=null&&this.emit(e,d,r),this.emit(e,{event:"content-block-finish",index:u,content:c},r)}),this.emit(e,{event:"message-finish",...dM(t)!=null?{usage:dM(t)}:{},...uM(t)!=null?{responseMetadata:uM(t)}:{}},r)}handleChatModelStart(e,t,r,i,n,a,o,s){o&&(!a||!a.includes("langsmith:nostream")&&!a.includes("nostream"))&&(this.metadatas[r]=[o.langgraph_checkpoint_ns.split("|"),{tags:a,name:s,...o}])}handleLLMNewToken(){}handleChatModelStreamEvent(e,t){let r=this.metadatas[t];if(r===void 0)return;let i=e;if(e.event==="message-start"){this.streamedRunIds.add(t);let n=e.id??`run-${t}`;this.seen[n]=!0,this.stableMessageIdMap[t]??=n,e.id==null&&(i={...e,id:n})}this.emit(r,i,t)}handleLLMEnd(e,t){let r=this.metadatas[t];if(r===void 0)return;let i=e.generations?.[0]?.[0],n=Te.isInstance(i?.message)?i.message:void 0;if(n!=null)if(this.streamedRunIds.has(t)){let a=this.normalizeMessageId(n,t);a!=null&&(this.seen[a]=n)}else this.emitFinalMessage(r,n,t,!0);this.streamedRunIds.delete(t),delete this.metadatas[t],delete this.stableMessageIdMap[t]}handleLLMError(e,t){this.streamedRunIds.delete(t),delete this.metadatas[t],delete this.stableMessageIdMap[t]}handleChainStart(e,t,r,i,n,a,o,s){if(a!==void 0&&s===a.langgraph_node&&(n===void 0||!n.includes("langsmith:hidden"))&&(this.metadatas[r]=[a.langgraph_checkpoint_ns.split("|"),{tags:n,name:s,...a}],typeof t=="object")){for(let c of Object.values(t))if((Te.isInstance(c)||$t.isInstance(c))&&c.id!==void 0)this.seen[c.id]=c;else if(Array.isArray(c))for(let l of c)(Te.isInstance(l)||$t.isInstance(l))&&l.id!==void 0&&(this.seen[l.id]=l)}}handleChainEnd(e,t){let r=this.metadatas[t];if(delete this.metadatas[t],r===void 0)return;let i=n=>{Te.isInstance(n)&&!_t.isInstance(n)&&this.emitFinalMessage(r,n,t,!0)};if(Te.isInstance(e))i(e);else if(Array.isArray(e))for(let n of e)i(n);else if(e!=null&&typeof e=="object")for(let n of Object.values(e))if(Array.isArray(n))for(let a of n)i(a);else i(n);delete this.stableMessageIdMap[t]}handleChainError(e,t){delete this.metadatas[t],delete this.stableMessageIdMap[t]}};var s9=class{active=!0;lastProgress=Date.now();refreshOn;constructor(e){this.refreshOn=e}touch(){this.lastProgress=Date.now()}autoTouch(){this.refreshOn==="auto"&&(this.lastProgress=Date.now())}close(){this.active=!1}},c9=class extends tr{name="IdleProgressCallbackHandler";awaitHandlers=!1;#e;constructor(e){super(),this.#e=e}#t=()=>{this.#e.autoTouch()};handleLLMStart=this.#t;handleChatModelStart=this.#t;handleLLMNewToken=this.#t;handleLLMEnd=this.#t;handleLLMError=this.#t;handleChainStart=this.#t;handleChainEnd=this.#t;handleChainError=this.#t;handleToolStart=this.#t;handleToolEnd=this.#t;handleToolError=this.#t;handleText=this.#t;handleRetrieverStart=this.#t;handleRetrieverEnd=this.#t;handleRetrieverError=this.#t;handleCustomEvent=this.#t};function l9(e,t,r,i){let n=e.configurable??{},a={},o=n[Mt];typeof o=="function"&&(a[Mt]=l=>{if(t.active)return l&&l.length&&t.autoTouch(),o(l)});let s=n[On];typeof s=="function"&&(a[On]=(...l)=>{if(!t.active)throw new Error(`Node "${i}" attempt was cancelled after its timeout fired`);return t.autoTouch(),s(...l)});let c={...Object.keys(a).length>0?wt(e,a):e};if(c.heartbeat=()=>{r.idleTimeout!==void 0&&t.touch()},typeof c.writer=="function"){let l=c.writer;c.writer=(u=>{if(t.active)return t.autoTouch(),l(u)})}if((r.refreshOn??"auto")==="auto"&&r.idleTimeout!==void 0){let l=new c9(t),u=c.callbacks;if(u===void 0)c.callbacks=[l];else if(Array.isArray(u))c.callbacks=[...u,l];else{let d=u.copy();d.addHandler(l,!0),c.callbacks=d}}return c}async function pM(e,t,r,i){let n=new s9(r.refreshOn??"auto"),a=new AbortController,{signal:o,dispose:s}=Ia(t.signal,a.signal),c=l9({...t,signal:o},n,r,String(e.name)),l=Date.now(),u=i(c).then(b=>({type:"ok",value:b}),b=>({type:"err",error:b})),d,f,p=()=>{d!==void 0&&clearTimeout(d),f!==void 0&&clearTimeout(f)},m=new Promise(b=>{if(r.runTimeout!==void 0&&(d=setTimeout(()=>b({type:"timeout",kind:"run"}),r.runTimeout)),r.idleTimeout!==void 0){let w=r.idleTimeout,S=()=>{let x=n.lastProgress+w-Date.now();x<=0?b({type:"timeout",kind:"idle"}):f=setTimeout(S,x)};f=setTimeout(S,w)}}),h;try{h=await Promise.race([u,m])}finally{p()}if(h.type!=="timeout"){let b=Date.now();r.runTimeout!==void 0&&b-l>=r.runTimeout?h={type:"timeout",kind:"run"}:r.idleTimeout!==void 0&&b-n.lastProgress>=r.idleTimeout&&(h={type:"timeout",kind:"idle"})}if(h.type==="ok")return s?.(),h.value;if(h.type==="err")throw s?.(),h.error;let _=Date.now()-l;throw n.close(),e.writes.splice(0,e.writes.length),a.abort(),s?.(),new Ku({node:String(e.name),elapsed:_,kind:h.kind,runTimeout:r.runTimeout,idleTimeout:r.idleTimeout})}var u9=[400,401,402,403,404,405,406,407,409],d9=e=>{if(e.message.startsWith("Cancel")||e.message.startsWith("AbortError")||e.name==="AbortError"||e.name==="GraphValueError"||e?.code==="ECONNABORTED")return!1;let t=e?.response?.status??e?.status;return!(t&&u9.includes(+t)||e?.error?.code==="insufficient_quota")};async function $h(e,t,r,i){let n=e.retry_policy??t,a=0,o,s,c=e.config??{};r&&(c=wt(c,r)),c={...c,signal:i};let l=Date.now();for(c.executionInfo!=null&&(c.executionInfo={...c.executionInfo,nodeFirstAttemptTime:l});!i?.aborted;){e.writes.splice(0,e.writes.length),o=void 0;try{e.timeout!==void 0?s=await pM(e,c,e.timeout,u=>e.proc.invoke(e.input,u)):s=await e.proc.invoke(e.input,c);break}catch(u){if(o=u,o.pregelTaskId=e.id,Ph(o)){let h=c?.configurable?.checkpoint_ns,_=o.command;if(_.graph===h){for(let b of e.writers)await b.invoke(_,c);o=void 0;break}else if(_.graph===dr.PARENT){let b=gR(h);o.command=new dr({...o.command,graph:b})}}if(Fi(o)||n===void 0||(a+=1,a>=(n.maxAttempts??3))||!(n.retryOn??d9)(o))break;let d=n.initialInterval??500,f=Math.min(n.maxInterval??128e3,d*(n.backoffFactor??2)**(a-1)),p=n.jitter??!0?f+Math.random()*1e3:f;await new Promise(h=>setTimeout(h,p));let m=o.name??o.constructor.unminifiable_name??o.constructor.name;(n?.logWarning??!0)&&console.log(`Retrying task "${String(e.name)}" after ${p.toFixed(2)}ms (attempt ${a}) after ${m}: ${o}`),c=wt(c,{[za]:!0}),c.executionInfo!=null&&(c.executionInfo={...c.executionInfo,nodeAttempt:a+1,nodeFirstAttemptTime:l})}}return{task:e,result:s,error:o,signalAborted:i?.aborted}}var pS=Symbol.for("promiseAdded");function f9(){let e={next:()=>{},wait:Promise.resolve(pS)};function t(r){e.next=()=>{e.wait=new Promise(t),r(pS)}}return e.wait=new Promise(t),e}var mM=class{nodeFinished;loop;handledExceptions=new WeakSet;constructor({loop:e,nodeFinished:t}){this.loop=e,this.nodeFinished=t}async tick(e={}){let{timeout:t,retryPolicy:r,onStepWrite:i,maxConcurrency:n}=e,a=new Set,o,s=new AbortController,c=s.signal,l=t?AbortSignal.timeout(t):void 0,u=Object.values(this.loop.tasks),d=u.filter(h=>h.writes.length===0),{signals:f,disposeCombinedSignal:p}=this._initializeAbortSignals({exceptionSignal:c,stepTimeoutSignal:l,signal:e.signal}),m=this._executeTasksWithRetry(d,{signals:f,retryPolicy:r,maxConcurrency:n});for await(let{task:h,error:_,signalAborted:b}of m)this._commit(h,_),!(_!==void 0&&this.handledExceptions.has(_))&&(ci(_)||Fi(_)&&!ci(o)?o=_:_&&(a.size===0||!b)&&(s.abort(),a.add(_)));if(p?.(),i?.(this.loop.step,u.map(h=>h.writes).flat()),a.size===1)throw Array.from(a)[0];if(a.size>1)throw new AggregateError(Array.from(a),`Multiple errors occurred during superstep ${this.loop.step}. See the "errors" field of this exception for more details.`);if(ci(o)||Hu(o)||Fi(o)&&this.loop.isNested)throw o}_initializeAbortSignals({exceptionSignal:e,stepTimeoutSignal:t,signal:r}){let i=this.loop.config.configurable?.__pregel_abort_signals??{},n=i.externalAbortSignal??r,a=t??i.timeoutAbortSignal,{signal:o,dispose:s}=Ia(n,a,e),c={externalAbortSignal:n,timeoutAbortSignal:a,composedAbortSignal:o};return this.loop.config=wt(this.loop.config,{[PS]:c}),{signals:c,disposeCombinedSignal:s}}async*_executeTasksWithRetry(e,t){let{retryPolicy:r,maxConcurrency:i,signals:n}=t??{},a=f9(),o={},s={executingTasksMap:o,barrier:a,retryPolicy:r,scheduleTask:async(f,p,m)=>this.loop.acceptPush(f,p,m)};if(n?.composedAbortSignal?.aborted)throw new Error("Abort");let c=0,l,u=Ia(n?.externalAbortSignal,n?.timeoutAbortSignal),d=u.signal?new Promise((f,p)=>{l=()=>p(new Error("Abort")),u.signal?.addEventListener("abort",l,{once:!0})}):void 0;for(;(c===0||Object.keys(o).length>0)&&e.length;){for(;Object.values(o).length<(i??e.length)&&c<e.length;c+=1){let _=e[c];o[_.id]=$h(_,r,{[On]:mS?.bind(s,this,_)},n?.composedAbortSignal).catch(b=>({task:_,error:b,signalAborted:n?.composedAbortSignal?.aborted}))}let f=await Promise.race([...Object.values(o),...d?[d]:[],a.wait]);if(f===pS)continue;let p=f,{task:m,error:h}=p;if(h!==void 0&&!Fi(h)&&!this.loop.isErrorHandlerNode(String(m.name))&&this.loop.getErrorHandlerNode(String(m.name))!==void 0){let _=this.loop.scheduleErrorHandler(m,h);_!==void 0&&(o[_.id]=$h(_,r,{[On]:mS?.bind(s,this,_)},n?.composedAbortSignal).catch(b=>({task:_,error:b,signalAborted:n?.composedAbortSignal?.aborted})),a.next())}yield p,l!=null&&(u.signal?.removeEventListener("abort",l),u.dispose?.()),delete o[f.task.id]}}_shouldRouteToErrorHandler(e){let t=String(e.name);return this.loop.isErrorHandlerNode(t)?!1:this.loop.getErrorHandlerNode(t)!==void 0}_commit(e,t){if(t!==void 0)if(ci(t)){if(t.interrupts.length){let r=t.interrupts.map(n=>[je,n]),i=e.writes.filter(n=>n[0]===qt);i.length&&r.push(...i),this.loop.putWrites(e.id,r)}}else Hu(t)?e.writes.length&&this.loop.putWrites(e.id,e.writes):Fi(t)&&e.writes.length?this.loop.putWrites(e.id,e.writes):(e.writes.push([ji,{message:t.message,name:t.name}]),this._shouldRouteToErrorHandler(e)&&(e.writes.push([Mc,String(e.name)]),this.handledExceptions.add(t)),this.loop.putWrites(e.id,e.writes));else this.nodeFinished&&(e.config?.tags==null||!e.config.tags.includes("langsmith:hidden"))&&this.nodeFinished(String(e.name)),e.writes.length===0&&e.writes.push([Dc,null]),this.loop.putWrites(e.id,e.writes)}};async function mS(e,t,r,i,n,a={}){let o=t.config?.configurable?.[Kt];if(!o)throw new Error(`BUG: No scratchpad found on task ${t.name}__${t.id}`);let s=o.callCounter;o.callCounter+=1;let c=new UR({func:r,name:i,input:n,cache:a.cache,retry:a.retry,timeout:a.timeout,callbacks:a.callbacks}),l=await this.scheduleTask(t,s,c);if(!l)return;let u=this.executingTasksMap[l.id];if(u!==void 0)return u;if(l.writes.length>0){let d=l.writes.filter(([p])=>p===Ui),f=l.writes.filter(([p])=>p===ji);if(d.length>0){if(d.length===1)return Promise.resolve(d[0][1]);throw new Error(`BUG: multiple returns found for task ${l.name}__${l.id}`)}if(f.length>0){if(f.length===1){let p=f[0][1],m=p instanceof Error?p:new Error(String(p));return Promise.reject(m)}throw new Error(`BUG: multiple errors found for task ${l.name}__${l.id}`)}return}else{let d=$h(l,a.retry,{[On]:mS.bind(this,e,l)});return this.executingTasksMap[l.id]=d,this.barrier.next(),d.then(({result:f,error:p})=>p?Promise.reject(p):f)}}var Oi=class extends Error{constructor(e){super(e),this.name="GraphValidationError"}};function hM({nodes:e,channels:t,inputChannels:r,outputChannels:i,streamChannels:n,interruptAfterNodes:a,interruptBeforeNodes:o}){if(!t)throw new Oi("Channels not provided");let s=new Set,c=new Set;for(let[l,u]of Object.entries(e)){if(l==="__interrupt__")throw new Oi(`"Node name ${je} is reserved"`);if(u.constructor===xn)u.triggers.forEach(d=>s.add(d));else throw new Oi(`Invalid node type ${typeof u}, expected PregelNode`)}for(let l of s)if(!(l in t))throw new Oi(`Subscribed channel '${String(l)}' not in channels`);if(Array.isArray(r)){if(r.every(l=>!s.has(l)))throw new Oi(`None of the input channels ${r} are subscribed to by any node`)}else if(!s.has(r))throw new Oi(`Input channel ${String(r)} is not subscribed to by any node`);Array.isArray(i)?i.forEach(l=>c.add(l)):c.add(i),n&&!Array.isArray(n)?c.add(n):Array.isArray(n)&&n.forEach(l=>c.add(l));for(let l of c)if(!(l in t))throw new Oi(`Output channel '${String(l)}' not in channels`);if(a&&a!=="*"){for(let l of a)if(!(l in e))throw new Oi(`Node ${String(l)} not in nodes`)}if(o&&o!=="*"){for(let l of o)if(!(l in e))throw new Oi(`Node ${String(l)} not in nodes`)}}function hS(e,t){if(Array.isArray(e)){for(let r of e)if(!(r in t))throw new Error(`Key ${String(r)} not found in channels`)}else if(!(e in t))throw new Error(`Key ${String(e)} not found in channels`)}var gS=class gM extends pt{lc_graph_name="Topic";unique=!1;accumulate=!1;seen;values;constructor(t){super(),this.unique=t?.unique??this.unique,this.accumulate=t?.accumulate??this.accumulate,this.seen=new Set,this.values=[]}fromCheckpoint(t){let r=new gM({unique:this.unique,accumulate:this.accumulate});return typeof t<"u"&&(r.seen=new Set(t[0]),r.values=t[1]),r}update(t){let r=!1;this.accumulate||(r=this.values.length>0,this.values=[]);let i=t.flat();if(i.length>0)if(this.unique)for(let n of i)this.seen.has(n)||(r=!0,this.seen.add(n),this.values.push(n));else r=!0,this.values.push(...i);return r}get(){if(this.values.length===0)throw new Pe;return this.values}checkpoint(){return[[...this.seen],this.values]}isAvailable(){return this.values.length!==0}};function p9(e){let t=new TextEncoder;return new ReadableStream({async start(r){try{for await(let i of e){let n=i.params.namespace,a=n.length?`${i.method}|${n.join("|")}`:i.method;r.enqueue(t.encode(`event: ${a}
427
- data: ${JSON.stringify(i.params.data??{})}
428
-
429
- `))}}catch(i){r.enqueue(t.encode(`event: error
430
- data: ${JSON.stringify({message:String(i)})}
431
-
432
- `))}finally{r.close()}}})}var _M=class{static subscribeTo(e,t){let{key:r,tags:i}={key:void 0,tags:void 0,...t??{}};if(Array.isArray(e)&&r!==void 0)throw new Error("Can't specify a key when subscribing to multiple channels");let n;return typeof e=="string"?r?n={[r]:e}:n=[e]:n=Object.fromEntries(e.map(a=>[a,a])),new xn({channels:n,triggers:Array.isArray(e)?e:[e],tags:i})}static writeTo(e,t){let r=[];for(let i of e)r.push({channel:i,value:wr,skipNone:!1});for(let[i,n]of Object.entries(t??{}))ae.isRunnable(n)||typeof n=="function"?r.push({channel:i,value:wr,skipNone:!0,mapper:tt(n)}):r.push({channel:i,value:n,skipNone:!1});return new ot(r)}},m9=class extends ae{lc_namespace=["langgraph","pregel"];invoke(e,t){throw new Error("Not implemented")}withConfig(e){return super.withConfig(e)}stream(e,t){return super.stream(e,t)}},Eh=class extends m9{static lc_name(){return"LangGraph"}lc_namespace=["langgraph","pregel"];lg_is_pregel=!0;nodes;channels;inputChannels;outputChannels;autoValidate=!0;streamMode=["values"];streamChannels;interruptAfter;interruptBefore;stepTimeout;debug=!1;checkpointer;retryPolicy;config;store;cache;userInterrupt;streamTransformers;triggerToNodes={};constructor(e){super(e);let{streamMode:t}=e;if(t!=null&&!Array.isArray(t)&&(t=[t]),this.nodes=e.nodes,this.channels=e.channels,"__pregel_tasks"in this.channels&&"lc_graph_name"in this.channels.__pregel_tasks&&this.channels.__pregel_tasks.lc_graph_name!=="Topic")throw new Error(`Channel '${Pn}' is reserved and cannot be used in the graph.`);this.channels[Pn]=new gS({accumulate:!1}),this.autoValidate=e.autoValidate??this.autoValidate,this.streamMode=t??this.streamMode,this.inputChannels=e.inputChannels,this.outputChannels=e.outputChannels,this.streamChannels=e.streamChannels??this.streamChannels,this.interruptAfter=e.interruptAfter,this.interruptBefore=e.interruptBefore,this.stepTimeout=e.stepTimeout??this.stepTimeout,this.debug=e.debug??this.debug,this.checkpointer=e.checkpointer,this.retryPolicy=e.retryPolicy,this.config=e.config,this.store=e.store,this.cache=e.cache,this.name=e.name,this.triggerToNodes=e.triggerToNodes??this.triggerToNodes,this.userInterrupt=e.userInterrupt,this.streamTransformers=e.streamTransformers??[],this.autoValidate&&this.validate()}withConfig(e){let{streamTransformers:t,...r}=e,i=vt(this.config,r),n=[...this.streamTransformers,...t??[]];return new this.constructor({...this,config:i,streamTransformers:n})}validate(){hM({nodes:this.nodes,channels:this.channels,outputChannels:this.outputChannels,inputChannels:this.inputChannels,streamChannels:this.streamChannels,interruptAfterNodes:this.interruptAfter,interruptBeforeNodes:this.interruptBefore});for(let[e,t]of Object.entries(this.nodes))for(let r of t.triggers)this.triggerToNodes[r]??=[],this.triggerToNodes[r].push(e);return this}get streamChannelsList(){return Array.isArray(this.streamChannels)?this.streamChannels:this.streamChannels?[this.streamChannels]:Object.keys(this.channels)}get streamChannelsAsIs(){return this.streamChannels?this.streamChannels:Object.keys(this.channels)}async getGraphAsync(e){return this.getGraph(e)}*getSubgraphs(e,t){for(let[r,i]of Object.entries(this.nodes)){if(e!==void 0&&!e.startsWith(r))continue;let n=i.subgraphs?.length?i.subgraphs:[i.bound];for(let a of n){let o=hh(a);if(o!==void 0){if(r===e){yield[r,o];return}if(e===void 0&&(yield[r,o]),t){let s=e;e!==void 0&&(s=e.slice(r.length+1));for(let[c,l]of o.getSubgraphs(s,t))yield[`${r}|${c}`,l]}}}}}async*getSubgraphsAsync(e,t){yield*this.getSubgraphs(e,t)}async _prepareStateSnapshot({config:e,saved:t,subgraphCheckpointer:r,applyPendingWrites:i=!1}){if(t===void 0)return{values:{},next:[],config:e,tasks:[]};let n=await wc(this.channels,t.checkpoint,{saver:typeof this.checkpointer=="object"?this.checkpointer:void 0,config:t.config??e});if(t.pendingWrites?.length){let d=t.pendingWrites.filter(([f,p])=>f===Yt).map(([f,p,m])=>[String(p),m]);d.length>0&&lr(t.checkpoint,n,[{name:An,writes:d,triggers:[]}],void 0,this.triggerToNodes)}let a=Object.values(Ta(t.checkpoint,t.pendingWrites,this.nodes,n,t.config,!0,{step:(t.metadata?.step??-1)+1,store:this.store})),o=await wn(this.getSubgraphsAsync()),s=t.config.configurable?.checkpoint_ns??"",c={};for(let d of a){let f=o.find(([m])=>m===d.name);if(!f)continue;let p=`${String(d.name)}:${d.id}`;if(s&&(p=`${s}|${p}`),r===void 0){let m={configurable:{thread_id:t.config.configurable?.thread_id,checkpoint_ns:p}};c[d.id]=m}else{let m={configurable:{[zr]:r,thread_id:t.config.configurable?.thread_id,checkpoint_ns:p}},h=f[1];c[d.id]=await h.getState(m,{subgraphs:!0})}}if(i&&t.pendingWrites?.length){let d=Object.fromEntries(a.map(p=>[p.id,p]));for(let[p,m,h]of t.pendingWrites)["__error__","__interrupt__",Ba].includes(m)||p in d&&d[p].writes.push([String(m),h]);let f=a.filter(p=>p.writes.length>0);f.length>0&&lr(t.checkpoint,n,f,void 0,this.triggerToNodes)}let l=t?.metadata;l&&t?.config?.configurable?.thread_id&&(l={...l,thread_id:t.config.configurable.thread_id});let u=a.filter(d=>d.writes.length===0).map(d=>d.name);return{values:Sn(n,this.streamChannelsAsIs),next:u,tasks:cS(a,t?.pendingWrites??[],c,this.streamChannelsAsIs),metadata:l,config:Ea(t.config,t.metadata),createdAt:t.checkpoint.ts,parentConfig:t.parentConfig}}async getState(e,t){let r=e.configurable?.__pregel_checkpointer??this.checkpointer;if(!r)throw new La("No checkpointer set",{lc_error_code:"MISSING_CHECKPOINTER"});let i=e.configurable?.checkpoint_ns??"";if(i!==""&&e.configurable?.__pregel_read===void 0&&e.configurable?.__pregel_checkpointer===void 0){let o=rh(i);for await(let[s,c]of this.getSubgraphsAsync(o,!0))if(s===o)return await c.getState(Bo(e,{[zr]:r}),{subgraphs:t?.subgraphs})}let n=vt(this.config,e),a=await r.getTuple(e);return await this._prepareStateSnapshot({config:n,saved:a,subgraphCheckpointer:t?.subgraphs?r:void 0,applyPendingWrites:!e.configurable?.checkpoint_id})}async*getStateHistory(e,t){let r=e.configurable?.__pregel_checkpointer??this.checkpointer;if(!r)throw new La("No checkpointer set",{lc_error_code:"MISSING_CHECKPOINTER"});let i=e.configurable?.checkpoint_ns??"";if(i!==""&&e.configurable?.__pregel_checkpointer===void 0){let a=rh(i);for await(let[o,s]of this.getSubgraphsAsync(a,!0))if(o===a){yield*s.getStateHistory(Bo(e,{[zr]:r}),t);return}}let n=vt(this.config,e,{configurable:{checkpoint_ns:i}});for await(let a of r.list(n,t))yield this._prepareStateSnapshot({config:a.config,saved:a})}async bulkUpdateState(e,t){let r=e.configurable?.__pregel_checkpointer??this.checkpointer;if(!r)throw new La("No checkpointer set",{lc_error_code:"MISSING_CHECKPOINTER"});if(t.length===0)throw new Error("No supersteps provided");if(t.some(o=>o.updates.length===0))throw new Error("No updates provided");let i=e.configurable?.checkpoint_ns??"";if(i!==""&&e.configurable?.__pregel_checkpointer===void 0){let o=rh(i);for await(let[,s]of this.getSubgraphsAsync(o,!0))return await s.bulkUpdateState(Bo(e,{[zr]:r}),t);throw new Error(`Subgraph "${o}" not found`)}let n=async(o,s)=>{let c=this.config?vt(this.config,o):o,l=await r.getTuple(c),u=l!==void 0?_n(l.checkpoint):Lo(),d={...l?.checkpoint.channel_versions},f=l?.metadata?.step??-1,p=Bo(c,{checkpoint_ns:c.configurable?.checkpoint_ns??""}),m=c.metadata??{};l?.config.configurable&&(p=Bo(c,l.config.configurable),m={...l.metadata,...m});let{values:h,asNode:_}=s[0];if(h==null&&_===void 0){if(s.length>1)throw new _e("Cannot create empty checkpoint with multiple updates");return Ea(await r.put(p,vn(u,void 0,f),{source:"update",step:f+1,parents:l?.metadata?.parents??{}},{}),l?l.metadata:void 0)}let b=await wc(this.channels,u,{saver:r,config:l?.config??p});if(h===null&&_==="__end__"){if(s.length>1)throw new _e("Cannot apply multiple updates when clearing state");if(l){let C=Ta(u,l.pendingWrites||[],this.nodes,b,l.config,!0,{step:(l.metadata?.step??-1)+1,checkpointer:r,store:this.store}),v=(l.pendingWrites||[]).filter(Z=>Z[0]===Yt).map(Z=>Z.slice(1));v.length>0&&lr(u,b,[{name:An,writes:v,triggers:[]}],r.getNextVersion.bind(r),this.triggerToNodes);for(let[Z,B,A]of l.pendingWrites||[])["__error__","__interrupt__",Ba].includes(B)||Z in C&&C[Z].writes.push([B,A]);lr(u,b,Object.values(C),r.getNextVersion.bind(r),this.triggerToNodes)}return Ea(await r.put(p,vn(u,b,f),{...m,source:"update",step:f+1,parents:l?.metadata?.parents??{}},Tc(d,u.channel_versions)),l?l.metadata:void 0)}if(_==="__copy__"){if(s.length>1)throw new _e("Cannot copy checkpoint with multiple updates");if(l==null)throw new _e("Cannot copy a non-existent checkpoint");let C=B=>!Array.isArray(B)||B.length===0?!1:B.every(A=>Array.isArray(A)&&A.length===2),v=vn(u,void 0,f),Z=await r.put(l.parentConfig??Bo(l.config,{checkpoint_id:void 0}),v,{source:"fork",step:f+1,parents:l.metadata?.parents??{}},{});if(C(h)){let B=Ta(v,l.pendingWrites,this.nodes,b,Z,!1,{step:f+2}),A=Object.values(B).reduce((G,{name:Y,id:Ie})=>(G[Y]??=[],G[Y].push({id:Ie}),G),{}),L=h.reduce((G,Y)=>{let[Ie,me]=Y;G[me]??=[];let En=G[me].length,Rr=A[me]?.[En]?.id;return G[me].push({values:Ie,asNode:me,taskId:Rr}),G},{});return n(Ea(Z,l.metadata),Object.values(L).flat())}return Ea(Z,l.metadata)}if(_==="__input__"){if(s.length>1)throw new _e("Cannot apply multiple updates when updating as input");let C=await wn(gh(this.inputChannels,h));if(C.length===0)throw new _e(`Received no input writes for ${JSON.stringify(this.inputChannels,null,2)}`);lr(u,b,[{name:An,writes:C,triggers:[]}],r.getNextVersion.bind(this.checkpointer),this.triggerToNodes);let v=l?.metadata?.step!=null?l.metadata.step+1:-1,Z=await r.put(p,vn(u,b,v),{source:"input",step:v,parents:l?.metadata?.parents??{}},Tc(d,u.channel_versions));return await r.putWrites(Z,C,Nn(An,u.id)),Ea(Z,l?l.metadata:void 0)}if(c.configurable?.checkpoint_id===void 0&&l?.pendingWrites!==void 0&&l.pendingWrites.length>0){let C=Ta(u,l.pendingWrites,this.nodes,b,l.config,!0,{store:this.store,checkpointer:this.checkpointer,step:(l.metadata?.step??-1)+1}),v=(l.pendingWrites??[]).filter(B=>B[0]===Yt).map(B=>B.slice(1));v.length>0&&lr(l.checkpoint,b,[{name:An,writes:v,triggers:[]}],void 0,this.triggerToNodes);for(let[B,A,L]of l.pendingWrites)["__error__","__interrupt__",Ba].includes(A)||C[B]===void 0||C[B].writes.push([A,L]);let Z=Object.values(C).filter(B=>B.writes.length>0);Z.length>0&&lr(u,b,Z,void 0,this.triggerToNodes)}let w=Object.values(u.versions_seen).map(C=>Object.values(C)).flat().find(C=>!!C),S=[];if(s.length===1){let{values:C,asNode:v,taskId:Z}=s[0];if(v===void 0&&Object.keys(this.nodes).length===1)[v]=Object.keys(this.nodes);else if(v===void 0&&w===void 0)typeof this.inputChannels=="string"&&this.nodes[this.inputChannels]!==void 0&&(v=this.inputChannels);else if(v===void 0){let B=Object.entries(u.versions_seen).map(([A,L])=>Object.values(L).map(G=>[G,A])).flat().filter(([A,L])=>L!==je).sort(([A],[L])=>Jm(A,L));B&&(B.length===1?v=B[0][1]:B[B.length-1][0]!==B[B.length-2][0]&&(v=B[B.length-1][1]))}if(v===void 0)throw new _e('Ambiguous update, specify "asNode"');S.push({values:C,asNode:v,taskId:Z})}else for(let{asNode:C,values:v,taskId:Z}of s){if(C==null)throw new _e('"asNode" is required when applying multiple updates');S.push({values:v,asNode:C,taskId:Z})}let x=[];for(let{asNode:C,values:v,taskId:Z}of S){if(this.nodes[C]===void 0)throw new _e(`Node "${C.toString()}" does not exist`);let B=this.nodes[C].getWriters();if(!B.length)throw new _e(`No writers found for node "${C.toString()}"`);x.push({name:C,input:v,proc:B.length>1?Pr.from(B,{omitSequenceTags:!0}):B[0],writes:[],triggers:[je],id:Z??Nn("__interrupt__",u.id),writers:[]})}for(let C of x)await C.proc.invoke(C.input,Se({...c,store:c?.store??this.store},{runName:c.runName??`${this.getName()}UpdateState`,configurable:{[Mt]:v=>C.writes.push(...v),[jr]:(v,Z=!1)=>Cc(u,b,C,v,Z)}}));for(let C of x){let v=C.writes.filter(Z=>Z[0]!==Xt);l!==void 0&&v.length>0&&await r.putWrites(p,v,C.id)}lr(u,b,x,r.getNextVersion.bind(this.checkpointer),this.triggerToNodes);let E=Tc(d,u.channel_versions),z=await r.put(p,vn(u,b,f+1),{source:"update",step:f+1,parents:l?.metadata?.parents??{}},E);for(let C of x){let v=C.writes.filter(Z=>Z[0]===Xt);v.length>0&&await r.putWrites(z,v,C.id)}return Ea(z,l?l.metadata:void 0)},a=e;for(let{updates:o}of t)a=await n(a,o);return a}async updateState(e,t,r){return this.bulkUpdateState(e,[{updates:[{values:t,asNode:r}]}])}_defaults(e){let{debug:t,streamMode:r,inputKeys:i,outputKeys:n,interruptAfter:a,interruptBefore:o,...s}=e,c=!0,l=t!==void 0?t:this.debug,u=n;u===void 0?u=this.streamChannelsAsIs:hS(u,this.channels);let d=i;d===void 0?d=this.inputChannels:hS(d,this.channels);let f=o??this.interruptBefore??[],p=a??this.interruptAfter??[],m;r!==void 0?(m=Array.isArray(r)?r:[r],c=typeof r=="string"):(e.configurable?.__pregel_task_id!==void 0?m=["values"]:m=this.streamMode,c=!0);let h;if(this.checkpointer===!1)h=void 0;else if(e!==void 0&&e.configurable?.__pregel_checkpointer!==void 0)h=e.configurable[zr];else{if(this.checkpointer===!0)throw new Error("checkpointer: true cannot be used for root graphs.");h=this.checkpointer}let _=e.store??this.store,b=e.cache??this.cache;if(e.durability!=null&&e.checkpointDuring!=null)throw new Error("Cannot use both `durability` and `checkpointDuring` at the same time.");let w=(()=>{if(e.checkpointDuring!=null)return e.checkpointDuring===!1?"exit":"async"})(),S=e.durability??w??e?.configurable?.__pregel_durability??"async";return[l,m,d,u,s,f,p,h,_,c,b,S]}async stream(e,t){let r=new AbortController,i={recursionLimit:this.config?.recursionLimit,...t,signal:Ia(t?.signal,r.signal).signal},n=await super.stream(e,i);return new Sh(t?.encoding==="text/event-stream"?tM(n):n,r)}async#e(e,t){let{version:r,encoding:i,transformers:n,...a}=t,o={recursionLimit:this.config?.recursionLimit,...a,configurable:{...this.config?.configurable,...a?.configurable},version:r,streamMode:F0,subgraphs:!0,encoding:void 0},s=this.stream(e,o),c=Y0({[Symbol.asyncIterator]:async function*(){let l=await s;for await(let u of l)yield u}},[...this.streamTransformers??[],...n??[]]);if(i==="text/event-stream"){let l=new AbortController;return l.signal.addEventListener("abort",()=>c.abort(l.signal.reason),{once:!0}),new Sh(p9(c),l)}return c}streamEvents(e,t,r){if(t.version==="v3")return this.#e(e,t);let i=new AbortController,n={recursionLimit:this.config?.recursionLimit,...t,callbacks:DR(this.config?.callbacks,t?.callbacks),signal:Ia(t?.signal,i.signal).signal};return new Sh(super.streamEvents(e,n,r),i)}async _validateInput(e){return e}async _validateContext(e){return e}async*_streamIterator(e,t){let r="version"in(t??{})?void 0:t?.encoding??void 0,i=t?.subgraphs,n=t?.version==="v3",a=xc(this.config,t);if(a.recursionLimit===void 0||a.recursionLimit<1)throw new Error('Passed "recursionLimit" must be at least 1.');if(this.checkpointer!==void 0&&this.checkpointer!==!1&&a.configurable===void 0)throw new Error('Checkpointer requires one or more of the following "configurable" keys: "thread_id", "checkpoint_ns", "checkpoint_id"');let o=await this._validateInput(e),{runId:s,...c}=a,[l,u,,d,f,p,m,h,_,b,w,S]=this._defaults(c);f.metadata={ls_integration:"langgraph",...f.metadata},typeof f.context<"u"?f.context=await this._validateContext(f.context):f.configurable=await this._validateContext(f.configurable);let x=new uS({modes:new Set(u)});if(this.checkpointer===!0){f.configurable??={};let L=f.configurable.checkpoint_ns??"";f.configurable[xr]=L.split("|").map(G=>G.split(":")[0]).join("|")}if(u.includes("messages")){let L=n?new fM(Y=>x.push(Y)):new lM(Y=>x.push(Y)),{callbacks:G}=f;if(G===void 0)f.callbacks=[L];else if(Array.isArray(G))f.callbacks=G.concat(L);else{let Y=G.copy();Y.addHandler(L,!0),f.callbacks=Y}}if(u.includes("tools")){let L=new eM(Y=>x.push(Y)),{callbacks:G}=f;if(G===void 0)f.callbacks=[L];else if(Array.isArray(G))f.callbacks=G.concat(L);else{let Y=G.copy();Y.addHandler(L,!0),f.callbacks=Y}}f.writer??=L=>{if(!u.includes("custom"))return;let G=U0()?.configurable?.[xr]?.split("|").slice(0,-1);x.push([G??[],"custom",L])},f.interrupt??=this.userInterrupt??rS,f.serverInfo==null&&(f.serverInfo=h9(f)),f.control??=new L0;let E={tracerInheritableMetadata:y9(f)},z=await(await et._configureSync(f?.callbacks,void 0,f?.tags,void 0,f?.metadata,void 0,E))?.handleChainStart(this.toJSON(),zR(e,"input"),s,void 0,void 0,void 0,f?.runName??this.getName()),C=bc(this.channels),v,Z,A=(async()=>{try{v=await oM.initialize({input:o,config:f,checkpointer:h,nodes:this.nodes,channelSpecs:C,outputKeys:d,streamKeys:this.streamChannelsAsIs,store:_,cache:w,stream:x,interruptAfter:m,interruptBefore:p,manager:z,debug:this.debug,triggerToNodes:this.triggerToNodes,durability:S});let L=new mM({loop:v,nodeFinished:f.configurable?.[OS]});t?.subgraphs&&(v.config.configurable={...v.config.configurable,[jc]:v.stream}),await this._runLoop({loop:v,runner:L,debug:l,config:f}),S==="sync"&&await Promise.all(v?.checkpointerPromises??[])}catch(L){Z=L}finally{try{v&&(await v.store?.stop(),await v.cache?.stop()),await Promise.all(v?.checkpointerPromises??[])}catch(L){Z=Z??L}Z?(await new Promise(L=>{queueMicrotask(L)}),x.error(Z)):x.close()}})();try{for await(let L of x){if(L===void 0)throw new Error("Data structure error.");let[G,Y,Ie]=L,me="version"in(t??{});if(u.includes(Y)||Y==="checkpoints"&&Sc(Ie)&&(n||me&&i&&u.includes("values"))){if(r==="text/event-stream"){i?yield[G,Y,Ie]:yield[null,Y,Ie];continue}i&&!b?yield[G,Y,Ie]:b?i?yield[G,Ie]:yield Ie:yield[Y,Ie]}}}catch(L){throw await z?.handleChainError(Z),L}finally{await A}await z?.handleChainEnd(v?.output??{},s,void 0,void 0,void 0)}async invoke(e,t){let r=t?.streamMode??"values",i={...t,outputKeys:t?.outputKeys??this.outputChannels,streamMode:r,encoding:void 0},n=[],a=await this.stream(e,i),o=[],s;for await(let c of a)r==="values"?Ua(c)?o.push(c[je]):s=c:n.push(c);if(r==="values"){if(o.length>0){let c=o.flat(1);if(s==null)return{[je]:c};if(typeof s=="object")return{...s,[je]:c}}return s}return n}async _runLoop(e){let{loop:t,runner:r,debug:i,config:n}=e,a;try{for(;await t.tick({inputKeys:this.inputChannels});){for(let{task:o}of await t._matchCachedWrites())t._outputWrites(o.id,o.writes,!0);i&&qR(t.checkpointMetadata.step,t.channels,this.streamChannelsList),i&&Ru(t.step,Object.values(t.tasks)),await r.tick({timeout:this.stepTimeout,retryPolicy:this.retryPolicy,onStepWrite:(o,s)=>{i&&XR(o,s,this.streamChannelsList)},maxConcurrency:n.maxConcurrency,signal:n.signal})}if(t.status==="draining")throw t.control==null?new Error("Draining status requires run control"):new Zu(t.control.drainReason??"shutdown");if(t.status==="out_of_steps")throw new Oh([`Recursion limit of ${n.recursionLimit} reached`,"without hitting a stop condition. You can increase the",'limit by setting the "recursionLimit" config key.'].join(" "),{lc_error_code:"GRAPH_RECURSION_LIMIT"})}catch(o){if(a=o,!await t.finishAndHandleError(a))throw o}finally{a===void 0&&await t.finishAndHandleError()}}async clearCache(){await this.cache?.clear([])}};function h9(e){let t=e.metadata??{},r=e.configurable??{},i=r.assistant_id??t.assistant_id,n=r.graph_id??t.graph_id,a=r.langgraph_auth_user,o;if(a!=null&&typeof a=="object"&&"identity"in a&&(o=a),i!=null||n!=null||o!=null)return{assistantId:i!=null?String(i):"",graphId:n!=null?String(n):"",user:o}}var g9=new Set(["key","token","secret","password","auth"]);function _9(e,t){let r=e.toLowerCase(),i=!1;for(let n of g9)if(r.includes(n)){i=!0;break}return e.startsWith("__")||!(typeof t=="string"||typeof t=="number"||typeof t=="boolean")||i}function y9(e){let t=e.configurable;if(!t)return;let r={};for(let[i,n]of Object.entries(t))_9(i,n)||(r[i]=n);return Object.keys(r).length>0?r:void 0}var kn=class yM extends pt{lc_graph_name="EphemeralValue";guard;value=[];constructor(t=!0){super(),this.guard=t}fromCheckpoint(t){let r=new yM(this.guard);return typeof t<"u"&&(r.value=[t]),r}update(t){if(t.length===0){let r=this.value.length>0;return this.value=[],r}if(t.length!==1&&this.guard)throw new _e("EphemeralValue can only receive one value per step.");return this.value=[t[t.length-1]],!0}get(){if(this.value.length===0)throw new Pe;return this.value[0]}checkpoint(){if(this.value.length===0)throw new Pe;return this.value[0]}isAvailable(){return this.value.length!==0}};var _S=class{path;ends;constructor(e){ae.isRunnable(e.path)?this.path=e.path:this.path=tt(e.path),this.ends=Array.isArray(e.pathMap)?e.pathMap.reduce((t,r)=>(t[r]=r,t),{}):e.pathMap}run(e,t){return ot.registerWriter(new Tt({name:"<branch_run>",trace:!1,func:async(r,i)=>{try{return await this._route(r,i,e,t)}catch(n){throw n.name===Gu.unminifiable_name&&console.warn(`[WARN]: 'NodeInterrupt' thrown in conditional edge. This is likely a bug in your graph implementation.
433
- NodeInterrupt should only be thrown inside a node, not in edge conditions.`),n}}}))}async _route(e,t,r,i){let n=await this.path.invoke(i?i(t):e,t);Array.isArray(n)||(n=[n]);let a;if(this.ends?a=n.map(o=>ht(o)?o:this.ends[o]):a=n,a.some(o=>!o))throw new Error("Branch condition returned unknown or null destination");if(a.filter(ht).some(o=>o.node==="__end__"))throw new _e("Cannot send a packet to the END node");return await r(a,t)??e}},yS=class{nodes;edges;branches;entryPoint;compiled=!1;constructor(){this.nodes={},this.edges=new Set,this.branches={}}warnIfCompiled(e){this.compiled&&console.warn(e)}get allEdges(){return this.edges}addNode(...e){function t(i){return i.length>=1&&typeof i[0]!="string"}let r=t(e)?Array.isArray(e[0])?e[0]:Object.entries(e[0]):[[e[0],e[1],e[2]]];if(r.length===0)throw new Error("No nodes provided in `addNode`");for(let[i,n,a]of r){for(let s of["|",":"])if(i.includes(s))throw new Error(`"${s}" is a reserved character and is not allowed in node names.`);if(this.warnIfCompiled("Adding a node to a graph that has already been compiled. This will not be reflected in the compiled graph."),i in this.nodes)throw new Error(`Node \`${i}\` already present.`);if(i==="__end__")throw new Error(`Node \`${i}\` is reserved.`);let o=tt(n);this.nodes[i]={runnable:o,metadata:a?.metadata,subgraphs:Au(o)?[o]:a?.subgraphs,ends:a?.ends}}return this}addEdge(e,t){if(this.warnIfCompiled("Adding an edge to a graph that has already been compiled. This will not be reflected in the compiled graph."),e==="__end__")throw new Error("END cannot be a start node");if(t==="__start__")throw new Error("START cannot be an end node");if(Array.from(this.edges).some(([r])=>r===e)&&!("channels"in this))throw new Error(`Already found path for ${e}. For multiple edges, use StateGraph.`);return this.edges.add([e,t]),this}addConditionalEdges(e,t,r){let i=typeof e=="object"?e:{source:e,path:t,pathMap:r};this.warnIfCompiled("Adding an edge to a graph that has already been compiled. This will not be reflected in the compiled graph."),ae.isRunnable(i.path)||(i.path=tt(i.path));let n=i.path.getName()==="RunnableLambda"?"condition":i.path.getName();if(this.branches[i.source]&&this.branches[i.source][n])throw new Error(`Condition \`${n}\` already present for node \`${e}\``);return this.branches[i.source]??={},this.branches[i.source][n]=new _S(i),this}setEntryPoint(e){return this.warnIfCompiled("Setting the entry point of a graph that has already been compiled. This will not be reflected in the compiled graph."),this.addEdge(He,e)}setFinishPoint(e){return this.warnIfCompiled("Setting a finish point of a graph that has already been compiled. This will not be reflected in the compiled graph."),this.addEdge(e,Je)}compile({checkpointer:e,interruptBefore:t,interruptAfter:r,name:i,transformers:n}={}){this.validate([...Array.isArray(t)?t:[],...Array.isArray(r)?r:[]]);let a=new vS({builder:this,checkpointer:e,interruptAfter:r,interruptBefore:t,autoValidate:!1,nodes:{},channels:{[He]:new kn,[Je]:new kn},inputChannels:He,outputChannels:Je,streamChannels:[],streamMode:"values",name:i,streamTransformers:n});for(let[o,s]of Object.entries(this.nodes))a.attachNode(o,s);for(let[o,s]of this.edges)a.attachEdge(o,s);for(let[o,s]of Object.entries(this.branches))for(let[c,l]of Object.entries(s))a.attachBranch(o,c,l);return a.validate()}validate(e){let t=new Set([...this.allEdges].map(([i,n])=>i));for(let[i]of Object.entries(this.branches))t.add(i);for(let i of t)if(i!=="__start__"&&!(i in this.nodes))throw new Error(`Found edge starting at unknown node \`${i}\``);let r=new Set([...this.allEdges].map(([i,n])=>n));for(let[i,n]of Object.entries(this.branches))for(let a of Object.values(n))if(a.ends!=null)for(let o of Object.values(a.ends))r.add(o);else{r.add(Je);for(let o of Object.keys(this.nodes))o!==i&&r.add(o)}for(let i of Object.values(this.nodes))for(let n of i.ends??[])r.add(n);if(Object.values(this.nodes).some(i=>i.isErrorHandler))for(let i of Object.keys(this.nodes))r.add(i);for(let i of Object.keys(this.nodes))if(!this.nodes[i].isErrorHandler&&!r.has(i))throw new Nh([`Node \`${i}\` is not reachable.`,"","If you are returning Command objects from your node,",'make sure you are passing names of potential destination nodes as an "ends" array','into ".addNode(..., { ends: ["node1", "node2"] })".'].join(`
434
- `),{lc_error_code:"UNREACHABLE_NODE"});for(let i of r)if(i!=="__end__"&&!(i in this.nodes))throw new Error(`Found edge ending at unknown node \`${i}\``);if(e){for(let i of e)if(!(i in this.nodes))throw new Error(`Interrupt node \`${i}\` is not present`)}this.compiled=!0}},vS=class extends Eh{builder;constructor({builder:e,...t}){super(t),this.builder=e}withConfig(e){return super.withConfig(e)}attachNode(e,t){this.channels[e]=new kn,this.nodes[e]=new xn({channels:[],triggers:[],metadata:t.metadata,subgraphs:t.subgraphs,ends:t.ends}).pipe(t.runnable).pipe(new ot([{channel:e,value:wr}],[ut])),this.streamChannels.push(e)}attachEdge(e,t){if(t==="__end__"){if(e==="__start__")throw new Error("Cannot have an edge from START to END");this.nodes[e].writers.push(new ot([{channel:Je,value:wr}],[ut]))}else this.nodes[t].triggers.push(e),this.nodes[t].channels.push(e)}attachBranch(e,t,r){e==="__start__"&&!this.nodes.__start__&&(this.nodes[He]=_M.subscribeTo(He,{tags:[ut]})),this.nodes[e].pipe(r.run(n=>new ot(n.map(a=>ht(a)?a:{channel:a==="__end__"?Je:`branch:${e}:${t}:${a}`,value:wr}),[ut])));let i=r.ends?Object.values(r.ends):Object.keys(this.nodes);for(let n of i)if(n!=="__end__"){let a=`branch:${e}:${t}:${n}`;this.channels[a]=new kn,this.nodes[n].triggers.push(a),this.nodes[n].channels.push(a)}}async getGraphAsync(e){let t=e?.xray,r=new Ro,i={[He]:r.addNode({schema:Xr.any()},He)},n={},a={};t&&(a=Object.fromEntries((await wn(this.getSubgraphsAsync())).filter(l=>vM(l[1]))));let o=[];function s(l,u,d,f=!1){if(u==="__end__"&&n.__end__===void 0&&(n[Je]=r.addNode({schema:Xr.any()},Je)),i[l]!==void 0){if(n[u]===void 0)throw new Error(`End node ${u} not found!`);return o.push({src:l,dest:u,conditional:f}),r.addEdge(i[l],n[u],d!==u?d:void 0,f)}}for(let[l,u]of Object.entries(this.builder.nodes)){let d=xt(l),f=u.runnable,p=u.metadata??{};if(this.interruptBefore?.includes(l)&&this.interruptAfter?.includes(l)?p.__interrupt="before,after":this.interruptBefore?.includes(l)?p.__interrupt="before":this.interruptAfter?.includes(l)&&(p.__interrupt="after"),t){let m=typeof t=="number"?t-1:t,h=a[l]!==void 0?await a[l].getGraphAsync({...e,xray:m}):f.getGraph(e);if(h.trimFirstNode(),h.trimLastNode(),Object.keys(h.nodes).length>1){let w=function(x){return x?x.lc_runnable:!1},S=function(x,E){if(x!==void 0&&!li(x))return x;if(w(E))try{let z=E.getName();return z=z.startsWith("Runnable")?z.slice(8):z,z}catch{return E.getName()}else return E.name??"UnknownSchema"},[_,b]=r.extend(h,d);if(_===void 0)throw new Error(`Could not extend subgraph "${l}" due to missing entrypoint.`);b!==void 0&&(i[d]={name:S(b.id,b.data),...b}),n[d]={name:S(_.id,_.data),..._}}else{let _=r.addNode(f,d,p);i[d]=_,n[d]=_}}else{let m=r.addNode(f,d,p);i[d]=m,n[d]=m}}let c=[...this.builder.allEdges].sort(([l],[u])=>l<u?-1:u>l?1:0);for(let[l,u]of c)s(xt(l),xt(u));for(let[l,u]of Object.entries(this.builder.branches)){let d={...Object.fromEntries(Object.keys(this.builder.nodes).filter(f=>f!==l).map(f=>[xt(f),xt(f)])),[Je]:Je};for(let f of Object.values(u)){let p;f.ends!==void 0?p=f.ends:p=d;for(let[m,h]of Object.entries(p))s(xt(l),xt(h),m,!0)}}for(let[l,u]of Object.entries(this.builder.nodes))if(u.ends!==void 0)for(let d of u.ends)s(xt(l),xt(d),void 0,!0);return bM(this.builder.nodes,o,s),r}getGraph(e){let t=e?.xray,r=new Ro,i={[He]:r.addNode({schema:Xr.any()},He)},n={},a={};t&&(a=Object.fromEntries($a(this.getSubgraphs()).filter(l=>vM(l[1]))));let o=[];function s(l,u,d,f=!1){if(u==="__end__"&&n.__end__===void 0&&(n[Je]=r.addNode({schema:Xr.any()},Je)),i[l]!==void 0){if(n[u]===void 0)throw new Error(`End node ${u} not found!`);return o.push({src:l,dest:u,conditional:f}),r.addEdge(i[l],n[u],d!==u?d:void 0,f)}}for(let[l,u]of Object.entries(this.builder.nodes)){let d=xt(l),f=u.runnable,p=u.metadata??{};if(this.interruptBefore?.includes(l)&&this.interruptAfter?.includes(l)?p.__interrupt="before,after":this.interruptBefore?.includes(l)?p.__interrupt="before":this.interruptAfter?.includes(l)&&(p.__interrupt="after"),t){let m=typeof t=="number"?t-1:t,h=a[l]!==void 0?a[l].getGraph({...e,xray:m}):f.getGraph(e);if(h.trimFirstNode(),h.trimLastNode(),Object.keys(h.nodes).length>1){let w=function(x){return x?x.lc_runnable:!1},S=function(x,E){if(x!==void 0&&!li(x))return x;if(w(E))try{let z=E.getName();return z=z.startsWith("Runnable")?z.slice(8):z,z}catch{return E.getName()}else return E.name??"UnknownSchema"},[_,b]=r.extend(h,d);if(_===void 0)throw new Error(`Could not extend subgraph "${l}" due to missing entrypoint.`);b!==void 0&&(i[d]={name:S(b.id,b.data),...b}),n[d]={name:S(_.id,_.data),..._}}else{let _=r.addNode(f,d,p);i[d]=_,n[d]=_}}else{let m=r.addNode(f,d,p);i[d]=m,n[d]=m}}let c=[...this.builder.allEdges].sort(([l],[u])=>l<u?-1:u>l?1:0);for(let[l,u]of c)s(xt(l),xt(u));for(let[l,u]of Object.entries(this.builder.branches)){let d={...Object.fromEntries(Object.keys(this.builder.nodes).filter(f=>f!==l).map(f=>[xt(f),xt(f)])),[Je]:Je};for(let f of Object.values(u)){let p;f.ends!==void 0?p=f.ends:p=d;for(let[m,h]of Object.entries(p))s(xt(l),xt(h),m,!0)}}for(let[l,u]of Object.entries(this.builder.nodes))if(u.ends!==void 0)for(let d of u.ends)s(xt(l),xt(d),void 0,!0);return bM(this.builder.nodes,o,s),r}};function vM(e){return typeof e.attachNode=="function"&&typeof e.attachEdge=="function"}function xt(e){return e==="subgraph"?`"${e}"`:e}function bM(e,t,r){let i=new Set(t.map(a=>a.src)),n=[...new Set(t.filter(a=>!a.conditional&&a.dest!=="__end__").map(a=>a.dest))].sort();for(let a of n){if(i.has(a))continue;let o=Object.keys(e).find(s=>xt(s)===a);o!==void 0&&e[o]?.isErrorHandler||r(a,Je)}}function Pi(e){return typeof e=="object"&&e!==null&&"~standard"in e&&typeof e["~standard"]=="object"&&e["~standard"]!==null&&"validate"in e["~standard"]}function bS(e){return typeof e=="object"&&e!==null&&"~standard"in e&&typeof e["~standard"]=="object"&&e["~standard"]!==null&&"jsonSchema"in e["~standard"]}function v9(e){return Pi(e)&&bS(e)}function Ca(e){if(bS(e))try{return e["~standard"].jsonSchema.input({target:"draft-07"})}catch{return}}function Aa(e){if(e!=null&&Pi(e))try{let t=e["~standard"].validate(void 0);if(t&&typeof t=="object"&&!("then"in t&&typeof t.then=="function")){let r=t;if(!r.issues){let i=r.value;return()=>i}}}catch{}}var b9=e=>e!=null&&e.lc_graph_name==="DeltaChannel",wM=class xM extends pt{lc_graph_name="DeltaChannel";value;reducer;snapshotFrequency;initialValueFactory;constructor(t,r){super();let i=r?.snapshotFrequency??1e3;if(!Number.isInteger(i)||i<=0)throw new Error(`snapshotFrequency must be a positive integer, got ${i}`);this.reducer=t,this.snapshotFrequency=i,this.initialValueFactory=r?.initialValueFactory??(()=>[]),this.value=void 0}fromCheckpoint(t){let r=new xM(this.reducer,{snapshotFrequency:this.snapshotFrequency,initialValueFactory:this.initialValueFactory});return t===void 0?r.value=this.initialValueFactory():Fh(t)?r.value=t.value:r.value=t,r}replayWrites(t){let r=t.map(o=>o[2]);if(r.length===0)return;let i=this.value,n=0;for(let o=0;o<r.length;o+=1){let[s,c]=tn(r[o]);s&&(i=c??this.initialValueFactory(),n=o+1)}let a=r.slice(n);this.value=a.length>0?this.reducer(i,a):i}update(t){if(t.length===0)return!1;let r;for(let n=0;n<t.length;n+=1)if(Bu(t[n])){if(r!==void 0)throw new _e("Can receive only one Overwrite value per step.");r=n}if(r!==void 0){let[,n]=tn(t[r]),a=n??this.initialValueFactory(),o=t.slice(r+1);return this.value=o.length>0?this.reducer(a,o):a,!0}let i=this.value===void 0?this.initialValueFactory():this.value;return this.value=this.reducer(i,t),!0}get(){if(this.value===void 0)throw new Pe;return this.value}checkpoint(){}isAvailable(){return this.value!==void 0}equals(t){return this===t?!0:!b9(t)||this.snapshotFrequency!==t.snapshotFrequency?!1:this.reducer===t.reducer}};var wS=Symbol.for("langgraph.channel.missing"),Ih=class SM extends pt{lc_graph_name="UntrackedValue";guard;_value=wS;initialValueFactory;constructor(t){super(),this.guard=t?.guard??!0,this.initialValueFactory=t?.initialValueFactory,this.initialValueFactory&&(this._value=this.initialValueFactory())}fromCheckpoint(t){return new SM({guard:this.guard,initialValueFactory:this.initialValueFactory})}update(t){if(t.length===0)return!1;if(t.length!==1&&this.guard)throw new _e("UntrackedValue(guard=true) can receive only one value per step. Use guard=false if you want to store any one of multiple values.",{lc_error_code:"INVALID_CONCURRENT_GRAPH_UPDATE"});return this._value=t[t.length-1],!0}get(){if(this._value===wS)throw new Pe;return this._value}checkpoint(){}isAvailable(){return this._value!==wS}};var Oa=(e,t)=>e.size===t.size&&[...e].every(r=>t.has(r)),xS=class kM extends pt{lc_graph_name="NamedBarrierValue";names;seen;constructor(t){super(),this.names=t,this.seen=new Set}fromCheckpoint(t){let r=new kM(this.names);return typeof t<"u"&&(r.seen=new Set(t)),r}update(t){let r=!1;for(let i of t)if(this.names.has(i))this.seen.has(i)||(this.seen.add(i),r=!0);else throw new _e(`Value ${JSON.stringify(i)} not in names ${JSON.stringify(this.names)}`);return r}get(){if(!Oa(this.names,this.seen))throw new Pe}checkpoint(){return[...this.seen]}consume(){return this.seen&&this.names&&Oa(this.seen,this.names)?(this.seen=new Set,!0):!1}isAvailable(){return!!this.names&&Oa(this.names,this.seen)}},SS=class $M extends pt{lc_graph_name="NamedBarrierValueAfterFinish";names;seen;finished;constructor(t){super(),this.names=t,this.seen=new Set,this.finished=!1}fromCheckpoint(t){let r=new $M(this.names);if(typeof t<"u"){let[i,n]=t;r.seen=new Set(i),r.finished=n}return r}update(t){let r=!1;for(let i of t)if(this.names.has(i)&&!this.seen.has(i))this.seen.add(i),r=!0;else if(!this.names.has(i))throw new _e(`Value ${JSON.stringify(i)} not in names ${JSON.stringify(this.names)}`);return r}get(){if(!this.finished||!Oa(this.names,this.seen))throw new Pe}checkpoint(){return[[...this.seen],this.finished]}consume(){return this.finished&&this.seen&&this.names&&Oa(this.seen,this.names)?(this.seen=new Set,this.finished=!1,!0):!1}finish(){return!this.finished&&this.names&&Oa(this.names,this.seen)?(this.finished=!0,!0):!1}isAvailable(){return this.finished&&!!this.names&&Oa(this.names,this.seen)}};var kS=Symbol.for("langgraph.state.reduced_value"),Ni=class{[kS]=!0;valueSchema;inputSchema;reducer;jsonSchemaExtra;constructor(e,t){this.reducer=t.reducer,this.jsonSchemaExtra=t.jsonSchemaExtra,this.valueSchema=e,this.inputSchema="inputSchema"in t?t.inputSchema:e,this.jsonSchemaExtra=t.jsonSchemaExtra}static isInstance(e){return typeof e=="object"&&e!==null&&kS in e&&e[kS]===!0}};var EM=Symbol.for("langgraph.state.untracked_value"),Zo=class{[EM]=!0;schema;guard;constructor(e,t){this.schema=e,this.guard=t?.guard??!0}static isInstance(e){return typeof e=="object"&&e!==null&&EM in e}};var $S=Symbol.for("langgraph.state.state_schema"),$n=class{[$S]=!0;constructor(e){this.fields=e}getChannels(){let e={};for(let[t,r]of Object.entries(this.fields))if(Ni.isInstance(r)){let i=Aa(r.valueSchema);e[t]=new Ci(r.reducer,i)}else if(Zo.isInstance(r)){let i=r.schema?Aa(r.schema):void 0;e[t]=new Ih({guard:r.guard,initialValueFactory:i})}else if(Pi(r))e[t]=new bn(Aa(r));else throw new Error(`Invalid state field "${t}": must be a schema, ReducedValue, UntrackedValue, or ManagedValue`);return e}getJsonSchema(){let e={},t=[];for(let[r,i]of Object.entries(this.fields)){let n;if(Ni.isInstance(i)?(n=Ca(i.valueSchema),i.jsonSchemaExtra&&(n={...n??{},...i.jsonSchemaExtra})):Zo.isInstance(i)?n=i.schema?Ca(i.schema):void 0:Pi(i)&&(n=Ca(i)),n){e[r]=n;let a=!1;Ni.isInstance(i)?a=Aa(i.valueSchema)!==void 0:Zo.isInstance(i)?a=i.schema?Aa(i.schema)!==void 0:!1:a=Aa(i)!==void 0,a||t.push(r)}}return{type:"object",properties:e,required:t.length>0?t:void 0}}getInputJsonSchema(){let e={};for(let[t,r]of Object.entries(this.fields)){let i;Ni.isInstance(r)?(i=Ca(r.inputSchema),r.jsonSchemaExtra&&(i={...i??{},...r.jsonSchemaExtra})):Zo.isInstance(r)?i=r.schema?Ca(r.schema):void 0:Pi(r)&&(i=Ca(r)),i&&(e[t]=i)}return{type:"object",properties:e}}getChannelKeys(){return Object.entries(this.fields).map(([e])=>e)}getAllKeys(){return Object.keys(this.fields)}async validateInput(e){if(e==null||typeof e!="object")return e;let t={};for(let[r,i]of Object.entries(e)){let n=this.fields[r];if(n===void 0){t[r]=i;continue}let a;if(Ni.isInstance(n)){let[o,s]=tn(i);if(o){a=n.valueSchema;let c=await a["~standard"].validate(s);if(c.issues)throw new Error(`Validation failed for field "${r}": ${JSON.stringify(c.issues)}`);t[r]={[Cn]:c.value};continue}a=n.inputSchema}else Zo.isInstance(n)?a=n.schema:Pi(n)&&(a=n);if(a){let o=await a["~standard"].validate(i);if(o.issues)throw new Error(`Validation failed for field "${r}": ${JSON.stringify(o.issues)}`);t[r]=o.value}else t[r]=i}return t}static isInstance(e){return typeof e=="object"&&e!==null&&$S in e&&e[$S]===!0}};var w9="__remove_all__";function Pa(e,t){let r=Array.isArray(e)?e:[e],i=Array.isArray(t)?t:[t],n=r.map(yt),a=i.map(yt);for(let u of n)(u.id===null||u.id===void 0)&&(u.id=Zi(),u.lc_kwargs.id=u.id);let o;for(let u=0;u<a.length;u+=1){let d=a[u];(d.id===null||d.id===void 0)&&(d.id=Zi(),d.lc_kwargs.id=d.id),Lr.isInstance(d)&&d.id==="__remove_all__"&&(o=u)}if(o!=null)return a.slice(o+1);let s=[...n],c=new Map(s.map((u,d)=>[u.id,d])),l=new Set;for(let u of a){let d=c.get(u.id);if(d!==void 0)Lr.isInstance(u)?l.add(u.id):(l.delete(u.id),s[d]=u);else{if(Lr.isInstance(u))throw new Error(`Attempting to delete a message with an ID that doesn't exist ('${u.id}')`);c.set(u.id,s.length),s.push(u)}}return s.filter(u=>!l.has(u.id))}function x9(e,t){let r=[];for(let s of t)Array.isArray(s)?r.push(...s):r.push(s);let i=e.length>0&&Te.isInstance(e[0])?e:e.map(yt),n=r.map(yt),a=new Map;for(let s=0;s<i.length;s+=1){let c=i[s].id;c!=null&&a.set(c,s)}let o=[...i];for(let s of n){let c=s.id;c==null?o.push(s):Lr.isInstance(s)?a.has(c)&&(o[a.get(c)]=null,a.delete(c)):a.has(c)?o[a.get(c)]=s:(a.set(c,o.length),o.push(s))}return o.filter(s=>s!==null)}var S9=new Ni(Xr.custom().default(()=>[]),{inputSchema:Xr.custom(),reducer:Pa,jsonSchemaExtra:{langgraph_type:"messages",description:"A list of chat messages"}});var k9=class{_map=new Map;_extensionCache=new Map;get(e){return this._map.get(e)}extend(e,t){let r=this.get(e);this._map.set(e,t(r))}remove(e){return this._map.delete(e),this}has(e){return this._map.has(e)}getChannelsForSchema(e){let t={},r=vi(e);for(let[i,n]of Object.entries(r)){let a=this.get(n);a?.reducer?t[i]=new Ci(a.reducer.fn,a.default):t[i]=new bn(a?.default)}return t}getExtendedChannelSchemas(e,t){if(Object.keys(t).length===0)return e;let r=Object.entries(t).filter(([,a])=>a===!0).sort(([a],[o])=>a.localeCompare(o)).map(([a,o])=>`${a}:${o}`).join("|"),i=this._extensionCache.get(r)??new Map;if(i.has(e))return i.get(e);let n=e;if(t.withReducerSchema||t.withJsonSchemaExtrasAsDescription){let a=Object.entries(vi(e)).map(([o,s])=>{let c=this.get(s),l=t.withReducerSchema?c?.reducer?.schema??s:s;if(t.withJsonSchemaExtrasAsDescription&&c?.jsonSchemaExtra){let u=bi(l)??bi(s),d=JSON.stringify({...c.jsonSchemaExtra,description:u});l=l.describe(`lg:${d}`)}return[o,l]});n=_p(e,Object.fromEntries(a)),at(n)&&(n._def.unknownKeys="strip")}return t.asPartial&&(n=ga(n)),i.set(e,n),this._extensionCache.set(r,i),n}},Mu=new k9;function IM(e,t){if(t.reducer&&!t.default){let r=yp(e);r!=null&&(t.default=r)}if(t.reducer){let r=Object.assign(e,{lg_reducer_schema:t.reducer?.schema??e});return Mu.extend(r,()=>t),r}else return Mu.extend(e,()=>t),e}function Ho(e){return e==null?!1:!!($n.isInstance(e)||Bt(e)||typeof e=="object"&&"lc_graph_name"in e&&e.lc_graph_name==="AnnotationRoot"||typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length>0&&Object.values(e).every(t=>typeof t=="function"||z0(t)))}function TM(e){if(typeof e!="object"||e==null)return!1;let t=e,r="state"in t&&Ho(t.state),i="stateSchema"in t&&Ho(t.stateSchema),n="input"in t&&Ho(t.input);return!(!r&&!i&&!n||"input"in t&&t.input!=null&&!Ho(t.input)||"output"in t&&t.output!=null&&!Ho(t.output))}var Ri="__root__",Ac="__default_error_handler__",Th=Symbol.for("langgraph.state.partial"),ES=class extends yS{channels={};waitingEdges=new Set;_schemaDefinition;_schemaRuntimeDefinition;_inputDefinition;_inputRuntimeDefinition;_outputDefinition;_outputRuntimeDefinition;_schemaDefinitions=new Map;_metaRegistry=Mu;_configSchema;_configRuntimeSchema;_interrupt;_writer;_nodeDefaults={};constructor(e,t){super();let r=this._normalizeToStateGraphInit(e,t),i=r.state??r.stateSchema??r.input;if(!i)throw new Uc;let n=this._getChannelsFromSchema(i);this._schemaDefinition=n,$n.isInstance(i)?this._schemaRuntimeDefinition=i:Bt(i)&&(this._schemaRuntimeDefinition=i),r.input?$n.isInstance(r.input)?this._inputRuntimeDefinition=r.input:Bt(r.input)?this._inputRuntimeDefinition=r.input:this._inputRuntimeDefinition=Th:this._inputRuntimeDefinition=Th,r.output?$n.isInstance(r.output)?this._outputRuntimeDefinition=r.output:Bt(r.output)?this._outputRuntimeDefinition=r.output:this._outputRuntimeDefinition=this._schemaRuntimeDefinition:this._outputRuntimeDefinition=this._schemaRuntimeDefinition;let a=r.input?this._getChannelsFromSchema(r.input):n,o=r.output?this._getChannelsFromSchema(r.output):n;this._inputDefinition=a,this._outputDefinition=o,this._addSchema(this._schemaDefinition),this._addSchema(this._inputDefinition),this._addSchema(this._outputDefinition),r.context&&Bt(r.context)&&(this._configRuntimeSchema=r.context),this._interrupt=r.interrupt,this._writer=r.writer}setNodeDefaults(e){return e.retryPolicy!==void 0&&(this._nodeDefaults.retryPolicy=e.retryPolicy),e.cachePolicy!==void 0&&(this._nodeDefaults.cachePolicy=typeof e.cachePolicy=="boolean"?e.cachePolicy?{}:void 0:e.cachePolicy),e.timeout!==void 0&&(this._nodeDefaults.timeout=Mi(e.timeout)),e.errorHandler!==void 0&&(this._nodeDefaults.errorHandler=e.errorHandler),this}_createDefaultErrorHandlerSpec(){let e=this._nodeDefaults.errorHandler;if(e!==void 0)return{runnable:new Tt({func:(t,r)=>{let i=r?.configurable?.[zc];return e(t,i,r)},name:Ac,trace:!1}),metadata:void 0,input:this._schemaDefinition,retryPolicy:void 0,cachePolicy:void 0,isErrorHandler:!0}}_normalizeToStateGraphInit(e,t){if(TM(e)){if(Bt(t)||eh.isInstance(t))return{...e,context:t};let r=t;return{...e,input:e.input??r?.input,output:e.output??r?.output,context:e.context??r?.context,interrupt:e.interrupt??r?.interrupt,writer:e.writer??r?.writer,nodes:e.nodes??r?.nodes}}if(Ho(e)){if(Bt(t)||eh.isInstance(t))return{state:e,context:t};let r=t;return{state:e,input:r?.input,output:r?.output,context:r?.context,interrupt:r?.interrupt,writer:r?.writer,nodes:r?.nodes}}if(E9(e))return{state:$9(e.channels)};throw new Uc}_getChannelsFromSchema(e){if($n.isInstance(e))return e.getChannels();if(Bt(e))return this._metaRegistry.getChannelsForSchema(e);if(typeof e=="object"&&"lc_graph_name"in e&&e.lc_graph_name==="AnnotationRoot")return e.spec;if(typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length>0)return e;throw new Uc("Invalid schema type. Expected StateSchema, Zod object, AnnotationRoot, or StateDefinition.")}get allEdges(){return new Set([...this.edges,...Array.from(this.waitingEdges).flatMap(([e,t])=>e.map(r=>[r,t]))])}_addSchema(e){if(!this._schemaDefinitions.has(e)){this._schemaDefinitions.set(e,e);for(let[t,r]of Object.entries(e)){let i;if(typeof r=="function"?i=r():i=r,this.channels[t]!==void 0){if(!this.channels[t].equals(i)&&i.lc_graph_name!=="LastValue")throw new Error(`Channel "${t}" already exists with a different type.`)}else this.channels[t]=i}}}addNode(...e){function t(i){return i.length>=1&&typeof i[0]!="string"}let r=t(e)?Array.isArray(e[0])?e[0]:Object.entries(e[0]).map(([i,n])=>[i,n]):[[e[0],e[1],e[2]]];if(r.length===0)throw new Error("No nodes provided in `addNode`");for(let[i,n,a]of r){if(i in this.channels)throw new Error(`${i} is already being used as a state attribute (a.k.a. a channel), cannot also be used as a node name.`);for(let f of["|",":"])if(i.includes(f))throw new Error(`"${f}" is a reserved character and is not allowed in node names.`);if(this.warnIfCompiled("Adding a node to a graph that has already been compiled. This will not be reflected in the compiled graph."),i in this.nodes)throw new Error(`Node \`${i}\` already present.`);if(i==="__end__"||i==="__start__")throw new Error(`Node \`${i}\` is reserved.`);let o=this._schemaDefinition;a?.input!==void 0&&(o=this._getChannelsFromSchema(a.input)),this._addSchema(o);let s;ae.isRunnable(n)?s=n:typeof n=="function"?s=new Tt({func:n,name:i,trace:!1}):s=tt(n);let c=a?.cachePolicy,l;c!==void 0&&(l=typeof c=="boolean"?c?{}:!1:c);let u;if(a?.errorHandler!==void 0){if(u=`__error_handler__${i}`,u in this.nodes)throw new Error(`Cannot add error handler to node \`${i}\`: the reserved name \`${u}\` is already in use. StateGraph registers \`__error_handler__<nodeName>\` when you pass \`errorHandler\` in addNode options. Remove or rename the existing node with that name (for example, you may have added it manually).`);let f=a.errorHandler,p={runnable:new Tt({func:(m,h)=>{let _=h?.configurable?.[zc];return f(m,_,h)},name:u,trace:!1}),metadata:void 0,input:o??this._schemaDefinition,retryPolicy:void 0,cachePolicy:void 0,isErrorHandler:!0};this.nodes[u]=p}let d={runnable:s,retryPolicy:a?.retryPolicy,cachePolicy:l,timeout:Mi(a?.timeout),metadata:a?.metadata,input:o??this._schemaDefinition,subgraphs:Au(s)?[s]:a?.subgraphs,ends:a?.ends,defer:a?.defer,errorHandlerNode:u};this.nodes[i]=d}return this}addEdge(e,t){if(typeof e=="string")return super.addEdge(e,t);this.compiled&&console.warn("Adding an edge to a graph that has already been compiled. This will not be reflected in the compiled graph.");for(let r of e){if(r==="__end__")throw new Error("END cannot be a start node");if(!Object.keys(this.nodes).some(i=>i===r))throw new Error(`Need to add a node named "${r}" first`)}if(t==="__end__")throw new Error("END cannot be an end node");if(!Object.keys(this.nodes).some(r=>r===t))throw new Error(`Need to add a node named "${t}" first`);return this.waitingEdges.add([e,t]),this}addSequence(e){let t=Array.isArray(e)?e:Object.entries(e);if(t.length===0)throw new Error("Sequence requires at least one node.");let r;for(let[i,n,a]of t){if(i in this.nodes)throw new Error(`Node names must be unique: node with the name "${i}" already exists.`);let o=i;this.addNode(i,n,a),r!=null&&this.addEdge(r,o),r=o}return this}compile({checkpointer:e,store:t,cache:r,interruptBefore:i,interruptAfter:n,name:a,description:o,transformers:s}={}){let c=this._createDefaultErrorHandlerSpec();if(c!==void 0){if(Ac in this.nodes)throw new Error(`Cannot apply a default error handler: the reserved node name \`${Ac}\` is already in use. setNodeDefaults({ errorHandler }) registers a node with that name; rename the conflicting node.`);this.nodes[Ac]=c}try{return this._compileResolved({checkpointer:e,store:t,cache:r,interruptBefore:i,interruptAfter:n,name:a,description:o,transformers:s,defaultErrorHandlerNode:c!==void 0?Ac:void 0})}finally{c!==void 0&&delete this.nodes[Ac]}}_compileResolved({checkpointer:e,store:t,cache:r,interruptBefore:i,interruptAfter:n,name:a,description:o,transformers:s,defaultErrorHandlerNode:c}){this.validate([...Array.isArray(i)?i:[],...Array.isArray(n)?n:[]]);let l=Object.keys(this._schemaDefinitions.get(this._outputDefinition)),u=l.length===1&&l[0]===Ri?Ri:l,d=Object.keys(this.channels),f=d.length===1&&d[0]===Ri?Ri:d,p=this._interrupt,m=new AM({builder:this,checkpointer:e,interruptAfter:n,interruptBefore:i,autoValidate:!1,nodes:{},channels:{...this.channels,[He]:new kn},inputChannels:He,outputChannels:u,streamChannels:f,streamMode:"updates",store:t,cache:r,name:a,description:o,userInterrupt:p,streamTransformers:s});m.attachNode(He);let h=this._nodeDefaults,_=h.retryPolicy!==void 0||h.cachePolicy!==void 0||h.timeout!==void 0||c!==void 0;for(let[b,w]of Object.entries(this.nodes)){let S=w.isErrorHandler===!0,x=_?{...w,retryPolicy:w.retryPolicy??h.retryPolicy,cachePolicy:S||w.cachePolicy===!1?void 0:w.cachePolicy??h.cachePolicy,timeout:w.timeout??h.timeout,errorHandlerNode:!S&&c!==void 0&&w.errorHandlerNode===void 0?c:w.errorHandlerNode}:w;m.attachNode(b,x)}m.attachBranch(He,Ah,CM(),{withReader:!1});for(let[b]of Object.entries(this.nodes))m.attachBranch(b,Ah,CM(),{withReader:!1});for(let[b,w]of this.edges)m.attachEdge(b,w);for(let[b,w]of this.waitingEdges)m.attachEdge(b,w);for(let[b,w]of Object.entries(this.branches))for(let[S,x]of Object.entries(w))m.attachBranch(b,S,x);return m.validate()}};function $9(e){let t={};for(let[r,i]of Object.entries(e))r===Ri?t[r]=th(i):t[r]=th(i);return t}var AM=class extends vS{description;_metaRegistry=Mu;constructor({description:e,...t}){super(t),this.description=e}attachNode(e,t){let r;e==="__start__"?r=Object.entries(this.builder._schemaDefinitions.get(this.builder._inputDefinition)).map(([c])=>c):r=Object.keys(this.builder.channels);function i(c){if(St(c))return c.graph===dr.PARENT?null:c._updateAsTuples();if(Array.isArray(c)&&c.length>0&&c.some(l=>St(l))){let l=[];for(let u of c)if(St(u)){if(u.graph===dr.PARENT)continue;l.push(...u._updateAsTuples())}else l.push([Ri,u]);return l}else if(c!=null)return[[Ri,c]];return null}let n=e,a=async c=>{if(c==null||c.length===0)return c;let l=this.builder._schemaRuntimeDefinition;if($n.isInstance(l)){let u=new Set(l.getChannelKeys());return Promise.all(c.map(async([d,f])=>{if(!u.has(d))return[d,f];let p=await l.validateInput({[d]:f});return[d,Object.prototype.hasOwnProperty.call(p,d)?p[d]:f]}))}if(Bt(l)){let u=new Set(Object.keys(vi(l)));if(c.filter(([p])=>u.has(p)).length===0)return c;let d=ga(this._metaRegistry.getExtendedChannelSchemas(l,{withReducerSchema:!0})),f=ga(l);return c.map(([p,m])=>{if(!u.has(p))return[p,m];let[h,_]=tn(m);if(h){let w=ha(f,{[p]:_});return[p,Object.prototype.hasOwnProperty.call(w,p)?{[Cn]:w[p]}:m]}let b=ha(d,{[p]:m});return[p,Object.prototype.hasOwnProperty.call(b,p)?b[p]:m]})}return c};async function o(c){if(c){if(St(c))return c.graph===dr.PARENT?null:a(c._updateAsTuples().filter(([l])=>r.includes(l)));if(Array.isArray(c)&&c.length>0&&c.some(St)){let l=[];for(let u of c)if(St(u)){if(u.graph===dr.PARENT)continue;l.push(...u._updateAsTuples().filter(([d])=>r.includes(d)))}else{let d=await o(u);d&&l.push(...d??[])}return a(l)}else{if(typeof c=="object"&&!Array.isArray(c))return a(Object.entries(c).filter(([l])=>r.includes(l)));{let l=Array.isArray(c)?"array":typeof c;throw new _e(`Expected node "${n.toString()}" to return an object or an array containing at least one Command object, received ${l}`,{lc_error_code:"INVALID_GRAPH_NODE_RETURN_VALUE"})}}}else return null}let s=[{value:wr,mapper:new Tt({func:r.length&&r[0]===Ri?i:o,trace:!1,recurse:!1})}];if(e==="__start__")this.nodes[e]=new xn({tags:[ut],triggers:[He],channels:[He],writers:[new ot(s,[ut])]});else{let c=t?.input??this.builder._schemaDefinition,l=Object.fromEntries(Object.keys(this.builder._schemaDefinitions.get(c)).map(m=>[m,m])),u=Object.keys(l).length===1&&Ri in l,d=`branch:to:${e}`;this.channels[d]=t?.defer?new D0:new kn(!1);let f=t?.cachePolicy,p=f===!1?void 0:f;this.nodes[e]=new xn({triggers:[d],channels:u?Object.keys(l):l,writers:[new ot(s,[ut])],mapper:u?void 0:m=>Object.fromEntries(Object.entries(m).filter(([h])=>h in l)),bound:t?.runnable,metadata:t?.metadata,retryPolicy:t?.retryPolicy,cachePolicy:p,timeout:t?.timeout,subgraphs:t?.subgraphs,ends:t?.ends,isErrorHandler:t?.isErrorHandler,errorHandlerNode:t?.errorHandlerNode})}}attachEdge(e,t){if(t!=="__end__"){if(typeof e=="string")this.nodes[e].writers.push(new ot([{channel:`branch:to:${t}`,value:null}],[ut]));else if(Array.isArray(e)){let r=`join:${e.join("+")}:${t}`;this.channels[r]=this.builder.nodes[t].defer?new SS(new Set(e)):new xS(new Set(e)),this.nodes[t].triggers.push(r);for(let i of e)this.nodes[i].writers.push(new ot([{channel:r,value:i}],[ut]))}}}attachBranch(e,t,r,i={withReader:!0}){let n=async(a,o)=>{let s=a.filter(l=>l!==Je);if(!s.length)return;let c=s.map(l=>ht(l)?l:{channel:l==="__end__"?l:`branch:to:${l}`,value:e});await ot.doWrite({...o,tags:(o.tags??[]).concat([ut])},c)};this.nodes[e].writers.push(r.run(n,i.withReader?a=>NR.doRead(a,this.streamChannels??this.outputChannels,!0):void 0))}async _validateInput(e){if(e==null)return e;let t=this.builder._inputRuntimeDefinition,r=this.builder._schemaRuntimeDefinition;if($n.isInstance(t)){if(St(e)){let n=e;return e.update&&(n.update=await t.validateInput(Array.isArray(e.update)?Object.fromEntries(e.update):e.update)),n}return await t.validateInput(e)}if(t===Th&&$n.isInstance(r)){if(St(e)){let n=e;return e.update&&(n.update=await r.validateInput(Array.isArray(e.update)?Object.fromEntries(e.update):e.update)),n}return await r.validateInput(e)}let i=(()=>{let n=a=>{if(a!=null)return this._metaRegistry.getExtendedChannelSchemas(a,{withReducerSchema:!0})};if(Bt(t))return n(t);if(t===Th)return Bt(r)?ga(n(r)):void 0})();if(St(e)){let n=e;if(e.update&&i!=null){let a=Array.isArray(e.update)?Object.fromEntries(e.update):e.update,o=ha(i,a);n.update=Object.fromEntries(Object.keys(a).map(s=>[s,o[s]]))}return n}return i!=null?ha(i,e):e}isInterrupted(e){return Ua(e)}async _validateContext(e){let t=this.builder._configRuntimeSchema;return Bt(t)&&ha(t,e),e}};function E9(e){return typeof e=="object"&&e!==null&&e.channels!==void 0}function I9(e){if(ht(e))return[e];let t=[];St(e)?t.push(e):Array.isArray(e)&&t.push(...e.filter(St));let r=[];for(let i of t){if(i.graph===dr.PARENT)throw new Ju(i);ht(i.goto)||typeof i.goto=="string"?r.push(i.goto):Array.isArray(i.goto)&&r.push(...i.goto)}return r}function CM(){return new _S({path:new Tt({func:I9,tags:[ut],trace:!1,recurse:!1,name:"<control_branch>"})})}var T9=class extends ES{constructor(){super({channels:{__root__:{reducer:Pa,default:()=>[]}}})}};function C9(e,t){let{stateKey:r,...i}=t??{},n=xc(i),a=r??"messages";r===null&&(a=void 0);let o=yt(e);if(!o.id)throw new Error("Message ID is required.");let s=(Array.isArray(n.callbacks)?n.callbacks:typeof n.callbacks<"u"?n.callbacks.handlers:[]).find(c=>"name"in c&&c.name==="StreamMessagesHandler");if(s){let c=n.metadata??{},l=(c.langgraph_checkpoint_ns??"").split("|");s._emit([l,c],o,void 0,!1)}return a&&n.configurable?.__pregel_send?.([[a,o]]),o}function A9(e,t){let r=typeof e=="string"?{name:e,retry:void 0,cachePolicy:void 0,timeout:void 0}:e,{name:i,retry:n}=r,a=Mi(r.timeout);if(nS(t)||iS(t))throw new Error("Generators are disallowed as tasks. For streaming responses, use config.write.");let o=r.cachePolicy??("cache"in r?r.cache:void 0),s;return typeof o=="boolean"?s=o?{}:void 0:s=o,(...c)=>VR({func:t,name:i,retry:n,cache:s,timeout:a},...c)}var OM=function(t,r){let{name:i,checkpointer:n,store:a,cache:o}=typeof t=="string"?{name:t,checkpointer:void 0,store:void 0}:t,s=Mi(typeof t=="string"?void 0:t.timeout);if(nS(r)||iS(r))throw new Error("Generators are disallowed as entrypoints. For streaming responses, use config.write.");let c="updates",l=BR(i,r);function u(m){return typeof m=="object"&&m!==null&&"__lg_type"in m&&m.__lg_type==="__pregel_final"}let d=new Tt({name:"pluckReturnValue",func:m=>u(m)?m.value:m}),f=new Tt({name:"pluckSaveValue",func:m=>u(m)?m.save:m}),p=new xn({bound:l,triggers:[He],channels:[He],timeout:s,writers:[new ot([{channel:Je,value:wr,mapper:d},{channel:Li,value:wr,mapper:f}],[ut])]});return new Eh({name:i,checkpointer:n,nodes:{[i]:p},channels:{[He]:new kn,[Je]:new bn,[Li]:new bn},inputChannels:He,outputChannels:Je,streamChannels:Je,streamMode:c,store:a,cache:o})};OM.final=function({value:t,save:r}){return{value:t,save:r,__lg_type:"__pregel_final"}};function O9(){return Ae.getRunnableConfig().configurable?.[zi]}var P9=Eu.Root({messages:Eu({reducer:Pa,default:()=>[]})}),PM={reducer:{fn:Pa},jsonSchemaExtra:{langgraph_type:"messages"},default:()=>[]},N9=It.object({messages:IM(It.custom(),PM)});function R9(e){let t=Ae.getRunnableConfig();if(!t)throw new Error("Called interrupt() outside the context of a graph.");let r=t.configurable;if(!r)throw new Error("No configurable found in config");return r.writer?.(e)}export{He as a,Je as b,je as c,Ch as d,RS as e,ja as f,MM as g,Ua as h,dr as i,St as j,Dr as k,Vu as l,Oh as m,La as n,Zu as o,Hu as p,si as q,Gu as r,Wu as s,zM as t,Ju as u,Ph as v,Fi as w,ci as x,Ku as y,DM as z,qu as A,Pe as B,_e as C,UM as D,Nh as E,LM as F,Uc as G,FM as H,fk as I,Qt as J,mj as K,Rn as L,xk as M,Zc as N,Sk as O,_t as P,ts as Q,Ce as R,is as S,Qe as T,an as U,Za as V,Ga as W,Wa as X,fi as Y,g$ as Z,Ft as _,ra as $,ao as aa,ca as ba,Df as ca,go as da,Ve as ea,at as fa,gr as ga,bi as ha,yp as ia,U as ja,It as ka,bt as la,Zt as ma,Dp as na,fF as oa,Vl as pa,Gp as qa,Dw as ra,XO as sa,YO as ta,_F as ua,yF as va,Lw as wa,xa,Sa as ya,rx as za,sc as Aa,su as Ba,Xr as Ca,kB as Da,PB as Ea,Lo as Fa,_n as Ga,Wm as Ha,lR as Ia,vc as Ja,qm as Ka,fR as La,pt as Ma,Ci as Na,Eu as Oa,uV as Pa,dV as Qa,U0 as Ra,fV as Sa,L0 as Ta,F0 as Ua,Sc as Va,B0 as Wa,Yr as Xa,ah as Ya,G0 as Za,Iu as _a,Tu as $a,W0 as ab,J0 as bb,oh as cb,X0 as db,SR as eb,Y0 as fb,rS as gb,yS as hb,Pi as ib,v9 as jb,Ca as kb,Aa as lb,wM as mb,Ih as nb,Ni as ob,Zo as pb,$n as qb,w9 as rb,Pa as sb,x9 as tb,S9 as ub,Mu as vb,IM as wb,ES as xb,AM as yb,T9 as zb,C9 as Ab,A9 as Bb,OM as Cb,O9 as Db,P9 as Eb,PM as Fb,N9 as Gb,R9 as Hb};