@esri/solutions-components 5.1.15 → 5.1.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. package/dist/cdn/247Q2TXM.js +2 -0
  2. package/dist/cdn/{VCKCRMSD.js → 2C4JBZR3.js} +1 -1
  3. package/dist/cdn/{VW4UJ7IY.js → 2DTIYSOT.js} +1 -1
  4. package/dist/cdn/{JNQB7T54.js → 2QR2IHMG.js} +1 -1
  5. package/dist/cdn/3ODUV7DM.js +2 -0
  6. package/dist/cdn/{CPWYI2FO.js → 3TZRVL3S.js} +1 -1
  7. package/dist/cdn/{IBSFJBIL.js → 447ZMCY3.js} +1 -1
  8. package/dist/cdn/{XRQNNWH3.js → 4JE4ZZEO.js} +1 -1
  9. package/dist/cdn/4O622WUQ.js +2 -0
  10. package/dist/cdn/4OZKMC4H.js +2 -0
  11. package/dist/cdn/{T6F3TWF6.js → 4RPDNW6C.js} +1 -1
  12. package/dist/cdn/{24U5P7WR.js → 4W4LIIXK.js} +1 -1
  13. package/dist/cdn/{SNRLIWGC.js → 56OXNE5M.js} +1 -1
  14. package/dist/cdn/{5DZ55HIG.js → 5E2X2LIC.js} +1 -1
  15. package/dist/cdn/{XL66TA6C.js → 5LSAVYFC.js} +1 -1
  16. package/dist/cdn/5MVOXMG2.js +2 -0
  17. package/dist/cdn/5QGU6U72.js +2 -0
  18. package/dist/cdn/{KN2PNGQX.js → 6HPH3E35.js} +1 -1
  19. package/dist/cdn/{5AGI2QC2.js → 6IWBGRKB.js} +1 -1
  20. package/dist/cdn/6PKGJDEH.js +2 -0
  21. package/dist/cdn/6TGGKMQB.js +2 -0
  22. package/dist/cdn/{BOA6VQK6.js → 75QFNN26.js} +1 -1
  23. package/dist/cdn/{HB56DBBP.js → 7EKT4XZ2.js} +5 -5
  24. package/dist/cdn/{7MJZYDDW.js → 7FGKODSI.js} +1 -1
  25. package/dist/cdn/{BFYYWPZY.js → 7RX3CC2H.js} +1 -1
  26. package/dist/cdn/{KJTTBON2.js → ACR7LXQM.js} +1 -1
  27. package/dist/cdn/{65VKA5R3.js → AIJ5KNSJ.js} +1 -1
  28. package/dist/cdn/AVMD543K.js +2 -0
  29. package/dist/cdn/{JIOMWIMT.js → B33ONN6M.js} +1 -1
  30. package/dist/cdn/{OZVQRDTO.js → BE4N7HFP.js} +1 -1
  31. package/dist/cdn/{Z4LGN5M5.js → BSPAXBDY.js} +1 -1
  32. package/dist/cdn/{DERWSE25.js → C5IHV5FJ.js} +1 -1
  33. package/dist/cdn/{EV55ZAHX.js → C7D3FPWP.js} +1 -1
  34. package/dist/cdn/{2GBCVJXZ.js → D62YOY7Q.js} +1 -1
  35. package/dist/cdn/{4VUQR74S.js → DCNEGYEC.js} +1 -1
  36. package/dist/cdn/DG2BBLXW.js +2 -0
  37. package/dist/cdn/{7GWFZ23D.js → DTXW7GR2.js} +1 -1
  38. package/dist/cdn/DXWCRPU7.js +2 -0
  39. package/dist/cdn/{ABPXUFXN.js → E7CD7GZL.js} +1 -1
  40. package/dist/cdn/EOMG2X5B.js +357 -0
  41. package/dist/cdn/{O4MNHPWI.js → EWCJJNT5.js} +1 -1
  42. package/dist/cdn/{WQUZG2NJ.js → FILRH4BY.js} +1 -1
  43. package/dist/cdn/{OQMMSCLX.js → FUEOEICW.js} +1 -1
  44. package/dist/cdn/{2CIYQPV2.js → FWRCG7QJ.js} +1 -1
  45. package/dist/cdn/{O62JG2Y6.js → FXGWLBJ7.js} +1 -1
  46. package/dist/cdn/{6MQWDLJ6.js → GMAV5T2N.js} +1 -1
  47. package/dist/cdn/{LGJMYSGU.js → GPODLJUL.js} +1 -1
  48. package/dist/cdn/{CNNBPMQT.js → GRFNUGBT.js} +1 -1
  49. package/dist/cdn/{JXERXJF5.js → GTX5TOX6.js} +1 -1
  50. package/dist/cdn/GWKUM5FJ.js +456 -0
  51. package/dist/cdn/{5TNQ4S67.js → H3GN63Y3.js} +1 -1
  52. package/dist/cdn/{T7JWS4CF.js → HIVXXDHM.js} +1 -1
  53. package/dist/cdn/I4WRVQPK.js +2 -0
  54. package/dist/cdn/{36LRAUE4.js → IPQDASPD.js} +1 -1
  55. package/dist/cdn/{RSPNBIIE.js → IWLPFHJF.js} +1 -1
  56. package/dist/cdn/{ZXHMBCGN.js → J4Y2UUE5.js} +1 -1
  57. package/dist/cdn/{YR6F4HW7.js → JDGAPNOB.js} +1 -1
  58. package/dist/cdn/{7SZY3VBD.js → JMFXUBR7.js} +1 -1
  59. package/dist/cdn/{GNX2VU4F.js → JSKYS7P5.js} +1 -1
  60. package/dist/cdn/{AQ2USXUY.js → JY2FA5F3.js} +1 -1
  61. package/dist/cdn/{TRNQ5OTY.js → JYKJLNCR.js} +1 -1
  62. package/dist/cdn/K5DU5RWF.js +2 -0
  63. package/dist/cdn/{N5DZRJNH.js → KH4ZYXHD.js} +1 -1
  64. package/dist/cdn/{DT7GQICF.js → KMKWVYPI.js} +1 -1
  65. package/dist/cdn/{QPMXVWMP.js → L6LA4X2Q.js} +1 -1
  66. package/dist/cdn/{FTWOLF7Y.js → L76QNBH4.js} +1 -1
  67. package/dist/cdn/{SSNO5VHY.js → LC7635YE.js} +1 -1
  68. package/dist/cdn/{COKMQSEA.js → LEZRHZSL.js} +1 -1
  69. package/dist/cdn/{COEHM4BJ.js → LSPJWXOL.js} +1 -1
  70. package/dist/cdn/{PHGSNNMQ.js → LULZPSZK.js} +1 -1
  71. package/dist/cdn/{5O6E2RIA.js → LVFCQS24.js} +1 -1
  72. package/dist/cdn/{QMUSSZL2.js → M3BC47EX.js} +1 -1
  73. package/dist/cdn/{IYZ2PDYK.js → MD2W2CNY.js} +1 -1
  74. package/dist/cdn/{MECI4R4R.js → MH3W3N6T.js} +3 -3
  75. package/dist/cdn/{XOPNEAS5.js → MIC565TO.js} +1 -1
  76. package/dist/cdn/{FJAUOTG7.js → MKGWQ7ED.js} +1 -1
  77. package/dist/cdn/{XSJOQTEM.js → MTGZHZYF.js} +1 -1
  78. package/dist/cdn/{G2OBSHPX.js → N74SSEHF.js} +1 -1
  79. package/dist/cdn/{KOIHVAUY.js → NLXWDQUL.js} +1 -1
  80. package/dist/cdn/{CDZW34JV.js → NWI63TZX.js} +1 -1
  81. package/dist/cdn/{CAPXLC6T.js → O2Y2MGL7.js} +1 -1
  82. package/dist/cdn/{2A7FDE6T.js → O4Q74CU3.js} +1 -1
  83. package/dist/cdn/{SYHEO472.js → O7KEBYBS.js} +1 -1
  84. package/dist/cdn/PB4KDDNX.js +2 -0
  85. package/dist/cdn/{HW4LYJUR.js → PCRICJQB.js} +1 -1
  86. package/dist/cdn/{53YBLXWP.js → PFGAF7W7.js} +1 -1
  87. package/dist/cdn/{IDJHBEJC.js → PJ556LHC.js} +3 -3
  88. package/dist/cdn/{AONULVO2.js → PRBMUEIU.js} +1 -1
  89. package/dist/cdn/{2WXIVPKA.js → PUBYJMMF.js} +1 -1
  90. package/dist/cdn/Q5ALOX6G.js +2 -0
  91. package/dist/cdn/{FLPXST7W.js → QIYUCOCH.js} +1 -1
  92. package/dist/cdn/{RLDOLDG5.js → QT66ATR6.js} +1 -1
  93. package/dist/cdn/{K3ALRIQF.js → R22ZBXMU.js} +1 -1
  94. package/dist/cdn/{6RHFFYNC.js → RBA5LP53.js} +1 -1
  95. package/dist/cdn/{4M55FA2L.js → RJJEDOA5.js} +1 -1
  96. package/dist/cdn/{3JF7PWPA.js → RTHNTV3C.js} +1 -1
  97. package/dist/cdn/{VQ5ZAQUF.js → RWYVVDWD.js} +1 -1
  98. package/dist/cdn/{RPLXKWJA.js → SWZW76QC.js} +1 -1
  99. package/dist/cdn/{AO7XKW2U.js → SY25U3KI.js} +1 -1
  100. package/dist/cdn/T5RT73MF.js +2 -0
  101. package/dist/cdn/{W6GIBBBE.js → TWELRTPF.js} +1 -1
  102. package/dist/cdn/U3D2IIAX.js +2 -0
  103. package/dist/cdn/UAWJNBXB.js +4 -0
  104. package/dist/cdn/{KF64ALRP.js → ULAU7YYD.js} +1 -1
  105. package/dist/cdn/{VZWYFHPJ.js → UPYHIGTA.js} +1 -1
  106. package/dist/cdn/{VHAXJPRY.js → UR2RYZ4Q.js} +1 -1
  107. package/dist/cdn/{L5DQOHD5.js → V3QY6GGE.js} +1 -1
  108. package/dist/cdn/{YGVATVII.js → VEBARNK2.js} +1 -1
  109. package/dist/cdn/VSTISYVL.js +2 -0
  110. package/dist/cdn/{JMY4B4WQ.js → VT35RTGD.js} +1 -1
  111. package/dist/cdn/{RGOUIRT7.js → WFDP33EC.js} +1 -1
  112. package/dist/cdn/{4QGYS5DL.js → WMY3JAPO.js} +1 -1
  113. package/dist/cdn/{CWW74G2W.js → WNSJ26IM.js} +1 -1
  114. package/dist/cdn/{RI7U6FA5.js → WP3FT4MH.js} +1 -1
  115. package/dist/cdn/{AIUJXRA5.js → WSGJL4QG.js} +1 -1
  116. package/dist/cdn/{WVRDKKBC.js → WWRJFSPK.js} +1 -1
  117. package/dist/cdn/XGF4Z7DL.js +2 -0
  118. package/dist/cdn/{67RAW3TG.js → XTMKQTKS.js} +1 -1
  119. package/dist/cdn/{BDVFJJR4.js → XUQJ6TZ4.js} +1 -1
  120. package/dist/cdn/{RD7MZ7SN.js → XWMICWSU.js} +1 -1
  121. package/dist/cdn/{D4HAXELR.js → XZE3UIAE.js} +1 -1
  122. package/dist/cdn/{5OMXJXRL.js → Y376MZ7V.js} +1 -1
  123. package/dist/cdn/{2ZH3GVSR.js → YGHICFBD.js} +1 -1
  124. package/dist/cdn/{GWLE7PJQ.js → YJCJZHBN.js} +1 -1
  125. package/dist/cdn/{VYOCZUVH.js → YP46NHDO.js} +1 -1
  126. package/dist/cdn/{MQQ2SHRV.js → YSZNDZHZ.js} +1 -1
  127. package/dist/cdn/{P3YHSJCB.js → Z7NC4HTS.js} +1 -1
  128. package/dist/cdn/{5DMFGBJJ.js → ZBXJES7E.js} +1 -1
  129. package/dist/cdn/{5USMP4M7.js → ZZIJOG6A.js} +1 -1
  130. package/dist/cdn/index.js +1 -1
  131. package/dist/chunks/runtime.js +1 -1
  132. package/dist/chunks/solution-builder-assistant.js +2 -2
  133. package/dist/components/arcgis-solutions-assistant/customElement.js +324 -335
  134. package/dist/components/create-feature/customElement.js +77 -48
  135. package/dist/components/layer-table/customElement.js +2 -2
  136. package/dist/components/map-card/customElement.js +2 -2
  137. package/dist/components/solutions-deploy-app/customElement.js +3 -3
  138. package/dist/docs/api.json +1 -1
  139. package/dist/docs/docs.json +1 -1
  140. package/dist/docs/web-types.json +1 -1
  141. package/dist/solutions-components_commit.txt +7 -7
  142. package/package.json +9 -7
  143. package/dist/cdn/3TAQSXLA.js +0 -2
  144. package/dist/cdn/4ESJPQUS.js +0 -2
  145. package/dist/cdn/64DMFXX3.js +0 -459
  146. package/dist/cdn/6JPXLTNI.js +0 -358
  147. package/dist/cdn/7LP2DUHS.js +0 -2
  148. package/dist/cdn/ACTGIDKO.js +0 -4
  149. package/dist/cdn/BA3J7L5N.js +0 -2
  150. package/dist/cdn/BPHZAC66.js +0 -2
  151. package/dist/cdn/ECJQJ4BY.js +0 -2
  152. package/dist/cdn/F5EJPIW4.js +0 -2
  153. package/dist/cdn/FX2C3BL4.js +0 -2
  154. package/dist/cdn/GEEQWXOZ.js +0 -2
  155. package/dist/cdn/H3QX6XOJ.js +0 -2
  156. package/dist/cdn/JRUIRTL7.js +0 -2
  157. package/dist/cdn/NF77ALHM.js +0 -2
  158. package/dist/cdn/OJH4NUGT.js +0 -2
  159. package/dist/cdn/SV2XM7U2.js +0 -2
  160. package/dist/cdn/TTXN5R4E.js +0 -2
  161. package/dist/cdn/VM2LS6TR.js +0 -2
  162. package/dist/cdn/VNWIFVKC.js +0 -2
  163. package/dist/cdn/VWNMKVMJ.js +0 -2
  164. package/dist/cdn/X3YWKGD7.js +0 -2
@@ -1,459 +0,0 @@
1
- /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{b as la,c as Fn,d as Vd}from"./EXBEKVP5.js";var ST=la((rJ,uy)=>{"use strict";var TU=Object.prototype.hasOwnProperty,gr="~";function Qu(){}Object.create&&(Qu.prototype=Object.create(null),new Qu().__proto__||(gr=!1));function AU(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function xT(e,t,r,n,i){if(typeof r!="function")throw new TypeError("The listener must be a function");var o=new AU(r,n||e,i),a=gr?gr+t:t;return e._events[a]?e._events[a].fn?e._events[a]=[e._events[a],o]:e._events[a].push(o):(e._events[a]=o,e._eventsCount++),e}function Bf(e,t){--e._eventsCount===0?e._events=new Qu:delete e._events[t]}function Xt(){this._events=new Qu,this._eventsCount=0}Xt.prototype.eventNames=function(){var t=[],r,n;if(this._eventsCount===0)return t;for(n in r=this._events)TU.call(r,n)&&t.push(gr?n.slice(1):n);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(r)):t};Xt.prototype.listeners=function(t){var r=gr?gr+t:t,n=this._events[r];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,o=n.length,a=new Array(o);i<o;i++)a[i]=n[i].fn;return a};Xt.prototype.listenerCount=function(t){var r=gr?gr+t:t,n=this._events[r];return n?n.fn?1:n.length:0};Xt.prototype.emit=function(t,r,n,i,o,a){var s=gr?gr+t:t;if(!this._events[s])return!1;var c=this._events[s],u=arguments.length,l,d;if(c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),u){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,n),!0;case 4:return c.fn.call(c.context,r,n,i),!0;case 5:return c.fn.call(c.context,r,n,i,o),!0;case 6:return c.fn.call(c.context,r,n,i,o,a),!0}for(d=1,l=new Array(u-1);d<u;d++)l[d-1]=arguments[d];c.fn.apply(c.context,l)}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),u){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,n);break;case 4:c[d].fn.call(c[d].context,r,n,i);break;default:if(!l)for(p=1,l=new Array(u-1);p<u;p++)l[p-1]=arguments[p];c[d].fn.apply(c[d].context,l)}}return!0};Xt.prototype.on=function(t,r,n){return xT(this,t,r,n,!1)};Xt.prototype.once=function(t,r,n){return xT(this,t,r,n,!0)};Xt.prototype.removeListener=function(t,r,n,i){var o=gr?gr+t:t;if(!this._events[o])return this;if(!r)return Bf(this,o),this;var a=this._events[o];if(a.fn)a.fn===r&&(!i||a.once)&&(!n||a.context===n)&&Bf(this,o);else{for(var s=0,c=[],u=a.length;s<u;s++)(a[s].fn!==r||i&&!a[s].once||n&&a[s].context!==n)&&c.push(a[s]);c.length?this._events[o]=c.length===1?c[0]:c:Bf(this,o)}return this};Xt.prototype.removeAllListeners=function(t){var r;return t?(r=gr?gr+t:t,this._events[r]&&Bf(this,r)):(this._events=new Qu,this._eventsCount=0),this};Xt.prototype.off=Xt.prototype.removeListener;Xt.prototype.addListener=Xt.prototype.on;Xt.prefixed=gr;Xt.EventEmitter=Xt;typeof uy<"u"&&(uy.exports=Xt)});var ET=la((nJ,kT)=>{"use strict";kT.exports=(e,t)=>(t=t||(()=>{}),e.then(r=>new Promise(n=>{n(t())}).then(()=>r),r=>new Promise(n=>{n(t())}).then(()=>{throw r})))});var $T=la((iJ,Hf)=>{"use strict";var CU=ET(),Vf=class extends Error{constructor(t){super(t),this.name="TimeoutError"}},IT=(e,t,r)=>new Promise((n,i)=>{if(typeof t!="number"||t<0)throw new TypeError("Expected `milliseconds` to be a positive number");if(t===1/0){n(e);return}let o=setTimeout(()=>{if(typeof r=="function"){try{n(r())}catch(c){i(c)}return}let a=typeof r=="string"?r:`Promise timed out after ${t} milliseconds`,s=r instanceof Error?r:new Vf(a);typeof e.cancel=="function"&&e.cancel(),i(s)},t);CU(e.then(n,i),()=>{clearTimeout(o)})});Hf.exports=IT;Hf.exports.default=IT;Hf.exports.TimeoutError=Vf});var TT=la(ly=>{"use strict";Object.defineProperty(ly,"__esModule",{value:!0});function OU(e,t,r){let n=0,i=e.length;for(;i>0;){let o=i/2|0,a=n+o;r(e[a],t)<=0?(n=++a,i-=o+1):i=o}return n}ly.default=OU});var AT=la(fy=>{"use strict";Object.defineProperty(fy,"__esModule",{value:!0});var PU=TT(),dy=class{constructor(){this._queue=[]}enqueue(t,r){r=Object.assign({priority:0},r);let n={priority:r.priority,run:t};if(this.size&&this._queue[this.size-1].priority>=r.priority){this._queue.push(n);return}let i=PU.default(this._queue,n,(o,a)=>a.priority-o.priority);this._queue.splice(i,0,n)}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}};fy.default=dy});var Gf=la(my=>{"use strict";Object.defineProperty(my,"__esModule",{value:!0});var NU=ST(),CT=$T(),RU=AT(),Zf=()=>{},jU=new CT.TimeoutError,py=class extends NU{constructor(t){var r,n,i,o;if(super(),this._intervalCount=0,this._intervalEnd=0,this._pendingCount=0,this._resolveEmpty=Zf,this._resolveIdle=Zf,t=Object.assign({carryoverConcurrencyCount:!1,intervalCap:1/0,interval:0,concurrency:1/0,autoStart:!0,queueClass:RU.default},t),!(typeof t.intervalCap=="number"&&t.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${(n=(r=t.intervalCap)===null||r===void 0?void 0:r.toString())!==null&&n!==void 0?n:""}\` (${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 \`${(o=(i=t.interval)===null||i===void 0?void 0:i.toString())!==null&&o!==void 0?o:""}\` (${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=Zf,this._pendingCount===0&&(this._resolveIdle(),this._resolveIdle=Zf,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((n,i)=>{let o=async()=>{this._pendingCount++,this._intervalCount++;try{let a=this._timeout===void 0&&r.timeout===void 0?t():CT.default(Promise.resolve(t()),r.timeout===void 0?this._timeout:r.timeout,()=>{(r.throwOnTimeout===void 0?this._throwOnTimeout:r.throwOnTimeout)&&i(jU)});n(await a)}catch(a){i(a)}this._next()};this._queue.enqueue(o,r),this._tryToStartAnother(),this.emit("add")})}async addAll(t,r){return Promise.all(t.map(async n=>this.add(n,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}};my.default=py});var a1=la(rh=>{"use strict";rh.byteLength=x9;rh.toByteArray=k9;rh.fromByteArray=$9;var fi=[],dn=[],w9=typeof Uint8Array<"u"?Uint8Array:Array,S0="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Es=0,i1=S0.length;Es<i1;++Es)fi[Es]=S0[Es],dn[S0.charCodeAt(Es)]=Es;var Es,i1;dn[45]=62;dn[95]=63;function o1(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 n=r===t?0:4-r%4;return[r,n]}function x9(e){var t=o1(e),r=t[0],n=t[1];return(r+n)*3/4-n}function S9(e,t,r){return(t+r)*3/4-r}function k9(e){var t,r=o1(e),n=r[0],i=r[1],o=new w9(S9(e,n,i)),a=0,s=i>0?n-4:n,c;for(c=0;c<s;c+=4)t=dn[e.charCodeAt(c)]<<18|dn[e.charCodeAt(c+1)]<<12|dn[e.charCodeAt(c+2)]<<6|dn[e.charCodeAt(c+3)],o[a++]=t>>16&255,o[a++]=t>>8&255,o[a++]=t&255;return i===2&&(t=dn[e.charCodeAt(c)]<<2|dn[e.charCodeAt(c+1)]>>4,o[a++]=t&255),i===1&&(t=dn[e.charCodeAt(c)]<<10|dn[e.charCodeAt(c+1)]<<4|dn[e.charCodeAt(c+2)]>>2,o[a++]=t>>8&255,o[a++]=t&255),o}function E9(e){return fi[e>>18&63]+fi[e>>12&63]+fi[e>>6&63]+fi[e&63]}function I9(e,t,r){for(var n,i=[],o=t;o<r;o+=3)n=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(e[o+2]&255),i.push(E9(n));return i.join("")}function $9(e){for(var t,r=e.length,n=r%3,i=[],o=16383,a=0,s=r-n;a<s;a+=o)i.push(I9(e,a,a+o>s?s:a+o));return n===1?(t=e[r-1],i.push(fi[t>>2]+fi[t<<4&63]+"==")):n===2&&(t=(e[r-2]<<8)+e[r-1],i.push(fi[t>>10]+fi[t>>4&63]+fi[t<<2&63]+"=")),i.join("")}});function wE(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 oo(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 n=wE(t.runTimeout,"runTimeout"),i=wE(t.idleTimeout,"idleTimeout");if(!(n===void 0&&i===void 0))return{runTimeout:n,idleTimeout:i,refreshOn:r}}var Ye="__start__",nt="__end__",Vn="__input__";var ao="__error__",Nu="__error_source_node__",Hd="__pregel_ns_writes";function xE(){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 qt="__pregel_send",Hn="__pregel_call",cr="__pregel_read",Qr="__pregel_checkpointer",fa="__pregel_resuming",Ds="__pregel_task_id",Ru="__pregel_stream",h4="__pregel_resume_value",pa="__pregel_resume_map",ur="__pregel_scratchpad",so="__pregel_previous",g4="__pregel_durability",co="checkpoint_id",Ur="checkpoint_ns",SE="__pregel_node_finished",ju="__pregel_node_error",Kt="checkpoint_map",Zd="__pregel_replay_state",kE="__pregel_abort_signals",Ve="__interrupt__",lr="__resume__",Mu="__no_writes__",uo="__return__",lo="__previous__",vt="langsmith:hidden";var Qg="__self__",Zn="__pregel_tasks",dr="__pregel_push",Gd="__pregel_pull",fr="00000000-0000-0000-0000-000000000000",EE=[vt,Vn,Ve,lr,ao,Nu,Mu,qt,cr,Qr,g4,Ru,fa,Ds,Hn,h4,ur,so,Kt,Ur,co,Zd],Yg=Symbol.for("langgraph.command"),IE=class{[Yg];constructor(e){this[Yg]=e}};function Wd(e){let t=e;return t!=null&&typeof t.node=="string"&&t.args!==void 0}var da=class{lg_name="Send";node;args;timeout;constructor(e,t,r){this.node=e,this.args=Pu(t),this.timeout=oo(r?.timeout)}toJSON(){return{lg_name:this.lg_name,node:this.node,args:this.args,timeout:this.timeout}}};function Et(e){return e instanceof da}var Bn="__overwrite__",_4=class{lg_name="Overwrite";[Bn];constructor(e){this[Bn]=e}get value(){return this[Bn]}toJSON(){return{[Bn]:this[Bn]}}static isInstance(e){return!e||typeof e!="object"?!1:"__overwrite__"in e||"lg_name"in e&&e.lg_name==="Overwrite"}};function _n(e){if(typeof e=="object"&&e!==null){if("__overwrite__"in e)return[!0,e[Bn]];let t=e;if(t.type==="__overwrite__"&&"value"in t)return[!0,t.value]}return[!1,void 0]}function ma(e){return _n(e)[0]}function ha(e){return!e||typeof e!="object"||!("__interrupt__"in e)?!1:Array.isArray(e[Ve])}var Ir=class extends IE{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)?Pu(e.goto):[Pu(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:Et(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 Rt(e){return typeof e!="object"||e==null?!1:"lg_name"in e&&e.lg_name==="Command"}function y4(e){let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function Pu(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((n,i)=>{r[i]=Pu(n,t)});else if(e instanceof Ir||e instanceof da||!y4(e))r=e,t.set(e,r);else if(Rt(e))r=new Ir(e),t.set(e,r);else if(Wd(e))r=new da(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[n,i]of Object.entries(e))r[n]=Pu(i,t)}return r}return e}var en=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}},qd=class extends en{get is_bubble_up(){return!0}},e_=class extends en{constructor(e,t){super(e,t),this.name="GraphRecursionError"}static get unminifiable_name(){return"GraphRecursionError"}},ga=class extends en{constructor(e,t){super(e,t),this.name="GraphValueError"}static get unminifiable_name(){return"GraphValueError"}},Kd=class extends qd{reason;constructor(e="shutdown",t){super(`Graph drained: ${e}`,t),this.name="GraphDrained",this.reason=e}static get unminifiable_name(){return"GraphDrained"}};function Jd(e){return e!==void 0&&e.name===Kd.unminifiable_name}var Si=class extends qd{interrupts;constructor(e,t){super(JSON.stringify(e,null,2),t),this.name="GraphInterrupt",this.interrupts=e??[]}static get unminifiable_name(){return"GraphInterrupt"}},Xd=class extends Si{constructor(e,t){super([{value:e}],t),this.name="NodeInterrupt"}static get unminifiable_name(){return"NodeInterrupt"}},Yd=class{node;error;constructor(e,t){this.node=e,this.error=t}static get unminifiable_name(){return"NodeError"}};function v4(e){return e!=null&&typeof e=="object"&&e.constructor!=null&&e.constructor.unminifiable_name===Yd.unminifiable_name}var Qd=class extends qd{command;constructor(e){super(),this.name="ParentCommand",this.command=e}static get unminifiable_name(){return"ParentCommand"}};function t_(e){return e!==void 0&&e.name===Qd.unminifiable_name}function fo(e){return e!==void 0&&e.is_bubble_up===!0}function ki(e){return e!==void 0&&[Si.unminifiable_name,Xd.unminifiable_name].includes(e.name)}var ef=class extends en{node;kind;timeout;elapsed;runTimeout;idleTimeout;constructor(e,t){let{node:r,elapsed:n,kind:i,runTimeout:o,idleTimeout:a}=e,s,c;if(i==="idle"){if(a===void 0)throw new Error("idleTimeout is required when kind='idle'");c=a,s=`Node "${r}" exceeded its idle timeout of ${a}ms without making progress (elapsed: ${n}ms).`}else{if(o===void 0)throw new Error("runTimeout is required when kind='run'");c=o,s=`Node "${r}" exceeded its run timeout of ${o}ms (elapsed: ${n}ms).`}super(s,t),this.name="NodeTimeoutError",this.node=r,this.kind=i,this.timeout=c,this.elapsed=n,this.runTimeout=o,this.idleTimeout=a}static get unminifiable_name(){return"NodeTimeoutError"}};function b4(e){return e!==void 0&&e.name===ef.unminifiable_name}var tf=class extends en{constructor(e,t){super(e,t),this.name="EmptyInputError"}static get unminifiable_name(){return"EmptyInputError"}},Ue=class extends en{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"}},we=class extends en{constructor(e,t){super(e,t),this.name="InvalidUpdateError"}static get unminifiable_name(){return"InvalidUpdateError"}},w4=class extends en{constructor(e,t){super(e,t),this.name="MultipleSubgraphError"}static get unminifiable_name(){return"MultipleSubgraphError"}},r_=class extends en{constructor(e,t){super(e,t),this.name="UnreachableNodeError"}static get unminifiable_name(){return"UnreachableNodeError"}},x4=class extends en{constructor(e,t){super(e,t),this.name="RemoteException"}static get unminifiable_name(){return"RemoteException"}},Du=class extends en{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"}},S4=()=>(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 $E=Object.defineProperty,A=(e,t)=>{let r={};for(var n in e)$E(r,n,{get:e[n],enumerable:!0});return t||$E(r,Symbol.toStringTag,{value:"Module"}),r};var TE="ffffffff-ffff-ffff-ffff-ffffffffffff";var AE="00000000-0000-0000-0000-000000000000";var CE=/^(?:[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 po(e){return typeof e=="string"&&CE.test(e)}function _a(e){if(!po(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 Ft=[];for(let e=0;e<256;++e)Ft.push((e+256).toString(16).slice(1));function Lr(e,t=0){return(Ft[e[t+0]]+Ft[e[t+1]]+Ft[e[t+2]]+Ft[e[t+3]]+"-"+Ft[e[t+4]]+Ft[e[t+5]]+"-"+Ft[e[t+6]]+Ft[e[t+7]]+"-"+Ft[e[t+8]]+Ft[e[t+9]]+"-"+Ft[e[t+10]]+Ft[e[t+11]]+Ft[e[t+12]]+Ft[e[t+13]]+Ft[e[t+14]]+Ft[e[t+15]]).toLowerCase()}function OE(e,t=0){let r=Lr(e,t);if(!po(r))throw TypeError("Stringified UUID is invalid");return r}var k4=new Uint8Array(16);function mo(){return crypto.getRandomValues(k4)}var zu={};function rf(e,t,r){let n,i=e?._v6??!1;if(e){let o=Object.keys(e);o.length===1&&o[0]==="_v6"&&(e=void 0)}if(e)n=PE(e.random??e.rng?.()??mo(),e.msecs,e.nsecs,e.clockseq,e.node,t,r);else{let o=Date.now(),a=mo();E4(zu,o,a),n=PE(a,zu.msecs,zu.nsecs,i?void 0:zu.clockseq,i?void 0:zu.node,t,r)}return t??Lr(n)}function E4(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 PE(e,t,r,n,i,o,a=0){if(e.length<16)throw new Error("Random bytes length must be >= 16");if(!o)o=new Uint8Array(16),a=0;else if(a<0||a+16>o.length)throw new RangeError(`UUID byte range ${a}:${a+15} is out of buffer bounds`);t??=Date.now(),r??=0,n??=(e[8]<<8|e[9])&16383,i??=e.slice(10,16),t+=122192928e5;let s=((t&268435455)*1e4+r)%4294967296;o[a++]=s>>>24&255,o[a++]=s>>>16&255,o[a++]=s>>>8&255,o[a++]=s&255;let c=t/4294967296*1e4&268435455;o[a++]=c>>>8&255,o[a++]=c&255,o[a++]=c>>>24&15|16,o[a++]=c>>>16&255,o[a++]=n>>>8|128,o[a++]=n&255;for(let u=0;u<6;++u)o[a++]=i[u];return o}function NE(e,t,r){return!t&&!e&&crypto.randomUUID?crypto.randomUUID():I4(e,t,r)}function I4(e,t,r){e=e||{};let n=e.random??e.rng?.()??mo();if(n.length<16)throw new Error("Random bytes length must be >= 16");if(n[6]=n[6]&15|64,n[8]=n[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 i=0;i<16;++i)t[r+i]=n[i];return t}return Lr(n)}function $4(e,t,r,n){switch(e){case 0:return t&r^~t&n;case 1:return t^r^n;case 2:return t&r^t&n^r&n;case 3:return t^r^n}}function n_(e,t){return e<<t|e>>>32-t}function RE(e){let t=[1518500249,1859775393,2400959708,3395469782],r=[1732584193,4023233417,2562383102,271733878,3285377520],n=new Uint8Array(e.length+1);n.set(e),n[e.length]=128,e=n;let i=e.length/4+2,o=Math.ceil(i/16),a=new Array(o);for(let s=0;s<o;++s){let c=new Uint32Array(16);for(let u=0;u<16;++u)c[u]=e[s*64+u*4]<<24|e[s*64+u*4+1]<<16|e[s*64+u*4+2]<<8|e[s*64+u*4+3];a[s]=c}a[o-1][14]=(e.length-1)*8/2**32,a[o-1][14]=Math.floor(a[o-1][14]),a[o-1][15]=(e.length-1)*8&4294967295;for(let s=0;s<o;++s){let c=new Uint32Array(80);for(let m=0;m<16;++m)c[m]=a[s][m];for(let m=16;m<80;++m)c[m]=n_(c[m-3]^c[m-8]^c[m-14]^c[m-16],1);let u=r[0],l=r[1],d=r[2],f=r[3],p=r[4];for(let m=0;m<80;++m){let h=Math.floor(m/20),_=n_(u,5)+$4(h,l,d,f)+p+t[h]+c[m]>>>0;p=f,f=d,d=n_(l,30)>>>0,l=u,u=_}r[0]=r[0]+u>>>0,r[1]=r[1]+l>>>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 T4(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 jE="6ba7b810-9dad-11d1-80b4-00c04fd430c8",ME="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function DE(e,t,r,n,i,o){let a=typeof r=="string"?T4(r):r,s=typeof n=="string"?_a(n):n;if(typeof n=="string"&&(n=_a(n)),n?.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let c=new Uint8Array(16+a.length);if(c.set(s),c.set(a,s.length),c=t(c),c[6]=c[6]&15|e,c[8]=c[8]&63|128,i){if(o??=0,o<0||o+16>i.length)throw new RangeError(`UUID byte range ${o}:${o+15} is out of buffer bounds`);for(let u=0;u<16;++u)i[o+u]=c[u];return i}return Lr(c)}function nf(e,t,r,n){return DE(80,RE,e,t,r,n)}nf.DNS=jE;nf.URL=ME;function zE(e){let t=A4(typeof e=="string"?_a(e):e);return typeof e=="string"?Lr(t):t}function A4(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 UE(e,t,r){e??={},r??=0;let n=rf({...e,_v6:!0},new Uint8Array(16));if(n=zE(n),t){if(r<0||r+16>t.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let i=0;i<16;i++)t[r+i]=n[i];return t}return Lr(n)}var i_={};function FE(e,t,r){let n;if(e)n=LE(e.random??e.rng?.()??mo(),e.msecs,e.seq,t,r);else{let i=Date.now(),o=mo();C4(i_,i,o),n=LE(o,i_.msecs,i_.seq,t,r)}return t??Lr(n)}function C4(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 LE(e,t,r,n,i=0){if(e.length<16)throw new Error("Random bytes length must be >= 16");if(!n)n=new Uint8Array(16),i=0;else if(i<0||i+16>n.length)throw new RangeError(`UUID byte range ${i}:${i+15} is out of buffer bounds`);return t??=Date.now(),r??=e[6]*127<<24|e[7]<<16|e[8]<<8|e[9],n[i++]=t/1099511627776&255,n[i++]=t/4294967296&255,n[i++]=t/16777216&255,n[i++]=t/65536&255,n[i++]=t/256&255,n[i++]=t&255,n[i++]=112|r>>>28&15,n[i++]=r>>>20&255,n[i++]=128|r>>>14&63,n[i++]=r>>>6&255,n[i++]=r<<2&255|e[10]&3,n[i++]=e[11],n[i++]=e[12],n[i++]=e[13],n[i++]=e[14],n[i++]=e[15],n}function BE(e){if(!po(e))throw TypeError("Invalid UUID");return parseInt(e.slice(14,15),16)}var VE=A({MAX:()=>O4,NIL:()=>P4,parse:()=>N4,stringify:()=>R4,v1:()=>j4,v4:()=>ho,v5:()=>zs,v6:()=>o_,v7:()=>tn,validate:()=>Ei,version:()=>M4}),O4=TE,P4=AE,N4=_a,R4=OE,j4=rf,ho=NE,zs=nf,o_=UE,tn=FE,Ei=po,M4=BE;var a_=0,Uu=0;function Lu(e){let t=Date.now();return t<=a_?(Uu+=1,Uu>=1e4&&(Uu=0,t=a_+1)):Uu=0,a_=t,o_({clockseq:e,msecs:t,nsecs:Uu})}function Gn(e,t){let r=t.replace(/-/g,"").match(/.{2}/g).map(n=>parseInt(n,16));return zs(e,new Uint8Array(r))}var Fu="__pregel_tasks",s_="__error__",ya="__scheduled__",c_="__interrupt__",u_="__resume__",Us=class{lg_name="DeltaSnapshot";value;constructor(e){this.value=e}};function l_(e){return e!=null&&typeof e=="object"&&e.lg_name==="DeltaSnapshot"}var HE="[...]",D4="[Circular]",of=[],Ls=[];function z4(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function ZE(e,t,r,n){typeof n>"u"&&(n=z4()),f_(e,"",0,[],void 0,0,n);var i;try{Ls.length===0?i=JSON.stringify(e,t,r):i=JSON.stringify(e,U4(t),r)}catch{return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;of.length!==0;){var o=of.pop();o.length===4?Object.defineProperty(o[0],o[1],o[3]):o[0][o[1]]=o[2]}}return i}function d_(e,t,r,n){var i=Object.getOwnPropertyDescriptor(n,r);i.get!==void 0?i.configurable?(Object.defineProperty(n,r,{value:e}),of.push([n,r,t,i])):Ls.push([t,r,e]):(n[r]=e,of.push([n,r,t]))}function f_(e,t,r,n,i,o,a){o+=1;var s;if(typeof e=="object"&&e!==null){for(s=0;s<n.length;s++)if(n[s]===e){d_(D4,e,t,i);return}if(typeof a.depthLimit<"u"&&o>a.depthLimit){d_(HE,e,t,i);return}if(typeof a.edgesLimit<"u"&&r+1>a.edgesLimit){d_(HE,e,t,i);return}if(n.push(e),Array.isArray(e))for(s=0;s<e.length;s++)f_(e[s],s,s,n,e,o,a);else{var c=Object.keys(e);for(s=0;s<c.length;s++){var u=c[s];f_(e[u],u,s,n,e,o,a)}}n.pop()}}function U4(e){return e=typeof e<"u"?e:function(t,r){return r},function(t,r){if(Ls.length>0)for(var n=0;n<Ls.length;n++){var i=Ls[n];if(i[1]===t&&i[0]===r){r=i[2],Ls.splice(n,1);break}}return e.call(this,t,r)}}var L4=/([A-Z]+)([A-Z][a-z0-9]+)/g,F4=/([a-z0-9])([A-Z])/g,GE=/[-_\s]+/g;function B4(e){return e.replace(L4,"$1_$2").replace(F4,"$1_$2").replace(GE,"_").toLowerCase()}function V4(e){let t=e.trim();return/[-_\s]/.test(t)?t.replace(GE,"_").toLowerCase().replace(/_+([a-z0-9])/g,(r,n)=>n.toUpperCase()):t}function WE(e,t){return t?.[e]||B4(e)}function qE(e,t){return t?.[e]||V4(e)}function af(e,t,r){let n={};for(let i in e)Object.hasOwn(e,i)&&(n[t(i,r)]=e[i]);return n}var KE="__lc_escaped__";function H4(e){return"lc"in e||Object.keys(e).length===1&&"__lc_escaped__"in e}function Z4(e){return{[KE]:e}}function p_(e){return Object.keys(e).length===1&&"__lc_escaped__"in e}function G4(e){return e!==null&&typeof e=="object"&&"lc_serializable"in e&&typeof e.toJSON=="function"}function W4(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 sf(e,t=new WeakSet){if(e!==null&&typeof e=="object"&&!Array.isArray(e)){if(t.has(e))return W4(e);if(G4(e))return e;t.add(e);let r=e;if(H4(r))return t.delete(e),Z4(r);let n={};for(let[i,o]of Object.entries(r))n[i]=sf(o,t);return t.delete(e),n}return Array.isArray(e)?e.map(r=>sf(r,t)):e}function cf(e){if(e!==null&&typeof e=="object"&&!Array.isArray(e)){let t=e;if(p_(t))return t[KE];let r={};for(let[n,i]of Object.entries(t))r[n]=cf(i);return r}return Array.isArray(e)?e.map(t=>cf(t)):e}var XE=A({Serializable:()=>yt,get_lc_unique_name:()=>Fs});function JE(e){return Array.isArray(e)?[...e]:{...e}}function q4(e,t){let r=JE(e);for(let[n,i]of Object.entries(t)){let[o,...a]=n.split(".").reverse(),s=r;for(let c of a.reverse()){if(s[c]===void 0)break;s[c]=JE(s[c]),s=s[c]}s[o]!==void 0&&(s[o]={lc:1,type:"secret",id:[i]})}return r}function Fs(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 yt=class YE{lc_serializable=!1;lc_kwargs;static lc_name(){return this.name}get lc_id(){return[...this.lc_namespace,Fs(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(([n])=>this.lc_serializable_keys?.includes(n))):this.lc_kwargs=t??{}}toJSON(){if(!this.lc_serializable)return this.toJSONNotImplemented();if(this.lc_kwargs instanceof YE||typeof this.lc_kwargs!="object"||Array.isArray(this.lc_kwargs))return this.toJSONNotImplemented();let t={},r={},n=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(n,Reflect.get(s,"lc_attributes",this));Object.keys(r).forEach(s=>{let c=this,u=n,[l,...d]=s.split(".").reverse();for(let f of d.reverse()){if(!(f in c)||c[f]===void 0)return;(!(f in u)||u[f]===void 0)&&(typeof c[f]=="object"&&c[f]!=null?u[f]={}:Array.isArray(c[f])&&(u[f]=[])),c=c[f],u=u[f]}l in c&&c[l]!==void 0&&(u[l]=u[l]||c[l])});let i={},o=new WeakSet;o.add(this);for(let[s,c]of Object.entries(n))i[s]=sf(c,o);let a=af(Object.keys(r).length?q4(i,r):i,WE,t);return{lc:1,type:"constructor",id:this.lc_id,kwargs:a}}toJSONNotImplemented(){return{lc:1,type:"not_implemented",id:this.lc_id}}};var QE=A({getEnv:()=>iI,getEnvironmentVariable:()=>pr,getRuntimeEnvironment:()=>h_,isBrowser:()=>eI,isDeno:()=>uf,isJsDom:()=>rI,isNode:()=>nI,isWebWorker:()=>tI}),eI=()=>typeof window<"u"&&typeof window.document<"u",tI=()=>typeof globalThis=="object"&&globalThis.constructor&&globalThis.constructor.name==="DedicatedWorkerGlobalScope",rI=()=>typeof window<"u"&&window.name==="nodejs"||typeof navigator<"u"&&navigator.userAgent.includes("jsdom"),uf=()=>typeof Deno<"u",nI=()=>typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"&&!uf(),iI=()=>{let e;return eI()?e="browser":nI()?e="node":tI()?e="webworker":rI()?e="jsdom":uf()?e="deno":e="other",e},m_;function h_(){return m_===void 0&&(m_={library:"langchain-js",runtime:iI()}),m_}function pr(e){try{return typeof process<"u"?process.env?.[e]:uf()?Deno?.env.get(e):void 0}catch{return}}var oI=[];var aI=A({});var sI=A({});var ee="0123456789abcdef".split(""),K4=[-2147483648,8388608,32768,128],yn=[24,16,8,0],lf=[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],jt=[];function vn(e,t){t?(jt[0]=jt[16]=jt[1]=jt[2]=jt[3]=jt[4]=jt[5]=jt[6]=jt[7]=jt[8]=jt[9]=jt[10]=jt[11]=jt[12]=jt[13]=jt[14]=jt[15]=0,this.blocks=jt):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}vn.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 n,i=0,o,a=e.length,s=this.blocks;i<a;){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(o=this.start;i<a&&o<64;++i)s[o>>>2]|=e[i]<<yn[o++&3];else for(o=this.start;i<a&&o<64;++i)n=e.charCodeAt(i),n<128?s[o>>>2]|=n<<yn[o++&3]:n<2048?(s[o>>>2]|=(192|n>>>6)<<yn[o++&3],s[o>>>2]|=(128|n&63)<<yn[o++&3]):n<55296||n>=57344?(s[o>>>2]|=(224|n>>>12)<<yn[o++&3],s[o>>>2]|=(128|n>>>6&63)<<yn[o++&3],s[o>>>2]|=(128|n&63)<<yn[o++&3]):(n=65536+((n&1023)<<10|e.charCodeAt(++i)&1023),s[o>>>2]|=(240|n>>>18)<<yn[o++&3],s[o>>>2]|=(128|n>>>12&63)<<yn[o++&3],s[o>>>2]|=(128|n>>>6&63)<<yn[o++&3],s[o>>>2]|=(128|n&63)<<yn[o++&3]);this.lastByteIndex=o,this.bytes+=o-this.start,o>=64?(this.block=s[16],this.start=o-64,this.hash(),this.hashed=!0):this.start=o}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}};vn.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var e=this.blocks,t=this.lastByteIndex;e[16]=this.block,e[t>>>2]|=K4[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()}};vn.prototype.hash=function(){var e=this.h0,t=this.h1,r=this.h2,n=this.h3,i=this.h4,o=this.h5,a=this.h6,s=this.h7,c=this.blocks,u,l,d,f,p,m,h,_,y,w,x;for(u=16;u<64;++u)p=c[u-15],l=(p>>>7|p<<25)^(p>>>18|p<<14)^p>>>3,p=c[u-2],d=(p>>>17|p<<15)^(p>>>19|p<<13)^p>>>10,c[u]=c[u-16]+l+c[u-7]+d<<0;for(x=t&r,u=0;u<64;u+=4)this.first?(this.is224?(_=300032,p=c[0]-1413257819,s=p-150054599<<0,n=p+24177077<<0):(_=704751109,p=c[0]-210244248,s=p-1521486534<<0,n=p+143694565<<0),this.first=!1):(l=(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10),d=(i>>>6|i<<26)^(i>>>11|i<<21)^(i>>>25|i<<7),_=e&t,f=_^e&r^x,h=i&o^~i&a,p=s+d+h+lf[u]+c[u],m=l+f,s=n+p<<0,n=p+m<<0),l=(n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10),d=(s>>>6|s<<26)^(s>>>11|s<<21)^(s>>>25|s<<7),y=n&e,f=y^n&t^_,h=a&s^~a&i,p=o+d+h+lf[u+1]+c[u+1],m=l+f,a=r+p<<0,r=p+m<<0,l=(r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10),d=(a>>>6|a<<26)^(a>>>11|a<<21)^(a>>>25|a<<7),w=r&n,f=w^r&e^y,h=o&a^~o&s,p=i+d+h+lf[u+2]+c[u+2],m=l+f,o=t+p<<0,t=p+m<<0,l=(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10),d=(o>>>6|o<<26)^(o>>>11|o<<21)^(o>>>25|o<<7),x=t&r,f=x^t&n^w,h=o&a^~o&s,p=i+d+h+lf[u+3]+c[u+3],m=l+f,i=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+n<<0,this.h4=this.h4+i<<0,this.h5=this.h5+o<<0,this.h6=this.h6+a<<0,this.h7=this.h7+s<<0};vn.prototype.hex=function(){this.finalize();var e=this.h0,t=this.h1,r=this.h2,n=this.h3,i=this.h4,o=this.h5,a=this.h6,s=this.h7,c=ee[e>>>28&15]+ee[e>>>24&15]+ee[e>>>20&15]+ee[e>>>16&15]+ee[e>>>12&15]+ee[e>>>8&15]+ee[e>>>4&15]+ee[e&15]+ee[t>>>28&15]+ee[t>>>24&15]+ee[t>>>20&15]+ee[t>>>16&15]+ee[t>>>12&15]+ee[t>>>8&15]+ee[t>>>4&15]+ee[t&15]+ee[r>>>28&15]+ee[r>>>24&15]+ee[r>>>20&15]+ee[r>>>16&15]+ee[r>>>12&15]+ee[r>>>8&15]+ee[r>>>4&15]+ee[r&15]+ee[n>>>28&15]+ee[n>>>24&15]+ee[n>>>20&15]+ee[n>>>16&15]+ee[n>>>12&15]+ee[n>>>8&15]+ee[n>>>4&15]+ee[n&15]+ee[i>>>28&15]+ee[i>>>24&15]+ee[i>>>20&15]+ee[i>>>16&15]+ee[i>>>12&15]+ee[i>>>8&15]+ee[i>>>4&15]+ee[i&15]+ee[o>>>28&15]+ee[o>>>24&15]+ee[o>>>20&15]+ee[o>>>16&15]+ee[o>>>12&15]+ee[o>>>8&15]+ee[o>>>4&15]+ee[o&15]+ee[a>>>28&15]+ee[a>>>24&15]+ee[a>>>20&15]+ee[a>>>16&15]+ee[a>>>12&15]+ee[a>>>8&15]+ee[a>>>4&15]+ee[a&15];return this.is224||(c+=ee[s>>>28&15]+ee[s>>>24&15]+ee[s>>>20&15]+ee[s>>>16&15]+ee[s>>>12&15]+ee[s>>>8&15]+ee[s>>>4&15]+ee[s&15]),c};vn.prototype.toString=vn.prototype.hex;vn.prototype.digest=function(){this.finalize();var e=this.h0,t=this.h1,r=this.h2,n=this.h3,i=this.h4,o=this.h5,a=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,n>>>24&255,n>>>16&255,n>>>8&255,n&255,i>>>24&255,i>>>16&255,i>>>8&255,i&255,o>>>24&255,o>>>16&255,o>>>8&255,o&255,a>>>24&255,a>>>16&255,a>>>8&255,a&255];return this.is224||c.push(s>>>24&255,s>>>16&255,s>>>8&255,s&255),c};vn.prototype.array=vn.prototype.digest;vn.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 Bs=(...e)=>new vn(!1,!0).update(e.join("")).hex();var cI=A({sha256:()=>Bs});function uI(e){let t=Symbol.for(e);return{brand(r,n){let i=n?Symbol.for(`${e}.${n}`):t;class o extends r{[i]=!0;constructor(...s){super(...s)}static isInstance(s){return typeof s=="object"&&s!==null&&i in s&&s[i]===!0}}return Object.defineProperty(o,"name",{value:r.name}),o},sub(r){return uI(`${e}.${r}`)},isInstance(r){return typeof r=="object"&&r!==null&&t in r&&r[t]===!0}}}var lI=uI("langchain");var dI=A({ContextOverflowError:()=>J4,LangChainError:()=>g_,ModelAbortError:()=>ff,addLangChainErrorFields:()=>Ii,ns:()=>df});function Ii(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 df=lI.sub("error"),g_=class extends df.brand(Error){name="LangChainError";constructor(e){super(e),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}},ff=class extends df.brand(g_,"model-abort"){name="ModelAbortError";partialOutput;constructor(e,t){super(e),this.partialOutput=t}},J4=class fI extends df.brand(g_,"context-overflow"){name="ContextOverflowError";cause;constructor(t){super(t??"Input exceeded the model's context window.")}static fromError(t){let r=new fI(t.message);return r.cause=t,r}};function Wn(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 Vs(e){return Wn(e)&&e.source_type==="url"&&"url"in e&&typeof e.url=="string"}function Hs(e){return Wn(e)&&e.source_type==="base64"&&"data"in e&&typeof e.data=="string"}function pI(e){return Wn(e)&&e.source_type==="text"&&"text"in e&&typeof e.text=="string"}function pf(e){return Wn(e)&&e.source_type==="id"&&"id"in e&&typeof e.id=="string"}function mf(e){if(Wn(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 mI(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(),n=t[1].trim();if(r===""||n==="")throw new Error(`Invalid mime type: "${e}" - type or subtype is empty.`);let i={};for(let o of e.split(";").slice(1)){let a=o.split("=");if(a.length!==2)throw new Error(`Invalid parameter syntax in mime type: "${e}".`);let s=a[0].trim(),c=a[1].trim();if(s==="")throw new Error(`Invalid parameter syntax in mime type: "${e}".`);i[s]=c}return{type:r,subtype:n,parameters:i}}function Bu({dataUrl:e,asTypedArray:t=!1}){let r=e.match(/^data:(\w+\/\w+);base64,([A-Za-z0-9+/]+=*)$/),n;if(r){n=r[1].toLowerCase();let i=t?Uint8Array.from(atob(r[2]),o=>o.charCodeAt(0)):r[2];return{mime_type:n,data:i}}}function hI(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 Z(e,t){return re(e)&&e.type===t}function re(e){return typeof e=="object"&&e!==null}function It(e){return Array.isArray(e)}function O(e){return typeof e=="string"}function Fr(e){return typeof e=="number"}function hf(e){return e instanceof Uint8Array}function __(e){try{return JSON.parse(e)}catch{return}}var Br=e=>e();function X4(e){if(e.type==="char_location"&&O(e.document_title)&&Fr(e.start_char_index)&&Fr(e.end_char_index)&&O(e.cited_text)){let{document_title:t,start_char_index:r,end_char_index:n,cited_text:i,...o}=e;return{...o,type:"citation",source:"char",title:t??void 0,startIndex:r,endIndex:n,citedText:i}}if(e.type==="page_location"&&O(e.document_title)&&Fr(e.start_page_number)&&Fr(e.end_page_number)&&O(e.cited_text)){let{document_title:t,start_page_number:r,end_page_number:n,cited_text:i,...o}=e;return{...o,type:"citation",source:"page",title:t??void 0,startIndex:r,endIndex:n,citedText:i}}if(e.type==="content_block_location"&&O(e.document_title)&&Fr(e.start_block_index)&&Fr(e.end_block_index)&&O(e.cited_text)){let{document_title:t,start_block_index:r,end_block_index:n,cited_text:i,...o}=e;return{...o,type:"citation",source:"block",title:t??void 0,startIndex:r,endIndex:n,citedText:i}}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:n,cited_text:i,...o}=e;return{...o,type:"citation",source:"url",url:t,title:r,startIndex:Number(n),endIndex:Number(n),citedText:i}}if(e.type==="search_result_location"&&O(e.source)&&O(e.title)&&Fr(e.start_block_index)&&Fr(e.end_block_index)&&O(e.cited_text)){let{source:t,title:r,start_block_index:n,end_block_index:i,cited_text:o,...a}=e;return{...a,type:"citation",source:"search",url:t,title:r??void 0,startIndex:n,endIndex:i,citedText:o}}}function _I(e){if(Z(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(Z(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 yI(e){function*t(){for(let r of e){let n=_I(r);n?yield n:yield r}}return Array.from(t())}function gI(e){function*t(){let r=typeof e.content=="string"?[{type:"text",text:e.content}]:e.content;for(let n of r){if(Z(n,"text")&&O(n.text)){let{text:i,citations:o,...a}=n;if(It(o)&&o.length){let s=o.reduce((c,u)=>{let l=X4(u);return l?[...c,l]:c},[]);yield{...a,type:"text",text:i,annotations:s};continue}else{yield{...a,type:"text",text:i};continue}}else if(Z(n,"thinking")&&O(n.thinking)){let{thinking:i,signature:o,...a}=n;yield{...a,type:"reasoning",reasoning:i,signature:o};continue}else if(Z(n,"redacted_thinking")){yield{type:"non_standard",value:n};continue}else if(Z(n,"tool_use")&&O(n.name)&&O(n.id)){yield{type:"tool_call",id:n.id,name:n.name,args:n.input};continue}else if(Z(n,"input_json_delta")){if(Y4(e)&&e.tool_call_chunks?.length){let i=e.tool_call_chunks[0];yield{type:"tool_call_chunk",id:i.id,name:i.name,args:i.args,index:i.index};continue}}else if(Z(n,"server_tool_use")&&O(n.name)&&O(n.id)){let{name:i,id:o}=n;if(i==="web_search"){yield{id:o,type:"server_tool_call",name:"web_search",args:{query:Br(()=>{if(typeof n.input=="string")return n.input;if(re(n.input)&&O(n.input.query))return n.input.query;if(O(n.partial_json)){let a=__(n.partial_json);if(a?.query)return a.query}return""})}};continue}else if(n.name==="code_execution"){yield{id:o,type:"server_tool_call",name:"code_execution",args:{code:Br(()=>{if(typeof n.input=="string")return n.input;if(re(n.input)&&O(n.input.code))return n.input.code;if(O(n.partial_json)){let a=__(n.partial_json);if(a?.code)return a.code}return""})}};continue}}else if(Z(n,"web_search_tool_result")&&O(n.tool_use_id)&&It(n.content)){let{content:i,tool_use_id:o}=n;yield{type:"server_tool_call_result",name:"web_search",toolCallId:o,status:"success",output:{urls:i.reduce((a,s)=>Z(s,"web_search_result")?[...a,s.url]:a,[])}};continue}else if(Z(n,"code_execution_tool_result")&&O(n.tool_use_id)&&re(n.content)){yield{type:"server_tool_call_result",name:"code_execution",toolCallId:n.tool_use_id,status:"success",output:n.content};continue}else if(Z(n,"mcp_tool_use")){yield{id:n.id,type:"server_tool_call",name:"mcp_tool_use",args:n.input};continue}else if(Z(n,"mcp_tool_result")&&O(n.tool_use_id)&&re(n.content)){yield{type:"server_tool_call_result",name:"mcp_tool_use",toolCallId:n.tool_use_id,status:"success",output:n.content};continue}else if(Z(n,"container_upload")){yield{type:"server_tool_call",name:"container_upload",args:n.input};continue}else if(Z(n,"search_result")){yield{id:n.id,type:"non_standard",value:n};continue}else if(Z(n,"tool_result")){yield{id:n.id,type:"non_standard",value:n};continue}else{let i=_I(n);if(i){yield i;continue}}yield{type:"non_standard",value:n}}}return Array.from(t())}var vI={translateContent:gI,translateContentChunk:gI};function Y4(e){return typeof e?._getType=="function"&&typeof e.concat=="function"&&e._getType()==="ai"}function Q4(e){return Vs(e)?{type:e.type,mimeType:e.mime_type,url:e.url,metadata:e.metadata}:Hs(e)?{type:e.type,mimeType:e.mime_type??"application/octet-stream",data:e.data,metadata:e.metadata}:pf(e)?{type:e.type,mimeType:e.mime_type,fileId:e.id,metadata:e.metadata}:e}function bI(e){return e.map(Q4)}function wI(e){return!!(Z(e,"image_url")&&re(e.image_url)||Z(e,"input_audio")&&re(e.input_audio)||Z(e,"file")&&re(e.file))}function xI(e){if(Z(e,"image_url")&&re(e.image_url)&&O(e.image_url.url)){let t=Bu({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(Z(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(Z(e,"file")&&re(e.file)&&O(e.file.data)){let t=Bu({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 ez(e){let t=[];typeof e.content=="string"?e.content.length>0&&t.push({type:"text",text:e.content}):t.push(...gf(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 tz(e){let t=[];typeof e.content=="string"?e.content.length>0&&t.push({type:"text",text:e.content}):t.push(...gf(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 gf(e){let t=[];for(let r of e)wI(r)?t.push(xI(r)):t.push(r);return t}function rz(e){if(e.type==="url_citation"){let{url:t,title:r,start_index:n,end_index:i}=e;return{type:"citation",url:t,title:r,startIndex:n,endIndex:i}}if(e.type==="file_citation"){let{file_id:t,filename:r,index:n}=e;return{type:"citation",title:r,startIndex:n,endIndex:n,fileId:t}}return e}function SI(e){function*t(){re(e.additional_kwargs?.reasoning)&&It(e.additional_kwargs.reasoning.summary)&&(yield{type:"reasoning",reasoning:e.additional_kwargs.reasoning.summary.reduce((n,i)=>re(i)&&O(i.text)?`${n}${i.text}`:n,"")});let r=typeof e.content=="string"?[{type:"text",text:e.content}]:e.content;for(let n of r)if(Z(n,"text")){let{text:i,annotations:o,phase:a,extras:s,...c}=n,u=re(s)?{...s}:{};O(a)&&(u.phase=a);let l=Object.keys(u).length>0?{extras:u}:{};Array.isArray(o)?yield{...c,...l,type:"text",text:String(i),annotations:o.map(rz)}:yield{...c,...l,type:"text",text:String(i)}}for(let n of e.tool_calls??[])yield{type:"tool_call",id:n.id,name:n.name,args:n.args};if(re(e.additional_kwargs)&&It(e.additional_kwargs.tool_outputs))for(let n of e.additional_kwargs.tool_outputs){if(Z(n,"web_search_call")){let i={};if(re(n.action)&&O(n.action.query)&&(i.query=n.action.query),yield{id:n.id,type:"server_tool_call",name:"web_search",args:i},n.status==="completed"||n.status==="failed"){let o={};re(n.action)&&(o.action=n.action),yield{type:"server_tool_call_result",toolCallId:O(n.id)?n.id:"",status:n.status==="completed"?"success":"error",output:o}}continue}else if(Z(n,"file_search_call")){yield{id:n.id,type:"server_tool_call",name:"file_search",args:{queries:It(n.queries)?n.queries:[]}},(n.status==="completed"||n.status==="failed")&&(yield{type:"server_tool_call_result",toolCallId:O(n.id)?n.id:"",status:n.status==="completed"?"success":"error",output:It(n.results)?{results:n.results}:{}});continue}else if(Z(n,"computer_call")){yield{type:"non_standard",value:n};continue}else if(Z(n,"code_interpreter_call")){if(O(n.code)&&(yield{id:n.id,type:"server_tool_call",name:"code_interpreter",args:{code:n.code}}),It(n.outputs)){let i=Br(()=>{if(n.status!=="in_progress"){if(n.status==="completed")return 0;if(n.status==="incomplete")return 127;if(n.status!=="interpreting"&&n.status==="failed")return 1}});for(let o of n.outputs)if(Z(o,"logs")){yield{type:"server_tool_call_result",toolCallId:n.id??"",status:"success",output:{type:"code_interpreter_output",returnCode:i??0,stderr:[0,void 0].includes(i)?void 0:String(o.logs),stdout:[0,void 0].includes(i)?String(o.logs):void 0}};continue}}continue}else if(Z(n,"mcp_call")){yield{id:n.id,type:"server_tool_call",name:"mcp_call",args:n.input};continue}else if(Z(n,"mcp_list_tools")){yield{id:n.id,type:"server_tool_call",name:"mcp_list_tools",args:n.input};continue}else if(Z(n,"mcp_approval_request")){yield{type:"non_standard",value:n};continue}else if(Z(n,"tool_search_call")){let i={};re(n.arguments)&&Object.assign(i,n.arguments);let o={};O(n.execution)&&(o.execution=n.execution),O(n.status)&&(o.status=n.status),O(n.call_id)&&(o.call_id=n.call_id),yield{id:O(n.id)?n.id:"",type:"server_tool_call",name:"tool_search",args:i,...Object.keys(o).length>0?{extras:o}:{}};continue}else if(Z(n,"tool_search_output")){let i={name:"tool_search"};O(n.execution)&&(i.execution=n.execution),yield{type:"server_tool_call_result",toolCallId:O(n.id)?n.id:"",status:n.status==="completed"?"success":n.status==="failed"?"error":"success",output:{tools:It(n.tools)?n.tools:[]},extras:i};continue}else if(Z(n,"image_generation_call")){O(n.result)&&(yield{type:"image",mimeType:"image/png",data:n.result,id:O(n.id)?n.id:void 0,metadata:{status:O(n.status)?n.status:void 0}}),yield{type:"non_standard",value:n};continue}re(n)&&(yield{type:"non_standard",value:n})}}return Array.from(t())}function nz(e){function*t(){yield*SI(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 kI={translateContent:e=>typeof e.content=="string"?ez(e):SI(e),translateContentChunk:e=>typeof e.content=="string"?tz(e):nz(e)};function _f(e){return typeof e=="object"&&e!==null&&"type"in e&&"content"in e&&(typeof e.content=="string"||Array.isArray(e.content))}function EI(e,t="pretty"){return t==="pretty"?iz(e):JSON.stringify(e)}function iz(e){let t=[],r=` ${e.type.charAt(0).toUpperCase()+e.type.slice(1)} Message `,n=Math.floor((80-r.length)/2),i="=".repeat(n),o=r.length%2===0?i:`${i}=`;if(t.push(`${i}${r}${o}`),e.type==="ai"){let a=e;if(a.tool_calls&&a.tool_calls.length>0){t.push("Tool Calls:");for(let s of a.tool_calls){t.push(` ${s.name} (${s.id})`),t.push(` Call ID: ${s.id}`),t.push(" Args:");for(let[c,u]of Object.entries(s.args))t.push(` ${c}: ${typeof u=="object"?JSON.stringify(u):u}`)}}}if(e.type==="tool"){let a=e;a.name&&t.push(`Name: ${a.name}`)}return typeof e.content=="string"&&e.content.trim()&&(t.length>1&&t.push(""),t.push(e.content)),t.join(`
9
- `)}var y_=Symbol.for("langchain.message");function II(e){return Array.isArray(e)?e:typeof e=="string"?e===""?[]:[{type:"text",text:e}]:e==null?[]:[e]}function Jt(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=>Wn(r))?[{type:"text",source_type:"text",text:e},...t]:[{type:"text",text:e},...t];if(Array.isArray(t)){let r=II(e);return go(r,t)??[...r,...t]}else return t===""?e:Array.isArray(e)&&e.some(r=>Wn(r))?[...e,{type:"file",source_type:"text",text:t}]:[...II(e),{type:"text",text:t}]}function yf(e,t){return e==="error"||t==="error"?"error":"success"}function oz(e,t){function r(n,i){if(typeof n!="object"||n===null||n===void 0)return n;if(i>=t)return Array.isArray(n)?"[Array]":"[Object]";if(Array.isArray(n))return n.map(a=>r(a,i+1));let o={};for(let a of Object.keys(n))o[a]=r(n[a],i+1);return o}return JSON.stringify(r(e,0),null,2)}var Re=class extends yt{lc_namespace=["langchain_core","messages"];lc_serializable=!0;get lc_aliases(){return{additional_kwargs:"additional_kwargs",response_metadata:"response_metadata"}}[y_]=!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[bI,gf,yI].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&&y_ in e&&e[y_]===!0&&_f(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=oz(this._printableFields,Math.max(4,e));return`${this.constructor.lc_name()} ${t}`}toFormattedString(e="pretty"){return EI(this,e)}};function CI(e){return Array.isArray(e)&&e.every(t=>typeof t.index=="number")}var v_=["index","created","timestamp"];function it(e,t,r){let n=r?.ignoreKeys??v_;if(e==null&&t==null)return;if(e==null||t==null)return e??t;let i={...e};for(let[o,a]of Object.entries(t))if(i[o]==null)i[o]=a;else{if(a==null)continue;if(typeof i[o]!=typeof a||Array.isArray(i[o])!==Array.isArray(a))throw new Error(`field[${o}] already exists in the message chunk, but with a different type.`);if(typeof i[o]=="string"){if(o==="type")continue;if(["id","name","output_version","model_provider"].includes(o))a&&(i[o]=a);else{if(n.includes(o))continue;i[o]+=a}}else if(typeof i[o]=="number"){if(n.includes(o))continue;i[o]=i[o]+a}else if(typeof i[o]=="object"&&!Array.isArray(i[o]))i[o]=it(i[o],a,r);else if(Array.isArray(i[o]))i[o]=go(i[o],a,r);else{if(i[o]===a)continue;console.warn(`field[${o}] already exists in this message chunk and value has unsupported type.`)}}return i}function az(e){return typeof e=="number"||typeof e=="string"}function $I(e){return typeof e!="object"||e===null||!("index"in e)?!1:az(e.index)}function TI(e){if(typeof e!="object"||e===null||!("id"in e))return!1;let t=e.id;return t!=null&&t!==""}function AI(e){return e.endsWith("_delta")?e.slice(0,-6):e}function sz(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"&&AI(e.type)!==AI(t.type)}function cz(e,t){let r=$I(t),n=TI(t);return!r&&!n?-1:e.findIndex(i=>{let o=$I(i),a=TI(i);return r&&o?i.index!==t.index||sz(i,t)?!1:a&&n?i.id===t.id:!0:!r&&!o&&n&&a?i.id===t.id:!1})}function go(e,t,r){if(!(e==null&&t==null)){if(e==null||t==null)return e||t;{let n=[...e];for(let i of t){let o=cz(n,i);if(o!==-1)n[o]=it(n[o],i,r);else{if(typeof i=="object"&&i!==null&&"text"in i&&i.text==="")continue;n.push(i)}}return n}}}function vf(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 go(e,t,r);if(typeof e=="object"&&typeof t=="object")return it(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 Mt=class OI extends Re{static isInstance(t){if(!super.isInstance(t))return!1;let r=Object.getPrototypeOf(t);for(;r!==null;){if(r===OI.prototype)return!0;r=Object.getPrototypeOf(r)}return!1}};function bf(e){return typeof e.role=="string"}function ot(e){return typeof e?._getType=="function"}function $i(e){return Mt.isInstance(e)}var PI=A({ToolMessage:()=>$t,ToolMessageChunk:()=>Zs,defaultToolCallParser:()=>Hu,isDirectToolOutput:()=>Vu,isToolMessage:()=>Zu,isToolMessageChunk:()=>b_});function Vu(e){return e!=null&&typeof e=="object"&&"lc_direct_tool_output"in e&&e.lc_direct_tool_output===!0}var $t=class extends Re{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 n=typeof e=="string"||Array.isArray(e)?{content:e,name:r,tool_call_id:t}:e;super(n),this.tool_call_id=n.tool_call_id,this.artifact=n.artifact,this.status=n.status,this.metadata=n.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}}},Zs=class extends Mt{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:Jt(this.content,e.content),additional_kwargs:it(this.additional_kwargs,e.additional_kwargs),response_metadata:it(this.response_metadata,e.response_metadata),artifact:vf(this.artifact,e.artifact),tool_call_id:this.tool_call_id,id:this.id??e.id,status:yf(this.status,e.status)})}get _printableFields(){return{...super._printableFields,tool_call_id:this.tool_call_id,artifact:this.artifact}}};function Hu(e){let t=[],r=[];for(let n of e)if(n.function){let i=n.function.name;try{let o=JSON.parse(n.function.arguments);t.push({name:i||"",args:o||{},id:n.id})}catch{r.push({name:i,args:n.function.arguments,id:n.id,error:"Malformed args."})}}else continue;return[t,r]}function Zu(e){return typeof e=="object"&&e!==null&&"getType"in e&&typeof e.getType=="function"&&e.getType()==="tool"}function b_(e){return e._getType()==="tool"}function _o(e){return!!(e&&typeof e=="object"&&"type"in e&&e.type==="tool_call")}function NI(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 Gs=class extends Error{output;constructor(e,t){super(e),this.output=t}};function va(e,t=qn){e=e.trim();let r=e.indexOf("```");if(r===-1)return t(e);let n=e.substring(r+3);n.startsWith(`json
14
- `)?n=n.substring(5):n.startsWith("json")?n=n.substring(4):n.startsWith(`
15
- `)&&(n=n.substring(1));let i=n.indexOf("```"),o=n;return i!==-1&&(o=n.substring(0,i)),t(o.trim())}function uz(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 n(){for(;r<t.length&&/\s/.test(t[r]);)r+=1}function i(){if(t[r]!=='"')throw new Error(`Expected '"' at position ${r}, got '${t[r]}'`);r+=1;let l="",d=!1;for(;r<t.length;){let f=t[r];if(d){if(f==="n")l+=`
16
- `;else if(f==="t")l+=" ";else if(f==="r")l+="\r";else if(f==="\\")l+="\\";else if(f==='"')l+='"';else if(f==="b")l+="\b";else if(f==="f")l+="\f";else if(f==="/")l+="/";else if(f==="u"){let p=t.substring(r+1,r+5);if(/^[0-9A-Fa-f]{0,4}$/.test(p))p.length===4?l+=String.fromCharCode(Number.parseInt(p,16)):l+=`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,l;l+=f}r+=1}return d&&(l+="\\"),l}function o(){let l=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 ${l}`);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=l,new Error(`Invalid number '${d}' at position ${l}`);return f}function a(){if(n(),r>=t.length)throw new Error(`Unexpected end of input at position ${r}`);let l=t[r];if(l==="{")return c();if(l==="[")return s();if(l==='"')return i();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(l==="-"||l>="0"&&l<="9")return o();throw new Error(`Unexpected character '${l}' at position ${r}`)}function s(){if(t[r]!=="[")throw new Error(`Expected '[' at position ${r}, got '${t[r]}'`);let l=[];if(r+=1,n(),r>=t.length)return l;if(t[r]==="]")return r+=1,l;for(;r<t.length;){if(n(),r>=t.length||(l.push(a()),n(),r>=t.length))return l;if(t[r]==="]")return r+=1,l;if(t[r]===","){r+=1;continue}throw new Error(`Expected ',' or ']' at position ${r}, got '${t[r]}'`)}return l}function c(){if(t[r]!=="{")throw new Error(`Expected '{' at position ${r}, got '${t[r]}'`);let l={};if(r+=1,n(),r>=t.length)return l;if(t[r]==="}")return r+=1,l;for(;r<t.length;){if(n(),r>=t.length)return l;let d=i();if(n(),r>=t.length)return l;if(t[r]!==":")throw new Error(`Expected ':' at position ${r}, got '${t[r]}'`);if(r+=1,n(),r>=t.length||(l[d]=a(),n(),r>=t.length))return l;if(t[r]==="}")return r+=1,l;if(t[r]===","){r+=1;continue}throw new Error(`Expected ',' or '}' at position ${r}, got '${t[r]}'`)}return l}let u=a();if(n(),r<t.length)throw new Error(`Unexpected character '${t[r]}' at position ${r}`);return u}function qn(e){try{return typeof e>"u"?null:uz(e)}catch{return null}}function w_(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 lz(e){if(re(e.document)&&re(e.document.source)){let t=w_(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(hf(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(It(e.document.source.content))return{type:"file",mimeType:t,data:e.document.source.content.reduce((r,n)=>re(n)&&O(n.text)?r+n.text:r,"")}}}return{type:"non_standard",value:e}}function dz(e){if(Z(e,"image")&&re(e.image)){let t=w_(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(hf(e.image.source.bytes))return{type:"image",mimeType:t,data:e.image.source.bytes}}}return{type:"non_standard",value:e}}function fz(e){if(Z(e,"video")&&re(e.video)){let t=w_(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(hf(e.video.source.bytes))return{type:"video",mimeType:t,data:e.video.source.bytes}}}return{type:"non_standard",value:e}}function RI(e){function*t(){let r=typeof e.content=="string"?[{type:"text",text:e.content}]:e.content;for(let n of r){if(Z(n,"reasoning")&&O(n.reasoning)){yield{...n,type:"reasoning",reasoning:n.reasoning};continue}else if(Z(n,"cache_point")){yield{type:"non_standard",value:n};continue}else if(Z(n,"citations_content")&&re(n.citationsContent)){yield{type:"text",text:It(n.citationsContent.content)?n.citationsContent.content.reduce((i,o)=>re(o)&&O(o.text)?i+o.text:i,""):"",annotations:It(n.citationsContent.citations)?n.citationsContent.citations.reduce((i,o)=>{if(re(o)){let a=It(o.sourceContent)?o.sourceContent.reduce((c,u)=>re(u)&&O(u.text)?c+u.text:c,""):"",s=Br(()=>{if(re(o.location)){let c=o.location.documentChar||o.location.documentPage||o.location.documentChunk;if(re(c))return{source:Fr(c.documentIndex)?c.documentIndex.toString():void 0,startIndex:Fr(c.start)?c.start:void 0,endIndex:Fr(c.end)?c.end:void 0}}return{}});i.push({type:"citation",citedText:a,...s})}return i},[]):[]};continue}else if(Z(n,"document")&&re(n.document)){yield lz(n);continue}else if(Z(n,"guard_content")){yield{type:"non_standard",value:n};continue}else if(Z(n,"image")&&re(n.image)){yield dz(n);continue}else if(Z(n,"reasoning_content")&&re(n.reasoningText)&&O(n.reasoningText.text)){yield{type:"reasoning",reasoning:n.reasoningText.text,...O(n.reasoningText.signature)?{signature:n.reasoningText.signature}:{}};continue}else if(Z(n,"reasoning_content")&&O(n.reasoningText)){yield{type:"reasoning",reasoning:n.reasoningText};continue}else if(Z(n,"text")&&O(n.text)){yield{type:"text",text:n.text};continue}else if(Z(n,"tool_result")){yield{type:"non_standard",value:n};continue}else{if(Z(n,"tool_call"))continue;if(Z(n,"video")&&re(n.video)){yield fz(n);continue}}yield{type:"non_standard",value:n}}}return Array.from(t())}var jI={translateContent:RI,translateContentChunk:RI};function MI(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 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 DI={translateContent:MI,translateContentChunk:MI};function zI(e){function*t(){let r=typeof e.content=="string"?[{type:"text",text:e.content}]:e.content;for(let n of r){if(Z(n,"text")&&O(n.text)){yield{type:"text",text:n.text};continue}else if(Z(n,"thinking")&&O(n.thinking)){yield{type:"reasoning",reasoning:n.thinking,...n.signature?{signature:n.signature}:{}};continue}else if(Z(n,"inlineData")&&re(n.inlineData)&&O(n.inlineData.mimeType)&&O(n.inlineData.data)){yield{type:"file",mimeType:n.inlineData.mimeType,data:n.inlineData.data};continue}else if(Z(n,"functionCall")&&re(n.functionCall)&&O(n.functionCall.name)&&re(n.functionCall.args)){yield{type:"tool_call",id:e.id,name:n.functionCall.name,args:n.functionCall.args};continue}else if(Z(n,"functionResponse")){yield{type:"non_standard",value:n};continue}else if(Z(n,"fileData")&&re(n.fileData)&&O(n.fileData.mimeType)&&O(n.fileData.fileUri)){yield{type:"file",mimeType:n.fileData.mimeType,fileId:n.fileData.fileUri};continue}else if(Z(n,"executableCode")){yield{type:"non_standard",value:n};continue}else if(Z(n,"codeExecutionResult")){yield{type:"non_standard",value:n};continue}yield{type:"non_standard",value:n}}}return Array.from(t())}var UI={translateContent:zI,translateContentChunk:zI};function LI(e){function*t(){let r=typeof e.content=="string"?[{type:"text",text:e.content}]:e.content;for(let n of r){if(Z(n,"reasoning")&&O(n.reasoning)){let i=Br(()=>{let o=r.indexOf(n);if(It(e.additional_kwargs?.signatures)&&o>=0)return e.additional_kwargs.signatures.at(o)});O(i)?yield{type:"reasoning",reasoning:n.reasoning,signature:i}:yield{type:"reasoning",reasoning:n.reasoning};continue}else if(Z(n,"thinking")&&O(n.thinking)){yield{type:"reasoning",reasoning:n.thinking,...n.signature?{signature:n.signature}:{}};continue}else if(Z(n,"text")&&O(n.text)){yield{type:"text",text:n.text};continue}else if(Z(n,"image_url")){if(O(n.image_url))if(n.image_url.startsWith("data:")){let i=n.image_url.match(/^data:([^;]+);base64,(.+)$/);i?yield{type:"image",data:i[2],mimeType:i[1]}:yield{type:"image",url:n.image_url}}else yield{type:"image",url:n.image_url};continue}else if(Z(n,"media")&&O(n.mimeType)&&O(n.data)){yield{type:"file",mimeType:n.mimeType,data:n.data};continue}yield{type:"non_standard",value:n}}}return Array.from(t())}var FI={translateContent:LI,translateContentChunk:LI};function BI(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 n=e.content,i=n.match(/<think>([\s\S]*?)<\/think>/);if(i){let o=i[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})}else for(let n of e.content)if(typeof n=="object"&&"type"in n&&n.type==="text"&&"text"in n&&O(n.text)){let i=n.text,o=i.match(/<think>([\s\S]*?)<\/think>/);if(o){let a=o[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})}for(let n of e.tool_calls??[])t.push({type:"tool_call",id:n.id,name:n.name,args:n.args});return t}var VI={translateContent:BI,translateContentChunk:BI};function HI(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 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 ZI={translateContent:HI,translateContentChunk:HI};function GI(e){let t=[],r=e.additional_kwargs?.reasoning_details,n=!1;if(Array.isArray(r)&&r.length>0)for(let i of r){if(i==null||typeof i!="object")continue;let o=i.type;if(o==="reasoning.summary"){let a=i.summary;O(a)&&a.length>0&&(t.push({type:"reasoning",reasoning:a}),n=!0)}else if(o==="reasoning.text"){let a=i.text;O(a)&&a.length>0&&(t.push({type:"reasoning",reasoning:a}),n=!0)}}if(!n){let i=e.additional_kwargs?.reasoning_content;O(i)&&i.length>0&&t.push({type:"reasoning",reasoning:i})}if(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 WI={translateContent:GI,translateContentChunk:GI};function qI(e){let t=[];if(re(e.additional_kwargs?.reasoning)){let n=e.additional_kwargs.reasoning;if(It(n.summary)){let i=n.summary.reduce((o,a)=>re(a)&&O(a.text)?`${o}${a.text}`:o,"");i.length>0&&t.push({type:"reasoning",reasoning:i})}}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 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 KI={translateContent:qI,translateContentChunk:qI};function JI(e){function*t(){let r=Br(()=>{if(typeof e.content=="string")return e.additional_kwargs.originalTextContentBlock?[{...e.additional_kwargs.originalTextContentBlock,type:"text"}]:[{type:"text",text:e.content}];{let n=e.additional_kwargs?.originalTextContentBlock;if(n?.thoughtSignature&&!e.content.some(i=>"thoughtSignature"in i)){let i=[...e.content];for(let o=i.length-1;o>=0;o--){let a=i[o];if(a.type==="text"&&!a.thought)return a.thoughtSignature=n.thoughtSignature,i}}return e.content}});for(let n of r){let i=Br(()=>Z(n,"text")&&O(n.text)?{type:"text",text:n.text}:Z(n,"inlineData")&&re(n.inlineData)&&O(n.inlineData.mimeType)&&O(n.inlineData.data)?{type:"file",mimeType:n.inlineData.mimeType,data:n.inlineData.data}:Z(n,"functionCall")&&re(n.functionCall)&&O(n.functionCall.name)&&re(n.functionCall.args)?{type:"tool_call",id:e.id,name:n.functionCall.name,args:n.functionCall.args}:Z(n,"functionResponse")?{type:"non_standard",value:n}:Z(n,"fileData")&&re(n.fileData)&&O(n.fileData.mimeType)&&O(n.fileData.fileUri)?{type:"file",mimeType:n.fileData.mimeType,fileId:n.fileData.fileUri}:Z(n,"executableCode")?{type:"non_standard",value:n}:Z(n,"codeExecutionResult")?{type:"non_standard",value:n}:{type:"non_standard",value:n}),o=Br(()=>"thought"in n&&n.thought?{type:"reasoning",reasoning:i.type==="text"?i.text:"",reasoningContentBlock:i}:i),a={thought:n.thought,thoughtSignature:n.thoughtSignature,partMetadata:n.partMetadata,...o};for(let s in a)a[s]===void 0&&delete a[s];yield a}}return Array.from(t())}var XI={translateContent:JI,translateContentChunk:JI};globalThis.lc_block_translators_registry??=new Map([["anthropic",vI],["bedrock-converse",jI],["deepseek",DI],["google",XI],["google-genai",UI],["google-vertexai",FI],["groq",VI],["ollama",ZI],["openai",kI],["openrouter",WI],["xai",KI]]);function x_(e){return globalThis.lc_block_translators_registry.get(e)}function wf(e,t){return it(e,t)??{}}function YI(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 pz(e,t){let r={...YI(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 mz(e,t){let r={...YI(e,t)};return(e?.reasoning!==void 0||t?.reasoning!==void 0)&&(r.reasoning=(e?.reasoning??0)+(t?.reasoning??0)),r}function Ws(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:pz(e?.input_token_details,t?.input_token_details),output_token_details:mz(e?.output_token_details,t?.output_token_details)}}function QI(e){return typeof e=="string"?e.length>0?[{type:"text",text:e}]:[]:Array.isArray(e)?e:e==null?[]:[e]}var je=class extends Re{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,n=t.tool_calls;r!=null&&r.length>0&&(n===void 0||n.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&&n===void 0){let[i,o]=Hu(r);t.tool_calls=i??[],t.invalid_tool_calls=o??[]}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.content!==void 0&&(t.contentBlocks=QI(t.content),t.content=void 0),t.contentBlocks!==void 0){if(Array.isArray(t.contentBlocks)||(t.contentBlocks=QI(t.contentBlocks)),t.tool_calls){let o=t.tool_calls.filter(a=>!t.contentBlocks?.some(s=>s.type==="tool_call"&&s.id===a.id&&s.name===a.name));t.contentBlocks.push(...o.map(a=>({type:"tool_call",id:a.id,name:a.name,args:a.args})))}let i=t.contentBlocks.filter(o=>o.type==="tool_call").filter(o=>!t.tool_calls?.some(a=>a.id===o.id&&a.name===o.name));i.length>0&&(t.tool_calls=[...t.tool_calls??[],...i.map(o=>({type:"tool_call",id:o.id,name:o.name,args:o.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=x_(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(n=>n.id===r.id&&n.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 qs(e){return e._getType()==="ai"}function Gu(e){return e._getType()==="ai"}var ut=class extends Mt{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=xf(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=x_(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:Jt(this.content,e.content),additional_kwargs:it(this.additional_kwargs,e.additional_kwargs),response_metadata:wf(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 n=go(this.tool_call_chunks,e.tool_call_chunks);n!==void 0&&n.length>0&&(t.tool_call_chunks=n)}if(this.tool_calls!==void 0||e.tool_calls!==void 0){let n=go(this.tool_calls,e.tool_calls);n!==void 0&&n.length>0&&(t.tool_calls=n)}(this.usage_metadata!==void 0||e.usage_metadata!==void 0)&&(t.usage_metadata=Ws(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 bn=class e$ extends Re{static lc_name(){return"ChatMessage"}type="generic";role;static _chatMessageClass(){return e$}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}}},ba=class extends Mt{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:Jt(this.content,e.content),additional_kwargs:it(this.additional_kwargs,e.additional_kwargs),response_metadata:it(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 t$(e){return e._getType()==="generic"}function r$(e){return e._getType()==="generic"}var wa=class extends Re{static lc_name(){return"FunctionMessage"}type="function";name;constructor(e){super(e),this.name=e.name}},xa=class extends Mt{static lc_name(){return"FunctionMessageChunk"}type="function";concat(e){let t=this.constructor;return new t({content:Jt(this.content,e.content),additional_kwargs:it(this.additional_kwargs,e.additional_kwargs),response_metadata:it(this.response_metadata,e.response_metadata),name:this.name??"",id:this.id??e.id})}};function n$(e){return e._getType()==="function"}function i$(e){return e._getType()==="function"}var dt=class extends Re{static lc_name(){return"HumanMessage"}type="human";constructor(e){super(e)}static isInstance(e){return super.isInstance(e)&&e.type==="human"}},Sa=class extends Mt{static lc_name(){return"HumanMessageChunk"}type="human";constructor(e){super(e)}concat(e){let t=this.constructor;return new t({content:Jt(this.content,e.content),additional_kwargs:it(this.additional_kwargs,e.additional_kwargs),response_metadata:it(this.response_metadata,e.response_metadata),id:this.id??e.id})}static isInstance(e){return super.isInstance(e)&&e.type==="human"}};function o$(e){return e.getType()==="human"}function a$(e){return e.getType()==="human"}var Vr=class extends Re{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 mr=class Sf extends Re{static lc_name(){return"SystemMessage"}type="system";constructor(t){super(t)}concat(t){if(typeof t=="string")return new Sf({content:Jt(this.content,t),additional_kwargs:this.additional_kwargs,response_metadata:this.response_metadata,id:this.id,name:this.name});if(Sf.isInstance(t))return new Sf({content:Jt(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"}},Ti=class extends Mt{static lc_name(){return"SystemMessageChunk"}type="system";constructor(e){super(e)}concat(e){let t=this.constructor;return new t({content:Jt(this.content,e.content),additional_kwargs:it(this.additional_kwargs,e.additional_kwargs),response_metadata:it(this.response_metadata,e.response_metadata),id:this.id??e.id})}static isInstance(e){return super.isInstance(e)&&e.type==="system"}};function s$(e){return e._getType()==="system"}function c$(e){return e._getType()==="system"}function hz(e){return e.isCustomTool===!0}var u$=e=>e();function gz(e){return _o(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 _z(e){return typeof e=="object"&&e!=null&&e.lc===1&&Array.isArray(e.id)&&e.kwargs!=null&&typeof e.kwargs=="object"}function S_(e){let t,r;if(_z(e)){let n=e.id.at(-1);n==="HumanMessage"||n==="HumanMessageChunk"?t="user":n==="AIMessage"||n==="AIMessageChunk"?t="assistant":n==="SystemMessage"||n==="SystemMessageChunk"?t="system":n==="FunctionMessage"||n==="FunctionMessageChunk"?t="function":n==="ToolMessage"||n==="ToolMessageChunk"?t="tool":t="unknown",r=e.kwargs}else{let{type:n,...i}=e;t=n,r=i}if(t==="human"||t==="user")return new dt(r);if(t==="ai"||t==="assistant"){let{tool_calls:n,...i}=r;if(!Array.isArray(n))return new je(r);let o=n.map(gz);return new je({...i,tool_calls:o})}else{if(t==="system")return new mr(r);if(t==="developer")return new mr({...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 Vr({...r,id:r.id});throw Ii(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 Tt(e){if(typeof e=="string")return new dt(e);if(ot(e))return e;if(Array.isArray(e)){let[t,r]=e;return S_({type:t,content:r})}else if(bf(e)){let{role:t,...r}=e;return S_({...r,type:t})}else return S_(e)}function yz(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 Ks(e,t="Human",r="AI"){let n=[];for(let i of e){let o;if(i.type==="human")o=t;else if(i.type==="ai")o=r;else if(i.type==="system")o="System";else if(i.type==="tool")o="Tool";else if(i.type==="generic")o=i.role;else throw new Error(`Got unsupported message type: ${i.type}`);let a=i.name?`${i.name}, `:"",s=typeof i.content=="string"?i.content:Array.isArray(i.content)?i.content.map(yz).filter(Boolean).join(""):"",c=`${o}: ${a}${s}`;if(i.type==="ai"){let u=i;u.tool_calls&&u.tool_calls.length>0?c+=JSON.stringify(u.tool_calls):u.additional_kwargs&&"function_call"in u.additional_kwargs&&(c+=JSON.stringify(u.additional_kwargs.function_call))}n.push(c)}return n.join(`
21
- `)}function vz(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 Wu(e){let t=vz(e);switch(t.type){case"human":return new dt(t.data);case"ai":return new je(t.data);case"system":return new mr(t.data);case"function":if(t.data.name===void 0)throw new Error("Name must be defined for function messages");return new wa(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 bn(t.data);default:throw new Error(`Got unexpected type: ${t.type}`)}}function l$(e){return e.map(Wu)}function d$(e){return e.map(t=>t.toDict())}function ka(e){let t=e._getType();if(t==="human")return new Sa({...e});if(t==="ai"){let r={...e};return"tool_calls"in r&&(r={...r,tool_call_chunks:r.tool_calls?.map(n=>({...n,type:"tool_call_chunk",index:void 0,args:JSON.stringify(n.args)}))}),new ut({...r})}else{if(t==="system")return new Ti({...e});if(t==="function")return new xa({...e});if(bn.isInstance(e))return new ba({...e});throw new Error("Unknown message type.")}}function xf(e){let t=e.reduce((i,o)=>{let a=i.findIndex(([s])=>"id"in o&&o.id&&"index"in o&&o.index!==void 0?o.id===s.id&&o.index===s.index:"id"in o&&o.id?o.id===s.id:"index"in o&&o.index!==void 0?o.index===s.index:!1);return a!==-1?i[a].push(o):i.push([o]),i},[]),r=[],n=[];for(let i of t){let o=null,a=i.some(hz),s=i[0]?.name??"",c=i.map(f=>f.args||"").join(""),u=a?c:c.trim(),l=u.length?u:"{}",d=i.find(f=>f.id)?.id??i[0]?.id;if(a&&d){r.push({name:s,args:{input:u},id:d,type:"tool_call"});continue}try{if(o=qn(l),!d||o===null||typeof o!="object"||Array.isArray(o))throw new Error("Malformed tool call chunk args.");r.push({name:s,args:o,id:d,type:"tool_call"})}catch{n.push({name:s,args:l,id:d,error:"Malformed args.",type:"invalid_tool_call"})}}return{tool_call_chunks:e,tool_calls:r,invalid_tool_calls:n}}var f$=A({BaseCache:()=>m$,InMemoryCache:()=>k_,defaultHashKeyEncoder:()=>p$,deserializeStoredGeneration:()=>bz,serializeGeneration:()=>wz}),p$=(...e)=>Bs(e.join("_"));function bz(e){return e.message!==void 0?{text:e.text,message:Wu(e.message)}:{text:e.text}}function wz(e){let t={text:e.text};return e.message!==void 0&&(t.message=e.message.toDict()),t}var m$=class{keyEncoder=p$;makeDefaultKeyEncoder(e){this.keyEncoder=e}},xz=new Map,k_=class h$ extends m${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,n){this.cache.set(this.keyEncoder(t,r),n)}static global(){return new h$(xz)}};var g$=A({BaseCallbackHandler:()=>hr,callbackHandlerPrefersChatModelStreamEvents:()=>E_,callbackHandlerPrefersStreaming:()=>qu,isBaseCallbackHandler:()=>I_}),Sz=class{};function qu(e){return"lc_prefer_streaming"in e&&e.lc_prefer_streaming}function E_(e){return"lc_prefer_chat_model_stream_events"in e&&e.lc_prefer_chat_model_stream_events}var hr=class extends Sz{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,Fs(this.constructor)]}lc_kwargs;ignoreLLM=!1;ignoreChain=!1;ignoreAgent=!1;ignoreRetriever=!1;ignoreCustomEvent=!1;raiseError=!1;awaitHandlers=pr("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 yt.prototype.toJSON.call(this)}toJSONNotImplemented(){return yt.prototype.toJSONNotImplemented.call(this)}static fromMethods(e){class t extends hr{name=tn();constructor(){super(),Object.assign(this,e)}}return new t}},I_=e=>{let t=e;return t!==void 0&&typeof t.copy=="function"&&typeof t.name=="string"&&typeof t.awaitHandlers=="boolean"};var _$=/^(?:[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 kz(e){return typeof e=="string"&&_$.test(e)}var Ku=kz;function Ez(e){if(!Ku(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 kf=Ez;var Bt=[];for(let e=0;e<256;++e)Bt.push((e+256).toString(16).slice(1));function Js(e,t=0){return(Bt[e[t+0]]+Bt[e[t+1]]+Bt[e[t+2]]+Bt[e[t+3]]+"-"+Bt[e[t+4]]+Bt[e[t+5]]+"-"+Bt[e[t+6]]+Bt[e[t+7]]+"-"+Bt[e[t+8]]+Bt[e[t+9]]+"-"+Bt[e[t+10]]+Bt[e[t+11]]+Bt[e[t+12]]+Bt[e[t+13]]+Bt[e[t+14]]+Bt[e[t+15]]).toLowerCase()}var Iz=new Uint8Array(16);function Xs(){return crypto.getRandomValues(Iz)}function $z(e,t,r){return!t&&!e&&crypto.randomUUID?crypto.randomUUID():Tz(e,t,r)}function Tz(e,t,r){e=e||{};let n=e.random??e.rng?.()??Xs();if(n.length<16)throw new Error("Random bytes length must be >= 16");if(n[6]=n[6]&15|64,n[8]=n[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 i=0;i<16;++i)t[r+i]=n[i];return t}return Js(n)}var Ea=$z;function Az(e,t,r,n){switch(e){case 0:return t&r^~t&n;case 1:return t^r^n;case 2:return t&r^t&n^r&n;case 3:return t^r^n}}function $_(e,t){return e<<t|e>>>32-t}function Cz(e){let t=[1518500249,1859775393,2400959708,3395469782],r=[1732584193,4023233417,2562383102,271733878,3285377520],n=new Uint8Array(e.length+1);n.set(e),n[e.length]=128,e=n;let i=e.length/4+2,o=Math.ceil(i/16),a=new Array(o);for(let s=0;s<o;++s){let c=new Uint32Array(16);for(let u=0;u<16;++u)c[u]=e[s*64+u*4]<<24|e[s*64+u*4+1]<<16|e[s*64+u*4+2]<<8|e[s*64+u*4+3];a[s]=c}a[o-1][14]=(e.length-1)*8/2**32,a[o-1][14]=Math.floor(a[o-1][14]),a[o-1][15]=(e.length-1)*8&4294967295;for(let s=0;s<o;++s){let c=new Uint32Array(80);for(let m=0;m<16;++m)c[m]=a[s][m];for(let m=16;m<80;++m)c[m]=$_(c[m-3]^c[m-8]^c[m-14]^c[m-16],1);let u=r[0],l=r[1],d=r[2],f=r[3],p=r[4];for(let m=0;m<80;++m){let h=Math.floor(m/20),_=$_(u,5)+Az(h,l,d,f)+p+t[h]+c[m]>>>0;p=f,f=d,d=$_(l,30)>>>0,l=u,u=_}r[0]=r[0]+u>>>0,r[1]=r[1]+l>>>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 y$=Cz;function Oz(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 T_="6ba7b810-9dad-11d1-80b4-00c04fd430c8",A_="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function C_(e,t,r,n,i,o){let a=typeof r=="string"?Oz(r):r,s=typeof n=="string"?kf(n):n;if(typeof n=="string"&&(n=kf(n)),n?.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let c=new Uint8Array(16+a.length);if(c.set(s),c.set(a,s.length),c=t(c),c[6]=c[6]&15|e,c[8]=c[8]&63|128,i){if(o??=0,o<0||o+16>i.length)throw new RangeError(`UUID byte range ${o}:${o+15} is out of buffer bounds`);for(let u=0;u<16;++u)i[o+u]=c[u];return i}return Js(c)}function O_(e,t,r,n){return C_(80,y$,e,t,r,n)}O_.DNS=T_;O_.URL=A_;var P_=O_;var N_={};function Pz(e,t,r){let n;if(e)n=v$(e.random??e.rng?.()??Xs(),e.msecs,e.seq,t,r);else{let i=Date.now(),o=Xs();Nz(N_,i,o),n=v$(o,N_.msecs,N_.seq,t,r)}return t??Js(n)}function Nz(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 v$(e,t,r,n,i=0){if(e.length<16)throw new Error("Random bytes length must be >= 16");if(!n)n=new Uint8Array(16),i=0;else if(i<0||i+16>n.length)throw new RangeError(`UUID byte range ${i}:${i+15} is out of buffer bounds`);return t??=Date.now(),r??=e[6]*127<<24|e[7]<<16|e[8]<<8|e[9],n[i++]=t/1099511627776&255,n[i++]=t/4294967296&255,n[i++]=t/16777216&255,n[i++]=t/65536&255,n[i++]=t/256&255,n[i++]=t&255,n[i++]=112|r>>>28&15,n[i++]=r>>>20&255,n[i++]=128|r>>>14&63,n[i++]=r>>>6&255,n[i++]=r<<2&255|e[10]&3,n[i++]=e[11],n[i++]=e[12],n[i++]=e[13],n[i++]=e[14],n[i++]=e[15],n}var Ys=Pz;var b$="gen_ai.operation.name",w$="gen_ai.system",R_="gen_ai.request.model",x$="gen_ai.response.model",j_="gen_ai.usage.input_tokens",M_="gen_ai.usage.output_tokens",D_="gen_ai.usage.total_tokens",S$="gen_ai.request.max_tokens",k$="gen_ai.request.temperature",E$="gen_ai.request.top_p",I$="gen_ai.request.frequency_penalty",$$="gen_ai.request.presence_penalty",T$="gen_ai.response.finish_reasons",A$="gen_ai.prompt",C$="gen_ai.completion",O$="gen_ai.request.extra_query",P$="gen_ai.request.extra_body",N$="gen_ai.serialized.name",R$="gen_ai.serialized.signature",j$="gen_ai.serialized.doc",M$="gen_ai.response.id",D$="gen_ai.response.service_tier",z$="gen_ai.response.system_fingerprint",U$="gen_ai.usage.input_token_details",L$="gen_ai.usage.output_token_details",F$="langsmith.trace.session_id",B$="langsmith.trace.session_name",V$="langsmith.span.kind",H$="langsmith.trace.name",Z$="langsmith.metadata",z_="langsmith.span.tags";var G$="langsmith.request.streaming",W$="langsmith.request.headers";var U_="langsmith.usage_metadata";var Mz=(...e)=>fetch(...e),Dz,q$=Symbol.for("ls:fetch_implementation");var K$=()=>globalThis[q$]===void 0?!0:Dz??!1,J$=e=>async(...t)=>{if(e||qe("DEBUG")==="true"){let[n,i]=t;console.log(`\u2192 ${i?.method||"GET"} ${n}`)}let r=await(globalThis[q$]??Mz)(...t);return(e||qe("DEBUG")==="true")&&console.log(`\u2190 ${r.status} ${r.statusText} ${r.url}`),r};var Ju=()=>qe("PROJECT")??Dt("LANGCHAIN_SESSION")??"default";var X$={};function zt(e,t){let r=t?.code??e;X$[r]||(X$[r]=!0,t?.type&&typeof process<"u"&&typeof process.emitWarning=="function"?process.emitWarning(e,{type:t.type,code:t.code}):t?.type&&t?.code?console.warn(`${t.type} [${t.code}]: ${e}`):console.warn(e))}var R=e=>BigInt(e),tT=R("0x9E3779B1"),rT=R("0x85EBCA77"),zz=R("0xC2B2AE3D"),yo=R("0x9E3779B185EBCA87"),Ia=R("0xC2B2AE3D27D4EB4F"),nT=R("0x165667B19E3779F9"),V_=R("0x85EBCA77C2B2AE63"),Uz=R("0x27D4EB2F165667C5"),Lz=R("0x165667919E3779F9"),Fz=R("0x9FB21C651E98DF25");function Bz(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 Kn=Bz("b8fe6c3923a44bbe7c01812cf721ad1cded46de9839097db7240a4a4b7b3671fcb79e64eccc0e578825ad07dccff7221b8084674f743248ee03590e6813a264c3c2852bb91c300cb88d0658b1b532ea371644897a20df94e3819ef46a9deacd8a8fa763fe39c343ff9dcbbc7c70b4f1d8a51e04bcdb45931c89f7ec9d9787364eac5ac8334d3ebc3c581a0fffa1363eb170ddd51b7f0da49d316552629d4689e2b16be587d47a1fc8ff8b8d17ad031ce45cb3a8f95160428afd7fbcabb4b407e"),ec=(R(1)<<R(128))-R(1),xe=(R(1)<<R(64))-R(1),Tf=(R(1)<<R(32))-R(1),Ai=64,iT=Ai/8,Vz=8,Ef=4;function Ke(e,t=0){return new Uint8Array(e.buffer,e.byteOffset+t,e.length-t)}function Qe(e,t=0){return new DataView(e.buffer,e.byteOffset+t).getBigUint64(0,!0)}function Qs(e,t=0){return new DataView(e.buffer,e.byteOffset+t).getUint32(0,!0)}function L_(e,t=0){return e[t]}var Hz=e=>(e&R(255))<<R(56)|(e&R(65280))<<R(40)|(e&R(16711680))<<R(24)|(e&R(4278190080))<<R(8)|(e&R(0xff00000000))>>R(8)|(e&R(0xff0000000000))>>R(24)|(e&R(0xff000000000000))>>R(40)|(e&R(0xff00000000000000))>>R(56),Zz=e=>(e=(e&R(65535))<<R(16)|(e&R(4294901760))>>R(16),e=(e&R(16711935))<<R(8)|(e&R(4278255360))>>R(8),e),Gz=(e,t)=>(e&Tf)*(t&Tf)&xe,tc=e=>{if(!e)throw new Error("Assert failed")};function Wz(e,t){return(e<<t|e>>R(32)-t)&Tf}function oT(e,t,r){for(let n=0;n<iT;n++){let i=Qe(t,n*8),o=i^Qe(r,n*8);e[n^1]+=i,e[n]+=Gz(o,o>>R(32))}return e}function Y$(e,t,r,n){for(let i=0;i<n;i++)oT(e,Ke(t,i*Ai),Ke(r,i*8));return e}function qz(e,t){for(let r=0;r<iT;r++){let n=Qe(t,r*8),i=e[r];i=F_(i,R(47)),i^=n,i*=tT,e[r]=i&xe}return e}function If(e,t){return aT(e[0]^Qe(t,0),e[1]^Qe(t,Vz))}function Q$(e,t,r){let n=r;return n+=If(e.slice(0),Ke(t,0*Ef)),n+=If(e.slice(2),Ke(t,4*Ef)),n+=If(e.slice(4),Ke(t,8*Ef)),n+=If(e.slice(6),Ke(t,12*Ef)),Jn(n&xe)}function Kz(e,t,r,n,i){let o=Math.floor((r.byteLength-Ai)/8),a=Ai*o,s=Math.floor((t.byteLength-1)/a);for(let c=0;c<s;c++)e=Y$(e,Ke(t,c*a),r,o),e=i(e,Ke(r,r.byteLength-Ai));{let c=Math.floor((t.byteLength-1-a*s)/Ai);e=Y$(e,Ke(t,s*a),r,c),e=n(e,Ke(t,t.byteLength-Ai),Ke(r,r.byteLength-Ai-7))}return e}function Jz(e,t,r){let n=new BigUint64Array([zz,yo,Ia,nT,V_,rT,Uz,tT]);tc(e.length>128),n=Kz(n,e,t,oT,qz),tc(n.length*8==64);{let i=Q$(n,Ke(t,11),R(e.byteLength)*yo&xe);return Q$(n,Ke(t,t.byteLength-Ai-11),~(R(e.byteLength)*Ia)&xe)<<R(64)|i}}function aT(e,t){let r=e*t&ec;return r&xe^r>>R(64)}function eT(e,t,r){return aT((Qe(e,0)^Qe(t,0)+r)&xe,(Qe(e,8)^Qe(t,8)-r)&xe)}function $f(e,t,r,n,i){let o=e&xe,a=e>>R(64)&xe;return o+=eT(t,n,i),o^=Qe(r,0)+Qe(r,8),o&=xe,a+=eT(r,Ke(n,16),i),a^=Qe(t,0)+Qe(t,8),a&=xe,a<<R(64)|o}function Jn(e){return e^=e>>R(37),e*=Lz,e&=xe,e^=e>>R(32),e}function Af(e){return e^=e>>R(33),e*=Ia,e&=xe,e^=e>>R(29),e*=nT,e&=xe,e^=e>>R(32),e}function Xz(e,t,r){let n=e.byteLength;tc(n>0&&n<=3);let i=R(L_(e,n-1))|R(n<<8)|R(L_(e,0)<<16)|R(L_(e,n>>1)<<24),o=(R(Qs(t,0))^R(Qs(t,4)))+r,a=(i^o)&xe,s=(R(Qs(t,8))^R(Qs(t,12)))-r,c=(Wz(Zz(i),R(13))^s)&xe;return(Af(c)&xe)<<R(64)|Af(a)}function F_(e,t){return e^e>>t}function Yz(e,t,r){let n=e.byteLength;tc(n>=4&&n<=8);{let i=Qs(e,0),o=Qs(e,n-4),a=R(i)|R(o)<<R(32),s=(Qe(t,16)^Qe(t,24))+r&xe,u=(a^s)*(yo+(R(n)<<R(2)))&ec;return u+=(u&xe)<<R(65),u&=ec,u^=u>>R(67),F_(F_(u&xe,R(35))*Fz&xe,R(28))|Jn(u>>R(64))<<R(64)}}function Qz(e,t,r){let n=e.byteLength;tc(n>=9&&n<=16);{let i=(Qe(t,32)^Qe(t,40))+r&xe,o=(Qe(t,48)^Qe(t,56))-r&xe,a=Qe(e),s=Qe(e,n-8),c=(a^s^i)*yo,u=(c&xe)+(R(n-1)<<R(54));c=c&(ec^xe)|u,s^=o,c+=s+(s&Tf)*(rT-R(1))<<R(64),c&=ec,c^=Hz(c>>R(64));let l=(c&xe)*Ia;return l+=(c>>R(64))*Ia<<R(64),l&=ec,Jn(l&xe)|Jn(l>>R(64))<<R(64)}}function eU(e,t){let r=e.byteLength;return tc(r<=16),r>8?Qz(e,Kn,t):r>=4?Yz(e,Kn,t):r>0?Xz(e,Kn,t):Af(t^Qe(Kn,64)^Qe(Kn,72))|Af(t^Qe(Kn,80)^Qe(Kn,88))<<R(64)}function B_(e){return~e+R(1)&xe}function tU(e,t,r){let n=R(e.byteLength)*yo&xe,i=R(e.byteLength-1)/R(32);for(;i>=0;){let s=Number(i);n=$f(n,Ke(e,16*s),Ke(e,e.byteLength-16*(s+1)),Ke(t,32*s),r),i--}let o=n+(n>>R(64))&xe;o=Jn(o);let a=(n&xe)*yo+(n>>R(64))*V_+(R(e.byteLength)-r&xe)*Ia;return a&=xe,a=B_(Jn(a)),o|a<<R(64)}function rU(e,t,r){let n=R(e.byteLength)*yo&xe;for(let a=32;a<160;a+=32)n=$f(n,Ke(e,a-32),Ke(e,a-16),Ke(t,a-32),r);n=Jn(n&xe)|Jn(n>>R(64))<<R(64);for(let a=160;a<=e.byteLength;a+=32)n=$f(n,Ke(e,a-32),Ke(e,a-16),Ke(t,3+a-160),r);n=$f(n,Ke(e,e.byteLength-16),Ke(e,e.byteLength-32),Ke(t,103),B_(r));let i=n+(n>>R(64))&xe;i=Jn(i);let o=(n&xe)*yo+(n>>R(64))*V_+(R(e.byteLength)-r&xe)*Ia;return o&=xe,o=B_(Jn(o)),i|o<<R(64)}function sT(e,t=R(0)){let r=e.byteLength;return r<=16?eU(e,t):r<=128?tU(e,Kn,t):r<=240?rU(e,Kn,t):Jz(e,Kn,t)}function cT(e){let t=new Uint8Array(16),r=new DataView(t.buffer),n=e&xe,i=e>>R(64);return r.setBigUint64(0,i,!1),r.setBigUint64(8,n,!1),t}var uT=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function de(e,t){if(!uT.test(e)){let r=t!==void 0?`Invalid UUID for ${t}: ${e}`:`Invalid UUID: ${e}`;throw new Error(r)}return e}function Cf(e){let t=typeof e=="string"?Date.parse(e):e;return Ys({msecs:t,seq:0})}function lT(e){if(!uT.test(e))return null;let t=e[14];return parseInt(t,16)}function nU(e){let t=e.replace(/-/g,""),r=new Uint8Array(16);for(let n=0;n<16;n++)r[n]=parseInt(t.slice(n*2,n*2+2),16);return r}function iU(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 oU=new TextEncoder;function aU(e){let t=oU.encode(e),r=sT(t);return cT(r)}function rc(e,t){let r=`${e}:${t}`,n=aU(r),i=new Uint8Array(16);if(lT(e)===7){let a=nU(e);i.set(a.slice(0,6),0)}else{let a=Date.now();i[0]=a/1099511627776&255,i[1]=a/4294967296&255,i[2]=a/16777216&255,i[3]=a/65536&255,i[4]=a/256&255,i[5]=a&255}return i[6]=112|n[0]&15,i[7]=n[1],i[8]=128|n[2]&63,i.set(n.slice(3,10),9),iU(i)}var H_=e=>e!==void 0?e:!!["TRACING_V2","TRACING"].find(r=>qe(r)==="true");var G_=class{getStore(){}run(t,r){return r()}},Z_=Symbol.for("ls:tracing_async_local_storage"),sU=new G_,W_=class{getInstance(){return globalThis[Z_]??sU}initializeGlobalInstance(t){globalThis[Z_]===void 0&&(globalThis[Z_]=t)}},cU=new W_;function q_(e=!1){let t=cU.getInstance().getStore();if(!e&&t===void 0)throw new Error(`Could not get the current run tree.
22
-
23
- Please make sure you are calling this method within a traceable function and that tracing is enabled.`);return t}function Of(e){return typeof e=="function"&&"langsmith:traceable"in e}var wn={join:(...e)=>e.join("/"),dirname:e=>e.split("/").slice(0,-1).join("/")};async function Pf(e){}async function nc(e,t){}async function dT(e){return[]}async function fT(e){return{size:0}}function ic(e){return!1}function $a(e){return""}async function pT(e){}async function Nf(e){}function uU(e,t){return t===null?!1:Date.now()-e.createdAt>t*1e3}var Rf=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 n=this.cache.get(t);if(!n){this._metrics.misses+=1;return}return this.cache.delete(t),this.cache.set(t,{...n,refreshFunc:r}),this._metrics.hits+=1,n.value}set(t,r,n){if(this.maxSize===0)return;if(this.refreshTimer===void 0&&this.startRefreshLoop(),!this.cache.has(t)&&this.cache.size>=this.maxSize){let o=this.cache.keys().next().value;o!==void 0&&this.cache.delete(o)}let i={value:r,createdAt:Date.now(),refreshFunc:n};this.cache.delete(t),this.cache.set(t,i)}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[o,a]of this.cache.entries())r[o]=a.value;let n=wn.dirname(t);ic(n)||void 0;let i=`${t}.tmp`;try{JSON.stringify({entries:r},null,2)}catch(o){throw ic(i)&&void 0,o}}load(t){if(!ic(t))return 0;let r;try{let o=$a(t);r=JSON.parse(o).entries??null}catch{return 0}if(!r)return 0;let n=0,i=Date.now();for(let[o,a]of Object.entries(r)){if(this.cache.size>=this.maxSize)break;let s={value:a,createdAt:i};this.cache.set(o,s),n+=1}return n}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,n]of this.cache.entries())uU(n,this.ttlSeconds)&&t.push([r,n]);return t}async refreshStaleEntries(){let t=this.getStaleEntries();if(t.length!==0){for(let[r,n]of t)if(n.refreshFunc!==void 0)try{let i=await n.refreshFunc();this.set(r,i,n.refreshFunc),this._metrics.refreshes+=1}catch(i){this._metrics.refreshErrors+=1,console.warn(`Failed to refresh cache entry ${r}:`,i)}}}configure(t){this.stop(),this.refreshIntervalSeconds=t.refreshIntervalSeconds??60,this.maxSize=t.maxSize??100,this.ttlSeconds=t.ttlSeconds??300}},jf=new Rf;function mT(e){return typeof e=="object"&&e!==null&&("name"in e&&e.name==="AbortError"||"message"in e&&String(e.message).includes("FetchRequestCanceledException"))}var Xu=e=>{if(e instanceof Error)return e;if(typeof e=="object"&&e!==null){try{if(Object.prototype.toString.call(e)==="[object Error]"){let t=new Error(e.message,e.cause?{cause:e.cause}:{});return e.stack&&(t.stack=e.stack),e.cause&&!t.cause&&(t.cause=e.cause),e.name&&(t.name=e.name),t}}catch{}try{return new Error(JSON.stringify(e))}catch{}}return new Error(e)};var $r=class extends Error{},Vt=class e extends $r{constructor(t,r,n,i){super(`${e.makeMessage(t,r,n)}`),Object.defineProperty(this,"status",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"headers",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"error",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.status=t,this.headers=i,this.error=r}static makeMessage(t,r,n){let i=r?.message?typeof r.message=="string"?r.message:JSON.stringify(r.message):r?JSON.stringify(r):n;return t&&i?`${t} ${i}`:t?`${t} status code (no body)`:i||"(no status code or body)"}static generate(t,r,n,i){if(!t||!i)return new Ci({message:n,cause:Xu(r)});let o=r;return t===400?new Aa(t,o,n,i):t===401?new Ca(t,o,n,i):t===403?new Oa(t,o,n,i):t===404?new Pa(t,o,n,i):t===409?new Na(t,o,n,i):t===422?new Ra(t,o,n,i):t===429?new ja(t,o,n,i):t>=500?new Ma(t,o,n,i):new e(t,o,n,i)}},vo=class extends Vt{constructor({message:t}={}){super(void 0,void 0,t||"Request was aborted.",void 0)}},Ci=class extends Vt{constructor({message:t,cause:r}){super(void 0,void 0,t||"Connection error.",void 0),r&&(this.cause=r)}},Ta=class extends Ci{constructor({message:t}={}){super({message:t??"Request timed out."})}},Aa=class extends Vt{},Ca=class extends Vt{},Oa=class extends Vt{},Pa=class extends Vt{},Na=class extends Vt{},Ra=class extends Vt{},ja=class extends Vt{},Ma=class extends Vt{};var Mf="0.8.9";var Yn,dU=()=>typeof window<"u"&&typeof window.document<"u",fU=()=>typeof globalThis=="object"&&globalThis.constructor&&globalThis.constructor.name==="DedicatedWorkerGlobalScope",pU=()=>typeof window<"u"&&window.name==="nodejs"||typeof navigator<"u"&&navigator.userAgent.includes("jsdom"),_T=()=>typeof globalThis.Deno<"u",mU=()=>typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"&&!_T(),Yu=()=>Yn||(typeof Bun<"u"?Yn="bun":dU()?Yn="browser":mU()?Yn="node":fU()?Yn="webworker":pU()?Yn="jsdom":_T()?Yn="deno":Yn="other",Yn),J_;function Df(){if(J_===void 0){let e=Yu(),t=gU();J_={library:"langsmith",runtime:e,sdk:"langsmith-js",sdk_version:Mf,...t}}return J_}function Y_(){let e=hU(),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[n,i]of Object.entries(e))typeof i=="string"&&!r.includes(n)&&!n.toLowerCase().includes("key")&&!n.toLowerCase().includes("secret")&&!n.toLowerCase().includes("token")&&(n==="LANGCHAIN_REVISION_ID"?t.revision_id=i:t[n]=i);return t}function hU(){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 Dt(e){try{return typeof process<"u"?process.env?.[e]:void 0}catch{return}}function qe(e){return Dt(`LANGSMITH_${e}`)||Dt(`LANGCHAIN_${e}`)}var X_;function gU(){if(X_!==void 0)return X_;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 n=Dt(r);n!==void 0&&(t[r]=n)}return X_=t,t}function hT(){return Dt("OTEL_ENABLED")==="true"||qe("OTEL_ENABLED")==="true"}var gT=new Set(["langsmith","otel"]);function zf(e){if(e!==void 0)return e;let t=qe("TRACING_MODE");if(t!==void 0&&t!==""){let r=t.toLowerCase();if(!gT.has(r))throw new Error(`Invalid LANGSMITH_TRACING_MODE=${JSON.stringify(t)}. Must be one of: ${[...gT].sort().join(", ")}`);return hT()&&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 hT()?"otel":"langsmith"}var ty=class{constructor(){Object.defineProperty(this,"hasWarned",{enumerable:!0,configurable:!0,writable:!0,value:!1})}startActiveSpan(t,...r){!this.hasWarned&&zf()==="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 n;if(r.length===1&&typeof r[0]=="function"?n=r[0]:r.length===2&&typeof r[1]=="function"?n=r[1]:r.length===3&&typeof r[2]=="function"&&(n=r[2]),typeof n=="function")return n()}},ry=class{constructor(){Object.defineProperty(this,"mockTracer",{enumerable:!0,configurable:!0,writable:!0,value:new ty})}getTracer(t,r){return this.mockTracer}getActiveSpan(){}setSpan(t,r){return t}getSpan(t){}setSpanContext(t,r){return t}getTracerProvider(){}setGlobalTracerProvider(t){return!1}},ny=class{active(){return{}}with(t,r){return r()}},Q_=Symbol.for("ls:otel_trace"),ey=Symbol.for("ls:otel_context"),yT=Symbol.for("ls:otel_get_default_otlp_tracer_provider"),_U=new ry,yU=new ny,iy=class{getTraceInstance(){return globalThis[Q_]??_U}getContextInstance(){return globalThis[ey]??yU}initializeGlobalInstances(t){globalThis[Q_]===void 0&&(globalThis[Q_]=t.trace),globalThis[ey]===void 0&&(globalThis[ey]=t.context)}setDefaultOTLPTracerComponents(t){globalThis[yT]=t}getDefaultOTLPTracerComponents(){return globalThis[yT]??void 0}},oy=new iy;function Uf(){return oy.getTraceInstance()}function vT(){return oy.getContextInstance()}function bT(){return oy.getDefaultOTLPTracerComponents()}var vU={llm:"chat",tool:"execute_tool",retriever:"embeddings",embedding:"embeddings",prompt:"chat"};function bU(e){return vU[e]||e}function wU(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"}var Lf=class{constructor(){Object.defineProperty(this,"spans",{enumerable:!0,configurable:!0,writable:!0,value:new Map})}exportBatch(t,r){for(let n of t)try{if(!n.run)continue;if(n.operation==="post"){let i=this.createSpanForRun(n,n.run,r.get(n.id));i&&!n.run.end_time&&this.spans.set(n.id,i)}else this.updateSpanForRun(n,n.run)}catch(i){console.error(`Error processing operation ${n.id}:`,i)}}createSpanForRun(t,r,n){let i=n&&Uf().getSpan(n);if(i)try{return this.finishSpanSetup(i,r,t)}catch(o){console.error(`Failed to create span for run ${t.id}:`,o);return}}finishSpanSetup(t,r,n){return this.setSpanAttributes(t,r,n),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 n=this.spans.get(t.id);if(!n){console.debug(`No span found for run ${t.id} during update`);return}this.setSpanAttributes(n,r,t),r.error?(n.setStatus({code:2}),n.recordException(new Error(r.error))):n.setStatus({code:1});let i=r.end_time;i&&(n.end(new Date(i)),this.spans.delete(t.id))}catch(n){console.error(`Failed to update span for run ${t.id}:`,n)}}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 n=r.invocation_params;if(n.model)return n.model;if(n.model_name)return n.model_name}}}setSpanAttributes(t,r,n){if("run_type"in r&&r.run_type){t.setAttribute(V$,r.run_type);let s=bU(r.run_type||"chain");t.setAttribute(b$,s)}"name"in r&&r.name&&t.setAttribute(H$,r.name),"session_id"in r&&r.session_id&&t.setAttribute(F$,r.session_id),"session_name"in r&&r.session_name&&t.setAttribute(B$,r.session_name),this.setGenAiSystem(t,r);let i=this.extractModelName(r);i&&t.setAttribute(R_,i),r.extra?.metadata?.usage_metadata&&typeof r.extra.metadata.usage_metadata=="object"&&t.setAttribute(U_,JSON.stringify(r.extra.metadata.usage_metadata)),"prompt_tokens"in r&&typeof r.prompt_tokens=="number"&&t.setAttribute(j_,r.prompt_tokens),"completion_tokens"in r&&typeof r.completion_tokens=="number"&&t.setAttribute(M_,r.completion_tokens),"total_tokens"in r&&typeof r.total_tokens=="number"&&t.setAttribute(D_,r.total_tokens),this.setInvocationParameters(t,r);let o=r.extra?.metadata||{};for(let[s,c]of Object.entries(o))c!=null&&t.setAttribute(`${Z$}.${s}`,wU(c)?String(c):JSON.stringify(c));let a=r.tags;if(a&&Array.isArray(a)?t.setAttribute(z_,a.join(", ")):a&&t.setAttribute(z_,String(a)),"serialized"in r&&typeof r.serialized=="object"){let s=r.serialized;s.name&&t.setAttribute(N$,String(s.name)),s.signature&&t.setAttribute(R$,String(s.signature)),s.doc&&t.setAttribute(j$,String(s.doc))}this.setIOAttributes(t,n)}setGenAiSystem(t,r){let n="langchain",i=this.extractModelName(r);if(i){let o=i.toLowerCase();o.includes("anthropic")||o.startsWith("claude")?n="anthropic":o.includes("bedrock")?n="aws.bedrock":o.includes("azure")&&o.includes("openai")?n="az.ai.openai":o.includes("azure")&&o.includes("inference")?n="az.ai.inference":o.includes("cohere")?n="cohere":o.includes("deepseek")?n="deepseek":o.includes("gemini")?n="gemini":o.includes("groq")?n="groq":o.includes("watson")||o.includes("ibm")?n="ibm.watsonx.ai":o.includes("mistral")?n="mistral_ai":o.includes("gpt")||o.includes("openai")?n="openai":o.includes("perplexity")||o.includes("sonar")?n="perplexity":o.includes("vertex")?n="vertex_ai":(o.includes("xai")||o.includes("grok"))&&(n="xai")}t.setAttribute(w$,n)}setInvocationParameters(t,r){if(!r.extra?.metadata?.invocation_params)return;let n=r.extra.metadata.invocation_params;n.max_tokens!==void 0&&t.setAttribute(S$,n.max_tokens),n.temperature!==void 0&&t.setAttribute(k$,n.temperature),n.top_p!==void 0&&t.setAttribute(E$,n.top_p),n.frequency_penalty!==void 0&&t.setAttribute(I$,n.frequency_penalty),n.presence_penalty!==void 0&&t.setAttribute($$,n.presence_penalty)}setIOAttributes(t,r){if(r.run.inputs)try{let n=r.run.inputs;typeof n=="object"&&n!==null&&(n.model&&Array.isArray(n.messages)&&t.setAttribute(R_,n.model),n.stream!==void 0&&t.setAttribute(G$,n.stream),n.extra_headers&&t.setAttribute(W$,JSON.stringify(n.extra_headers)),n.extra_query&&t.setAttribute(O$,JSON.stringify(n.extra_query)),n.extra_body&&t.setAttribute(P$,JSON.stringify(n.extra_body))),t.setAttribute(A$,JSON.stringify(n))}catch(n){console.debug(`Failed to process inputs for run ${r.id}`,n)}if(r.run.outputs)try{let n=r.run.outputs,i=this.getUnifiedRunTokens(n);if(i&&(t.setAttribute(j_,i[0]),t.setAttribute(M_,i[1]),t.setAttribute(D_,i[0]+i[1])),n&&typeof n=="object"){if(n.model&&t.setAttribute(x$,String(n.model)),n.id&&t.setAttribute(M$,n.id),n.choices&&Array.isArray(n.choices)){let o=n.choices.map(a=>a.finish_reason).filter(a=>a).map(String);o.length>0&&t.setAttribute(T$,o.join(", "))}if(n.service_tier&&t.setAttribute(D$,n.service_tier),n.system_fingerprint&&t.setAttribute(z$,n.system_fingerprint),n.usage_metadata&&typeof n.usage_metadata=="object"){let o=n.usage_metadata;t.setAttribute(U_,JSON.stringify(o)),o.input_token_details&&t.setAttribute(U$,JSON.stringify(o.input_token_details)),o.output_token_details&&t.setAttribute(L$,JSON.stringify(o.output_token_details))}}t.setAttribute(C$,JSON.stringify(n))}catch(n){console.debug(`Failed to process outputs for run ${r.id}`,n)}}getUnifiedRunTokens(t){if(!t)return null;let r=this.extractUnifiedRunTokens(t.usage_metadata);if(r)return r;let n=Object.keys(t);for(let a of n){let s=t[a];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 i=t.generations||[];if(!Array.isArray(i))return null;let o=Array.isArray(i[0])?i.flat():i;for(let a of o)if(typeof a=="object"&&a.message&&typeof a.message=="object"&&a.message.kwargs&&typeof a.message.kwargs=="object"&&(r=this.extractUnifiedRunTokens(a.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 xU=Object.prototype.toString,SU=e=>xU.call(e)==="[object Error]",kU=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 ay(e){if(!(e&&SU(e)&&e.name==="TypeError"&&typeof e.message=="string"))return!1;let{message:r,stack:n}=e;return r==="Load failed"?n===void 0||"__sentry_captured__"in e:r.startsWith("error sending request for url")?!0:kU.has(r)}function EU(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 Ff(e,t,{min:r=0,allowInfinity:n=!1}={}){if(t!==void 0){if(typeof t!="number"||Number.isNaN(t))throw new TypeError(`Expected \`${e}\` to be a number${n?" or Infinity":""}.`);if(!n&&!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 sy=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 IU(e,t){let r=Math.max(1,e+1),n=t.randomize?Math.random()+1:1,i=Math.round(n*t.minTimeout*t.factor**(r-1));return i=Math.min(i,t.maxTimeout),i}function wT(e,t){return Number.isFinite(t)?t-(performance.now()-e):t}async function $U({error:e,attemptNumber:t,retriesConsumed:r,startTime:n,options:i}){let o=e instanceof Error?e:new TypeError(`Non-error was thrown: "${e}". You should only throw errors.`);if(o instanceof sy)throw o.originalError;let a=Number.isFinite(i.retries)?Math.max(0,i.retries-r):i.retries,s=i.maxRetryTime??Number.POSITIVE_INFINITY,c=Object.freeze({error:o,attemptNumber:t,retriesLeft:a,retriesConsumed:r});if(await i.onFailedAttempt(c),wT(n,s)<=0)throw o;let u=await i.shouldConsumeRetry(c),l=wT(n,s);if(l<=0||a<=0)throw o;if(o instanceof TypeError&&!ay(o)){if(u)throw o;return i.signal?.throwIfAborted(),!1}if(!await i.shouldRetry(c))throw o;if(!u)return i.signal?.throwIfAborted(),!1;let d=IU(r,i),f=Math.min(d,l);return f>0&&await new Promise((p,m)=>{let h=()=>{clearTimeout(_),i.signal?.removeEventListener("abort",h),m(i.signal.reason)},_=setTimeout(()=>{i.signal?.removeEventListener("abort",h),p()},f);i.unref&&_.unref?.(),i.signal?.addEventListener("abort",h,{once:!0})}),i.signal?.throwIfAborted(),!0}async function cy(e,t={}){if(t={...t},EU(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,Ff("factor",t.factor,{min:0,allowInfinity:!1}),Ff("minTimeout",t.minTimeout,{min:0,allowInfinity:!1}),Ff("maxTimeout",t.maxTimeout,{min:0,allowInfinity:!0}),Ff("maxRetryTime",t.maxRetryTime,{min:0,allowInfinity:!0}),t.factor>0||(t.factor=1),t.signal?.throwIfAborted();let r=0,n=0,i=performance.now();for(;!Number.isFinite(t.retries)||n<=t.retries;){r++;try{t.signal?.throwIfAborted();let o=await e(r);return t.signal?.throwIfAborted(),o}catch(o){await $U({error:o,attemptNumber:r,retriesConsumed:n,startTime:i,options:t})&&n++}}throw new Error("Retry attempts exhausted without throwing an error.")}var Wf=Vd(Gf(),1),OT="default"in Wf.default?Wf.default.default:Wf.default;var MU=[408,425,429,500,502,503,504],el=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 OT({concurrency:this.maxConcurrency}),this.onFailedResponseHook=t?.onFailedResponseHook}call(t,...r){return this.callWithOptions({},t,...r)}callWithOptions(t,r,...n){let i=t.sizeBytes??0;if(this.maxQueueSizeBytes!==void 0&&i>0&&this.queueSizeBytes+i>this.maxQueueSizeBytes)return Promise.reject(new Error(`Queue size limit (${this.maxQueueSizeBytes} bytes) exceeded. Current queue size: ${this.queueSizeBytes} bytes, attempted addition: ${i} bytes.`));i>0&&(this.queueSizeBytes+=i);let o=this.onFailedResponseHook,a=this.queue.add(()=>cy(()=>r(...n).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 u="response"in s?s.response:void 0;if(o&&await o(u))return;let l=u?.status??("status"in s?s.status:void 0);if(l!=null&&(typeof l=="number"||typeof l=="string")&&!MU.includes(+l))throw s},retries:this.maxRetries,randomize:!0}),{throwOnTimeout:!0});return i>0&&(a=a.finally(()=>{this.queueSizeBytes-=i})),t.signal?Promise.race([a,new Promise((s,c)=>{t.signal?.addEventListener("abort",()=>{c(new Error("AbortError"))})})]):a}};function hy(e){return typeof e?._getType=="function"}function gy(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}var _y=function(){let{crypto:e}=globalThis;if(e?.randomUUID)return _y=e.randomUUID.bind(e),e.randomUUID();let t=new Uint8Array(1),r=e?()=>e.getRandomValues(t)[0]:()=>Math.random()*255&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,n=>(+n^r()&15>>+n/4).toString(16))};var DU=/^[a-z][a-z0-9+.-]*:/i,PT=e=>DU.test(e),Yt=e=>(Yt=Array.isArray,Yt(e)),yy=Yt;function oc(e){return typeof e!="object"?{}:e??{}}function vy(e){if(!e)return!0;for(let t in e)return!1;return!0}function NT(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var RT=(e,t)=>{if(typeof t!="number"||!Number.isInteger(t))throw new $r(`${e} must be an integer`);if(t<0)throw new $r(`${e} must be a positive integer`);return t};var jT=e=>{try{return JSON.parse(e)}catch{return}};var MT=e=>new Promise(t=>setTimeout(t,e));var bo="0.0.1";function zU(){return typeof Deno<"u"&&Deno.build!=null?"deno":typeof EdgeRuntime<"u"?"edge":Object.prototype.toString.call(typeof globalThis.process<"u"?globalThis.process:0)==="[object process]"?"node":"unknown"}var UU=()=>{let e=zU();if(e==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":bo,"X-Stainless-OS":zT(Deno.build.os),"X-Stainless-Arch":DT(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":typeof Deno.version=="string"?Deno.version:Deno.version?.deno??"unknown"};if(typeof EdgeRuntime<"u")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":bo,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if(e==="node")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":bo,"X-Stainless-OS":zT(globalThis.process.platform??"unknown"),"X-Stainless-Arch":DT(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};let t=LU();return t?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":bo,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${t.browser}`,"X-Stainless-Runtime-Version":t.version}:{"X-Stainless-Lang":"js","X-Stainless-Package-Version":bo,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function LU(){if(typeof navigator>"u"||!navigator)return null;let e=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(let{key:t,pattern:r}of e){let n=r.exec(navigator.userAgent);if(n){let i=n[1]||0,o=n[2]||0,a=n[3]||0;return{browser:t,version:`${i}.${o}.${a}`}}}return null}var DT=e=>e==="x32"?"x32":e==="x86_64"||e==="x64"?"x64":e==="arm"?"arm":e==="aarch64"||e==="arm64"?"arm64":e?`other:${e}`:"unknown",zT=e=>(e=e.toLowerCase(),e.includes("ios")?"iOS":e==="android"?"Android":e==="darwin"?"MacOS":e==="win32"?"Windows":e==="freebsd"?"FreeBSD":e==="openbsd"?"OpenBSD":e==="linux"?"Linux":e?`Other:${e}`:"Unknown"),FU,UT=()=>FU??=UU();function LT(){if(typeof fetch<"u")return fetch;throw new Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new Langsmith({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function BU(...e){let t=globalThis.ReadableStream;if(typeof t>"u")throw new Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function by(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return BU({start(){},async pull(r){let{done:n,value:i}=await t.next();n?r.close():r.enqueue(i)},async cancel(){await t.return?.()}})}async function FT(e){if(e===null||typeof e!="object")return;if(e[Symbol.asyncIterator]){await e[Symbol.asyncIterator]().return?.();return}let t=e.getReader(),r=t.cancel();t.releaseLock(),await r}var BT=({headers:e,body:t})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(t)});var wy="RFC3986",xy=e=>String(e),Sy={RFC1738:e=>String(e).replace(/%20/g,"+"),RFC3986:xy},VT="RFC1738";var qf=(e,t)=>(qf=Object.hasOwn??Function.prototype.call.bind(Object.prototype.hasOwnProperty),qf(e,t)),Qn=(()=>{let e=[];for(let t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e})();var ky=1024,HT=(e,t,r,n,i)=>{if(e.length===0)return e;let o=e;if(typeof e=="symbol"?o=Symbol.prototype.toString.call(e):typeof e!="string"&&(o=String(e)),r==="iso-8859-1")return escape(o).replace(/%u[0-9a-f]{4}/gi,function(s){return"%26%23"+parseInt(s.slice(2),16)+"%3B"});let a="";for(let s=0;s<o.length;s+=ky){let c=o.length>=ky?o.slice(s,s+ky):o,u=[];for(let l=0;l<c.length;++l){let d=c.charCodeAt(l);if(d===45||d===46||d===95||d===126||d>=48&&d<=57||d>=65&&d<=90||d>=97&&d<=122||i===VT&&(d===40||d===41)){u[u.length]=c.charAt(l);continue}if(d<128){u[u.length]=Qn[d];continue}if(d<2048){u[u.length]=Qn[192|d>>6]+Qn[128|d&63];continue}if(d<55296||d>=57344){u[u.length]=Qn[224|d>>12]+Qn[128|d>>6&63]+Qn[128|d&63];continue}l+=1,d=65536+((d&1023)<<10|c.charCodeAt(l)&1023),u[u.length]=Qn[240|d>>18]+Qn[128|d>>12&63]+Qn[128|d>>6&63]+Qn[128|d&63]}a+=u.join("")}return a};function ZT(e){return!e||typeof e!="object"?!1:!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))}function Ey(e,t){if(Yt(e)){let r=[];for(let n=0;n<e.length;n+=1)r.push(t(e[n]));return r}return t(e)}var GT={brackets(e){return String(e)+"[]"},comma:"comma",indices(e,t){return String(e)+"["+t+"]"},repeat(e){return String(e)}},WT=function(e,t){Array.prototype.push.apply(e,Yt(t)?t:[t])},ZU,At={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:HT,encodeValuesOnly:!1,format:wy,formatter:xy,indices:!1,serializeDate(e){return(ZU??=Function.prototype.call.bind(Date.prototype.toISOString))(e)},skipNulls:!1,strictNullHandling:!1};function GU(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"||typeof e=="symbol"||typeof e=="bigint"}var Iy={};function qT(e,t,r,n,i,o,a,s,c,u,l,d,f,p,m,h,_,y){let w=e,x=y,S=0,E=!1;for(;(x=x.get(Iy))!==void 0&&!E;){let N=x.get(e);if(S+=1,typeof N<"u"){if(N===S)throw new RangeError("Cyclic object value");E=!0}typeof x.get(Iy)>"u"&&(S=0)}if(typeof u=="function"?w=u(t,w):w instanceof Date?w=f?.(w):r==="comma"&&Yt(w)&&(w=Ey(w,function(N){return N instanceof Date?f?.(N):N})),w===null){if(o)return c&&!h?c(t,At.encoder,_,"key",p):t;w=""}if(GU(w)||ZT(w)){if(c){let N=h?t:c(t,At.encoder,_,"key",p);return[m?.(N)+"="+m?.(c(w,At.encoder,_,"value",p))]}return[m?.(t)+"="+m?.(String(w))]}let C=[];if(typeof w>"u")return C;let T;if(r==="comma"&&Yt(w))h&&c&&(w=Ey(w,c)),T=[{value:w.length>0?w.join(",")||null:void 0}];else if(Yt(u))T=u;else{let N=Object.keys(w);T=l?N.sort(l):N}let b=s?String(t).replace(/\./g,"%2E"):String(t),L=n&&Yt(w)&&w.length===1?b+"[]":b;if(i&&Yt(w)&&w.length===0)return L+"[]";for(let N=0;N<T.length;++N){let W=T[N],ie=typeof W=="object"&&typeof W.value<"u"?W.value:w[W];if(a&&ie===null)continue;let _e=d&&s?W.replace(/\./g,"%2E"):W,$e=Yt(w)?typeof r=="function"?r(L,_e):L:L+(d?"."+_e:"["+_e+"]");y.set(e,S);let ct=new WeakMap;ct.set(Iy,y),WT(C,qT(ie,$e,r,n,i,o,a,s,r==="comma"&&h&&Yt(w)?null:c,u,l,d,f,p,m,h,_,ct))}return C}function WU(e=At){if(typeof e.allowEmptyArrays<"u"&&typeof e.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof e.encodeDotInKeys<"u"&&typeof e.encodeDotInKeys!="boolean")throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(e.encoder!==null&&typeof e.encoder<"u"&&typeof e.encoder!="function")throw new TypeError("Encoder has to be a function.");let t=e.charset||At.charset;if(typeof e.charset<"u"&&e.charset!=="utf-8"&&e.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");let r=wy;if(typeof e.format<"u"){if(!qf(Sy,e.format))throw new TypeError("Unknown format option provided.");r=e.format}let n=Sy[r],i=At.filter;(typeof e.filter=="function"||Yt(e.filter))&&(i=e.filter);let o;if(e.arrayFormat&&e.arrayFormat in GT?o=e.arrayFormat:"indices"in e?o=e.indices?"indices":"repeat":o=At.arrayFormat,"commaRoundTrip"in e&&typeof e.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");let a=typeof e.allowDots>"u"?e.encodeDotInKeys?!0:At.allowDots:!!e.allowDots;return{addQueryPrefix:typeof e.addQueryPrefix=="boolean"?e.addQueryPrefix:At.addQueryPrefix,allowDots:a,allowEmptyArrays:typeof e.allowEmptyArrays=="boolean"?!!e.allowEmptyArrays:At.allowEmptyArrays,arrayFormat:o,charset:t,charsetSentinel:typeof e.charsetSentinel=="boolean"?e.charsetSentinel:At.charsetSentinel,commaRoundTrip:!!e.commaRoundTrip,delimiter:typeof e.delimiter>"u"?At.delimiter:e.delimiter,encode:typeof e.encode=="boolean"?e.encode:At.encode,encodeDotInKeys:typeof e.encodeDotInKeys=="boolean"?e.encodeDotInKeys:At.encodeDotInKeys,encoder:typeof e.encoder=="function"?e.encoder:At.encoder,encodeValuesOnly:typeof e.encodeValuesOnly=="boolean"?e.encodeValuesOnly:At.encodeValuesOnly,filter:i,format:r,formatter:n,serializeDate:typeof e.serializeDate=="function"?e.serializeDate:At.serializeDate,skipNulls:typeof e.skipNulls=="boolean"?e.skipNulls:At.skipNulls,sort:typeof e.sort=="function"?e.sort:null,strictNullHandling:typeof e.strictNullHandling=="boolean"?e.strictNullHandling:At.strictNullHandling}}function KT(e,t={}){let r=e,n=WU(t),i,o;typeof n.filter=="function"?(o=n.filter,r=o("",r)):Yt(n.filter)&&(o=n.filter,i=o);let a=[];if(typeof r!="object"||r===null)return"";let s=GT[n.arrayFormat],c=s==="comma"&&n.commaRoundTrip;i||(i=Object.keys(r)),n.sort&&i.sort(n.sort);let u=new WeakMap;for(let f=0;f<i.length;++f){let p=i[f];n.skipNulls&&r[p]===null||WT(a,qT(r[p],p,s,c,n.allowEmptyArrays,n.strictNullHandling,n.skipNulls,n.encodeDotInKeys,n.encode?n.encoder:null,n.filter,n.sort,n.allowDots,n.serializeDate,n.format,n.formatter,n.encodeValuesOnly,n.charset,u))}let l=a.join(n.delimiter),d=n.addQueryPrefix===!0?"?":"";return n.charsetSentinel&&(n.charset==="iso-8859-1"?d+="utf8=%26%2310003%3B&":d+="utf8=%E2%9C%93&"),l.length>0?d+l:""}function JT(e){return KT(e,{arrayFormat:"repeat"})}var Jf={off:0,error:200,warn:300,info:400,debug:500},$y=(e,t,r)=>{if(e){if(NT(Jf,e))return e;_r(r).warn(`${t} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(Jf))}`)}};function tl(){}function Kf(e,t,r){return!t||Jf[e]>Jf[r]?tl:t[e].bind(t)}var KU={error:tl,warn:tl,info:tl,debug:tl},XT=new WeakMap;function _r(e){let t=e.logger,r=e.logLevel??"off";if(!t)return KU;let n=XT.get(t);if(n&&n[0]===r)return n[1];let i={error:Kf("error",t,r),warn:Kf("warn",t,r),info:Kf("info",t,r),debug:Kf("debug",t,r)};return XT.set(t,[r,i]),i}var Oi=e=>(e.options&&(e.options={...e.options},delete e.options.headers),e.headers&&(e.headers=Object.fromEntries((e.headers instanceof Headers?[...e.headers]:Object.entries(e.headers)).map(([t,r])=>[t,t.toLowerCase()==="authorization"||t.toLowerCase()==="api-key"||t.toLowerCase()==="x-api-key"||t.toLowerCase()==="cookie"||t.toLowerCase()==="set-cookie"||t.toLowerCase()==="x-tenant-id"?"***":r]))),"retryOfRequestLogID"in e&&(e.retryOfRequestLogID&&(e.retryOf=e.retryOfRequestLogID),delete e.retryOfRequestLogID),e);async function Xf(e,t){let{response:r,requestLogID:n,retryOfRequestLogID:i,startTime:o}=t,a=await(async()=>{if(r.status===204)return null;if(t.options.__binaryResponse)return r;let c=r.headers.get("content-type")?.split(";")[0]?.trim();return c?.includes("application/json")||c?.endsWith("+json")?r.headers.get("content-length")==="0"?void 0:await r.json():await r.text()})();return _r(e).debug(`[${n}] response parsed`,Oi({retryOfRequestLogID:i,url:r.url,status:r.status,body:a,durationMs:Date.now()-o})),a}var JU=function(e,t,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(e,r):i?i.value=r:t.set(e,r),r},YT=function(e,t,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(e):n?n.value:t.get(e)},rl,Da=class e extends Promise{constructor(t,r,n=Xf){super(i=>{i(null)}),Object.defineProperty(this,"responsePromise",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"parseResponse",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"parsedPromise",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),rl.set(this,void 0),JU(this,rl,t,"f")}_thenUnwrap(t){return new e(YT(this,rl,"f"),this.responsePromise,async(r,n)=>t(await this.parseResponse(r,n),n))}asResponse(){return this.responsePromise.then(t=>t.response)}async withResponse(){let[t,r]=await Promise.all([this.parse(),this.asResponse()]);return{data:t,response:r}}parse(){return this.parsedPromise||(this.parsedPromise=this.responsePromise.then(t=>this.parseResponse(YT(this,rl,"f"),t))),this.parsedPromise}then(t,r){return this.parse().then(t,r)}catch(t){return this.parse().catch(t)}finally(t){return this.parse().finally(t)}};rl=new WeakMap;var XU=function(e,t,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(e,r):i?i.value=r:t.set(e,r),r},YU=function(e,t,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(e):n?n.value:t.get(e)},Yf,za=class{constructor(t,r,n,i){Yf.set(this,void 0),Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"response",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"body",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),XU(this,Yf,t,"f"),this.options=i,this.response=r,this.body=n}hasNextPage(){return this.getPaginatedItems().length?this.nextPageRequestOptions()!=null:!1}async getNextPage(){let t=this.nextPageRequestOptions();if(!t)throw new $r("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");return await YU(this,Yf,"f").requestAPIList(this.constructor,t)}async*iterPages(){let t=this;for(yield t;t.hasNextPage();)t=await t.getNextPage(),yield t}async*[(Yf=new WeakMap,Symbol.asyncIterator)](){for await(let t of this.iterPages())for(let r of t.getPaginatedItems())yield r}},nl=class extends Da{constructor(t,r,n){super(t,r,async(i,o)=>new n(i,o.response,await Xf(i,o),o.options))}async*[Symbol.asyncIterator](){let t=await this;for await(let r of t)yield r}},Qf=class extends za{constructor(t,r,n,i){super(t,r,n,i),Object.defineProperty(this,"items",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.items=n||[]}getPaginatedItems(){return this.items??[]}nextPageRequestOptions(){let t=this.options.query.offset??0,r=this.getPaginatedItems().length,n=t+r;return{...this.options,query:{...oc(this.options.query),offset:n}}}},ep=class extends za{constructor(t,r,n,i){super(t,r,n,i),Object.defineProperty(this,"items",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.items=n||[]}getPaginatedItems(){return this.items??[]}nextPageRequestOptions(){let t=this.options.query.offset??0,r=this.getPaginatedItems().length,n=t+r;return{...this.options,query:{...oc(this.options.query),offset:n}}}};var tp=class extends za{constructor(t,r,n,i){super(t,r,n,i),Object.defineProperty(this,"evaluators",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"total",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.evaluators=n.evaluators||[],this.total=n.total||0}getPaginatedItems(){return this.evaluators??[]}nextPageRequestOptions(){let t=this.options.query.offset??0,r=this.getPaginatedItems().length,n=t+r;return{...this.options,query:{...oc(this.options.query),offset:n}}}};var ei=class extends za{constructor(t,r,n,i){super(t,r,n,i),Object.defineProperty(this,"items",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"next_cursor",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.items=n.items||[],this.next_cursor=n.next_cursor||""}getPaginatedItems(){return this.items??[]}nextPageRequestOptions(){let t=this.next_cursor;return t?{...this.options,body:{...oc(this.options.body),cursor:t}}:null}},ac=class extends za{constructor(t,r,n,i){super(t,r,n,i),Object.defineProperty(this,"items",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"next_cursor",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.items=n.items||[],this.next_cursor=n.next_cursor||""}getPaginatedItems(){return this.items??[]}nextPageRequestOptions(){let t=this.next_cursor;return t?{...this.options,query:{...oc(this.options.query),cursor:t}}:null}};var Ty=()=>{if(typeof File>"u"){let{process:e}=globalThis,t=typeof e?.versions?.node=="string"&&parseInt(e.versions.node.split("."))<20;throw new Error("`File` is not defined as a global, which is required for file uploads."+(t?" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`.":""))}};function rp(e,t,r){return Ty(),new File(e,t??"unknown_file",r)}function QT(e){return(typeof e=="object"&&e!==null&&("name"in e&&e.name&&String(e.name)||"url"in e&&e.url&&String(e.url)||"filename"in e&&e.filename&&String(e.filename)||"path"in e&&e.path&&String(e.path))||"").split(/[\\/]/).pop()||void 0}var eA=e=>e!=null&&typeof e=="object"&&typeof e[Symbol.asyncIterator]=="function";var tA=e=>e!=null&&typeof e=="object"&&typeof e.size=="number"&&typeof e.type=="string"&&typeof e.text=="function"&&typeof e.slice=="function"&&typeof e.arrayBuffer=="function",eL=e=>e!=null&&typeof e=="object"&&typeof e.name=="string"&&typeof e.lastModified=="number"&&tA(e),tL=e=>e!=null&&typeof e=="object"&&typeof e.url=="string"&&typeof e.blob=="function";async function np(e,t,r){if(Ty(),e=await e,eL(e))return e instanceof File?e:rp([await e.arrayBuffer()],e.name);if(tL(e)){let i=await e.blob();return t||=new URL(e.url).pathname.split(/[\\/]/).pop(),rp(await Ay(i),t,r)}let n=await Ay(e);if(t||=QT(e),!r?.type){let i=n.find(o=>typeof o=="object"&&"type"in o&&o.type);typeof i=="string"&&(r={...r,type:i})}return rp(n,t,r)}async function Ay(e){let t=[];if(typeof e=="string"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer)t.push(e);else if(tA(e))t.push(e instanceof Blob?e:await e.arrayBuffer());else if(eA(e))for await(let r of e)t.push(...await Ay(r));else{let r=e?.constructor?.name;throw new Error(`Unexpected data type: ${typeof e}${r?`; constructor: ${r}`:""}${rL(e)}`)}return t}function rL(e){return typeof e!="object"||e===null?"":`; props: [${Object.getOwnPropertyNames(e).map(r=>`"${r}"`).join(", ")}]`}var Te=class{constructor(t){Object.defineProperty(this,"_client",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._client=t}};function nA(e){return e.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}var rA=Object.freeze(Object.create(null)),iL=(e=nA)=>function(r,...n){if(r.length===1)return r[0];let i=!1,o=[],a=r.reduce((l,d,f)=>{/[?#]/.test(d)&&(i=!0);let p=n[f],m=(i?encodeURIComponent:e)(""+p);return f!==n.length&&(p==null||typeof p=="object"&&p.toString===Object.getPrototypeOf(Object.getPrototypeOf(p.hasOwnProperty??rA)??rA)?.toString)&&(m=p+"",o.push({start:l.length+d.length,length:m.length,error:`Value of type ${Object.prototype.toString.call(p).slice(8,-1)} is not a valid path parameter`})),l+d+(f===n.length?"":m)},""),s=a.split(/[?#]/,1)[0],c=/(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi,u;for(;(u=c.exec(s))!==null;)o.push({start:u.index,length:u[0].length,error:`Value "${u[0]}" can't be safely passed as a path parameter`});if(o.sort((l,d)=>l.start-d.start),o.length>0){let l=0,d=o.reduce((f,p)=>{let m=" ".repeat(p.start-l),h="^".repeat(p.length);return l=p.start+p.length,f+m+h},"");throw new $r(`Path parameters result in path with invalid segments:
24
- ${o.map(f=>f.error).join(`
25
- `)}
26
- ${a}
27
- ${d}`)}return a},te=iL(nA);var sc=class extends Te{create(t,r,n){let{extend_trace_retention:i,...o}=r;return this._client.post(te`/api/v1/platform/annotation-queues/${t}/items`,{query:{extend_trace_retention:i},body:o,...n})}update(t,r,n){let{queue_id:i,...o}=r;return this._client.patch(te`/api/v1/platform/annotation-queues/${i}/items/${t}`,{body:o,...n})}list(t,r,n){return this._client.getAPIList(te`/api/v1/platform/annotation-queues/${t}/items`,ac,{query:r,...n})}createStatus(t,r,n){return this._client.post(te`/api/v1/platform/annotation-queues/items/${t}/status`,{body:r,...n})}deleteAll(t,r,n){return this._client.post(te`/api/v1/platform/annotation-queues/${t}/items/delete`,{body:r,...n})}retrieveCount(t,r,n){return this._client.get(te`/api/v1/platform/annotation-queues/${t}/items/count`,{query:r,...n})}retrievePlacement(t,r,n){let{queue_id:i}=r;return this._client.get(te`/api/v1/platform/annotation-queues/${i}/items/${t}/placement`,n)}};var cc=class extends Te{create(t,r,n){let{body:i,extend_trace_retention:o}=r;return this._client.post(te`/api/v1/annotation-queues/${t}/runs`,{query:{extend_trace_retention:o},body:i,...n})}update(t,r,n){let{queue_id:i,...o}=r;return this._client.patch(te`/api/v1/annotation-queues/${i}/runs/${t}`,{body:o,...n})}list(t,r={},n){return this._client.get(te`/api/v1/annotation-queues/${t}/runs`,{query:r,...n})}createByKey(t,r,n){let{body:i,extend_trace_retention:o}=r;return this._client.post(te`/api/v1/annotation-queues/${t}/runs/by-key`,{query:{extend_trace_retention:o},body:i,...n})}deleteAll(t,r,n){return this._client.post(te`/api/v1/annotation-queues/${t}/runs/delete`,{body:r,...n})}deleteQueue(t,r,n){let{queue_id:i}=r;return this._client.delete(te`/api/v1/annotation-queues/${i}/runs/${t}`,n)}};var Pi=class extends Te{constructor(){super(...arguments),Object.defineProperty(this,"runs",{enumerable:!0,configurable:!0,writable:!0,value:new cc(this._client)}),Object.defineProperty(this,"items",{enumerable:!0,configurable:!0,writable:!0,value:new sc(this._client)})}retrieve(t,r){return this._client.get(te`/api/v1/annotation-queues/${t}`,r)}update(t,r,n){return this._client.patch(te`/api/v1/annotation-queues/${t}`,{body:r,...n})}delete(t,r){return this._client.delete(te`/api/v1/annotation-queues/${t}`,r)}annotationQueues(t,r){return this._client.post("/api/v1/annotation-queues",{body:t,...r})}createRunStatus(t,r,n){return this._client.post(te`/api/v1/annotation-queues/status/${t}`,{body:r,...n})}export(t,r,n){return this._client.post(te`/api/v1/annotation-queues/${t}/export`,{body:r,...n})}populate(t,r){return this._client.post("/api/v1/annotation-queues/populate",{body:t,...r})}retrieveAnnotationQueues(t={},r){return this._client.getAPIList("/api/v1/annotation-queues",Qf,{query:t,...r})}retrieveQueues(t,r){return this._client.get(te`/api/v1/annotation-queues/${t}/queues`,r)}retrieveRun(t,r,n){let{queue_id:i,...o}=r;return this._client.get(te`/api/v1/annotation-queues/${i}/run/${t}`,{query:o,...n})}retrieveSize(t,r={},n){return this._client.get(te`/api/v1/annotation-queues/${t}/size`,{query:r,...n})}retrieveTotalArchived(t,r={},n){return this._client.get(te`/api/v1/annotation-queues/${t}/total_archived`,{query:r,...n})}retrieveTotalSize(t,r){return this._client.get(te`/api/v1/annotation-queues/${t}/total_size`,r)}};Pi.Runs=cc;Pi.Items=sc;var uc=class extends Te{query(t,r,n){return this._client.getAPIList(te`/api/v2/datasets/${t}/experiment-runs`,ei,{body:r,method:"post",...n})}};var wo=class extends Te{constructor(){super(...arguments),Object.defineProperty(this,"experimentRuns",{enumerable:!0,configurable:!0,writable:!0,value:new uc(this._client)})}};wo.ExperimentRuns=uc;var Ua=class extends Te{list(t){return this._client.get("/api/v1/info",t)}};var La=class extends Te{retrieve(t,r){return this._client.get(te`/api/v1/platform/issues/${t}`,r)}list(t={},r){return this._client.getAPIList("/api/v1/platform/issues",ep,{query:t,...r})}};var iA=Symbol("brand.privateNullableHeaders");function*cL(e){if(!e)return;if(iA in e){let{values:n,nulls:i}=e;yield*n.entries();for(let o of i)yield[o,null];return}let t=!1,r;e instanceof Headers?r=e.entries():yy(e)?r=e:(t=!0,r=Object.entries(e??{}));for(let n of r){let i=n[0];if(typeof i!="string")throw new TypeError("expected header name to be a string");let o=yy(n[1])?n[1]:[n[1]],a=!1;for(let s of o)s!==void 0&&(t&&!a&&(a=!0,yield[i,null]),yield[i,s])}}var et=e=>{let t=new Headers,r=new Set;for(let n of e){let i=new Set;for(let[o,a]of cL(n)){let s=o.toLowerCase();i.has(s)||(t.delete(o),i.add(s)),a===null?(t.delete(o),r.add(s)):(t.append(o,a),r.delete(s))}}return{[iA]:!0,values:t,nulls:r}};var Fa=class extends Te{create(t,r){return this._client.post("/api/v1/platform/evaluators",{body:t,...r})}retrieve(t,r){return this._client.get(te`/api/v1/platform/evaluators/${t}`,r)}update(t,r,n){return this._client.patch(te`/api/v1/platform/evaluators/${t}`,{body:r,...n})}list(t={},r){return this._client.getAPIList("/api/v1/platform/evaluators",tp,{query:t,...r})}delete(t,r={},n){let{delete_run_rules:i}=r??{};return this._client.delete(te`/api/v1/platform/evaluators/${t}`,{query:{delete_run_rules:i},...n,headers:et([{Accept:"*/*"},n?.headers])})}bulkDelete(t,r){let{evaluator_ids:n,delete_run_rules:i}=t;return this._client.delete("/api/v1/platform/evaluators",{query:{evaluator_ids:n,delete_run_rules:i},...r})}spend(t,r){return this._client.get("/api/v1/platform/evaluators/spend",{query:t,...r})}};var lc=class extends Te{retrieve(t,r,n){let{share_token:i,Accept:o,...a}=r;return this._client.get(te`/api/v2/public/${i}/run/${t}`,{query:a,...n,headers:et([{...o!=null?{Accept:o}:void 0},n?.headers])})}query(t,r,n){let{Accept:i,...o}=r;return this._client.post(te`/api/v2/public/${t}/runs/query`,{body:o,...n,headers:et([{...i!=null?{Accept:i}:void 0},n?.headers])})}};var xo=class extends Te{constructor(){super(...arguments),Object.defineProperty(this,"runs",{enumerable:!0,configurable:!0,writable:!0,value:new lc(this._client)})}};xo.Runs=lc;var dc=class extends Te{create(t,r,n){return this._client.post(te`/api/v2/runs/${t}/share`,{body:r,...n})}delete(t,r,n){return this._client.delete(te`/api/v2/runs/${t}/share`,{body:r,...n,headers:et([{Accept:"*/*"},n?.headers])})}};var So=class extends Te{constructor(){super(...arguments),Object.defineProperty(this,"share",{enumerable:!0,configurable:!0,writable:!0,value:new dc(this._client)}),Object.defineProperty(this,"retrieve",{enumerable:!0,configurable:!0,writable:!0,value:this.retrieveV2}),Object.defineProperty(this,"query",{enumerable:!0,configurable:!0,writable:!0,value:this.queryV2})}getURL(t,r,n){return this._client.get(te`/api/v2/runs/${t}/url`,{query:r,...n})}queryV2(t,r){let{Accept:n,...i}=t;return this._client.getAPIList("/api/v2/runs/query",ei,{body:i,method:"post",...r,headers:et([{...n!=null?{Accept:n}:void 0},r?.headers])})}retrieveV2(t,r,n){let{Accept:i,...o}=r;return this._client.get(te`/api/v2/runs/${t}`,{query:o,...n,headers:et([{...i!=null?{Accept:i}:void 0},n?.headers])})}};So.Share=dc;var fc=class extends Te{create(t,r){return this._client.post("/api/v2/sandboxes/boxes",{body:t,...r})}retrieve(t,r){return this._client.get(te`/api/v2/sandboxes/boxes/${t}`,r)}update(t,r,n){return this._client.patch(te`/api/v2/sandboxes/boxes/${t}`,{body:r,...n})}list(t={},r){return this._client.get("/api/v2/sandboxes/boxes",{query:t,...r})}delete(t,r){return this._client.delete(te`/api/v2/sandboxes/boxes/${t}`,{...r,headers:et([{Accept:"*/*"},r?.headers])})}createSnapshot(t,r,n){return this._client.post(te`/api/v2/sandboxes/boxes/${t}/snapshot`,{body:r,...n})}generateServiceURL(t,r,n){return this._client.post(te`/api/v2/sandboxes/boxes/${t}/service-url`,{body:r,...n})}getStatus(t,r){return this._client.get(te`/api/v2/sandboxes/boxes/${t}/status`,r)}start(t,r){return this._client.post(te`/api/v2/sandboxes/boxes/${t}/start`,r)}stop(t,r){return this._client.post(te`/api/v2/sandboxes/boxes/${t}/stop`,{...r,headers:et([{Accept:"*/*"},r?.headers])})}};var pc=class extends Te{create(t,r){return this._client.post("/api/v2/sandboxes/registries",{body:t,...r})}retrieve(t,r){return this._client.get(te`/api/v2/sandboxes/registries/${t}`,r)}update(t,r,n){return this._client.patch(te`/api/v2/sandboxes/registries/${t}`,{body:r,...n})}list(t={},r){return this._client.get("/api/v2/sandboxes/registries",{query:t,...r})}delete(t,r){return this._client.delete(te`/api/v2/sandboxes/registries/${t}`,{...r,headers:et([{Accept:"*/*"},r?.headers])})}};var mc=class extends Te{create(t,r){return this._client.post("/api/v2/sandboxes/snapshots",{body:t,...r})}retrieve(t,r){return this._client.get(te`/api/v2/sandboxes/snapshots/${t}`,r)}list(t={},r){return this._client.get("/api/v2/sandboxes/snapshots",{query:t,...r})}delete(t,r){return this._client.delete(te`/api/v2/sandboxes/snapshots/${t}`,{...r,headers:et([{Accept:"*/*"},r?.headers])})}};var ti=class extends Te{constructor(){super(...arguments),Object.defineProperty(this,"boxes",{enumerable:!0,configurable:!0,writable:!0,value:new fc(this._client)}),Object.defineProperty(this,"registries",{enumerable:!0,configurable:!0,writable:!0,value:new pc(this._client)}),Object.defineProperty(this,"snapshots",{enumerable:!0,configurable:!0,writable:!0,value:new mc(this._client)})}};ti.Boxes=fc;ti.Registries=pc;ti.Snapshots=mc;var Ba=class extends Te{listTraces(t,r,n){return this._client.getAPIList(te`/api/v2/threads/${t}/traces`,ac,{query:r,...n})}query(t,r){return this._client.getAPIList("/api/v2/threads/query",ei,{body:t,method:"post",...r})}stats(t,r,n){return this._client.get(te`/api/v2/threads/${t}/stats`,{query:r,...n})}};var Va=class extends Te{listRuns(t,r,n){let{Accept:i,...o}=r;return this._client.get(te`/api/v2/traces/${t}/runs`,{query:o,...n,headers:et([{...i!=null?{Accept:i}:void 0},n?.headers])})}query(t,r){return this._client.getAPIList("/api/v2/traces/query",ei,{body:t,method:"post",...r})}};var hc=e=>{if(typeof globalThis.process<"u")return globalThis.process.env?.[e]?.trim()||void 0;if(typeof globalThis.Deno<"u")return globalThis.Deno.env?.get?.(e)?.trim()||void 0};var hL=function(e,t,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(e,r):i?i.value=r:t.set(e,r),r},oA=function(e,t,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(e):n?n.value:t.get(e)},Cy,Oy,ip,aA,ze=class{constructor({baseURL:t=hc("LANGCHAIN_BASE_URL"),apiKey:r=hc("LANGSMITH_API_KEY")??null,tenantID:n=hc("LANGSMITH_TENANT_ID")??null,...i}={}){Cy.add(this),Object.defineProperty(this,"apiKey",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"tenantID",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"baseURL",{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,"timeout",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"logLevel",{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,"fetch",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),ip.set(this,void 0),Object.defineProperty(this,"idempotencyHeader",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_options",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"datasets",{enumerable:!0,configurable:!0,writable:!0,value:new wo(this)}),Object.defineProperty(this,"runs",{enumerable:!0,configurable:!0,writable:!0,value:new So(this)}),Object.defineProperty(this,"threads",{enumerable:!0,configurable:!0,writable:!0,value:new Ba(this)}),Object.defineProperty(this,"traces",{enumerable:!0,configurable:!0,writable:!0,value:new Va(this)}),Object.defineProperty(this,"onlineEvaluators",{enumerable:!0,configurable:!0,writable:!0,value:new Fa(this)}),Object.defineProperty(this,"public",{enumerable:!0,configurable:!0,writable:!0,value:new xo(this)}),Object.defineProperty(this,"annotationQueues",{enumerable:!0,configurable:!0,writable:!0,value:new Pi(this)}),Object.defineProperty(this,"info",{enumerable:!0,configurable:!0,writable:!0,value:new Ua(this)}),Object.defineProperty(this,"issues",{enumerable:!0,configurable:!0,writable:!0,value:new La(this)}),Object.defineProperty(this,"sandboxes",{enumerable:!0,configurable:!0,writable:!0,value:new ti(this)});let o={apiKey:r,tenantID:n,...i,baseURL:t||"https://api.smith.langchain.com/"};this.baseURL=o.baseURL,this.timeout=o.timeout??Oy.DEFAULT_TIMEOUT,this.logger=o.logger??console;let a="warn";this.logLevel=a,this.logLevel=$y(o.logLevel,"ClientOptions.logLevel",this)??$y(hc("LANGCHAIN_LOG"),"process.env['LANGCHAIN_LOG']",this)??a,this.fetchOptions=o.fetchOptions,this.maxRetries=o.maxRetries??2,this.fetch=o.fetch??LT(),hL(this,ip,BT,"f");let s=hc("LANGCHAIN_CUSTOM_HEADERS");if(s){let c={};for(let u of s.split(`
28
- `)){let l=u.indexOf(":");l>=0&&(c[u.substring(0,l).trim()]=u.substring(l+1).trim())}o.defaultHeaders={...c,...o.defaultHeaders}}this._options=o,this.apiKey=r,this.tenantID=n}withOptions(t){return new this.constructor({...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,tenantID:this.tenantID,...t})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:t,nulls:r}){if(!(this.apiKey&&t.get("x-api-key"))&&!r.has("x-api-key")&&!(this.tenantID&&t.get("x-tenant-id"))&&!r.has("x-tenant-id"))throw new Error('Could not resolve authentication method. Expected either apiKey or tenantID to be set. Or for one of the "X-API-Key" or "X-Tenant-Id" headers to be explicitly omitted')}async authHeaders(t){return et([await this.apiKeyAuth(t),await this.tenantIDAuth(t)])}async apiKeyAuth(t){if(this.apiKey!=null)return et([{"X-API-Key":this.apiKey}])}async tenantIDAuth(t){if(this.tenantID!=null)return et([{"X-Tenant-Id":this.tenantID}])}stringifyQuery(t){return JT(t)}getUserAgent(){return`${this.constructor.name}/JS ${bo}`}defaultIdempotencyKey(){return`stainless-node-retry-${_y()}`}makeStatusError(t,r,n,i){return Vt.generate(t,r,n,i)}buildURL(t,r,n){let i=!oA(this,Cy,"m",aA).call(this)&&n||this.baseURL,o=PT(t)?new URL(t):new URL(i+(i.endsWith("/")&&t.startsWith("/")?t.slice(1):t)),a=this.defaultQuery(),s=Object.fromEntries(o.searchParams);return(!vy(a)||!vy(s))&&(r={...s,...a,...r}),typeof r=="object"&&r&&!Array.isArray(r)&&(o.search=this.stringifyQuery(r)),o.toString()}async prepareOptions(t){}async prepareRequest(t,{url:r,options:n}){}get(t,r){return this.methodRequest("get",t,r)}post(t,r){return this.methodRequest("post",t,r)}patch(t,r){return this.methodRequest("patch",t,r)}put(t,r){return this.methodRequest("put",t,r)}delete(t,r){return this.methodRequest("delete",t,r)}methodRequest(t,r,n){return this.request(Promise.resolve(n).then(i=>({method:t,path:r,...i})))}request(t,r=null){return new Da(this,this.makeRequest(t,r,void 0))}async makeRequest(t,r,n){let i=await t,o=i.maxRetries??this.maxRetries;r==null&&(r=o),await this.prepareOptions(i);let{req:a,url:s,timeout:c}=await this.buildRequest(i,{retryCount:o-r});await this.prepareRequest(a,{url:s,options:i});let u="log_"+(Math.random()*(1<<24)|0).toString(16).padStart(6,"0"),l=n===void 0?"":`, retryOf: ${n}`,d=Date.now();if(_r(this).debug(`[${u}] sending request`,Oi({retryOfRequestLogID:n,method:i.method,url:s,options:i,headers:a.headers})),i.signal?.aborted)throw new vo;let f=new AbortController,p=await this.fetchWithTimeout(s,a,c,f).catch(Xu),m=Date.now();if(p instanceof globalThis.Error){let _=`retrying, ${r} attempts remaining`;if(i.signal?.aborted)throw new vo;let y=mT(p)||/timed? ?out/i.test(String(p)+("cause"in p?String(p.cause):""));if(r)return _r(this).info(`[${u}] connection ${y?"timed out":"failed"} - ${_}`),_r(this).debug(`[${u}] connection ${y?"timed out":"failed"} (${_})`,Oi({retryOfRequestLogID:n,url:s,durationMs:m-d,message:p.message})),this.retryRequest(i,r,n??u);throw _r(this).info(`[${u}] connection ${y?"timed out":"failed"} - error; no more retries left`),_r(this).debug(`[${u}] connection ${y?"timed out":"failed"} (error; no more retries left)`,Oi({retryOfRequestLogID:n,url:s,durationMs:m-d,message:p.message})),y?new Ta:new Ci({cause:p})}let h=`[${u}${l}] ${a.method} ${s} ${p.ok?"succeeded":"failed"} with status ${p.status} in ${m-d}ms`;if(!p.ok){let _=await this.shouldRetry(p);if(r&&_){let C=`retrying, ${r} attempts remaining`;return await FT(p.body),_r(this).info(`${h} - ${C}`),_r(this).debug(`[${u}] response error (${C})`,Oi({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,durationMs:m-d})),this.retryRequest(i,r,n??u,p.headers)}let y=_?"error; no more retries left":"error; not retryable";_r(this).info(`${h} - ${y}`);let w=await p.text().catch(C=>Xu(C).message),x=jT(w),S=x?void 0:w;throw _r(this).debug(`[${u}] response error (${y})`,Oi({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,message:S,durationMs:Date.now()-d})),this.makeStatusError(p.status,x,S,p.headers)}return _r(this).info(h),_r(this).debug(`[${u}] response start`,Oi({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,durationMs:m-d})),{response:p,options:i,controller:f,requestLogID:u,retryOfRequestLogID:n,startTime:d}}getAPIList(t,r,n){return this.requestAPIList(r,n&&"then"in n?n.then(i=>({method:"get",path:t,...i})):{method:"get",path:t,...n})}requestAPIList(t,r){let n=this.makeRequest(r,null,void 0);return new nl(this,n,t)}async fetchWithTimeout(t,r,n,i){let{signal:o,method:a,...s}=r||{},c=this._makeAbort(i);o&&o.addEventListener("abort",c,{once:!0});let u=setTimeout(c,n),l=globalThis.ReadableStream&&s.body instanceof globalThis.ReadableStream||typeof s.body=="object"&&s.body!==null&&Symbol.asyncIterator in s.body,d={signal:i.signal,...l?{duplex:"half"}:{},method:"GET",...s};a&&(d.method=a.toUpperCase());try{return await this.fetch.call(void 0,t,d)}finally{clearTimeout(u)}}async shouldRetry(t){let r=t.headers.get("x-should-retry");return r==="true"?!0:r==="false"?!1:t.status===408||t.status===409||t.status===429||t.status>=500}async retryRequest(t,r,n,i){let o,a=i?.get("retry-after-ms");if(a){let c=parseFloat(a);Number.isNaN(c)||(o=c)}let s=i?.get("retry-after");if(s&&!o){let c=parseFloat(s);Number.isNaN(c)?o=Date.parse(s)-Date.now():o=c*1e3}if(o===void 0){let c=t.maxRetries??this.maxRetries;o=this.calculateDefaultRetryTimeoutMillis(r,c)}return await MT(o),this.makeRequest(t,r-1,n)}calculateDefaultRetryTimeoutMillis(t,r){let o=r-t,a=Math.min(.5*Math.pow(2,o),16),s=1-Math.random()*.25;return a*s*1e3}async buildRequest(t,{retryCount:r=0}={}){let n={...t},{method:i,path:o,query:a,defaultBaseURL:s}=n,c=this.buildURL(o,a,s);"timeout"in n&&RT("timeout",n.timeout),n.timeout=n.timeout??this.timeout;let{bodyHeaders:u,body:l}=this.buildBody({options:n}),d=await this.buildHeaders({options:t,method:i,bodyHeaders:u,retryCount:r});return{req:{method:i,headers:d,...n.signal&&{signal:n.signal},...globalThis.ReadableStream&&l instanceof globalThis.ReadableStream&&{duplex:"half"},...l&&{body:l},...this.fetchOptions??{},...n.fetchOptions??{}},url:c,timeout:n.timeout}}async buildHeaders({options:t,method:r,bodyHeaders:n,retryCount:i}){let o={};this.idempotencyHeader&&r!=="get"&&(t.idempotencyKey||(t.idempotencyKey=this.defaultIdempotencyKey()),o[this.idempotencyHeader]=t.idempotencyKey);let a=et([o,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(i),...t.timeout?{"X-Stainless-Timeout":String(Math.trunc(t.timeout/1e3))}:{},...UT()},await this.authHeaders(t),this._options.defaultHeaders,n,t.headers]);return this.validateHeaders(a),a.values}_makeAbort(t){return()=>t.abort()}buildBody({options:{body:t,headers:r}}){if(!t)return{bodyHeaders:void 0,body:void 0};let n=et([r]);return ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof DataView||typeof t=="string"&&n.values.has("content-type")||globalThis.Blob&&t instanceof globalThis.Blob||t instanceof FormData||t instanceof URLSearchParams||globalThis.ReadableStream&&t instanceof globalThis.ReadableStream?{bodyHeaders:void 0,body:t}:typeof t=="object"&&(Symbol.asyncIterator in t||Symbol.iterator in t&&"next"in t&&typeof t.next=="function")?{bodyHeaders:void 0,body:by(t)}:typeof t=="object"&&n.values.get("content-type")==="application/x-www-form-urlencoded"?{bodyHeaders:{"content-type":"application/x-www-form-urlencoded"},body:this.stringifyQuery(t)}:oA(this,ip,"f").call(this,{body:t,headers:n})}};Oy=ze,ip=new WeakMap,Cy=new WeakSet,aA=function(){return this.baseURL!=="https://api.smith.langchain.com/"};Object.defineProperty(ze,"Langsmith",{enumerable:!0,configurable:!0,writable:!0,value:Oy});Object.defineProperty(ze,"DEFAULT_TIMEOUT",{enumerable:!0,configurable:!0,writable:!0,value:9e4});Object.defineProperty(ze,"LangsmithError",{enumerable:!0,configurable:!0,writable:!0,value:$r});Object.defineProperty(ze,"APIError",{enumerable:!0,configurable:!0,writable:!0,value:Vt});Object.defineProperty(ze,"APIConnectionError",{enumerable:!0,configurable:!0,writable:!0,value:Ci});Object.defineProperty(ze,"APIConnectionTimeoutError",{enumerable:!0,configurable:!0,writable:!0,value:Ta});Object.defineProperty(ze,"APIUserAbortError",{enumerable:!0,configurable:!0,writable:!0,value:vo});Object.defineProperty(ze,"NotFoundError",{enumerable:!0,configurable:!0,writable:!0,value:Pa});Object.defineProperty(ze,"ConflictError",{enumerable:!0,configurable:!0,writable:!0,value:Na});Object.defineProperty(ze,"RateLimitError",{enumerable:!0,configurable:!0,writable:!0,value:ja});Object.defineProperty(ze,"BadRequestError",{enumerable:!0,configurable:!0,writable:!0,value:Aa});Object.defineProperty(ze,"AuthenticationError",{enumerable:!0,configurable:!0,writable:!0,value:Ca});Object.defineProperty(ze,"InternalServerError",{enumerable:!0,configurable:!0,writable:!0,value:Ma});Object.defineProperty(ze,"PermissionDeniedError",{enumerable:!0,configurable:!0,writable:!0,value:Oa});Object.defineProperty(ze,"UnprocessableEntityError",{enumerable:!0,configurable:!0,writable:!0,value:Ra});Object.defineProperty(ze,"toFile",{enumerable:!0,configurable:!0,writable:!0,value:np});ze.Datasets=wo;ze.Runs=So;ze.Threads=Ba;ze.Traces=Va;ze.OnlineEvaluators=Fa;ze.Public=xo;ze.AnnotationQueues=Pi;ze.Info=Ua;ze.Issues=La;ze.Sandboxes=ti;var il={CLICKHOUSE_ONLY:"clickhouse_only",SMITHDB_ONLY:"smithdb_only",DUAL:"dual"};function sA(e){let t=e??{},r=!!(t.ch_query_enabled??!0),n=!!(t.sdb_query_enabled??!1);return!r&&n?il.SMITHDB_ONLY:r&&n?il.DUAL:il.CLICKHOUSE_ONLY}function ap(e){return`Invalid prompt identifier format: "${e}". Expected one of:
29
- - "prompt-name" (for private prompts)
30
- - "owner/prompt-name" (for prompts with explicit owner)
31
- - "prompt-name:commit-hash" (with commit reference)
32
- - "owner/prompt-name:commit-hash" (with owner and commit)`}var Py=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}},Ny=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 sp(e){return e!=null&&typeof e=="object"&&"name"in e&&e?.name==="LangSmithNotFoundError"}function cA(e){return e!=null&&typeof e=="object"&&"name"in e&&e?.name==="LangSmithConflictError"}async function X(e,t,r){let n;if(e.ok){r&&(n=await e.text());return}if(e.status===403)try{(await e.json())?.error==="org_scoped_key_requires_workspace"&&(n="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(n===void 0)try{n=await e.text()}catch{n=""}let i=`Failed to ${t}. Received status [${e.status}]: ${e.statusText}. Message: ${n}`;if(e.status===404)throw new Ny(i);if(e.status===409)throw new Py(i);let o=new Error(i);throw o.status=e.status,o}var uA="ERR_CONFLICTING_ENDPOINTS",op=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:uA}),this.name="ConflictingEndpointsError"}};function lA(e){return typeof e=="object"&&e!==null&&e.code===uA}function Qt(e){if(!e||e.split("/").length>2||e.startsWith("/")||e.endsWith("/")||e.split(":").length>2)throw new Error(ap(e));let[t,r]=e.split(":"),n=r||"latest";if(t.includes("/")){let[i,o]=t.split("/",2);if(!i||!o)throw new Error(ap(e));return[i,o,n]}else{if(!t)throw new Error(ap(e));return["-",t,n]}}var gL=10,_L=1e4,dA="created_at";function yL(e){return new Promise(t=>setTimeout(t,e))}function vL(e){return typeof e=="object"&&e!==null&&e.code==="EEXIST"}function fA(e){try{return $a(wn.join(e,dA)).split(`
33
- `)}catch{return}}function bL(e){let t=fA(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 wL(e){let t=fA(e);if(t&&t.length>=2&&t[1].trim())return t[1].trim()}async function xL(e){let t=bL(e);return t===void 0||Date.now()-t<=_L?!1:(await Nf(e),!0)}async function pA(e,t){let r=`${e}.oauth.lock.lock`,n=wn.dirname(r);n&&await Pf(n);let i=globalThis.crypto.randomUUID();for(;;){try{await pT(r)}catch(o){if(!vL(o))throw o;if(!await xL(r)){if(Date.now()>=t)throw new Error("timed out acquiring OAuth refresh lock");await yL(Math.min(gL,Math.max(0,t-Date.now())))}continue}try{await nc(wn.join(r,dA),`${new Date().toISOString()}
34
- ${i}
35
- `)}catch(o){throw await Nf(r),o}break}return{async release(){wL(r)===i&&await Nf(r)}}}var cp="https://api.smith.langchain.com",SL="langsmith-cli",kL=6e4,EL=1e4;function IL(){let e=Yu();return e==="browser"||e==="webworker"}function $L(){let e=Dt("LANGSMITH_CONFIG_FILE");if(e)return e;let t=Dt("HOME")??Dt("USERPROFILE");if(t)return wn.join(t,".langsmith","config.json")}function TL(e){let t=Dt("LANGSMITH_PROFILE");if(t)return t;if(e.current_profile)return e.current_profile;if(e.profiles?.default)return"default"}function AL(){if(IL())return;let e=$L();if(!(!e||!ic(e)))try{let t=JSON.parse($a(e)),r=TL(t),n=r?t.profiles?.[r]:void 0;return!r||!n?void 0:{configPath:e,config:t,profileName:r,profile:n}}catch{return}}function rn(e){return e!=null&&e.trim()!==""}function ko(e){return e?.trim().replace(/^["']|["']$/g,"")}function mA(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()+kL}function CL(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 OL(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 hA(e){return e.reason??new Error("The operation was aborted.")}async function PL(e,t){if(!t)return e;if(t.aborted)throw hA(t);let r,n=new Promise((i,o)=>{let a=()=>{o(hA(t))};t.addEventListener("abort",a,{once:!0}),r=()=>{t.removeEventListener("abort",a)}});try{return await Promise.race([e,n])}finally{r?.()}}function gA(){let e=AL(),t=e?.profile;if(!e||!t)return{};let r=ko(t.api_key),n=ko(t.oauth?.access_token),i=ko(t.oauth?.refresh_token);return{apiUrl:t.api_url,apiKey:r,workspaceId:t.workspace_id,oauthAccessToken:n,oauthRefreshToken:i,profileAuth:r||n||i?new Ry(e):void 0}}var Ry=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=NL(this.state.profile);return this.rememberProfileAuthHeader(t),t}async getAuthHeader(t,r){mA(this.state.profile)&&(this.refreshPromise||(this.refreshPromise=this.refreshOAuthToken(t).finally(()=>{this.refreshPromise=void 0})),await PL(this.refreshPromise,r));let n=_A(this.state.profile);return this.rememberProfileAuthHeader(n),n}isProfileAuthorizationHeader(t){return t===this.managedAuthorizationValue}reloadProfile(){try{let t=JSON.parse($a(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 n=ko(this.state.profile.api_url)??cp,i=Date.now()+EL,o;try{if(o=await pA(this.state.configPath,i),this.reloadProfile()&&!mA(this.state.profile))return;let s=new URLSearchParams({grant_type:"refresh_token",client_id:SL,refresh_token:this.state.profile.oauth?.refresh_token??r}),c=await t(`${CL(n)}/oauth/token`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s.toString(),signal:AbortSignal.timeout(Math.max(0,i-Date.now()))});if(!c.ok)return;let u=await c.json();if(!u.access_token)return;OL(this.state.profile,u),this.state.config.profiles??={},this.state.config.profiles[this.state.profileName]=this.state.profile,await nc(this.state.configPath,`${JSON.stringify(this.state.config,null,2)}
36
- `)}catch{return}finally{await o?.release()}}rememberProfileAuthHeader(t){this.managedAuthorizationValue=t?.name==="Authorization"?t.value:void 0}};function NL(e){let t=ko(e.oauth?.access_token);if(t)return{name:"Authorization",value:`Bearer ${t}`};if(!ko(e.oauth?.refresh_token))return _A(e)}function _A(e){let t=ko(e.oauth?.access_token);if(t)return{name:"Authorization",value:`Bearer ${t}`};let r=ko(e.api_key);if(r)return{name:"x-api-key",value:r}}var yA="[...]",RL={result:"[Circular]"},lp=[],gc=[],jL=new TextEncoder;function ML(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function up(e){return jL.encode(e)}function vA(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 DL(e){return function(t,r){if(e){let n=e.call(this,t,r);if(n!==void 0)return n}return vA(r)}}function bA(e){try{let i=function(l){let d=n(l);return d>r&&(r=d),d+2},o=function(l){return l===0?2:2+l*4},a=function(l){return l===void 0||typeof l=="function"||typeof l=="symbol"},s=function(l){return l===void 0||typeof l=="function"||typeof l=="symbol"?4:c(l)},c=function(l){if(l===null)return 4;if(l===void 0)return 0;let d=typeof l;if(d==="boolean")return 5;if(d==="number")return Number.isFinite(l)?l.toString().length:4;if(d==="bigint")return l.toString().length+2;if(d==="string")return i(l);if(d==="function"||d==="symbol")return 0;let f=l;if(f instanceof Date)return 26;if(f instanceof RegExp)return n(f.toString())+2;if(f instanceof Error){let m=f.name??"",h=f.message??"";return 22+n(m)+n(h)}if(typeof Buffer<"u"&&f instanceof Buffer)return 28+o(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(a(_))continue;m>0&&(p+=1);let y=typeof h=="string"?h:String(h);p+=n(y)+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 y=h[_],w=f[y];a(w)||(m>0&&(p+=1),p+=n(y)+3,p+=c(w),m++)}}return t.delete(f),p},t=new Set,r=0,n=typeof Buffer<"u"&&typeof Buffer.byteLength=="function"?l=>Buffer.byteLength(l,"utf8"):l=>l.length;return{size:c(e),maxStringLen:r}}catch{return{size:er(e).length,maxStringLen:0}}}function er(e,t,r,n,i){try{let o=JSON.stringify(e,DL(r),n);return up(o)}catch(o){if(!o.message?.includes("Converting circular structure to JSON"))return console.warn(`[WARNING]: LangSmith received unserializable value.${t?`
37
- Context: ${t}`:""}`),up("[Unserializable]");qe("SUPPRESS_CIRCULAR_JSON_WARNINGS")!=="true"&&console.warn(`[WARNING]: LangSmith received circular JSON. This will decrease tracer performance. ${t?`
38
- Context: ${t}`:""}`),typeof i>"u"&&(i=ML()),My(e,"",0,[],void 0,0,i);let a;try{gc.length===0?a=JSON.stringify(e,r,n):a=JSON.stringify(e,zL(r),n)}catch{return up("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;lp.length!==0;){let s=lp.pop();s.length===4?Object.defineProperty(s[0],s[1],s[3]):s[0][s[1]]=s[2]}}return up(a)}}function jy(e,t,r,n){var i=Object.getOwnPropertyDescriptor(n,r);i.get!==void 0?i.configurable?(Object.defineProperty(n,r,{value:e}),lp.push([n,r,t,i])):gc.push([t,r,e]):(n[r]=e,lp.push([n,r,t]))}function My(e,t,r,n,i,o,a){o+=1;var s;if(typeof e=="object"&&e!==null){for(s=0;s<n.length;s++)if(n[s]===e){jy(RL,e,t,i);return}if(typeof a.depthLimit<"u"&&o>a.depthLimit){jy(yA,e,t,i);return}if(typeof a.edgesLimit<"u"&&r+1>a.edgesLimit){jy(yA,e,t,i);return}if(n.push(e),Array.isArray(e))for(s=0;s<e.length;s++)My(e[s],s,s,n,e,o,a);else{e=vA(e);var c=Object.keys(e);for(s=0;s<c.length;s++){var u=c[s];My(e[u],u,s,n,e,o,a)}}n.pop()}}function zL(e){return e=typeof e<"u"?e:function(t,r){return r},function(t,r){if(gc.length>0)for(var n=0;n<gc.length;n++){var i=gc[n];if(i[1]===t&&i[0]===r){r=i[2],gc.splice(n,1);break}}return e.call(this,t,r)}}var LL=`
39
- const { parentPort } = require("worker_threads");
40
-
41
- const CIRCULAR_REPLACE_NODE = { result: "[Circular]" };
42
-
43
- function serializeWellKnownTypes(val) {
44
- if (val && typeof val === "object") {
45
- if (val instanceof Map) return Object.fromEntries(val);
46
- if (val instanceof Set) return Array.from(val);
47
- if (val instanceof Date) return val.toISOString();
48
- if (val instanceof RegExp) return val.toString();
49
- if (val instanceof Error) return { name: val.name, message: val.message };
50
- } else if (typeof val === "bigint") {
51
- return val.toString();
52
- }
53
- return val;
54
- }
55
-
56
- function defaultReplacer(_key, val) {
57
- return serializeWellKnownTypes(val);
58
- }
59
-
60
- // Decirculate in-place: replace circular refs with { result: "[Circular]" }
61
- // then restore after stringify. Mirrors fast-safe-stringify's decirc().
62
- const restoreStack = [];
63
- function decirc(val, k, stack, parent) {
64
- if (typeof val === "object" && val !== null) {
65
- for (let i = 0; i < stack.length; i++) {
66
- if (stack[i] === val) {
67
- const orig = parent[k];
68
- parent[k] = CIRCULAR_REPLACE_NODE;
69
- restoreStack.push([parent, k, orig]);
70
- return;
71
- }
72
- }
73
- stack.push(val);
74
- if (Array.isArray(val)) {
75
- for (let i = 0; i < val.length; i++) decirc(val[i], i, stack, val);
76
- } else {
77
- const normalized = serializeWellKnownTypes(val);
78
- // Only recurse into normalized if it's still an object (arrays/objects),
79
- // else it was replaced with a primitive (e.g. Date -> string).
80
- if (normalized === val) {
81
- const keys = Object.keys(val);
82
- for (let i = 0; i < keys.length; i++) decirc(val[keys[i]], keys[i], stack, val);
83
- }
84
- }
85
- stack.pop();
86
- }
87
- }
88
-
89
- function serialize(obj) {
90
- try {
91
- return JSON.stringify(obj, defaultReplacer);
92
- } catch (e) {
93
- if (!String(e && e.message).includes("Converting circular structure to JSON")) {
94
- return "[Unserializable]";
95
- }
96
- decirc(obj, "", [], { "": obj });
97
- try {
98
- return JSON.stringify(obj, defaultReplacer);
99
- } catch (_) {
100
- return "[unable to serialize, circular reference is too complex to analyze]";
101
- } finally {
102
- while (restoreStack.length) {
103
- const [p, k, v] = restoreStack.pop();
104
- p[k] = v;
105
- }
106
- }
107
- }
108
- }
109
-
110
- parentPort.on("message", (msg) => {
111
- const { id, op, payload } = msg;
112
- try {
113
- if (op === "serialize") {
114
- const str = serialize(payload);
115
- const buf = Buffer.from(str, "utf8");
116
- // Slice into its own ArrayBuffer so we can transfer without dragging
117
- // unrelated bytes from any shared pool buffer.
118
- const ab = buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
119
- parentPort.postMessage({ id, bytes: ab, length: buf.byteLength }, [ab]);
120
- } else if (op === "ping") {
121
- parentPort.postMessage({ id });
122
- } else {
123
- parentPort.postMessage({ id, error: "unknown op: " + op });
124
- }
125
- } catch (e) {
126
- parentPort.postMessage({ id, error: String((e && e.message) || e) });
127
- }
128
- });
129
- `,zy=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(LL,{eval:!0});return t.on("message",r=>{let n=this.pending.get(r.id);n&&(this.pending.delete(r.id),r.error?n.reject(new Error(r.error)):r.bytes&&typeof r.length=="number"?n.resolve(new Uint8Array(r.bytes,0,r.length)):n.reject(new Error("worker returned malformed message")))}),t.on("error",r=>{for(let[,n]of this.pending)n.reject(r);this.pending.clear(),this.disabled=!0,this.worker=null}),t.on("exit",r=>{for(let[,n]of this.pending)n.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 n=this.nextId++;return new Promise((i,o)=>{this.pending.set(n,{resolve:i,reject:o});try{this.worker.postMessage({id:n,op:"serialize",payload:t})}catch(a){this.pending.delete(n),o(a)}})}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()}},Dy=null;function xA(){return Dy===null&&(Dy=new zy),Dy}var FL=64*1024,BL=2048;function SA(e,t=FL,r=BL){if(e===null||typeof e!="object")return typeof e=="string"&&e.length>=t;let n=[e],i=new Set,o=0;for(;n.length>0;){if(o++>=r)return!1;let a=n.pop();if(a==null)continue;let s=typeof a;if(s==="string"){if(a.length>=t)return!0;continue}if(s!=="object")continue;let c=a;if(i.has(c)||(i.add(c),c instanceof Date||c instanceof RegExp||c instanceof Error||c instanceof ArrayBuffer||ArrayBuffer.isView(c)))continue;if(Array.isArray(c)){for(let l=c.length-1;l>=0;l--)n.push(c[l]);continue}if(c instanceof Map){for(let[,l]of c)n.push(l);continue}if(c instanceof Set){for(let l of c)n.push(l);continue}let u=Object.keys(c);for(let l=u.length-1;l>=0;l--)n.push(c[u[l]])}return!1}function VL(e,t){let[r]=Qt(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 kA(e){return typeof e=="string"&&e.length>0&&!e.includes("Z")&&!e.includes("+")&&!e.includes("-",10)?e+"Z":e}function _c(e){return{...e,start_time:kA(e.start_time),end_time:kA(e.end_time)}}function EA(e,t,r){if(r)return e;let n=Df(),i=t??Y_(),o=e.extra??{},a=o.metadata;return e.extra={...o,runtime:{...n,...o?.runtime},metadata:{...i,...i.revision_id||"revision_id"in e&&e.revision_id?{revision_id:("revision_id"in e?e.revision_id:void 0)??i.revision_id}:{},...a}},e}var HL=e=>{let t=e?.toString()??qe("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},ZL=e=>{let r=e.replace("http://","").replace("https://","").split("/")[0].split(":")[0];return r==="localhost"||r==="127.0.0.1"||r==="::1"};async function GL(e){let t=[];for await(let r of e)t.push(r);return t}function dp(e){if(e!==void 0)return e.trim().replace(/^"(.*)"$/,"$1").replace(/^'(.*)'$/,"$1")}var WL=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 IA(e){return typeof e=="number"?Number(e.toFixed(4)):e}function qL(e,t){if(!e)return;let r=u=>u.split(".").map(l=>parseInt(l,10)),[n,i,o]=r(e),[a,s,c]=r(t);if(isNaN(n)||isNaN(i)||isNaN(o)||isNaN(a)||isNaN(s)||isNaN(c)){console.warn(`[LANGSMITH]: Could not parse backend version ${JSON.stringify(e)} for compatibility check.`);return}(n<a||n===a&&i<s||n===a&&i===s&&o<c)&&console.warn(`[LANGSMITH]: Backend version ${JSON.stringify(e)} is older than the minimum version required by this SDK (${JSON.stringify(t)}). Some features may not work as expected. See https://docs.langchain.com/langsmith/smithdb-sdk-migration`)}var KL=24*1024*1024,CA=1024*1024*1024,JL=1e4,XL=100;function OA(e,t){new Headers({[e]:t})}function $A(e){for(let[t,r]of Object.entries(e??{}))OA(t,r)}function TA(e){if(!e)return{};let t=e instanceof Headers?[...e.entries()]:Array.isArray(e)?e.map(([i,o])=>[i,o]):Object.entries(e),r={},n=new Map;for(let[i,o]of t){OA(i,o);let a=i.toLowerCase(),s=n.get(a);s===void 0?(n.set(a,i),r[i]=o):r[s]=o}return r}function YL(e,t,r){let n={...e},i=new Map(Object.keys(n).map(o=>[o.toLowerCase(),o]));for(let[o,a]of Object.entries(t)){let s=o.toLowerCase();n[i.get(s)??o]=a}for(let o of Object.keys(n))r.has(o.toLowerCase())&&delete n[o];return n}var Uy=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??CA}peek(){return this.items[0]}push(t){let r,n=new Promise(o=>{r=o}),i=bA(t.item).size;return this.sizeBytes+i>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: ${i} bytes.`),r(),n):(this.items.push({action:t.action,payload:t.item,otelContext:t.otelContext,apiKey:t.apiKey,apiUrl:t.apiUrl,workspaceId:t.workspaceId,itemPromiseResolve:r,itemPromise:n,size:i}),this.sizeBytes+=i,n)}pop({upToSizeBytes:t,upToSize:r}){if(t<1)throw new Error("Number of bytes to pop off may not be less than 1.");let n=[],i=0;for(;i+(this.peek()?.size??0)<t&&this.items.length>0&&n.length<r;){let o=this.items.shift();o&&(n.push(o),i+=o.size,this.sizeBytes-=o.size)}if(n.length===0&&this.items.length>0){let o=this.items.shift();n.push(o),i+=o.size,this.sizeBytes-=o.size}return[n.map(o=>({action:o.action,item:o.payload,otelContext:o.otelContext,apiKey:o.apiKey,apiUrl:o.apiUrl,workspaceId:o.workspaceId,size:o.size})),()=>n.forEach(o=>o.itemPromiseResolve())]}},Xn=class e{get tracingMode(){return this._tracingMode}get _fetch(){let t=this.fetchImplementation||J$(this.debug);return(async(r,n)=>{let i,o=this.getProfileManagedAuthorizationHeader(n);return this.apiKey!==void 0?i={name:"x-api-key",value:`${this.apiKey}`}:this.hasExplicitAuthHeader(n,o)||(i=await this.profileAuth?.getAuthHeader(t,n?.signal)),t(r,this.applyCurrentAuthHeaders(n,i,o))})}getProfileManagedAuthorizationHeader(t){if(!t?.headers||!this.profileAuth)return;let r=new Headers(t.headers).get("Authorization");if(rn(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 n=new Headers(t.headers);if(rn(n.get("x-api-key")))return!0;let i=n.get("Authorization");return rn(i)?!this.isProfileManagedAuthorizationHeader(i??"",r):!1}applyCurrentAuthHeaders(t,r,n){if(!r)return t;let i=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(rn(d.get("x-api-key")))return d;let p=d.get("Authorization");return rn(p)&&!this.isProfileManagedAuthorizationHeader(p??"",n)||d.set("Authorization",r.value),d}let f=d.get("Authorization");return rn(f)&&!this.isProfileManagedAuthorizationHeader(f??"",n)||(rn(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:i(new Headers(t.headers))};if(Array.isArray(t.headers))return{...t,headers:i(new Headers(t.headers))};let o={...t.headers??{}},a=d=>Object.keys(o).find(f=>f.toLowerCase()===d),s=d=>{let f=a(d);return f?o[f]:void 0},c=rn(s("x-api-key")),u=s("authorization"),l=rn(u)&&!this.isProfileManagedAuthorizationHeader(u??"",n);if(this.apiKey!==void 0&&r.name==="x-api-key"){let d=a("authorization");return d&&delete o[d],c||(o["x-api-key"]=r.value),{...t,headers:o}}if(r.name==="Authorization"){if(!c&&!l){let d=a("authorization");d&&d!=="Authorization"&&delete o[d],o.Authorization=r.value}return{...t,headers:o}}if(!l){let d=a("authorization");d&&delete o[d],c||(o["x-api-key"]=r.value)}return{...t,headers:o}}_trackDrain(t){this._pendingDrains.add(t),t.finally(()=>{this._pendingDrains.delete(t)})}async _serializeBody(t,r){if(this.manualFlushMode)return er(t,r);if(!SA(t))return er(t,r);if(this._serializeWorker===void 0&&(this._serializeWorker=xA()),this._serializeWorker===null)return er(t,r);try{let n=await this._serializeWorker.serialize(t);return n===null?(this._serializeWorker=null,er(t,r)):n}catch{return er(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,"anonymizer",{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,"_fetchOptionsHeaders",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_openAPIClient",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_openAPIClientSignature",{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:Dt("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,"_stainlessVersionsChecked",{enumerable:!0,configurable:!0,writable:!0,value:new Set}),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:qe("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:qe("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:Dt("LANGSMITH_DEBUG")==="true"});let r=e.getDefaultClientConfig();this.tracingSampleRate=HL(t.tracingSamplingRate),this.apiUrl=dp(t.apiUrl??r.apiUrl)??"",this.apiUrl.endsWith("/")&&(this.apiUrl=this.apiUrl.slice(0,-1));let n=dp(t.apiKey??r.apiKey);if(this.apiKey=rn(n)?n:void 0,this.profileAuth=this.apiKey!==void 0?void 0:r.profileAuth,this.webUrl=dp(t.webUrl??r.webUrl),this.webUrl?.endsWith("/")&&(this.webUrl=this.webUrl.slice(0,-1)),this.workspaceId=dp(t.workspaceId??r.workspaceId),this.timeout_ms=t.timeout_ms??9e4,this.caller=new el({...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=qe("FAILED_TRACES_DIR")||void 0;let i=qe("FAILED_TRACES_MAX_MB");if(i){let c=parseInt(i,10);Number.isFinite(c)&&c>0&&(this.failedTracesMaxBytes=c*1024*1024)}let o=t.maxIngestMemoryBytes??CA;this.batchIngestCaller=new el({maxRetries:4,maxConcurrency:this.traceBatchConcurrency,maxQueueSizeBytes:o,...t.callerOptions??{},onFailedResponseHook:WL,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.anonymizer=t.anonymizer,this.omitTracedRuntimeInfo=t.omitTracedRuntimeInfo??!1,this.autoBatchTracing=t.autoBatchTracing??this.autoBatchTracing,this.autoBatchQueue=new Uy(o),this.blockOnRootRunFinalization=t.blockOnRootRunFinalization??this.blockOnRootRunFinalization,this.batchSizeBytesLimit=t.batchSizeBytesLimit,this.batchSizeLimit=t.batchSizeLimit;let{headers:a,...s}=t.fetchOptions||{};this.fetchOptions=s,this._fetchOptionsHeaders=TA(a),$A(t.headers),this._customHeaders=t.headers??{},this.manualFlushMode=t.manualFlushMode??this.manualFlushMode,this._tracingMode=zf(t.tracingMode),this._tracingMode==="otel"&&(this.langSmithToOTELTranslator=new Lf),this.cachedLSEnvVarsForMetadata=Y_(),t.cache!==void 0&&t.disablePromptCache&&zt("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?(zt("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=jf:this._promptCache=t.cache):t.disablePromptCache||(this._promptCache=jf)}static getDefaultClientConfig(){let t=gA(),r=qe("API_KEY"),n=qe("ENDPOINT"),i=qe("WORKSPACE_ID"),o=rn(r),a=n??t.apiUrl??cp,s=i??t.workspaceId,c=qe("HIDE_INPUTS")==="true",u=qe("HIDE_OUTPUTS")==="true",l=qe("HIDE_METADATA")==="true";return{apiUrl:a,apiKey:r,webUrl:void 0,hideInputs:c,hideOutputs:u,hideMetadata:l,workspaceId:s,oauthAccessToken:o?void 0:t.oauthAccessToken,oauthRefreshToken:o?void 0:t.oauthRefreshToken,profileAuth:o?void 0:t.profileAuth}}getHostUrl(){return this.webUrl?this.webUrl:ZL(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 _sdkControlledHeaders(){let t=new Set;if(this.apiKey!==void 0)t.add("x-api-key");else{let r=this.profileAuth?.currentAuthHeader();r&&t.add(r.name.toLowerCase())}return this.workspaceId&&t.add("x-tenant-id"),t}get _callerHeaders(){return YL(TA(this._customHeaders),this._fetchOptionsHeaders,this._sdkControlledHeaders)}get _mergedHeaders(){let t={"User-Agent":`langsmith-js/${Mf}`,...this._callerHeaders};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 _openAPIAuth(){let t={...this._callerHeaders},r=Object.keys(t).find(i=>i.toLowerCase()==="x-api-key"),n=this.apiKey;return n===void 0&&r!==void 0&&(n=t[r]??void 0,delete t[r]),n===void 0&&this.workspaceId===void 0&&(t["X-API-Key"]=null),{apiKey:n,defaultHeaders:Object.keys(t).length>0?t:void 0}}get headers(){return this._customHeaders}set headers(t){$A(t),this._customHeaders=t??{}}_getOpenAPIBaseUrl(){let t=this.apiUrl.replace(/\/$/,"");for(let r of["/api/v1","/api"])if(t.endsWith(r))return t.slice(0,-r.length);return t}get openAPIClient(){let t=this._openAPIAuth,r=JSON.stringify([t.apiKey,t.defaultHeaders]);return(this._openAPIClient===void 0||this._openAPIClientSignature!==r)&&(this._openAPIClientSignature=r,this._openAPIClient=this._newOpenAPIClient(t)),this._openAPIClient}_newOpenAPIClient(t=this._openAPIAuth){let{method:r,body:n,signal:i,...o}=this.fetchOptions;return new ze({apiKey:t.apiKey,tenantID:this.workspaceId,baseURL:this._getOpenAPIBaseUrl(),timeout:this.timeout_ms,fetch:this._fetch,fetchOptions:o,defaultHeaders:t.defaultHeaders})}_getPlatformEndpointPath(t){return this.apiUrl.slice(-3)!=="/v1"&&this.apiUrl.slice(-4)!=="/v1/"?`/v1/platform/${t}`:`/platform/${t}`}get evaluators(){return this._checkStainlessVersion("0.16.0"),this.openAPIClient.onlineEvaluators}get runs(){return this._checkStainlessVersion("0.16.0"),this.openAPIClient.runs}get sandboxes(){return this._checkStainlessVersion("0.16.0"),this.openAPIClient.sandboxes}get datasets(){return this._checkStainlessVersion("0.16.0"),this.openAPIClient.datasets}get annotationQueues(){return this._checkStainlessVersion("0.16.14"),this.openAPIClient.annotationQueues}get threads(){return this._checkStainlessVersion("0.16.0"),this.openAPIClient.threads}get traces(){return this._checkStainlessVersion("0.16.0"),this.openAPIClient.traces}get public(){return this._checkStainlessVersion("0.16.0"),this.openAPIClient.public}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}async processError(t){if(this.anonymizer==null)return t;let r=await this.anonymizer({error:t});return typeof r?.error=="string"?r.error:t}_filterNewTokenEvents(t){return!t||t.length===0?t:t.map(r=>{if(r.name==="new_token"){let{kwargs:n,...i}=r;return i}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.error!==void 0&&(r.error=await this.processError(r.error)),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 n=r?.toString()??"",i=`${this.apiUrl}${t}?${n}`;return await this.caller.call(async()=>{let a=await this._fetch(i,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(a,`fetch ${t}`),a})}async _get(t,r){return(await this._getResponse(t,r)).json()}async*_getPaginated(t,r=new URLSearchParams,n){let i=Number(r.get("offset"))||0,o=Number(r.get("limit"))||100;for(;;){r.set("offset",String(i)),r.set("limit",String(o));let a=`${this.apiUrl}${t}?${r}`,s=await this.caller.call(async()=>{let u=await this._fetch(a,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(u,`fetch ${t}`),u}),c=n?n(await s.json()):await s.json();if(c.length===0||(yield c,c.length<o))break;i+=c.length}}async*_getCursorPaginatedList(t,r=null,n="POST",i="runs"){let o=r?{...r}:{};for(;;){let a=JSON.stringify(o),c=await(await this.caller.call(async()=>{let l=await this._fetch(`${this.apiUrl}${t}`,{method:n,headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:a});return await X(l,`fetch ${t}`),l})).json();if(!c||!c[i])break;yield c[i];let u=c.cursors;if(!u||!u.next)break;o.cursor=u.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 n=[];for(let i of t)this.filteredPostUuids.has(i.trace_id)?i.id===i.trace_id&&this.filteredPostUuids.delete(i.trace_id):n.push(i);return n}else{let n=[];for(let i of t){let o=i.trace_id??i.id;this.filteredPostUuids.has(o)||(i.id===o?this._shouldSample()?n.push(i):this.filteredPostUuids.add(o):n.push(i))}return n}}async _getBatchSizeLimitBytes(){let t=await this._ensureServerInfo();return this.batchSizeBytesLimit??t?.batch_ingest_config?.size_limit_bytes??KL}async _getBatchSizeLimit(){let t=await this._ensureServerInfo();return this.batchSizeLimit??t?.batch_ingest_config?.size_limit??XL}async _getDatasetExamplesMultiPartSupport(){return(await this._ensureServerInfo()).instance_flags?.dataset_examples_multipart_enabled??!1}drainAutoBatchQueue({batchSizeLimitBytes:t,batchSizeLimit:r}){let n=[];for(;this.autoBatchQueue.items.length>0;){let[i,o]=this.autoBatchQueue.pop({upToSizeBytes:t,upToSize:r});if(!i.length){o();break}let a=i.reduce((u,l)=>{let d=l.apiUrl??this.apiUrl,f=l.apiKey??this.apiKey,p=l.workspaceId??this.workspaceId,h=l.apiKey===this.apiKey&&l.apiUrl===this.apiUrl&&l.workspaceId===this.workspaceId?"default":`${d}|${f}|${p??""}`;return u[h]||(u[h]=[]),u[h].push(l),u},{}),s=[];for(let[u,l]of Object.entries(a)){let d=u==="default",f=d?[]:u.split("|"),p=f[2],m=this._processBatch(l,{apiUrl:d?void 0:f[0],apiKey:d?void 0:f[1],workspaceId:d||!p?void 0:p});s.push(m)}let c=Promise.all(s).finally(o);n.push(c)}return Promise.all(n)}static async _writeTraceToFallbackDir(t,r,n,i,o){try{let a=typeof r=="string"?Buffer.from(r,"utf8"):Buffer.from(r),s=JSON.stringify({version:1,endpoint:i,headers:n,body_base64:a.toString("base64")}),c=`trace_${Date.now()}_${Ea().slice(0,8)}.json`,u=wn.join(t,c);if(e._fallbackDirsCreated.has(t)||(await Pf(t),e._fallbackDirsCreated.add(t)),o!==void 0&&o>0)try{let d=(await dT(t)).filter(p=>p.startsWith("trace_")&&p.endsWith(".json")),f=0;for(let p of d){let{size:m}=await fT(wn.join(t,p));f+=m}if(f>=o){console.warn(`Could not write trace to fallback dir ${t} as it's already over size limit (${f} bytes >= ${o} bytes). Increase LANGSMITH_FAILED_TRACES_MAX_MB if possible.`);return}}catch{}await nc(u,s),console.warn(`LangSmith trace upload failed; data saved to ${u} for later replay.`)}catch(a){console.error(`LangSmith tracing error: could not write trace to fallback dir ${t}:`,a)}}async _processBatch(t,r){if(!t.length)return;let n=t.reduce((i,o)=>i+(o.size??0),0);try{if(this.langSmithToOTELTranslator!==void 0)this._sendBatchToOTELTranslator(t);else{let i={runCreates:t.filter(s=>s.action==="create").map(s=>s.item),runUpdates:t.filter(s=>s.action==="update").map(s=>s.item)},o=await this._ensureServerInfo();if(!this._multipartDisabled&&(o?.batch_ingest_config?.use_multipart_endpoint??!0)){let s=!this._runCompressionDisabled&&o?.instance_flags?.gzip_body_enabled;try{await this.multipartIngestRuns(i,{...r,useGzip:s,sizeBytes:n})}catch(c){if(sp(c))this._multipartDisabled=!0,await this.batchIngestRuns(i,{...r,sizeBytes:n});else throw c}}else await this.batchIngestRuns(i,{...r,sizeBytes:n})}}catch(i){console.error("Error exporting batch:",i)}}_sendBatchToOTELTranslator(t){if(this.langSmithToOTELTranslator!==void 0){let r=new Map,n=[];for(let i of t)i.item.id&&i.otelContext&&(r.set(i.item.id,i.otelContext),i.action==="create"?n.push({operation:"post",id:i.item.id,trace_id:i.item.trace_id??i.item.id,run:i.item}):n.push({operation:"patch",id:i.item.id,trace_id:i.item.trace_id??i.item.id,run:i.item}));this.langSmithToOTELTranslator.exportBatch(n,r)}}async processRunOperation(t){clearTimeout(this.autoBatchTimeout),this.autoBatchTimeout=void 0,t.item=EA(t.item,this.cachedLSEnvVarsForMetadata,this.omitTracedRuntimeInfo);let r=this.autoBatchQueue.push(t);if(this.manualFlushMode)return r;let n=await this._getBatchSizeLimitBytes(),i=await this._getBatchSizeLimit();return(this.autoBatchQueue.sizeBytes>n||this.autoBatchQueue.items.length>i)&&this._trackDrain(this.drainAutoBatchQueue({batchSizeLimitBytes:n,batchSizeLimit:i})),this.autoBatchQueue.items.length>0&&(this.autoBatchTimeout=setTimeout(()=>{this.autoBatchTimeout=void 0,this._trackDrain(this.drainAutoBatchQueue({batchSizeLimitBytes:n,batchSizeLimit:i}))},this.autoBatchAggregationDelayMs)),r}async _getServerInfo(){let r=await(await this.caller.call(async()=>{let n=await this._fetch(`${this.apiUrl}/info`,{method:"GET",headers:{...this._mergedHeaders,Accept:"application/json"},signal:AbortSignal.timeout(JL),...this.fetchOptions});return await X(n,"get server info"),n})).json();return this.debug&&console.log(`
130
- === LangSmith Server Configuration ===
131
- `+JSON.stringify(r,null,2)+`
132
- `),r}_checkStainlessVersion(t){this._stainlessVersionsChecked.has(t)||(this._stainlessVersionsChecked.add(t),this._ensureServerInfo().then(r=>{qL(r?.version,t)}).catch(()=>{}))}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 _supportsSDBQuery(){return(await this._ensureServerInfo()).instance_flags?.sdb_query_enabled===!0}async _checkFeedbackSessionId(){let t="https://docs.langchain.com/langsmith/smithdb-sdk-migration#feedback-create",r=await this._ensureServerInfo();if(sA(r.instance_flags)===il.SMITHDB_ONLY)throw new Error(`sessionId must be provided when creating feedback for a run: this deployment cannot locate the run without it. See ${t}`);zt(`Creating feedback for a run without sessionId is deprecated and will stop working in a future release. See ${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=Uf(),r=vT();if(this.langSmithToOTELTranslator!==void 0){let n=t.getActiveSpan();if(n)return t.setSpan(r.active(),n)}}async createRun(t,r){if(!this._filterForSampling([t]).length)return;let n={...this._mergedHeaders,"Content-Type":"application/json"},i=t.project_name;delete t.project_name;let o=await this.prepareRunCreateOrUpdateInputs({session_name:i,...t,start_time:t.start_time??Date.now()});if(this.autoBatchTracing&&o.trace_id!==void 0&&o.dotted_order!==void 0){let c=this._cloneCurrentOTELContext();this.processRunOperation({action:"create",item:o,otelContext:c,apiKey:r?.apiKey,apiUrl:r?.apiUrl,workspaceId:r?.workspaceId}).catch(console.error);return}let a=EA(o,this.cachedLSEnvVarsForMetadata,this.omitTracedRuntimeInfo);r?.apiKey!==void 0&&(n["x-api-key"]=r.apiKey),r?.workspaceId!==void 0&&(n["x-tenant-id"]=r.workspaceId);let s=er(a,`Creating run with id: ${a.id}`);await this.caller.call(async()=>{let c=await this._fetch(`${r?.apiUrl??this.apiUrl}/runs`,{method:"POST",headers:n,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:s});return await X(c,"create run",!0),c})}async batchIngestRuns({runCreates:t,runUpdates:r},n){if(t===void 0&&r===void 0)return;let i=await Promise.all(t?.map(c=>this.prepareRunCreateOrUpdateInputs(c))??[]),o=await Promise.all(r?.map(c=>this.prepareRunCreateOrUpdateInputs(c))??[]);if(i.length>0&&o.length>0){let c=i.reduce((l,d)=>(d.id&&(l[d.id]=d),l),{}),u=[];for(let l of o)l.id!==void 0&&c[l.id]?c[l.id]={...c[l.id],...l}:u.push(l);i=Object.values(c),o=u}let a={post:i,patch:o};if(!a.post.length&&!a.patch.length)return;let s={post:[],patch:[]};for(let c of["post","patch"]){let u=c,l=a[u].reverse(),d=l.pop();for(;d!==void 0;)s[u].push(d),d=l.pop()}if(s.post.length>0||s.patch.length>0){let c=s.post.map(u=>u.id).concat(s.patch.map(u=>u.id)).join(",");await this._postBatchIngestRuns(await this._serializeBody(s,`Ingesting runs with ids: ${c}`),n)}}async _postBatchIngestRuns(t,r){let n={...this._mergedHeaders,"Content-Type":"application/json",Accept:"application/json"};r?.apiKey!==void 0&&(n["x-api-key"]=r.apiKey),r?.workspaceId!==void 0&&(n["x-tenant-id"]=r.workspaceId),await this.batchIngestCaller.callWithOptions({sizeBytes:r?.sizeBytes},async()=>{let i=await this._fetch(`${r?.apiUrl??this.apiUrl}/runs/batch`,{method:"POST",headers:n,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:t});return await X(i,"batch create run",!0),i})}async multipartIngestRuns({runCreates:t,runUpdates:r},n){if(t===void 0&&r===void 0)return;let i={},o=[];for(let d of t??[]){let f=await this.prepareRunCreateOrUpdateInputs(d);f.id!==void 0&&f.attachments!==void 0&&(i[f.id]=f.attachments),delete f.attachments,o.push(f)}let a=[];for(let d of r??[])a.push(await this.prepareRunCreateOrUpdateInputs(d));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 creating a run');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 updating a run');if(o.length>0&&a.length>0){let d=o.reduce((p,m)=>(m.id&&(p[m.id]=m),p),{}),f=[];for(let p of a)p.id!==void 0&&d[p.id]?d[p.id]={...d[p.id],...p}:f.push(p);o=Object.values(d),a=f}if(o.length===0&&a.length===0)return;let u=[],l=[];for(let[d,f]of[["post",o],["patch",a]])for(let p of f){let{inputs:m,outputs:h,events:_,extra:y,error:w,serialized:x,attachments:S,...E}=p,C={inputs:m,outputs:h,events:_,extra:y,error:w,serialized:x},T=await this._serializeBody(E,`Serializing for multipart ingestion of run with id: ${E.id}`);l.push({name:`${d}.${E.id}`,payload:new Blob([T],{type:`application/json; length=${T.length}`})});for(let[b,L]of Object.entries(C)){if(L===void 0)continue;let N=await this._serializeBody(L,`Serializing ${b} for multipart ingestion of run with id: ${E.id}`);l.push({name:`${d}.${E.id}.${b}`,payload:new Blob([N],{type:`application/json; length=${N.length}`})})}if(E.id!==void 0){let b=i[E.id];if(b){delete i[E.id];for(let[L,N]of Object.entries(b)){let W,ie;if(Array.isArray(N)?[W,ie]=N:(W=N.mimeType,ie=N.data),L.includes(".")){console.warn(`Skipping attachment '${L}' for run ${E.id}: Invalid attachment name. Attachment names must not contain periods ('.'). Please rename the attachment and try again.`);continue}l.push({name:`attachment.${E.id}.${L}`,payload:new Blob([ie],{type:`${W}; length=${ie.byteLength}`})})}}}u.push(`trace=${E.trace_id},id=${E.id}`)}await this._sendMultipartRequest(l,u.join("; "),n)}async _createNodeFetchBody(t,r){let n=[];for(let a of t)n.push(new Blob([`--${r}\r
133
- `])),n.push(new Blob([`Content-Disposition: form-data; name="${a.name}"\r
134
- `,`Content-Type: ${a.payload.type}\r
135
- \r
136
- `])),n.push(a.payload),n.push(new Blob([`\r
137
- `]));return n.push(new Blob([`--${r}--\r
138
- `])),await new Blob(n).arrayBuffer()}async _createMultipartStream(t,r){let n=new TextEncoder;return new ReadableStream({async start(o){let a=async s=>{typeof s=="string"?o.enqueue(n.encode(s)):o.enqueue(s)};for(let s of t){await a(`--${r}\r
139
- `),await a(`Content-Disposition: form-data; name="${s.name}"\r
140
- `),await a(`Content-Type: ${s.payload.type}\r
141
- \r
142
- `);let u=s.payload.stream().getReader();try{let l;for(;!(l=await u.read()).done;)o.enqueue(l.value)}finally{u.releaseLock()}await a(`\r
143
- `)}await a(`--${r}--\r
144
- `),o.close()}})}async _sendMultipartRequest(t,r,n){let i="----LangSmithFormBoundary"+Math.random().toString(36).slice(2),o=()=>this._createNodeFetchBody(t,i),a=()=>this._createMultipartStream(t,i),s=async c=>this.batchIngestCaller.callWithOptions({sizeBytes:n?.sizeBytes},async()=>{let u=await c(),l={...this._mergedHeaders,"Content-Type":`multipart/form-data; boundary=${i}`};n?.apiKey!==void 0&&(l["x-api-key"]=n.apiKey),n?.workspaceId!==void 0&&(l["x-tenant-id"]=n.workspaceId);let d=u;n?.useGzip&&typeof u=="object"&&"pipeThrough"in u&&(d=u.pipeThrough(new CompressionStream("gzip")),l["Content-Encoding"]="gzip");let f=await this._fetch(`${n?.apiUrl??this.apiUrl}/runs/multipart`,{method:"POST",headers:l,body:d,duplex:"half",signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(f,"Failed to send multipart request",!0),f});try{let c,u=!1;K$()&&!this.multipartStreamingDisabled&&Yu()!=="bun"?(u=!0,c=await s(a)):c=await s(o),(!this.multipartStreamingDisabled||u)&&c.status===422&&(n?.apiUrl??this.apiUrl)!==cp&&(console.warn(`Streaming multipart upload to ${n?.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(o))}catch(c){if(sp(c))throw c;if(console.warn(`${c.message.trim()}
145
-
146
- Context: ${r}`),this.failedTracesDir){let u=await this._createNodeFetchBody(t,i).catch(()=>null);u&&await e._writeTraceToFallbackDir(this.failedTracesDir,u,{"Content-Type":`multipart/form-data; boundary=${i}`},"runs/multipart",this.failedTracesMaxBytes)}}}async updateRun(t,r,n){de(t),r.inputs&&(r.inputs=await this.processInputs(r.inputs)),r.outputs&&(r.outputs=await this.processOutputs(r.outputs)),r.error&&(r.error=await this.processError(r.error)),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 i={...r,id:t};if(!this._filterForSampling([i],!0).length)return;if(this.autoBatchTracing&&i.trace_id!==void 0&&i.dotted_order!==void 0){let s=this._cloneCurrentOTELContext();if(r.end_time!==void 0&&i.parent_run_id===void 0&&this.blockOnRootRunFinalization&&!this.manualFlushMode){await this.processRunOperation({action:"update",item:i,otelContext:s,apiKey:n?.apiKey,apiUrl:n?.apiUrl,workspaceId:n?.workspaceId}).catch(console.error);return}else this.processRunOperation({action:"update",item:i,otelContext:s,apiKey:n?.apiKey,apiUrl:n?.apiUrl,workspaceId:n?.workspaceId}).catch(console.error);return}let o={...this._mergedHeaders,"Content-Type":"application/json"};n?.apiKey!==void 0&&(o["x-api-key"]=n.apiKey),n?.workspaceId!==void 0&&(o["x-tenant-id"]=n.workspaceId);let a=er(r,`Serializing payload to update run with id: ${t}`);await this.caller.call(async()=>{let s=await this._fetch(`${n?.apiUrl??this.apiUrl}/runs/${t}`,{method:"PATCH",headers:o,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:a});return await X(s,"update run",!0),s})}async readRun(t,{loadChildRuns:r}={loadChildRuns:!1}){return zt("readRun() is deprecated and will be removed after Jan 31, 2027. Use client.runs.retrieve() instead. See https://docs.langchain.com/langsmith/smithdb-sdk-migration#runs-retrieve for the migration guide.",{type:"DeprecationWarning",code:"LANGSMITH_DEPRECATED_READ_RUN"}),this._readRun(t,{loadChildRuns:r})}async _readRun(t,{loadChildRuns:r}={loadChildRuns:!1}){de(t);let n=_c(await this._get(`/runs/${t}`));return r&&(n=await this._loadChildRuns(n)),n}async getRunUrl({runId:t,run:r,projectOpts:n}){if(zt("getRunUrl() is deprecated and will be removed after Jan 31, 2027. Use client.runs.getURL() instead. See https://docs.langchain.com/langsmith/smithdb-sdk-migration#runs-get-url for the migration guide.",{type:"DeprecationWarning",code:"LANGSMITH_DEPRECATED_GET_RUN_URL"}),r!==void 0){let i;r.session_id?i=r.session_id:n?.projectName?i=(await this.readProject({projectName:n?.projectName})).id:n?.projectId?i=n?.projectId:i=(await this.readProject({projectName:qe("PROJECT")||"default"})).id;let o=await this._getTenantId();return`${this.getHostUrl()}/o/${o}/projects/p/${i}/r/${r.id}?poll=true`}else if(t!==void 0){let i=await this._readRun(t);if(!i.app_path)throw new Error(`Run ${t} has no app_path`);return`${this.getHostUrl()}${i.app_path}`}else throw new Error("Must provide either runId or run")}async _loadChildRuns(t){let r=await GL(this._listRuns({isRoot:!1,projectId:t.session_id,traceId:t.trace_id})),n={},i={};r.sort((o,a)=>(o?.dotted_order??"").localeCompare(a?.dotted_order??""));for(let o of r){if(o.parent_run_id===null||o.parent_run_id===void 0)throw new Error(`Child run ${o.id} has no parent`);o.dotted_order?.startsWith(t.dotted_order??"")&&o.id!==t.id&&(o.parent_run_id in n||(n[o.parent_run_id]=[]),n[o.parent_run_id].push(o),i[o.id]=o)}t.child_runs=n[t.id]||[];for(let o in n)o!==t.id&&(i[o].child_runs=n[o]);return t}async*listRuns(t){zt("listRuns() is deprecated and will be removed after Jan 31, 2027. Use client.runs.query() instead. See https://docs.langchain.com/langsmith/smithdb-sdk-migration#runs-query for the migration guide.",{type:"DeprecationWarning",code:"LANGSMITH_DEPRECATED_LIST_RUNS"}),yield*this._listRuns(t)}async*_listRuns(t){let{projectId:r,projectName:n,parentRunId:i,traceId:o,referenceExampleId:a,startTime:s,executionOrder:c,isRoot:u,runType:l,error:d,id:f,query:p,filter:m,traceFilter:h,treeFilter:_,limit:y,select:w,order:x}=t,S=[];if(r&&(S=Array.isArray(r)?r:[r]),n){let b=Array.isArray(n)?n:[n],L=await Promise.all(b.map(N=>this.readProject({projectName:N}).then(W=>W.id)));S.push(...L)}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"],C={session:S.length?S:null,run_type:l,reference_example:a,query:p,filter:m,trace_filter:h,tree_filter:_,execution_order:c,parent_run:i,start_time:s?s.toISOString():null,error:d,id:f,limit:y,trace:o,select:w||E,is_root:u,order:x};C.select.includes("child_run_ids")&&zt("Deprecated: 'child_run_ids' in the listRuns select parameter is deprecated and will be removed in a future version.");let T=0;for await(let b of this._getCursorPaginatedList("/runs/query",C)){let L=b.map(_c);if(y){if(T>=y)break;if(L.length+T>y){yield*L.slice(0,y-T);break}T+=L.length,yield*L}else yield*L}}async*listGroupRuns(t){let{projectId:r,projectName:n,groupBy:i,filter:o,startTime:a,endTime:s,limit:c,offset:u}=t,d={session_id:r||(await this.readProject({projectName:n})).id,group_by:i,filter:o,start_time:a?a.toISOString():null,end_time:s?s.toISOString():null,limit:Number(c)||100},f=Number(u)||0,p="/runs/group",m=`${this.apiUrl}${p}`;for(;;){let h={...d,offset:f},_=Object.fromEntries(Object.entries(h).filter(([C,T])=>T!==void 0)),y=JSON.stringify(_),x=await(await this.caller.call(async()=>{let C=await this._fetch(m,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:y});return await X(C,`Failed to fetch ${p}`),C})).json(),{groups:S,total:E}=x;if(S.length===0)break;for(let C of S)yield C;if(f+=S.length,f>=E)break}}async*readThread(t){zt("readThread() is deprecated and will be removed after Jan 31, 2027. Use client.threads.listTraces() instead. See https://docs.langchain.com/langsmith/smithdb-sdk-migration#threads-list-traces for the migration guide.",{type:"DeprecationWarning",code:"LANGSMITH_DEPRECATED_READ_THREAD"});let{threadId:r,projectId:n,projectName:i,isRoot:o=!0,limit:a,filter:s,order:c="asc"}=t;if(!n&&!i)throw new Error("threadId requires projectId or projectName");let u=`eq(thread_id, ${JSON.stringify(r)})`,l=s?`and(${u}, ${s})`:u;yield*this._listRuns({projectId:n??void 0,projectName:i??void 0,isRoot:o,limit:a,filter:l,order:c})}async listThreads(t){zt("listThreads() is deprecated and will be removed after Jan 31, 2027. Use client.threads.query() instead. See https://docs.langchain.com/langsmith/smithdb-sdk-migration#threads-query for the migration guide.",{type:"DeprecationWarning",code:"LANGSMITH_DEPRECATED_LIST_THREADS"});let{projectId:r,projectName:n,limit:i,offset:o=0,filter:a,startTime:s,isRoot:c=!0}=t;if(!r&&!n)throw new Error("Either projectId or projectName must be provided");if(r&&n)throw new Error("Provide exactly one of projectId or projectName");let u=r??(await this.readProject({projectName:n})).id,l=s??new Date(Date.now()-1440*60*1e3),f={session:[u],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:l.toISOString()};a!=null&&(f.filter=a);let p=new Map;for await(let y of this._getCursorPaginatedList("/runs/query",f))for(let w of y){let x=_c(w),S=x.thread_id;if(S){let E=p.get(S)??[];E.push(x),p.set(S,E)}}let m=[];for(let[y,w]of p.entries()){w.sort((T,b)=>{let L=T,N=b,W=L.start_time??"",ie=N.start_time??"";if(W!==ie)return W.localeCompare(ie);let _e=L.dotted_order??"",$e=N.dotted_order??"";return _e.localeCompare($e)});let S=[...w.map(T=>T.start_time).filter(Boolean)].sort(),E=S.length?S[0]:"",C=S.length?S[S.length-1]:"";m.push({thread_id:y,runs:w,count:w.length,filter:"",total_tokens:0,total_cost:null,min_start_time:E,max_start_time:C,latency_p50:0,latency_p99:0,feedback_stats:null,first_inputs:"",last_outputs:"",last_error:null})}m.sort((y,w)=>{let x=y.max_start_time??"";return(w.max_start_time??"").localeCompare(x)});let h=o>0?m.slice(o):m;return i!==void 0?h.slice(0,i):h}async getRunStats({id:t,trace:r,parentRun:n,runType:i,projectNames:o,projectIds:a,referenceExampleIds:s,startTime:c,endTime:u,error:l,query:d,filter:f,traceFilter:p,treeFilter:m,isRoot:h,dataSourceType:_}){let y=a||[];if(o&&(y=[...a||[],...await Promise.all(o.map(T=>this.readProject({projectName:T}).then(b=>b.id)))]),y.length===0)throw new Error("At least one of projectNames or projectIds must be provided.");let x=Object.fromEntries(Object.entries({id:t,trace:r,parent_run:n,run_type:i,session:y,reference_example:s,start_time:c,end_time:u,error:l,query:d,filter:f,trace_filter:p,tree_filter:m,is_root:h,data_source_type:_}).filter(([T,b])=>b!==void 0)),S=JSON.stringify(x);return await(await this.caller.call(async()=>{let T=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:S});return await X(T,"get run stats"),T})).json()}async shareRun(t,{shareId:r}={}){zt("shareRun() is deprecated and will be removed after Jan 31, 2027. Use client.runs.share.create() instead. See https://docs.langchain.com/langsmith/smithdb-sdk-migration#share-and-read-public-runs for the migration guide.",{type:"DeprecationWarning",code:"LANGSMITH_DEPRECATED_SHARE_RUN"});let n={run_id:t,share_token:r||Ea()};de(t);let i=JSON.stringify(n),a=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:i});return await X(s,"share run"),s})).json();if(a===null||!("share_token"in a))throw new Error("Invalid response from server");return`${this.getHostUrl()}/public/${a.share_token}/r`}async unshareRun(t){zt("unshareRun() is deprecated and will be removed after Jan 31, 2027. Use client.runs.share.delete() instead. See https://docs.langchain.com/langsmith/smithdb-sdk-migration#share-and-read-public-runs for the migration guide.",{type:"DeprecationWarning",code:"LANGSMITH_DEPRECATED_UNSHARE_RUN"}),de(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 X(r,"unshare run",!0),r})}async readRunSharedLink(t){zt('readRunSharedLink() is deprecated and will be removed after Jan 31, 2027. Use client.runs.retrieve({ selects: ["SHARE_URL"] }) instead. See https://docs.langchain.com/langsmith/smithdb-sdk-migration#share-and-read-public-runs for the migration guide.',{type:"DeprecationWarning",code:"LANGSMITH_DEPRECATED_READ_RUN_SHARED_LINK"}),de(t);let n=await(await this.caller.call(async()=>{let i=await this._fetch(`${this.apiUrl}/runs/${t}/share`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(i,"read run shared link"),i})).json();if(!(n===null||!("share_token"in n)))return`${this.getHostUrl()}/public/${n.share_token}/r`}async listSharedRuns(t,{runIds:r}={}){zt("listSharedRuns() is deprecated and will be removed after Jan 31, 2027. Use client.public.runs.query() instead. See https://docs.langchain.com/langsmith/smithdb-sdk-migration#share-and-read-public-runs for the migration guide.",{type:"DeprecationWarning",code:"LANGSMITH_DEPRECATED_LIST_SHARED_RUNS"});let n=new URLSearchParams({share_token:t});if(r!==void 0)for(let a of r)n.append("id",a);return de(t),(await(await this.caller.call(async()=>{let a=await this._fetch(`${this.apiUrl}/public/${t}/runs${n}`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(a,"list shared runs"),a})).json()).map(_c)}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),de(t);let i=await(await this.caller.call(async()=>{let o=await this._fetch(`${this.apiUrl}/datasets/${t}/share`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(o,"read dataset shared schema"),o})).json();return i.url=`${this.getHostUrl()}/public/${i.share_token}/d`,i}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 n={dataset_id:t};de(t);let i=JSON.stringify(n),a=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:i});return await X(s,"share dataset"),s})).json();return a.url=`${this.getHostUrl()}/public/${a.share_token}/d`,a}async unshareDataset(t){de(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 X(r,"unshare dataset",!0),r})}async readSharedDataset(t){return de(t),await(await this.caller.call(async()=>{let i=await this._fetch(`${this.apiUrl}/public/${t}/datasets`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(i,"read shared dataset"),i})).json()}async listSharedExamples(t,r){let n={};r?.exampleIds&&(n.id=r.exampleIds);let i=new URLSearchParams;Object.entries(n).forEach(([s,c])=>{Array.isArray(c)?c.forEach(u=>i.append(s,u)):i.append(s,c)});let o=await this.caller.call(async()=>{let s=await this._fetch(`${this.apiUrl}/public/${t}/examples?${i.toString()}`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(s,"list shared examples"),s}),a=await o.json();if(!o.ok)throw"detail"in a?new Error(`Failed to list shared examples.
147
- Status: ${o.status}
148
- Message: ${Array.isArray(a.detail)?a.detail.join(`
149
- `):"Unspecified error"}`):new Error(`Failed to list shared examples: ${o.status} ${o.statusText}`);return a.map(s=>({...s,_hostUrl:this.getHostUrl()}))}async createProject({projectName:t,description:r=null,metadata:n=null,upsert:i=!1,projectExtra:o=null,referenceDatasetId:a=null,numExamples:s=null,numRepetitions:c=null,evaluatorKeys:u=null}){let l=i?"?upsert=true":"",d=`${this.apiUrl}/sessions${l}`,f=o||{};n&&(f.metadata=n);let p={name:t,extra:f,description:r};a!==null&&(p.reference_dataset_id=a),s!=null&&(p.num_examples=s),c!=null&&(p.num_repetitions=c),u!=null&&u.length>0&&(p.evaluator_keys=u);let m=JSON.stringify(p);return await(await this.caller.call(async()=>{let y=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 X(y,"create project"),y})).json()}async updateProject(t,{name:r=null,description:n=null,metadata:i=null,projectExtra:o=null,endTime:a=null}){let s=`${this.apiUrl}/sessions/${t}`,c=o;i&&(c={...c||{},metadata:i});let u=JSON.stringify({name:r,extra:c,description:n,end_time:a?new Date(a).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:u});return await X(f,"update project"),f})).json()}async hasProject({projectId:t,projectName:r}){let n="/sessions",i=new URLSearchParams;if(t!==void 0&&r!==void 0)throw new Error("Must provide either projectName or projectId, not both");if(t!==void 0)de(t),n+=`/${t}`;else if(r!==void 0)i.append("name",r);else throw new Error("Must provide projectName or projectId");let o=await this.caller.call(async()=>{let a=await this._fetch(`${this.apiUrl}${n}?${i}`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(a,"has project"),a});try{let a=await o.json();return o.ok?Array.isArray(a)?a.length>0:!0:!1}catch{return!1}}async readProject({projectId:t,projectName:r,includeStats:n}){let i="/sessions",o=new URLSearchParams;if(t!==void 0&&r!==void 0)throw new Error("Must provide either projectName or projectId, not both");if(t!==void 0)de(t),i+=`/${t}`;else if(r!==void 0)o.append("name",r);else throw new Error("Must provide projectName or projectId");n!==void 0&&o.append("include_stats",n.toString());let a=await this._get(i,o),s;if(Array.isArray(a)){if(a.length===0)throw new Error(`Project[id=${t}, name=${r}] not found`);s=a[0]}else s=a;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 n=await this.readProject({projectId:t,projectName:r}),i=await this._getTenantId();return`${this.getHostUrl()}/o/${i}/projects/p/${n.id}`}async getDatasetUrl({datasetId:t,datasetName:r}){if(t===void 0&&r===void 0)throw new Error("Must provide either datasetName or datasetId");let n=await this.readDataset({datasetId:t,datasetName:r}),i=await this._getTenantId();return`${this.getHostUrl()}/o/${i}/datasets/${n.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:n,referenceDatasetId:i,referenceDatasetName:o,includeStats:a,datasetVersion:s,referenceFree:c,metadata:u}={}){let l=new URLSearchParams;if(t!==void 0)for(let d of t)l.append("id",d);if(r!==void 0&&l.append("name",r),n!==void 0&&l.append("name_contains",n),i!==void 0)l.append("reference_dataset",i);else if(o!==void 0){let d=await this.readDataset({datasetName:o});l.append("reference_dataset",d.id)}a!==void 0&&l.append("include_stats",a.toString()),s!==void 0&&l.append("dataset_version",s),c!==void 0&&l.append("reference_free",c.toString()),u!==void 0&&l.append("metadata",JSON.stringify(u));for await(let d of this._getPaginated("/sessions",l))yield*d}async deleteProject({projectId:t,projectName:r}){let n;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?n=(await this.readProject({projectName:r})).id:n=t,de(n),await this.caller.call(async()=>{let i=await this._fetch(`${this.apiUrl}/sessions/${n}`,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(i,`delete session ${n} (${r})`,!0),i})}async uploadCsv({csvFile:t,fileName:r,inputKeys:n,outputKeys:i,description:o,dataType:a,name:s}){let c=`${this.apiUrl}/datasets/upload`,u=new FormData,l=new Blob([t],{type:"text/csv"});return u.append("file",l,r),n.forEach(p=>{u.append("input_keys",p)}),i.forEach(p=>{u.append("output_keys",p)}),o&&u.append("description",o),a&&u.append("data_type",a),s&&u.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:u});return await X(p,"upload CSV"),p})).json()}async createDataset(t,{description:r,dataType:n,inputsSchema:i,outputsSchema:o,metadata:a}={}){let s={name:t,description:r,extra:{source:"sdk",...a?{metadata:a}:{}}};n&&(s.data_type=n),i&&(s.inputs_schema_definition=i),o&&(s.outputs_schema_definition=o);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 X(d,"create dataset"),d})).json()}async readDataset({datasetId:t,datasetName:r}){let n="/datasets",i=new URLSearchParams({limit:"1"});if(t&&r)throw new Error("Must provide either datasetName or datasetId, not both");if(t)de(t),n+=`/${t}`;else if(r)i.append("name",r);else throw new Error("Must provide datasetName or datasetId");let o=await this._get(n,i),a;if(Array.isArray(o)){if(o.length===0)throw new Error(`Dataset[id=${t}, name=${r}] not found`);a=o[0]}else a=o;return a}async hasDataset({datasetId:t,datasetName:r}){try{return await this.readDataset({datasetId:t,datasetName:r}),!0}catch(n){if(n instanceof Error&&n.message.toLocaleLowerCase().includes("not found"))return!1;throw n}}async diffDatasetVersions({datasetId:t,datasetName:r,fromVersion:n,toVersion:i}){let o=t;if(o===void 0&&r===void 0)throw new Error("Must provide either datasetName or datasetId");if(o!==void 0&&r!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");o===void 0&&(o=(await this.readDataset({datasetName:r})).id);let a=new URLSearchParams({from_version:typeof n=="string"?n:n.toISOString(),to_version:typeof i=="string"?i:i.toISOString()});return await this._get(`/datasets/${o}/versions/diff`,a)}async readDatasetOpenaiFinetuning({datasetId:t,datasetName:r}){let n="/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(`${n}/${t}/openai_ft`)).text()).trim().split(`
150
- `).map(s=>JSON.parse(s))}async*listDatasets({limit:t=100,offset:r=0,datasetIds:n,datasetName:i,datasetNameContains:o,metadata:a}={}){let s="/datasets",c=new URLSearchParams({limit:t.toString(),offset:r.toString()});if(n!==void 0)for(let u of n)c.append("id",u);i!==void 0&&c.append("name",i),o!==void 0&&c.append("name_contains",o),a!==void 0&&c.append("metadata",JSON.stringify(a));for await(let u of this._getPaginated(s,c))yield*u}async updateDataset(t){let{datasetId:r,datasetName:n,...i}=t;if(!r&&!n)throw new Error("Must provide either datasetName or datasetId");let o=r??(await this.readDataset({datasetName:n})).id;de(o);let a=JSON.stringify(i);return await(await this.caller.call(async()=>{let c=await this._fetch(`${this.apiUrl}/datasets/${o}`,{method:"PATCH",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:a});return await X(c,"update dataset"),c})).json()}async updateDatasetTag(t){let{datasetId:r,datasetName:n,asOf:i,tag:o}=t;if(!r&&!n)throw new Error("Must provide either datasetName or datasetId");let a=r??(await this.readDataset({datasetName:n})).id;de(a);let s=JSON.stringify({as_of:typeof i=="string"?i:i.toISOString(),tag:o});await this.caller.call(async()=>{let c=await this._fetch(`${this.apiUrl}/datasets/${a}/tags`,{method:"PUT",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:s});return await X(c,"update dataset tags",!0),c})}async deleteDataset({datasetId:t,datasetName:r}){let n="/datasets",i=t;if(t!==void 0&&r!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");if(r!==void 0&&(i=(await this.readDataset({datasetName:r})).id),i!==void 0)de(i),n+=`/${i}`;else throw new Error("Must provide datasetName or datasetId");await this.caller.call(async()=>{let o=await this._fetch(this.apiUrl+n,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(o,`delete ${n}`,!0),o})}async createExample(t,r,n){if(AA(t)&&(r!==void 0||n!==void 0))throw new Error("Cannot provide outputs or options when using ExampleCreate object");let i=r?n?.datasetId:t.dataset_id,o=r?n?.datasetName:t.dataset_name;if(i===void 0&&o===void 0)throw new Error("Must provide either datasetName or datasetId");if(i!==void 0&&o!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");i===void 0&&(i=(await this.readDataset({datasetName:o})).id);let a=(r?n?.createdAt:t.created_at)||new Date,s;AA(t)?s=t:s={inputs:t,outputs:r,created_at:a?.toISOString(),id:n?.exampleId,metadata:n?.metadata,split:n?.split,source_run_id:n?.sourceRunId,use_source_run_io:n?.useSourceRunIO,use_source_run_attachments:n?.useSourceRunAttachments,attachments:n?.attachments};let c=await this._uploadExamplesMultipart(i,[s]);return await this.readExample(c.example_ids?.[0]??Ea())}async createExamples(t){if(Array.isArray(t)){if(t.length===0)return[];let w=t,x=w[0].dataset_id,S=w[0].dataset_name;if(x===void 0&&S===void 0)throw new Error("Must provide either datasetName or datasetId");if(x!==void 0&&S!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");x===void 0&&(x=(await this.readDataset({datasetName:S})).id);let E=await this._uploadExamplesMultipart(x,w);return await Promise.all(E.example_ids.map(T=>this.readExample(T)))}let{inputs:r,outputs:n,metadata:i,splits:o,sourceRunIds:a,useSourceRunIOs:s,useSourceRunAttachments:c,attachments:u,exampleIds:l,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,x)=>({dataset_id:p,inputs:w,outputs:n?.[x],metadata:i?.[x],split:o?.[x],id:l?.[x],attachments:u?.[x],source_run_id:a?.[x],use_source_run_io:s?.[x],use_source_run_attachments:c?.[x]})),_=await this._uploadExamplesMultipart(p,h);return await Promise.all(_.example_ids.map(w=>this.readExample(w)))}async createLLMExample(t,r,n){return this.createExample({input:t},{output:r},n)}async createChatExample(t,r,n){let i=t.map(a=>hy(a)?gy(a):a),o=hy(r)?gy(r):r;return this.createExample({input:i},{output:o},n)}async readExample(t){de(t);let r=`/examples/${t}`,n=await this._get(r),{attachment_urls:i,...o}=n,a=o;return i&&(a.attachments=Object.entries(i).reduce((s,[c,u])=>(s[c.slice(11)]={presigned_url:u.presigned_url,mime_type:u.mime_type},s),{})),a}async*listExamples({datasetId:t,datasetName:r,exampleIds:n,asOf:i,splits:o,inlineS3Urls:a,metadata:s,limit:c,offset:u,filter:l,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=i?typeof i=="string"?i:i?.toISOString():void 0;m&&p.append("as_of",m);let h=a??!0;if(p.append("inline_s3_urls",h.toString()),n!==void 0)for(let y of n)p.append("id",y);if(o!==void 0)for(let y of o)p.append("splits",y);if(s!==void 0){let y=JSON.stringify(s);p.append("metadata",y)}c!==void 0&&p.append("limit",c.toString()),u!==void 0&&p.append("offset",u.toString()),l!==void 0&&p.append("filter",l),d===!0&&["attachment_urls","outputs","metadata"].forEach(y=>p.append("select",y));let _=0;for await(let y of this._getPaginated("/examples",p)){for(let w of y){let{attachment_urls:x,...S}=w,E=S;x&&(E.attachments=Object.entries(x).reduce((C,[T,b])=>(C[T.slice(11)]={presigned_url:b.presigned_url,mime_type:b.mime_type||void 0},C),{})),yield E,_++}if(c!==void 0&&_>=c)break}}async deleteExample(t){de(t);let r=`/examples/${t}`;await this.caller.call(async()=>{let n=await this._fetch(this.apiUrl+r,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(n,`delete ${r}`,!0),n})}async deleteExamples(t,r){if(t.forEach(n=>de(n)),r?.hardDelete){let n=this._getPlatformEndpointPath("datasets/examples/delete");await this.caller.call(async()=>{let i=await this._fetch(`${this.apiUrl}${n}`,{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 X(i,"hard delete examples",!0),i})}else{let n=new URLSearchParams;t.forEach(i=>n.append("example_ids",i)),await this.caller.call(async()=>{let i=await this._fetch(`${this.apiUrl}/examples?${n.toString()}`,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(i,"delete examples",!0),i})}}async updateExample(t,r){let n;r?n=t:n=t.id,de(n);let i;r?i={id:n,...r}:i=t;let o;return i.dataset_id!==void 0?o=i.dataset_id:o=(await this.readExample(n)).dataset_id,this._updateExamplesMultipart(o,[i])}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:n,tag:i}){let o;if(t?o=t:o=(await this.readDataset({datasetName:r})).id,de(o),n&&i||!n&&!i)throw new Error("Exactly one of asOf and tag must be specified.");let a=new URLSearchParams;return n!==void 0&&a.append("as_of",typeof n=="string"?n:n.toISOString()),i!==void 0&&a.append("tag",i),await(await this.caller.call(async()=>{let c=await this._fetch(`${this.apiUrl}/datasets/${o}/version?${a.toString()}`,{method:"GET",headers:{...this._mergedHeaders},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(c,"read dataset version"),c})).json()}async listDatasetSplits({datasetId:t,datasetName:r,asOf:n}){let i;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?i=(await this.readDataset({datasetName:r})).id:i=t,de(i);let o=new URLSearchParams,a=n?typeof n=="string"?n:n?.toISOString():void 0;return a&&o.append("as_of",a),await this._get(`/datasets/${i}/splits`,o)}async updateDatasetSplits({datasetId:t,datasetName:r,splitName:n,exampleIds:i,remove:o=!1}){let a;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?a=(await this.readDataset({datasetName:r})).id:a=t,de(a);let s={split_name:n,examples:i.map(u=>(de(u),u)),remove:o},c=JSON.stringify(s);await this.caller.call(async()=>{let u=await this._fetch(`${this.apiUrl}/datasets/${a}/splits`,{method:"PUT",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:c});return await X(u,"update dataset splits",!0),u})}async createFeedback(t,r,n){let{runId:i=null,key:o,score:a,value:s,correction:c,comment:u,sourceInfo:l,feedbackSourceType:d="api",sourceRunId:f,feedbackId:p,feedbackConfig:m,projectId:h,comparativeExperimentId:_,sessionId:y,startTime:w,extendTraceRetention:x}=typeof t=="object"&&t!==null?t:{runId:t,key:r,...n};if(!i&&!h)throw new Error("One of runId or projectId must be provided");if(i&&h)throw new Error("Only one of runId or projectId can be provided");i&&y===void 0&&await this._checkFeedbackSessionId();let S={type:d??"api",metadata:l??{}};f!==void 0&&S?.metadata!==void 0&&!S.metadata.__run&&(S.metadata.__run={run_id:f}),S?.metadata!==void 0&&S.metadata.__run?.run_id!==void 0&&de(S.metadata.__run.run_id);let E={id:p??Ys(),run_id:i,key:o,score:IA(a),value:s,correction:c,comment:u,feedback_source:S,comparative_experiment_id:_,feedbackConfig:m,session_id:y??h,start_time:w,extend_trace_retention:x},C=JSON.stringify(E),T=`${this.apiUrl}/feedback`;return await this.caller.call(async()=>{let b=await this._fetch(T,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:C});return await X(b,"create feedback",!0),b}),E}async updateFeedback(t,{score:r,value:n,correction:i,comment:o}){let a={};r!=null&&(a.score=IA(r)),n!=null&&(a.value=n),i!=null&&(a.correction=i),o!=null&&(a.comment=o),de(t);let s=JSON.stringify(a);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 X(c,"update feedback",!0),c})}async readFeedback(t){de(t);let r=`/feedback/${t}`;return await this._get(r)}async deleteFeedback(t){de(t);let r=`/feedback/${t}`;await this.caller.call(async()=>{let n=await this._fetch(this.apiUrl+r,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(n,`delete ${r}`,!0),n})}async*listFeedback({runIds:t,feedbackKeys:r,feedbackSourceTypes:n}={}){let i=new URLSearchParams;if(t)for(let o of t)de(o),i.append("run",o);if(r)for(let o of r)i.append("key",o);if(n)for(let o of n)i.append("source",o);for await(let o of this._getPaginated("/feedback",i))yield*o}async createPresignedFeedbackToken(t,r,{expiration:n,feedbackConfig:i}={}){let o={run_id:t,feedback_key:r,feedback_config:i};n?typeof n=="string"?o.expires_at=n:(n?.hours||n?.minutes||n?.days)&&(o.expires_in=n):o.expires_in={hours:3};let a=JSON.stringify(o);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:a});return await X(c,"create presigned feedback token"),c})).json()}async createComparativeExperiment({name:t,experimentIds:r,referenceDatasetId:n,createdAt:i,description:o,metadata:a,id:s}){if(r.length===0)throw new Error("At least one experiment is required");if(n||(n=(await this.readProject({projectId:r[0]})).reference_dataset_id),!n==null)throw new Error("A reference dataset is required");let c={id:s,name:t,experiment_ids:r,reference_dataset_id:n,description:o,created_at:(i??new Date)?.toISOString(),extra:{}};a&&(c.extra.metadata=a);let u=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:u});return await X(d,"create comparative experiment"),d})).json()}async*listPresignedFeedbackTokens(t){de(t);let r=new URLSearchParams({run_id:t});for await(let n of this._getPaginated("/feedback/tokens",r))yield*n}_selectEvalResults(t){let r;return"results"in t?r=t.results:Array.isArray(t)?r=t:r=[t],r}async _logEvaluationFeedback(t,r,n,i){let o=this._selectEvalResults(t),a=[];for(let s of o){let c=n||{};s.evaluatorInfo&&(c={...s.evaluatorInfo,...c});let u=null;s.targetRunId?u=s.targetRunId:r&&(u=r.id),a.push(await this.createFeedback(u,s.key,{score:s.score,value:s.value,comment:s.comment,correction:s.correction,sourceInfo:c,sourceRunId:s.sourceRunId,feedbackConfig:s.feedbackConfig,feedbackSourceType:"model",sessionId:r?.session_id??i,startTime:r?.start_time}))}return[o,a]}async logEvaluationFeedback(t,r,n,i){if(t!=null&&typeof t=="object"&&"evaluatorResponse"in t){let[a]=await this._logEvaluationFeedback(t.evaluatorResponse,t.run,t.sourceInfo,t.projectId);return a}let[o]=await this._logEvaluationFeedback(t,r,n,i);return o}async createFeedbackConfig(t){let{feedbackKey:r,feedbackConfig:n,isLowerScoreBetter:i=!1}=t,o={feedback_key:r,feedback_config:n,is_lower_score_better:i};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(o)});return await X(s,"create feedback config"),s})).json()}async*listFeedbackConfigs(t={}){let{feedbackKeys:r,nameContains:n,limit:i}=t,o=new URLSearchParams;r&&r.forEach(s=>{o.append("key",s)}),n&&o.append("name_contains",n),o.append("limit",(i!==void 0?Math.min(i,100):100).toString());let a=0;for await(let s of this._getPaginated("/feedback-configs",o))if(yield*s,a+=s.length,i!==void 0&&a>=i)break}async updateFeedbackConfig(t,r={}){let{feedbackConfig:n,isLowerScoreBetter:i}=r,o={feedback_key:t};return n!==void 0&&(o.feedback_config=n),i!==void 0&&(o.is_lower_score_better=i),(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(o)});return await X(s,"update feedback config"),s})).json()}async deleteFeedbackConfig(t){let r=new URLSearchParams({feedback_key:t});await this.caller.call(async()=>{let n=await this._fetch(`${this.apiUrl}/feedback-configs?${r}`,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(n,"delete feedback config",!0),n})}async*listAnnotationQueues(t={}){let{queueIds:r,name:n,nameContains:i,limit:o}=t,a=new URLSearchParams;r&&r.forEach((c,u)=>{de(c,`queueIds[${u}]`),a.append("ids",c)}),n&&a.append("name",n),i&&a.append("name_contains",i),a.append("limit",(o!==void 0?Math.min(o,100):100).toString());let s=0;for await(let c of this._getPaginated("/annotation-queues",a))if(yield*c,s++,o!==void 0&&s>=o)break}async createAnnotationQueue(t){let{name:r,description:n,queueId:i,rubricInstructions:o,rubricItems:a}=t,s={name:r,description:n,id:i||Ea(),rubric_instructions:o,rubric_items:a},c=JSON.stringify(Object.fromEntries(Object.entries(s).filter(([l,d])=>d!==void 0)));return(await this.caller.call(async()=>{let l=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 X(l,"create annotation queue"),l})).json()}async readAnnotationQueue(t){return(await this.caller.call(async()=>{let n=await this._fetch(`${this.apiUrl}/annotation-queues/${de(t,"queueId")}`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(n,"read annotation queue"),n})).json()}async updateAnnotationQueue(t,r){let{name:n,description:i,rubricInstructions:o,rubricItems:a}=r,s={};n!==void 0&&(s.name=n),i!==void 0&&(s.description=i),o!==void 0&&(s.rubric_instructions=o),a!==void 0&&(s.rubric_items=a);let c=JSON.stringify(s);await this.caller.call(async()=>{let u=await this._fetch(`${this.apiUrl}/annotation-queues/${de(t,"queueId")}`,{method:"PATCH",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:c});return await X(u,"update annotation queue",!0),u})}async deleteAnnotationQueue(t){await this.caller.call(async()=>{let r=await this._fetch(`${this.apiUrl}/annotation-queues/${de(t,"queueId")}`,{method:"DELETE",headers:{...this._mergedHeaders,Accept:"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(r,"delete annotation queue",!0),r})}async addRunsToAnnotationQueue(t,r){let n=`${this.apiUrl}/annotation-queues/${de(t,"queueId")}/runs`,i=r.every(s=>typeof s=="string"),o,a;i?(zt("Passing run IDs as strings to addRunsToAnnotationQueue() is deprecated and will be removed after Jan 31, 2027. Use RunKey[] instead. See https://docs.langchain.com/langsmith/smithdb-sdk-migration#annotation-queues-add-runs for the migration guide.",{type:"DeprecationWarning",code:"LANGSMITH_DEPRECATED_ADD_RUNS_STRING_IDS"}),o=n,a=JSON.stringify(r.map((s,c)=>de(s,`runs[${c}]`).toString()))):(o=`${n}/by-key`,a=JSON.stringify(r.map((s,c)=>{let u={run_id:de(s.runId,`runs[${c}].runId`).toString(),session_id:de(s.sessionId,`runs[${c}].sessionId`).toString(),start_time:typeof s.startTime=="string"?s.startTime:new Date(s.startTime).toISOString()};return s.sourceProposedExampleId!=null&&(u.source_proposed_example_id=de(s.sourceProposedExampleId,`runs[${c}].sourceProposedExampleId`).toString()),u}))),await this.caller.call(async()=>{let s=await this._fetch(o,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:a});return await X(s,"add runs to annotation queue",!0),s})}async getRunFromAnnotationQueue(t,r){let n=`/annotation-queues/${de(t,"queueId")}/run`,o=await(await this.caller.call(async()=>{let a=await this._fetch(`${this.apiUrl}${n}/${r}`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(a,"get run from annotation queue"),a})).json();return _c(o)}async*listRunsFromAnnotationQueue(t,r={}){let{status:n,limit:i}=r,o=new URLSearchParams,a=i!==void 0&&Number.isFinite(i)?Math.min(i,100):100;n&&o.append("status",n),o.append("limit",a.toString());let s=0,c=`/annotation-queues/${de(t,"queueId")}/runs`;for await(let u of this._getPaginated(c,o))for(let l of u)if(yield _c(l),s++,s>=a)return}async deleteRunFromAnnotationQueue(t,r){await this.caller.call(async()=>{let n=await this._fetch(`${this.apiUrl}/annotation-queues/${de(t,"queueId")}/runs/${de(r,"queueRunId")}`,{method:"DELETE",headers:{...this._mergedHeaders,Accept:"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(n,"delete run from annotation queue",!0),n})}async getSizeFromAnnotationQueue(t){return(await this.caller.call(async()=>{let n=await this._fetch(`${this.apiUrl}/annotation-queues/${de(t,"queueId")}/size`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(n,"get size from annotation queue"),n})).json()}async _currentTenantIsOwner(t){let r=await this._getSettings();return t=="-"||r.tenant_handle===t}async _ownerConflictError(t,r){let n=await this._getSettings();return new Error(`Cannot ${t} for another tenant.
151
-
152
- Current tenant: ${n.tenant_handle}
153
-
154
- Requested tenant: ${r}`)}async _getLatestCommitHash(t){let n=await(await this.caller.call(async()=>{let i=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 X(i,"get latest commit hash"),i})).json();if(n.commits.length!==0)return n.commits[0].commit_hash}async _createCommitTags(t,r,n){let i=typeof n=="string"?[n]:n;await Promise.all(i.map(async o=>this.caller.call(async()=>{let a=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:o,commit_id:r})});return await X(a,"create commit tag"),a})))}async _likeOrUnlikePrompt(t,r){let[n,i,o]=Qt(t),a=JSON.stringify({like:r});return(await this.caller.call(async()=>{let c=await this._fetch(`${this.apiUrl}/likes/${n}/${i}`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:a});return await X(c,`${r?"like":"unlike"} prompt`),c})).json()}async _getPromptUrl(t){let[r,n,i]=Qt(t);if(await this._currentTenantIsOwner(r)){let o=await this._getSettings();return i!=="latest"?`${this.getHostUrl()}/prompts/${n}/${i.substring(0,8)}?organizationId=${o.id}`:`${this.getHostUrl()}/prompts/${n}?organizationId=${o.id}`}else return i!=="latest"?`${this.getHostUrl()}/hub/${r}/${n}/${i.substring(0,8)}`:`${this.getHostUrl()}/hub/${r}/${n}`}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,n,i]=Qt(t);for await(let o of this._getPaginated(`/commits/${r}/${n}/`,new URLSearchParams,a=>a.commits))yield*o}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 n of this._getPaginated("/repos",r,i=>i.repos))yield*n}async getPrompt(t){let[r,n,i]=Qt(t),a=await(await this.caller.call(async()=>{let s=await this._fetch(`${this.apiUrl}/repos/${r}/${n}`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return s?.status===404?null:(await X(s,"get prompt"),s)}))?.json();return a?.repo?a.repo:null}async createPrompt(t,r){let n=await this._getSettings();if(r?.isPublic&&!n.tenant_handle)throw new Error(`Cannot create a public prompt without first
155
-
156
- creating a LangChain Hub handle.
157
- You can add a handle by creating a public prompt at:
158
-
159
- https://smith.langchain.com/prompts`);let[i,o,a]=Qt(t);if(!await this._currentTenantIsOwner(i))throw await this._ownerConflictError("create a prompt",i);let s={repo_handle:o,...r?.description&&{description:r.description},...r?.readme&&{readme:r.readme},...r?.tags&&{tags:r.tags},is_public:!!r?.isPublic},c=JSON.stringify(s),u=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 X(d,"create prompt"),d}),{repo:l}=await u.json();return l}async createCommit(t,r,n){if(!await this.promptExists(t))throw new Error("Prompt does not exist, you must create it first.");let[i,o,a]=Qt(t),s=n?.parentCommitHash==="latest"||!n?.parentCommitHash?await this._getLatestCommitHash(`${i}/${o}`):n?.parentCommitHash,c={manifest:JSON.parse(JSON.stringify(r)),parent_commit:s,...n?.description!==void 0&&{description:n.description}},u=JSON.stringify(c),d=await(await this.caller.call(async()=>{let p=await this._fetch(`${this.apiUrl}/commits/${i}/${o}`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:u});return await X(p,"create commit"),p})).json(),f=d.commit??d;return n?.tags&&await this._createCommitTags(`${i}/${o}`,f.id,n.tags),this._getPromptUrl(`${i}/${o}${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 n=new FormData;for(let a of r){let s=a.id,c={...a.metadata&&{metadata:a.metadata},...a.split&&{split:a.split}},u=er(c,`Serializing body for example with id: ${s}`),l=new Blob([u],{type:"application/json"});if(n.append(s,l),a.inputs){let d=er(a.inputs,`Serializing inputs for example with id: ${s}`),f=new Blob([d],{type:"application/json"});n.append(`${s}.inputs`,f)}if(a.outputs){let d=er(a.outputs,`Serializing outputs whle updating example with id: ${s}`),f=new Blob([d],{type:"application/json"});n.append(`${s}.outputs`,f)}if(a.attachments)for(let[d,f]of Object.entries(a.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}`});n.append(`${s}.attachment.${d}`,h)}if(a.attachments_operations){let d=er(a.attachments_operations,`Serializing attachments while updating example with id: ${s}`),f=new Blob([d],{type:"application/json"});n.append(`${s}.attachments_operations`,f)}}let i=t??r[0]?.dataset_id;return(await this.caller.call(async()=>{let a=await this._fetch(`${this.apiUrl}${this._getPlatformEndpointPath(`datasets/${i}/examples`)}`,{method:"PATCH",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:n});return await X(a,"update examples"),a})).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 n=new FormData;for(let o of r){let a=(o.id??Ea()).toString(),s={created_at:o.created_at,...o.metadata&&{metadata:o.metadata},...o.split&&{split:o.split},...o.source_run_id&&{source_run_id:o.source_run_id},...o.use_source_run_io&&{use_source_run_io:o.use_source_run_io},...o.use_source_run_attachments&&{use_source_run_attachments:o.use_source_run_attachments}},c=er(s,`Serializing body for uploaded example with id: ${a}`),u=new Blob([c],{type:"application/json"});if(n.append(a,u),o.inputs){let l=er(o.inputs,`Serializing inputs for uploaded example with id: ${a}`),d=new Blob([l],{type:"application/json"});n.append(`${a}.inputs`,d)}if(o.outputs){let l=er(o.outputs,`Serializing outputs for uploaded example with id: ${a}`),d=new Blob([l],{type:"application/json"});n.append(`${a}.outputs`,d)}if(o.attachments)for(let[l,d]of Object.entries(o.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}`});n.append(`${a}.attachment.${l}`,m)}}return(await this.caller.call(async()=>{let o=await this._fetch(`${this.apiUrl}${this._getPlatformEndpointPath(`datasets/${t}/examples`)}`,{method:"POST",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:n});return await X(o,"upload examples"),o})).json()}async updatePrompt(t,r){if(!await this.promptExists(t))throw new Error("Prompt does not exist, you must create it first.");let[n,i]=Qt(t);if(!await this._currentTenantIsOwner(n))throw await this._ownerConflictError("update a prompt",n);let o={};if(r?.description!==void 0&&(o.description=r.description),r?.readme!==void 0&&(o.readme=r.readme),r?.tags!==void 0&&(o.tags=r.tags),r?.isPublic!==void 0&&(o.is_public=r.isPublic),r?.isArchived!==void 0&&(o.is_archived=r.isArchived),Object.keys(o).length===0)throw new Error("No valid update options provided");let a=JSON.stringify(o);return(await this.caller.call(async()=>{let c=await this._fetch(`${this.apiUrl}/repos/${n}/${i}`,{method:"PATCH",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:a});return await X(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,n,i]=Qt(t);if(!await this._currentTenantIsOwner(r))throw await this._ownerConflictError("delete a prompt",r);return(await this.caller.call(async()=>{let a=await this._fetch(`${this.apiUrl}/repos/${r}/${n}`,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(a,"delete prompt"),a})).json()}_getPromptCacheKey(t,r){return`${t}${r?":with_model":""}`}async _fetchPromptFromApi(t,r){let[n,i,o]=Qt(t),s=await(await this.caller.call(async()=>{let c=await this._fetch(`${this.apiUrl}/commits/${n}/${i}/${o}${r?.includeModel?"?include_model=true":""}`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(c,"pull prompt commit"),c})).json();return{owner:n,repo:i,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){VL(t,r?.dangerouslyPullPublicPrompt);let n=this._fetchPromptFromApi.bind(this,t,r);if(!r?.skipCache&&this._promptCache){let i=this._getPromptCacheKey(t,r?.includeModel),o=this._promptCache.get(i,n);if(o)return o;let a=await n();return this._promptCache.set(i,a,n),a}return this._fetchPromptFromApi(t,r)}async _pullPrompt(t,r){let n=await this.pullPromptCommit(t,{includeModel:r?.includeModel,skipCache:r?.skipCache,dangerouslyPullPublicPrompt:r?.dangerouslyPullPublicPrompt});return JSON.stringify(n.manifest)}async pushPrompt(t,r){return await this.promptExists(t)?r&&["description","readme","tags","isPublic"].some(i=>r[i]!==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,n]=Qt(t);return this._repoExists(r,n)}async skillExists(t){let[r,n]=Qt(t);return this._repoExists(r,n)}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 n=new URLSearchParams;n.append("repo_type",t),n.append("is_archived",(!!r?.isArchived).toString()),r?.isPublic!==void 0&&n.append("is_public",r.isPublic.toString()),r?.query&&n.append("query",r.query);for await(let i of this._getPaginated("/repos",n,o=>o.repos))yield*i}async _pullDirectory(t,r,n){let[i,o,a]=Qt(t),s=n??(a!=="latest"?a:void 0),c=new URL(`${this.apiUrl}${this._getPlatformEndpointPath(`hub/repos/${i}/${o}/directories`)}`);return c.searchParams.set("repo_type",r),s&&c.searchParams.set("commit",s),await(await this.caller.call(async()=>{let l=await this._fetch(c.toString(),{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(l,"pull directory"),l})).json()}async _pushDirectory(t,r,n){if(n.parentCommit!==void 0&&(n.parentCommit.length<8||n.parentCommit.length>64))throw new Error("parent_commit must be 8-64 characters");let[i,o]=Qt(t);if(!await this._currentTenantIsOwner(i))throw await this._ownerConflictError(`push ${r}`,i);if(await this._repoExists(i,o))(n.description!==void 0||n.readme!==void 0||n.tags!==void 0||n.isPublic!==void 0)&&await this._updateRepoMetadata(i,o,n);else{let f=/^[a-z][a-z0-9-_]*$/;if(!f.test(o))throw new Error(`Invalid repo_handle ${JSON.stringify(o)}: must match ${f}`);await this._createRepo(o,r,n)}let a={files:n.files};n.parentCommit&&(a.parent_commit=n.parentCommit);let u=(await(await this.caller.call(async()=>{let f=await this._fetch(`${this.apiUrl}${this._getPlatformEndpointPath(`hub/repos/${i}/${o}/directories/commits`)}`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:JSON.stringify(a)});return await X(f,`push ${r}`),f})).json()).commit.commit_hash,l=await this._getSettings(),d=new URLSearchParams({organizationId:l.id});return`${this.getHostUrl()}/context/${o}/${u.slice(0,8)}?${d.toString()}`}async _deleteDirectory(t){let[r,n]=Qt(t);if(!await this._currentTenantIsOwner(r))throw await this._ownerConflictError("delete",r);await this.caller.call(async()=>{let i=await this._fetch(`${this.apiUrl}${this._getPlatformEndpointPath(`hub/repos/${r}/${n}/directories`)}`,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(i,"delete directory"),i})}async _repoExists(t,r){try{return await this.caller.call(async()=>{let n=await this._fetch(`${this.apiUrl}/repos/${t}/${r}`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(n,"check repo exists"),n}),!0}catch(n){if(sp(n))return!1;throw n}}async _createRepo(t,r,n){let i={repo_handle:t,repo_type:r,is_public:!!n.isPublic};n.description!==void 0&&(i.description=n.description),n.readme!==void 0&&(i.readme=n.readme),n.tags!==void 0&&(i.tags=n.tags);try{await this.caller.call(async()=>{let o=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(i)});return await X(o,`create ${r}`),o})}catch(o){if(cA(o))return;throw o}}async _updateRepoMetadata(t,r,n){let i={};n.description!==void 0&&(i.description=n.description),n.readme!==void 0&&(i.readme=n.readme),n.tags!==void 0&&(i.tags=n.tags),n.isPublic!==void 0&&(i.is_public=n.isPublic),Object.keys(i).length!==0&&await this.caller.call(async()=>{let o=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(i)});return await X(o,"update repo metadata"),o})}async clonePublicDataset(t,r={}){let{sourceApiUrl:n=this.apiUrl,datasetName:i}=r,[o,a]=this.parseTokenOrUrl(t,n),s=new e({apiUrl:o,apiKey:"placeholder"}),c=await s.readSharedDataset(a),u=i||c.name;try{if(await this.hasDataset({datasetId:u})){console.log(`Dataset ${u} already exists in your tenant. Skipping.`);return}}catch{}let l=await s.listSharedExamples(a),d=await this.createDataset(u,{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:l.map(f=>f.inputs),outputs:l.flatMap(f=>f.outputs?[f.outputs]:[]),datasetId:d.id})}catch(f){throw console.error(`An error occurred while creating dataset ${u}. You should delete it manually.`),f}}parseTokenOrUrl(t,r,n=2,i="dataset"){try{return de(t),[r,t]}catch{}try{let a=new URL(t).pathname.split("/").filter(s=>s!=="");if(a.length>=n){let s=a[a.length-n];return[r,s]}else throw new Error(`Invalid public ${i} URL: ${t}`)}catch{throw new Error(`Invalid public ${i} 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 bT()?.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(Xn,"_fallbackDirsCreated",{enumerable:!0,configurable:!0,writable:!0,value:new Set});function AA(e){return"dataset_id"in e||"dataset_name"in e}var ri=Symbol.for("lc:context_variables");var fp=Symbol.for("langsmith:replica_trace_roots");function Ly(e,t){if(ri in e)return e[ri][t]}function PA(e,t,r){let n=ri in e?e[ri]:{};n[t]=r,e[ri]=n}var ol=36,QL="6ba7b810-9dad-11d1-80b4-00c04fd430c8";function NA(e){let r=Object.keys(e).sort().map(n=>`${n}:${e[n]??""}`).join("|");return P_(r,QL)}function e2(e){return e.replace(/[-:.]/g,"")}function jA(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 Fy(e,t,r=1){let n=jA(e,r);return{dottedOrder:e2(n)+t,microsecondPrecisionDatestring:n}}var t2=new Set(["projectName","primary","updates","reroot"]);function r2(e){let t={};for(let r of Object.keys(e))r==="primary"&&typeof e[r]!="boolean"||t2.has(r)&&(t[r]=e[r]);return t}var pp=class e{constructor(t,r,n,i){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=n,this.replicas=i}static fromHeader(t){let r=t.split(","),n={},i=[],o,a;for(let s of r){let[c,u]=s.split("="),l=decodeURIComponent(u);c==="langsmith-metadata"?n=JSON.parse(l):c==="langsmith-tags"?i=l.split(","):c==="langsmith-project"?o=l:c==="langsmith-replicas"&&(a=JSON.parse(l).map(f=>Array.isArray(f)?f:r2(f)))}return new e(n,i,o,a)}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(",")}},xn=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}),MA(t)){Object.assign(this,{...t});return}let r=e.getDefaultConfig(),{metadata:n,...i}=t,o=i.client??e.getSharedClient(),a={...n,...i?.extra?.metadata};if(i.extra={...i.extra,metadata:a},"id"in i&&i.id==null&&delete i.id,Object.assign(this,{...r,...i,client:o}),this.execution_order??=1,this.child_execution_order??=1,this.dotted_order||(this._serialized_start_time=jA(this.start_time,this.execution_order)),this.id||(this.id=Cf(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=a2(this.replicas),!this.dotted_order){let{dottedOrder:s}=Fy(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:Ju(),child_runs:[],api_url:Dt("LANGCHAIN_ENDPOINT")??"http://localhost:1984",api_key:Dt("LANGCHAIN_API_KEY"),caller_options:{},start_time:t,serialized:{},inputs:{},extra:{}}}static getSharedClient(){return e.sharedClient||(e.sharedClient=new Xn),e.sharedClient}createChild(t){let r=this.child_execution_order+1,n=this.replicas?.map(f=>{let{reroot:p,...m}=f;return m}),i=t.replicas??n,o=new e({...t,parent_run:this,project_name:this.project_name,replicas:i,client:this.client,tracingEnabled:this.tracingEnabled,execution_order:r,child_execution_order:r}),a=this.extra?.metadata??{},s=o.extra?.metadata??{};Object.keys(a).length>0&&(o.extra={...o.extra,metadata:{...a,...s}}),ri in this&&(o[ri]=this[ri]);let c=Symbol.for("lc:child_config"),u=t.extra?.[c]??this.extra[c];if(i2(u)){let f={...u},p=n2(f.callbacks)?f.callbacks.copy?.():void 0;p&&(Object.assign(p,{_parentRunId:o.id}),p.handlers?.find(DA)?.updateFromRunTree?.(o),f.callbacks=p),o.extra[c]=f}let l=new Set,d=this;for(;d!=null&&!l.has(d.id);)l.add(d.id),d.child_execution_order=Math.max(d.child_execution_order,r),d=d.parent_run;return this.child_runs.push(o),o}async end(t,r,n=Date.now(),i){this.outputs=this.outputs??t,this.error=this.error??r,this.end_time=this.end_time??n,i&&Object.keys(i).length>0&&(this.extra=this.extra?{...this.extra,metadata:{...this.extra.metadata,...i}}:{metadata:i})}_convertToCreate(t,r,n=!0){let i=t.extra??{};if(i?.runtime?.library===void 0&&(i.runtime||(i.runtime={}),r))for(let[s,c]of Object.entries(r))i.runtime[s]||(i.runtime[s]=c);let o=t.parent_run?.id??t.parent_run_id,a;return n?a=[]:a=t.child_runs.map(s=>this._convertToCreate(s,r,n)),{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:i,serialized:t.serialized,error:t.error,inputs:t.inputs,outputs:t.outputs,session_name:t.project_name,child_runs:a,parent_run_id:o,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 n=r.dotted_order.split("."),i=null;for(let o=0;o<n.length;o++)if(n[o].slice(-ol)===t){i=o;break}if(i!==null){let o=n.slice(i+1);r.dotted_order=o.join("."),o.length>0?r.trace_id=o[0].slice(-ol):r.trace_id=r.id}}r.parent_run_id===t&&(r.parent_run_id=void 0)}_setReplicaTraceRoot(t,r){let n=Ly(this,fp)??{};n[t]=r,PA(this,fp,n);for(let i of this.child_runs)i._setReplicaTraceRoot(t,r)}_remapForProject(t){let{projectName:r,primary:n,runtimeEnv:i,excludeChildRuns:o=!0,reroot:a=!1,distributedParentId:s,apiUrl:c,apiKey:u,workspaceId:l}=t,d=this._convertToCreate(this,i,o);if(n===void 0&&r===this.project_name)return{...d,session_name:r};if(a){if(s)this._sliceParentId(s,d);else if(d.parent_run_id=void 0,d.dotted_order){let x=d.dotted_order.split(".");x.length>0&&(d.dotted_order=x[x.length-1],d.trace_id=d.id)}let w=NA({projectName:r,apiUrl:c,apiKey:u,workspaceId:l});this._setReplicaTraceRoot(w,d.id)}let f;if(!a){let w=Ly(this,fp)??{},x=NA({projectName:r,apiUrl:c,apiKey:u,workspaceId:l});if(f=w[x],f&&(d.trace_id=f,d.dotted_order)){let S=d.dotted_order.split("."),E=null;for(let C=0;C<S.length;C++)if(S[C].slice(-ol)===f){E=C;break}if(E!==null){let C=S.slice(E);d.dotted_order=C.join(".")}}}if(n)return{...d,session_name:r};let p=d.id,m=rc(p,r),h;d.trace_id?h=rc(d.trace_id,r):h=m;let _;d.parent_run_id&&(_=rc(d.parent_run_id,r));let y;return d.dotted_order&&(y=d.dotted_order.split(".").map(S=>{let E=S.slice(-ol),C=rc(E,r);return S.slice(0,-ol)+C}).join(".")),{...d,id:m,trace_id:h,parent_run_id:_,dotted_order:y,session_name:r}}async postRun(t=!0){this._awaitInputsOnPost&&(this.inputs=await this.inputs);try{let r=Df();if(this.replicas&&this.replicas.length>0)for(let{projectName:n,primary:i,apiKey:o,apiUrl:a,workspaceId:s,reroot:c,client:u}of this.replicas){let l=this._remapForProject({projectName:n??this.project_name,primary:i,runtimeEnv:r,excludeChildRuns:!0,reroot:c,distributedParentId:this.distributedParentId,apiUrl:a,apiKey:o,workspaceId:s});await(u??this.client).createRun(l,{apiKey:o,apiUrl:a,workspaceId:s})}else{let n=this._convertToCreate(this,r,t);await this.client.createRun(n)}if(!t){zt("Posting with excludeChildRuns=false is deprecated and will be removed in a future version.");for(let n of this.child_runs)await n.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,primary:n,apiKey:i,apiUrl:o,workspaceId:a,updates:s,reroot:c,client:u}of this.replicas){let l=this._remapForProject({projectName:r??this.project_name,primary:n,runtimeEnv:void 0,excludeChildRuns:!0,reroot:c,distributedParentId:this.distributedParentId,apiUrl:o,apiKey:i,workspaceId:a}),d={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,...s};t?.excludeInputs||(d.inputs=l.inputs),await(u??this.client).updateRun(l.id,d,{apiKey:i,apiUrl:o,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 n=t?.callbacks,i,o,a,s=H_();if(n){let u=n?.getParentRunId?.()??"",l=n?.handlers?.find(d=>d?.name=="langchain_tracer");i=l?.getRun?.(u),o=l?.projectName,a=l?.client,s=s||!!l}return i?new e({name:i.name,id:i.id,trace_id:i.trace_id,dotted_order:i.dotted_order,client:a,tracingEnabled:s,project_name:o,tags:[...new Set((i?.tags??[]).concat(t?.tags??[]))],extra:{metadata:{...i?.extra?.metadata,...t?.metadata}}}).createChild(r):new e({...r,client:a,tracingEnabled:s,project_name:o})}static fromDottedOrder(t){return this.fromHeaders({"langsmith-trace":t})}static fromHeaders(t,r){let n="get"in t&&typeof t.get=="function"?{"langsmith-trace":t.get("langsmith-trace"),baggage:t.get("baggage")}:t,i=n["langsmith-trace"];if(!i||typeof i!="string")return;let o=i.trim(),a=o.split(".").map(l=>{let[d,f]=l.split("Z");return{strTime:d,time:Date.parse(d+"Z"),uuid:f}}),s=a[0].uuid,c={...r,name:r?.name??"parent",run_type:r?.run_type??"chain",start_time:r?.start_time??Date.now(),id:a.at(-1)?.uuid,trace_id:s,dotted_order:o};if(n.baggage&&typeof n.baggage=="string"){let l=pp.fromHeader(n.baggage);c.metadata=l.metadata,c.tags=l.tags,c.project_name=l.project_name,c.replicas=l.replicas}let u=new e(c);return u.distributedParentId=u.id,u}toHeaders(t){let r={"langsmith-trace":this.dotted_order,baggage:new pp(this.extra?.metadata,this.tags,this.project_name,this.replicas).toHeader()};if(t)for(let[n,i]of Object.entries(r))t.set(n,i);return r}};Object.defineProperty(xn,"sharedClient",{enumerable:!0,configurable:!0,writable:!0,value:null});function MA(e){return e!=null&&typeof e.createChild=="function"&&typeof e.postRun=="function"}function DA(e){return typeof e=="object"&&e!=null&&typeof e.name=="string"&&e.name==="langchain_tracer"}function RA(e){return Array.isArray(e)&&e.some(t=>DA(t))}function n2(e){return typeof e=="object"&&e!=null&&Array.isArray(e.handlers)}function i2(e){let t=e?.callbacks;return e!=null&&typeof t=="object"&&(RA(t?.handlers)||RA(t))}function o2(){let e=Dt("LANGSMITH_RUNS_ENDPOINTS");if(!e)return[];try{let t=JSON.parse(e);if(Array.isArray(t)){let r=[];for(let n of t){if(typeof n!="object"||n===null){console.warn(`Invalid item type in LANGSMITH_RUNS_ENDPOINTS: expected object, got ${typeof n}`);continue}if(typeof n.api_url!="string"){console.warn(`Invalid api_url type in LANGSMITH_RUNS_ENDPOINTS: expected string, got ${typeof n.api_url}`);continue}if(typeof n.api_key!="string"){console.warn(`Invalid api_key type in LANGSMITH_RUNS_ENDPOINTS: expected string, got ${typeof n.api_key}`);continue}if(n.project_name!==void 0&&n.project_name!==null&&typeof n.project_name!="string"){console.warn(`Invalid project_name type in LANGSMITH_RUNS_ENDPOINTS: expected string, got ${typeof n.project_name}`);continue}if(n.primary!==void 0&&typeof n.primary!="boolean"){console.warn(`Invalid primary type in LANGSMITH_RUNS_ENDPOINTS: expected boolean, got ${typeof n.primary}`);continue}r.push({apiUrl:n.api_url.replace(/\/$/,""),apiKey:n.api_key,projectName:n.project_name??void 0,primary:n.primary??void 0})}return r}else if(typeof t=="object"&&t!==null){s2(t);let r=[];for(let[n,i]of Object.entries(t)){let o=n.replace(/\/$/,"");if(typeof i=="string")r.push({apiUrl:o,apiKey:i});else{console.warn(`Invalid value type in LANGSMITH_RUNS_ENDPOINTS for URL ${n}: expected string, got ${typeof i}`);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(lA(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 a2(e){let t=e?e.map(r=>Array.isArray(r)?{projectName:r[0],updates:r[1]}:r):o2();if(t.filter(r=>r.primary===!0).length>1)throw new Error("Only one replica can be marked as primary.");return t}function s2(e){if(Object.keys(e).length>0&&qe("ENDPOINT"))throw new op}var zA=A({BaseTracer:()=>Ht,isBaseTracer:()=>Ha}),c2=e=>{if(e)return e.events=e.events??[],e.child_runs=e.child_runs??[],e};function Vy(e,t){if(e)return new xn({...e,start_time:e._serialized_start_time??e.start_time,parent_run:Vy(t),child_runs:e.child_runs.map(r=>Vy(r)).filter(r=>r!==void 0),extra:{...e.extra,runtime:h_()},tracingEnabled:!1})}function By(e,t){return e&&!Array.isArray(e)&&typeof e=="object"?e:{[t]:e}}function Ha(e){return typeof e._addRunToRunMap=="function"}var Ht=class extends hr{runMap=new Map;runTreeMap=new Map;usesRunTreeMap=!1;constructor(e){super(...arguments)}copy(){return this}getRunById(e){if(e!==void 0)return this.usesRunTreeMap?c2(this.runTreeMap.get(e)):this.runMap.get(e)}stringifyError(e){return e instanceof Error?e.message+(e?.stack?`
160
-
161
- ${e.stack}`:""):typeof e=="string"?e:`${e}`}_addChildRun(e,t){e.child_runs.push(t)}_addRunToRunMap(e){let{dottedOrder:t,microsecondPrecisionDatestring:r}=Fy(new Date(e.start_time).getTime(),e.id,e.execution_order),n={...e},i=this.getRunById(n.parent_run_id);if(n.parent_run_id!==void 0?i?(this._addChildRun(i,n),i.child_execution_order=Math.max(i.child_execution_order,n.child_execution_order),n.trace_id=i.trace_id,i.dotted_order!==void 0&&(n.dotted_order=[i.dotted_order,t].join("."),n._serialized_start_time=r)):n.parent_run_id=void 0:(n.trace_id=n.id,n.dotted_order=t,n._serialized_start_time=r),this.usesRunTreeMap){let o=Vy(n,i);o!==void 0&&this.runTreeMap.set(n.id,o)}else this.runMap.set(n.id,n);return n}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,n,i,o,a,s){let c=this._getExecutionOrder(n),u=Date.now(),l=a?{...i,metadata:a}:i,d={id:r,name:s??e.id[e.id.length-1],parent_run_id:n,start_time:u,serialized:e,events:[{name:"start",time:new Date(u).toISOString()}],inputs:{prompts:t},execution_order:c,child_runs:[],child_execution_order:c,run_type:"llm",extra:l??{},tags:o||[]};return this._addRunToRunMap(d)}async handleLLMStart(e,t,r,n,i,o,a,s){let c=this.getRunById(r)??this._createRunForLLMStart(e,t,r,n,i,o,a,s);return await this.onRunCreate?.(c),await this.onLLMStart?.(c),c}_createRunForChatModelStart(e,t,r,n,i,o,a,s){let c=this._getExecutionOrder(n),u=Date.now(),l=a?{...i,metadata:a}:i,d={id:r,name:s??e.id[e.id.length-1],parent_run_id:n,start_time:u,serialized:e,events:[{name:"start",time:new Date(u).toISOString()}],inputs:{messages:t},execution_order:c,child_runs:[],child_execution_order:c,run_type:"llm",extra:l??{},tags:o||[]};return this._addRunToRunMap(d)}async handleChatModelStart(e,t,r,n,i,o,a,s){let c=this.getRunById(r)??this._createRunForChatModelStart(e,t,r,n,i,o,a,s);return await this.onRunCreate?.(c),await this.onLLMStart?.(c),c}async handleLLMEnd(e,t,r,n,i){let o=this.getRunById(t);if(!o||o?.run_type!=="llm")throw new Error("No LLM run to end.");return o.end_time=Date.now(),o.outputs=e,o.events.push({name:"end",time:new Date(o.end_time).toISOString()}),o.extra={...o.extra,...i},await this.onLLMEnd?.(o),await this._endTrace(o),o}async handleLLMError(e,t,r,n,i){let o=this.getRunById(t);if(!o||o?.run_type!=="llm")throw new Error("No LLM run to end.");return o.end_time=Date.now(),o.error=this.stringifyError(e),o.events.push({name:"error",time:new Date(o.end_time).toISOString()}),o.extra={...o.extra,...i},await this.onLLMError?.(o),await this._endTrace(o),o}_createRunForChainStart(e,t,r,n,i,o,a,s,c){let u=this._getExecutionOrder(n),l=Date.now(),d={id:r,name:s??e.id[e.id.length-1],parent_run_id:n,start_time:l,serialized:e,events:[{name:"start",time:new Date(l).toISOString()}],inputs:t,execution_order:u,child_execution_order:u,run_type:a??"chain",child_runs:[],extra:o?{...c,metadata:o}:{...c},tags:i||[]};return this._addRunToRunMap(d)}async handleChainStart(e,t,r,n,i,o,a,s){let c=this.getRunById(r)??this._createRunForChainStart(e,t,r,n,i,o,a,s);return await this.onRunCreate?.(c),await this.onChainStart?.(c),c}async handleChainEnd(e,t,r,n,i){let o=this.getRunById(t);if(!o)throw new Error("No chain run to end.");return o.end_time=Date.now(),o.outputs=By(e,"output"),o.events.push({name:"end",time:new Date(o.end_time).toISOString()}),i?.inputs!==void 0&&(o.inputs=By(i.inputs,"input")),await this.onChainEnd?.(o),await this._endTrace(o),o}async handleChainError(e,t,r,n,i){let o=this.getRunById(t);if(!o)throw new Error("No chain run to end.");return o.end_time=Date.now(),o.error=this.stringifyError(e),o.events.push({name:"error",time:new Date(o.end_time).toISOString()}),i?.inputs!==void 0&&(o.inputs=By(i.inputs,"input")),await this.onChainError?.(o),await this._endTrace(o),o}_createRunForToolStart(e,t,r,n,i,o,a){let s=this._getExecutionOrder(n),c=Date.now(),u={id:r,name:a??e.id[e.id.length-1],parent_run_id:n,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:o?{metadata:o}:{},tags:i||[]};return this._addRunToRunMap(u)}async handleToolStart(e,t,r,n,i,o,a){let s=this.getRunById(r)??this._createRunForToolStart(e,t,r,n,i,o,a);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 n=r;n.actions=n.actions||[],n.actions.push(e),n.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,n,i,o,a){let s=this._getExecutionOrder(n),c=Date.now(),u={id:r,name:a??e.id[e.id.length-1],parent_run_id:n,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:o?{metadata:o}:{},tags:i||[]};return this._addRunToRunMap(u)}async handleRetrieverStart(e,t,r,n,i,o,a){let s=this.getRunById(r)??this._createRunForRetrieverStart(e,t,r,n,i,o,a);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,n,i,o){let a=this.getRunById(r);if(!a||a?.run_type!=="llm")throw new Error('Invalid "runId" provided to "handleLLMNewToken" callback.');return a.events.push({name:"new_token",time:new Date().toISOString(),kwargs:{token:e,idx:t,chunk:o?.chunk}}),await this.onLLMNewToken?.(a,e,{chunk:o?.chunk}),a}};var LA=A({ConsoleCallbackHandler:()=>mp}),FA={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 yr(e,t){return`${e.open}${t}${e.close}`}function nn(e,t){try{return JSON.stringify(e,null,2)}catch{return t}}function UA(e){return typeof e=="string"?e.trim():e==null?e:nn(e,e.toString())}function Eo(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:Tr}=FA,mp=class extends Ht{name="console_callback_handler";persistRun(e){return Promise.resolve()}getParents(e){let t=[],r=e;for(;r.parent_run_id;){let n=this.runMap.get(r.parent_run_id);if(n)t.push(n),r=n;else break}return t}getBreadcrumbs(e){let t=[...this.getParents(e).reverse(),e].map((r,n,i)=>{let o=`${r.execution_order}:${r.run_type}:${r.name}`;return n===i.length-1?yr(FA.bold,o):o}).join(" > ");return yr(Tr.grey,t)}onChainStart(e){let t=this.getBreadcrumbs(e);console.log(`${yr(Tr.green,"[chain/start]")} [${t}] Entering Chain run with input: ${nn(e.inputs,"[inputs]")}`)}onChainEnd(e){let t=this.getBreadcrumbs(e);console.log(`${yr(Tr.cyan,"[chain/end]")} [${t}] [${Eo(e)}] Exiting Chain run with output: ${nn(e.outputs,"[outputs]")}`)}onChainError(e){let t=this.getBreadcrumbs(e);console.log(`${yr(Tr.red,"[chain/error]")} [${t}] [${Eo(e)}] Chain run errored with error: ${nn(e.error,"[error]")}`)}onLLMStart(e){let t=this.getBreadcrumbs(e),r="prompts"in e.inputs?{prompts:e.inputs.prompts.map(n=>n.trim())}:e.inputs;console.log(`${yr(Tr.green,"[llm/start]")} [${t}] Entering LLM run with input: ${nn(r,"[inputs]")}`)}onLLMEnd(e){let t=this.getBreadcrumbs(e);console.log(`${yr(Tr.cyan,"[llm/end]")} [${t}] [${Eo(e)}] Exiting LLM run with output: ${nn(e.outputs,"[response]")}`)}onLLMError(e){let t=this.getBreadcrumbs(e);console.log(`${yr(Tr.red,"[llm/error]")} [${t}] [${Eo(e)}] LLM run errored with error: ${nn(e.error,"[error]")}`)}onToolStart(e){let t=this.getBreadcrumbs(e);console.log(`${yr(Tr.green,"[tool/start]")} [${t}] Entering Tool run with input: "${UA(e.inputs.input)}"`)}onToolEnd(e){let t=this.getBreadcrumbs(e);console.log(`${yr(Tr.cyan,"[tool/end]")} [${t}] [${Eo(e)}] Exiting Tool run with output: "${UA(e.outputs?.output)}"`)}onToolError(e){let t=this.getBreadcrumbs(e);console.log(`${yr(Tr.red,"[tool/error]")} [${t}] [${Eo(e)}] Tool run errored with error: ${nn(e.error,"[error]")}`)}onRetrieverStart(e){let t=this.getBreadcrumbs(e);console.log(`${yr(Tr.green,"[retriever/start]")} [${t}] Entering Retriever run with input: ${nn(e.inputs,"[inputs]")}`)}onRetrieverEnd(e){let t=this.getBreadcrumbs(e);console.log(`${yr(Tr.cyan,"[retriever/end]")} [${t}] [${Eo(e)}] Exiting Retriever run with output: ${nn(e.outputs,"[outputs]")}`)}onRetrieverError(e){let t=this.getBreadcrumbs(e);console.log(`${yr(Tr.red,"[retriever/error]")} [${t}] [${Eo(e)}] Retriever run errored with error: ${nn(e.error,"[error]")}`)}onAgentAction(e){let t=e,r=this.getBreadcrumbs(e);console.log(`${yr(Tr.blue,"[agent/action]")} [${r}] Agent selected action: ${nn(t.actions[t.actions.length-1],"[action]")}`)}};var Hy,hp=()=>(Hy===void 0&&(Hy=new Xn(pr("LANGCHAIN_CALLBACKS_BACKGROUND")==="false"?{blockOnRootRunFinalization:!0}:{})),Hy);var VA=A({LangChainTracer:()=>Io,OVERRIDABLE_LANGSMITH_INHERITABLE_METADATA_KEYS:()=>Gy}),Gy=new Set(["ls_agent_type"]);function u2(e){let t;for(let r of e)for(let n of r)je.isInstance(n.message)&&n.message.usage_metadata!==void 0&&(t=Ws(t,n.message.usage_metadata));return t}var Io=class Zy extends Ht{name="langchain_tracer";projectName;exampleId;client;replicas;usesRunTreeMap=!0;tracingMetadata;tracingTags=[];constructor(t={}){super(t),this.fields=t;let{exampleId:r,projectName:n,client:i,replicas:o,metadata:a,tags:s}=t;this.projectName=n??Ju(),this.replicas=o,this.exampleId=r,this.client=i??hp(),this.tracingMetadata=a?{...a}:void 0,this.tracingTags=s??[];let c=Zy.getTraceableRunTree();c&&this.updateFromRunTree(c)}async persistRun(t){}async onRunCreate(t){BA(this,t),t.extra?.lc_defers_inputs||await this.getRunTreeWithTracingConfig(t.id)?.postRun()}async onRunUpdate(t){BA(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 n=u2(r.generations);if(n!==void 0){t.extra=t.extra??{};let i=t.extra.metadata??{};i.usage_metadata=n,t.extra.metadata=i}}}copyWithTracingConfig({metadata:t,tags:r}){let n;if(t===void 0)n=this.tracingMetadata?{...this.tracingMetadata}:void 0;else if(this.tracingMetadata===void 0)n={...t};else{n={...this.tracingMetadata};for(let[a,s]of Object.entries(t))(!Object.prototype.hasOwnProperty.call(n,a)||Gy.has(a))&&(n[a]=s)}let i=r?Array.from(new Set([...this.tracingTags,...r])):[...this.tracingTags],o=new Zy({...this.fields,metadata:n,tags:i});return o.runMap=this.runMap,o.runTreeMap=this.runTreeMap,o}_getRunStoreKey(){return this.runTreeMap}getRun(t){return this.runTreeMap.get(t)}updateFromRunTree(t){this.runTreeMap.set(t.id,t);let r=t,n=new Set;for(;r.parent_run&&!(n.has(r.id)||(n.add(r.id),!r.parent_run));)r=r.parent_run;n.clear();let i=[r];for(;i.length>0;){let o=i.shift();!o||n.has(o.id)||(n.add(o.id),this.runTreeMap.set(o.id,o),o.child_runs&&i.push(...o.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 xn({...r,client:this.client,project_name:this.projectName,replicas:this.replicas,reference_example_id:this.exampleId,tracingEnabled:!0})}static getTraceableRunTree(){try{return q_(!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 BA(e,t){if(e.tracingMetadata){t.extra??={};let r=t.extra.metadata??{},n=!1;for(let[i,o]of Object.entries(e.tracingMetadata))(!Object.prototype.hasOwnProperty.call(r,i)||Gy.has(i))&&r[i]!==o&&(r[i]=o,n=!0);n&&(t.extra.metadata=r)}e.tracingTags.length>0&&(t.tags=Array.from(new Set([...t.tags??[],...e.tracingTags])))}var HA=Symbol.for("ls:tracing_async_local_storage"),$o=Symbol.for("lc:context_variables"),ZA=e=>{globalThis[HA]=e},To=()=>globalThis[HA];var gp=Vd(Gf(),1),Za;function l2(){return new("default"in gp.default?gp.default.default:gp.default)({autoStart:!0,concurrency:1})}function d2(){return typeof Za>"u"&&(Za=l2()),Za}async function at(e,t){if(t===!0){let r=To();r!==void 0?await r.run(void 0,async()=>e()):await e()}else Za=d2(),Za.add(async()=>{let r=To();r!==void 0?await r.run(void 0,async()=>e()):await e()})}async function GA(){let e=hp();await Promise.allSettled([typeof Za<"u"?Za.onIdle():Promise.resolve(),e.awaitPendingTraceBatches()])}var WA=A({awaitAllCallbacks:()=>GA,consumeCallback:()=>at});var qA=e=>e!==void 0?e:!!["LANGSMITH_TRACING_V2","LANGCHAIN_TRACING_V2","LANGSMITH_TRACING","LANGCHAIN_TRACING"].find(t=>pr(t)==="true");function Wy(e){let t=To();if(t!==void 0)return t.getStore()?.[$o]?.[e]}var f2=Symbol("lc:configure_hooks"),KA=()=>Wy(f2)||[];var JA=A({BaseCallbackManager:()=>XA,BaseRunManager:()=>sl,CallbackManager:()=>tt,CallbackManagerForChainRun:()=>QA,CallbackManagerForLLMRun:()=>Ky,CallbackManagerForRetrieverRun:()=>YA,CallbackManagerForToolRun:()=>eC,ensureHandler:()=>Ni,parseCallbackConfigArg:()=>Ga});function qy(e){return e._getRunStoreKey?.()??e}function p2(e,t){return e===t?e:e.copyWithTracingConfig({metadata:t.tracingMetadata,tags:t.tracingTags})}function m2(e,t){let r=new Set(t),n=new Map,i=[],o=s=>{let c=qy(s),u=r.has(s),l=n.get(c);if(l===void 0){n.set(c,{index:i.length,tracer:s,hasInheritable:u}),i.push(s);return}u&&!l.hasInheritable?(l.tracer=s,l.hasInheritable=!0):(u||!l.hasInheritable)&&(l.tracer=p2(l.tracer,s)),i[l.index]=l.tracer};for(let s of e)s instanceof Io?o(s):i.push(s);for(let s of t)s instanceof Io&&!n.has(qy(s))&&o(s);let a=new Set;return{handlers:i,inheritableHandlers:t.flatMap(s=>{if(!(s instanceof Io))return[s];let c=qy(s);return a.has(c)?[]:(a.add(c),[n.get(c)?.tracer??s])})}}function Ga(e){return e?Array.isArray(e)||"name"in e?{callbacks:e}:e:{}}var XA=class{setHandler(e){return this.setHandlers([e])}},sl=class{constructor(e,t,r,n,i,o,a,s){this.runId=e,this.handlers=t,this.inheritableHandlers=r,this.tags=n,this.inheritableTags=i,this.metadata=o,this.inheritableMetadata=a,this._parentRunId=s}get parentRunId(){return this._parentRunId}async handleText(e){await Promise.all(this.handlers.map(t=>at(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,n,i){await Promise.all(this.handlers.map(o=>at(async()=>{try{await o.handleCustomEvent?.(e,t,this.runId,this.tags,this.metadata)}catch(a){if((o.raiseError?console.error:console.warn)(`Error in handler ${o.constructor.name}, handleCustomEvent: ${a}`),o.raiseError)throw a}},o.awaitHandlers)))}},YA=class extends sl{getChild(e){let t=new tt(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=>at(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=>at(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)))}},Ky=class extends sl{async handleLLMNewToken(e,t,r,n,i,o){await Promise.all(this.handlers.map(a=>at(async()=>{if(!a.ignoreLLM)try{await a.handleLLMNewToken?.(e,t??{prompt:0,completion:0},this.runId,this._parentRunId,this.tags,o)}catch(s){if((a.raiseError?console.error:console.warn)(`Error in handler ${a.constructor.name}, handleLLMNewToken: ${s}`),a.raiseError)throw s}},a.awaitHandlers)))}async handleChatModelStreamEvent(e){await Promise.all(this.handlers.map(t=>at(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,n,i){await Promise.all(this.handlers.map(o=>at(async()=>{if(!o.ignoreLLM)try{await o.handleLLMError?.(e,this.runId,this._parentRunId,this.tags,i)}catch(a){if((o.raiseError?console.error:console.warn)(`Error in handler ${o.constructor.name}, handleLLMError: ${a}`),o.raiseError)throw a}},o.awaitHandlers)))}async handleLLMEnd(e,t,r,n,i){await Promise.all(this.handlers.map(o=>at(async()=>{if(!o.ignoreLLM)try{await o.handleLLMEnd?.(e,this.runId,this._parentRunId,this.tags,i)}catch(a){if((o.raiseError?console.error:console.warn)(`Error in handler ${o.constructor.name}, handleLLMEnd: ${a}`),o.raiseError)throw a}},o.awaitHandlers)))}},QA=class extends sl{getChild(e){let t=new tt(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,n,i){await Promise.all(this.handlers.map(o=>at(async()=>{if(!o.ignoreChain)try{await o.handleChainError?.(e,this.runId,this._parentRunId,this.tags,i)}catch(a){if((o.raiseError?console.error:console.warn)(`Error in handler ${o.constructor.name}, handleChainError: ${a}`),o.raiseError)throw a}},o.awaitHandlers)))}async handleChainEnd(e,t,r,n,i){await Promise.all(this.handlers.map(o=>at(async()=>{if(!o.ignoreChain)try{await o.handleChainEnd?.(e,this.runId,this._parentRunId,this.tags,i)}catch(a){if((o.raiseError?console.error:console.warn)(`Error in handler ${o.constructor.name}, handleChainEnd: ${a}`),o.raiseError)throw a}},o.awaitHandlers)))}async handleAgentAction(e){await Promise.all(this.handlers.map(t=>at(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=>at(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)))}},eC=class extends sl{getChild(e){let t=new tt(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=>at(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=>at(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=>at(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)))}},tt=class al extends XA{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,n=void 0,i=void 0,o=void 0,a=void 0,s=void 0,c=void 0){return Promise.all(r.map(async(u,l)=>{let d=l===0&&n?n:tn();return await Promise.all(this.handlers.map(f=>{if(!f.ignoreLLM)return Ha(f)&&f._createRunForLLMStart(t,[u],d,this._parentRunId,o,this.tags,this.metadata,c),at(async()=>{try{await f.handleLLMStart?.(t,[u],d,this._parentRunId,o,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 Ky(d,this.handlers,this.inheritableHandlers,this.tags,this.inheritableTags,this.metadata,this.inheritableMetadata,this._parentRunId)}))}async handleChatModelStart(t,r,n=void 0,i=void 0,o=void 0,a=void 0,s=void 0,c=void 0){return Promise.all(r.map(async(u,l)=>{let d=l===0&&n?n:tn();return await Promise.all(this.handlers.map(f=>{if(!f.ignoreLLM)return Ha(f)&&f._createRunForChatModelStart(t,[u],d,this._parentRunId,o,this.tags,this.metadata,c),at(async()=>{try{if(f.handleChatModelStart)await f.handleChatModelStart?.(t,[u],d,this._parentRunId,o,this.tags,this.metadata,c);else if(f.handleLLMStart){let p=Ks(u);await f.handleLLMStart?.(t,[p],d,this._parentRunId,o,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 Ky(d,this.handlers,this.inheritableHandlers,this.tags,this.inheritableTags,this.metadata,this.inheritableMetadata,this._parentRunId)}))}async handleChainStart(t,r,n=tn(),i=void 0,o=void 0,a=void 0,s=void 0,c=void 0,u=void 0){return await Promise.all(this.handlers.map(l=>{if(!l.ignoreChain)return Ha(l)&&l._createRunForChainStart(t,r,n,this._parentRunId,this.tags,this.metadata,i,s,u),at(async()=>{try{await l.handleChainStart?.(t,r,n,this._parentRunId,this.tags,this.metadata,i,s,u)}catch(d){if((l.raiseError?console.error:console.warn)(`Error in handler ${l.constructor.name}, handleChainStart: ${d}`),l.raiseError)throw d}},l.awaitHandlers)})),new QA(n,this.handlers,this.inheritableHandlers,this.tags,this.inheritableTags,this.metadata,this.inheritableMetadata,this._parentRunId)}async handleToolStart(t,r,n=tn(),i=void 0,o=void 0,a=void 0,s=void 0,c=void 0){return await Promise.all(this.handlers.map(u=>{if(!u.ignoreAgent)return Ha(u)&&u._createRunForToolStart(t,r,n,this._parentRunId,this.tags,this.metadata,s),at(async()=>{try{await u.handleToolStart?.(t,r,n,this._parentRunId,this.tags,this.metadata,s,c)}catch(l){if((u.raiseError?console.error:console.warn)(`Error in handler ${u.constructor.name}, handleToolStart: ${l}`),u.raiseError)throw l}},u.awaitHandlers)})),new eC(n,this.handlers,this.inheritableHandlers,this.tags,this.inheritableTags,this.metadata,this.inheritableMetadata,this._parentRunId)}async handleRetrieverStart(t,r,n=tn(),i=void 0,o=void 0,a=void 0,s=void 0){return await Promise.all(this.handlers.map(c=>{if(!c.ignoreRetriever)return Ha(c)&&c._createRunForRetrieverStart(t,r,n,this._parentRunId,this.tags,this.metadata,s),at(async()=>{try{await c.handleRetrieverStart?.(t,r,n,this._parentRunId,this.tags,this.metadata,s)}catch(u){if((c.raiseError?console.error:console.warn)(`Error in handler ${c.constructor.name}, handleRetrieverStart: ${u}`),c.raiseError)throw u}},c.awaitHandlers)})),new YA(n,this.handlers,this.inheritableHandlers,this.tags,this.inheritableTags,this.metadata,this.inheritableMetadata,this._parentRunId)}async handleCustomEvent(t,r,n,i,o){await Promise.all(this.handlers.map(a=>at(async()=>{if(!a.ignoreCustomEvent)try{await a.handleCustomEvent?.(t,r,n,this.tags,this.metadata)}catch(s){if((a.raiseError?console.error:console.warn)(`Error in handler ${a.constructor.name}, handleCustomEvent: ${s}`),a.raiseError)throw s}},a.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 n of t)this.addHandler(n,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 n=new al(this._parentRunId);for(let i of this.handlers){let o=this.inheritableHandlers.includes(i);n.addHandler(i,o)}for(let i of this.tags){let o=this.inheritableTags.includes(i);n.addTags([i],o)}for(let i of Object.keys(this.metadata)){let o=Object.keys(this.inheritableMetadata).includes(i);n.addMetadata({[i]:this.metadata[i]},o)}for(let i of t)n.handlers.filter(o=>o.name==="console_callback_handler").some(o=>o.name===i.name)||n.addHandler(i,r);return n}static fromHandlers(t){class r extends hr{name=tn();constructor(){super(),Object.assign(this,t)}}let n=new this;return n.addHandler(new r),n}static configure(t,r,n,i,o,a,s){return this._configureSync(t,r,n,i,o,a,s)}static _configureSync(t,r,n,i,o,a,s){let c;(t||r)&&(Array.isArray(t)||!t?(c=new al,c.setHandlers(t?.map(Ni)??[],!0)):c=t,c=c.copy(Array.isArray(r)?r.map(Ni):r?.handlers,!1));let u=pr("LANGCHAIN_VERBOSE")==="true"||s?.verbose,l=Io.getTraceableRunTree(),d=l?.tracingEnabled??qA();if(l?.tracingEnabled===!1&&c){let h=c.handlers.filter(_=>_.name==="langchain_tracer");for(let _ of h)c.removeHandler(_)}let f=d||(pr("LANGCHAIN_TRACING")??!1);if(u||f){if(c||(c=new al),u&&!c.handlers.some(h=>h.name===mp.prototype.name)){let h=new mp;c.addHandler(h,!0)}if(f&&!c.handlers.some(h=>h.name==="langchain_tracer")&&d){let h=new Io;c.addHandler(h,!0)}d&&l&&c._parentRunId===void 0&&(c._parentRunId=l.id,c.handlers.find(h=>h.name==="langchain_tracer")?.updateFromRunTree(l))}for(let{contextVar:h,inheritable:_=!0,handlerClass:y,envVar:w}of KA()){let x=w&&pr(w)==="true"&&y,S,E=h!==void 0?Wy(h):void 0;E&&I_(E)?S=E:x&&(S=new y({})),S!==void 0&&(c||(c=new al),c.handlers.some(C=>C.name===S.name)||c.addHandler(S,_))}(n||i)&&c&&(c.addTags(n??[]),c.addTags(i??[],!1)),(o||a)&&c&&(c.addMetadata(o??{}),c.addMetadata(a??{},!1));let p=s?.tracerInheritableMetadata,m=s?.tracerInheritableTags;if(c&&(p||m)){let h=new Map,_=y=>{if(!(y instanceof Io))return y;let w=h.get(y);if(w!==void 0)return w;let x=y.copyWithTracingConfig({metadata:p,tags:m});return h.set(y,x),x};c.handlers=c.handlers.map(_),c.inheritableHandlers=c.inheritableHandlers.map(_)}if(c){let h=m2(c.handlers,c.inheritableHandlers);c.handlers=h.handlers,c.inheritableHandlers=h.inheritableHandlers}return c}};function Ni(e){return"name"in e?e:hr.fromMethods(e)}var Jy=class{getStore(){}run(e,t){return t()}enterWith(e){}},h2=new Jy,tC=Symbol.for("lc:child_config"),g2=class{getInstance(){return To()??h2}getRunnableConfig(){return this.getInstance().getStore()?.extra?.[tC]}runWithConfig(e,t,r){let n=tt._configureSync(e?.callbacks,void 0,e?.tags,void 0,e?.metadata),i=this.getInstance(),o=i.getStore(),a=n?.getParentRunId(),s=n?.handlers?.find(u=>u?.name==="langchain_tracer"),c;return s&&a?c=s.getRunTreeWithTracingConfig(a):r||(c=new xn({name:"<runnable_lambda>",tracingEnabled:!1})),c&&(c.extra={...c.extra,[tC]:e}),o!==void 0&&o[$o]!==void 0&&(c===void 0&&(c={}),c[$o]=o[$o]),i.run(c,t)}initializeGlobalInstance(e){To()===void 0&&ZA(e)}},Me=new g2;var rC=A({AsyncLocalStorageProviderSingleton:()=>Me,MockAsyncLocalStorage:()=>Jy,_CONTEXT_VARIABLES_KEY:()=>$o});var _2=new Set(["api_key"]),y2=new Set(["string","number","boolean"]);function v2(e){let t=e.configurable??{},r=e.metadata??{},n={};for(let[i,o]of Object.entries(t))!i.startsWith("__")&&!Object.prototype.hasOwnProperty.call(r,i)&&!_2.has(i)&&y2.has(typeof o)&&(n[i]=o);return Object.keys(n).length>0?n:void 0}async function tr(e){return tt._configureSync(e?.callbacks,void 0,e?.tags,void 0,e?.metadata,void 0,{tracerInheritableMetadata:e?v2(e):void 0})}function Ct(...e){let t={};for(let r of e.filter(n=>!!n))for(let n of Object.keys(r))if(n==="metadata")t[n]={...t[n],...r[n]};else if(n==="tags"){let i=t[n]??[];t[n]=[...new Set(i.concat(r[n]??[]))]}else if(n==="configurable")t[n]={...t[n],...r[n]};else if(n==="timeout")t.timeout===void 0?t.timeout=r.timeout:r.timeout!==void 0&&(t.timeout=Math.min(t.timeout,r.timeout));else if(n==="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(n==="callbacks"){let i=t.callbacks,o=r.callbacks;if(Array.isArray(o))if(!i)t.callbacks=o;else if(Array.isArray(i))t.callbacks=i.concat(o);else{let a=i.copy();for(let s of o)a.addHandler(Ni(s),!0);t.callbacks=a}else if(o)if(!i)t.callbacks=o;else if(Array.isArray(i)){let a=o.copy();for(let s of i)a.addHandler(Ni(s),!0);t.callbacks=a}else t.callbacks=new tt(o._parentRunId,{handlers:i.handlers.concat(o.handlers),inheritableHandlers:i.inheritableHandlers.concat(o.inheritableHandlers),tags:Array.from(new Set(i.tags.concat(o.tags))),inheritableTags:Array.from(new Set(i.inheritableTags.concat(o.inheritableTags))),metadata:{...i.metadata,...o.metadata}})}else{let i=n;t[i]=r[i]??t[i]}return t}function Ee(e){let t=Me.getRunnableConfig(),r={tags:[],metadata:{},recursionLimit:25,runId:void 0};if(t){let{runId:n,runName:i,...o}=t;r=Object.entries(o).reduce((a,[s,c])=>(c!==void 0&&(a[s]=c),a),r)}if(e&&(r=Object.entries(e).reduce((n,[i,o])=>(o!==void 0&&(n[i]=o),n),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 n=r.timeout,i=AbortSignal.timeout(n);r.metadata||(r.metadata={}),r.metadata.timeoutMs===void 0&&(r.metadata.timeoutMs=n),r.signal!==void 0?"any"in AbortSignal&&(r.signal=AbortSignal.any([r.signal,i])):r.signal=i,delete r.timeout}return r}function Ae(e={},{callbacks:t,maxConcurrency:r,recursionLimit:n,runName:i,configurable:o,runId:a}={}){let s=Ee(e);return t!==void 0&&(delete s.runName,s.callbacks=t),n!==void 0&&(s.recursionLimit=n),r!==void 0&&(s.maxConcurrency=r),i!==void 0&&(s.runName=i),o!==void 0&&(s.configurable={...s.configurable,...o}),a!==void 0&&delete s.runId,s}function Ar(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 Hr(e,t){if(t===void 0)return e;let r;return Promise.race([e.catch(n=>{if(!t?.aborted)throw n}),new Promise((n,i)=>{r=()=>{i(Ao(t))},t.addEventListener("abort",r,{once:!0}),t.aborted&&i(Ao(t))})]).finally(()=>t.removeEventListener("abort",r))}function Ao(e){return e?.reason instanceof Error?e.reason:typeof e?.reason=="string"?new Error(e.reason):new Error("Aborted")}var nC=A({AsyncGeneratorWithSetup:()=>Co,IterableReadableStream:()=>bt,atee:()=>_p,concat:()=>Zr,pipeGeneratorWithSetup:()=>Yy}),bt=class Xy 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 Xy({start(n){return i();function i(){return r.read().then(({done:o,value:a})=>{if(o){n.close();return}return n.enqueue(a),i()})}},cancel(){r.releaseLock()}})}static fromAsyncGenerator(t){return new Xy({async pull(r){let{value:n,done:i}=await t.next();i&&r.close(),r.enqueue(n)},async cancel(r){await t.return(r)}})}};function _p(e,t=2){let r=Array.from({length:t},()=>[]);return r.map(async function*(i){for(;;)if(i.length===0){let o=await e.next();for(let a of r)a.push(o)}else{if(i[0].done)return;yield i.shift().value}})}function Zr(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[n,i]of Object.entries(t))n in r&&!Array.isArray(r[n])?r[n]=Zr(r[n],i):r[n]=i;return r}else throw new Error(`Cannot concat ${typeof e} and ${typeof t}`)}var Co=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)=>{Me.runWithConfig(Ar(e.config),async()=>{this.firstResult=this.signal?Hr(e.generator.next(),this.signal):e.generator.next(),e.startSetup?this.firstResult.then(e.startSetup).then(t,r):this.firstResult.then(n=>t(void 0),r)},!0)})}async next(...e){return this.signal?.throwIfAborted(),this.firstResultUsed?Me.runWithConfig(Ar(this.config),this.signal?async()=>Hr(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 Yy(e,t,r,n,...i){let o=new Co({generator:t,startSetup:r,signal:n}),a=await o.setup;return{output:e(o,a,...i),setup:a}}var b2=Object.prototype.hasOwnProperty;function vp(e,t){return b2.call(e,t)}function bp(e){if(Array.isArray(e)){let r=new Array(e.length);for(let n=0;n<r.length;n++)r[n]=""+n;return r}if(Object.keys)return Object.keys(e);let t=[];for(let r in e)vp(e,r)&&t.push(r);return t}function Gr(e){switch(typeof e){case"object":return JSON.parse(JSON.stringify(e));case"undefined":return null;default:return e}}function wp(e){let t=0,r=e.length,n;for(;t<r;){if(n=e.charCodeAt(t),n>=48&&n<=57){t++;continue}return!1}return!0}function Wa(e){return e.indexOf("/")===-1&&e.indexOf("~")===-1?e:e.replace(/~/g,"~0").replace(/\//g,"~1")}function oC(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function yp(e){if(e===void 0)return!0;if(e){if(Array.isArray(e)){for(let r=0,n=e.length;r<n;r++)if(yp(e[r]))return!0}else if(typeof e=="object"){let r=bp(e),n=r.length;for(var t=0;t<n;t++)if(yp(e[r[t]]))return!0}}return!1}function iC(e,t){let r=[e];for(let n in t){let i=typeof t[n]=="object"?JSON.stringify(t[n],null,2):t[n];typeof i<"u"&&r.push(`${n}: ${i}`)}return r.join(`
162
- `)}var aC=class extends Error{constructor(e,t,r,n,i){super(iC(e,{name:t,index:r,operation:n,tree:i})),this.name=t,this.index=r,this.operation=n,this.tree=i,Object.setPrototypeOf(this,new.target.prototype),this.message=iC(e,{name:t,index:r,operation:n,tree:i})}};var sC=A({JsonPatchError:()=>ft,_areEquals:()=>cl,applyOperation:()=>qa,applyPatch:()=>Oo,applyReducer:()=>S2,deepClone:()=>w2,getValueByPointer:()=>xp,validate:()=>cC,validator:()=>Sp}),ft=aC,w2=Gr,yc={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 n=e[t];return delete e[t],{newDocument:r,removed:n}},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 n=e[t];return e[t]=this.value,{newDocument:r,removed:n}},move:function(e,t,r){let n=xp(r,this.path);n&&(n=Gr(n));let i=qa(r,{op:"remove",path:this.from}).removed;return qa(r,{op:"add",path:this.path,value:i}),{newDocument:r,removed:n}},copy:function(e,t,r){let n=xp(r,this.from);return qa(r,{op:"add",path:this.path,value:Gr(n)}),{newDocument:r}},test:function(e,t,r){return{newDocument:r,test:cl(e[t],this.value)}},_get:function(e,t,r){return this.value=e[t],{newDocument:r}}},x2={add:function(e,t,r){return wp(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 n=e[t];return e[t]=this.value,{newDocument:r,removed:n}},move:yc.move,copy:yc.copy,test:yc.test,_get:yc._get};function xp(e,t){if(t=="")return e;var r={op:"_get",path:t};return qa(e,r),r.value}function qa(e,t,r=!1,n=!0,i=!0,o=0){if(r&&(typeof r=="function"?r(t,0,e,t.path):Sp(t,0)),t.path===""){let a={newDocument:e};if(t.op==="add")return a.newDocument=t.value,a;if(t.op==="replace")return a.newDocument=t.value,a.removed=e,a;if(t.op==="move"||t.op==="copy")return a.newDocument=xp(e,t.from),t.op==="move"&&(a.removed=e),a;if(t.op==="test"){if(a.test=cl(e,t.value),a.test===!1)throw new ft("Test operation failed","TEST_OPERATION_FAILED",o,t,e);return a.newDocument=e,a}else{if(t.op==="remove")return a.removed=e,a.newDocument=null,a;if(t.op==="_get")return t.value=e,a;if(r)throw new ft("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",o,t,e);return a}}else{n||(e=Gr(e));let a=(t.path||"").split("/"),s=e,c=1,u=a.length,l,d,f;for(typeof r=="function"?f=r:f=Sp;;){if(d=a[c],d&&d.indexOf("~")!=-1&&(d=oC(d)),i&&(d=="__proto__"||d=="prototype"&&c>0&&a[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&&l===void 0&&(s[d]===void 0?l=a.slice(0,c).join("/"):c==u-1&&(l=t.path),l!==void 0&&f(t,0,e,l)),c++,Array.isArray(s)){if(d==="-")d=s.length;else{if(r&&!wp(d))throw new ft("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",o,t,e);wp(d)&&(d=~~d)}if(c>=u){if(r&&t.op==="add"&&d>s.length)throw new ft("The specified index MUST NOT be greater than the number of elements in the array","OPERATION_VALUE_OUT_OF_BOUNDS",o,t,e);let p=x2[t.op].call(t,s,d,e);if(p.test===!1)throw new ft("Test operation failed","TEST_OPERATION_FAILED",o,t,e);return p}}else if(c>=u){let p=yc[t.op].call(t,s,d,e);if(p.test===!1)throw new ft("Test operation failed","TEST_OPERATION_FAILED",o,t,e);return p}if(s=s[d],r&&c<u&&(!s||typeof s!="object"))throw new ft("Cannot perform operation at the desired path","OPERATION_PATH_UNRESOLVABLE",o,t,e)}}}function Oo(e,t,r,n=!0,i=!0){if(r&&!Array.isArray(t))throw new ft("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");n||(e=Gr(e));let o=new Array(t.length);for(let a=0,s=t.length;a<s;a++)o[a]=qa(e,t[a],r,!0,i,a),e=o[a].newDocument;return o.newDocument=e,o}function S2(e,t,r){let n=qa(e,t);if(n.test===!1)throw new ft("Test operation failed","TEST_OPERATION_FAILED",r,t,e);return n.newDocument}function Sp(e,t,r,n){if(typeof e!="object"||e===null||Array.isArray(e))throw new ft("Operation is not an object","OPERATION_NOT_AN_OBJECT",t,e,r);if(yc[e.op]){if(typeof e.path!="string")throw new ft("Operation `path` property is not a string","OPERATION_PATH_INVALID",t,e,r);if(e.path.indexOf("/")!==0&&e.path.length>0)throw new ft('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 ft("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 ft("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")&&yp(e.value))throw new ft("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 i=e.path.split("/").length,o=n.split("/").length;if(i!==o+1&&i!==o)throw new ft("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!==n)throw new ft("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 a=cC([{op:"_get",path:e.from,value:void 0}],r);if(a&&a.name==="OPERATION_PATH_UNRESOLVABLE")throw new ft("Cannot perform the operation from a path that does not exist","OPERATION_FROM_UNRESOLVABLE",t,e,r)}}}else throw new ft("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",t,e,r)}function cC(e,t,r){try{if(!Array.isArray(e))throw new ft("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");if(t)Oo(Gr(t),Gr(e),r||!0);else{r=r||Sp;for(var n=0;n<e.length;n++)r(e[n],n,t,void 0)}}catch(i){if(i instanceof ft)return i;throw i}}function cl(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){var r=Array.isArray(e),n=Array.isArray(t),i,o,a;if(r&&n){if(o=e.length,o!=t.length)return!1;for(i=o;i--!==0;)if(!cl(e[i],t[i]))return!1;return!0}if(r!=n)return!1;var s=Object.keys(e);if(o=s.length,o!==Object.keys(t).length)return!1;for(i=o;i--!==0;)if(!t.hasOwnProperty(s[i]))return!1;for(i=o;i--!==0;)if(a=s[i],!cl(e[a],t[a]))return!1;return!0}return e!==e&&t!==t}function uC(e,t,r,n,i){if(t!==e){typeof t.toJSON=="function"&&(t=t.toJSON());for(var o=bp(t),a=bp(e),s=!1,c=a.length-1;c>=0;c--){var u=a[c],l=e[u];if(vp(t,u)&&!(t[u]===void 0&&l!==void 0&&Array.isArray(t)===!1)){var d=t[u];typeof l=="object"&&l!=null&&typeof d=="object"&&d!=null&&Array.isArray(l)===Array.isArray(d)?uC(l,d,r,n+"/"+Wa(u),i):l!==d&&(i&&r.push({op:"test",path:n+"/"+Wa(u),value:Gr(l)}),r.push({op:"replace",path:n+"/"+Wa(u),value:Gr(d)}))}else Array.isArray(e)===Array.isArray(t)?(i&&r.push({op:"test",path:n+"/"+Wa(u),value:Gr(l)}),r.push({op:"remove",path:n+"/"+Wa(u)}),s=!0):(i&&r.push({op:"test",path:n,value:e}),r.push({op:"replace",path:n,value:t}))}if(!(!s&&o.length==a.length))for(var c=0;c<o.length;c++){var u=o[c];!vp(e,u)&&t[u]!==void 0&&r.push({op:"add",path:n+"/"+Wa(u),value:Gr(t[u])})}}}function Po(e,t,r=!1){var n=[];return uC(e,t,n,"",r),n}({...sC});var fC=A({LogStreamCallbackHandler:()=>Ep,RunLog:()=>kp,RunLogPatch:()=>ni,isLogStreamHandler:()=>ev}),ni=class{ops;constructor(e){this.ops=e.ops??[]}concat(e){let t=this.ops.concat(e.ops),r=Oo({},t);return new kp({ops:t,state:r[r.length-1].newDocument})}},kp=class Qy extends ni{state;constructor(t){super(t),this.state=t.state}concat(t){let r=this.ops.concat(t.ops),n=Oo(this.state,t.ops);return new Qy({ops:r,state:n[n.length-1].newDocument})}static fromRunLogPatch(t){let r=Oo({},t.ops);return new Qy({ops:t.ops,state:r[r.length-1].newDocument})}},ev=e=>e.name==="log_stream_tracer";async function lC(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 dC(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 k2(e){return e!==void 0&&e.message!==void 0}var Ep=class extends Ht{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=bt.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(n=>this.includeTags?.includes(n))!==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(n=>!this.excludeTags?.includes(n))),r}async*tapOutputIterable(e,t){for await(let r of t){if(e!==this.rootId){let n=this.keyMapByRunId[e];n&&await this.writer.write(new ni({ops:[{op:"add",path:`/logs/${n}/streamed_output/-`,value:r}]}))}yield r}}async onRunCreate(e){if(this.rootId===void 0&&(this.rootId=e.id,await this.writer.write(new ni({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 lC(e,this._schemaFormat)),await this.writer.write(new ni({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 lC(e,this._schemaFormat)}),r.push({op:"add",path:`/logs/${t}/final_output`,value:await dC(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 n=new ni({ops:r});await this.writer.write(n)}finally{if(e.id===this.rootId){let t=new ni({ops:[{op:"replace",path:"/final_output",value:await dC(e,this._schemaFormat)}]});await this.writer.write(t),this.autoClose&&await this.writer.close()}}}async onLLMNewToken(e,t,r){let n=this.keyMapByRunId[e.id];if(n===void 0)return;let i=e.inputs.messages!==void 0,o;i?k2(r?.chunk)?o=r?.chunk:o=new ut({id:`run-${e.id}`,content:t}):o=t;let a=new ni({ops:[{op:"add",path:`/logs/${n}/streamed_output_str/-`,value:t},{op:"add",path:`/logs/${n}/streamed_output/-`,value:o}]});await this.writer.write(a)}};var pC=A({ChatGenerationChunk:()=>No,GenerationChunk:()=>Ri,RUN_KEY:()=>Ka}),Ka="__run",Ri=class mC{text;generationInfo;constructor(t){this.text=t.text,this.generationInfo=t.generationInfo}concat(t){return new mC({text:this.text+t.text,generationInfo:{...this.generationInfo,...t.generationInfo}})}},No=class hC extends Ri{message;constructor(t){super(t),this.message=t.message}concat(t){return new hC({text:this.text+t.text,generationInfo:{...this.generationInfo,...t.generationInfo},message:this.message.concat(t.message)})}};var E2=Object.prototype.toString,I2=e=>E2.call(e)==="[object Error]",$2=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 gC(e){if(!(e&&I2(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:$2.has(t)}function T2(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 Ip(e,t,{min:r=0,allowInfinity:n=!1}={}){if(t!==void 0){if(typeof t!="number"||Number.isNaN(t))throw new TypeError(`Expected \`${e}\` to be a number${n?" or Infinity":""}.`);if(!n&&!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 A2=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 C2(e,t){let r=Math.max(1,e+1),n=t.randomize?Math.random()+1:1,i=Math.round(n*t.minTimeout*t.factor**(r-1));return i=Math.min(i,t.maxTimeout),i}function _C(e,t){return Number.isFinite(t)?t-(performance.now()-e):t}async function O2({error:e,attemptNumber:t,retriesConsumed:r,startTime:n,options:i}){let o=e instanceof Error?e:new TypeError(`Non-error was thrown: "${e}". You should only throw errors.`);if(o instanceof A2)throw o.originalError;let a=Number.isFinite(i.retries)?Math.max(0,i.retries-r):i.retries,s=i.maxRetryTime??Number.POSITIVE_INFINITY,c=Object.freeze({error:o,attemptNumber:t,retriesLeft:a,retriesConsumed:r});if(await i.onFailedAttempt(c),_C(n,s)<=0)throw o;let u=await i.shouldConsumeRetry(c),l=_C(n,s);if(l<=0||a<=0)throw o;if(o instanceof TypeError&&!gC(o)){if(u)throw o;return i.signal?.throwIfAborted(),!1}if(!await i.shouldRetry(c))throw o;if(!u)return i.signal?.throwIfAborted(),!1;let d=C2(r,i),f=typeof o.retryAfterMs=="number"&&o.retryAfterMs>=0?o.retryAfterMs:void 0;f!==void 0&&(d=Math.max(d,f));let p=Math.min(d,l);return p>0&&await new Promise((m,h)=>{let _=()=>{clearTimeout(y),i.signal?.removeEventListener("abort",_),h(i.signal.reason)},y=setTimeout(()=>{i.signal?.removeEventListener("abort",_),m()},p);i.unref&&y.unref?.(),i.signal?.addEventListener("abort",_,{once:!0})}),i.signal?.throwIfAborted(),!0}async function ul(e,t={}){if(t={...t},T2(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,Ip("factor",t.factor,{min:0,allowInfinity:!1}),Ip("minTimeout",t.minTimeout,{min:0,allowInfinity:!1}),Ip("maxTimeout",t.maxTimeout,{min:0,allowInfinity:!0}),Ip("maxRetryTime",t.maxRetryTime,{min:0,allowInfinity:!0}),t.factor>0||(t.factor=1),t.signal?.throwIfAborted();let r=0,n=0,i=performance.now();for(;!Number.isFinite(t.retries)||n<=t.retries;){r++;try{t.signal?.throwIfAborted();let o=await e(r);return t.signal?.throwIfAborted(),o}catch(o){await O2({error:o,attemptNumber:r,retriesConsumed:n,startTime:i,options:t})&&n++}}throw new Error("Retry attempts exhausted without throwing an error.")}var $p=Vd(Gf(),1),vC=A({AsyncCaller:()=>ji,classifyRateLimitError:()=>kC,parseRetryAfterMs:()=>SC}),P2=[400,401,402,403,404,405,406,407,409],N2=6e4,R2=[/insufficient[_ -]?quota/i,/exceeded (?:your|the current|the available).+quota/i,/usage quota/i,/quota (?:has been )?exhausted/i,/billing/i,/credit balance/i,/out of credits/i,/will reset at/i],j2=/(?:try again in|retry after)\s+(\d+(?:\.\d+)?)\s*(milliseconds?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h)\b/i;function bC(e){return typeof e=="object"&&e!==null&&"response"in e&&typeof e.response=="object"&&e.response!==null&&"status"in e.response&&typeof e.response.status=="number"?e.response.status:void 0}function wC(e){if(!(typeof e!="object"||e===null)){if("status"in e&&typeof e.status=="number")return e.status;if("statusCode"in e&&typeof e.statusCode=="number")return e.statusCode}}function rv(e){return typeof e=="object"&&e!==null&&"message"in e&&typeof e.message=="string"?e.message:void 0}function xC(e){if(!(typeof e!="object"||e===null))return"code"in e&&typeof e.code=="string"?e.code:"error"in e&&typeof e.error=="object"&&e.error!==null&&"code"in e.error&&typeof e.error.code=="string"?e.error.code:void 0}function M2(e){if(e?.headers)return typeof e.headers.get=="function"?e.headers.get("retry-after"):e.headers["retry-after"]??e.headers["Retry-After"];if(e?.response?.headers)return typeof e.response.headers.get=="function"?e.response.headers.get("retry-after"):e.response.headers["retry-after"]??e.response.headers["Retry-After"]}function D2(e){if(e==null)return;let t=j2.exec(e);if(!t)return;let r=Number(t[1]),n=t[2]?.toLowerCase();if(!(Number.isNaN(r)||!n))return n==="ms"||n.startsWith("millisecond")?r:n==="m"||n.startsWith("min")?r*6e4:n==="h"||n.startsWith("hr")||n.startsWith("hour")?r*36e5:r*1e3}function yC(e,t){if(e instanceof Error)return e;let r=new Error(t);return typeof e=="object"&&e!==null&&Object.assign(r,e),r}function tv(e,t){if(typeof e!="object"||e===null)return;let r=e;r.rateLimitType=t.action,r.rateLimitReason=t.reason,t.retryAfterMs!==void 0&&(r.retryAfterMs=t.retryAfterMs)}function SC(e){if(e==null)return;let t=e.trim();if(!t)return;let r=Number(t);if(!Number.isNaN(r)&&r>=0)return r*1e3;let n=Date.parse(t);if(!Number.isNaN(n)){let i=n-Date.now();return i>0?i:0}}function kC(e){if((bC(e)??wC(e))!==429)return;if(xC(e)==="insufficient_quota")return{action:"stop",reason:"insufficient_quota"};let t=rv(e);if(t&&R2.some(n=>n.test(t)))return{action:"stop",reason:"quota_message"};let r=SC(M2(e))??D2(t);return r!==void 0?r<=N2?{action:"wait",retryAfterMs:r,reason:"retry_after_hint"}:{action:"capacity",retryAfterMs:r,reason:"retry_after_too_large"}:{action:"capacity",reason:"headerless_429"}}var z2=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=bC(e)??wC(e);if(t&&P2.includes(+t))throw e;if(xC(e)==="insufficient_quota"){let n=yC(e,rv(e)??"Insufficient quota");throw n.name="InsufficientQuotaError",tv(n,{action:"stop",reason:"insufficient_quota"}),n}let r=kC(e);if(r){if(r.action==="wait"){tv(e,r);return}let n=yC(e,rv(e)??"Rate limit exceeded");throw n.name==="Error"&&(n.name=r.action==="stop"?"RateLimitQuotaExhaustedError":"RateLimitCapacityError"),tv(n,r),n}},ji=class{maxConcurrency;maxRetries;onFailedAttempt;queue;constructor(e){this.maxConcurrency=e.maxConcurrency??1/0,this.maxRetries=e.maxRetries??6,this.onFailedAttempt=e.onFailedAttempt??z2;let t="default"in $p.default?$p.default.default:$p.default;this.queue=new t({concurrency:this.maxConcurrency})}async call(e,...t){return this.queue.add(()=>ul(()=>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 n;return Promise.race([this.call(t,...r),new Promise((i,o)=>{n=()=>{o(Ao(e.signal))},e.signal?.addEventListener("abort",n,{once:!0})})]).finally(()=>{e.signal&&n&&e.signal.removeEventListener("abort",n)})}return this.call(t,...r)}fetch(...e){return this.call(()=>fetch(...e).then(t=>t.ok?t:Promise.reject(t)))}};var EC=A({isSerializableSchema:()=>Ja,isStandardJsonSchema:()=>Tp,isStandardSchema:()=>IC});function IC(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 Tp(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 Ja(e){return IC(e)&&Tp(e)}var zi={};Fn(zi,{$ZodAny:()=>Gb,$ZodArray:()=>Kb,$ZodAsyncError:()=>Sn,$ZodBase64:()=>Mb,$ZodBase64URL:()=>Db,$ZodBigInt:()=>qp,$ZodBigIntFormat:()=>Bb,$ZodBoolean:()=>xl,$ZodCIDRv4:()=>Nb,$ZodCIDRv6:()=>Rb,$ZodCUID:()=>wb,$ZodCUID2:()=>xb,$ZodCatch:()=>pw,$ZodCheck:()=>We,$ZodCheckBigIntFormat:()=>Xv,$ZodCheckEndsWith:()=>ub,$ZodCheckGreaterThan:()=>Bp,$ZodCheckIncludes:()=>sb,$ZodCheckLengthEquals:()=>nb,$ZodCheckLessThan:()=>Fp,$ZodCheckLowerCase:()=>ob,$ZodCheckMaxLength:()=>tb,$ZodCheckMaxSize:()=>Yv,$ZodCheckMimeType:()=>db,$ZodCheckMinLength:()=>rb,$ZodCheckMinSize:()=>Qv,$ZodCheckMultipleOf:()=>Kv,$ZodCheckNumberFormat:()=>Jv,$ZodCheckOverwrite:()=>fb,$ZodCheckProperty:()=>lb,$ZodCheckRegex:()=>ib,$ZodCheckSizeEquals:()=>eb,$ZodCheckStartsWith:()=>cb,$ZodCheckStringFormat:()=>Ic,$ZodCheckUpperCase:()=>ab,$ZodCodec:()=>Il,$ZodCustom:()=>ww,$ZodCustomStringFormat:()=>Lb,$ZodDate:()=>qb,$ZodDefault:()=>uw,$ZodDiscriminatedUnion:()=>Yb,$ZodE164:()=>zb,$ZodEmail:()=>_b,$ZodEmoji:()=>vb,$ZodEncodeError:()=>Ro,$ZodEnum:()=>nw,$ZodError:()=>gl,$ZodExactOptional:()=>sw,$ZodFile:()=>ow,$ZodFunction:()=>yw,$ZodGUID:()=>hb,$ZodIPv4:()=>Cb,$ZodIPv6:()=>Ob,$ZodISODate:()=>$b,$ZodISODateTime:()=>Ib,$ZodISODuration:()=>Ab,$ZodISOTime:()=>Tb,$ZodIntersection:()=>Qb,$ZodJWT:()=>Ub,$ZodKSUID:()=>Eb,$ZodLazy:()=>bw,$ZodLiteral:()=>iw,$ZodMAC:()=>Pb,$ZodMap:()=>tw,$ZodNaN:()=>mw,$ZodNanoID:()=>bb,$ZodNever:()=>kl,$ZodNonOptional:()=>dw,$ZodNull:()=>Zb,$ZodNullable:()=>cw,$ZodNumber:()=>Wp,$ZodNumberFormat:()=>Fb,$ZodObject:()=>nO,$ZodObjectJIT:()=>Jb,$ZodOptional:()=>rs,$ZodPipe:()=>Jp,$ZodPrefault:()=>lw,$ZodPreprocess:()=>hw,$ZodPromise:()=>vw,$ZodReadonly:()=>gw,$ZodRealError:()=>Or,$ZodRecord:()=>ew,$ZodRegistry:()=>em,$ZodSet:()=>rw,$ZodString:()=>ts,$ZodStringFormat:()=>He,$ZodSuccess:()=>fw,$ZodSymbol:()=>Vb,$ZodTemplateLiteral:()=>_w,$ZodTransform:()=>aw,$ZodTuple:()=>Kp,$ZodType:()=>he,$ZodULID:()=>Sb,$ZodURL:()=>yb,$ZodUUID:()=>gb,$ZodUndefined:()=>Hb,$ZodUnion:()=>El,$ZodUnknown:()=>Sl,$ZodVoid:()=>Wb,$ZodXID:()=>kb,$ZodXor:()=>Xb,$brand:()=>iv,$constructor:()=>k,$input:()=>Sw,$output:()=>xw,Doc:()=>wl,JSONSchema:()=>oP,JSONSchemaGenerator:()=>Cm,NEVER:()=>nv,TimePrecision:()=>$w,_any:()=>qw,_array:()=>Qw,_base64:()=>ym,_base64url:()=>vm,_bigint:()=>Fw,_boolean:()=>Uw,_catch:()=>sB,_check:()=>iP,_cidrv4:()=>gm,_cidrv6:()=>_m,_coercedBigint:()=>Bw,_coercedBoolean:()=>Lw,_coercedDate:()=>Xw,_coercedNumber:()=>Nw,_coercedString:()=>Ew,_cuid:()=>um,_cuid2:()=>lm,_custom:()=>tx,_date:()=>Jw,_decode:()=>Pp,_decodeAsync:()=>Rp,_default:()=>iB,_discriminatedUnion:()=>GF,_e164:()=>bm,_email:()=>rm,_emoji:()=>sm,_encode:()=>Op,_encodeAsync:()=>Np,_endsWith:()=>Nc,_enum:()=>YF,_file:()=>ex,_float32:()=>jw,_float64:()=>Mw,_gt:()=>oi,_gte:()=>br,_guid:()=>Al,_includes:()=>Oc,_int:()=>Rw,_int32:()=>Dw,_int64:()=>Vw,_intersection:()=>WF,_ipv4:()=>mm,_ipv6:()=>hm,_isoDate:()=>Aw,_isoDateTime:()=>Tw,_isoDuration:()=>Ow,_isoTime:()=>Cw,_jwt:()=>wm,_ksuid:()=>pm,_lazy:()=>dB,_length:()=>os,_literal:()=>eB,_lowercase:()=>Ac,_lt:()=>ii,_lte:()=>qr,_mac:()=>Iw,_map:()=>JF,_max:()=>qr,_maxLength:()=>is,_maxSize:()=>Fo,_mime:()=>Rc,_min:()=>br,_minLength:()=>Di,_minSize:()=>ai,_multipleOf:()=>Lo,_nan:()=>Yw,_nanoid:()=>cm,_nativeEnum:()=>QF,_negative:()=>Sm,_never:()=>Pl,_nonnegative:()=>Em,_nonoptional:()=>oB,_nonpositive:()=>km,_normalize:()=>jc,_null:()=>Ww,_nullable:()=>nB,_number:()=>Pw,_optional:()=>rB,_overwrite:()=>kn,_parse:()=>xc,_parseAsync:()=>Sc,_pipe:()=>cB,_positive:()=>xm,_promise:()=>fB,_property:()=>Im,_readonly:()=>uB,_record:()=>KF,_refine:()=>rx,_regex:()=>Tc,_safeDecode:()=>Mp,_safeDecodeAsync:()=>zp,_safeEncode:()=>jp,_safeEncodeAsync:()=>Dp,_safeParse:()=>kc,_safeParseAsync:()=>Ec,_set:()=>XF,_size:()=>ns,_slugify:()=>Uc,_startsWith:()=>Pc,_string:()=>kw,_stringFormat:()=>Lc,_stringbool:()=>ax,_success:()=>aB,_superRefine:()=>nx,_symbol:()=>Zw,_templateLiteral:()=>lB,_toLowerCase:()=>Dc,_toUpperCase:()=>zc,_transform:()=>tB,_trim:()=>Mc,_tuple:()=>qF,_uint32:()=>zw,_uint64:()=>Hw,_ulid:()=>dm,_undefined:()=>Gw,_union:()=>HF,_unknown:()=>Ol,_uppercase:()=>Cc,_url:()=>Cl,_uuid:()=>nm,_uuidv4:()=>im,_uuidv6:()=>om,_uuidv7:()=>am,_void:()=>Kw,_xid:()=>fm,_xor:()=>ZF,clone:()=>rt,config:()=>pt,createStandardJSONSchemaMethod:()=>Fc,createToJSONSchemaMethod:()=>sx,decode:()=>f6,decodeAsync:()=>m6,describe:()=>ix,encode:()=>d6,encodeAsync:()=>p6,extractDefs:()=>Vo,finalize:()=>Ho,flattenError:()=>_l,formatError:()=>yl,globalConfig:()=>Xa,globalRegistry:()=>Le,initializeContext:()=>Bo,isValidBase64:()=>jb,isValidBase64URL:()=>QC,isValidJWT:()=>eO,locales:()=>Tl,meta:()=>ox,parse:()=>Uo,parseAsync:()=>Qa,prettifyError:()=>_v,process:()=>Fe,regexes:()=>Wr,registry:()=>tm,safeDecode:()=>g6,safeDecodeAsync:()=>y6,safeEncode:()=>h6,safeEncodeAsync:()=>_6,safeParse:()=>yv,safeParseAsync:()=>vv,toDotPath:()=>PC,toJSONSchema:()=>as,treeifyError:()=>gv,util:()=>D,version:()=>pb});var $C,nv=Object.freeze({status:"aborted"});function k(e,t,r){function n(s,c){if(s._zod||Object.defineProperty(s,"_zod",{value:{def:c,constr:a,traits:new Set},enumerable:!1}),s._zod.traits.has(e))return;s._zod.traits.add(e),t(s,c);let u=a.prototype,l=Object.keys(u);for(let d=0;d<l.length;d++){let f=l[d];f in s||(s[f]=u[f].bind(s))}}let i=r?.Parent??Object;class o extends i{}Object.defineProperty(o,"name",{value:e});function a(s){var c;let u=r?.Parent?new o:this;n(u,s),(c=u._zod).deferred??(c.deferred=[]);for(let l of u._zod.deferred)l();return u}return Object.defineProperty(a,"init",{value:n}),Object.defineProperty(a,Symbol.hasInstance,{value:s=>r?.Parent&&s instanceof r.Parent?!0:s?._zod?.traits?.has(e)}),Object.defineProperty(a,"name",{value:e}),a}var iv=Symbol("zod_brand"),Sn=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Ro=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}};($C=globalThis).__zod_globalConfig??($C.__zod_globalConfig={});var Xa=globalThis.__zod_globalConfig;function pt(e){return e&&Object.assign(Xa,e),Xa}var D={};Fn(D,{BIGINT_FORMAT_RANGES:()=>mv,Class:()=>av,NUMBER_FORMAT_RANGES:()=>pv,aborted:()=>zo,allowsEval:()=>uv,assert:()=>V2,assertEqual:()=>U2,assertIs:()=>F2,assertNever:()=>B2,assertNotEqual:()=>L2,assignProp:()=>Mo,base64ToUint8Array:()=>AC,base64urlToUint8Array:()=>a6,cached:()=>bc,captureStackTrace:()=>Cp,cleanEnum:()=>o6,cleanRegex:()=>fl,clone:()=>rt,cloneDef:()=>Z2,createTransparentProxy:()=>X2,defineLazy:()=>Ie,esc:()=>Ap,escapeRegex:()=>on,explicitlyAborted:()=>hv,extend:()=>e6,finalizeIssue:()=>vr,floatSafeRemainder:()=>sv,getElementAtPath:()=>G2,getEnumValues:()=>dl,getLengthableOrigin:()=>hl,getParsedType:()=>J2,getSizableOrigin:()=>ml,hexToUint8Array:()=>c6,isObject:()=>Ya,isPlainObject:()=>Do,issue:()=>wc,joinValues:()=>$,jsonStringifyReplacer:()=>vc,merge:()=>r6,mergeDefs:()=>Mi,normalizeParams:()=>F,nullish:()=>jo,numKeys:()=>K2,objectClone:()=>H2,omit:()=>Q2,optionalKeys:()=>fv,parsedType:()=>M,partial:()=>n6,pick:()=>Y2,prefixIssues:()=>Cr,primitiveTypes:()=>dv,promiseAllObject:()=>W2,propertyKeyTypes:()=>pl,randomString:()=>q2,required:()=>i6,safeExtend:()=>t6,shallowClone:()=>lv,slugify:()=>cv,stringifyPrimitive:()=>j,uint8ArrayToBase64:()=>CC,uint8ArrayToBase64url:()=>s6,uint8ArrayToHex:()=>u6,unwrapMessage:()=>ll});function U2(e){return e}function L2(e){return e}function F2(e){}function B2(e){throw new Error("Unexpected value in exhaustive check")}function V2(e){}function dl(e){let t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,i])=>t.indexOf(+n)===-1).map(([n,i])=>i)}function $(e,t="|"){return e.map(r=>j(r)).join(t)}function vc(e,t){return typeof t=="bigint"?t.toString():t}function bc(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function jo(e){return e==null}function fl(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function sv(e,t){let r=e/t,n=Math.round(r),i=Number.EPSILON*Math.max(Math.abs(r),1);return Math.abs(r-n)<i?0:r-n}var TC=Symbol("evaluating");function Ie(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==TC)return n===void 0&&(n=TC,n=r()),n},set(i){Object.defineProperty(e,t,{value:i})},configurable:!0})}function H2(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function Mo(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Mi(...e){let t={};for(let r of e){let n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function Z2(e){return Mi(e._zod.def)}function G2(e,t){return t?t.reduce((r,n)=>r?.[n],e):e}function W2(e){let t=Object.keys(e),r=t.map(n=>e[n]);return Promise.all(r).then(n=>{let i={};for(let o=0;o<t.length;o++)i[t[o]]=n[o];return i})}function q2(e=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<e;n++)r+=t[Math.floor(Math.random()*t.length)];return r}function Ap(e){return JSON.stringify(e)}function cv(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Cp="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Ya(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var uv=bc(()=>{if(Xa.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function Do(e){if(Ya(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(Ya(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function lv(e){return Do(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function K2(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}var J2=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}`)}},pl=new Set(["string","number","symbol"]),dv=new Set(["string","number","bigint","boolean","symbol","undefined"]);function on(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function rt(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}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 X2(e){let t;return new Proxy({},{get(r,n,i){return t??(t=e()),Reflect.get(t,n,i)},set(r,n,i,o){return t??(t=e()),Reflect.set(t,n,i,o)},has(r,n){return t??(t=e()),Reflect.has(t,n)},deleteProperty(r,n){return t??(t=e()),Reflect.deleteProperty(t,n)},ownKeys(r){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(r,n){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,n)},defineProperty(r,n,i){return t??(t=e()),Reflect.defineProperty(t,n,i)}})}function j(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function fv(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var pv={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]},mv={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Y2(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let o=Mi(e._zod.def,{get shape(){let a={};for(let s in t){if(!(s in r.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&(a[s]=r.shape[s])}return Mo(this,"shape",a),a},checks:[]});return rt(e,o)}function Q2(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let o=Mi(e._zod.def,{get shape(){let a={...e._zod.def.shape};for(let s in t){if(!(s in r.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&delete a[s]}return Mo(this,"shape",a),a},checks:[]});return rt(e,o)}function e6(e,t){if(!Do(t))throw new Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let o=e._zod.def.shape;for(let a in t)if(Object.getOwnPropertyDescriptor(o,a)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let i=Mi(e._zod.def,{get shape(){let o={...e._zod.def.shape,...t};return Mo(this,"shape",o),o}});return rt(e,i)}function t6(e,t){if(!Do(t))throw new Error("Invalid input to safeExtend: expected a plain object");let r=Mi(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Mo(this,"shape",n),n}});return rt(e,r)}function r6(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=Mi(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return Mo(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return rt(e,r)}function n6(e,t,r){let i=t._zod.def.checks;if(i&&i.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");let a=Mi(t._zod.def,{get shape(){let s=t._zod.def.shape,c={...s};if(r)for(let u in r){if(!(u in s))throw new Error(`Unrecognized key: "${u}"`);r[u]&&(c[u]=e?new e({type:"optional",innerType:s[u]}):s[u])}else for(let u in s)c[u]=e?new e({type:"optional",innerType:s[u]}):s[u];return Mo(this,"shape",c),c},checks:[]});return rt(t,a)}function i6(e,t,r){let n=Mi(t._zod.def,{get shape(){let i=t._zod.def.shape,o={...i};if(r)for(let a in r){if(!(a in o))throw new Error(`Unrecognized key: "${a}"`);r[a]&&(o[a]=new e({type:"nonoptional",innerType:i[a]}))}else for(let a in i)o[a]=new e({type:"nonoptional",innerType:i[a]});return Mo(this,"shape",o),o}});return rt(t,n)}function zo(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 hv(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 Cr(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function ll(e){return typeof e=="string"?e:e?.message}function vr(e,t,r){let n=e.message?e.message:ll(e.inst?._zod.def?.error?.(e))??ll(t?.error?.(e))??ll(r.customError?.(e))??ll(r.localeError?.(e))??"Invalid input",{inst:i,continue:o,input:a,...s}=e;return s.path??(s.path=[]),s.message=n,t?.reportInput&&(s.input=a),s}function ml(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function hl(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 wc(...e){let[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}function o6(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function AC(e){let t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}function CC(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function a6(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return AC(t+r)}function s6(e){return CC(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function c6(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 n=0;n<t.length;n+=2)r[n/2]=Number.parseInt(t.slice(n,n+2),16);return r}function u6(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var av=class{constructor(...t){}};var OC=(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,vc,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},gl=k("$ZodError",OC),Or=k("$ZodError",OC,{Parent:Error});function _l(e,t=r=>r.message){let r={},n=[];for(let i of e.issues)i.path.length>0?(r[i.path[0]]=r[i.path[0]]||[],r[i.path[0]].push(t(i))):n.push(t(i));return{formErrors:n,fieldErrors:r}}function yl(e,t=r=>r.message){let r={_errors:[]},n=(i,o=[])=>{for(let a of i.issues)if(a.code==="invalid_union"&&a.errors.length)a.errors.map(s=>n({issues:s},[...o,...a.path]));else if(a.code==="invalid_key")n({issues:a.issues},[...o,...a.path]);else if(a.code==="invalid_element")n({issues:a.issues},[...o,...a.path]);else{let s=[...o,...a.path];if(s.length===0)r._errors.push(t(a));else{let c=r,u=0;for(;u<s.length;){let l=s[u];u===s.length-1?(c[l]=c[l]||{_errors:[]},c[l]._errors.push(t(a))):c[l]=c[l]||{_errors:[]},c=c[l],u++}}}};return n(e),r}function gv(e,t=r=>r.message){let r={errors:[]},n=(i,o=[])=>{var a,s;for(let c of i.issues)if(c.code==="invalid_union"&&c.errors.length)c.errors.map(u=>n({issues:u},[...o,...c.path]));else if(c.code==="invalid_key")n({issues:c.issues},[...o,...c.path]);else if(c.code==="invalid_element")n({issues:c.issues},[...o,...c.path]);else{let u=[...o,...c.path];if(u.length===0){r.errors.push(t(c));continue}let l=r,d=0;for(;d<u.length;){let f=u[d],p=d===u.length-1;typeof f=="string"?(l.properties??(l.properties={}),(a=l.properties)[f]??(a[f]={errors:[]}),l=l.properties[f]):(l.items??(l.items=[]),(s=l.items)[f]??(s[f]={errors:[]}),l=l.items[f]),p&&l.errors.push(t(c)),d++}}};return n(e),r}function PC(e){let t=[],r=e.map(n=>typeof n=="object"?n.key:n);for(let n of r)typeof n=="number"?t.push(`[${n}]`):typeof n=="symbol"?t.push(`[${JSON.stringify(String(n))}]`):/[^\w$]/.test(n)?t.push(`[${JSON.stringify(n)}]`):(t.length&&t.push("."),t.push(n));return t.join("")}function _v(e){let t=[],r=[...e.issues].sort((n,i)=>(n.path??[]).length-(i.path??[]).length);for(let n of r)t.push(`\u2716 ${n.message}`),n.path?.length&&t.push(` \u2192 at ${PC(n.path)}`);return t.join(`
163
- `)}var xc=e=>(t,r,n,i)=>{let o=n?{...n,async:!1}:{async:!1},a=t._zod.run({value:r,issues:[]},o);if(a instanceof Promise)throw new Sn;if(a.issues.length){let s=new(i?.Err??e)(a.issues.map(c=>vr(c,o,pt())));throw Cp(s,i?.callee),s}return a.value},Uo=xc(Or),Sc=e=>async(t,r,n,i)=>{let o=n?{...n,async:!0}:{async:!0},a=t._zod.run({value:r,issues:[]},o);if(a instanceof Promise&&(a=await a),a.issues.length){let s=new(i?.Err??e)(a.issues.map(c=>vr(c,o,pt())));throw Cp(s,i?.callee),s}return a.value},Qa=Sc(Or),kc=e=>(t,r,n)=>{let i=n?{...n,async:!1}:{async:!1},o=t._zod.run({value:r,issues:[]},i);if(o instanceof Promise)throw new Sn;return o.issues.length?{success:!1,error:new(e??gl)(o.issues.map(a=>vr(a,i,pt())))}:{success:!0,data:o.value}},yv=kc(Or),Ec=e=>async(t,r,n)=>{let i=n?{...n,async:!0}:{async:!0},o=t._zod.run({value:r,issues:[]},i);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new e(o.issues.map(a=>vr(a,i,pt())))}:{success:!0,data:o.value}},vv=Ec(Or),Op=e=>(t,r,n)=>{let i=n?{...n,direction:"backward"}:{direction:"backward"};return xc(e)(t,r,i)},d6=Op(Or),Pp=e=>(t,r,n)=>xc(e)(t,r,n),f6=Pp(Or),Np=e=>async(t,r,n)=>{let i=n?{...n,direction:"backward"}:{direction:"backward"};return Sc(e)(t,r,i)},p6=Np(Or),Rp=e=>async(t,r,n)=>Sc(e)(t,r,n),m6=Rp(Or),jp=e=>(t,r,n)=>{let i=n?{...n,direction:"backward"}:{direction:"backward"};return kc(e)(t,r,i)},h6=jp(Or),Mp=e=>(t,r,n)=>kc(e)(t,r,n),g6=Mp(Or),Dp=e=>async(t,r,n)=>{let i=n?{...n,direction:"backward"}:{direction:"backward"};return Ec(e)(t,r,i)},_6=Dp(Or),zp=e=>async(t,r,n)=>Ec(e)(t,r,n),y6=zp(Or);var Wr={};Fn(Wr,{base64:()=>jv,base64url:()=>Up,bigint:()=>Bv,boolean:()=>Hv,browserEmail:()=>I6,cidrv4:()=>Nv,cidrv6:()=>Rv,cuid:()=>bv,cuid2:()=>wv,date:()=>zv,datetime:()=>Lv,domain:()=>A6,duration:()=>Iv,e164:()=>Dv,email:()=>Tv,emoji:()=>Av,extendedDuration:()=>v6,guid:()=>$v,hex:()=>C6,hostname:()=>T6,html5Email:()=>S6,httpProtocol:()=>Mv,idnEmail:()=>E6,integer:()=>Vv,ipv4:()=>Cv,ipv6:()=>Ov,ksuid:()=>kv,lowercase:()=>Wv,mac:()=>Pv,md5_base64:()=>P6,md5_base64url:()=>N6,md5_hex:()=>O6,nanoid:()=>Ev,null:()=>Zv,number:()=>Lp,rfc5322Email:()=>k6,sha1_base64:()=>j6,sha1_base64url:()=>M6,sha1_hex:()=>R6,sha256_base64:()=>z6,sha256_base64url:()=>U6,sha256_hex:()=>D6,sha384_base64:()=>F6,sha384_base64url:()=>B6,sha384_hex:()=>L6,sha512_base64:()=>H6,sha512_base64url:()=>Z6,sha512_hex:()=>V6,string:()=>Fv,time:()=>Uv,ulid:()=>xv,undefined:()=>Gv,unicodeEmail:()=>NC,uppercase:()=>qv,uuid:()=>es,uuid4:()=>b6,uuid6:()=>w6,uuid7:()=>x6,xid:()=>Sv});var bv=/^[cC][0-9a-z]{6,}$/,wv=/^[0-9a-z]+$/,xv=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Sv=/^[0-9a-vA-V]{20}$/,kv=/^[A-Za-z0-9]{27}$/,Ev=/^[a-zA-Z0-9_-]{21}$/,Iv=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,v6=/^[-+]?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)?)??$/,$v=/^([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})$/,es=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)$/,b6=es(4),w6=es(6),x6=es(7),Tv=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,S6=/^[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])?)*$/,k6=/^(([^<>()\[\]\\.,;:\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,}))$/,NC=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,E6=NC,I6=/^[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])?)*$/,$6="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Av(){return new RegExp($6,"u")}var Cv=/^(?:(?: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])$/,Ov=/^(([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}|:))$/,Pv=e=>{let t=on(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},Nv=/^((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])$/,Rv=/^(([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])$/,jv=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Up=/^[A-Za-z0-9_-]*$/,T6=/^(?=.{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])?)*\.?$/,A6=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,Mv=/^https?$/,Dv=/^\+[1-9]\d{6,14}$/,RC="(?:(?:\\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])))",zv=new RegExp(`^${RC}$`);function jC(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 Uv(e){return new RegExp(`^${jC(e)}$`)}function Lv(e){let t=jC({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${t}(?:${r.join("|")})`;return new RegExp(`^${RC}T(?:${n})$`)}var Fv=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Bv=/^-?\d+n?$/,Vv=/^-?\d+$/,Lp=/^-?\d+(?:\.\d+)?$/,Hv=/^(?:true|false)$/i,Zv=/^null$/i;var Gv=/^undefined$/i;var Wv=/^[^A-Z]*$/,qv=/^[^a-z]*$/,C6=/^[0-9a-fA-F]*$/;function vl(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function bl(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}var O6=/^[0-9a-fA-F]{32}$/,P6=vl(22,"=="),N6=bl(22),R6=/^[0-9a-fA-F]{40}$/,j6=vl(27,"="),M6=bl(27),D6=/^[0-9a-fA-F]{64}$/,z6=vl(43,"="),U6=bl(43),L6=/^[0-9a-fA-F]{96}$/,F6=vl(64,""),B6=bl(64),V6=/^[0-9a-fA-F]{128}$/,H6=vl(86,"=="),Z6=bl(86);var We=k("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),DC={number:"number",bigint:"bigint",object:"date"},Fp=k("$ZodCheckLessThan",(e,t)=>{We.init(e,t);let r=DC[typeof t.value];e._zod.onattach.push(n=>{let i=n._zod.bag,o=(t.inclusive?i.maximum:i.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<o&&(t.inclusive?i.maximum=t.value:i.exclusiveMaximum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:r,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Bp=k("$ZodCheckGreaterThan",(e,t)=>{We.init(e,t);let r=DC[typeof t.value];e._zod.onattach.push(n=>{let i=n._zod.bag,o=(t.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>o&&(t.inclusive?i.minimum=t.value:i.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Kv=k("$ZodCheckMultipleOf",(e,t)=>{We.init(e,t),e._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.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):sv(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})}}),Jv=k("$ZodCheckNumberFormat",(e,t)=>{We.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[i,o]=pv[t.format];e._zod.onattach.push(a=>{let s=a._zod.bag;s.format=t.format,s.minimum=i,s.maximum=o,r&&(s.pattern=Vv)}),e._zod.check=a=>{let s=a.value;if(r){if(!Number.isInteger(s)){a.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?a.issues.push({input:s,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}):a.issues.push({input:s,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}s<i&&a.issues.push({origin:"number",input:s,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>o&&a.issues.push({origin:"number",input:s,code:"too_big",maximum:o,inclusive:!0,inst:e,continue:!t.abort})}}),Xv=k("$ZodCheckBigIntFormat",(e,t)=>{We.init(e,t);let[r,n]=mv[t.format];e._zod.onattach.push(i=>{let o=i._zod.bag;o.format=t.format,o.minimum=r,o.maximum=n}),e._zod.check=i=>{let o=i.value;o<r&&i.issues.push({origin:"bigint",input:o,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),o>n&&i.issues.push({origin:"bigint",input:o,code:"too_big",maximum:n,inclusive:!0,inst:e,continue:!t.abort})}}),Yv=k("$ZodCheckMaxSize",(e,t)=>{var r;We.init(e,t),(r=e._zod.def).when??(r.when=n=>{let i=n.value;return!jo(i)&&i.size!==void 0}),e._zod.onattach.push(n=>{let i=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<i&&(n._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let i=n.value;i.size<=t.maximum||n.issues.push({origin:ml(i),code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),Qv=k("$ZodCheckMinSize",(e,t)=>{var r;We.init(e,t),(r=e._zod.def).when??(r.when=n=>{let i=n.value;return!jo(i)&&i.size!==void 0}),e._zod.onattach.push(n=>{let i=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>i&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let i=n.value;i.size>=t.minimum||n.issues.push({origin:ml(i),code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),eb=k("$ZodCheckSizeEquals",(e,t)=>{var r;We.init(e,t),(r=e._zod.def).when??(r.when=n=>{let i=n.value;return!jo(i)&&i.size!==void 0}),e._zod.onattach.push(n=>{let i=n._zod.bag;i.minimum=t.size,i.maximum=t.size,i.size=t.size}),e._zod.check=n=>{let i=n.value,o=i.size;if(o===t.size)return;let a=o>t.size;n.issues.push({origin:ml(i),...a?{code:"too_big",maximum:t.size}:{code:"too_small",minimum:t.size},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),tb=k("$ZodCheckMaxLength",(e,t)=>{var r;We.init(e,t),(r=e._zod.def).when??(r.when=n=>{let i=n.value;return!jo(i)&&i.length!==void 0}),e._zod.onattach.push(n=>{let i=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<i&&(n._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let i=n.value;if(i.length<=t.maximum)return;let a=hl(i);n.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),rb=k("$ZodCheckMinLength",(e,t)=>{var r;We.init(e,t),(r=e._zod.def).when??(r.when=n=>{let i=n.value;return!jo(i)&&i.length!==void 0}),e._zod.onattach.push(n=>{let i=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>i&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let i=n.value;if(i.length>=t.minimum)return;let a=hl(i);n.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),nb=k("$ZodCheckLengthEquals",(e,t)=>{var r;We.init(e,t),(r=e._zod.def).when??(r.when=n=>{let i=n.value;return!jo(i)&&i.length!==void 0}),e._zod.onattach.push(n=>{let i=n._zod.bag;i.minimum=t.length,i.maximum=t.length,i.length=t.length}),e._zod.check=n=>{let i=n.value,o=i.length;if(o===t.length)return;let a=hl(i),s=o>t.length;n.issues.push({origin:a,...s?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Ic=k("$ZodCheckStringFormat",(e,t)=>{var r,n;We.init(e,t),e._zod.onattach.push(i=>{let o=i._zod.bag;o.format=t.format,t.pattern&&(o.patterns??(o.patterns=new Set),o.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=i=>{t.pattern.lastIndex=0,!t.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:t.format,input:i.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),ib=k("$ZodCheckRegex",(e,t)=>{Ic.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})}}),ob=k("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Wv),Ic.init(e,t)}),ab=k("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=qv),Ic.init(e,t)}),sb=k("$ZodCheckIncludes",(e,t)=>{We.init(e,t);let r=on(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push(i=>{let o=i._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=i=>{i.value.includes(t.includes,t.position)||i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:i.value,inst:e,continue:!t.abort})}}),cb=k("$ZodCheckStartsWith",(e,t)=>{We.init(e,t);let r=new RegExp(`^${on(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{let i=n._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),ub=k("$ZodCheckEndsWith",(e,t)=>{We.init(e,t);let r=new RegExp(`.*${on(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{let i=n._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}});function MC(e,t,r){e.issues.length&&t.issues.push(...Cr(r,e.issues))}var lb=k("$ZodCheckProperty",(e,t)=>{We.init(e,t),e._zod.check=r=>{let n=t.schema._zod.run({value:r.value[t.property],issues:[]},{});if(n instanceof Promise)return n.then(i=>MC(i,r,t.property));MC(n,r,t.property)}}),db=k("$ZodCheckMimeType",(e,t)=>{We.init(e,t);let r=new Set(t.mime);e._zod.onattach.push(n=>{n._zod.bag.mime=t.mime}),e._zod.check=n=>{r.has(n.value.type)||n.issues.push({code:"invalid_value",values:t.mime,input:n.value.type,inst:e,continue:!t.abort})}}),fb=k("$ZodCheckOverwrite",(e,t)=>{We.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});var wl=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 n=t.split(`
164
- `).filter(a=>a),i=Math.min(...n.map(a=>a.length-a.trimStart().length)),o=n.map(a=>a.slice(i)).map(a=>" ".repeat(this.indent*2)+a);for(let a of o)this.content.push(a)}compile(){let t=Function,r=this?.args,i=[...(this?.content??[""]).map(o=>` ${o}`)];return new t(...r,i.join(`
165
- `))}};var pb={major:4,minor:4,patch:3};var he=k("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=pb;let n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(let i of n)for(let o of i._zod.onattach)o(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let i=(a,s,c)=>{let u=zo(a),l;for(let d of s){if(d._zod.def.when){if(hv(a)||!d._zod.def.when(a))continue}else if(u)continue;let f=a.issues.length,p=d._zod.check(a);if(p instanceof Promise&&c?.async===!1)throw new Sn;if(l||p instanceof Promise)l=(l??Promise.resolve()).then(async()=>{await p,a.issues.length!==f&&(u||(u=zo(a,f)))});else{if(a.issues.length===f)continue;u||(u=zo(a,f))}}return l?l.then(()=>a):a},o=(a,s,c)=>{if(zo(a))return a.aborted=!0,a;let u=i(s,n,c);if(u instanceof Promise){if(c.async===!1)throw new Sn;return u.then(l=>e._zod.parse(l,c))}return e._zod.parse(u,c)};e._zod.run=(a,s)=>{if(s.skipChecks)return e._zod.parse(a,s);if(s.direction==="backward"){let u=e._zod.parse({value:a.value,issues:[]},{...s,skipChecks:!0});return u instanceof Promise?u.then(l=>o(l,a,s)):o(u,a,s)}let c=e._zod.parse(a,s);if(c instanceof Promise){if(s.async===!1)throw new Sn;return c.then(u=>i(u,n,s))}return i(c,n,s)}}Ie(e,"~standard",()=>({validate:i=>{try{let o=yv(e,i);return o.success?{value:o.data}:{issues:o.error?.issues}}catch{return vv(e,i).then(a=>a.success?{value:a.data}:{issues:a.error?.issues})}},vendor:"zod",version:1}))}),ts=k("$ZodString",(e,t)=>{he.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Fv(e._zod.bag),e._zod.parse=(r,n)=>{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}}),He=k("$ZodStringFormat",(e,t)=>{Ic.init(e,t),ts.init(e,t)}),hb=k("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=$v),He.init(e,t)}),gb=k("$ZodUUID",(e,t)=>{if(t.version){let n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=es(n))}else t.pattern??(t.pattern=es());He.init(e,t)}),_b=k("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Tv),He.init(e,t)}),yb=k("$ZodURL",(e,t)=>{He.init(e,t),e._zod.check=r=>{try{let n=r.value.trim();if(!t.normalize&&t.protocol?.source===Mv.source&&!/^https?:\/\//i.test(n)){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}let i=new URL(n);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.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(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.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=i.href:r.value=n;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),vb=k("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Av()),He.init(e,t)}),bb=k("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Ev),He.init(e,t)}),wb=k("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=bv),He.init(e,t)}),xb=k("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=wv),He.init(e,t)}),Sb=k("$ZodULID",(e,t)=>{t.pattern??(t.pattern=xv),He.init(e,t)}),kb=k("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Sv),He.init(e,t)}),Eb=k("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=kv),He.init(e,t)}),Ib=k("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Lv(t)),He.init(e,t)}),$b=k("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=zv),He.init(e,t)}),Tb=k("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Uv(t)),He.init(e,t)}),Ab=k("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Iv),He.init(e,t)}),Cb=k("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Cv),He.init(e,t),e._zod.bag.format="ipv4"}),Ob=k("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Ov),He.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})}}}),Pb=k("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=Pv(t.delimiter)),He.init(e,t),e._zod.bag.format="mac"}),Nb=k("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Nv),He.init(e,t)}),Rb=k("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Rv),He.init(e,t),e._zod.check=r=>{let n=r.value.split("/");try{if(n.length!==2)throw new Error;let[i,o]=n;if(!o)throw new Error;let a=Number(o);if(`${a}`!==o)throw new Error;if(a<0||a>128)throw new Error;new URL(`http://[${i}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function jb(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var Mb=k("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=jv),He.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=r=>{jb(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function QC(e){if(!Up.test(e))return!1;let t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return jb(r)}var Db=k("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Up),He.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=r=>{QC(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),zb=k("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Dv),He.init(e,t)});function eO(e,t=null){try{let r=e.split(".");if(r.length!==3)return!1;let[n]=r;if(!n)return!1;let i=JSON.parse(atob(n));return!("typ"in i&&i?.typ!=="JWT"||!i.alg||t&&(!("alg"in i)||i.alg!==t))}catch{return!1}}var Ub=k("$ZodJWT",(e,t)=>{He.init(e,t),e._zod.check=r=>{eO(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),Lb=k("$ZodCustomStringFormat",(e,t)=>{He.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})}}),Wp=k("$ZodNumber",(e,t)=>{he.init(e,t),e._zod.pattern=e._zod.bag.pattern??Lp,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}let i=r.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return r;let o=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...o?{received:o}:{}}),r}}),Fb=k("$ZodNumberFormat",(e,t)=>{Jv.init(e,t),Wp.init(e,t)}),xl=k("$ZodBoolean",(e,t)=>{he.init(e,t),e._zod.pattern=Hv,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=!!r.value}catch{}let i=r.value;return typeof i=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:e}),r}}),qp=k("$ZodBigInt",(e,t)=>{he.init(e,t),e._zod.pattern=Bv,e._zod.parse=(r,n)=>{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}}),Bb=k("$ZodBigIntFormat",(e,t)=>{Xv.init(e,t),qp.init(e,t)}),Vb=k("$ZodSymbol",(e,t)=>{he.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;return typeof i=="symbol"||r.issues.push({expected:"symbol",code:"invalid_type",input:i,inst:e}),r}}),Hb=k("$ZodUndefined",(e,t)=>{he.init(e,t),e._zod.pattern=Gv,e._zod.values=new Set([void 0]),e._zod.parse=(r,n)=>{let i=r.value;return typeof i>"u"||r.issues.push({expected:"undefined",code:"invalid_type",input:i,inst:e}),r}}),Zb=k("$ZodNull",(e,t)=>{he.init(e,t),e._zod.pattern=Zv,e._zod.values=new Set([null]),e._zod.parse=(r,n)=>{let i=r.value;return i===null||r.issues.push({expected:"null",code:"invalid_type",input:i,inst:e}),r}}),Gb=k("$ZodAny",(e,t)=>{he.init(e,t),e._zod.parse=r=>r}),Sl=k("$ZodUnknown",(e,t)=>{he.init(e,t),e._zod.parse=r=>r}),kl=k("$ZodNever",(e,t)=>{he.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)}),Wb=k("$ZodVoid",(e,t)=>{he.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;return typeof i>"u"||r.issues.push({expected:"void",code:"invalid_type",input:i,inst:e}),r}}),qb=k("$ZodDate",(e,t)=>{he.init(e,t),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=new Date(r.value)}catch{}let i=r.value,o=i instanceof Date;return o&&!Number.isNaN(i.getTime())||r.issues.push({expected:"date",code:"invalid_type",input:i,...o?{received:"Invalid Date"}:{},inst:e}),r}});function UC(e,t,r){e.issues.length&&t.issues.push(...Cr(r,e.issues)),t.value[r]=e.value}var Kb=k("$ZodArray",(e,t)=>{he.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;if(!Array.isArray(i))return r.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),r;r.value=Array(i.length);let o=[];for(let a=0;a<i.length;a++){let s=i[a],c=t.element._zod.run({value:s,issues:[]},n);c instanceof Promise?o.push(c.then(u=>UC(u,r,a))):UC(c,r,a)}return o.length?Promise.all(o).then(()=>r):r}});function Gp(e,t,r,n,i,o){let a=r in n;if(e.issues.length){if(i&&o&&!a)return;t.issues.push(...Cr(r,e.issues))}if(!a&&!i){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}e.value===void 0?a&&(t.value[r]=void 0):t.value[r]=e.value}function tO(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);let r=fv(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function rO(e,t,r,n,i,o){let a=[],s=i.keySet,c=i.catchall._zod,u=c.def.type,l=c.optin==="optional",d=c.optout==="optional";for(let f in t){if(f==="__proto__"||s.has(f))continue;if(u==="never"){a.push(f);continue}let p=c.run({value:t[f],issues:[]},n);p instanceof Promise?e.push(p.then(m=>Gp(m,r,f,t,l,d))):Gp(p,r,f,t,l,d)}return a.length&&r.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:o}),e.length?Promise.all(e).then(()=>r):r}var nO=k("$ZodObject",(e,t)=>{if(he.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 n=bc(()=>tO(t));Ie(e._zod,"propValues",()=>{let s=t.shape,c={};for(let u in s){let l=s[u]._zod;if(l.values){c[u]??(c[u]=new Set);for(let d of l.values)c[u].add(d)}}return c});let i=Ya,o=t.catchall,a;e._zod.parse=(s,c)=>{a??(a=n.value);let u=s.value;if(!i(u))return s.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),s;s.value={};let l=[],d=a.shape;for(let f of a.keys){let p=d[f],m=p._zod.optin==="optional",h=p._zod.optout==="optional",_=p._zod.run({value:u[f],issues:[]},c);_ instanceof Promise?l.push(_.then(y=>Gp(y,s,f,u,m,h))):Gp(_,s,f,u,m,h)}return o?rO(l,u,s,c,n.value,e):l.length?Promise.all(l).then(()=>s):s}}),Jb=k("$ZodObjectJIT",(e,t)=>{nO.init(e,t);let r=e._zod.parse,n=bc(()=>tO(t)),i=f=>{let p=new wl(["shape","payload","ctx"]),m=n.value,h=x=>{let S=Ap(x);return`shape[${S}]._zod.run({ value: input[${S}], issues: [] }, ctx)`};p.write("const input = payload.value;");let _=Object.create(null),y=0;for(let x of m.keys)_[x]=`key_${y++}`;p.write("const newResult = {};");for(let x of m.keys){let S=_[x],E=Ap(x),C=f[x],T=C?._zod?.optin==="optional",b=C?._zod?.optout==="optional";p.write(`const ${S} = ${h(x)};`),T&&b?p.write(`
166
- if (${S}.issues.length) {
167
- if (${E} in input) {
168
- payload.issues = payload.issues.concat(${S}.issues.map(iss => ({
169
- ...iss,
170
- path: iss.path ? [${E}, ...iss.path] : [${E}]
171
- })));
172
- }
173
- }
174
-
175
- if (${S}.value === undefined) {
176
- if (${E} in input) {
177
- newResult[${E}] = undefined;
178
- }
179
- } else {
180
- newResult[${E}] = ${S}.value;
181
- }
182
-
183
- `):T?p.write(`
184
- if (${S}.issues.length) {
185
- payload.issues = payload.issues.concat(${S}.issues.map(iss => ({
186
- ...iss,
187
- path: iss.path ? [${E}, ...iss.path] : [${E}]
188
- })));
189
- }
190
-
191
- if (${S}.value === undefined) {
192
- if (${E} in input) {
193
- newResult[${E}] = undefined;
194
- }
195
- } else {
196
- newResult[${E}] = ${S}.value;
197
- }
198
-
199
- `):p.write(`
200
- const ${S}_present = ${E} in input;
201
- if (${S}.issues.length) {
202
- payload.issues = payload.issues.concat(${S}.issues.map(iss => ({
203
- ...iss,
204
- path: iss.path ? [${E}, ...iss.path] : [${E}]
205
- })));
206
- }
207
- if (!${S}_present && !${S}.issues.length) {
208
- payload.issues.push({
209
- code: "invalid_type",
210
- expected: "nonoptional",
211
- input: undefined,
212
- path: [${E}]
213
- });
214
- }
215
-
216
- if (${S}_present) {
217
- if (${S}.value === undefined) {
218
- newResult[${E}] = undefined;
219
- } else {
220
- newResult[${E}] = ${S}.value;
221
- }
222
- }
223
-
224
- `)}p.write("payload.value = newResult;"),p.write("return payload;");let w=p.compile();return(x,S)=>w(f,x,S)},o,a=Ya,s=!Xa.jitless,u=s&&uv.value,l=t.catchall,d;e._zod.parse=(f,p)=>{d??(d=n.value);let m=f.value;return a(m)?s&&u&&p?.async===!1&&p.jitless!==!0?(o||(o=i(t.shape)),f=o(f,p),l?rO([],m,f,p,d,e):f):r(f,p):(f.issues.push({expected:"object",code:"invalid_type",input:m,inst:e}),f)}});function LC(e,t,r,n){for(let o of e)if(o.issues.length===0)return t.value=o.value,t;let i=e.filter(o=>!zo(o));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(o=>o.issues.map(a=>vr(a,n,pt())))}),t)}var El=k("$ZodUnion",(e,t)=>{he.init(e,t),Ie(e._zod,"optin",()=>t.options.some(n=>n._zod.optin==="optional")?"optional":void 0),Ie(e._zod,"optout",()=>t.options.some(n=>n._zod.optout==="optional")?"optional":void 0),Ie(e._zod,"values",()=>{if(t.options.every(n=>n._zod.values))return new Set(t.options.flatMap(n=>Array.from(n._zod.values)))}),Ie(e._zod,"pattern",()=>{if(t.options.every(n=>n._zod.pattern)){let n=t.options.map(i=>i._zod.pattern);return new RegExp(`^(${n.map(i=>fl(i.source)).join("|")})$`)}});let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(n,i)=>{if(r)return r(n,i);let o=!1,a=[];for(let s of t.options){let c=s._zod.run({value:n.value,issues:[]},i);if(c instanceof Promise)a.push(c),o=!0;else{if(c.issues.length===0)return c;a.push(c)}}return o?Promise.all(a).then(s=>LC(s,n,e,i)):LC(a,n,e,i)}});function FC(e,t,r,n){let i=e.filter(o=>o.issues.length===0);return i.length===1?(t.value=i[0].value,t):(i.length===0?t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(o=>o.issues.map(a=>vr(a,n,pt())))}):t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:[],inclusive:!1}),t)}var Xb=k("$ZodXor",(e,t)=>{El.init(e,t),t.inclusive=!1;let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(n,i)=>{if(r)return r(n,i);let o=!1,a=[];for(let s of t.options){let c=s._zod.run({value:n.value,issues:[]},i);c instanceof Promise?(a.push(c),o=!0):a.push(c)}return o?Promise.all(a).then(s=>FC(s,n,e,i)):FC(a,n,e,i)}}),Yb=k("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,El.init(e,t);let r=e._zod.parse;Ie(e._zod,"propValues",()=>{let i={};for(let o of t.options){let a=o._zod.propValues;if(!a||Object.keys(a).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(o)}"`);for(let[s,c]of Object.entries(a)){i[s]||(i[s]=new Set);for(let u of c)i[s].add(u)}}return i});let n=bc(()=>{let i=t.options,o=new Map;for(let a of i){let s=a._zod.propValues?.[t.discriminator];if(!s||s.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(a)}"`);for(let c of s){if(o.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);o.set(c,a)}}return o});e._zod.parse=(i,o)=>{let a=i.value;if(!Ya(a))return i.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),i;let s=n.value.get(a?.[t.discriminator]);return s?s._zod.run(i,o):t.unionFallback||o.direction==="backward"?r(i,o):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(n.value.keys()),input:a,path:[t.discriminator],inst:e}),i)}}),Qb=k("$ZodIntersection",(e,t)=>{he.init(e,t),e._zod.parse=(r,n)=>{let i=r.value,o=t.left._zod.run({value:i,issues:[]},n),a=t.right._zod.run({value:i,issues:[]},n);return o instanceof Promise||a instanceof Promise?Promise.all([o,a]).then(([c,u])=>BC(r,c,u)):BC(r,o,a)}});function mb(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(Do(e)&&Do(t)){let r=Object.keys(t),n=Object.keys(e).filter(o=>r.indexOf(o)!==-1),i={...e,...t};for(let o of n){let a=mb(e[o],t[o]);if(!a.valid)return{valid:!1,mergeErrorPath:[o,...a.mergeErrorPath]};i[o]=a.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<e.length;n++){let i=e[n],o=t[n],a=mb(i,o);if(!a.valid)return{valid:!1,mergeErrorPath:[n,...a.mergeErrorPath]};r.push(a.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function BC(e,t,r){let n=new Map,i;for(let s of t.issues)if(s.code==="unrecognized_keys"){i??(i=s);for(let c of s.keys)n.has(c)||n.set(c,{}),n.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)n.has(c)||n.set(c,{}),n.get(c).r=!0;else e.issues.push(s);let o=[...n].filter(([,s])=>s.l&&s.r).map(([s])=>s);if(o.length&&i&&e.issues.push({...i,keys:o}),zo(e))return e;let a=mb(t.value,r.value);if(!a.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(a.mergeErrorPath)}`);return e.value=a.data,e}var Kp=k("$ZodTuple",(e,t)=>{he.init(e,t);let r=t.items;e._zod.parse=(n,i)=>{let o=n.value;if(!Array.isArray(o))return n.issues.push({input:o,inst:e,expected:"tuple",code:"invalid_type"}),n;n.value=[];let a=[],s=VC(r,"optin"),c=VC(r,"optout");if(!t.rest){if(o.length<s)return n.issues.push({code:"too_small",minimum:s,inclusive:!0,input:o,inst:e,origin:"array"}),n;o.length>r.length&&n.issues.push({code:"too_big",maximum:r.length,inclusive:!0,input:o,inst:e,origin:"array"})}let u=new Array(r.length);for(let l=0;l<r.length;l++){let d=r[l]._zod.run({value:o[l],issues:[]},i);d instanceof Promise?a.push(d.then(f=>{u[l]=f})):u[l]=d}if(t.rest){let l=r.length-1,d=o.slice(r.length);for(let f of d){l++;let p=t.rest._zod.run({value:f,issues:[]},i);p instanceof Promise?a.push(p.then(m=>HC(m,n,l))):HC(p,n,l)}}return a.length?Promise.all(a).then(()=>ZC(u,n,r,o,c)):ZC(u,n,r,o,c)}});function VC(e,t){for(let r=e.length-1;r>=0;r--)if(e[r]._zod[t]!=="optional")return r+1;return 0}function HC(e,t,r){e.issues.length&&t.issues.push(...Cr(r,e.issues)),t.value[r]=e.value}function ZC(e,t,r,n,i){for(let o=0;o<r.length;o++){let a=e[o],s=o<n.length;if(a.issues.length){if(!s&&o>=i){t.value.length=o;break}t.issues.push(...Cr(o,a.issues))}t.value[o]=a.value}for(let o=t.value.length-1;o>=n.length&&(r[o]._zod.optout==="optional"&&t.value[o]===void 0);o--)t.value.length=o;return t}var ew=k("$ZodRecord",(e,t)=>{he.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;if(!Do(i))return r.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),r;let o=[],a=t.keyType._zod.values;if(a){r.value={};let s=new Set;for(let u of a)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){s.add(typeof u=="number"?u.toString():u);let l=t.keyType._zod.run({value:u,issues:[]},n);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(l.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(p=>vr(p,n,pt())),input:u,path:[u],inst:e});continue}let d=l.value,f=t.valueType._zod.run({value:i[u],issues:[]},n);f instanceof Promise?o.push(f.then(p=>{p.issues.length&&r.issues.push(...Cr(u,p.issues)),r.value[d]=p.value})):(f.issues.length&&r.issues.push(...Cr(u,f.issues)),r.value[d]=f.value)}let c;for(let u in i)s.has(u)||(c=c??[],c.push(u));c&&c.length>0&&r.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:c})}else{r.value={};for(let s of Reflect.ownKeys(i)){if(s==="__proto__"||!Object.prototype.propertyIsEnumerable.call(i,s))continue;let c=t.keyType._zod.run({value:s,issues:[]},n);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof s=="string"&&Lp.test(s)&&c.issues.length){let d=t.keyType._zod.run({value:Number(s),issues:[]},n);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]=i[s]:r.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(d=>vr(d,n,pt())),input:s,path:[s],inst:e});continue}let l=t.valueType._zod.run({value:i[s],issues:[]},n);l instanceof Promise?o.push(l.then(d=>{d.issues.length&&r.issues.push(...Cr(s,d.issues)),r.value[c.value]=d.value})):(l.issues.length&&r.issues.push(...Cr(s,l.issues)),r.value[c.value]=l.value)}}return o.length?Promise.all(o).then(()=>r):r}}),tw=k("$ZodMap",(e,t)=>{he.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;if(!(i instanceof Map))return r.issues.push({expected:"map",code:"invalid_type",input:i,inst:e}),r;let o=[];r.value=new Map;for(let[a,s]of i){let c=t.keyType._zod.run({value:a,issues:[]},n),u=t.valueType._zod.run({value:s,issues:[]},n);c instanceof Promise||u instanceof Promise?o.push(Promise.all([c,u]).then(([l,d])=>{GC(l,d,r,a,i,e,n)})):GC(c,u,r,a,i,e,n)}return o.length?Promise.all(o).then(()=>r):r}});function GC(e,t,r,n,i,o,a){e.issues.length&&(pl.has(typeof n)?r.issues.push(...Cr(n,e.issues)):r.issues.push({code:"invalid_key",origin:"map",input:i,inst:o,issues:e.issues.map(s=>vr(s,a,pt()))})),t.issues.length&&(pl.has(typeof n)?r.issues.push(...Cr(n,t.issues)):r.issues.push({origin:"map",code:"invalid_element",input:i,inst:o,key:n,issues:t.issues.map(s=>vr(s,a,pt()))})),r.value.set(e.value,t.value)}var rw=k("$ZodSet",(e,t)=>{he.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;if(!(i instanceof Set))return r.issues.push({input:i,inst:e,expected:"set",code:"invalid_type"}),r;let o=[];r.value=new Set;for(let a of i){let s=t.valueType._zod.run({value:a,issues:[]},n);s instanceof Promise?o.push(s.then(c=>WC(c,r))):WC(s,r)}return o.length?Promise.all(o).then(()=>r):r}});function WC(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}var nw=k("$ZodEnum",(e,t)=>{he.init(e,t);let r=dl(t.entries),n=new Set(r);e._zod.values=n,e._zod.pattern=new RegExp(`^(${r.filter(i=>pl.has(typeof i)).map(i=>typeof i=="string"?on(i):i.toString()).join("|")})$`),e._zod.parse=(i,o)=>{let a=i.value;return n.has(a)||i.issues.push({code:"invalid_value",values:r,input:a,inst:e}),i}}),iw=k("$ZodLiteral",(e,t)=>{if(he.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(n=>typeof n=="string"?on(n):n?on(n.toString()):String(n)).join("|")})$`),e._zod.parse=(n,i)=>{let o=n.value;return r.has(o)||n.issues.push({code:"invalid_value",values:t.values,input:o,inst:e}),n}}),ow=k("$ZodFile",(e,t)=>{he.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;return i instanceof File||r.issues.push({expected:"file",code:"invalid_type",input:i,inst:e}),r}}),aw=k("$ZodTransform",(e,t)=>{he.init(e,t),e._zod.optin="optional",e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Ro(e.constructor.name);let i=t.transform(r.value,r);if(n.async)return(i instanceof Promise?i:Promise.resolve(i)).then(a=>(r.value=a,r.fallback=!0,r));if(i instanceof Promise)throw new Sn;return r.value=i,r.fallback=!0,r}});function qC(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var rs=k("$ZodOptional",(e,t)=>{he.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Ie(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Ie(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${fl(r.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(t.innerType._zod.optin==="optional"){let i=r.value,o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(a=>qC(a,i)):qC(o,i)}return r.value===void 0?r:t.innerType._zod.run(r,n)}}),sw=k("$ZodExactOptional",(e,t)=>{rs.init(e,t),Ie(e._zod,"values",()=>t.innerType._zod.values),Ie(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),cw=k("$ZodNullable",(e,t)=>{he.init(e,t),Ie(e._zod,"optin",()=>t.innerType._zod.optin),Ie(e._zod,"optout",()=>t.innerType._zod.optout),Ie(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${fl(r.source)}|null)$`):void 0}),Ie(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)}),uw=k("$ZodDefault",(e,t)=>{he.init(e,t),e._zod.optin="optional",Ie(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(o=>KC(o,t)):KC(i,t)}});function KC(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var lw=k("$ZodPrefault",(e,t)=>{he.init(e,t),e._zod.optin="optional",Ie(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>(n.direction==="backward"||r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,n))}),dw=k("$ZodNonOptional",(e,t)=>{he.init(e,t),Ie(e._zod,"values",()=>{let r=t.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),e._zod.parse=(r,n)=>{let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(o=>JC(o,e)):JC(i,e)}});function JC(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 fw=k("$ZodSuccess",(e,t)=>{he.init(e,t),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Ro("ZodSuccess");let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(o=>(r.value=o.issues.length===0,r)):(r.value=i.issues.length===0,r)}}),pw=k("$ZodCatch",(e,t)=>{he.init(e,t),e._zod.optin="optional",Ie(e._zod,"optout",()=>t.innerType._zod.optout),Ie(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(o=>(r.value=o.value,o.issues.length&&(r.value=t.catchValue({...r,error:{issues:o.issues.map(a=>vr(a,n,pt()))},input:r.value}),r.issues=[],r.fallback=!0),r)):(r.value=i.value,i.issues.length&&(r.value=t.catchValue({...r,error:{issues:i.issues.map(o=>vr(o,n,pt()))},input:r.value}),r.issues=[],r.fallback=!0),r)}}),mw=k("$ZodNaN",(e,t)=>{he.init(e,t),e._zod.parse=(r,n)=>((typeof r.value!="number"||!Number.isNaN(r.value))&&r.issues.push({input:r.value,inst:e,expected:"nan",code:"invalid_type"}),r)}),Jp=k("$ZodPipe",(e,t)=>{he.init(e,t),Ie(e._zod,"values",()=>t.in._zod.values),Ie(e._zod,"optin",()=>t.in._zod.optin),Ie(e._zod,"optout",()=>t.out._zod.optout),Ie(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,n)=>{if(n.direction==="backward"){let o=t.out._zod.run(r,n);return o instanceof Promise?o.then(a=>Vp(a,t.in,n)):Vp(o,t.in,n)}let i=t.in._zod.run(r,n);return i instanceof Promise?i.then(o=>Vp(o,t.out,n)):Vp(i,t.out,n)}});function Vp(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 Il=k("$ZodCodec",(e,t)=>{he.init(e,t),Ie(e._zod,"values",()=>t.in._zod.values),Ie(e._zod,"optin",()=>t.in._zod.optin),Ie(e._zod,"optout",()=>t.out._zod.optout),Ie(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,n)=>{if((n.direction||"forward")==="forward"){let o=t.in._zod.run(r,n);return o instanceof Promise?o.then(a=>Hp(a,t,n)):Hp(o,t,n)}else{let o=t.out._zod.run(r,n);return o instanceof Promise?o.then(a=>Hp(a,t,n)):Hp(o,t,n)}}});function Hp(e,t,r){if(e.issues.length)return e.aborted=!0,e;if((r.direction||"forward")==="forward"){let i=t.transform(e.value,e);return i instanceof Promise?i.then(o=>Zp(e,o,t.out,r)):Zp(e,i,t.out,r)}else{let i=t.reverseTransform(e.value,e);return i instanceof Promise?i.then(o=>Zp(e,o,t.in,r)):Zp(e,i,t.in,r)}}function Zp(e,t,r,n){return e.issues.length?(e.aborted=!0,e):r._zod.run({value:t,issues:e.issues},n)}var hw=k("$ZodPreprocess",(e,t)=>{Jp.init(e,t)}),gw=k("$ZodReadonly",(e,t)=>{he.init(e,t),Ie(e._zod,"propValues",()=>t.innerType._zod.propValues),Ie(e._zod,"values",()=>t.innerType._zod.values),Ie(e._zod,"optin",()=>t.innerType?._zod?.optin),Ie(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(XC):XC(i)}});function XC(e){return e.value=Object.freeze(e.value),e}var _w=k("$ZodTemplateLiteral",(e,t)=>{he.init(e,t);let r=[];for(let n of t.parts)if(typeof n=="object"&&n!==null){if(!n._zod.pattern)throw new Error(`Invalid template literal part, no pattern found: ${[...n._zod.traits].shift()}`);let i=n._zod.pattern instanceof RegExp?n._zod.pattern.source:n._zod.pattern;if(!i)throw new Error(`Invalid template literal part: ${n._zod.traits}`);let o=i.startsWith("^")?1:0,a=i.endsWith("$")?i.length-1:i.length;r.push(i.slice(o,a))}else if(n===null||dv.has(typeof n))r.push(on(`${n}`));else throw new Error(`Invalid template literal part: ${n}`);e._zod.pattern=new RegExp(`^${r.join("")}$`),e._zod.parse=(n,i)=>typeof n.value!="string"?(n.issues.push({input:n.value,inst:e,expected:"string",code:"invalid_type"}),n):(e._zod.pattern.lastIndex=0,e._zod.pattern.test(n.value)||n.issues.push({input:n.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source}),n)}),yw=k("$ZodFunction",(e,t)=>(he.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(...n){let i=e._def.input?Uo(e._def.input,n):n,o=Reflect.apply(r,this,i);return e._def.output?Uo(e._def.output,o):o}},e.implementAsync=r=>{if(typeof r!="function")throw new Error("implementAsync() must be called with a function");return async function(...n){let i=e._def.input?await Qa(e._def.input,n):n,o=await Reflect.apply(r,this,i);return e._def.output?await Qa(e._def.output,o):o}},e._zod.parse=(r,n)=>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 n=e.constructor;return Array.isArray(r[0])?new n({type:"function",input:new Kp({type:"tuple",items:r[0],rest:r[1]}),output:e._def.output}):new n({type:"function",input:r[0],output:e._def.output})},e.output=r=>{let n=e.constructor;return new n({type:"function",input:e._def.input,output:r})},e)),vw=k("$ZodPromise",(e,t)=>{he.init(e,t),e._zod.parse=(r,n)=>Promise.resolve(r.value).then(i=>t.innerType._zod.run({value:i,issues:[]},n))}),bw=k("$ZodLazy",(e,t)=>{he.init(e,t),Ie(e._zod,"innerType",()=>{let r=t;return r._cachedInner||(r._cachedInner=t.getter()),r._cachedInner}),Ie(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),Ie(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),Ie(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),Ie(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(r,n)=>e._zod.innerType._zod.run(r,n)}),ww=k("$ZodCustom",(e,t)=>{We.init(e,t),he.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{let n=r.value,i=t.fn(n);if(i instanceof Promise)return i.then(o=>YC(o,r,n,e));YC(i,r,n,e)}});function YC(e,t,r,n){if(!e){let i={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(i.params=n._zod.def.params),t.issues.push(wc(i))}}var Tl={};Fn(Tl,{ar:()=>iO,az:()=>oO,be:()=>sO,bg:()=>cO,ca:()=>uO,cs:()=>lO,da:()=>dO,de:()=>fO,el:()=>pO,en:()=>Xp,eo:()=>mO,es:()=>hO,fa:()=>gO,fi:()=>_O,fr:()=>yO,frCA:()=>vO,he:()=>bO,hr:()=>wO,hu:()=>xO,hy:()=>kO,id:()=>EO,is:()=>IO,it:()=>$O,ja:()=>TO,ka:()=>AO,kh:()=>CO,km:()=>Yp,ko:()=>OO,lt:()=>NO,mk:()=>RO,ms:()=>jO,nl:()=>MO,no:()=>DO,ota:()=>zO,pl:()=>LO,ps:()=>UO,pt:()=>FO,ro:()=>BO,ru:()=>HO,sl:()=>ZO,sv:()=>GO,ta:()=>WO,th:()=>qO,tr:()=>KO,ua:()=>JO,uk:()=>Qp,ur:()=>XO,uz:()=>YO,vi:()=>QO,yo:()=>rP,zhCN:()=>eP,zhTW:()=>tP});var W6=()=>{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(i){return e[i]??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"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=M(i.input),s=n[a]??a;return/^[A-Z]/.test(i.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 ${i.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 ${o}\u060C \u0648\u0644\u0643\u0646 \u062A\u0645 \u0625\u062F\u062E\u0627\u0644 ${s}`}case"invalid_value":return i.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 ${j(i.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.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?` \u0623\u0643\u0628\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0623\u0646 \u062A\u0643\u0648\u0646 ${i.origin??"\u0627\u0644\u0642\u064A\u0645\u0629"} ${o} ${i.maximum.toString()} ${a.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 ${i.origin??"\u0627\u0644\u0642\u064A\u0645\u0629"} ${o} ${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`\u0623\u0635\u063A\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0644\u0640 ${i.origin} \u0623\u0646 \u064A\u0643\u0648\u0646 ${o} ${i.minimum.toString()} ${a.unit}`:`\u0623\u0635\u063A\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0644\u0640 ${i.origin} \u0623\u0646 \u064A\u0643\u0648\u0646 ${o} ${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.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 "${i.prefix}"`:o.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 "${o.suffix}"`:o.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 "${o.includes}"`:o.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 ${o.pattern}`:`${r[o.format]??i.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 ${i.divisor}`;case"unrecognized_keys":return`\u0645\u0639\u0631\u0641${i.keys.length>1?"\u0627\u062A":""} \u063A\u0631\u064A\u0628${i.keys.length>1?"\u0629":""}: ${$(i.keys,"\u060C ")}`;case"invalid_key":return`\u0645\u0639\u0631\u0641 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644 \u0641\u064A ${i.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 ${i.origin}`;default:return"\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644"}}};function iO(){return{localeError:W6()}}var q6=()=>{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(i){return e[i]??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"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=M(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n instanceof ${i.expected}, daxil olan ${s}`:`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n ${o}, daxil olan ${s}`}case"invalid_value":return i.values.length===1?`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n ${j(i.values[0])}`:`Yanl\u0131\u015F se\xE7im: a\u015Fa\u011F\u0131dak\u0131lardan biri olmal\u0131d\u0131r: ${$(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`\xC7ox b\xF6y\xFCk: g\xF6zl\u0259nil\u0259n ${i.origin??"d\u0259y\u0259r"} ${o}${i.maximum.toString()} ${a.unit??"element"}`:`\xC7ox b\xF6y\xFCk: g\xF6zl\u0259nil\u0259n ${i.origin??"d\u0259y\u0259r"} ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`\xC7ox ki\xE7ik: g\xF6zl\u0259nil\u0259n ${i.origin} ${o}${i.minimum.toString()} ${a.unit}`:`\xC7ox ki\xE7ik: g\xF6zl\u0259nil\u0259n ${i.origin} ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Yanl\u0131\u015F m\u0259tn: "${o.prefix}" il\u0259 ba\u015Flamal\u0131d\u0131r`:o.format==="ends_with"?`Yanl\u0131\u015F m\u0259tn: "${o.suffix}" il\u0259 bitm\u0259lidir`:o.format==="includes"?`Yanl\u0131\u015F m\u0259tn: "${o.includes}" daxil olmal\u0131d\u0131r`:o.format==="regex"?`Yanl\u0131\u015F m\u0259tn: ${o.pattern} \u015Fablonuna uy\u011Fun olmal\u0131d\u0131r`:`Yanl\u0131\u015F ${r[o.format]??i.format}`}case"not_multiple_of":return`Yanl\u0131\u015F \u0259d\u0259d: ${i.divisor} il\u0259 b\xF6l\xFCn\u0259 bil\u0259n olmal\u0131d\u0131r`;case"unrecognized_keys":return`Tan\u0131nmayan a\xE7ar${i.keys.length>1?"lar":""}: ${$(i.keys,", ")}`;case"invalid_key":return`${i.origin} daxilind\u0259 yanl\u0131\u015F a\xE7ar`;case"invalid_union":return"Yanl\u0131\u015F d\u0259y\u0259r";case"invalid_element":return`${i.origin} daxilind\u0259 yanl\u0131\u015F d\u0259y\u0259r`;default:return"Yanl\u0131\u015F d\u0259y\u0259r"}}};function oO(){return{localeError:q6()}}function aO(e,t,r,n){let i=Math.abs(e),o=i%10,a=i%100;return a>=11&&a<=19?n:o===1?t:o>=2&&o<=4?r:n}var K6=()=>{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(i){return e[i]??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"},n={nan:"NaN",number:"\u043B\u0456\u043A",array:"\u043C\u0430\u0441\u0456\u045E"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=M(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u045E\u0441\u044F instanceof ${i.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 ${o}, \u0430\u0442\u0440\u044B\u043C\u0430\u043D\u0430 ${s}`}case"invalid_value":return i.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 ${j(i.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.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);if(a){let s=Number(i.maximum),c=aO(s,a.unit.one,a.unit.few,a.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 ${i.origin??"\u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435"} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 ${a.verb} ${o}${i.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 ${i.origin??"\u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435"} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 \u0431\u044B\u0446\u044C ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);if(a){let s=Number(i.minimum),c=aO(s,a.unit.one,a.unit.few,a.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 ${i.origin} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 ${a.verb} ${o}${i.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 ${i.origin} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 \u0431\u044B\u0446\u044C ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.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 "${o.prefix}"`:o.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 "${o.suffix}"`:o.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 "${o.includes}"`:o.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 ${o.pattern}`:`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B ${r[o.format]??i.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 ${i.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0441\u043F\u0430\u0437\u043D\u0430\u043D\u044B ${i.keys.length>1?"\u043A\u043B\u044E\u0447\u044B":"\u043A\u043B\u044E\u0447"}: ${$(i.keys,", ")}`;case"invalid_key":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u043A\u043B\u044E\u0447 \u0443 ${i.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 ${i.origin}`;default:return"\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434"}}};function sO(){return{localeError:K6()}}var J6=()=>{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(i){return e[i]??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"},n={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0438\u0432"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=M(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434: \u043E\u0447\u0430\u043A\u0432\u0430\u043D instanceof ${i.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 ${o}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D ${s}`}case"invalid_value":return i.values.length===1?`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434: \u043E\u0447\u0430\u043A\u0432\u0430\u043D ${j(i.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.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`\u0422\u0432\u044A\u0440\u0434\u0435 \u0433\u043E\u043B\u044F\u043C\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${i.origin??"\u0441\u0442\u043E\u0439\u043D\u043E\u0441\u0442"} \u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430 ${o}${i.maximum.toString()} ${a.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 ${i.origin??"\u0441\u0442\u043E\u0439\u043D\u043E\u0441\u0442"} \u0434\u0430 \u0431\u044A\u0434\u0435 ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`\u0422\u0432\u044A\u0440\u0434\u0435 \u043C\u0430\u043B\u043A\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${i.origin} \u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430 ${o}${i.minimum.toString()} ${a.unit}`:`\u0422\u0432\u044A\u0440\u0434\u0435 \u043C\u0430\u043B\u043A\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${i.origin} \u0434\u0430 \u0431\u044A\u0434\u0435 ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;if(o.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 "${o.prefix}"`;if(o.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 "${o.suffix}"`;if(o.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 "${o.includes}"`;if(o.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 ${o.pattern}`;let a="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D";return o.format==="emoji"&&(a="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E"),o.format==="datetime"&&(a="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E"),o.format==="date"&&(a="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430"),o.format==="time"&&(a="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E"),o.format==="duration"&&(a="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430"),`${a} ${r[o.format]??i.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 ${i.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0437\u043F\u043E\u0437\u043D\u0430\u0442${i.keys.length>1?"\u0438":""} \u043A\u043B\u044E\u0447${i.keys.length>1?"\u043E\u0432\u0435":""}: ${$(i.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043A\u043B\u044E\u0447 \u0432 ${i.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 ${i.origin}`;default:return"\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434"}}};function cO(){return{localeError:J6()}}var X6=()=>{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(i){return e[i]??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"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=M(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`Tipus inv\xE0lid: s'esperava instanceof ${i.expected}, s'ha rebut ${s}`:`Tipus inv\xE0lid: s'esperava ${o}, s'ha rebut ${s}`}case"invalid_value":return i.values.length===1?`Valor inv\xE0lid: s'esperava ${j(i.values[0])}`:`Opci\xF3 inv\xE0lida: s'esperava una de ${$(i.values," o ")}`;case"too_big":{let o=i.inclusive?"com a m\xE0xim":"menys de",a=t(i.origin);return a?`Massa gran: s'esperava que ${i.origin??"el valor"} contingu\xE9s ${o} ${i.maximum.toString()} ${a.unit??"elements"}`:`Massa gran: s'esperava que ${i.origin??"el valor"} fos ${o} ${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?"com a m\xEDnim":"m\xE9s de",a=t(i.origin);return a?`Massa petit: s'esperava que ${i.origin} contingu\xE9s ${o} ${i.minimum.toString()} ${a.unit}`:`Massa petit: s'esperava que ${i.origin} fos ${o} ${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Format inv\xE0lid: ha de comen\xE7ar amb "${o.prefix}"`:o.format==="ends_with"?`Format inv\xE0lid: ha d'acabar amb "${o.suffix}"`:o.format==="includes"?`Format inv\xE0lid: ha d'incloure "${o.includes}"`:o.format==="regex"?`Format inv\xE0lid: ha de coincidir amb el patr\xF3 ${o.pattern}`:`Format inv\xE0lid per a ${r[o.format]??i.format}`}case"not_multiple_of":return`N\xFAmero inv\xE0lid: ha de ser m\xFAltiple de ${i.divisor}`;case"unrecognized_keys":return`Clau${i.keys.length>1?"s":""} no reconeguda${i.keys.length>1?"s":""}: ${$(i.keys,", ")}`;case"invalid_key":return`Clau inv\xE0lida a ${i.origin}`;case"invalid_union":return"Entrada inv\xE0lida";case"invalid_element":return`Element inv\xE0lid a ${i.origin}`;default:return"Entrada inv\xE0lida"}}};function uO(){return{localeError:X6()}}var Y6=()=>{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(i){return e[i]??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"},n={nan:"NaN",number:"\u010D\xEDslo",string:"\u0159et\u011Bzec",function:"funkce",array:"pole"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=M(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no instanceof ${i.expected}, obdr\u017Eeno ${s}`:`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no ${o}, obdr\u017Eeno ${s}`}case"invalid_value":return i.values.length===1?`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no ${j(i.values[0])}`:`Neplatn\xE1 mo\u017Enost: o\u010Dek\xE1v\xE1na jedna z hodnot ${$(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`Hodnota je p\u0159\xEDli\u0161 velk\xE1: ${i.origin??"hodnota"} mus\xED m\xEDt ${o}${i.maximum.toString()} ${a.unit??"prvk\u016F"}`:`Hodnota je p\u0159\xEDli\u0161 velk\xE1: ${i.origin??"hodnota"} mus\xED b\xFDt ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`Hodnota je p\u0159\xEDli\u0161 mal\xE1: ${i.origin??"hodnota"} mus\xED m\xEDt ${o}${i.minimum.toString()} ${a.unit??"prvk\u016F"}`:`Hodnota je p\u0159\xEDli\u0161 mal\xE1: ${i.origin??"hodnota"} mus\xED b\xFDt ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED za\u010D\xEDnat na "${o.prefix}"`:o.format==="ends_with"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED kon\u010Dit na "${o.suffix}"`:o.format==="includes"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED obsahovat "${o.includes}"`:o.format==="regex"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED odpov\xEDdat vzoru ${o.pattern}`:`Neplatn\xFD form\xE1t ${r[o.format]??i.format}`}case"not_multiple_of":return`Neplatn\xE9 \u010D\xEDslo: mus\xED b\xFDt n\xE1sobkem ${i.divisor}`;case"unrecognized_keys":return`Nezn\xE1m\xE9 kl\xED\u010De: ${$(i.keys,", ")}`;case"invalid_key":return`Neplatn\xFD kl\xED\u010D v ${i.origin}`;case"invalid_union":return"Neplatn\xFD vstup";case"invalid_element":return`Neplatn\xE1 hodnota v ${i.origin}`;default:return"Neplatn\xFD vstup"}}};function lO(){return{localeError:Y6()}}var Q6=()=>{let e={string:{unit:"tegn",verb:"havde"},file:{unit:"bytes",verb:"havde"},array:{unit:"elementer",verb:"indeholdt"},set:{unit:"elementer",verb:"indeholdt"}};function t(i){return e[i]??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"},n={nan:"NaN",string:"streng",number:"tal",boolean:"boolean",array:"liste",object:"objekt",set:"s\xE6t",file:"fil"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=M(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`Ugyldigt input: forventede instanceof ${i.expected}, fik ${s}`:`Ugyldigt input: forventede ${o}, fik ${s}`}case"invalid_value":return i.values.length===1?`Ugyldig v\xE6rdi: forventede ${j(i.values[0])}`:`Ugyldigt valg: forventede en af f\xF8lgende ${$(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin),s=n[i.origin]??i.origin;return a?`For stor: forventede ${s??"value"} ${a.verb} ${o} ${i.maximum.toString()} ${a.unit??"elementer"}`:`For stor: forventede ${s??"value"} havde ${o} ${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin),s=n[i.origin]??i.origin;return a?`For lille: forventede ${s} ${a.verb} ${o} ${i.minimum.toString()} ${a.unit}`:`For lille: forventede ${s} havde ${o} ${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Ugyldig streng: skal starte med "${o.prefix}"`:o.format==="ends_with"?`Ugyldig streng: skal ende med "${o.suffix}"`:o.format==="includes"?`Ugyldig streng: skal indeholde "${o.includes}"`:o.format==="regex"?`Ugyldig streng: skal matche m\xF8nsteret ${o.pattern}`:`Ugyldig ${r[o.format]??i.format}`}case"not_multiple_of":return`Ugyldigt tal: skal v\xE6re deleligt med ${i.divisor}`;case"unrecognized_keys":return`${i.keys.length>1?"Ukendte n\xF8gler":"Ukendt n\xF8gle"}: ${$(i.keys,", ")}`;case"invalid_key":return`Ugyldig n\xF8gle i ${i.origin}`;case"invalid_union":return"Ugyldigt input: matcher ingen af de tilladte typer";case"invalid_element":return`Ugyldig v\xE6rdi i ${i.origin}`;default:return"Ugyldigt input"}}};function dO(){return{localeError:Q6()}}var eF=()=>{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(i){return e[i]??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"},n={nan:"NaN",number:"Zahl",array:"Array"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=M(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`Ung\xFCltige Eingabe: erwartet instanceof ${i.expected}, erhalten ${s}`:`Ung\xFCltige Eingabe: erwartet ${o}, erhalten ${s}`}case"invalid_value":return i.values.length===1?`Ung\xFCltige Eingabe: erwartet ${j(i.values[0])}`:`Ung\xFCltige Option: erwartet eine von ${$(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`Zu gro\xDF: erwartet, dass ${i.origin??"Wert"} ${o}${i.maximum.toString()} ${a.unit??"Elemente"} hat`:`Zu gro\xDF: erwartet, dass ${i.origin??"Wert"} ${o}${i.maximum.toString()} ist`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`Zu klein: erwartet, dass ${i.origin} ${o}${i.minimum.toString()} ${a.unit} hat`:`Zu klein: erwartet, dass ${i.origin} ${o}${i.minimum.toString()} ist`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Ung\xFCltiger String: muss mit "${o.prefix}" beginnen`:o.format==="ends_with"?`Ung\xFCltiger String: muss mit "${o.suffix}" enden`:o.format==="includes"?`Ung\xFCltiger String: muss "${o.includes}" enthalten`:o.format==="regex"?`Ung\xFCltiger String: muss dem Muster ${o.pattern} entsprechen`:`Ung\xFCltig: ${r[o.format]??i.format}`}case"not_multiple_of":return`Ung\xFCltige Zahl: muss ein Vielfaches von ${i.divisor} sein`;case"unrecognized_keys":return`${i.keys.length>1?"Unbekannte Schl\xFCssel":"Unbekannter Schl\xFCssel"}: ${$(i.keys,", ")}`;case"invalid_key":return`Ung\xFCltiger Schl\xFCssel in ${i.origin}`;case"invalid_union":return"Ung\xFCltige Eingabe";case"invalid_element":return`Ung\xFCltiger Wert in ${i.origin}`;default:return"Ung\xFCltige Eingabe"}}};function fO(){return{localeError:eF()}}var tF=()=>{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(i){return e[i]??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"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=M(i.input),s=n[a]??a;return typeof i.expected=="string"&&/^[A-Z]/.test(i.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 ${i.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 ${o}, \u03BB\u03AE\u03C6\u03B8\u03B7\u03BA\u03B5 ${s}`}case"invalid_value":return i.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 ${j(i.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.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B5\u03B3\u03AC\u03BB\u03BF: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${i.origin??"\u03C4\u03B9\u03BC\u03AE"} \u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9 ${o}${i.maximum.toString()} ${a.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 ${i.origin??"\u03C4\u03B9\u03BC\u03AE"} \u03BD\u03B1 \u03B5\u03AF\u03BD\u03B1\u03B9 ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B9\u03BA\u03C1\u03CC: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${i.origin} \u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9 ${o}${i.minimum.toString()} ${a.unit}`:`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B9\u03BA\u03C1\u03CC: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${i.origin} \u03BD\u03B1 \u03B5\u03AF\u03BD\u03B1\u03B9 ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.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 "${o.prefix}"`:o.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 "${o.suffix}"`:o.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 "${o.includes}"`:o.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 ${o.pattern}`:`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03BF: ${r[o.format]??i.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 ${i.divisor}`;case"unrecognized_keys":return`\u0386\u03B3\u03BD\u03C9\u03C3\u03C4${i.keys.length>1?"\u03B1":"\u03BF"} \u03BA\u03BB\u03B5\u03B9\u03B4${i.keys.length>1?"\u03B9\u03AC":"\u03AF"}: ${$(i.keys,", ")}`;case"invalid_key":return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03BF \u03BA\u03BB\u03B5\u03B9\u03B4\u03AF \u03C3\u03C4\u03BF ${i.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 ${i.origin}`;default:return"\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2"}}};function pO(){return{localeError:tF()}}var rF=()=>{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(i){return e[i]??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"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=M(i.input),s=n[a]??a;return`Invalid input: expected ${o}, received ${s}`}case"invalid_value":return i.values.length===1?`Invalid input: expected ${j(i.values[0])}`:`Invalid option: expected one of ${$(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`Too big: expected ${i.origin??"value"} to have ${o}${i.maximum.toString()} ${a.unit??"elements"}`:`Too big: expected ${i.origin??"value"} to be ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`Too small: expected ${i.origin} to have ${o}${i.minimum.toString()} ${a.unit}`:`Too small: expected ${i.origin} to be ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Invalid string: must start with "${o.prefix}"`:o.format==="ends_with"?`Invalid string: must end with "${o.suffix}"`:o.format==="includes"?`Invalid string: must include "${o.includes}"`:o.format==="regex"?`Invalid string: must match pattern ${o.pattern}`:`Invalid ${r[o.format]??i.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${i.divisor}`;case"unrecognized_keys":return`Unrecognized key${i.keys.length>1?"s":""}: ${$(i.keys,", ")}`;case"invalid_key":return`Invalid key in ${i.origin}`;case"invalid_union":return i.options&&Array.isArray(i.options)&&i.options.length>0?`Invalid discriminator value. Expected ${i.options.map(a=>`'${a}'`).join(" | ")}`:"Invalid input";case"invalid_element":return`Invalid value in ${i.origin}`;default:return"Invalid input"}}};function Xp(){return{localeError:rF()}}var nF=()=>{let e={string:{unit:"karaktrojn",verb:"havi"},file:{unit:"bajtojn",verb:"havi"},array:{unit:"elementojn",verb:"havi"},set:{unit:"elementojn",verb:"havi"}};function t(i){return e[i]??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"},n={nan:"NaN",number:"nombro",array:"tabelo",null:"senvalora"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=M(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`Nevalida enigo: atendi\u011Dis instanceof ${i.expected}, ricevi\u011Dis ${s}`:`Nevalida enigo: atendi\u011Dis ${o}, ricevi\u011Dis ${s}`}case"invalid_value":return i.values.length===1?`Nevalida enigo: atendi\u011Dis ${j(i.values[0])}`:`Nevalida opcio: atendi\u011Dis unu el ${$(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`Tro granda: atendi\u011Dis ke ${i.origin??"valoro"} havu ${o}${i.maximum.toString()} ${a.unit??"elementojn"}`:`Tro granda: atendi\u011Dis ke ${i.origin??"valoro"} havu ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`Tro malgranda: atendi\u011Dis ke ${i.origin} havu ${o}${i.minimum.toString()} ${a.unit}`:`Tro malgranda: atendi\u011Dis ke ${i.origin} estu ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Nevalida karaktraro: devas komenci\u011Di per "${o.prefix}"`:o.format==="ends_with"?`Nevalida karaktraro: devas fini\u011Di per "${o.suffix}"`:o.format==="includes"?`Nevalida karaktraro: devas inkluzivi "${o.includes}"`:o.format==="regex"?`Nevalida karaktraro: devas kongrui kun la modelo ${o.pattern}`:`Nevalida ${r[o.format]??i.format}`}case"not_multiple_of":return`Nevalida nombro: devas esti oblo de ${i.divisor}`;case"unrecognized_keys":return`Nekonata${i.keys.length>1?"j":""} \u015Dlosilo${i.keys.length>1?"j":""}: ${$(i.keys,", ")}`;case"invalid_key":return`Nevalida \u015Dlosilo en ${i.origin}`;case"invalid_union":return"Nevalida enigo";case"invalid_element":return`Nevalida valoro en ${i.origin}`;default:return"Nevalida enigo"}}};function mO(){return{localeError:nF()}}var iF=()=>{let e={string:{unit:"caracteres",verb:"tener"},file:{unit:"bytes",verb:"tener"},array:{unit:"elementos",verb:"tener"},set:{unit:"elementos",verb:"tener"}};function t(i){return e[i]??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"},n={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 i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=M(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`Entrada inv\xE1lida: se esperaba instanceof ${i.expected}, recibido ${s}`:`Entrada inv\xE1lida: se esperaba ${o}, recibido ${s}`}case"invalid_value":return i.values.length===1?`Entrada inv\xE1lida: se esperaba ${j(i.values[0])}`:`Opci\xF3n inv\xE1lida: se esperaba una de ${$(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin),s=n[i.origin]??i.origin;return a?`Demasiado grande: se esperaba que ${s??"valor"} tuviera ${o}${i.maximum.toString()} ${a.unit??"elementos"}`:`Demasiado grande: se esperaba que ${s??"valor"} fuera ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin),s=n[i.origin]??i.origin;return a?`Demasiado peque\xF1o: se esperaba que ${s} tuviera ${o}${i.minimum.toString()} ${a.unit}`:`Demasiado peque\xF1o: se esperaba que ${s} fuera ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Cadena inv\xE1lida: debe comenzar con "${o.prefix}"`:o.format==="ends_with"?`Cadena inv\xE1lida: debe terminar en "${o.suffix}"`:o.format==="includes"?`Cadena inv\xE1lida: debe incluir "${o.includes}"`:o.format==="regex"?`Cadena inv\xE1lida: debe coincidir con el patr\xF3n ${o.pattern}`:`Inv\xE1lido ${r[o.format]??i.format}`}case"not_multiple_of":return`N\xFAmero inv\xE1lido: debe ser m\xFAltiplo de ${i.divisor}`;case"unrecognized_keys":return`Llave${i.keys.length>1?"s":""} desconocida${i.keys.length>1?"s":""}: ${$(i.keys,", ")}`;case"invalid_key":return`Llave inv\xE1lida en ${n[i.origin]??i.origin}`;case"invalid_union":return"Entrada inv\xE1lida";case"invalid_element":return`Valor inv\xE1lido en ${n[i.origin]??i.origin}`;default:return"Entrada inv\xE1lida"}}};function hO(){return{localeError:iF()}}var oF=()=>{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(i){return e[i]??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"},n={nan:"NaN",number:"\u0639\u062F\u062F",array:"\u0622\u0631\u0627\u06CC\u0647"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=M(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A instanceof ${i.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 ${o} \u0645\u06CC\u200C\u0628\u0648\u062F\u060C ${s} \u062F\u0631\u06CC\u0627\u0641\u062A \u0634\u062F`}case"invalid_value":return i.values.length===1?`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A ${j(i.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.values,"|")} \u0645\u06CC\u200C\u0628\u0648\u062F`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`\u062E\u06CC\u0644\u06CC \u0628\u0632\u0631\u06AF: ${i.origin??"\u0645\u0642\u062F\u0627\u0631"} \u0628\u0627\u06CC\u062F ${o}${i.maximum.toString()} ${a.unit??"\u0639\u0646\u0635\u0631"} \u0628\u0627\u0634\u062F`:`\u062E\u06CC\u0644\u06CC \u0628\u0632\u0631\u06AF: ${i.origin??"\u0645\u0642\u062F\u0627\u0631"} \u0628\u0627\u06CC\u062F ${o}${i.maximum.toString()} \u0628\u0627\u0634\u062F`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`\u062E\u06CC\u0644\u06CC \u06A9\u0648\u0686\u06A9: ${i.origin} \u0628\u0627\u06CC\u062F ${o}${i.minimum.toString()} ${a.unit} \u0628\u0627\u0634\u062F`:`\u062E\u06CC\u0644\u06CC \u06A9\u0648\u0686\u06A9: ${i.origin} \u0628\u0627\u06CC\u062F ${o}${i.minimum.toString()} \u0628\u0627\u0634\u062F`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 "${o.prefix}" \u0634\u0631\u0648\u0639 \u0634\u0648\u062F`:o.format==="ends_with"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 "${o.suffix}" \u062A\u0645\u0627\u0645 \u0634\u0648\u062F`:o.format==="includes"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0634\u0627\u0645\u0644 "${o.includes}" \u0628\u0627\u0634\u062F`:o.format==="regex"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC ${o.pattern} \u0645\u0637\u0627\u0628\u0642\u062A \u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F`:`${r[o.format]??i.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 ${i.divisor} \u0628\u0627\u0634\u062F`;case"unrecognized_keys":return`\u06A9\u0644\u06CC\u062F${i.keys.length>1?"\u0647\u0627\u06CC":""} \u0646\u0627\u0634\u0646\u0627\u0633: ${$(i.keys,", ")}`;case"invalid_key":return`\u06A9\u0644\u06CC\u062F \u0646\u0627\u0634\u0646\u0627\u0633 \u062F\u0631 ${i.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 ${i.origin}`;default:return"\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631"}}};function gO(){return{localeError:oF()}}var aF=()=>{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(i){return e[i]??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"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=M(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`Virheellinen tyyppi: odotettiin instanceof ${i.expected}, oli ${s}`:`Virheellinen tyyppi: odotettiin ${o}, oli ${s}`}case"invalid_value":return i.values.length===1?`Virheellinen sy\xF6te: t\xE4ytyy olla ${j(i.values[0])}`:`Virheellinen valinta: t\xE4ytyy olla yksi seuraavista: ${$(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`Liian suuri: ${a.subject} t\xE4ytyy olla ${o}${i.maximum.toString()} ${a.unit}`.trim():`Liian suuri: arvon t\xE4ytyy olla ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`Liian pieni: ${a.subject} t\xE4ytyy olla ${o}${i.minimum.toString()} ${a.unit}`.trim():`Liian pieni: arvon t\xE4ytyy olla ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Virheellinen sy\xF6te: t\xE4ytyy alkaa "${o.prefix}"`:o.format==="ends_with"?`Virheellinen sy\xF6te: t\xE4ytyy loppua "${o.suffix}"`:o.format==="includes"?`Virheellinen sy\xF6te: t\xE4ytyy sis\xE4lt\xE4\xE4 "${o.includes}"`:o.format==="regex"?`Virheellinen sy\xF6te: t\xE4ytyy vastata s\xE4\xE4nn\xF6llist\xE4 lauseketta ${o.pattern}`:`Virheellinen ${r[o.format]??i.format}`}case"not_multiple_of":return`Virheellinen luku: t\xE4ytyy olla luvun ${i.divisor} monikerta`;case"unrecognized_keys":return`${i.keys.length>1?"Tuntemattomat avaimet":"Tuntematon avain"}: ${$(i.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 _O(){return{localeError:aF()}}var sF=()=>{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(i){return e[i]??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"},n={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 i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=M(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`Entr\xE9e invalide : instanceof ${i.expected} attendu, ${s} re\xE7u`:`Entr\xE9e invalide : ${o} attendu, ${s} re\xE7u`}case"invalid_value":return i.values.length===1?`Entr\xE9e invalide : ${j(i.values[0])} attendu`:`Option invalide : une valeur parmi ${$(i.values,"|")} attendue`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`Trop grand : ${n[i.origin]??"valeur"} doit ${a.verb} ${o}${i.maximum.toString()} ${a.unit??"\xE9l\xE9ment(s)"}`:`Trop grand : ${n[i.origin]??"valeur"} doit \xEAtre ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`Trop petit : ${n[i.origin]??"valeur"} doit ${a.verb} ${o}${i.minimum.toString()} ${a.unit}`:`Trop petit : ${n[i.origin]??"valeur"} doit \xEAtre ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Cha\xEEne invalide : doit commencer par "${o.prefix}"`:o.format==="ends_with"?`Cha\xEEne invalide : doit se terminer par "${o.suffix}"`:o.format==="includes"?`Cha\xEEne invalide : doit inclure "${o.includes}"`:o.format==="regex"?`Cha\xEEne invalide : doit correspondre au mod\xE8le ${o.pattern}`:`${r[o.format]??i.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit \xEAtre un multiple de ${i.divisor}`;case"unrecognized_keys":return`Cl\xE9${i.keys.length>1?"s":""} non reconnue${i.keys.length>1?"s":""} : ${$(i.keys,", ")}`;case"invalid_key":return`Cl\xE9 invalide dans ${i.origin}`;case"invalid_union":return"Entr\xE9e invalide";case"invalid_element":return`Valeur invalide dans ${i.origin}`;default:return"Entr\xE9e invalide"}}};function yO(){return{localeError:sF()}}var cF=()=>{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(i){return e[i]??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"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=M(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`Entr\xE9e invalide : attendu instanceof ${i.expected}, re\xE7u ${s}`:`Entr\xE9e invalide : attendu ${o}, re\xE7u ${s}`}case"invalid_value":return i.values.length===1?`Entr\xE9e invalide : attendu ${j(i.values[0])}`:`Option invalide : attendu l'une des valeurs suivantes ${$(i.values,"|")}`;case"too_big":{let o=i.inclusive?"\u2264":"<",a=t(i.origin);return a?`Trop grand : attendu que ${i.origin??"la valeur"} ait ${o}${i.maximum.toString()} ${a.unit}`:`Trop grand : attendu que ${i.origin??"la valeur"} soit ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?"\u2265":">",a=t(i.origin);return a?`Trop petit : attendu que ${i.origin} ait ${o}${i.minimum.toString()} ${a.unit}`:`Trop petit : attendu que ${i.origin} soit ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Cha\xEEne invalide : doit commencer par "${o.prefix}"`:o.format==="ends_with"?`Cha\xEEne invalide : doit se terminer par "${o.suffix}"`:o.format==="includes"?`Cha\xEEne invalide : doit inclure "${o.includes}"`:o.format==="regex"?`Cha\xEEne invalide : doit correspondre au motif ${o.pattern}`:`${r[o.format]??i.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit \xEAtre un multiple de ${i.divisor}`;case"unrecognized_keys":return`Cl\xE9${i.keys.length>1?"s":""} non reconnue${i.keys.length>1?"s":""} : ${$(i.keys,", ")}`;case"invalid_key":return`Cl\xE9 invalide dans ${i.origin}`;case"invalid_union":return"Entr\xE9e invalide";case"invalid_element":return`Valeur invalide dans ${i.origin}`;default:return"Entr\xE9e invalide"}}};function vO(){return{localeError:cF()}}var uF=()=>{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=u=>u?e[u]:void 0,n=u=>{let l=r(u);return l?l.label:u??e.unknown.label},i=u=>`\u05D4${n(u)}`,o=u=>(r(u)?.gender??"m")==="f"?"\u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05D9\u05D5\u05EA":"\u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA",a=u=>u?t[u]??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 u=>{switch(u.code){case"invalid_type":{let l=u.expected,d=c[l??""]??n(l),f=M(u.input),p=c[f]??e[f]?.label??f;return/^[A-Z]/.test(u.expected)?`\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA instanceof ${u.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(u.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 ${j(u.values[0])}`;let l=u.values.map(p=>j(p));if(u.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 ${l[0]} \u05D0\u05D5 ${l[1]}`;let d=l[l.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 ${l.slice(0,-1).join(", ")} \u05D0\u05D5 ${d}`}case"too_big":{let l=a(u.origin),d=i(u.origin??"value");if(u.origin==="string")return`${l?.longLabel??"\u05D0\u05E8\u05D5\u05DA"} \u05DE\u05D3\u05D9: ${d} \u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05DB\u05D9\u05DC ${u.maximum.toString()} ${l?.unit??""} ${u.inclusive?"\u05D0\u05D5 \u05E4\u05D7\u05D5\u05EA":"\u05DC\u05DB\u05DC \u05D4\u05D9\u05D5\u05EA\u05E8"}`.trim();if(u.origin==="number"){let m=u.inclusive?`\u05E7\u05D8\u05DF \u05D0\u05D5 \u05E9\u05D5\u05D5\u05D4 \u05DC-${u.maximum}`:`\u05E7\u05D8\u05DF \u05DE-${u.maximum}`;return`\u05D2\u05D3\u05D5\u05DC \u05DE\u05D3\u05D9: ${d} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${m}`}if(u.origin==="array"||u.origin==="set"){let m=u.origin==="set"?"\u05E6\u05E8\u05D9\u05DB\u05D4":"\u05E6\u05E8\u05D9\u05DA",h=u.inclusive?`${u.maximum} ${l?.unit??""} \u05D0\u05D5 \u05E4\u05D7\u05D5\u05EA`:`\u05E4\u05D7\u05D5\u05EA \u05DE-${u.maximum} ${l?.unit??""}`;return`\u05D2\u05D3\u05D5\u05DC \u05DE\u05D3\u05D9: ${d} ${m} \u05DC\u05D4\u05DB\u05D9\u05DC ${h}`.trim()}let f=u.inclusive?"<=":"<",p=o(u.origin??"value");return l?.unit?`${l.longLabel} \u05DE\u05D3\u05D9: ${d} ${p} ${f}${u.maximum.toString()} ${l.unit}`:`${l?.longLabel??"\u05D2\u05D3\u05D5\u05DC"} \u05DE\u05D3\u05D9: ${d} ${p} ${f}${u.maximum.toString()}`}case"too_small":{let l=a(u.origin),d=i(u.origin??"value");if(u.origin==="string")return`${l?.shortLabel??"\u05E7\u05E6\u05E8"} \u05DE\u05D3\u05D9: ${d} \u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05DB\u05D9\u05DC ${u.minimum.toString()} ${l?.unit??""} ${u.inclusive?"\u05D0\u05D5 \u05D9\u05D5\u05EA\u05E8":"\u05DC\u05E4\u05D7\u05D5\u05EA"}`.trim();if(u.origin==="number"){let m=u.inclusive?`\u05D2\u05D3\u05D5\u05DC \u05D0\u05D5 \u05E9\u05D5\u05D5\u05D4 \u05DC-${u.minimum}`:`\u05D2\u05D3\u05D5\u05DC \u05DE-${u.minimum}`;return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${d} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${m}`}if(u.origin==="array"||u.origin==="set"){let m=u.origin==="set"?"\u05E6\u05E8\u05D9\u05DB\u05D4":"\u05E6\u05E8\u05D9\u05DA";if(u.minimum===1&&u.inclusive){let _=(u.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=u.inclusive?`${u.minimum} ${l?.unit??""} \u05D0\u05D5 \u05D9\u05D5\u05EA\u05E8`:`\u05D9\u05D5\u05EA\u05E8 \u05DE-${u.minimum} ${l?.unit??""}`;return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${d} ${m} \u05DC\u05D4\u05DB\u05D9\u05DC ${h}`.trim()}let f=u.inclusive?">=":">",p=o(u.origin??"value");return l?.unit?`${l.shortLabel} \u05DE\u05D3\u05D9: ${d} ${p} ${f}${u.minimum.toString()} ${l.unit}`:`${l?.shortLabel??"\u05E7\u05D8\u05DF"} \u05DE\u05D3\u05D9: ${d} ${p} ${f}${u.minimum.toString()}`}case"invalid_format":{let l=u;if(l.format==="starts_with")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05EA\u05D7\u05D9\u05DC \u05D1 "${l.prefix}"`;if(l.format==="ends_with")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05E1\u05EA\u05D9\u05D9\u05DD \u05D1 "${l.suffix}"`;if(l.format==="includes")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05DB\u05DC\u05D5\u05DC "${l.includes}"`;if(l.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 ${l.pattern}`;let d=s[l.format],f=d?.label??l.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 ${u.divisor}`;case"unrecognized_keys":return`\u05DE\u05E4\u05EA\u05D7${u.keys.length>1?"\u05D5\u05EA":""} \u05DC\u05D0 \u05DE\u05D6\u05D5\u05D4${u.keys.length>1?"\u05D9\u05DD":"\u05D4"}: ${$(u.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${i(u.origin??"array")}`;default:return"\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF"}}};function bO(){return{localeError:uF()}}var lF=()=>{let e={string:{unit:"znakova",verb:"imati"},file:{unit:"bajtova",verb:"imati"},array:{unit:"stavki",verb:"imati"},set:{unit:"stavki",verb:"imati"}};function t(i){return e[i]??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"},n={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 i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=M(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`Neispravan unos: o\u010Dekuje se instanceof ${i.expected}, a primljeno je ${s}`:`Neispravan unos: o\u010Dekuje se ${o}, a primljeno je ${s}`}case"invalid_value":return i.values.length===1?`Neispravna vrijednost: o\u010Dekivano ${j(i.values[0])}`:`Neispravna opcija: o\u010Dekivano jedno od ${$(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin),s=n[i.origin]??i.origin;return a?`Preveliko: o\u010Dekivano da ${s??"vrijednost"} ima ${o}${i.maximum.toString()} ${a.unit??"elemenata"}`:`Preveliko: o\u010Dekivano da ${s??"vrijednost"} bude ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin),s=n[i.origin]??i.origin;return a?`Premalo: o\u010Dekivano da ${s} ima ${o}${i.minimum.toString()} ${a.unit}`:`Premalo: o\u010Dekivano da ${s} bude ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Neispravan tekst: mora zapo\u010Dinjati s "${o.prefix}"`:o.format==="ends_with"?`Neispravan tekst: mora zavr\u0161avati s "${o.suffix}"`:o.format==="includes"?`Neispravan tekst: mora sadr\u017Eavati "${o.includes}"`:o.format==="regex"?`Neispravan tekst: mora odgovarati uzorku ${o.pattern}`:`Neispravna ${r[o.format]??i.format}`}case"not_multiple_of":return`Neispravan broj: mora biti vi\u0161ekratnik od ${i.divisor}`;case"unrecognized_keys":return`Neprepoznat${i.keys.length>1?"i klju\u010Devi":" klju\u010D"}: ${$(i.keys,", ")}`;case"invalid_key":return`Neispravan klju\u010D u ${n[i.origin]??i.origin}`;case"invalid_union":return"Neispravan unos";case"invalid_element":return`Neispravna vrijednost u ${n[i.origin]??i.origin}`;default:return"Neispravan unos"}}};function wO(){return{localeError:lF()}}var dF=()=>{let e={string:{unit:"karakter",verb:"legyen"},file:{unit:"byte",verb:"legyen"},array:{unit:"elem",verb:"legyen"},set:{unit:"elem",verb:"legyen"}};function t(i){return e[i]??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"},n={nan:"NaN",number:"sz\xE1m",array:"t\xF6mb"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=M(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k instanceof ${i.expected}, a kapott \xE9rt\xE9k ${s}`:`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k ${o}, a kapott \xE9rt\xE9k ${s}`}case"invalid_value":return i.values.length===1?`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k ${j(i.values[0])}`:`\xC9rv\xE9nytelen opci\xF3: valamelyik \xE9rt\xE9k v\xE1rt ${$(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`T\xFAl nagy: ${i.origin??"\xE9rt\xE9k"} m\xE9rete t\xFAl nagy ${o}${i.maximum.toString()} ${a.unit??"elem"}`:`T\xFAl nagy: a bemeneti \xE9rt\xE9k ${i.origin??"\xE9rt\xE9k"} t\xFAl nagy: ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`T\xFAl kicsi: a bemeneti \xE9rt\xE9k ${i.origin} m\xE9rete t\xFAl kicsi ${o}${i.minimum.toString()} ${a.unit}`:`T\xFAl kicsi: a bemeneti \xE9rt\xE9k ${i.origin} t\xFAl kicsi ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\xC9rv\xE9nytelen string: "${o.prefix}" \xE9rt\xE9kkel kell kezd\u0151dnie`:o.format==="ends_with"?`\xC9rv\xE9nytelen string: "${o.suffix}" \xE9rt\xE9kkel kell v\xE9gz\u0151dnie`:o.format==="includes"?`\xC9rv\xE9nytelen string: "${o.includes}" \xE9rt\xE9ket kell tartalmaznia`:o.format==="regex"?`\xC9rv\xE9nytelen string: ${o.pattern} mint\xE1nak kell megfelelnie`:`\xC9rv\xE9nytelen ${r[o.format]??i.format}`}case"not_multiple_of":return`\xC9rv\xE9nytelen sz\xE1m: ${i.divisor} t\xF6bbsz\xF6r\xF6s\xE9nek kell lennie`;case"unrecognized_keys":return`Ismeretlen kulcs${i.keys.length>1?"s":""}: ${$(i.keys,", ")}`;case"invalid_key":return`\xC9rv\xE9nytelen kulcs ${i.origin}`;case"invalid_union":return"\xC9rv\xE9nytelen bemenet";case"invalid_element":return`\xC9rv\xE9nytelen \xE9rt\xE9k: ${i.origin}`;default:return"\xC9rv\xE9nytelen bemenet"}}};function xO(){return{localeError:dF()}}function SO(e,t,r){return Math.abs(e)===1?t:r}function $c(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 fF=()=>{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(i){return e[i]??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"},n={nan:"NaN",number:"\u0569\u056B\u057E",array:"\u0566\u0561\u0576\u0563\u057E\u0561\u056E"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=M(i.input),s=n[a]??a;return/^[A-Z]/.test(i.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 ${i.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 ${o}, \u057D\u057F\u0561\u0581\u057E\u0565\u056C \u0567 ${s}`}case"invalid_value":return i.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 ${j(i.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.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);if(a){let s=Number(i.maximum),c=SO(s,a.unit.one,a.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 ${$c(i.origin??"\u0561\u0580\u056A\u0565\u0584")} \u056F\u0578\u0582\u0576\u0565\u0576\u0561 ${o}${i.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 ${$c(i.origin??"\u0561\u0580\u056A\u0565\u0584")} \u056C\u056B\u0576\u056B ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);if(a){let s=Number(i.minimum),c=SO(s,a.unit.one,a.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 ${$c(i.origin)} \u056F\u0578\u0582\u0576\u0565\u0576\u0561 ${o}${i.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 ${$c(i.origin)} \u056C\u056B\u0576\u056B ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u057D\u056F\u057D\u057E\u056B "${o.prefix}"-\u0578\u057E`:o.format==="ends_with"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u0561\u057E\u0561\u0580\u057F\u057E\u056B "${o.suffix}"-\u0578\u057E`:o.format==="includes"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u057A\u0561\u0580\u0578\u0582\u0576\u0561\u056F\u056B "${o.includes}"`:o.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 ${o.pattern} \u0571\u0587\u0561\u0579\u0561\u0583\u056B\u0576`:`\u054D\u056D\u0561\u056C ${r[o.format]??i.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 ${i.divisor}-\u056B`;case"unrecognized_keys":return`\u0549\u0573\u0561\u0576\u0561\u0579\u057E\u0561\u056E \u0562\u0561\u0576\u0561\u056C\u056B${i.keys.length>1?"\u0576\u0565\u0580":""}. ${$(i.keys,", ")}`;case"invalid_key":return`\u054D\u056D\u0561\u056C \u0562\u0561\u0576\u0561\u056C\u056B ${$c(i.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 ${$c(i.origin)}-\u0578\u0582\u0574`;default:return"\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574"}}};function kO(){return{localeError:fF()}}var pF=()=>{let e={string:{unit:"karakter",verb:"memiliki"},file:{unit:"byte",verb:"memiliki"},array:{unit:"item",verb:"memiliki"},set:{unit:"item",verb:"memiliki"}};function t(i){return e[i]??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"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=M(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`Input tidak valid: diharapkan instanceof ${i.expected}, diterima ${s}`:`Input tidak valid: diharapkan ${o}, diterima ${s}`}case"invalid_value":return i.values.length===1?`Input tidak valid: diharapkan ${j(i.values[0])}`:`Pilihan tidak valid: diharapkan salah satu dari ${$(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`Terlalu besar: diharapkan ${i.origin??"value"} memiliki ${o}${i.maximum.toString()} ${a.unit??"elemen"}`:`Terlalu besar: diharapkan ${i.origin??"value"} menjadi ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`Terlalu kecil: diharapkan ${i.origin} memiliki ${o}${i.minimum.toString()} ${a.unit}`:`Terlalu kecil: diharapkan ${i.origin} menjadi ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`String tidak valid: harus dimulai dengan "${o.prefix}"`:o.format==="ends_with"?`String tidak valid: harus berakhir dengan "${o.suffix}"`:o.format==="includes"?`String tidak valid: harus menyertakan "${o.includes}"`:o.format==="regex"?`String tidak valid: harus sesuai pola ${o.pattern}`:`${r[o.format]??i.format} tidak valid`}case"not_multiple_of":return`Angka tidak valid: harus kelipatan dari ${i.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali ${i.keys.length>1?"s":""}: ${$(i.keys,", ")}`;case"invalid_key":return`Kunci tidak valid di ${i.origin}`;case"invalid_union":return"Input tidak valid";case"invalid_element":return`Nilai tidak valid di ${i.origin}`;default:return"Input tidak valid"}}};function EO(){return{localeError:pF()}}var mF=()=>{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(i){return e[i]??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"},n={nan:"NaN",number:"n\xFAmer",array:"fylki"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=M(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`Rangt gildi: \xDE\xFA sl\xF3st inn ${s} \xFEar sem \xE1 a\xF0 vera instanceof ${i.expected}`:`Rangt gildi: \xDE\xFA sl\xF3st inn ${s} \xFEar sem \xE1 a\xF0 vera ${o}`}case"invalid_value":return i.values.length===1?`Rangt gildi: gert r\xE1\xF0 fyrir ${j(i.values[0])}`:`\xD3gilt val: m\xE1 vera eitt af eftirfarandi ${$(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`Of st\xF3rt: gert er r\xE1\xF0 fyrir a\xF0 ${i.origin??"gildi"} hafi ${o}${i.maximum.toString()} ${a.unit??"hluti"}`:`Of st\xF3rt: gert er r\xE1\xF0 fyrir a\xF0 ${i.origin??"gildi"} s\xE9 ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`Of l\xEDti\xF0: gert er r\xE1\xF0 fyrir a\xF0 ${i.origin} hafi ${o}${i.minimum.toString()} ${a.unit}`:`Of l\xEDti\xF0: gert er r\xE1\xF0 fyrir a\xF0 ${i.origin} s\xE9 ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\xD3gildur strengur: ver\xF0ur a\xF0 byrja \xE1 "${o.prefix}"`:o.format==="ends_with"?`\xD3gildur strengur: ver\xF0ur a\xF0 enda \xE1 "${o.suffix}"`:o.format==="includes"?`\xD3gildur strengur: ver\xF0ur a\xF0 innihalda "${o.includes}"`:o.format==="regex"?`\xD3gildur strengur: ver\xF0ur a\xF0 fylgja mynstri ${o.pattern}`:`Rangt ${r[o.format]??i.format}`}case"not_multiple_of":return`R\xF6ng tala: ver\xF0ur a\xF0 vera margfeldi af ${i.divisor}`;case"unrecognized_keys":return`\xD3\xFEekkt ${i.keys.length>1?"ir lyklar":"ur lykill"}: ${$(i.keys,", ")}`;case"invalid_key":return`Rangur lykill \xED ${i.origin}`;case"invalid_union":return"Rangt gildi";case"invalid_element":return`Rangt gildi \xED ${i.origin}`;default:return"Rangt gildi"}}};function IO(){return{localeError:mF()}}var hF=()=>{let e={string:{unit:"caratteri",verb:"avere"},file:{unit:"byte",verb:"avere"},array:{unit:"elementi",verb:"avere"},set:{unit:"elementi",verb:"avere"}};function t(i){return e[i]??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"},n={nan:"NaN",number:"numero",array:"vettore"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=M(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`Input non valido: atteso instanceof ${i.expected}, ricevuto ${s}`:`Input non valido: atteso ${o}, ricevuto ${s}`}case"invalid_value":return i.values.length===1?`Input non valido: atteso ${j(i.values[0])}`:`Opzione non valida: atteso uno tra ${$(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`Troppo grande: ${i.origin??"valore"} deve avere ${o}${i.maximum.toString()} ${a.unit??"elementi"}`:`Troppo grande: ${i.origin??"valore"} deve essere ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`Troppo piccolo: ${i.origin} deve avere ${o}${i.minimum.toString()} ${a.unit}`:`Troppo piccolo: ${i.origin} deve essere ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Stringa non valida: deve iniziare con "${o.prefix}"`:o.format==="ends_with"?`Stringa non valida: deve terminare con "${o.suffix}"`:o.format==="includes"?`Stringa non valida: deve includere "${o.includes}"`:o.format==="regex"?`Stringa non valida: deve corrispondere al pattern ${o.pattern}`:`Input non valido: ${r[o.format]??i.format}`}case"not_multiple_of":return`Numero non valido: deve essere un multiplo di ${i.divisor}`;case"unrecognized_keys":return`Chiav${i.keys.length>1?"i":"e"} non riconosciut${i.keys.length>1?"e":"a"}: ${$(i.keys,", ")}`;case"invalid_key":return`Chiave non valida in ${i.origin}`;case"invalid_union":return"Input non valido";case"invalid_element":return`Valore non valido in ${i.origin}`;default:return"Input non valido"}}};function $O(){return{localeError:hF()}}var gF=()=>{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(i){return e[i]??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"},n={nan:"NaN",number:"\u6570\u5024",array:"\u914D\u5217"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=M(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`\u7121\u52B9\u306A\u5165\u529B: instanceof ${i.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: ${o}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F\u304C\u3001${s}\u304C\u5165\u529B\u3055\u308C\u307E\u3057\u305F`}case"invalid_value":return i.values.length===1?`\u7121\u52B9\u306A\u5165\u529B: ${j(i.values[0])}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F`:`\u7121\u52B9\u306A\u9078\u629E: ${$(i.values,"\u3001")}\u306E\u3044\u305A\u308C\u304B\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;case"too_big":{let o=i.inclusive?"\u4EE5\u4E0B\u3067\u3042\u308B":"\u3088\u308A\u5C0F\u3055\u3044",a=t(i.origin);return a?`\u5927\u304D\u3059\u304E\u308B\u5024: ${i.origin??"\u5024"}\u306F${i.maximum.toString()}${a.unit??"\u8981\u7D20"}${o}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u5927\u304D\u3059\u304E\u308B\u5024: ${i.origin??"\u5024"}\u306F${i.maximum.toString()}${o}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`}case"too_small":{let o=i.inclusive?"\u4EE5\u4E0A\u3067\u3042\u308B":"\u3088\u308A\u5927\u304D\u3044",a=t(i.origin);return a?`\u5C0F\u3055\u3059\u304E\u308B\u5024: ${i.origin}\u306F${i.minimum.toString()}${a.unit}${o}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u5C0F\u3055\u3059\u304E\u308B\u5024: ${i.origin}\u306F${i.minimum.toString()}${o}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${o.prefix}"\u3067\u59CB\u307E\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:o.format==="ends_with"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${o.suffix}"\u3067\u7D42\u308F\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:o.format==="includes"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${o.includes}"\u3092\u542B\u3080\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:o.format==="regex"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: \u30D1\u30BF\u30FC\u30F3${o.pattern}\u306B\u4E00\u81F4\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u7121\u52B9\u306A${r[o.format]??i.format}`}case"not_multiple_of":return`\u7121\u52B9\u306A\u6570\u5024: ${i.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${i.keys.length>1?"\u7FA4":""}: ${$(i.keys,"\u3001")}`;case"invalid_key":return`${i.origin}\u5185\u306E\u7121\u52B9\u306A\u30AD\u30FC`;case"invalid_union":return"\u7121\u52B9\u306A\u5165\u529B";case"invalid_element":return`${i.origin}\u5185\u306E\u7121\u52B9\u306A\u5024`;default:return"\u7121\u52B9\u306A\u5165\u529B"}}};function TO(){return{localeError:gF()}}var _F=()=>{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(i){return e[i]??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"},n={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 i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=M(i.input),s=n[a]??a;return/^[A-Z]/.test(i.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 ${i.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 ${o}, \u10DB\u10D8\u10E6\u10D4\u10D1\u10E3\u10DA\u10D8 ${s}`}case"invalid_value":return i.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 ${j(i.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.values,"|")}-\u10D3\u10D0\u10DC`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10D3\u10D8\u10D3\u10D8: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${i.origin??"\u10DB\u10DC\u10D8\u10E8\u10D5\u10DC\u10D4\u10DA\u10DD\u10D1\u10D0"} ${a.verb} ${o}${i.maximum.toString()} ${a.unit}`:`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10D3\u10D8\u10D3\u10D8: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${i.origin??"\u10DB\u10DC\u10D8\u10E8\u10D5\u10DC\u10D4\u10DA\u10DD\u10D1\u10D0"} \u10D8\u10E7\u10DD\u10E1 ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`\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 ${i.origin} ${a.verb} ${o}${i.minimum.toString()} ${a.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 ${i.origin} \u10D8\u10E7\u10DD\u10E1 ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.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 "${o.prefix}"-\u10D8\u10D7`:o.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 "${o.suffix}"-\u10D8\u10D7`:o.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 "${o.includes}"-\u10E1`:o.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 ${o.pattern}`:`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 ${r[o.format]??i.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 ${i.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${i.keys.length>1?"\u10D4\u10D1\u10D8":"\u10D8"}: ${$(i.keys,", ")}`;case"invalid_key":return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D2\u10D0\u10E1\u10D0\u10E6\u10D4\u10D1\u10D8 ${i.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 ${i.origin}-\u10E8\u10D8`;default:return"\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0"}}};function AO(){return{localeError:_F()}}var yF=()=>{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(i){return e[i]??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"},n={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 i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=M(i.input),s=n[a]??a;return/^[A-Z]/.test(i.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 ${i.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 ${o} \u1794\u17C9\u17BB\u1793\u17D2\u178F\u17C2\u1791\u1791\u17BD\u179B\u1794\u17B6\u1793 ${s}`}case"invalid_value":return i.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 ${j(i.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.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`\u1792\u17C6\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${i.origin??"\u178F\u1798\u17D2\u179B\u17C3"} ${o} ${i.maximum.toString()} ${a.unit??"\u1792\u17B6\u178F\u17BB"}`:`\u1792\u17C6\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${i.origin??"\u178F\u1798\u17D2\u179B\u17C3"} ${o} ${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`\u178F\u17BC\u1785\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${i.origin} ${o} ${i.minimum.toString()} ${a.unit}`:`\u178F\u17BC\u1785\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${i.origin} ${o} ${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.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 "${o.prefix}"`:o.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 "${o.suffix}"`:o.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 "${o.includes}"`:o.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 ${o.pattern}`:`\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 ${r[o.format]??i.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 ${i.divisor}`;case"unrecognized_keys":return`\u179A\u1780\u1783\u17BE\u1789\u179F\u17C4\u1798\u17B7\u1793\u179F\u17D2\u1782\u17B6\u179B\u17CB\u17D6 ${$(i.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 ${i.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 ${i.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 Yp(){return{localeError:yF()}}function CO(){return Yp()}var vF=()=>{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(i){return e[i]??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"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=M(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`\uC798\uBABB\uB41C \uC785\uB825: \uC608\uC0C1 \uD0C0\uC785\uC740 instanceof ${i.expected}, \uBC1B\uC740 \uD0C0\uC785\uC740 ${s}\uC785\uB2C8\uB2E4`:`\uC798\uBABB\uB41C \uC785\uB825: \uC608\uC0C1 \uD0C0\uC785\uC740 ${o}, \uBC1B\uC740 \uD0C0\uC785\uC740 ${s}\uC785\uB2C8\uB2E4`}case"invalid_value":return i.values.length===1?`\uC798\uBABB\uB41C \uC785\uB825: \uAC12\uC740 ${j(i.values[0])} \uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4`:`\uC798\uBABB\uB41C \uC635\uC158: ${$(i.values,"\uB610\uB294 ")} \uC911 \uD558\uB098\uC5EC\uC57C \uD569\uB2C8\uB2E4`;case"too_big":{let o=i.inclusive?"\uC774\uD558":"\uBBF8\uB9CC",a=o==="\uBBF8\uB9CC"?"\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4":"\uC5EC\uC57C \uD569\uB2C8\uB2E4",s=t(i.origin),c=s?.unit??"\uC694\uC18C";return s?`${i.origin??"\uAC12"}\uC774 \uB108\uBB34 \uD07D\uB2C8\uB2E4: ${i.maximum.toString()}${c} ${o}${a}`:`${i.origin??"\uAC12"}\uC774 \uB108\uBB34 \uD07D\uB2C8\uB2E4: ${i.maximum.toString()} ${o}${a}`}case"too_small":{let o=i.inclusive?"\uC774\uC0C1":"\uCD08\uACFC",a=o==="\uC774\uC0C1"?"\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4":"\uC5EC\uC57C \uD569\uB2C8\uB2E4",s=t(i.origin),c=s?.unit??"\uC694\uC18C";return s?`${i.origin??"\uAC12"}\uC774 \uB108\uBB34 \uC791\uC2B5\uB2C8\uB2E4: ${i.minimum.toString()}${c} ${o}${a}`:`${i.origin??"\uAC12"}\uC774 \uB108\uBB34 \uC791\uC2B5\uB2C8\uB2E4: ${i.minimum.toString()} ${o}${a}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${o.prefix}"(\uC73C)\uB85C \uC2DC\uC791\uD574\uC57C \uD569\uB2C8\uB2E4`:o.format==="ends_with"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${o.suffix}"(\uC73C)\uB85C \uB05D\uB098\uC57C \uD569\uB2C8\uB2E4`:o.format==="includes"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${o.includes}"\uC744(\uB97C) \uD3EC\uD568\uD574\uC57C \uD569\uB2C8\uB2E4`:o.format==="regex"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: \uC815\uADDC\uC2DD ${o.pattern} \uD328\uD134\uACFC \uC77C\uCE58\uD574\uC57C \uD569\uB2C8\uB2E4`:`\uC798\uBABB\uB41C ${r[o.format]??i.format}`}case"not_multiple_of":return`\uC798\uBABB\uB41C \uC22B\uC790: ${i.divisor}\uC758 \uBC30\uC218\uC5EC\uC57C \uD569\uB2C8\uB2E4`;case"unrecognized_keys":return`\uC778\uC2DD\uD560 \uC218 \uC5C6\uB294 \uD0A4: ${$(i.keys,", ")}`;case"invalid_key":return`\uC798\uBABB\uB41C \uD0A4: ${i.origin}`;case"invalid_union":return"\uC798\uBABB\uB41C \uC785\uB825";case"invalid_element":return`\uC798\uBABB\uB41C \uAC12: ${i.origin}`;default:return"\uC798\uBABB\uB41C \uC785\uB825"}}};function OO(){return{localeError:vF()}}var $l=e=>e.charAt(0).toUpperCase()+e.slice(1);function PO(e){let t=Math.abs(e),r=t%10,n=t%100;return n>=11&&n<=19||r===0?"many":r===1?"one":"few"}var bF=()=>{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(i,o,a,s){let c=e[i]??null;return c===null?c:{unit:c.unit[o],verb:c.verb[s][a?"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"},n={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 i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=M(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`Gautas tipas ${s}, o tik\u0117tasi - instanceof ${i.expected}`:`Gautas tipas ${s}, o tik\u0117tasi - ${o}`}case"invalid_value":return i.values.length===1?`Privalo b\u016Bti ${j(i.values[0])}`:`Privalo b\u016Bti vienas i\u0161 ${$(i.values,"|")} pasirinkim\u0173`;case"too_big":{let o=n[i.origin]??i.origin,a=t(i.origin,PO(Number(i.maximum)),i.inclusive??!1,"smaller");if(a?.verb)return`${$l(o??i.origin??"reik\u0161m\u0117")} ${a.verb} ${i.maximum.toString()} ${a.unit??"element\u0173"}`;let s=i.inclusive?"ne didesnis kaip":"ma\u017Eesnis kaip";return`${$l(o??i.origin??"reik\u0161m\u0117")} turi b\u016Bti ${s} ${i.maximum.toString()} ${a?.unit}`}case"too_small":{let o=n[i.origin]??i.origin,a=t(i.origin,PO(Number(i.minimum)),i.inclusive??!1,"bigger");if(a?.verb)return`${$l(o??i.origin??"reik\u0161m\u0117")} ${a.verb} ${i.minimum.toString()} ${a.unit??"element\u0173"}`;let s=i.inclusive?"ne ma\u017Eesnis kaip":"didesnis kaip";return`${$l(o??i.origin??"reik\u0161m\u0117")} turi b\u016Bti ${s} ${i.minimum.toString()} ${a?.unit}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Eilut\u0117 privalo prasid\u0117ti "${o.prefix}"`:o.format==="ends_with"?`Eilut\u0117 privalo pasibaigti "${o.suffix}"`:o.format==="includes"?`Eilut\u0117 privalo \u012Ftraukti "${o.includes}"`:o.format==="regex"?`Eilut\u0117 privalo atitikti ${o.pattern}`:`Neteisingas ${r[o.format]??i.format}`}case"not_multiple_of":return`Skai\u010Dius privalo b\u016Bti ${i.divisor} kartotinis.`;case"unrecognized_keys":return`Neatpa\u017Eint${i.keys.length>1?"i":"as"} rakt${i.keys.length>1?"ai":"as"}: ${$(i.keys,", ")}`;case"invalid_key":return"Rastas klaidingas raktas";case"invalid_union":return"Klaidinga \u012Fvestis";case"invalid_element":{let o=n[i.origin]??i.origin;return`${$l(o??i.origin??"reik\u0161m\u0117")} turi klaiding\u0105 \u012Fvest\u012F`}default:return"Klaidinga \u012Fvestis"}}};function NO(){return{localeError:bF()}}var wF=()=>{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(i){return e[i]??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"},n={nan:"NaN",number:"\u0431\u0440\u043E\u0458",array:"\u043D\u0438\u0437\u0430"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=M(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 instanceof ${i.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 ${o}, \u043F\u0440\u0438\u043C\u0435\u043D\u043E ${s}`}case"invalid_value":return i.values.length===1?`Invalid input: expected ${j(i.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.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u0433\u043E\u043B\u0435\u043C: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${i.origin??"\u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442\u0430"} \u0434\u0430 \u0438\u043C\u0430 ${o}${i.maximum.toString()} ${a.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 ${i.origin??"\u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442\u0430"} \u0434\u0430 \u0431\u0438\u0434\u0435 ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u043C\u0430\u043B: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${i.origin} \u0434\u0430 \u0438\u043C\u0430 ${o}${i.minimum.toString()} ${a.unit}`:`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u043C\u0430\u043B: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${i.origin} \u0434\u0430 \u0431\u0438\u0434\u0435 ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.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 "${o.prefix}"`:o.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 "${o.suffix}"`:o.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 "${o.includes}"`:o.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 ${o.pattern}`:`Invalid ${r[o.format]??i.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 ${i.divisor}`;case"unrecognized_keys":return`${i.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.keys,", ")}`;case"invalid_key":return`\u0413\u0440\u0435\u0448\u0435\u043D \u043A\u043B\u0443\u0447 \u0432\u043E ${i.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 ${i.origin}`;default:return"\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441"}}};function RO(){return{localeError:wF()}}var xF=()=>{let e={string:{unit:"aksara",verb:"mempunyai"},file:{unit:"bait",verb:"mempunyai"},array:{unit:"elemen",verb:"mempunyai"},set:{unit:"elemen",verb:"mempunyai"}};function t(i){return e[i]??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"},n={nan:"NaN",number:"nombor"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=M(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`Input tidak sah: dijangka instanceof ${i.expected}, diterima ${s}`:`Input tidak sah: dijangka ${o}, diterima ${s}`}case"invalid_value":return i.values.length===1?`Input tidak sah: dijangka ${j(i.values[0])}`:`Pilihan tidak sah: dijangka salah satu daripada ${$(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`Terlalu besar: dijangka ${i.origin??"nilai"} ${a.verb} ${o}${i.maximum.toString()} ${a.unit??"elemen"}`:`Terlalu besar: dijangka ${i.origin??"nilai"} adalah ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`Terlalu kecil: dijangka ${i.origin} ${a.verb} ${o}${i.minimum.toString()} ${a.unit}`:`Terlalu kecil: dijangka ${i.origin} adalah ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`String tidak sah: mesti bermula dengan "${o.prefix}"`:o.format==="ends_with"?`String tidak sah: mesti berakhir dengan "${o.suffix}"`:o.format==="includes"?`String tidak sah: mesti mengandungi "${o.includes}"`:o.format==="regex"?`String tidak sah: mesti sepadan dengan corak ${o.pattern}`:`${r[o.format]??i.format} tidak sah`}case"not_multiple_of":return`Nombor tidak sah: perlu gandaan ${i.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali: ${$(i.keys,", ")}`;case"invalid_key":return`Kunci tidak sah dalam ${i.origin}`;case"invalid_union":return"Input tidak sah";case"invalid_element":return`Nilai tidak sah dalam ${i.origin}`;default:return"Input tidak sah"}}};function jO(){return{localeError:xF()}}var SF=()=>{let e={string:{unit:"tekens",verb:"heeft"},file:{unit:"bytes",verb:"heeft"},array:{unit:"elementen",verb:"heeft"},set:{unit:"elementen",verb:"heeft"}};function t(i){return e[i]??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"},n={nan:"NaN",number:"getal"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=M(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`Ongeldige invoer: verwacht instanceof ${i.expected}, ontving ${s}`:`Ongeldige invoer: verwacht ${o}, ontving ${s}`}case"invalid_value":return i.values.length===1?`Ongeldige invoer: verwacht ${j(i.values[0])}`:`Ongeldige optie: verwacht \xE9\xE9n van ${$(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin),s=i.origin==="date"?"laat":i.origin==="string"?"lang":"groot";return a?`Te ${s}: verwacht dat ${i.origin??"waarde"} ${o}${i.maximum.toString()} ${a.unit??"elementen"} ${a.verb}`:`Te ${s}: verwacht dat ${i.origin??"waarde"} ${o}${i.maximum.toString()} is`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin),s=i.origin==="date"?"vroeg":i.origin==="string"?"kort":"klein";return a?`Te ${s}: verwacht dat ${i.origin} ${o}${i.minimum.toString()} ${a.unit} ${a.verb}`:`Te ${s}: verwacht dat ${i.origin} ${o}${i.minimum.toString()} is`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Ongeldige tekst: moet met "${o.prefix}" beginnen`:o.format==="ends_with"?`Ongeldige tekst: moet op "${o.suffix}" eindigen`:o.format==="includes"?`Ongeldige tekst: moet "${o.includes}" bevatten`:o.format==="regex"?`Ongeldige tekst: moet overeenkomen met patroon ${o.pattern}`:`Ongeldig: ${r[o.format]??i.format}`}case"not_multiple_of":return`Ongeldig getal: moet een veelvoud van ${i.divisor} zijn`;case"unrecognized_keys":return`Onbekende key${i.keys.length>1?"s":""}: ${$(i.keys,", ")}`;case"invalid_key":return`Ongeldige key in ${i.origin}`;case"invalid_union":return"Ongeldige invoer";case"invalid_element":return`Ongeldige waarde in ${i.origin}`;default:return"Ongeldige invoer"}}};function MO(){return{localeError:SF()}}var kF=()=>{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(i){return e[i]??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"},n={nan:"NaN",number:"tall",array:"liste"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=M(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`Ugyldig input: forventet instanceof ${i.expected}, fikk ${s}`:`Ugyldig input: forventet ${o}, fikk ${s}`}case"invalid_value":return i.values.length===1?`Ugyldig verdi: forventet ${j(i.values[0])}`:`Ugyldig valg: forventet en av ${$(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`For stor(t): forventet ${i.origin??"value"} til \xE5 ha ${o}${i.maximum.toString()} ${a.unit??"elementer"}`:`For stor(t): forventet ${i.origin??"value"} til \xE5 ha ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`For lite(n): forventet ${i.origin} til \xE5 ha ${o}${i.minimum.toString()} ${a.unit}`:`For lite(n): forventet ${i.origin} til \xE5 ha ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Ugyldig streng: m\xE5 starte med "${o.prefix}"`:o.format==="ends_with"?`Ugyldig streng: m\xE5 ende med "${o.suffix}"`:o.format==="includes"?`Ugyldig streng: m\xE5 inneholde "${o.includes}"`:o.format==="regex"?`Ugyldig streng: m\xE5 matche m\xF8nsteret ${o.pattern}`:`Ugyldig ${r[o.format]??i.format}`}case"not_multiple_of":return`Ugyldig tall: m\xE5 v\xE6re et multiplum av ${i.divisor}`;case"unrecognized_keys":return`${i.keys.length>1?"Ukjente n\xF8kler":"Ukjent n\xF8kkel"}: ${$(i.keys,", ")}`;case"invalid_key":return`Ugyldig n\xF8kkel i ${i.origin}`;case"invalid_union":return"Ugyldig input";case"invalid_element":return`Ugyldig verdi i ${i.origin}`;default:return"Ugyldig input"}}};function DO(){return{localeError:kF()}}var EF=()=>{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(i){return e[i]??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"},n={nan:"NaN",number:"numara",array:"saf",null:"gayb"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=M(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`F\xE2sit giren: umulan instanceof ${i.expected}, al\u0131nan ${s}`:`F\xE2sit giren: umulan ${o}, al\u0131nan ${s}`}case"invalid_value":return i.values.length===1?`F\xE2sit giren: umulan ${j(i.values[0])}`:`F\xE2sit tercih: m\xFBteberler ${$(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`Fazla b\xFCy\xFCk: ${i.origin??"value"}, ${o}${i.maximum.toString()} ${a.unit??"elements"} sahip olmal\u0131yd\u0131.`:`Fazla b\xFCy\xFCk: ${i.origin??"value"}, ${o}${i.maximum.toString()} olmal\u0131yd\u0131.`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`Fazla k\xFC\xE7\xFCk: ${i.origin}, ${o}${i.minimum.toString()} ${a.unit} sahip olmal\u0131yd\u0131.`:`Fazla k\xFC\xE7\xFCk: ${i.origin}, ${o}${i.minimum.toString()} olmal\u0131yd\u0131.`}case"invalid_format":{let o=i;return o.format==="starts_with"?`F\xE2sit metin: "${o.prefix}" ile ba\u015Flamal\u0131.`:o.format==="ends_with"?`F\xE2sit metin: "${o.suffix}" ile bitmeli.`:o.format==="includes"?`F\xE2sit metin: "${o.includes}" ihtiv\xE2 etmeli.`:o.format==="regex"?`F\xE2sit metin: ${o.pattern} nak\u015F\u0131na uymal\u0131.`:`F\xE2sit ${r[o.format]??i.format}`}case"not_multiple_of":return`F\xE2sit say\u0131: ${i.divisor} kat\u0131 olmal\u0131yd\u0131.`;case"unrecognized_keys":return`Tan\u0131nmayan anahtar ${i.keys.length>1?"s":""}: ${$(i.keys,", ")}`;case"invalid_key":return`${i.origin} i\xE7in tan\u0131nmayan anahtar var.`;case"invalid_union":return"Giren tan\u0131namad\u0131.";case"invalid_element":return`${i.origin} i\xE7in tan\u0131nmayan k\u0131ymet var.`;default:return"K\u0131ymet tan\u0131namad\u0131."}}};function zO(){return{localeError:EF()}}var IF=()=>{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(i){return e[i]??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"},n={nan:"NaN",number:"\u0639\u062F\u062F",array:"\u0627\u0631\u06D0"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=M(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F instanceof ${i.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 ${o} \u0648\u0627\u06CC, \u0645\u06AB\u0631 ${s} \u062A\u0631\u0644\u0627\u0633\u0647 \u0634\u0648`}case"invalid_value":return i.values.length===1?`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F ${j(i.values[0])} \u0648\u0627\u06CC`:`\u0646\u0627\u0633\u0645 \u0627\u0646\u062A\u062E\u0627\u0628: \u0628\u0627\u06CC\u062F \u06CC\u0648 \u0644\u0647 ${$(i.values,"|")} \u0685\u062E\u0647 \u0648\u0627\u06CC`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`\u0689\u06CC\u0631 \u0644\u0648\u06CC: ${i.origin??"\u0627\u0631\u0632\u069A\u062A"} \u0628\u0627\u06CC\u062F ${o}${i.maximum.toString()} ${a.unit??"\u0639\u0646\u0635\u0631\u0648\u0646\u0647"} \u0648\u0644\u0631\u064A`:`\u0689\u06CC\u0631 \u0644\u0648\u06CC: ${i.origin??"\u0627\u0631\u0632\u069A\u062A"} \u0628\u0627\u06CC\u062F ${o}${i.maximum.toString()} \u0648\u064A`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`\u0689\u06CC\u0631 \u06A9\u0648\u0686\u0646\u06CC: ${i.origin} \u0628\u0627\u06CC\u062F ${o}${i.minimum.toString()} ${a.unit} \u0648\u0644\u0631\u064A`:`\u0689\u06CC\u0631 \u06A9\u0648\u0686\u0646\u06CC: ${i.origin} \u0628\u0627\u06CC\u062F ${o}${i.minimum.toString()} \u0648\u064A`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F "${o.prefix}" \u0633\u0631\u0647 \u067E\u06CC\u0644 \u0634\u064A`:o.format==="ends_with"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F "${o.suffix}" \u0633\u0631\u0647 \u067E\u0627\u06CC \u062A\u0647 \u0648\u0631\u0633\u064A\u0696\u064A`:o.format==="includes"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F "${o.includes}" \u0648\u0644\u0631\u064A`:o.format==="regex"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F ${o.pattern} \u0633\u0631\u0647 \u0645\u0637\u0627\u0628\u0642\u062A \u0648\u0644\u0631\u064A`:`${r[o.format]??i.format} \u0646\u0627\u0633\u0645 \u062F\u06CC`}case"not_multiple_of":return`\u0646\u0627\u0633\u0645 \u0639\u062F\u062F: \u0628\u0627\u06CC\u062F \u062F ${i.divisor} \u0645\u0636\u0631\u0628 \u0648\u064A`;case"unrecognized_keys":return`\u0646\u0627\u0633\u0645 ${i.keys.length>1?"\u06A9\u0644\u06CC\u0689\u0648\u0646\u0647":"\u06A9\u0644\u06CC\u0689"}: ${$(i.keys,", ")}`;case"invalid_key":return`\u0646\u0627\u0633\u0645 \u06A9\u0644\u06CC\u0689 \u067E\u0647 ${i.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 ${i.origin} \u06A9\u06D0`;default:return"\u0646\u0627\u0633\u0645\u0647 \u0648\u0631\u0648\u062F\u064A"}}};function UO(){return{localeError:IF()}}var $F=()=>{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(i){return e[i]??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"},n={nan:"NaN",number:"liczba",array:"tablica"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=M(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano instanceof ${i.expected}, otrzymano ${s}`:`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano ${o}, otrzymano ${s}`}case"invalid_value":return i.values.length===1?`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano ${j(i.values[0])}`:`Nieprawid\u0142owa opcja: oczekiwano jednej z warto\u015Bci ${$(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`Za du\u017Ca warto\u015B\u0107: oczekiwano, \u017Ce ${i.origin??"warto\u015B\u0107"} b\u0119dzie mie\u0107 ${o}${i.maximum.toString()} ${a.unit??"element\xF3w"}`:`Zbyt du\u017C(y/a/e): oczekiwano, \u017Ce ${i.origin??"warto\u015B\u0107"} b\u0119dzie wynosi\u0107 ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`Za ma\u0142a warto\u015B\u0107: oczekiwano, \u017Ce ${i.origin??"warto\u015B\u0107"} b\u0119dzie mie\u0107 ${o}${i.minimum.toString()} ${a.unit??"element\xF3w"}`:`Zbyt ma\u0142(y/a/e): oczekiwano, \u017Ce ${i.origin??"warto\u015B\u0107"} b\u0119dzie wynosi\u0107 ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi zaczyna\u0107 si\u0119 od "${o.prefix}"`:o.format==="ends_with"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi ko\u0144czy\u0107 si\u0119 na "${o.suffix}"`:o.format==="includes"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi zawiera\u0107 "${o.includes}"`:o.format==="regex"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi odpowiada\u0107 wzorcowi ${o.pattern}`:`Nieprawid\u0142ow(y/a/e) ${r[o.format]??i.format}`}case"not_multiple_of":return`Nieprawid\u0142owa liczba: musi by\u0107 wielokrotno\u015Bci\u0105 ${i.divisor}`;case"unrecognized_keys":return`Nierozpoznane klucze${i.keys.length>1?"s":""}: ${$(i.keys,", ")}`;case"invalid_key":return`Nieprawid\u0142owy klucz w ${i.origin}`;case"invalid_union":return"Nieprawid\u0142owe dane wej\u015Bciowe";case"invalid_element":return`Nieprawid\u0142owa warto\u015B\u0107 w ${i.origin}`;default:return"Nieprawid\u0142owe dane wej\u015Bciowe"}}};function LO(){return{localeError:$F()}}var TF=()=>{let e={string:{unit:"caracteres",verb:"ter"},file:{unit:"bytes",verb:"ter"},array:{unit:"itens",verb:"ter"},set:{unit:"itens",verb:"ter"}};function t(i){return e[i]??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"},n={nan:"NaN",number:"n\xFAmero",null:"nulo"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=M(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`Tipo inv\xE1lido: esperado instanceof ${i.expected}, recebido ${s}`:`Tipo inv\xE1lido: esperado ${o}, recebido ${s}`}case"invalid_value":return i.values.length===1?`Entrada inv\xE1lida: esperado ${j(i.values[0])}`:`Op\xE7\xE3o inv\xE1lida: esperada uma das ${$(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`Muito grande: esperado que ${i.origin??"valor"} tivesse ${o}${i.maximum.toString()} ${a.unit??"elementos"}`:`Muito grande: esperado que ${i.origin??"valor"} fosse ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`Muito pequeno: esperado que ${i.origin} tivesse ${o}${i.minimum.toString()} ${a.unit}`:`Muito pequeno: esperado que ${i.origin} fosse ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Texto inv\xE1lido: deve come\xE7ar com "${o.prefix}"`:o.format==="ends_with"?`Texto inv\xE1lido: deve terminar com "${o.suffix}"`:o.format==="includes"?`Texto inv\xE1lido: deve incluir "${o.includes}"`:o.format==="regex"?`Texto inv\xE1lido: deve corresponder ao padr\xE3o ${o.pattern}`:`${r[o.format]??i.format} inv\xE1lido`}case"not_multiple_of":return`N\xFAmero inv\xE1lido: deve ser m\xFAltiplo de ${i.divisor}`;case"unrecognized_keys":return`Chave${i.keys.length>1?"s":""} desconhecida${i.keys.length>1?"s":""}: ${$(i.keys,", ")}`;case"invalid_key":return`Chave inv\xE1lida em ${i.origin}`;case"invalid_union":return"Entrada inv\xE1lida";case"invalid_element":return`Valor inv\xE1lido em ${i.origin}`;default:return"Campo inv\xE1lido"}}};function FO(){return{localeError:TF()}}var AF=()=>{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(i){return e[i]??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"},n={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 i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=M(i.input),s=n[a]??a;return`Intrare invalid\u0103: a\u0219teptat ${o}, primit ${s}`}case"invalid_value":return i.values.length===1?`Intrare invalid\u0103: a\u0219teptat ${j(i.values[0])}`:`Op\u021Biune invalid\u0103: a\u0219teptat una dintre ${$(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`Prea mare: a\u0219teptat ca ${i.origin??"valoarea"} ${a.verb} ${o}${i.maximum.toString()} ${a.unit??"elemente"}`:`Prea mare: a\u0219teptat ca ${i.origin??"valoarea"} s\u0103 fie ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`Prea mic: a\u0219teptat ca ${i.origin} ${a.verb} ${o}${i.minimum.toString()} ${a.unit}`:`Prea mic: a\u0219teptat ca ${i.origin} s\u0103 fie ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\u0218ir invalid: trebuie s\u0103 \xEEnceap\u0103 cu "${o.prefix}"`:o.format==="ends_with"?`\u0218ir invalid: trebuie s\u0103 se termine cu "${o.suffix}"`:o.format==="includes"?`\u0218ir invalid: trebuie s\u0103 includ\u0103 "${o.includes}"`:o.format==="regex"?`\u0218ir invalid: trebuie s\u0103 se potriveasc\u0103 cu modelul ${o.pattern}`:`Format invalid: ${r[o.format]??i.format}`}case"not_multiple_of":return`Num\u0103r invalid: trebuie s\u0103 fie multiplu de ${i.divisor}`;case"unrecognized_keys":return`Chei nerecunoscute: ${$(i.keys,", ")}`;case"invalid_key":return`Cheie invalid\u0103 \xEEn ${i.origin}`;case"invalid_union":return"Intrare invalid\u0103";case"invalid_element":return`Valoare invalid\u0103 \xEEn ${i.origin}`;default:return"Intrare invalid\u0103"}}};function BO(){return{localeError:AF()}}function VO(e,t,r,n){let i=Math.abs(e),o=i%10,a=i%100;return a>=11&&a<=19?n:o===1?t:o>=2&&o<=4?r:n}var CF=()=>{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(i){return e[i]??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"},n={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0441\u0438\u0432"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=M(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C instanceof ${i.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 ${o}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D\u043E ${s}`}case"invalid_value":return i.values.length===1?`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C ${j(i.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.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);if(a){let s=Number(i.maximum),c=VO(s,a.unit.one,a.unit.few,a.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 ${i.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435"} \u0431\u0443\u0434\u0435\u0442 \u0438\u043C\u0435\u0442\u044C ${o}${i.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 ${i.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435"} \u0431\u0443\u0434\u0435\u0442 ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);if(a){let s=Number(i.minimum),c=VO(s,a.unit.one,a.unit.few,a.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 ${i.origin} \u0431\u0443\u0434\u0435\u0442 \u0438\u043C\u0435\u0442\u044C ${o}${i.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 ${i.origin} \u0431\u0443\u0434\u0435\u0442 ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.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 "${o.prefix}"`:o.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 "${o.suffix}"`:o.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 "${o.includes}"`:o.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 ${o.pattern}`:`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 ${r[o.format]??i.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 ${i.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0441\u043F\u043E\u0437\u043D\u0430\u043D\u043D${i.keys.length>1?"\u044B\u0435":"\u044B\u0439"} \u043A\u043B\u044E\u0447${i.keys.length>1?"\u0438":""}: ${$(i.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u043A\u043B\u044E\u0447 \u0432 ${i.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 ${i.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 HO(){return{localeError:CF()}}var OF=()=>{let e={string:{unit:"znakov",verb:"imeti"},file:{unit:"bajtov",verb:"imeti"},array:{unit:"elementov",verb:"imeti"},set:{unit:"elementov",verb:"imeti"}};function t(i){return e[i]??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"},n={nan:"NaN",number:"\u0161tevilo",array:"tabela"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=M(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`Neveljaven vnos: pri\u010Dakovano instanceof ${i.expected}, prejeto ${s}`:`Neveljaven vnos: pri\u010Dakovano ${o}, prejeto ${s}`}case"invalid_value":return i.values.length===1?`Neveljaven vnos: pri\u010Dakovano ${j(i.values[0])}`:`Neveljavna mo\u017Enost: pri\u010Dakovano eno izmed ${$(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`Preveliko: pri\u010Dakovano, da bo ${i.origin??"vrednost"} imelo ${o}${i.maximum.toString()} ${a.unit??"elementov"}`:`Preveliko: pri\u010Dakovano, da bo ${i.origin??"vrednost"} ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`Premajhno: pri\u010Dakovano, da bo ${i.origin} imelo ${o}${i.minimum.toString()} ${a.unit}`:`Premajhno: pri\u010Dakovano, da bo ${i.origin} ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Neveljaven niz: mora se za\u010Deti z "${o.prefix}"`:o.format==="ends_with"?`Neveljaven niz: mora se kon\u010Dati z "${o.suffix}"`:o.format==="includes"?`Neveljaven niz: mora vsebovati "${o.includes}"`:o.format==="regex"?`Neveljaven niz: mora ustrezati vzorcu ${o.pattern}`:`Neveljaven ${r[o.format]??i.format}`}case"not_multiple_of":return`Neveljavno \u0161tevilo: mora biti ve\u010Dkratnik ${i.divisor}`;case"unrecognized_keys":return`Neprepoznan${i.keys.length>1?"i klju\u010Di":" klju\u010D"}: ${$(i.keys,", ")}`;case"invalid_key":return`Neveljaven klju\u010D v ${i.origin}`;case"invalid_union":return"Neveljaven vnos";case"invalid_element":return`Neveljavna vrednost v ${i.origin}`;default:return"Neveljaven vnos"}}};function ZO(){return{localeError:OF()}}var PF=()=>{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(i){return e[i]??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"},n={nan:"NaN",number:"antal",array:"lista"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=M(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`Ogiltig inmatning: f\xF6rv\xE4ntat instanceof ${i.expected}, fick ${s}`:`Ogiltig inmatning: f\xF6rv\xE4ntat ${o}, fick ${s}`}case"invalid_value":return i.values.length===1?`Ogiltig inmatning: f\xF6rv\xE4ntat ${j(i.values[0])}`:`Ogiltigt val: f\xF6rv\xE4ntade en av ${$(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`F\xF6r stor(t): f\xF6rv\xE4ntade ${i.origin??"v\xE4rdet"} att ha ${o}${i.maximum.toString()} ${a.unit??"element"}`:`F\xF6r stor(t): f\xF6rv\xE4ntat ${i.origin??"v\xE4rdet"} att ha ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`F\xF6r lite(t): f\xF6rv\xE4ntade ${i.origin??"v\xE4rdet"} att ha ${o}${i.minimum.toString()} ${a.unit}`:`F\xF6r lite(t): f\xF6rv\xE4ntade ${i.origin??"v\xE4rdet"} att ha ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Ogiltig str\xE4ng: m\xE5ste b\xF6rja med "${o.prefix}"`:o.format==="ends_with"?`Ogiltig str\xE4ng: m\xE5ste sluta med "${o.suffix}"`:o.format==="includes"?`Ogiltig str\xE4ng: m\xE5ste inneh\xE5lla "${o.includes}"`:o.format==="regex"?`Ogiltig str\xE4ng: m\xE5ste matcha m\xF6nstret "${o.pattern}"`:`Ogiltig(t) ${r[o.format]??i.format}`}case"not_multiple_of":return`Ogiltigt tal: m\xE5ste vara en multipel av ${i.divisor}`;case"unrecognized_keys":return`${i.keys.length>1?"Ok\xE4nda nycklar":"Ok\xE4nd nyckel"}: ${$(i.keys,", ")}`;case"invalid_key":return`Ogiltig nyckel i ${i.origin??"v\xE4rdet"}`;case"invalid_union":return"Ogiltig input";case"invalid_element":return`Ogiltigt v\xE4rde i ${i.origin??"v\xE4rdet"}`;default:return"Ogiltig input"}}};function GO(){return{localeError:PF()}}var NF=()=>{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(i){return e[i]??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"},n={nan:"NaN",number:"\u0B8E\u0BA3\u0BCD",array:"\u0B85\u0BA3\u0BBF",null:"\u0BB5\u0BC6\u0BB1\u0BC1\u0BAE\u0BC8"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=M(i.input),s=n[a]??a;return/^[A-Z]/.test(i.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 ${i.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 ${o}, \u0BAA\u0BC6\u0BB1\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${s}`}case"invalid_value":return i.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 ${j(i.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.values,"|")} \u0B87\u0BB2\u0BCD \u0B92\u0BA9\u0BCD\u0BB1\u0BC1`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`\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 ${i.origin??"\u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1"} ${o}${i.maximum.toString()} ${a.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 ${i.origin??"\u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1"} ${o}${i.maximum.toString()} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`\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 ${i.origin} ${o}${i.minimum.toString()} ${a.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 ${i.origin} ${o}${i.minimum.toString()} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${o.prefix}" \u0B87\u0BB2\u0BCD \u0BA4\u0BCA\u0B9F\u0B99\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:o.format==="ends_with"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${o.suffix}" \u0B87\u0BB2\u0BCD \u0BAE\u0BC1\u0B9F\u0BBF\u0BB5\u0B9F\u0BC8\u0BAF \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:o.format==="includes"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${o.includes}" \u0B90 \u0B89\u0BB3\u0BCD\u0BB3\u0B9F\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:o.format==="regex"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: ${o.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[o.format]??i.format}`}case"not_multiple_of":return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B8E\u0BA3\u0BCD: ${i.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${i.keys.length>1?"\u0B95\u0BB3\u0BCD":""}: ${$(i.keys,", ")}`;case"invalid_key":return`${i.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`${i.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 WO(){return{localeError:NF()}}var RF=()=>{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(i){return e[i]??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"},n={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 i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=M(i.input),s=n[a]??a;return/^[A-Z]/.test(i.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 ${i.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 ${o} \u0E41\u0E15\u0E48\u0E44\u0E14\u0E49\u0E23\u0E31\u0E1A ${s}`}case"invalid_value":return i.values.length===1?`\u0E04\u0E48\u0E32\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 ${j(i.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.values,"|")}`;case"too_big":{let o=i.inclusive?"\u0E44\u0E21\u0E48\u0E40\u0E01\u0E34\u0E19":"\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32",a=t(i.origin);return a?`\u0E40\u0E01\u0E34\u0E19\u0E01\u0E33\u0E2B\u0E19\u0E14: ${i.origin??"\u0E04\u0E48\u0E32"} \u0E04\u0E27\u0E23\u0E21\u0E35${o} ${i.maximum.toString()} ${a.unit??"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23"}`:`\u0E40\u0E01\u0E34\u0E19\u0E01\u0E33\u0E2B\u0E19\u0E14: ${i.origin??"\u0E04\u0E48\u0E32"} \u0E04\u0E27\u0E23\u0E21\u0E35${o} ${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?"\u0E2D\u0E22\u0E48\u0E32\u0E07\u0E19\u0E49\u0E2D\u0E22":"\u0E21\u0E32\u0E01\u0E01\u0E27\u0E48\u0E32",a=t(i.origin);return a?`\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32\u0E01\u0E33\u0E2B\u0E19\u0E14: ${i.origin} \u0E04\u0E27\u0E23\u0E21\u0E35${o} ${i.minimum.toString()} ${a.unit}`:`\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32\u0E01\u0E33\u0E2B\u0E19\u0E14: ${i.origin} \u0E04\u0E27\u0E23\u0E21\u0E35${o} ${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.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 "${o.prefix}"`:o.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 "${o.suffix}"`:o.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 "${o.includes}" \u0E2D\u0E22\u0E39\u0E48\u0E43\u0E19\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21`:o.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 ${o.pattern}`:`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: ${r[o.format]??i.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 ${i.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.keys,", ")}`;case"invalid_key":return`\u0E04\u0E35\u0E22\u0E4C\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E43\u0E19 ${i.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 ${i.origin}`;default:return"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07"}}};function qO(){return{localeError:RF()}}var jF=()=>{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(i){return e[i]??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"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=M(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`Ge\xE7ersiz de\u011Fer: beklenen instanceof ${i.expected}, al\u0131nan ${s}`:`Ge\xE7ersiz de\u011Fer: beklenen ${o}, al\u0131nan ${s}`}case"invalid_value":return i.values.length===1?`Ge\xE7ersiz de\u011Fer: beklenen ${j(i.values[0])}`:`Ge\xE7ersiz se\xE7enek: a\u015Fa\u011F\u0131dakilerden biri olmal\u0131: ${$(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`\xC7ok b\xFCy\xFCk: beklenen ${i.origin??"de\u011Fer"} ${o}${i.maximum.toString()} ${a.unit??"\xF6\u011Fe"}`:`\xC7ok b\xFCy\xFCk: beklenen ${i.origin??"de\u011Fer"} ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`\xC7ok k\xFC\xE7\xFCk: beklenen ${i.origin} ${o}${i.minimum.toString()} ${a.unit}`:`\xC7ok k\xFC\xE7\xFCk: beklenen ${i.origin} ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Ge\xE7ersiz metin: "${o.prefix}" ile ba\u015Flamal\u0131`:o.format==="ends_with"?`Ge\xE7ersiz metin: "${o.suffix}" ile bitmeli`:o.format==="includes"?`Ge\xE7ersiz metin: "${o.includes}" i\xE7ermeli`:o.format==="regex"?`Ge\xE7ersiz metin: ${o.pattern} desenine uymal\u0131`:`Ge\xE7ersiz ${r[o.format]??i.format}`}case"not_multiple_of":return`Ge\xE7ersiz say\u0131: ${i.divisor} ile tam b\xF6l\xFCnebilmeli`;case"unrecognized_keys":return`Tan\u0131nmayan anahtar${i.keys.length>1?"lar":""}: ${$(i.keys,", ")}`;case"invalid_key":return`${i.origin} i\xE7inde ge\xE7ersiz anahtar`;case"invalid_union":return"Ge\xE7ersiz de\u011Fer";case"invalid_element":return`${i.origin} i\xE7inde ge\xE7ersiz de\u011Fer`;default:return"Ge\xE7ersiz de\u011Fer"}}};function KO(){return{localeError:jF()}}var MF=()=>{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(i){return e[i]??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"},n={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0438\u0432"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=M(i.input),s=n[a]??a;return/^[A-Z]/.test(i.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 ${i.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 ${o}, \u043E\u0442\u0440\u0438\u043C\u0430\u043D\u043E ${s}`}case"invalid_value":return i.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 ${j(i.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.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`\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 ${i.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F"} ${a.verb} ${o}${i.maximum.toString()} ${a.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 ${i.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F"} \u0431\u0443\u0434\u0435 ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u043C\u0430\u043B\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${i.origin} ${a.verb} ${o}${i.minimum.toString()} ${a.unit}`:`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u043C\u0430\u043B\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${i.origin} \u0431\u0443\u0434\u0435 ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.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 "${o.prefix}"`:o.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 "${o.suffix}"`:o.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 "${o.includes}"`:o.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 ${o.pattern}`:`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 ${r[o.format]??i.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 ${i.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u043E\u0437\u043F\u0456\u0437\u043D\u0430\u043D\u0438\u0439 \u043A\u043B\u044E\u0447${i.keys.length>1?"\u0456":""}: ${$(i.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u043A\u043B\u044E\u0447 \u0443 ${i.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 ${i.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 Qp(){return{localeError:MF()}}function JO(){return Qp()}var DF=()=>{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(i){return e[i]??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"},n={nan:"NaN",number:"\u0646\u0645\u0628\u0631",array:"\u0622\u0631\u06D2",null:"\u0646\u0644"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=M(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: instanceof ${i.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: ${o} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627\u060C ${s} \u0645\u0648\u0635\u0648\u0644 \u06C1\u0648\u0627`}case"invalid_value":return i.values.length===1?`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: ${j(i.values[0])} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`:`\u063A\u0644\u0637 \u0622\u067E\u0634\u0646: ${$(i.values,"|")} \u0645\u06CC\u06BA \u0633\u06D2 \u0627\u06CC\u06A9 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`\u0628\u06C1\u062A \u0628\u0691\u0627: ${i.origin??"\u0648\u06CC\u0644\u06CC\u0648"} \u06A9\u06D2 ${o}${i.maximum.toString()} ${a.unit??"\u0639\u0646\u0627\u0635\u0631"} \u06C1\u0648\u0646\u06D2 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u06D2`:`\u0628\u06C1\u062A \u0628\u0691\u0627: ${i.origin??"\u0648\u06CC\u0644\u06CC\u0648"} \u06A9\u0627 ${o}${i.maximum.toString()} \u06C1\u0648\u0646\u0627 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`\u0628\u06C1\u062A \u0686\u06BE\u0648\u0679\u0627: ${i.origin} \u06A9\u06D2 ${o}${i.minimum.toString()} ${a.unit} \u06C1\u0648\u0646\u06D2 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u06D2`:`\u0628\u06C1\u062A \u0686\u06BE\u0648\u0679\u0627: ${i.origin} \u06A9\u0627 ${o}${i.minimum.toString()} \u06C1\u0648\u0646\u0627 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${o.prefix}" \u0633\u06D2 \u0634\u0631\u0648\u0639 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:o.format==="ends_with"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${o.suffix}" \u067E\u0631 \u062E\u062A\u0645 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:o.format==="includes"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${o.includes}" \u0634\u0627\u0645\u0644 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:o.format==="regex"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: \u067E\u06CC\u0679\u0631\u0646 ${o.pattern} \u0633\u06D2 \u0645\u06CC\u0686 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:`\u063A\u0644\u0637 ${r[o.format]??i.format}`}case"not_multiple_of":return`\u063A\u0644\u0637 \u0646\u0645\u0628\u0631: ${i.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${i.keys.length>1?"\u0632":""}: ${$(i.keys,"\u060C ")}`;case"invalid_key":return`${i.origin} \u0645\u06CC\u06BA \u063A\u0644\u0637 \u06A9\u06CC`;case"invalid_union":return"\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679";case"invalid_element":return`${i.origin} \u0645\u06CC\u06BA \u063A\u0644\u0637 \u0648\u06CC\u0644\u06CC\u0648`;default:return"\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679"}}};function XO(){return{localeError:DF()}}var zF=()=>{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(i){return e[i]??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"},n={nan:"NaN",number:"raqam",array:"massiv"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=M(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`Noto\u2018g\u2018ri kirish: kutilgan instanceof ${i.expected}, qabul qilingan ${s}`:`Noto\u2018g\u2018ri kirish: kutilgan ${o}, qabul qilingan ${s}`}case"invalid_value":return i.values.length===1?`Noto\u2018g\u2018ri kirish: kutilgan ${j(i.values[0])}`:`Noto\u2018g\u2018ri variant: quyidagilardan biri kutilgan ${$(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`Juda katta: kutilgan ${i.origin??"qiymat"} ${o}${i.maximum.toString()} ${a.unit} ${a.verb}`:`Juda katta: kutilgan ${i.origin??"qiymat"} ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`Juda kichik: kutilgan ${i.origin} ${o}${i.minimum.toString()} ${a.unit} ${a.verb}`:`Juda kichik: kutilgan ${i.origin} ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Noto\u2018g\u2018ri satr: "${o.prefix}" bilan boshlanishi kerak`:o.format==="ends_with"?`Noto\u2018g\u2018ri satr: "${o.suffix}" bilan tugashi kerak`:o.format==="includes"?`Noto\u2018g\u2018ri satr: "${o.includes}" ni o\u2018z ichiga olishi kerak`:o.format==="regex"?`Noto\u2018g\u2018ri satr: ${o.pattern} shabloniga mos kelishi kerak`:`Noto\u2018g\u2018ri ${r[o.format]??i.format}`}case"not_multiple_of":return`Noto\u2018g\u2018ri raqam: ${i.divisor} ning karralisi bo\u2018lishi kerak`;case"unrecognized_keys":return`Noma\u2019lum kalit${i.keys.length>1?"lar":""}: ${$(i.keys,", ")}`;case"invalid_key":return`${i.origin} dagi kalit noto\u2018g\u2018ri`;case"invalid_union":return"Noto\u2018g\u2018ri kirish";case"invalid_element":return`${i.origin} da noto\u2018g\u2018ri qiymat`;default:return"Noto\u2018g\u2018ri kirish"}}};function YO(){return{localeError:zF()}}var UF=()=>{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(i){return e[i]??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"},n={nan:"NaN",number:"s\u1ED1",array:"m\u1EA3ng"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=M(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i instanceof ${i.expected}, nh\u1EADn \u0111\u01B0\u1EE3c ${s}`:`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i ${o}, nh\u1EADn \u0111\u01B0\u1EE3c ${s}`}case"invalid_value":return i.values.length===1?`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i ${j(i.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.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`Qu\xE1 l\u1EDBn: mong \u0111\u1EE3i ${i.origin??"gi\xE1 tr\u1ECB"} ${a.verb} ${o}${i.maximum.toString()} ${a.unit??"ph\u1EA7n t\u1EED"}`:`Qu\xE1 l\u1EDBn: mong \u0111\u1EE3i ${i.origin??"gi\xE1 tr\u1ECB"} ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`Qu\xE1 nh\u1ECF: mong \u0111\u1EE3i ${i.origin} ${a.verb} ${o}${i.minimum.toString()} ${a.unit}`:`Qu\xE1 nh\u1ECF: mong \u0111\u1EE3i ${i.origin} ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i b\u1EAFt \u0111\u1EA7u b\u1EB1ng "${o.prefix}"`:o.format==="ends_with"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i k\u1EBFt th\xFAc b\u1EB1ng "${o.suffix}"`:o.format==="includes"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i bao g\u1ED3m "${o.includes}"`:o.format==="regex"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i kh\u1EDBp v\u1EDBi m\u1EABu ${o.pattern}`:`${r[o.format]??i.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 ${i.divisor}`;case"unrecognized_keys":return`Kh\xF3a kh\xF4ng \u0111\u01B0\u1EE3c nh\u1EADn d\u1EA1ng: ${$(i.keys,", ")}`;case"invalid_key":return`Kh\xF3a kh\xF4ng h\u1EE3p l\u1EC7 trong ${i.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 ${i.origin}`;default:return"\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7"}}};function QO(){return{localeError:UF()}}var LF=()=>{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(i){return e[i]??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"},n={nan:"NaN",number:"\u6570\u5B57",array:"\u6570\u7EC4",null:"\u7A7A\u503C(null)"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=M(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B instanceof ${i.expected}\uFF0C\u5B9E\u9645\u63A5\u6536 ${s}`:`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B ${o}\uFF0C\u5B9E\u9645\u63A5\u6536 ${s}`}case"invalid_value":return i.values.length===1?`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B ${j(i.values[0])}`:`\u65E0\u6548\u9009\u9879\uFF1A\u671F\u671B\u4EE5\u4E0B\u4E4B\u4E00 ${$(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`\u6570\u503C\u8FC7\u5927\uFF1A\u671F\u671B ${i.origin??"\u503C"} ${o}${i.maximum.toString()} ${a.unit??"\u4E2A\u5143\u7D20"}`:`\u6570\u503C\u8FC7\u5927\uFF1A\u671F\u671B ${i.origin??"\u503C"} ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`\u6570\u503C\u8FC7\u5C0F\uFF1A\u671F\u671B ${i.origin} ${o}${i.minimum.toString()} ${a.unit}`:`\u6570\u503C\u8FC7\u5C0F\uFF1A\u671F\u671B ${i.origin} ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u4EE5 "${o.prefix}" \u5F00\u5934`:o.format==="ends_with"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u4EE5 "${o.suffix}" \u7ED3\u5C3E`:o.format==="includes"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u5305\u542B "${o.includes}"`:o.format==="regex"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u6EE1\u8DB3\u6B63\u5219\u8868\u8FBE\u5F0F ${o.pattern}`:`\u65E0\u6548${r[o.format]??i.format}`}case"not_multiple_of":return`\u65E0\u6548\u6570\u5B57\uFF1A\u5FC5\u987B\u662F ${i.divisor} \u7684\u500D\u6570`;case"unrecognized_keys":return`\u51FA\u73B0\u672A\u77E5\u7684\u952E(key): ${$(i.keys,", ")}`;case"invalid_key":return`${i.origin} \u4E2D\u7684\u952E(key)\u65E0\u6548`;case"invalid_union":return"\u65E0\u6548\u8F93\u5165";case"invalid_element":return`${i.origin} \u4E2D\u5305\u542B\u65E0\u6548\u503C(value)`;default:return"\u65E0\u6548\u8F93\u5165"}}};function eP(){return{localeError:LF()}}var FF=()=>{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(i){return e[i]??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"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=M(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA instanceof ${i.expected}\uFF0C\u4F46\u6536\u5230 ${s}`:`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA ${o}\uFF0C\u4F46\u6536\u5230 ${s}`}case"invalid_value":return i.values.length===1?`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA ${j(i.values[0])}`:`\u7121\u6548\u7684\u9078\u9805\uFF1A\u9810\u671F\u70BA\u4EE5\u4E0B\u5176\u4E2D\u4E4B\u4E00 ${$(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`\u6578\u503C\u904E\u5927\uFF1A\u9810\u671F ${i.origin??"\u503C"} \u61C9\u70BA ${o}${i.maximum.toString()} ${a.unit??"\u500B\u5143\u7D20"}`:`\u6578\u503C\u904E\u5927\uFF1A\u9810\u671F ${i.origin??"\u503C"} \u61C9\u70BA ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`\u6578\u503C\u904E\u5C0F\uFF1A\u9810\u671F ${i.origin} \u61C9\u70BA ${o}${i.minimum.toString()} ${a.unit}`:`\u6578\u503C\u904E\u5C0F\uFF1A\u9810\u671F ${i.origin} \u61C9\u70BA ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u4EE5 "${o.prefix}" \u958B\u982D`:o.format==="ends_with"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u4EE5 "${o.suffix}" \u7D50\u5C3E`:o.format==="includes"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u5305\u542B "${o.includes}"`:o.format==="regex"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u7B26\u5408\u683C\u5F0F ${o.pattern}`:`\u7121\u6548\u7684 ${r[o.format]??i.format}`}case"not_multiple_of":return`\u7121\u6548\u7684\u6578\u5B57\uFF1A\u5FC5\u9808\u70BA ${i.divisor} \u7684\u500D\u6578`;case"unrecognized_keys":return`\u7121\u6CD5\u8B58\u5225\u7684\u9375\u503C${i.keys.length>1?"\u5011":""}\uFF1A${$(i.keys,"\u3001")}`;case"invalid_key":return`${i.origin} \u4E2D\u6709\u7121\u6548\u7684\u9375\u503C`;case"invalid_union":return"\u7121\u6548\u7684\u8F38\u5165\u503C";case"invalid_element":return`${i.origin} \u4E2D\u6709\u7121\u6548\u7684\u503C`;default:return"\u7121\u6548\u7684\u8F38\u5165\u503C"}}};function tP(){return{localeError:FF()}}var BF=()=>{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(i){return e[i]??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"},n={nan:"NaN",number:"n\u1ECD\u0301mb\xE0",array:"akop\u1ECD"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=M(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi instanceof ${i.expected}, \xE0m\u1ECD\u0300 a r\xED ${s}`:`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi ${o}, \xE0m\u1ECD\u0300 a r\xED ${s}`}case"invalid_value":return i.values.length===1?`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi ${j(i.values[0])}`:`\xC0\u1E63\xE0y\xE0n a\u1E63\xEC\u1E63e: yan \u1ECD\u0300kan l\xE1ra ${$(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`T\xF3 p\u1ECD\u0300 j\xF9: a n\xED l\xE1ti j\u1EB9\u0301 p\xE9 ${i.origin??"iye"} ${a.verb} ${o}${i.maximum} ${a.unit}`:`T\xF3 p\u1ECD\u0300 j\xF9: a n\xED l\xE1ti j\u1EB9\u0301 ${o}${i.maximum}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`K\xE9r\xE9 ju: a n\xED l\xE1ti j\u1EB9\u0301 p\xE9 ${i.origin} ${a.verb} ${o}${i.minimum} ${a.unit}`:`K\xE9r\xE9 ju: a n\xED l\xE1ti j\u1EB9\u0301 ${o}${i.minimum}`}case"invalid_format":{let o=i;return o.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 "${o.prefix}"`:o.format==="ends_with"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 par\xED p\u1EB9\u0300l\xFA "${o.suffix}"`:o.format==="includes"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 n\xED "${o.includes}"`:o.format==="regex"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 b\xE1 \xE0p\u1EB9\u1EB9r\u1EB9 mu ${o.pattern}`:`A\u1E63\xEC\u1E63e: ${r[o.format]??i.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 ${i.divisor}`;case"unrecognized_keys":return`B\u1ECDt\xECn\xEC \xE0\xECm\u1ECD\u0300: ${$(i.keys,", ")}`;case"invalid_key":return`B\u1ECDt\xECn\xEC a\u1E63\xEC\u1E63e n\xEDn\xFA ${i.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 ${i.origin}`;default:return"\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e"}}};function rP(){return{localeError:BF()}}var nP,xw=Symbol("ZodOutput"),Sw=Symbol("ZodInput"),em=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...r){let n=r[0];return this._map.set(t,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.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 n={...this.get(r)??{}};delete n.id;let i={...n,...this._map.get(t)};return Object.keys(i).length?i:void 0}return this._map.get(t)}has(t){return this._map.has(t)}};function tm(){return new em}(nP=globalThis).__zod_globalRegistry??(nP.__zod_globalRegistry=tm());var Le=globalThis.__zod_globalRegistry;function kw(e,t){return new e({type:"string",...F(t)})}function Ew(e,t){return new e({type:"string",coerce:!0,...F(t)})}function rm(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...F(t)})}function Al(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...F(t)})}function nm(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...F(t)})}function im(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...F(t)})}function om(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...F(t)})}function am(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...F(t)})}function Cl(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...F(t)})}function sm(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...F(t)})}function cm(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...F(t)})}function um(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...F(t)})}function lm(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...F(t)})}function dm(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...F(t)})}function fm(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...F(t)})}function pm(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...F(t)})}function mm(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...F(t)})}function hm(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...F(t)})}function Iw(e,t){return new e({type:"string",format:"mac",check:"string_format",abort:!1,...F(t)})}function gm(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...F(t)})}function _m(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...F(t)})}function ym(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...F(t)})}function vm(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...F(t)})}function bm(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...F(t)})}function wm(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...F(t)})}var $w={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6};function Tw(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...F(t)})}function Aw(e,t){return new e({type:"string",format:"date",check:"string_format",...F(t)})}function Cw(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...F(t)})}function Ow(e,t){return new e({type:"string",format:"duration",check:"string_format",...F(t)})}function Pw(e,t){return new e({type:"number",checks:[],...F(t)})}function Nw(e,t){return new e({type:"number",coerce:!0,checks:[],...F(t)})}function Rw(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...F(t)})}function jw(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float32",...F(t)})}function Mw(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float64",...F(t)})}function Dw(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"int32",...F(t)})}function zw(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"uint32",...F(t)})}function Uw(e,t){return new e({type:"boolean",...F(t)})}function Lw(e,t){return new e({type:"boolean",coerce:!0,...F(t)})}function Fw(e,t){return new e({type:"bigint",...F(t)})}function Bw(e,t){return new e({type:"bigint",coerce:!0,...F(t)})}function Vw(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...F(t)})}function Hw(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...F(t)})}function Zw(e,t){return new e({type:"symbol",...F(t)})}function Gw(e,t){return new e({type:"undefined",...F(t)})}function Ww(e,t){return new e({type:"null",...F(t)})}function qw(e){return new e({type:"any"})}function Ol(e){return new e({type:"unknown"})}function Pl(e,t){return new e({type:"never",...F(t)})}function Kw(e,t){return new e({type:"void",...F(t)})}function Jw(e,t){return new e({type:"date",...F(t)})}function Xw(e,t){return new e({type:"date",coerce:!0,...F(t)})}function Yw(e,t){return new e({type:"nan",...F(t)})}function ii(e,t){return new Fp({check:"less_than",...F(t),value:e,inclusive:!1})}function qr(e,t){return new Fp({check:"less_than",...F(t),value:e,inclusive:!0})}function oi(e,t){return new Bp({check:"greater_than",...F(t),value:e,inclusive:!1})}function br(e,t){return new Bp({check:"greater_than",...F(t),value:e,inclusive:!0})}function xm(e){return oi(0,e)}function Sm(e){return ii(0,e)}function km(e){return qr(0,e)}function Em(e){return br(0,e)}function Lo(e,t){return new Kv({check:"multiple_of",...F(t),value:e})}function Fo(e,t){return new Yv({check:"max_size",...F(t),maximum:e})}function ai(e,t){return new Qv({check:"min_size",...F(t),minimum:e})}function ns(e,t){return new eb({check:"size_equals",...F(t),size:e})}function is(e,t){return new tb({check:"max_length",...F(t),maximum:e})}function Di(e,t){return new rb({check:"min_length",...F(t),minimum:e})}function os(e,t){return new nb({check:"length_equals",...F(t),length:e})}function Tc(e,t){return new ib({check:"string_format",format:"regex",...F(t),pattern:e})}function Ac(e){return new ob({check:"string_format",format:"lowercase",...F(e)})}function Cc(e){return new ab({check:"string_format",format:"uppercase",...F(e)})}function Oc(e,t){return new sb({check:"string_format",format:"includes",...F(t),includes:e})}function Pc(e,t){return new cb({check:"string_format",format:"starts_with",...F(t),prefix:e})}function Nc(e,t){return new ub({check:"string_format",format:"ends_with",...F(t),suffix:e})}function Im(e,t,r){return new lb({check:"property",property:e,schema:t,...F(r)})}function Rc(e,t){return new db({check:"mime_type",mime:e,...F(t)})}function kn(e){return new fb({check:"overwrite",tx:e})}function jc(e){return kn(t=>t.normalize(e))}function Mc(){return kn(e=>e.trim())}function Dc(){return kn(e=>e.toLowerCase())}function zc(){return kn(e=>e.toUpperCase())}function Uc(){return kn(e=>cv(e))}function Qw(e,t,r){return new e({type:"array",element:t,...F(r)})}function HF(e,t,r){return new e({type:"union",options:t,...F(r)})}function ZF(e,t,r){return new e({type:"union",options:t,inclusive:!1,...F(r)})}function GF(e,t,r,n){return new e({type:"union",options:r,discriminator:t,...F(n)})}function WF(e,t,r){return new e({type:"intersection",left:t,right:r})}function qF(e,t,r,n){let i=r instanceof he,o=i?n:r,a=i?r:null;return new e({type:"tuple",items:t,rest:a,...F(o)})}function KF(e,t,r,n){return new e({type:"record",keyType:t,valueType:r,...F(n)})}function JF(e,t,r,n){return new e({type:"map",keyType:t,valueType:r,...F(n)})}function XF(e,t,r){return new e({type:"set",valueType:t,...F(r)})}function YF(e,t,r){let n=Array.isArray(t)?Object.fromEntries(t.map(i=>[i,i])):t;return new e({type:"enum",entries:n,...F(r)})}function QF(e,t,r){return new e({type:"enum",entries:t,...F(r)})}function eB(e,t,r){return new e({type:"literal",values:Array.isArray(t)?t:[t],...F(r)})}function ex(e,t){return new e({type:"file",...F(t)})}function tB(e,t){return new e({type:"transform",transform:t})}function rB(e,t){return new e({type:"optional",innerType:t})}function nB(e,t){return new e({type:"nullable",innerType:t})}function iB(e,t,r){return new e({type:"default",innerType:t,get defaultValue(){return typeof r=="function"?r():lv(r)}})}function oB(e,t,r){return new e({type:"nonoptional",innerType:t,...F(r)})}function aB(e,t){return new e({type:"success",innerType:t})}function sB(e,t,r){return new e({type:"catch",innerType:t,catchValue:typeof r=="function"?r:()=>r})}function cB(e,t,r){return new e({type:"pipe",in:t,out:r})}function uB(e,t){return new e({type:"readonly",innerType:t})}function lB(e,t,r){return new e({type:"template_literal",parts:t,...F(r)})}function dB(e,t){return new e({type:"lazy",getter:t})}function fB(e,t){return new e({type:"promise",innerType:t})}function tx(e,t,r){let n=F(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}function rx(e,t,r){return new e({type:"custom",check:"custom",fn:t,...F(r)})}function nx(e,t){let r=iP(n=>(n.addIssue=i=>{if(typeof i=="string")n.issues.push(wc(i,n.value,r._zod.def));else{let o=i;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=r),o.continue??(o.continue=!r._zod.def.abort),n.issues.push(wc(o))}},e(n.value,n)),t);return r}function iP(e,t){let r=new We({check:"custom",...F(t)});return r._zod.check=e,r}function ix(e){let t=new We({check:"describe"});return t._zod.onattach=[r=>{let n=Le.get(r)??{};Le.add(r,{...n,description:e})}],t._zod.check=()=>{},t}function ox(e){let t=new We({check:"meta"});return t._zod.onattach=[r=>{let n=Le.get(r)??{};Le.add(r,{...n,...e})}],t._zod.check=()=>{},t}function ax(e,t){let r=F(t),n=r.truthy??["true","1","yes","on","y","enabled"],i=r.falsy??["false","0","no","off","n","disabled"];r.case!=="sensitive"&&(n=n.map(p=>typeof p=="string"?p.toLowerCase():p),i=i.map(p=>typeof p=="string"?p.toLowerCase():p));let o=new Set(n),a=new Set(i),s=e.Codec??Il,c=e.Boolean??xl,u=e.String??ts,l=new u({type:"string",error:r.error}),d=new c({type:"boolean",error:r.error}),f=new s({type:"pipe",in:l,out:d,transform:((p,m)=>{let h=p;return r.case!=="sensitive"&&(h=h.toLowerCase()),o.has(h)?!0:a.has(h)?!1:(m.issues.push({code:"invalid_value",expected:"stringbool",values:[...o,...a],input:m.value,inst:f,continue:!1}),{})}),reverseTransform:((p,m)=>p===!0?n[0]||"true":i[0]||"false"),error:r.error});return f}function Lc(e,t,r,n={}){let i=F(n),o={...F(n),check:"string_format",type:"string",format:t,fn:typeof r=="function"?r:s=>r.test(s),...i};return r instanceof RegExp&&(o.pattern=r),new e(o)}function Bo(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??Le,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 Fe(e,t,r={path:[],schemaPath:[]}){var n;let i=e._zod.def,o=t.seen.get(e);if(o)return o.count++,r.schemaPath.includes(e)&&(o.cycle=r.path),o.schema;let a={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,a);let s=e._zod.toJSONSchema?.();if(s)a.schema=s;else{let l={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,a.schema,l);else{let f=a.schema,p=t.processors[i.type];if(!p)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);p(e,t,f,l)}let d=e._zod.parent;d&&(a.ref||(a.ref=d),Fe(d,t,l),t.seen.get(d).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(a.schema,c),t.io==="input"&&wr(e)&&(delete a.schema.examples,delete a.schema.default),t.io==="input"&&"_prefault"in a.schema&&((n=a.schema).default??(n.default=a.schema._prefault)),delete a.schema._prefault,t.seen.get(e).schema}function Vo(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let n=new Map;for(let a of e.seen.entries()){let s=e.metadataRegistry.get(a[0])?.id;if(s){let c=n.get(s);if(c&&c!==a[0])throw new Error(`Duplicate schema id "${s}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(s,a[0])}}let i=a=>{let s=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let d=e.external.registry.get(a[0])?.id,f=e.external.uri??(m=>m);if(d)return{ref:f(d)};let p=a[1].defId??a[1].schema.id??`schema${e.counter++}`;return a[1].defId=p,{defId:p,ref:`${f("__shared")}#/${s}/${p}`}}if(a[1]===r)return{ref:"#"};let u=`#/${s}/`,l=a[1].schema.id??`__schema${e.counter++}`;return{defId:l,ref:u+l}},o=a=>{if(a[1].schema.$ref)return;let s=a[1],{ref:c,defId:u}=i(a);s.def={...s.schema},u&&(s.defId=u);let l=s.schema;for(let d in l)delete l[d];l.$ref=c};if(e.cycles==="throw")for(let a of e.seen.entries()){let s=a[1];if(s.cycle)throw new Error(`Cycle detected: #/${s.cycle?.join("/")}/<root>
225
-
226
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let a of e.seen.entries()){let s=a[1];if(t===a[0]){o(a);continue}if(e.external){let u=e.external.registry.get(a[0])?.id;if(t!==a[0]&&u){o(a);continue}}if(e.metadataRegistry.get(a[0])?.id){o(a);continue}if(s.cycle){o(a);continue}if(s.count>1&&e.reused==="ref"){o(a);continue}}}function Ho(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let n=s=>{let c=e.seen.get(s);if(c.ref===null)return;let u=c.def??c.schema,l={...u},d=c.ref;if(c.ref=null,d){n(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")?(u.allOf=u.allOf??[],u.allOf.push(m)):Object.assign(u,m),Object.assign(u,l),s._zod.parent===d)for(let _ in u)_==="$ref"||_==="allOf"||_ in l||delete u[_];if(m.$ref&&p.def)for(let _ in u)_==="$ref"||_==="allOf"||_ in p.def&&JSON.stringify(u[_])===JSON.stringify(p.def[_])&&delete u[_]}let f=s._zod.parent;if(f&&f!==d){n(f);let p=e.seen.get(f);if(p?.schema.$ref&&(u.$ref=p.schema.$ref,p.def))for(let m in u)m==="$ref"||m==="allOf"||m in p.def&&JSON.stringify(u[m])===JSON.stringify(p.def[m])&&delete u[m]}e.override({zodSchema:s,jsonSchema:u,path:c.path??[]})};for(let s of[...e.seen.entries()].reverse())n(s[0]);let i={};if(e.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?i.$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");i.$id=e.external.uri(s)}Object.assign(i,r.def??r.schema);let o=e.metadataRegistry.get(t)?.id;o!==void 0&&i.id===o&&delete i.id;let a=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,a[c.defId]=c.def)}e.external||Object.keys(a).length>0&&(e.target==="draft-2020-12"?i.$defs=a:i.definitions=a);try{let s=JSON.parse(JSON.stringify(i));return Object.defineProperty(s,"~standard",{value:{...t["~standard"],jsonSchema:{input:Fc(t,"input",e.processors),output:Fc(t,"output",e.processors)}},enumerable:!1,writable:!1}),s}catch{throw new Error("Error converting schema to JSON.")}}function wr(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return wr(n.element,r);if(n.type==="set")return wr(n.valueType,r);if(n.type==="lazy")return wr(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault")return wr(n.innerType,r);if(n.type==="intersection")return wr(n.left,r)||wr(n.right,r);if(n.type==="record"||n.type==="map")return wr(n.keyType,r)||wr(n.valueType,r);if(n.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:wr(n.in,r)||wr(n.out,r);if(n.type==="object"){for(let i in n.shape)if(wr(n.shape[i],r))return!0;return!1}if(n.type==="union"){for(let i of n.options)if(wr(i,r))return!0;return!1}if(n.type==="tuple"){for(let i of n.items)if(wr(i,r))return!0;return!!(n.rest&&wr(n.rest,r))}return!1}var sx=(e,t={})=>r=>{let n=Bo({...r,processors:t});return Fe(e,n),Vo(n,e),Ho(n,e)},Fc=(e,t,r={})=>n=>{let{libraryOptions:i,target:o}=n??{},a=Bo({...i??{},target:o,io:t,processors:r});return Fe(e,a),Vo(a,e),Ho(a,e)};var pB={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},cx=(e,t,r,n)=>{let i=r;i.type="string";let{minimum:o,maximum:a,format:s,patterns:c,contentEncoding:u}=e._zod.bag;if(typeof o=="number"&&(i.minLength=o),typeof a=="number"&&(i.maxLength=a),s&&(i.format=pB[s]??s,i.format===""&&delete i.format,s==="time"&&delete i.format),u&&(i.contentEncoding=u),c&&c.size>0){let l=[...c];l.length===1?i.pattern=l[0].source:l.length>1&&(i.allOf=[...l.map(d=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))])}},ux=(e,t,r,n)=>{let i=r,{minimum:o,maximum:a,format:s,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:l}=e._zod.bag;typeof s=="string"&&s.includes("int")?i.type="integer":i.type="number";let d=typeof l=="number"&&l>=(o??Number.NEGATIVE_INFINITY),f=typeof u=="number"&&u<=(a??Number.POSITIVE_INFINITY),p=t.target==="draft-04"||t.target==="openapi-3.0";d?p?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:typeof o=="number"&&(i.minimum=o),f?p?(i.maximum=u,i.exclusiveMaximum=!0):i.exclusiveMaximum=u:typeof a=="number"&&(i.maximum=a),typeof c=="number"&&(i.multipleOf=c)},lx=(e,t,r,n)=>{r.type="boolean"},dx=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},fx=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},px=(e,t,r,n)=>{t.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"},mx=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},hx=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},gx=(e,t,r,n)=>{r.not={}},_x=(e,t,r,n)=>{},yx=(e,t,r,n)=>{},vx=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},bx=(e,t,r,n)=>{let i=e._zod.def,o=dl(i.entries);o.every(a=>typeof a=="number")&&(r.type="number"),o.every(a=>typeof a=="string")&&(r.type="string"),r.enum=o},wx=(e,t,r,n)=>{let i=e._zod.def,o=[];for(let a of i.values)if(a===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof a=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");o.push(Number(a))}else o.push(a);if(o.length!==0)if(o.length===1){let a=o[0];r.type=a===null?"null":typeof a,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[a]:r.const=a}else o.every(a=>typeof a=="number")&&(r.type="number"),o.every(a=>typeof a=="string")&&(r.type="string"),o.every(a=>typeof a=="boolean")&&(r.type="boolean"),o.every(a=>a===null)&&(r.type="null"),r.enum=o},xx=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},Sx=(e,t,r,n)=>{let i=r,o=e._zod.pattern;if(!o)throw new Error("Pattern not found in template literal");i.type="string",i.pattern=o.source},kx=(e,t,r,n)=>{let i=r,o={type:"string",format:"binary",contentEncoding:"binary"},{minimum:a,maximum:s,mime:c}=e._zod.bag;a!==void 0&&(o.minLength=a),s!==void 0&&(o.maxLength=s),c?c.length===1?(o.contentMediaType=c[0],Object.assign(i,o)):(Object.assign(i,o),i.anyOf=c.map(u=>({contentMediaType:u}))):Object.assign(i,o)},Ex=(e,t,r,n)=>{r.type="boolean"},Ix=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},$x=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},Tx=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Ax=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},Cx=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},Ox=(e,t,r,n)=>{let i=r,o=e._zod.def,{minimum:a,maximum:s}=e._zod.bag;typeof a=="number"&&(i.minItems=a),typeof s=="number"&&(i.maxItems=s),i.type="array",i.items=Fe(o.element,t,{...n,path:[...n.path,"items"]})},Px=(e,t,r,n)=>{let i=r,o=e._zod.def;i.type="object",i.properties={};let a=o.shape;for(let u in a)i.properties[u]=Fe(a[u],t,{...n,path:[...n.path,"properties",u]});let s=new Set(Object.keys(a)),c=new Set([...s].filter(u=>{let l=o.shape[u]._zod;return t.io==="input"?l.optin===void 0:l.optout===void 0}));c.size>0&&(i.required=Array.from(c)),o.catchall?._zod.def.type==="never"?i.additionalProperties=!1:o.catchall?o.catchall&&(i.additionalProperties=Fe(o.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},Tm=(e,t,r,n)=>{let i=e._zod.def,o=i.inclusive===!1,a=i.options.map((s,c)=>Fe(s,t,{...n,path:[...n.path,o?"oneOf":"anyOf",c]}));o?r.oneOf=a:r.anyOf=a},Nx=(e,t,r,n)=>{let i=e._zod.def,o=Fe(i.left,t,{...n,path:[...n.path,"allOf",0]}),a=Fe(i.right,t,{...n,path:[...n.path,"allOf",1]}),s=u=>"allOf"in u&&Object.keys(u).length===1,c=[...s(o)?o.allOf:[o],...s(a)?a.allOf:[a]];r.allOf=c},Rx=(e,t,r,n)=>{let i=r,o=e._zod.def;i.type="array";let a=t.target==="draft-2020-12"?"prefixItems":"items",s=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",c=o.items.map((f,p)=>Fe(f,t,{...n,path:[...n.path,a,p]})),u=o.rest?Fe(o.rest,t,{...n,path:[...n.path,s,...t.target==="openapi-3.0"?[o.items.length]:[]]}):null;t.target==="draft-2020-12"?(i.prefixItems=c,u&&(i.items=u)):t.target==="openapi-3.0"?(i.items={anyOf:c},u&&i.items.anyOf.push(u),i.minItems=c.length,u||(i.maxItems=c.length)):(i.items=c,u&&(i.additionalItems=u));let{minimum:l,maximum:d}=e._zod.bag;typeof l=="number"&&(i.minItems=l),typeof d=="number"&&(i.maxItems=d)},jx=(e,t,r,n)=>{let i=r,o=e._zod.def;i.type="object";let a=o.keyType,c=a._zod.bag?.patterns;if(o.mode==="loose"&&c&&c.size>0){let l=Fe(o.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});i.patternProperties={};for(let d of c)i.patternProperties[d.source]=l}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(i.propertyNames=Fe(o.keyType,t,{...n,path:[...n.path,"propertyNames"]})),i.additionalProperties=Fe(o.valueType,t,{...n,path:[...n.path,"additionalProperties"]});let u=a._zod.values;if(u){let l=[...u].filter(d=>typeof d=="string"||typeof d=="number");l.length>0&&(i.required=l)}},Mx=(e,t,r,n)=>{let i=e._zod.def,o=Fe(i.innerType,t,n),a=t.seen.get(e);t.target==="openapi-3.0"?(a.ref=i.innerType,r.nullable=!0):r.anyOf=[o,{type:"null"}]},Dx=(e,t,r,n)=>{let i=e._zod.def;Fe(i.innerType,t,n);let o=t.seen.get(e);o.ref=i.innerType},zx=(e,t,r,n)=>{let i=e._zod.def;Fe(i.innerType,t,n);let o=t.seen.get(e);o.ref=i.innerType,r.default=JSON.parse(JSON.stringify(i.defaultValue))},Ux=(e,t,r,n)=>{let i=e._zod.def;Fe(i.innerType,t,n);let o=t.seen.get(e);o.ref=i.innerType,t.io==="input"&&(r._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},Lx=(e,t,r,n)=>{let i=e._zod.def;Fe(i.innerType,t,n);let o=t.seen.get(e);o.ref=i.innerType;let a;try{a=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}r.default=a},Fx=(e,t,r,n)=>{let i=e._zod.def,o=i.in._zod.traits.has("$ZodTransform"),a=t.io==="input"?o?i.out:i.in:i.out;Fe(a,t,n);let s=t.seen.get(e);s.ref=a},Bx=(e,t,r,n)=>{let i=e._zod.def;Fe(i.innerType,t,n);let o=t.seen.get(e);o.ref=i.innerType,r.readOnly=!0},Vx=(e,t,r,n)=>{let i=e._zod.def;Fe(i.innerType,t,n);let o=t.seen.get(e);o.ref=i.innerType},Am=(e,t,r,n)=>{let i=e._zod.def;Fe(i.innerType,t,n);let o=t.seen.get(e);o.ref=i.innerType},Hx=(e,t,r,n)=>{let i=e._zod.innerType;Fe(i,t,n);let o=t.seen.get(e);o.ref=i},$m={string:cx,number:ux,boolean:lx,bigint:dx,symbol:fx,null:px,undefined:mx,void:hx,never:gx,any:_x,unknown:yx,date:vx,enum:bx,literal:wx,nan:xx,template_literal:Sx,file:kx,success:Ex,custom:Ix,function:$x,transform:Tx,map:Ax,set:Cx,array:Ox,object:Px,union:Tm,intersection:Nx,tuple:Rx,record:jx,nullable:Mx,nonoptional:Dx,default:zx,prefault:Ux,catch:Lx,pipe:Fx,readonly:Bx,promise:Vx,optional:Am,lazy:Hx};function as(e,t){if("_idmap"in e){let n=e,i=Bo({...t,processors:$m}),o={};for(let c of n._idmap.entries()){let[u,l]=c;Fe(l,i)}let a={},s={registry:n,uri:t?.uri,defs:o};i.external=s;for(let c of n._idmap.entries()){let[u,l]=c;Vo(i,l),a[u]=Ho(i,l)}if(Object.keys(o).length>0){let c=i.target==="draft-2020-12"?"$defs":"definitions";a.__shared={[c]:o}}return{schemas:a}}let r=Bo({...t,processors:$m});return Fe(e,r),Vo(r,e),Ho(r,e)}var Cm=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=Bo({processors:$m,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 Fe(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)),Vo(this.ctx,t);let n=Ho(this.ctx,t),{"~standard":i,...o}=n;return o}};var oP={};function Je(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 mt(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 aP(e){return Je(e)&&console.warn("[WARNING] Attempting to use Zod 4 schema in a context where Zod 3 schema is expected. This may cause unexpected behavior."),mt(e)}function Pr(e){return!e||typeof e!="object"||Array.isArray(e)?!1:!!(Je(e)||mt(e))}function Zx(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 Gx(e){return Je(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 sP(e){return!!(Zx(e)||Gx(e))}async function Pm(e,t){if(Je(e))try{return{success:!0,data:await Qa(e,t)}}catch(r){return{success:!1,error:r}}if(mt(e))return await e.safeParseAsync(t);throw new Error("Schema must be an instance of z3.ZodType or z4.$ZodType")}async function Zo(e,t){if(Je(e))return await Qa(e,t);if(mt(e))return await e.parseAsync(t);throw new Error("Schema must be an instance of z3.ZodType or z4.$ZodType")}function cP(e,t){if(Je(e))try{return{success:!0,data:Uo(e,t)}}catch(r){return{success:!1,error:r}}if(mt(e))return e.safeParse(t);throw new Error("Schema must be an instance of z3.ZodType or z4.$ZodType")}function Go(e,t){if(Je(e))return Uo(e,t);if(mt(e))return e.parse(t);throw new Error("Schema must be an instance of z3.ZodType or z4.$ZodType")}function Li(e){if(Je(e))return Le.get(e)?.description;if(mt(e)||"description"in e&&typeof e.description=="string")return e.description}function uP(e){if(!Pr(e))return!1;if(mt(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(Je(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 Vc(e){return Pr(e)?mt(e)?e._def.typeName==="ZodString":Je(e)?e._zod.def.type==="string":!1:!1}function Nl(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 an(e){return Je(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 Rl(e){return Je(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 Wx(e){return Je(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 qx(e){return Je(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 rr(e){return!!(Nl(e)||an(e))}function Ui(e){if(mt(e))return e.shape;if(Je(e))return e._zod.def.shape;throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject")}function Nm(e,t){if(mt(e))return e.extend(t);if(Je(e))return D.extend(e,t);throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject")}function Wo(e){if(mt(e))return e.partial();if(Je(e))return D.partial(rs,e,void 0);throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject")}function Bc(e,t=!1){if(Nl(e))return e.strict();if(an(e)){let r=e._zod.def.shape;if(t)for(let[o,a]of Object.entries(e._zod.def.shape)){if(an(a))r[o]=Bc(a,t);else if(Rl(a)){let c=a._zod.def.element;an(c)&&(c=Bc(c,t)),r[o]=rt(a,{...a._zod.def,element:c})}else r[o]=a;let s=Le.get(a);s&&Le.add(r[o],s)}let n=rt(e,{...e._zod.def,shape:r,catchall:Pl(kl)}),i=Le.get(e);return i&&Le.add(n,i),n}throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject")}function Om(e,t=!1){if(Nl(e))return e.passthrough();if(an(e)){let r=e._zod.def.shape;if(t)for(let[o,a]of Object.entries(e._zod.def.shape)){if(an(a))r[o]=Om(a,t);else if(Rl(a)){let c=a._zod.def.element;an(c)&&(c=Om(c,t)),r[o]=rt(a,{...a._zod.def,element:c})}else r[o]=a;let s=Le.get(a);s&&Le.add(r[o],s)}let n=rt(e,{...e._zod.def,shape:r,catchall:Ol(Sl)}),i=Le.get(e);return i&&Le.add(n,i),n}throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject")}function Rm(e){if(mt(e))try{let t=e.parse(void 0);return()=>t}catch{return}if(Je(e))try{let t=Uo(e,void 0);return()=>t}catch{return}}function hB(e){return mt(e)&&"typeName"in e._def&&e._def.typeName==="ZodEffects"}function gB(e){return Je(e)&&e._zod.def.type==="pipe"}function ss(e,t,r){let n=r.get(e);if(n!==void 0)return n;if(mt(e))return hB(e)?ss(e._def.schema,t,r):e;if(Je(e)){let i=e;if(gB(e)&&(i=ss(e._zod.def.in,t,r)),t){if(an(i)){let a={};for(let[s,c]of Object.entries(i._zod.def.shape))a[s]=ss(c,t,r);i=rt(i,{...i._zod.def,shape:a})}else if(Rl(i)){let a=ss(i._zod.def.element,t,r);i=rt(i,{...i._zod.def,element:a})}else if(Wx(i)){let a=ss(i._zod.def.innerType,t,r);i=rt(i,{...i._zod.def,innerType:a})}else if(qx(i)){let a=ss(i._zod.def.innerType,t,r);i=rt(i,{...i._zod.def,innerType:a})}}let o=Le.get(e);return o&&Le.add(i,o),r.set(e,i),i}throw new Error("Schema must be an instance of z3.ZodType or z4.$ZodType")}function jm(e,t=!1){return ss(e,t,new WeakMap)}function lP(e,t){if(mt(e)){let r=Ui(e),n={};for(let[i,o]of Object.entries(r))t(i,o)?n[i]=o.optional():n[i]=o;return e.extend(n)}if(Je(e)){let r=Ui(e),n={...e._zod.def.shape};for(let[a,s]of Object.entries(r))t(a,s)&&(n[a]=new rs({type:"optional",innerType:s}));let i=rt(e,{...e._zod.def,shape:n}),o=Le.get(e);return o&&Le.add(i,o),i}throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject")}function Mm(e){return e instanceof Error&&(e.constructor.name==="ZodError"||e.constructor.name==="$ZodError")}var fP=Symbol("Let zodToJsonSchema decide on which parser to use"),dP={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"},pP=e=>typeof e=="string"?{...dP,name:e}:{...dP,...e};var mP=e=>{let t=pP(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(([n,i])=>[i._def,{def:i._def,path:[...t.basePath,t.definitionPath,n],jsonSchema:void 0}]))}};var Dm=(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 st(e){if(e.target!=="openAi")return{};let t=[...e.basePath,e.definitionPath,e.openAiAnyTypeName];return e.flags.hasReferencedOpenAiAnyType=!0,{$ref:e.$refStrategy==="relative"?Dm(t,e.currentPath):t.join("/")}}function Kx(e,t,r,n){n?.errorMessages&&r&&(e.errorMessage={...e.errorMessage,[t]:r})}function De(e,t,r,n,i){e[t]=r,Kx(e,t,n,i)}var Ut={};Fn(Ut,{BRAND:()=>BB,DIRTY:()=>cs,EMPTY_PATH:()=>bB,INVALID:()=>ue,NEVER:()=>IV,OK:()=>nr,ParseStatus:()=>Zt,Schema:()=>Se,ZodAny:()=>Jo,ZodArray:()=>Hi,ZodBigInt:()=>ls,ZodBoolean:()=>ds,ZodBranded:()=>Ml,ZodCatch:()=>xs,ZodDate:()=>fs,ZodDefault:()=>ws,ZodDiscriminatedUnion:()=>Lm,ZodEffects:()=>un,ZodEnum:()=>vs,ZodError:()=>Nr,ZodFirstPartyTypeKind:()=>U,ZodFunction:()=>Bm,ZodIntersection:()=>gs,ZodIssueCode:()=>z,ZodLazy:()=>_s,ZodLiteral:()=>ys,ZodMap:()=>Kc,ZodNaN:()=>Xc,ZodNativeEnum:()=>bs,ZodNever:()=>En,ZodNull:()=>ms,ZodNullable:()=>ui,ZodNumber:()=>us,ZodObject:()=>Rr,ZodOptional:()=>sn,ZodParsedType:()=>J,ZodPipeline:()=>Dl,ZodPromise:()=>Xo,ZodReadonly:()=>Ss,ZodRecord:()=>Fm,ZodSchema:()=>Se,ZodSet:()=>Jc,ZodString:()=>Ko,ZodSymbol:()=>Wc,ZodTransformer:()=>un,ZodTuple:()=>ci,ZodType:()=>Se,ZodUndefined:()=>ps,ZodUnion:()=>hs,ZodUnknown:()=>Vi,ZodVoid:()=>qc,addIssueToContext:()=>H,any:()=>XB,array:()=>tV,bigint:()=>GB,boolean:()=>EP,coerce:()=>EV,custom:()=>xP,date:()=>WB,datetimeRegex:()=>bP,defaultErrorMap:()=>Fi,discriminatedUnion:()=>oV,effect:()=>_V,enum:()=>mV,function:()=>dV,getErrorMap:()=>Hc,getParsedType:()=>si,instanceof:()=>HB,intersection:()=>aV,isAborted:()=>zm,isAsync:()=>Zc,isDirty:()=>Um,isValid:()=>qo,late:()=>VB,lazy:()=>fV,literal:()=>pV,makeIssue:()=>jl,map:()=>uV,nan:()=>ZB,nativeEnum:()=>hV,never:()=>QB,null:()=>JB,nullable:()=>vV,number:()=>kP,object:()=>rV,objectUtil:()=>Jx,oboolean:()=>kV,onumber:()=>SV,optional:()=>yV,ostring:()=>xV,pipeline:()=>wV,preprocess:()=>bV,promise:()=>gV,quotelessJson:()=>_B,record:()=>cV,set:()=>lV,setErrorMap:()=>vB,strictObject:()=>nV,string:()=>SP,symbol:()=>qB,transformer:()=>_V,tuple:()=>sV,undefined:()=>KB,union:()=>iV,unknown:()=>YB,util:()=>Ne,void:()=>eV});var Ne;(function(e){e.assertEqual=i=>{};function t(i){}e.assertIs=t;function r(i){throw new Error}e.assertNever=r,e.arrayToEnum=i=>{let o={};for(let a of i)o[a]=a;return o},e.getValidEnumValues=i=>{let o=e.objectKeys(i).filter(s=>typeof i[i[s]]!="number"),a={};for(let s of o)a[s]=i[s];return e.objectValues(a)},e.objectValues=i=>e.objectKeys(i).map(function(o){return i[o]}),e.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{let o=[];for(let a in i)Object.prototype.hasOwnProperty.call(i,a)&&o.push(a);return o},e.find=(i,o)=>{for(let a of i)if(o(a))return a},e.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function n(i,o=" | "){return i.map(a=>typeof a=="string"?`'${a}'`:a).join(o)}e.joinValues=n,e.jsonStringifyReplacer=(i,o)=>typeof o=="bigint"?o.toString():o})(Ne||(Ne={}));var Jx;(function(e){e.mergeShapes=(t,r)=>({...t,...r})})(Jx||(Jx={}));var J=Ne.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),si=e=>{switch(typeof e){case"undefined":return J.undefined;case"string":return J.string;case"number":return Number.isNaN(e)?J.nan:J.number;case"boolean":return J.boolean;case"function":return J.function;case"bigint":return J.bigint;case"symbol":return J.symbol;case"object":return Array.isArray(e)?J.array:e===null?J.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?J.promise:typeof Map<"u"&&e instanceof Map?J.map:typeof Set<"u"&&e instanceof Set?J.set:typeof Date<"u"&&e instanceof Date?J.date:J.object;default:return J.unknown}};var z=Ne.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"]),_B=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),Nr=class e extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};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(o){return o.message},n={_errors:[]},i=o=>{for(let a of o.issues)if(a.code==="invalid_union")a.unionErrors.map(i);else if(a.code==="invalid_return_type")i(a.returnTypeError);else if(a.code==="invalid_arguments")i(a.argumentsError);else if(a.path.length===0)n._errors.push(r(a));else{let s=n,c=0;for(;c<a.path.length;){let u=a.path[c];c===a.path.length-1?(s[u]=s[u]||{_errors:[]},s[u]._errors.push(r(a))):s[u]=s[u]||{_errors:[]},s=s[u],c++}}};return i(this),n}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,Ne.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=r=>r.message){let r=Object.create(null),n=[];for(let i of this.issues)if(i.path.length>0){let o=i.path[0];r[o]=r[o]||[],r[o].push(t(i))}else n.push(t(i));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};Nr.create=e=>new Nr(e);var yB=(e,t)=>{let r;switch(e.code){case z.invalid_type:e.received===J.undefined?r="Required":r=`Expected ${e.expected}, received ${e.received}`;break;case z.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,Ne.jsonStringifyReplacer)}`;break;case z.unrecognized_keys:r=`Unrecognized key(s) in object: ${Ne.joinValues(e.keys,", ")}`;break;case z.invalid_union:r="Invalid input";break;case z.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${Ne.joinValues(e.options)}`;break;case z.invalid_enum_value:r=`Invalid enum value. Expected ${Ne.joinValues(e.options)}, received '${e.received}'`;break;case z.invalid_arguments:r="Invalid function arguments";break;case z.invalid_return_type:r="Invalid function return type";break;case z.invalid_date:r="Invalid date";break;case z.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}"`:Ne.assertNever(e.validation):e.validation!=="regex"?r=`Invalid ${e.validation}`:r="Invalid";break;case z.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 z.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 z.custom:r="Invalid input";break;case z.invalid_intersection_types:r="Intersection results could not be merged";break;case z.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case z.not_finite:r="Number must be finite";break;default:r=t.defaultError,Ne.assertNever(e)}return{message:r}},Fi=yB;var hP=Fi;function vB(e){hP=e}function Hc(){return hP}var jl=e=>{let{data:t,path:r,errorMaps:n,issueData:i}=e,o=[...r,...i.path||[]],a={...i,path:o};if(i.message!==void 0)return{...i,path:o,message:i.message};let s="",c=n.filter(u=>!!u).slice().reverse();for(let u of c)s=u(a,{data:t,defaultError:s}).message;return{...i,path:o,message:s}},bB=[];function H(e,t){let r=Hc(),n=jl({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===Fi?void 0:Fi].filter(i=>!!i)});e.common.issues.push(n)}var Zt=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 n=[];for(let i of r){if(i.status==="aborted")return ue;i.status==="dirty"&&t.dirty(),n.push(i.value)}return{status:t.value,value:n}}static async mergeObjectAsync(t,r){let n=[];for(let i of r){let o=await i.key,a=await i.value;n.push({key:o,value:a})}return e.mergeObjectSync(t,n)}static mergeObjectSync(t,r){let n={};for(let i of r){let{key:o,value:a}=i;if(o.status==="aborted"||a.status==="aborted")return ue;o.status==="dirty"&&t.dirty(),a.status==="dirty"&&t.dirty(),o.value!=="__proto__"&&(typeof a.value<"u"||i.alwaysSet)&&(n[o.value]=a.value)}return{status:t.value,value:n}}},ue=Object.freeze({status:"aborted"}),cs=e=>({status:"dirty",value:e}),nr=e=>({status:"valid",value:e}),zm=e=>e.status==="aborted",Um=e=>e.status==="dirty",qo=e=>e.status==="valid",Zc=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 cn=class{constructor(t,r,n,i){this._cachedPath=[],this.parent=t,this.data=r,this._path=n,this._key=i}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}},gP=(e,t)=>{if(qo(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 Nr(e.common.issues);return this._error=r,this._error}}};function ye(e){if(!e)return{};let{errorMap:t,invalid_type_error:r,required_error:n,description:i}=e;if(t&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(a,s)=>{let{message:c}=e;return a.code==="invalid_enum_value"?{message:c??s.defaultError}:typeof s.data>"u"?{message:c??n??s.defaultError}:a.code!=="invalid_type"?{message:s.defaultError}:{message:c??r??s.defaultError}},description:i}}var Se=class{get description(){return this._def.description}_getType(t){return si(t.data)}_getOrReturnCtx(t,r){return r||{common:t.parent.common,data:t.data,parsedType:si(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new Zt,ctx:{common:t.parent.common,data:t.data,parsedType:si(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let r=this._parse(t);if(Zc(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 n=this.safeParse(t,r);if(n.success)return n.data;throw n.error}safeParse(t,r){let n={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:si(t)},i=this._parseSync({data:t,path:n.path,parent:n});return gP(n,i)}"~validate"(t){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:si(t)};if(!this["~standard"].async)try{let n=this._parseSync({data:t,path:[],parent:r});return qo(n)?{value:n.value}:{issues:r.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:r}).then(n=>qo(n)?{value:n.value}:{issues:r.common.issues})}async parseAsync(t,r){let n=await this.safeParseAsync(t,r);if(n.success)return n.data;throw n.error}async safeParseAsync(t,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:si(t)},i=this._parse({data:t,path:n.path,parent:n}),o=await(Zc(i)?i:Promise.resolve(i));return gP(n,o)}refine(t,r){let n=i=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(i):r;return this._refinement((i,o)=>{let a=t(i),s=()=>o.addIssue({code:z.custom,...n(i)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(s(),!1)):a?!0:(s(),!1)})}refinement(t,r){return this._refinement((n,i)=>t(n)?!0:(i.addIssue(typeof r=="function"?r(n,i):r),!1))}_refinement(t){return new un({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 sn.create(this,this._def)}nullable(){return ui.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Hi.create(this)}promise(){return Xo.create(this,this._def)}or(t){return hs.create([this,t],this._def)}and(t){return gs.create(this,t,this._def)}transform(t){return new un({...ye(this._def),schema:this,typeName:U.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let r=typeof t=="function"?t:()=>t;return new ws({...ye(this._def),innerType:this,defaultValue:r,typeName:U.ZodDefault})}brand(){return new Ml({typeName:U.ZodBranded,type:this,...ye(this._def)})}catch(t){let r=typeof t=="function"?t:()=>t;return new xs({...ye(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 Dl.create(this,t)}readonly(){return Ss.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},wB=/^c[^\s-]{8,}$/i,xB=/^[0-9a-z]+$/,SB=/^[0-9A-HJKMNP-TV-Z]{26}$/i,kB=/^[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,EB=/^[a-z0-9_-]{21}$/i,IB=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,$B=/^[-+]?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)?)??$/,TB=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,AB="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Xx,CB=/^(?:(?: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])$/,OB=/^(?:(?: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])$/,PB=/^(([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]))$/,NB=/^(([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])$/,RB=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,jB=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,yP="((\\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])))",MB=new RegExp(`^${yP}$`);function vP(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 DB(e){return new RegExp(`^${vP(e)}$`)}function bP(e){let t=`${yP}T${vP(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 zB(e,t){return!!((t==="v4"||!t)&&CB.test(e)||(t==="v6"||!t)&&PB.test(e))}function UB(e,t){if(!IB.test(e))return!1;try{let[r]=e.split(".");if(!r)return!1;let n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),i=JSON.parse(atob(n));return!(typeof i!="object"||i===null||"typ"in i&&i?.typ!=="JWT"||!i.alg||t&&i.alg!==t)}catch{return!1}}function LB(e,t){return!!((t==="v4"||!t)&&OB.test(e)||(t==="v6"||!t)&&NB.test(e))}var Ko=class e extends Se{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==J.string){let o=this._getOrReturnCtx(t);return H(o,{code:z.invalid_type,expected:J.string,received:o.parsedType}),ue}let n=new Zt,i;for(let o of this._def.checks)if(o.kind==="min")t.data.length<o.value&&(i=this._getOrReturnCtx(t,i),H(i,{code:z.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),n.dirty());else if(o.kind==="max")t.data.length>o.value&&(i=this._getOrReturnCtx(t,i),H(i,{code:z.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),n.dirty());else if(o.kind==="length"){let a=t.data.length>o.value,s=t.data.length<o.value;(a||s)&&(i=this._getOrReturnCtx(t,i),a?H(i,{code:z.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}):s&&H(i,{code:z.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}),n.dirty())}else if(o.kind==="email")TB.test(t.data)||(i=this._getOrReturnCtx(t,i),H(i,{validation:"email",code:z.invalid_string,message:o.message}),n.dirty());else if(o.kind==="emoji")Xx||(Xx=new RegExp(AB,"u")),Xx.test(t.data)||(i=this._getOrReturnCtx(t,i),H(i,{validation:"emoji",code:z.invalid_string,message:o.message}),n.dirty());else if(o.kind==="uuid")kB.test(t.data)||(i=this._getOrReturnCtx(t,i),H(i,{validation:"uuid",code:z.invalid_string,message:o.message}),n.dirty());else if(o.kind==="nanoid")EB.test(t.data)||(i=this._getOrReturnCtx(t,i),H(i,{validation:"nanoid",code:z.invalid_string,message:o.message}),n.dirty());else if(o.kind==="cuid")wB.test(t.data)||(i=this._getOrReturnCtx(t,i),H(i,{validation:"cuid",code:z.invalid_string,message:o.message}),n.dirty());else if(o.kind==="cuid2")xB.test(t.data)||(i=this._getOrReturnCtx(t,i),H(i,{validation:"cuid2",code:z.invalid_string,message:o.message}),n.dirty());else if(o.kind==="ulid")SB.test(t.data)||(i=this._getOrReturnCtx(t,i),H(i,{validation:"ulid",code:z.invalid_string,message:o.message}),n.dirty());else if(o.kind==="url")try{new URL(t.data)}catch{i=this._getOrReturnCtx(t,i),H(i,{validation:"url",code:z.invalid_string,message:o.message}),n.dirty()}else o.kind==="regex"?(o.regex.lastIndex=0,o.regex.test(t.data)||(i=this._getOrReturnCtx(t,i),H(i,{validation:"regex",code:z.invalid_string,message:o.message}),n.dirty())):o.kind==="trim"?t.data=t.data.trim():o.kind==="includes"?t.data.includes(o.value,o.position)||(i=this._getOrReturnCtx(t,i),H(i,{code:z.invalid_string,validation:{includes:o.value,position:o.position},message:o.message}),n.dirty()):o.kind==="toLowerCase"?t.data=t.data.toLowerCase():o.kind==="toUpperCase"?t.data=t.data.toUpperCase():o.kind==="startsWith"?t.data.startsWith(o.value)||(i=this._getOrReturnCtx(t,i),H(i,{code:z.invalid_string,validation:{startsWith:o.value},message:o.message}),n.dirty()):o.kind==="endsWith"?t.data.endsWith(o.value)||(i=this._getOrReturnCtx(t,i),H(i,{code:z.invalid_string,validation:{endsWith:o.value},message:o.message}),n.dirty()):o.kind==="datetime"?bP(o).test(t.data)||(i=this._getOrReturnCtx(t,i),H(i,{code:z.invalid_string,validation:"datetime",message:o.message}),n.dirty()):o.kind==="date"?MB.test(t.data)||(i=this._getOrReturnCtx(t,i),H(i,{code:z.invalid_string,validation:"date",message:o.message}),n.dirty()):o.kind==="time"?DB(o).test(t.data)||(i=this._getOrReturnCtx(t,i),H(i,{code:z.invalid_string,validation:"time",message:o.message}),n.dirty()):o.kind==="duration"?$B.test(t.data)||(i=this._getOrReturnCtx(t,i),H(i,{validation:"duration",code:z.invalid_string,message:o.message}),n.dirty()):o.kind==="ip"?zB(t.data,o.version)||(i=this._getOrReturnCtx(t,i),H(i,{validation:"ip",code:z.invalid_string,message:o.message}),n.dirty()):o.kind==="jwt"?UB(t.data,o.alg)||(i=this._getOrReturnCtx(t,i),H(i,{validation:"jwt",code:z.invalid_string,message:o.message}),n.dirty()):o.kind==="cidr"?LB(t.data,o.version)||(i=this._getOrReturnCtx(t,i),H(i,{validation:"cidr",code:z.invalid_string,message:o.message}),n.dirty()):o.kind==="base64"?RB.test(t.data)||(i=this._getOrReturnCtx(t,i),H(i,{validation:"base64",code:z.invalid_string,message:o.message}),n.dirty()):o.kind==="base64url"?jB.test(t.data)||(i=this._getOrReturnCtx(t,i),H(i,{validation:"base64url",code:z.invalid_string,message:o.message}),n.dirty()):Ne.assertNever(o);return{status:n.value,value:t.data}}_regex(t,r,n){return this.refinement(i=>t.test(i),{validation:r,code:z.invalid_string,...ne.errToObj(n)})}_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}};Ko.create=e=>new Ko({checks:[],typeName:U.ZodString,coerce:e?.coerce??!1,...ye(e)});function FB(e,t){let r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,i=r>n?r:n,o=Number.parseInt(e.toFixed(i).replace(".","")),a=Number.parseInt(t.toFixed(i).replace(".",""));return o%a/10**i}var us=class e extends Se{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)!==J.number){let o=this._getOrReturnCtx(t);return H(o,{code:z.invalid_type,expected:J.number,received:o.parsedType}),ue}let n,i=new Zt;for(let o of this._def.checks)o.kind==="int"?Ne.isInteger(t.data)||(n=this._getOrReturnCtx(t,n),H(n,{code:z.invalid_type,expected:"integer",received:"float",message:o.message}),i.dirty()):o.kind==="min"?(o.inclusive?t.data<o.value:t.data<=o.value)&&(n=this._getOrReturnCtx(t,n),H(n,{code:z.too_small,minimum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),i.dirty()):o.kind==="max"?(o.inclusive?t.data>o.value:t.data>=o.value)&&(n=this._getOrReturnCtx(t,n),H(n,{code:z.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),i.dirty()):o.kind==="multipleOf"?FB(t.data,o.value)!==0&&(n=this._getOrReturnCtx(t,n),H(n,{code:z.not_multiple_of,multipleOf:o.value,message:o.message}),i.dirty()):o.kind==="finite"?Number.isFinite(t.data)||(n=this._getOrReturnCtx(t,n),H(n,{code:z.not_finite,message:o.message}),i.dirty()):Ne.assertNever(o);return{status:i.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,n,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:ne.toString(i)}]})}_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"&&Ne.isInteger(t.value))}get isFinite(){let t=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(t===null||n.value<t)&&(t=n.value)}return Number.isFinite(r)&&Number.isFinite(t)}};us.create=e=>new us({checks:[],typeName:U.ZodNumber,coerce:e?.coerce||!1,...ye(e)});var ls=class e extends Se{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)!==J.bigint)return this._getInvalidInput(t);let n,i=new Zt;for(let o of this._def.checks)o.kind==="min"?(o.inclusive?t.data<o.value:t.data<=o.value)&&(n=this._getOrReturnCtx(t,n),H(n,{code:z.too_small,type:"bigint",minimum:o.value,inclusive:o.inclusive,message:o.message}),i.dirty()):o.kind==="max"?(o.inclusive?t.data>o.value:t.data>=o.value)&&(n=this._getOrReturnCtx(t,n),H(n,{code:z.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),i.dirty()):o.kind==="multipleOf"?t.data%o.value!==BigInt(0)&&(n=this._getOrReturnCtx(t,n),H(n,{code:z.not_multiple_of,multipleOf:o.value,message:o.message}),i.dirty()):Ne.assertNever(o);return{status:i.value,value:t.data}}_getInvalidInput(t){let r=this._getOrReturnCtx(t);return H(r,{code:z.invalid_type,expected:J.bigint,received:r.parsedType}),ue}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,n,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:ne.toString(i)}]})}_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}};ls.create=e=>new ls({checks:[],typeName:U.ZodBigInt,coerce:e?.coerce??!1,...ye(e)});var ds=class extends Se{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==J.boolean){let n=this._getOrReturnCtx(t);return H(n,{code:z.invalid_type,expected:J.boolean,received:n.parsedType}),ue}return nr(t.data)}};ds.create=e=>new ds({typeName:U.ZodBoolean,coerce:e?.coerce||!1,...ye(e)});var fs=class e extends Se{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==J.date){let o=this._getOrReturnCtx(t);return H(o,{code:z.invalid_type,expected:J.date,received:o.parsedType}),ue}if(Number.isNaN(t.data.getTime())){let o=this._getOrReturnCtx(t);return H(o,{code:z.invalid_date}),ue}let n=new Zt,i;for(let o of this._def.checks)o.kind==="min"?t.data.getTime()<o.value&&(i=this._getOrReturnCtx(t,i),H(i,{code:z.too_small,message:o.message,inclusive:!0,exact:!1,minimum:o.value,type:"date"}),n.dirty()):o.kind==="max"?t.data.getTime()>o.value&&(i=this._getOrReturnCtx(t,i),H(i,{code:z.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),n.dirty()):Ne.assertNever(o);return{status:n.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}};fs.create=e=>new fs({checks:[],coerce:e?.coerce||!1,typeName:U.ZodDate,...ye(e)});var Wc=class extends Se{_parse(t){if(this._getType(t)!==J.symbol){let n=this._getOrReturnCtx(t);return H(n,{code:z.invalid_type,expected:J.symbol,received:n.parsedType}),ue}return nr(t.data)}};Wc.create=e=>new Wc({typeName:U.ZodSymbol,...ye(e)});var ps=class extends Se{_parse(t){if(this._getType(t)!==J.undefined){let n=this._getOrReturnCtx(t);return H(n,{code:z.invalid_type,expected:J.undefined,received:n.parsedType}),ue}return nr(t.data)}};ps.create=e=>new ps({typeName:U.ZodUndefined,...ye(e)});var ms=class extends Se{_parse(t){if(this._getType(t)!==J.null){let n=this._getOrReturnCtx(t);return H(n,{code:z.invalid_type,expected:J.null,received:n.parsedType}),ue}return nr(t.data)}};ms.create=e=>new ms({typeName:U.ZodNull,...ye(e)});var Jo=class extends Se{constructor(){super(...arguments),this._any=!0}_parse(t){return nr(t.data)}};Jo.create=e=>new Jo({typeName:U.ZodAny,...ye(e)});var Vi=class extends Se{constructor(){super(...arguments),this._unknown=!0}_parse(t){return nr(t.data)}};Vi.create=e=>new Vi({typeName:U.ZodUnknown,...ye(e)});var En=class extends Se{_parse(t){let r=this._getOrReturnCtx(t);return H(r,{code:z.invalid_type,expected:J.never,received:r.parsedType}),ue}};En.create=e=>new En({typeName:U.ZodNever,...ye(e)});var qc=class extends Se{_parse(t){if(this._getType(t)!==J.undefined){let n=this._getOrReturnCtx(t);return H(n,{code:z.invalid_type,expected:J.void,received:n.parsedType}),ue}return nr(t.data)}};qc.create=e=>new qc({typeName:U.ZodVoid,...ye(e)});var Hi=class e extends Se{_parse(t){let{ctx:r,status:n}=this._processInputParams(t),i=this._def;if(r.parsedType!==J.array)return H(r,{code:z.invalid_type,expected:J.array,received:r.parsedType}),ue;if(i.exactLength!==null){let a=r.data.length>i.exactLength.value,s=r.data.length<i.exactLength.value;(a||s)&&(H(r,{code:a?z.too_big:z.too_small,minimum:s?i.exactLength.value:void 0,maximum:a?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&r.data.length<i.minLength.value&&(H(r,{code:z.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&r.data.length>i.maxLength.value&&(H(r,{code:z.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((a,s)=>i.type._parseAsync(new cn(r,a,r.path,s)))).then(a=>Zt.mergeArray(n,a));let o=[...r.data].map((a,s)=>i.type._parseSync(new cn(r,a,r.path,s)));return Zt.mergeArray(n,o)}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)}};Hi.create=(e,t)=>new Hi({type:e,minLength:null,maxLength:null,exactLength:null,typeName:U.ZodArray,...ye(t)});function Gc(e){if(e instanceof Rr){let t={};for(let r in e.shape){let n=e.shape[r];t[r]=sn.create(Gc(n))}return new Rr({...e._def,shape:()=>t})}else return e instanceof Hi?new Hi({...e._def,type:Gc(e.element)}):e instanceof sn?sn.create(Gc(e.unwrap())):e instanceof ui?ui.create(Gc(e.unwrap())):e instanceof ci?ci.create(e.items.map(t=>Gc(t))):e}var Rr=class e extends Se{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=Ne.objectKeys(t);return this._cached={shape:t,keys:r},this._cached}_parse(t){if(this._getType(t)!==J.object){let u=this._getOrReturnCtx(t);return H(u,{code:z.invalid_type,expected:J.object,received:u.parsedType}),ue}let{status:n,ctx:i}=this._processInputParams(t),{shape:o,keys:a}=this._getCached(),s=[];if(!(this._def.catchall instanceof En&&this._def.unknownKeys==="strip"))for(let u in i.data)a.includes(u)||s.push(u);let c=[];for(let u of a){let l=o[u],d=i.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new cn(i,d,i.path,u)),alwaysSet:u in i.data})}if(this._def.catchall instanceof En){let u=this._def.unknownKeys;if(u==="passthrough")for(let l of s)c.push({key:{status:"valid",value:l},value:{status:"valid",value:i.data[l]}});else if(u==="strict")s.length>0&&(H(i,{code:z.unrecognized_keys,keys:s}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let u=this._def.catchall;for(let l of s){let d=i.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new cn(i,d,i.path,l)),alwaysSet:l in i.data})}}return i.common.async?Promise.resolve().then(async()=>{let u=[];for(let l of c){let d=await l.key,f=await l.value;u.push({key:d,value:f,alwaysSet:l.alwaysSet})}return u}).then(u=>Zt.mergeObjectSync(n,u)):Zt.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(t){return ne.errToObj,new e({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(r,n)=>{let i=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:ne.errToObj(t).message??i}:{message:i}}}:{}})}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 n of Ne.objectKeys(t))t[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new e({...this._def,shape:()=>r})}omit(t){let r={};for(let n of Ne.objectKeys(this.shape))t[n]||(r[n]=this.shape[n]);return new e({...this._def,shape:()=>r})}deepPartial(){return Gc(this)}partial(t){let r={};for(let n of Ne.objectKeys(this.shape)){let i=this.shape[n];t&&!t[n]?r[n]=i:r[n]=i.optional()}return new e({...this._def,shape:()=>r})}required(t){let r={};for(let n of Ne.objectKeys(this.shape))if(t&&!t[n])r[n]=this.shape[n];else{let o=this.shape[n];for(;o instanceof sn;)o=o._def.innerType;r[n]=o}return new e({...this._def,shape:()=>r})}keyof(){return wP(Ne.objectKeys(this.shape))}};Rr.create=(e,t)=>new Rr({shape:()=>e,unknownKeys:"strip",catchall:En.create(),typeName:U.ZodObject,...ye(t)});Rr.strictCreate=(e,t)=>new Rr({shape:()=>e,unknownKeys:"strict",catchall:En.create(),typeName:U.ZodObject,...ye(t)});Rr.lazycreate=(e,t)=>new Rr({shape:e,unknownKeys:"strip",catchall:En.create(),typeName:U.ZodObject,...ye(t)});var hs=class extends Se{_parse(t){let{ctx:r}=this._processInputParams(t),n=this._def.options;function i(o){for(let s of o)if(s.result.status==="valid")return s.result;for(let s of o)if(s.result.status==="dirty")return r.common.issues.push(...s.ctx.common.issues),s.result;let a=o.map(s=>new Nr(s.ctx.common.issues));return H(r,{code:z.invalid_union,unionErrors:a}),ue}if(r.common.async)return Promise.all(n.map(async o=>{let a={...r,common:{...r.common,issues:[]},parent:null};return{result:await o._parseAsync({data:r.data,path:r.path,parent:a}),ctx:a}})).then(i);{let o,a=[];for(let c of n){let u={...r,common:{...r.common,issues:[]},parent:null},l=c._parseSync({data:r.data,path:r.path,parent:u});if(l.status==="valid")return l;l.status==="dirty"&&!o&&(o={result:l,ctx:u}),u.common.issues.length&&a.push(u.common.issues)}if(o)return r.common.issues.push(...o.ctx.common.issues),o.result;let s=a.map(c=>new Nr(c));return H(r,{code:z.invalid_union,unionErrors:s}),ue}}get options(){return this._def.options}};hs.create=(e,t)=>new hs({options:e,typeName:U.ZodUnion,...ye(t)});var Bi=e=>e instanceof _s?Bi(e.schema):e instanceof un?Bi(e.innerType()):e instanceof ys?[e.value]:e instanceof vs?e.options:e instanceof bs?Ne.objectValues(e.enum):e instanceof ws?Bi(e._def.innerType):e instanceof ps?[void 0]:e instanceof ms?[null]:e instanceof sn?[void 0,...Bi(e.unwrap())]:e instanceof ui?[null,...Bi(e.unwrap())]:e instanceof Ml||e instanceof Ss?Bi(e.unwrap()):e instanceof xs?Bi(e._def.innerType):[],Lm=class e extends Se{_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==J.object)return H(r,{code:z.invalid_type,expected:J.object,received:r.parsedType}),ue;let n=this.discriminator,i=r.data[n],o=this.optionsMap.get(i);return o?r.common.async?o._parseAsync({data:r.data,path:r.path,parent:r}):o._parseSync({data:r.data,path:r.path,parent:r}):(H(r,{code:z.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),ue)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,r,n){let i=new Map;for(let o of r){let a=Bi(o.shape[t]);if(!a.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let s of a){if(i.has(s))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(s)}`);i.set(s,o)}}return new e({typeName:U.ZodDiscriminatedUnion,discriminator:t,options:r,optionsMap:i,...ye(n)})}};function Yx(e,t){let r=si(e),n=si(t);if(e===t)return{valid:!0,data:e};if(r===J.object&&n===J.object){let i=Ne.objectKeys(t),o=Ne.objectKeys(e).filter(s=>i.indexOf(s)!==-1),a={...e,...t};for(let s of o){let c=Yx(e[s],t[s]);if(!c.valid)return{valid:!1};a[s]=c.data}return{valid:!0,data:a}}else if(r===J.array&&n===J.array){if(e.length!==t.length)return{valid:!1};let i=[];for(let o=0;o<e.length;o++){let a=e[o],s=t[o],c=Yx(a,s);if(!c.valid)return{valid:!1};i.push(c.data)}return{valid:!0,data:i}}else return r===J.date&&n===J.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}var gs=class extends Se{_parse(t){let{status:r,ctx:n}=this._processInputParams(t),i=(o,a)=>{if(zm(o)||zm(a))return ue;let s=Yx(o.value,a.value);return s.valid?((Um(o)||Um(a))&&r.dirty(),{status:r.value,value:s.data}):(H(n,{code:z.invalid_intersection_types}),ue)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([o,a])=>i(o,a)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};gs.create=(e,t,r)=>new gs({left:e,right:t,typeName:U.ZodIntersection,...ye(r)});var ci=class e extends Se{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==J.array)return H(n,{code:z.invalid_type,expected:J.array,received:n.parsedType}),ue;if(n.data.length<this._def.items.length)return H(n,{code:z.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),ue;!this._def.rest&&n.data.length>this._def.items.length&&(H(n,{code:z.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let o=[...n.data].map((a,s)=>{let c=this._def.items[s]||this._def.rest;return c?c._parse(new cn(n,a,n.path,s)):null}).filter(a=>!!a);return n.common.async?Promise.all(o).then(a=>Zt.mergeArray(r,a)):Zt.mergeArray(r,o)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};ci.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ci({items:e,typeName:U.ZodTuple,rest:null,...ye(t)})};var Fm=class e extends Se{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==J.object)return H(n,{code:z.invalid_type,expected:J.object,received:n.parsedType}),ue;let i=[],o=this._def.keyType,a=this._def.valueType;for(let s in n.data)i.push({key:o._parse(new cn(n,s,n.path,s)),value:a._parse(new cn(n,n.data[s],n.path,s)),alwaysSet:s in n.data});return n.common.async?Zt.mergeObjectAsync(r,i):Zt.mergeObjectSync(r,i)}get element(){return this._def.valueType}static create(t,r,n){return r instanceof Se?new e({keyType:t,valueType:r,typeName:U.ZodRecord,...ye(n)}):new e({keyType:Ko.create(),valueType:t,typeName:U.ZodRecord,...ye(r)})}},Kc=class extends Se{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==J.map)return H(n,{code:z.invalid_type,expected:J.map,received:n.parsedType}),ue;let i=this._def.keyType,o=this._def.valueType,a=[...n.data.entries()].map(([s,c],u)=>({key:i._parse(new cn(n,s,n.path,[u,"key"])),value:o._parse(new cn(n,c,n.path,[u,"value"]))}));if(n.common.async){let s=new Map;return Promise.resolve().then(async()=>{for(let c of a){let u=await c.key,l=await c.value;if(u.status==="aborted"||l.status==="aborted")return ue;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),s.set(u.value,l.value)}return{status:r.value,value:s}})}else{let s=new Map;for(let c of a){let u=c.key,l=c.value;if(u.status==="aborted"||l.status==="aborted")return ue;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),s.set(u.value,l.value)}return{status:r.value,value:s}}}};Kc.create=(e,t,r)=>new Kc({valueType:t,keyType:e,typeName:U.ZodMap,...ye(r)});var Jc=class e extends Se{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==J.set)return H(n,{code:z.invalid_type,expected:J.set,received:n.parsedType}),ue;let i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(H(n,{code:z.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),r.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(H(n,{code:z.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),r.dirty());let o=this._def.valueType;function a(c){let u=new Set;for(let l of c){if(l.status==="aborted")return ue;l.status==="dirty"&&r.dirty(),u.add(l.value)}return{status:r.value,value:u}}let s=[...n.data.values()].map((c,u)=>o._parse(new cn(n,c,n.path,u)));return n.common.async?Promise.all(s).then(c=>a(c)):a(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)}};Jc.create=(e,t)=>new Jc({valueType:e,minSize:null,maxSize:null,typeName:U.ZodSet,...ye(t)});var Bm=class e extends Se{constructor(){super(...arguments),this.validate=this.implement}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==J.function)return H(r,{code:z.invalid_type,expected:J.function,received:r.parsedType}),ue;function n(s,c){return jl({data:s,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Hc(),Fi].filter(u=>!!u),issueData:{code:z.invalid_arguments,argumentsError:c}})}function i(s,c){return jl({data:s,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Hc(),Fi].filter(u=>!!u),issueData:{code:z.invalid_return_type,returnTypeError:c}})}let o={errorMap:r.common.contextualErrorMap},a=r.data;if(this._def.returns instanceof Xo){let s=this;return nr(async function(...c){let u=new Nr([]),l=await s._def.args.parseAsync(c,o).catch(p=>{throw u.addIssue(n(c,p)),u}),d=await Reflect.apply(a,this,l);return await s._def.returns._def.type.parseAsync(d,o).catch(p=>{throw u.addIssue(i(d,p)),u})})}else{let s=this;return nr(function(...c){let u=s._def.args.safeParse(c,o);if(!u.success)throw new Nr([n(c,u.error)]);let l=Reflect.apply(a,this,u.data),d=s._def.returns.safeParse(l,o);if(!d.success)throw new Nr([i(l,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:ci.create(t).rest(Vi.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,n){return new e({args:t||ci.create([]).rest(Vi.create()),returns:r||Vi.create(),typeName:U.ZodFunction,...ye(n)})}},_s=class extends Se{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})}};_s.create=(e,t)=>new _s({getter:e,typeName:U.ZodLazy,...ye(t)});var ys=class extends Se{_parse(t){if(t.data!==this._def.value){let r=this._getOrReturnCtx(t);return H(r,{received:r.data,code:z.invalid_literal,expected:this._def.value}),ue}return{status:"valid",value:t.data}}get value(){return this._def.value}};ys.create=(e,t)=>new ys({value:e,typeName:U.ZodLiteral,...ye(t)});function wP(e,t){return new vs({values:e,typeName:U.ZodEnum,...ye(t)})}var vs=class e extends Se{_parse(t){if(typeof t.data!="string"){let r=this._getOrReturnCtx(t),n=this._def.values;return H(r,{expected:Ne.joinValues(n),received:r.parsedType,code:z.invalid_type}),ue}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){let r=this._getOrReturnCtx(t),n=this._def.values;return H(r,{received:r.data,code:z.invalid_enum_value,options:n}),ue}return nr(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(n=>!t.includes(n)),{...this._def,...r})}};vs.create=wP;var bs=class extends Se{_parse(t){let r=Ne.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(t);if(n.parsedType!==J.string&&n.parsedType!==J.number){let i=Ne.objectValues(r);return H(n,{expected:Ne.joinValues(i),received:n.parsedType,code:z.invalid_type}),ue}if(this._cache||(this._cache=new Set(Ne.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){let i=Ne.objectValues(r);return H(n,{received:n.data,code:z.invalid_enum_value,options:i}),ue}return nr(t.data)}get enum(){return this._def.values}};bs.create=(e,t)=>new bs({values:e,typeName:U.ZodNativeEnum,...ye(t)});var Xo=class extends Se{unwrap(){return this._def.type}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==J.promise&&r.common.async===!1)return H(r,{code:z.invalid_type,expected:J.promise,received:r.parsedType}),ue;let n=r.parsedType===J.promise?r.data:Promise.resolve(r.data);return nr(n.then(i=>this._def.type.parseAsync(i,{path:r.path,errorMap:r.common.contextualErrorMap})))}};Xo.create=(e,t)=>new Xo({type:e,typeName:U.ZodPromise,...ye(t)});var un=class extends Se{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:n}=this._processInputParams(t),i=this._def.effect||null,o={addIssue:a=>{H(n,a),a.fatal?r.abort():r.dirty()},get path(){return n.path}};if(o.addIssue=o.addIssue.bind(o),i.type==="preprocess"){let a=i.transform(n.data,o);if(n.common.async)return Promise.resolve(a).then(async s=>{if(r.value==="aborted")return ue;let c=await this._def.schema._parseAsync({data:s,path:n.path,parent:n});return c.status==="aborted"?ue:c.status==="dirty"?cs(c.value):r.value==="dirty"?cs(c.value):c});{if(r.value==="aborted")return ue;let s=this._def.schema._parseSync({data:a,path:n.path,parent:n});return s.status==="aborted"?ue:s.status==="dirty"?cs(s.value):r.value==="dirty"?cs(s.value):s}}if(i.type==="refinement"){let a=s=>{let c=i.refinement(s,o);if(n.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(n.common.async===!1){let s=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?ue:(s.status==="dirty"&&r.dirty(),a(s.value),{status:r.value,value:s.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(s=>s.status==="aborted"?ue:(s.status==="dirty"&&r.dirty(),a(s.value).then(()=>({status:r.value,value:s.value}))))}if(i.type==="transform")if(n.common.async===!1){let a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!qo(a))return ue;let s=i.transform(a.value,o);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:n.data,path:n.path,parent:n}).then(a=>qo(a)?Promise.resolve(i.transform(a.value,o)).then(s=>({status:r.value,value:s})):ue);Ne.assertNever(i)}};un.create=(e,t,r)=>new un({schema:e,typeName:U.ZodEffects,effect:t,...ye(r)});un.createWithPreprocess=(e,t,r)=>new un({schema:t,effect:{type:"preprocess",transform:e},typeName:U.ZodEffects,...ye(r)});var sn=class extends Se{_parse(t){return this._getType(t)===J.undefined?nr(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};sn.create=(e,t)=>new sn({innerType:e,typeName:U.ZodOptional,...ye(t)});var ui=class extends Se{_parse(t){return this._getType(t)===J.null?nr(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};ui.create=(e,t)=>new ui({innerType:e,typeName:U.ZodNullable,...ye(t)});var ws=class extends Se{_parse(t){let{ctx:r}=this._processInputParams(t),n=r.data;return r.parsedType===J.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};ws.create=(e,t)=>new ws({innerType:e,typeName:U.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...ye(t)});var xs=class extends Se{_parse(t){let{ctx:r}=this._processInputParams(t),n={...r,common:{...r.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Zc(i)?i.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new Nr(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Nr(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};xs.create=(e,t)=>new xs({innerType:e,typeName:U.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...ye(t)});var Xc=class extends Se{_parse(t){if(this._getType(t)!==J.nan){let n=this._getOrReturnCtx(t);return H(n,{code:z.invalid_type,expected:J.nan,received:n.parsedType}),ue}return{status:"valid",value:t.data}}};Xc.create=e=>new Xc({typeName:U.ZodNaN,...ye(e)});var BB=Symbol("zod_brand"),Ml=class extends Se{_parse(t){let{ctx:r}=this._processInputParams(t),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}},Dl=class e extends Se{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.common.async)return(async()=>{let o=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?ue:o.status==="dirty"?(r.dirty(),cs(o.value)):this._def.out._parseAsync({data:o.value,path:n.path,parent:n})})();{let i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?ue:i.status==="dirty"?(r.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(t,r){return new e({in:t,out:r,typeName:U.ZodPipeline})}},Ss=class extends Se{_parse(t){let r=this._def.innerType._parse(t),n=i=>(qo(i)&&(i.value=Object.freeze(i.value)),i);return Zc(r)?r.then(i=>n(i)):n(r)}unwrap(){return this._def.innerType}};Ss.create=(e,t)=>new Ss({innerType:e,typeName:U.ZodReadonly,...ye(t)});function _P(e,t){let r=typeof e=="function"?e(t):typeof e=="string"?{message:e}:e;return typeof r=="string"?{message:r}:r}function xP(e,t={},r){return e?Jo.create().superRefine((n,i)=>{let o=e(n);if(o instanceof Promise)return o.then(a=>{if(!a){let s=_P(t,n),c=s.fatal??r??!0;i.addIssue({code:"custom",...s,fatal:c})}});if(!o){let a=_P(t,n),s=a.fatal??r??!0;i.addIssue({code:"custom",...a,fatal:s})}}):Jo.create()}var VB={object:Rr.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 HB=(e,t={message:`Input not instance of ${e.name}`})=>xP(r=>r instanceof e,t),SP=Ko.create,kP=us.create,ZB=Xc.create,GB=ls.create,EP=ds.create,WB=fs.create,qB=Wc.create,KB=ps.create,JB=ms.create,XB=Jo.create,YB=Vi.create,QB=En.create,eV=qc.create,tV=Hi.create,rV=Rr.create,nV=Rr.strictCreate,iV=hs.create,oV=Lm.create,aV=gs.create,sV=ci.create,cV=Fm.create,uV=Kc.create,lV=Jc.create,dV=Bm.create,fV=_s.create,pV=ys.create,mV=vs.create,hV=bs.create,gV=Xo.create,_V=un.create,yV=sn.create,vV=ui.create,bV=un.createWithPreprocess,wV=Dl.create,xV=()=>SP().optional(),SV=()=>kP().optional(),kV=()=>EP().optional(),EV={string:(e=>Ko.create({...e,coerce:!0})),number:(e=>us.create({...e,coerce:!0})),boolean:(e=>ds.create({...e,coerce:!0})),bigint:(e=>ls.create({...e,coerce:!0})),date:(e=>fs.create({...e,coerce:!0}))};var IV=ue;function IP(e,t){let r={type:"array"};return e.type?._def&&e.type?._def?.typeName!==U.ZodAny&&(r.items=le(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&De(r,"minItems",e.minLength.value,e.minLength.message,t),e.maxLength&&De(r,"maxItems",e.maxLength.value,e.maxLength.message,t),e.exactLength&&(De(r,"minItems",e.exactLength.value,e.exactLength.message,t),De(r,"maxItems",e.exactLength.value,e.exactLength.message,t)),r}function $P(e,t){let r={type:"integer",format:"int64"};if(!e.checks)return r;for(let n of e.checks)switch(n.kind){case"min":t.target==="jsonSchema7"?n.inclusive?De(r,"minimum",n.value,n.message,t):De(r,"exclusiveMinimum",n.value,n.message,t):(n.inclusive||(r.exclusiveMinimum=!0),De(r,"minimum",n.value,n.message,t));break;case"max":t.target==="jsonSchema7"?n.inclusive?De(r,"maximum",n.value,n.message,t):De(r,"exclusiveMaximum",n.value,n.message,t):(n.inclusive||(r.exclusiveMaximum=!0),De(r,"maximum",n.value,n.message,t));break;case"multipleOf":De(r,"multipleOf",n.value,n.message,t);break}return r}function TP(){return{type:"boolean"}}function Vm(e,t){return le(e.type._def,t)}var AP=(e,t)=>le(e.innerType._def,t);function Qx(e,t,r){let n=r??t.dateStrategy;if(Array.isArray(n))return{anyOf:n.map(i=>Qx(e,t,i))};switch(n){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return $V(e,t)}}var $V=(e,t)=>{let r={type:"integer",format:"unix-time"};if(t.target==="openApi3")return r;for(let n of e.checks)switch(n.kind){case"min":De(r,"minimum",n.value,n.message,t);break;case"max":De(r,"maximum",n.value,n.message,t);break}return r};function CP(e,t){return{...le(e.innerType._def,t),default:e.defaultValue()}}function OP(e,t){return t.effectStrategy==="input"?le(e.schema._def,t):st(t)}function PP(e){return{type:"string",enum:Array.from(e.values)}}var TV=e=>"type"in e&&e.type==="string"?!1:"allOf"in e;function NP(e,t){let r=[le(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),le(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(o=>!!o),n=t.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,i=[];return r.forEach(o=>{if(TV(o))i.push(...o.allOf),o.unevaluatedProperties===void 0&&(n=void 0);else{let a=o;if("additionalProperties"in o&&o.additionalProperties===!1){let{additionalProperties:s,...c}=o;a=c}else n=void 0;i.push(a)}}),i.length?{allOf:i,...n}:void 0}function RP(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 e0,In={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:()=>(e0===void 0&&(e0=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),e0),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 Hm(e,t){let r={type:"string"};if(e.checks)for(let n of e.checks)switch(n.kind){case"min":De(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,t);break;case"max":De(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,t);break;case"email":switch(t.emailStrategy){case"format:email":$n(r,"email",n.message,t);break;case"format:idn-email":$n(r,"idn-email",n.message,t);break;case"pattern:zod":xr(r,In.email,n.message,t);break}break;case"url":$n(r,"uri",n.message,t);break;case"uuid":$n(r,"uuid",n.message,t);break;case"regex":xr(r,n.regex,n.message,t);break;case"cuid":xr(r,In.cuid,n.message,t);break;case"cuid2":xr(r,In.cuid2,n.message,t);break;case"startsWith":xr(r,RegExp(`^${t0(n.value,t)}`),n.message,t);break;case"endsWith":xr(r,RegExp(`${t0(n.value,t)}$`),n.message,t);break;case"datetime":$n(r,"date-time",n.message,t);break;case"date":$n(r,"date",n.message,t);break;case"time":$n(r,"time",n.message,t);break;case"duration":$n(r,"duration",n.message,t);break;case"length":De(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,t),De(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,t);break;case"includes":xr(r,RegExp(t0(n.value,t)),n.message,t);break;case"ip":n.version!=="v6"&&$n(r,"ipv4",n.message,t),n.version!=="v4"&&$n(r,"ipv6",n.message,t);break;case"base64url":xr(r,In.base64url,n.message,t);break;case"jwt":xr(r,In.jwt,n.message,t);break;case"cidr":n.version!=="v6"&&xr(r,In.ipv4Cidr,n.message,t),n.version!=="v4"&&xr(r,In.ipv6Cidr,n.message,t);break;case"emoji":xr(r,In.emoji(),n.message,t);break;case"ulid":xr(r,In.ulid,n.message,t);break;case"base64":switch(t.base64Strategy){case"format:binary":$n(r,"binary",n.message,t);break;case"contentEncoding:base64":De(r,"contentEncoding","base64",n.message,t);break;case"pattern:zod":xr(r,In.base64,n.message,t);break}break;case"nanoid":xr(r,In.nanoid,n.message,t);break;case"toLowerCase":case"toUpperCase":case"trim":break;default:}return r}function t0(e,t){return t.patternStrategy==="escape"?CV(e):e}var AV=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function CV(e){let t="";for(let r=0;r<e.length;r++)AV.has(e[r])||(t+="\\"),t+=e[r];return t}function $n(e,t,r,n){e.format||e.anyOf?.some(i=>i.format)?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format,...e.errorMessage&&n.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&&n.errorMessages&&{errorMessage:{format:r}}})):De(e,"format",t,r,n)}function xr(e,t,r,n){e.pattern||e.allOf?.some(i=>i.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern,...e.errorMessage&&n.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:jP(t,n),...r&&n.errorMessages&&{errorMessage:{pattern:r}}})):De(e,"pattern",jP(t,n),r,n)}function jP(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")},n=r.i?e.source.toLowerCase():e.source,i="",o=!1,a=!1,s=!1;for(let c=0;c<n.length;c++){if(o){i+=n[c],o=!1;continue}if(r.i){if(a){if(n[c].match(/[a-z]/)){s?(i+=n[c],i+=`${n[c-2]}-${n[c]}`.toUpperCase(),s=!1):n[c+1]==="-"&&n[c+2]?.match(/[a-z]/)?(i+=n[c],s=!0):i+=`${n[c]}${n[c].toUpperCase()}`;continue}}else if(n[c].match(/[a-z]/)){i+=`[${n[c]}${n[c].toUpperCase()}]`;continue}}if(r.m){if(n[c]==="^"){i+=`(^|(?<=[\r
227
- ]))`;continue}else if(n[c]==="$"){i+=`($|(?=[\r
228
- ]))`;continue}}if(r.s&&n[c]==="."){i+=a?`${n[c]}\r
229
- `:`[${n[c]}\r
230
- ]`;continue}i+=n[c],n[c]==="\\"?o=!0:a&&n[c]==="]"?a=!1:!a&&n[c]==="["&&(a=!0)}try{new RegExp(i)}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 i}function Zm(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((n,i)=>({...n,[i]:le(e.valueType._def,{...t,currentPath:[...t.currentPath,"properties",i]})??st(t)}),{}),additionalProperties:t.rejectedAdditionalProperties};let r={type:"object",additionalProperties:le(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:n,...i}=Hm(e.keyType._def,t);return{...r,propertyNames:i}}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:n,...i}=Vm(e.keyType._def,t);return{...r,propertyNames:i}}}return r}function MP(e,t){return t.mapStrategy==="record"?Zm(e,t):{type:"array",maxItems:125,items:{type:"array",items:[le(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||st(t),le(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||st(t)],minItems:2,maxItems:2}}}function DP(e){let t=e.values,r=Object.keys(e.values).filter(i=>typeof t[t[i]]!="number").map(i=>t[i]),n=Array.from(new Set(r.map(i=>typeof i)));return{type:n.length===1?n[0]==="string"?"string":"number":["string","number"],enum:r}}function zP(e){return e.target==="openAi"?void 0:{not:st({...e,currentPath:[...e.currentPath,"not"]})}}function UP(e){return e.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var zl={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function FP(e,t){if(t.target==="openApi3")return LP(e,t);let r=e.options instanceof Map?Array.from(e.options.values()):e.options;if(r.every(n=>n._def.typeName in zl&&(!n._def.checks||!n._def.checks.length))){let n=r.reduce((i,o)=>{let a=zl[o._def.typeName];return a&&!i.includes(a)?[...i,a]:i},[]);return{type:n.length>1?n:n[0]}}else if(r.every(n=>n._def.typeName==="ZodLiteral"&&!n.description)){let n=r.reduce((i,o)=>{let a=typeof o._def.value;switch(a){case"string":case"number":case"boolean":return[...i,a];case"bigint":return[...i,"integer"];case"object":return o._def.value===null?[...i,"null"]:i;default:return i}},[]);if(n.length===r.length){let i=n.filter((o,a,s)=>s.indexOf(o)===a);return{type:i.length>1?i:i[0],enum:r.reduce((o,a)=>o.includes(a._def.value)?o:[...o,a._def.value],[])}}}else if(r.every(n=>n._def.typeName==="ZodEnum"))return{type:"string",enum:r.reduce((n,i)=>[...n,...i._def.values.filter(o=>!n.includes(o))],[])};return LP(e,t)}var LP=(e,t)=>{let r=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((n,i)=>le(n._def,{...t,currentPath:[...t.currentPath,"anyOf",`${i}`]})).filter(n=>!!n&&(!t.strictUnions||typeof n=="object"&&Object.keys(n).length>0));return r.length?{anyOf:r}:void 0};function BP(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:zl[e.innerType._def.typeName],nullable:!0}:{type:[zl[e.innerType._def.typeName],"null"]};if(t.target==="openApi3"){let n=le(e.innerType._def,{...t,currentPath:[...t.currentPath]});return n&&"$ref"in n?{allOf:[n],nullable:!0}:n&&{...n,nullable:!0}}let r=le(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}function VP(e,t){let r={type:"number"};if(!e.checks)return r;for(let n of e.checks)switch(n.kind){case"int":r.type="integer",Kx(r,"type",n.message,t);break;case"min":t.target==="jsonSchema7"?n.inclusive?De(r,"minimum",n.value,n.message,t):De(r,"exclusiveMinimum",n.value,n.message,t):(n.inclusive||(r.exclusiveMinimum=!0),De(r,"minimum",n.value,n.message,t));break;case"max":t.target==="jsonSchema7"?n.inclusive?De(r,"maximum",n.value,n.message,t):De(r,"exclusiveMaximum",n.value,n.message,t):(n.inclusive||(r.exclusiveMaximum=!0),De(r,"maximum",n.value,n.message,t));break;case"multipleOf":De(r,"multipleOf",n.value,n.message,t);break}return r}function HP(e,t){let r=t.target==="openAi",n={type:"object",properties:{}},i=[],o=e.shape();for(let s in o){let c=o[s];if(c===void 0||c._def===void 0)continue;let u=PV(c);u&&r&&(c._def.typeName==="ZodOptional"&&(c=c._def.innerType),c.isNullable()||(c=c.nullable()),u=!1);let l=le(c._def,{...t,currentPath:[...t.currentPath,"properties",s],propertyPath:[...t.currentPath,"properties",s]});l!==void 0&&(n.properties[s]=l,u||i.push(s))}i.length&&(n.required=i);let a=OV(e,t);return a!==void 0&&(n.additionalProperties=a),n}function OV(e,t){if(e.catchall._def.typeName!=="ZodNever")return le(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 PV(e){try{return e.isOptional()}catch{return!0}}var ZP=(e,t)=>{if(t.currentPath.toString()===t.propertyPath?.toString())return le(e.innerType._def,t);let r=le(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return r?{anyOf:[{not:st(t)},r]}:st(t)};var GP=(e,t)=>{if(t.pipeStrategy==="input")return le(e.in._def,t);if(t.pipeStrategy==="output")return le(e.out._def,t);let r=le(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]});return{allOf:[r,le(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",r?"1":"0"]})].filter(n=>n!==void 0)}};function WP(e,t){return le(e.type._def,t)}function qP(e,t){let r={type:"array",uniqueItems:!0,items:le(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&De(r,"minItems",e.minSize.value,e.minSize.message,t),e.maxSize&&De(r,"maxItems",e.maxSize.value,e.maxSize.message,t),r}function KP(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((r,n)=>le(r._def,{...t,currentPath:[...t.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[]),additionalItems:le(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((r,n)=>le(r._def,{...t,currentPath:[...t.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[])}}function JP(e){return{not:st(e)}}function XP(e){return st(e)}var YP=(e,t)=>le(e.innerType._def,t);var QP=(e,t,r)=>{switch(t){case U.ZodString:return Hm(e,r);case U.ZodNumber:return VP(e,r);case U.ZodObject:return HP(e,r);case U.ZodBigInt:return $P(e,r);case U.ZodBoolean:return TP();case U.ZodDate:return Qx(e,r);case U.ZodUndefined:return JP(r);case U.ZodNull:return UP(r);case U.ZodArray:return IP(e,r);case U.ZodUnion:case U.ZodDiscriminatedUnion:return FP(e,r);case U.ZodIntersection:return NP(e,r);case U.ZodTuple:return KP(e,r);case U.ZodRecord:return Zm(e,r);case U.ZodLiteral:return RP(e,r);case U.ZodEnum:return PP(e);case U.ZodNativeEnum:return DP(e);case U.ZodNullable:return BP(e,r);case U.ZodOptional:return ZP(e,r);case U.ZodMap:return MP(e,r);case U.ZodSet:return qP(e,r);case U.ZodLazy:return()=>e.getter()._def;case U.ZodPromise:return WP(e,r);case U.ZodNaN:case U.ZodNever:return zP(r);case U.ZodEffects:return OP(e,r);case U.ZodAny:return st(r);case U.ZodUnknown:return XP(r);case U.ZodDefault:return CP(e,r);case U.ZodBranded:return Vm(e,r);case U.ZodReadonly:return YP(e,r);case U.ZodCatch:return AP(e,r);case U.ZodPipeline:return GP(e,r);case U.ZodFunction:case U.ZodVoid:case U.ZodSymbol:return;default:return(n=>{})(t)}};function le(e,t,r=!1){let n=t.seen.get(e);if(t.override){let s=t.override?.(e,t,n,r);if(s!==fP)return s}if(n&&!r){let s=NV(n,t);if(s!==void 0)return s}let i={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,i);let o=QP(e,e.typeName,t),a=typeof o=="function"?le(o(),t):o;if(a&&RV(e,t,a),t.postProcess){let s=t.postProcess(a,e,t);return i.jsonSchema=a,s}return i.jsonSchema=a,a}var NV=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:Dm(t.currentPath,e.path)};case"none":case"seen":return e.path.length<t.currentPath.length&&e.path.every((r,n)=>t.currentPath[n]===r)?(console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),st(t)):t.$refStrategy==="seen"?st(t):void 0}},RV=(e,t,r)=>(e.description&&(r.description=e.description,t.markdownDescription&&(r.markdownDescription=e.description)),r);var eN=(e,t)=>{let r=mP(t),n=typeof t=="object"&&t.definitions?Object.entries(t.definitions).reduce((c,[u,l])=>({...c,[u]:le(l._def,{...r,currentPath:[...r.basePath,r.definitionPath,u]},!0)??st(r)}),{}):void 0,i=typeof t=="string"?t:t?.nameStrategy==="title"?void 0:t?.name,o=le(e._def,i===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,i]},!1)??st(r),a=typeof t=="object"&&t.name!==void 0&&t.nameStrategy==="title"?t.name:void 0;a!==void 0&&(o.title=a),r.flags.hasReferencedOpenAiAnyType&&(n||(n={}),n[r.openAiAnyTypeName]||(n[r.openAiAnyTypeName]={type:["string","number","integer","boolean","array","null"],items:{$ref:r.$refStrategy==="relative"?"1":[...r.basePath,r.definitionPath,r.openAiAnyTypeName].join("/")}}));let s=i===void 0?n?{...o,[r.definitionPath]:n}:o:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,i].join("/"),[r.definitionPath]:{...n,[i]:o}};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 li(e,t){let r=typeof e;if(r!==typeof t)return!1;if(Array.isArray(e)){if(!Array.isArray(t))return!1;let n=e.length;if(n!==t.length)return!1;for(let i=0;i<n;i++)if(!li(e[i],t[i]))return!1;return!0}if(r==="object"){if(!e||!t)return e===t;let n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return!1;for(let a of n)if(!li(e[a],t[a]))return!1;return!0}return e===t}function Kr(e){return encodeURI(jV(e))}function jV(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}var MV={prefixItems:!0,items:!0,allOf:!0,anyOf:!0,oneOf:!0},DV={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependentSchemas:!0},zV={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},UV=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 Tn(e,t=Object.create(null),r=UV,n=""){if(e&&typeof e=="object"&&!Array.isArray(e)){let o=e.$id||e.id;if(o){let a=new URL(o,r.href);a.hash.length>1?t[a.href]=e:(a.hash="",n===""?r=a:Tn(e,t,r))}}else if(e!==!0&&e!==!1)return t;let i=r.href+(n?"#"+n:"");if(t[i]!==void 0)throw new Error(`Duplicate schema URI "${i}".`);if(t[i]=e,e===!0||e===!1)return t;if(e.__absolute_uri__===void 0&&Object.defineProperty(e,"__absolute_uri__",{enumerable:!1,value:i}),e.$ref&&e.__absolute_ref__===void 0){let o=new URL(e.$ref,r.href);o.hash=o.hash,Object.defineProperty(e,"__absolute_ref__",{enumerable:!1,value:o.href})}if(e.$recursiveRef&&e.__absolute_recursive_ref__===void 0){let o=new URL(e.$recursiveRef,r.href);o.hash=o.hash,Object.defineProperty(e,"__absolute_recursive_ref__",{enumerable:!1,value:o.href})}if(e.$anchor){let o=new URL("#"+e.$anchor,r.href);t[o.href]=e}for(let o in e){if(zV[o])continue;let a=`${n}/${Kr(o)}`,s=e[o];if(Array.isArray(s)){if(MV[o]){let c=s.length;for(let u=0;u<c;u++)Tn(s[u],t,r,`${a}/${u}`)}}else if(DV[o])for(let c in s)Tn(s[c],t,r,`${a}/${Kr(c)}`);else Tn(s,t,r,a)}return t}var LV=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,FV=[0,31,28,31,30,31,30,31,31,30,31,30,31],BV=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i,VV=/^(?=.{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,HV=/^(?:[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,ZV=/^(?:(?:[^\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,GV=/^(?:(?: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,WV=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,qV=/^(?:\/(?:[^~/]|~0|~1)*)*$/,KV=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,JV=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,XV=e=>{if(e[0]==='"')return!1;let[t,r,...n]=e.split("@");return!t||!r||n.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(i=>/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i.test(i))},YV=/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,QV=/^((([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,e9=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 di(e){return e.test.bind(e)}var r0={date:tN,time:rN.bind(void 0,!1),"date-time":n9,duration:e9,uri:a9,"uri-reference":di(HV),"uri-template":di(ZV),url:di(GV),email:XV,hostname:di(VV),ipv4:di(YV),ipv6:di(QV),regex:c9,uuid:di(WV),"json-pointer":di(qV),"json-pointer-uri-fragment":di(KV),"relative-json-pointer":di(JV)};function t9(e){return e%4===0&&(e%100!==0||e%400===0)}function tN(e){let t=e.match(LV);if(!t)return!1;let r=+t[1],n=+t[2],i=+t[3];return n>=1&&n<=12&&i>=1&&i<=(n==2&&t9(r)?29:FV[n])}function rN(e,t){let r=t.match(BV);if(!r)return!1;let n=+r[1],i=+r[2],o=+r[3],a=!!r[5];return(n<=23&&i<=59&&o<=59||n==23&&i==59&&o==60)&&(!e||a)}var r9=/t|\s/i;function n9(e){let t=e.split(r9);return t.length==2&&tN(t[0])&&rN(!0,t[1])}var i9=/\/|:/,o9=/^(?:[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 a9(e){return i9.test(e)&&o9.test(e)}var s9=/[^\\]\\Z/;function c9(e){if(s9.test(e))return!1;try{return new RegExp(e,"u"),!0}catch{return!1}}var nN;(function(e){e[e.Flag=1]="Flag",e[e.Basic=2]="Basic",e[e.Detailed=4]="Detailed"})(nN||(nN={}));function iN(e){let t=0,r=e.length,n=0,i;for(;n<r;)t++,i=e.charCodeAt(n++),i>=55296&&i<=56319&&n<r&&(i=e.charCodeAt(n),(i&64512)==56320&&n++);return t}function Xe(e,t,r="2019-09",n=Tn(t),i=!0,o=null,a="#",s="#",c=Object.create(null)){if(t===!0)return{valid:!0,errors:[]};if(t===!1)return{valid:!1,errors:[{instanceLocation:a,keyword:"false",keywordLocation:a,error:"False boolean schema."}]};let u=typeof e,l;switch(u){case"boolean":case"number":case"string":l=u;break;case"object":e===null?l="null":Array.isArray(e)?l="array":l="object";break;default:throw new Error(`Instances of "${u}" type are not supported.`)}let{$ref:d,$recursiveRef:f,$recursiveAnchor:p,type:m,const:h,enum:_,required:y,not:w,anyOf:x,allOf:S,oneOf:E,if:C,then:T,else:b,format:L,properties:N,patternProperties:W,additionalProperties:ie,unevaluatedProperties:_e,minProperties:$e,maxProperties:ct,propertyNames:be,dependentRequired:V,dependentSchemas:Y,dependencies:oe,prefixItems:ae,items:Oe,additionalItems:zr,unevaluatedItems:no,contains:io,minContains:gn,maxContains:v,minItems:g,maxItems:P,uniqueItems:I,minimum:Pe,maximum:Be,exclusiveMinimum:kt,exclusiveMaximum:gt,multipleOf:Wt,minLength:Yr,maxLength:_t,pattern:Ln,__absolute_ref__:Ms,__absolute_recursive_ref__:Bd}=t,K=[];if(p===!0&&o===null&&(o=t),f==="#"){let fe=o===null?n[Bd]:o,se=`${s}/$recursiveRef`,ge=Xe(e,o===null?t:o,r,n,i,fe,a,se,c);ge.valid||K.push({instanceLocation:a,keyword:"$recursiveRef",keywordLocation:se,error:"A subschema had errors."},...ge.errors)}if(d!==void 0){let se=n[Ms||d];if(se===void 0){let q=`Unresolved $ref "${d}".`;throw Ms&&Ms!==d&&(q+=` Absolute URI "${Ms}".`),q+=`
231
- Known schemas:
232
- - ${Object.keys(n).join(`
233
- - `)}`,new Error(q)}let ge=`${s}/$ref`,Q=Xe(e,se,r,n,i,o,a,ge,c);if(Q.valid||K.push({instanceLocation:a,keyword:"$ref",keywordLocation:ge,error:"A subschema had errors."},...Q.errors),r==="4"||r==="7")return{valid:K.length===0,errors:K}}if(Array.isArray(m)){let fe=m.length,se=!1;for(let ge=0;ge<fe;ge++)if(l===m[ge]||m[ge]==="integer"&&l==="number"&&e%1===0&&e===e){se=!0;break}se||K.push({instanceLocation:a,keyword:"type",keywordLocation:`${s}/type`,error:`Instance type "${l}" is invalid. Expected "${m.join('", "')}".`})}else m==="integer"?(l!=="number"||e%1||e!==e)&&K.push({instanceLocation:a,keyword:"type",keywordLocation:`${s}/type`,error:`Instance type "${l}" is invalid. Expected "${m}".`}):m!==void 0&&l!==m&&K.push({instanceLocation:a,keyword:"type",keywordLocation:`${s}/type`,error:`Instance type "${l}" is invalid. Expected "${m}".`});if(h!==void 0&&(l==="object"||l==="array"?li(e,h)||K.push({instanceLocation:a,keyword:"const",keywordLocation:`${s}/const`,error:`Instance does not match ${JSON.stringify(h)}.`}):e!==h&&K.push({instanceLocation:a,keyword:"const",keywordLocation:`${s}/const`,error:`Instance does not match ${JSON.stringify(h)}.`})),_!==void 0&&(l==="object"||l==="array"?_.some(fe=>li(e,fe))||K.push({instanceLocation:a,keyword:"enum",keywordLocation:`${s}/enum`,error:`Instance does not match any of ${JSON.stringify(_)}.`}):_.some(fe=>e===fe)||K.push({instanceLocation:a,keyword:"enum",keywordLocation:`${s}/enum`,error:`Instance does not match any of ${JSON.stringify(_)}.`})),w!==void 0){let fe=`${s}/not`;Xe(e,w,r,n,i,o,a,fe).valid&&K.push({instanceLocation:a,keyword:"not",keywordLocation:fe,error:'Instance matched "not" schema.'})}let ua=[];if(x!==void 0){let fe=`${s}/anyOf`,se=K.length,ge=!1;for(let Q=0;Q<x.length;Q++){let q=x[Q],me=Object.create(c),pe=Xe(e,q,r,n,i,p===!0?o:null,a,`${fe}/${Q}`,me);K.push(...pe.errors),ge=ge||pe.valid,pe.valid&&ua.push(me)}ge?K.length=se:K.splice(se,0,{instanceLocation:a,keyword:"anyOf",keywordLocation:fe,error:"Instance does not match any subschemas."})}if(S!==void 0){let fe=`${s}/allOf`,se=K.length,ge=!0;for(let Q=0;Q<S.length;Q++){let q=S[Q],me=Object.create(c),pe=Xe(e,q,r,n,i,p===!0?o:null,a,`${fe}/${Q}`,me);K.push(...pe.errors),ge=ge&&pe.valid,pe.valid&&ua.push(me)}ge?K.length=se:K.splice(se,0,{instanceLocation:a,keyword:"allOf",keywordLocation:fe,error:"Instance does not match every subschema."})}if(E!==void 0){let fe=`${s}/oneOf`,se=K.length,ge=E.filter((Q,q)=>{let me=Object.create(c),pe=Xe(e,Q,r,n,i,p===!0?o:null,a,`${fe}/${q}`,me);return K.push(...pe.errors),pe.valid&&ua.push(me),pe.valid}).length;ge===1?K.length=se:K.splice(se,0,{instanceLocation:a,keyword:"oneOf",keywordLocation:fe,error:`Instance does not match exactly one subschema (${ge} matches).`})}if((l==="object"||l==="array")&&Object.assign(c,...ua),C!==void 0){let fe=`${s}/if`;if(Xe(e,C,r,n,i,o,a,fe,c).valid){if(T!==void 0){let ge=Xe(e,T,r,n,i,o,a,`${s}/then`,c);ge.valid||K.push({instanceLocation:a,keyword:"if",keywordLocation:fe,error:'Instance does not match "then" schema.'},...ge.errors)}}else if(b!==void 0){let ge=Xe(e,b,r,n,i,o,a,`${s}/else`,c);ge.valid||K.push({instanceLocation:a,keyword:"if",keywordLocation:fe,error:'Instance does not match "else" schema.'},...ge.errors)}}if(l==="object"){if(y!==void 0)for(let Q of y)Q in e||K.push({instanceLocation:a,keyword:"required",keywordLocation:`${s}/required`,error:`Instance does not have required property "${Q}".`});let fe=Object.keys(e);if($e!==void 0&&fe.length<$e&&K.push({instanceLocation:a,keyword:"minProperties",keywordLocation:`${s}/minProperties`,error:`Instance does not have at least ${$e} properties.`}),ct!==void 0&&fe.length>ct&&K.push({instanceLocation:a,keyword:"maxProperties",keywordLocation:`${s}/maxProperties`,error:`Instance does not have at least ${ct} properties.`}),be!==void 0){let Q=`${s}/propertyNames`;for(let q in e){let me=`${a}/${Kr(q)}`,pe=Xe(q,be,r,n,i,o,me,Q);pe.valid||K.push({instanceLocation:a,keyword:"propertyNames",keywordLocation:Q,error:`Property name "${q}" does not match schema.`},...pe.errors)}}if(V!==void 0){let Q=`${s}/dependantRequired`;for(let q in V)if(q in e){let me=V[q];for(let pe of me)pe in e||K.push({instanceLocation:a,keyword:"dependentRequired",keywordLocation:Q,error:`Instance has "${q}" but does not have "${pe}".`})}}if(Y!==void 0)for(let Q in Y){let q=`${s}/dependentSchemas`;if(Q in e){let me=Xe(e,Y[Q],r,n,i,o,a,`${q}/${Kr(Q)}`,c);me.valid||K.push({instanceLocation:a,keyword:"dependentSchemas",keywordLocation:q,error:`Instance has "${Q}" but does not match dependant schema.`},...me.errors)}}if(oe!==void 0){let Q=`${s}/dependencies`;for(let q in oe)if(q in e){let me=oe[q];if(Array.isArray(me))for(let pe of me)pe in e||K.push({instanceLocation:a,keyword:"dependencies",keywordLocation:Q,error:`Instance has "${q}" but does not have "${pe}".`});else{let pe=Xe(e,me,r,n,i,o,a,`${Q}/${Kr(q)}`);pe.valid||K.push({instanceLocation:a,keyword:"dependencies",keywordLocation:Q,error:`Instance has "${q}" but does not match dependant schema.`},...pe.errors)}}}let se=Object.create(null),ge=!1;if(N!==void 0){let Q=`${s}/properties`;for(let q in N){if(!(q in e))continue;let me=`${a}/${Kr(q)}`,pe=Xe(e[q],N[q],r,n,i,o,me,`${Q}/${Kr(q)}`);if(pe.valid)c[q]=se[q]=!0;else if(ge=i,K.push({instanceLocation:a,keyword:"properties",keywordLocation:Q,error:`Property "${q}" does not match schema.`},...pe.errors),ge)break}}if(!ge&&W!==void 0){let Q=`${s}/patternProperties`;for(let q in W){let me=new RegExp(q,"u"),pe=W[q];for(let Er in e){if(!me.test(Er))continue;let vE=`${a}/${Kr(Er)}`,bE=Xe(e[Er],pe,r,n,i,o,vE,`${Q}/${Kr(q)}`);bE.valid?c[Er]=se[Er]=!0:(ge=i,K.push({instanceLocation:a,keyword:"patternProperties",keywordLocation:Q,error:`Property "${Er}" matches pattern "${q}" but does not match associated schema.`},...bE.errors))}}}if(!ge&&ie!==void 0){let Q=`${s}/additionalProperties`;for(let q in e){if(se[q])continue;let me=`${a}/${Kr(q)}`,pe=Xe(e[q],ie,r,n,i,o,me,Q);pe.valid?c[q]=!0:(ge=i,K.push({instanceLocation:a,keyword:"additionalProperties",keywordLocation:Q,error:`Property "${q}" does not match additional properties schema.`},...pe.errors))}}else if(!ge&&_e!==void 0){let Q=`${s}/unevaluatedProperties`;for(let q in e)if(!c[q]){let me=`${a}/${Kr(q)}`,pe=Xe(e[q],_e,r,n,i,o,me,Q);pe.valid?c[q]=!0:K.push({instanceLocation:a,keyword:"unevaluatedProperties",keywordLocation:Q,error:`Property "${q}" does not match unevaluated properties schema.`},...pe.errors)}}}else if(l==="array"){P!==void 0&&e.length>P&&K.push({instanceLocation:a,keyword:"maxItems",keywordLocation:`${s}/maxItems`,error:`Array has too many items (${e.length} > ${P}).`}),g!==void 0&&e.length<g&&K.push({instanceLocation:a,keyword:"minItems",keywordLocation:`${s}/minItems`,error:`Array has too few items (${e.length} < ${g}).`});let fe=e.length,se=0,ge=!1;if(ae!==void 0){let Q=`${s}/prefixItems`,q=Math.min(ae.length,fe);for(;se<q;se++){let me=Xe(e[se],ae[se],r,n,i,o,`${a}/${se}`,`${Q}/${se}`);if(c[se]=!0,!me.valid&&(ge=i,K.push({instanceLocation:a,keyword:"prefixItems",keywordLocation:Q,error:"Items did not match schema."},...me.errors),ge))break}}if(Oe!==void 0){let Q=`${s}/items`;if(Array.isArray(Oe)){let q=Math.min(Oe.length,fe);for(;se<q;se++){let me=Xe(e[se],Oe[se],r,n,i,o,`${a}/${se}`,`${Q}/${se}`);if(c[se]=!0,!me.valid&&(ge=i,K.push({instanceLocation:a,keyword:"items",keywordLocation:Q,error:"Items did not match schema."},...me.errors),ge))break}}else for(;se<fe;se++){let q=Xe(e[se],Oe,r,n,i,o,`${a}/${se}`,Q);if(c[se]=!0,!q.valid&&(ge=i,K.push({instanceLocation:a,keyword:"items",keywordLocation:Q,error:"Items did not match schema."},...q.errors),ge))break}if(!ge&&zr!==void 0){let q=`${s}/additionalItems`;for(;se<fe;se++){let me=Xe(e[se],zr,r,n,i,o,`${a}/${se}`,q);c[se]=!0,me.valid||(ge=i,K.push({instanceLocation:a,keyword:"additionalItems",keywordLocation:q,error:"Items did not match additional items schema."},...me.errors))}}}if(io!==void 0)if(fe===0&&gn===void 0)K.push({instanceLocation:a,keyword:"contains",keywordLocation:`${s}/contains`,error:"Array is empty. It must contain at least one item matching the schema."});else if(gn!==void 0&&fe<gn)K.push({instanceLocation:a,keyword:"minContains",keywordLocation:`${s}/minContains`,error:`Array has less items (${fe}) than minContains (${gn}).`});else{let Q=`${s}/contains`,q=K.length,me=0;for(let pe=0;pe<fe;pe++){let Er=Xe(e[pe],io,r,n,i,o,`${a}/${pe}`,Q);Er.valid?(c[pe]=!0,me++):K.push(...Er.errors)}me>=(gn||0)&&(K.length=q),gn===void 0&&v===void 0&&me===0?K.splice(q,0,{instanceLocation:a,keyword:"contains",keywordLocation:Q,error:"Array does not contain item matching schema."}):gn!==void 0&&me<gn?K.push({instanceLocation:a,keyword:"minContains",keywordLocation:`${s}/minContains`,error:`Array must contain at least ${gn} items matching schema. Only ${me} items were found.`}):v!==void 0&&me>v&&K.push({instanceLocation:a,keyword:"maxContains",keywordLocation:`${s}/maxContains`,error:`Array may contain at most ${v} items matching schema. ${me} items were found.`})}if(!ge&&no!==void 0){let Q=`${s}/unevaluatedItems`;for(se;se<fe;se++){if(c[se])continue;let q=Xe(e[se],no,r,n,i,o,`${a}/${se}`,Q);c[se]=!0,q.valid||K.push({instanceLocation:a,keyword:"unevaluatedItems",keywordLocation:Q,error:"Items did not match unevaluated items schema."},...q.errors)}}if(I)for(let Q=0;Q<fe;Q++){let q=e[Q],me=typeof q=="object"&&q!==null;for(let pe=0;pe<fe;pe++){if(Q===pe)continue;let Er=e[pe];(q===Er||me&&(typeof Er=="object"&&Er!==null)&&li(q,Er))&&(K.push({instanceLocation:a,keyword:"uniqueItems",keywordLocation:`${s}/uniqueItems`,error:`Duplicate items at indexes ${Q} and ${pe}.`}),Q=Number.MAX_SAFE_INTEGER,pe=Number.MAX_SAFE_INTEGER)}}}else if(l==="number"){if(r==="4"?(Pe!==void 0&&(kt===!0&&e<=Pe||e<Pe)&&K.push({instanceLocation:a,keyword:"minimum",keywordLocation:`${s}/minimum`,error:`${e} is less than ${kt?"or equal to ":""} ${Pe}.`}),Be!==void 0&&(gt===!0&&e>=Be||e>Be)&&K.push({instanceLocation:a,keyword:"maximum",keywordLocation:`${s}/maximum`,error:`${e} is greater than ${gt?"or equal to ":""} ${Be}.`})):(Pe!==void 0&&e<Pe&&K.push({instanceLocation:a,keyword:"minimum",keywordLocation:`${s}/minimum`,error:`${e} is less than ${Pe}.`}),Be!==void 0&&e>Be&&K.push({instanceLocation:a,keyword:"maximum",keywordLocation:`${s}/maximum`,error:`${e} is greater than ${Be}.`}),kt!==void 0&&e<=kt&&K.push({instanceLocation:a,keyword:"exclusiveMinimum",keywordLocation:`${s}/exclusiveMinimum`,error:`${e} is less than ${kt}.`}),gt!==void 0&&e>=gt&&K.push({instanceLocation:a,keyword:"exclusiveMaximum",keywordLocation:`${s}/exclusiveMaximum`,error:`${e} is greater than or equal to ${gt}.`})),Wt!==void 0){let fe=e%Wt;Math.abs(0-fe)>=11920929e-14&&Math.abs(Wt-fe)>=11920929e-14&&K.push({instanceLocation:a,keyword:"multipleOf",keywordLocation:`${s}/multipleOf`,error:`${e} is not a multiple of ${Wt}.`})}}else if(l==="string"){let fe=Yr===void 0&&_t===void 0?0:iN(e);Yr!==void 0&&fe<Yr&&K.push({instanceLocation:a,keyword:"minLength",keywordLocation:`${s}/minLength`,error:`String is too short (${fe} < ${Yr}).`}),_t!==void 0&&fe>_t&&K.push({instanceLocation:a,keyword:"maxLength",keywordLocation:`${s}/maxLength`,error:`String is too long (${fe} > ${_t}).`}),Ln!==void 0&&!new RegExp(Ln,"u").test(e)&&K.push({instanceLocation:a,keyword:"pattern",keywordLocation:`${s}/pattern`,error:"String does not match pattern."}),L!==void 0&&r0[L]&&!r0[L](e)&&K.push({instanceLocation:a,keyword:"format",keywordLocation:`${s}/format`,error:`String does not match format "${L}".`})}return{valid:K.length===0,errors:K}}var Gm=class{schema;draft;shortCircuit;lookup;constructor(t,r="2019-09",n=!0){this.schema=t,this.draft=r,this.shortCircuit=n,this.lookup=Tn(t)}validate(t){return Xe(t,this.schema,this.draft,this.lookup,this.shortCircuit)}addSchema(t,r){r&&(t={...t,$id:r}),Tn(t,this.lookup)}};var aN=A({Validator:()=>Gm,deepCompareStrict:()=>li,toJsonSchema:()=>Ot,validatesOnlyStrings:()=>Yc}),oN=new WeakMap;function Ot(e,t){let r=!t&&e!=null&&typeof e=="object";if(r){let i=oN.get(e);if(i)return i}let n;if(Tp(e)&&!Je(e))n=e["~standard"].jsonSchema.input({target:"draft-07"});else if(Je(e)){let i=jm(e,!0);an(i)?n=as(Bc(i,!0),t):n=as(e,t)}else mt(e)?n=eN(e):n=e;return r&&n!=null&&typeof n=="object"&&oN.set(e,n),n}function Yc(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=>Yc(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=>Yc(r))}if("not"in e)return!1;if("$ref"in e&&typeof e.$ref=="string"){let t=e.$ref,r=Tn(e);return r[t]?Yc(r[t]):!1}return!1}function Ul(e){return e?e.lc_runnable:!1}var sN=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,n=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||n.some(i=>this.includeTags?.includes(i))),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&&n.every(i=>!this.excludeTags?.includes(i))),r}},cN=e=>btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");function n0(e){return e.replace(/[^a-zA-Z-_0-9]/g,"_")}var u9=["*","_","`"];function l9(e){let t="";for(let[r,n]of Object.entries(e))t+=` classDef ${r} ${n};
234
- `;return t}function uN(e,t,r){let{firstNode:n,lastNode:i,nodeColors:o,withStyles:a=!0,curveStyle:s="linear",wrapLabelNWords:c=9}=r??{},u=a?`%%{init: {'flowchart': {'curve': '${s}'}}}%%
235
- graph TD;
236
- `:`graph TD;
237
- `;if(a){let m="default",h={[m]:"{0}({1})"};n!==void 0&&(h[n]="{0}([{1}]):::first"),i!==void 0&&(h[i]="{0}([{1}]):::last");for(let[_,y]of Object.entries(e)){let w=y.name.split(":").pop()??"",x=u9.some(E=>w.startsWith(E)&&w.endsWith(E))?`<p>${w}</p>`:w;Object.keys(y.metadata??{}).length&&(x+=`<hr/><small><em>${Object.entries(y.metadata??{}).map(([E,C])=>`${E} = ${C}`).join(`
238
- `)}</em></small>`);let S=(h[_]??h[m]).replace("{0}",n0(_)).replace("{1}",x);u+=` ${S}
239
- `}}let l={};for(let m of t){let h=m.source.split(":"),_=m.target.split(":"),y=h.filter((w,x)=>w===_[x]).join(":");l[y]||(l[y]=[]),l[y].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),u+=` subgraph ${w}
240
- `}let y=f(Object.keys(l).filter(w=>w.startsWith(`${h}:`)&&w!==h&&w.split(":").length===h.split(":").length+1));for(let w of y)p(l[w],w);for(let w of m){let{source:x,target:S,data:E,conditional:C}=w,T="";if(E!==void 0){let b=E,L=b.split(" ");L.length>c&&(b=Array.from({length:Math.ceil(L.length/c)},(N,W)=>L.slice(W*c,(W+1)*c).join(" ")).join("&nbsp;<br>&nbsp;")),T=C?` -. &nbsp;${b}&nbsp; .-> `:` -- &nbsp;${b}&nbsp; --> `}else T=C?" -.-> ":" --> ";u+=` ${n0(x)}${T}${n0(S)};
241
- `}h&&!_&&(u+=` end
242
- `)}p(l[""]??[],"");for(let m in l)!m.includes(":")&&m!==""&&p(l[m],m);return a&&(u+=l9(o??{})),u}async function lN(e,t){let r=t?.backgroundColor??"white",n=t?.imageType??"png",i=cN(e);r!==void 0&&(/^#(?:[0-9a-fA-F]{3}){1,2}$/.test(r)||(r=`!${r}`));let o=`https://mermaid.ink/img/${i}?bgColor=${r}&type=${n}`,a=await fetch(o);if(!a.ok)throw new Error(["Failed to render the graph using the Mermaid.INK API.",`Status code: ${a.status}`,`Status text: ${a.statusText}`].join(`
243
- `));return await a.blob()}var pN=A({Graph:()=>ks});function d9(e,t){if(e!==void 0&&!Ei(e))return e;if(Ul(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 f9(e){return Ul(e.data)?{type:"runnable",data:{id:e.data.lc_id,name:e.data.getName()}}:{type:"schema",data:{...Ot(e.data.schema),title:e.data.name}}}var ks=class mN{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,n)=>{t[r.id]=Ei(r.id)?n:r.id}),{nodes:Object.values(this.nodes).map(r=>({id:t[r.id],...f9(r)})),edges:this.edges.map(r=>{let n={source:t[r.source],target:t[r.target]};return typeof r.data<"u"&&(n.data=r.data),typeof r.conditional<"u"&&(n.conditional=r.conditional),n})}}addNode(t,r,n){if(r!==void 0&&this.nodes[r]!==void 0)throw new Error(`Node with id ${r} already exists`);let i=r??ho(),o={id:i,data:t,name:d9(r,t),metadata:n};return this.nodes[i]=o,o}removeNode(t){delete this.nodes[t.id],this.edges=this.edges.filter(r=>r.source!==t.id&&r.target!==t.id)}addEdge(t,r,n,i){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 o={source:t.id,target:r.id,data:n,conditional:i};return this.edges.push(o),o}firstNode(){return dN(this)}lastNode(){return fN(this)}extend(t,r=""){let n=r;Object.values(t.nodes).map(c=>c.id).every(Ei)&&(n="");let i=c=>n?`${n}:${c}`:c;Object.entries(t.nodes).forEach(([c,u])=>{this.nodes[i(c)]={...u,id:i(c)}});let o=t.edges.map(c=>({...c,source:i(c.source),target:i(c.target)}));this.edges=[...this.edges,...o];let a=t.firstNode(),s=t.lastNode();return[a?{id:i(a.id),data:a.data}:void 0,s?{id:i(s.id),data:s.data}:void 0]}trimFirstNode(){let t=this.firstNode();t&&dN(this,[t.id])&&this.removeNode(t)}trimLastNode(){let t=this.lastNode();t&&fN(this,[t.id])&&this.removeNode(t)}reid(){let t=Object.fromEntries(Object.values(this.nodes).map(i=>[i.id,i.name])),r=new Map;Object.values(t).forEach(i=>{r.set(i,(r.get(i)||0)+1)});let n=i=>{let o=t[i];return Ei(i)&&r.get(o)===1?o:i};return new mN({nodes:Object.fromEntries(Object.entries(this.nodes).map(([i,o])=>[n(i),{...o,id:n(i)}])),edges:this.edges.map(i=>({...i,source:n(i.source),target:n(i.target)}))})}drawMermaid(t){let{withStyles:r,curveStyle:n,nodeColors:i={default:"fill:#f2f0ff,line-height:1.2",first:"fill-opacity:0",last:"fill:#bfb6fc"},wrapLabelNWords:o}=t??{},a=this.reid(),s=a.firstNode(),c=a.lastNode();return uN(a.nodes,a.edges,{firstNode:s?.id,lastNode:c?.id,withStyles:r,curveStyle:n,nodeColors:i,wrapLabelNWords:o})}async drawMermaidPng(t){return lN(this.drawMermaid(t),{backgroundColor:t?.backgroundColor})}};function dN(e,t=[]){let r=new Set(e.edges.filter(i=>!t.includes(i.source)).map(i=>i.target)),n=[];for(let i of Object.values(e.nodes))!t.includes(i.id)&&!r.has(i.id)&&n.push(i);return n.length===1?n[0]:void 0}function fN(e,t=[]){let r=new Set(e.edges.filter(i=>!t.includes(i.target)).map(i=>i.source)),n=[];for(let i of Object.values(e.nodes))!t.includes(i.id)&&!r.has(i.id)&&n.push(i);return n.length===1?n[0]:void 0}function Wm({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 hN=e=>e.name==="event_stream_tracer",gN=class extends Ht{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=bt.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(n=>this.includeTags?.includes(n))!==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(n=>!this.excludeTags?.includes(n))),r}async*tapOutputIterable(e,t){let r=await t.next();if(r.done)return;let n=this.runInfoMap.get(e);if(n===void 0){yield r.value;return}function i(a,s){return a==="llm"&&typeof s=="string"?new Ri({text:s}):s}let o=this.tappedPromises.get(e);if(o===void 0){let a;o=new Promise(s=>{a=s}),this.tappedPromises.set(e,o);try{let s={event:`on_${n.runType}_stream`,run_id:e,name:n.name,tags:n.tags,metadata:n.metadata,data:{}};await this.send({...s,data:{chunk:i(n.runType,r.value)}},n),yield r.value;for await(let c of t)n.runType!=="tool"&&n.runType!=="retriever"&&await this.send({...s,data:{chunk:i(n.runType,c)}},n),yield c}finally{a?.()}}else{yield r.value;for await(let a of t)yield a}}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=Wm(e),r=e.inputs.messages!==void 0?"chat_model":"llm",n={tags:e.tags??[],metadata:e.extra?.metadata??{},name:t,runType:r,inputs:e.inputs};this.runInfoMap.set(e.id,n);let i=`on_${r}_start`;await this.send({event:i,data:{input:e.inputs},name:t,tags:e.tags??[],run_id:e.id,metadata:e.extra?.metadata??{}},n)}async onLLMNewToken(e,t,r){let n=this.runInfoMap.get(e.id),i,o;if(n===void 0)throw new Error(`onLLMNewToken: Run ID ${e.id} not found in run map.`);if(this.runInfoMap.size!==1){if(n.runType==="chat_model")o="on_chat_model_stream",r?.chunk===void 0?i=new ut({content:t,id:`run-${e.id}`}):i=r.chunk.message;else if(n.runType==="llm")o="on_llm_stream",r?.chunk===void 0?i=new Ri({text:t}):i=r.chunk;else throw new Error(`Unexpected run type ${n.runType}`);await this.send({event:o,data:{chunk:i},run_id:e.id,name:n.name,tags:n.tags,metadata:n.metadata},n)}}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 n=e.outputs?.generations,i;if(t.runType==="chat_model"){for(let o of n??[]){if(i!==void 0)break;i=o[0]?.message}r="on_chat_model_end"}else if(t.runType==="llm")i={generations:n?.map(o=>o.map(a=>({text:a.text,generationInfo:a.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:i,input:t.inputs},run_id:e.id,name:t.name,tags:t.tags,metadata:t.metadata},t)}async onChainStart(e){let t=Wm(e),r=e.run_type??"chain",n={tags:e.tags??[],metadata:e.extra?.metadata??{},name:t,runType:e.run_type},i={};e.inputs.input===""&&Object.keys(e.inputs).length===1?(i={},n.inputs={}):e.inputs.input!==void 0?(i.input=e.inputs.input,n.inputs=e.inputs.input):(i.input=e.inputs,n.inputs=e.inputs),this.runInfoMap.set(e.id,n),await this.send({event:`on_${r}_start`,data:i,name:t,tags:e.tags??[],run_id:e.id,metadata:e.extra?.metadata??{}},n)}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`,n=e.inputs??t.inputs??{},i={output:e.outputs?.output??e.outputs,input:n};n.input&&Object.keys(n).length===1&&(i.input=n.input,t.inputs=n.input),await this.sendEndEvent({event:r,data:i,run_id:e.id,name:t.name,tags:t.tags,metadata:t.metadata??{}},t)}async onToolStart(e){let t=Wm(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=Wm(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 n=this.runInfoMap.get(r);if(n===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:n.tags,metadata:n.metadata,data:t},n)}async finish(){let e=[...this.tappedPromises.values()];Promise.all(e).finally(()=>{this.writer.close()})}};var i0=class extends Ht{name="RootListenersTracer";rootId;config;argOnStart;argOnEnd;argOnError;constructor({config:e,onStart:t,onEnd:r,onError:n}){super({_awaitHandler:!0}),this.config=e,this.argOnStart=t,this.argOnEnd=r,this.argOnError=n}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 _N(e){let t=new TextEncoder,r=new ReadableStream({async start(n){for await(let i of e)n.enqueue(t.encode(`event: data
244
- data: ${JSON.stringify(i)}
245
-
246
- `));n.enqueue(t.encode(`event: end
247
-
248
- `)),n.close()}});return bt.fromReadableStream(r)}function o0(e){return typeof e=="object"&&e!==null&&typeof e[Symbol.iterator]=="function"&&typeof e.next=="function"}var yN=e=>e!=null&&typeof e=="object"&&"next"in e&&typeof e.next=="function";function qm(e){return typeof e=="object"&&e!==null&&typeof e[Symbol.asyncIterator]=="function"}function a0(e){return e!=null&&typeof e=="object"&&typeof e.next=="function"}async function vN(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*s0(e,t){for(;;){let{value:r,done:n}=Me.runWithConfig(Ar(e),t.next.bind(t),!0);if(n)break;yield r}}async function*Km(e,t){let r=t[Symbol.asyncIterator]();for(;;){let{value:n,done:i}=await Me.runWithConfig(Ar(e),r.next.bind(t),!0);if(i)break;yield n}}function wt(e,t){return e&&!Array.isArray(e)&&!(e instanceof Date)&&typeof e=="object"?e:{[t]:e}}var ce=class extends yt{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 Xm({bound:this,kwargs:{},config:{},maxAttemptNumber:e?.stopAfterAttempt,...e})}withConfig(e){return new ln({bound:this,config:e,kwargs:{}})}withFallbacks(e){let t=Array.isArray(e)?e:e.fallbacks;return new c0({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(Ee);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(([n])=>n!=="runId"));return Array.from({length:t},(n,i)=>Ee(i===0?e:r))}return Array.from({length:t},()=>Ee(e))}async batch(e,t,r){let n=this._getOptionsList(t??{},e.length),i=new ji({maxConcurrency:n[0]?.maxConcurrency??r?.maxConcurrency,onFailedAttempt:a=>{throw a}}),o=e.map((a,s)=>i.call(async()=>{try{return await this.invoke(a,n[s])}catch(c){if(r?.returnExceptions)return c;throw c}}));return Promise.all(o)}async*_streamIterator(e,t){yield this.invoke(e,t)}async stream(e,t){let r=Ee(t),n=new Co({generator:this._streamIterator(e,r),config:r});return await n.setup,bt.fromAsyncGenerator(n)}_separateRunnableConfigFromCallOptions(e){let t;e===void 0?t=Ee(e):t=Ee({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 n=Ee(r),i=await(await tr(n))?.handleChainStart(this.toJSON(),wt(t,"input"),n.runId,n?.runType,void 0,void 0,n?.runName??this.getName());delete n.runId;let o;try{o=await Hr(e.call(this,t,n,i),n.signal)}catch(a){throw await i?.handleChainError(a),a}return await i?.handleChainEnd(wt(o,"output")),o}async _batchWithConfig(e,t,r,n){let i=this._getOptionsList(r??{},t.length),o=await Promise.all(i.map(tr)),a=await Promise.all(o.map(async(c,u)=>{let l=await c?.handleChainStart(this.toJSON(),wt(t[u],"input"),i[u].runId,i[u].runType,void 0,void 0,i[u].runName??this.getName());return delete i[u].runId,l})),s;try{s=await Hr(e.call(this,t,i,a,n),i?.[0]?.signal)}catch(c){throw await Promise.all(a.map(u=>u?.handleChainError(c))),c}return await Promise.all(a.map(c=>c?.handleChainEnd(wt(s,"output")))),s}_concatOutputChunks(e,t){return Zr(e,t)}async*_transformStreamWithConfig(e,t,r){let n,i=!0,o,a=!0,s=Ee(r),c=await tr(s),u=this;async function*l(){for await(let f of e){if(i)if(n===void 0)n=f;else try{n=u._concatOutputChunks(n,f)}catch{n=void 0,i=!1}yield f}}let d;try{let f=await Yy(t.bind(this),l(),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(hN),m=f.output;p!==void 0&&d!==void 0&&(m=p.tapOutputIterable(d.runId,m));let h=d?.handlers.find(ev);h!==void 0&&d!==void 0&&(m=h.tapOutputIterable(d.runId,m));for await(let _ of m)if(yield _,a)if(o===void 0)o=_;else try{o=this._concatOutputChunks(o,_)}catch{o=void 0,a=!1}}catch(f){throw await d?.handleChainError(f,void 0,void 0,void 0,{inputs:wt(n,"input")}),f}await d?.handleChainEnd(o??{},void 0,void 0,void 0,{inputs:wt(n,"input")})}getGraph(e){let t=new ks,r=t.addNode({name:`${this.getName()}Input`,schema:Ut.any()}),n=t.addNode(this),i=t.addNode({name:`${this.getName()}Output`,schema:Ut.any()});return t.addEdge(r,n),t.addEdge(n,i),t}pipe(e){return new Jr({first:this,last:lt(e)})}pick(e){return this.pipe(new u0(e))}assign(e){return this.pipe(new Fl(new Yo({steps:e})))}async*transform(e,t){let r;for await(let n of e)r===void 0?r=n:r=this._concatOutputChunks(r,n);yield*this._streamIterator(r,Ee(t))}async*streamLog(e,t,r){let n=new Ep({...r,autoClose:!1,_schemaFormat:"original"}),i=Ee(t);yield*this._streamLog(e,n,i)}async*_streamLog(e,t,r){let{callbacks:n}=r;if(n===void 0)r.callbacks=[t];else if(Array.isArray(n))r.callbacks=n.concat([t]);else{let s=n.copy();s.addHandler(t,!0),r.callbacks=s}let i=this.stream(e,r);async function o(){try{let s=await i;for await(let c of s){let u=new ni({ops:[{op:"add",path:"/streamed_output/-",value:c}]});await t.writer.write(u)}}finally{await t.writer.close()}}let a=o();try{for await(let s of t)yield s}finally{await a}}streamEvents(e,t,r){let n;if(t.version==="v1")n=this._streamEventsV1(e,t,r);else if(t.version==="v2")n=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"?_N(n):bt.fromAsyncGenerator(n)}async*_streamEventsV2(e,t,r){let n=new gN({...r,autoClose:!1}),i=Ee(t),o=i.runId??tn();i.runId=o;let a=i.callbacks;if(a===void 0)i.callbacks=[n];else if(Array.isArray(a))i.callbacks=a.concat(n);else{let p=a.copy();p.addHandler(n,!0),i.callbacks=p}let s=new AbortController,c=this;async function u(){let p;try{if(i.signal)if("any"in AbortSignal)p=AbortSignal.any([s.signal,i.signal]);else{let _=new AbortController;i.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,{...i,signal:p}),h=n.tapOutputIterable(o,m);for await(let _ of h)if(s.signal.aborted)break}finally{await n.finish()}}let l=u(),d=!1,f;try{for await(let p of n){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 l}}async*_streamEventsV1(e,t,r){let n,i=!1,o=Ee(t),a=o.tags??[],s=o.metadata??{},c=o.runName??this.getName(),u=new Ep({...r,autoClose:!1,_schemaFormat:"streaming_events"}),l=new sN({...r}),d=this._streamLog(e,u,o);for await(let p of d){if(n?n=n.concat(p):n=kp.fromRunLogPatch(p),n.state===void 0)throw new Error('Internal error: "streamEvents" state is missing. Please open a bug report.');if(!i){i=!0;let y={...n.state},w={run_id:y.id,event:`on_${y.type}_start`,name:c,tags:a,metadata:s,data:{input:e}};l.includeEvent(w,y.type)&&(yield w)}let m=p.ops.filter(y=>y.path.startsWith("/logs/")).map(y=>y.path.split("/")[2]),h=[...new Set(m)];for(let y of h){let w,x={},S=n.state.logs[y];if(S.end_time===void 0?S.streamed_output.length>0?w="stream":w="start":w="end",w==="start")S.inputs!==void 0&&(x.input=S.inputs);else if(w==="end")S.inputs!==void 0&&(x.input=S.inputs),x.output=S.final_output;else if(w==="stream"){let E=S.streamed_output.length;if(E!==1)throw new Error(`Expected exactly one chunk of streamed output, got ${E} instead. Encountered in: "${S.name}"`);x={chunk:S.streamed_output[0]},S.streamed_output=[]}yield{event:`on_${S.type}_${w}`,name:S.name,run_id:S.id,tags:S.tags,metadata:S.metadata,data:x}}let{state:_}=n;if(_.streamed_output.length>0){let y=_.streamed_output.length;if(y!==1)throw new Error(`Expected exactly one chunk of streamed output, got ${y} instead. Encountered in: "${_.name}"`);let w={chunk:_.streamed_output[0]};_.streamed_output=[];let x={event:`on_${_.type}_stream`,run_id:_.id,tags:a,metadata:s,name:c,data:w};l.includeEvent(x,_.type)&&(yield x)}}let f=n?.state;if(f!==void 0){let p={event:`on_${f.type}_end`,name:c,run_id:f.id,tags:a,metadata:s,data:{output:f.final_output}};l.includeEvent(p,f.type)&&(yield p)}}static isRunnable(e){return Ul(e)}withListeners({onStart:e,onEnd:t,onError:r}){return new ln({bound:this,config:{},configFactories:[n=>({callbacks:[new i0({config:n,onStart:e,onEnd:t,onError:r})]})]})}asTool(e){return h9(this,e)}},ln=class bN extends ce{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=Ct(this.config,...t);return Ct(r,...this.configFactories?await Promise.all(this.configFactories.map(async n=>await n(r))):[])}withConfig(t){return new this.constructor({bound:this.bound,kwargs:this.kwargs,config:{...this.config,...t}})}withRetry(t){return new Xm({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,n){let i=Array.isArray(r)?await Promise.all(r.map(async o=>this._mergeConfig(Ee(o),this.kwargs))):await this._mergeConfig(Ee(r),this.kwargs);return this.bound.batch(t,i,n)}_concatOutputChunks(t,r){return this.bound._concatOutputChunks(t,r)}async*_streamIterator(t,r){yield*this.bound._streamIterator(t,await this._mergeConfig(Ee(r),this.kwargs))}async stream(t,r){return this.bound.stream(t,await this._mergeConfig(Ee(r),this.kwargs))}async*transform(t,r){yield*this.bound.transform(t,await this._mergeConfig(Ee(r),this.kwargs))}streamEvents(t,r,n){let i=this,o=async function*(){yield*i.bound.streamEvents(t,{...await i._mergeConfig(Ee(r),i.kwargs),version:r.version},n)};return bt.fromAsyncGenerator(o())}static isRunnableBinding(t){return t.bound&&ce.isRunnable(t.bound)}withListeners({onStart:t,onEnd:r,onError:n}){return new bN({bound:this.bound,kwargs:this.kwargs,config:this.config,configFactories:[i=>({callbacks:[new i0({config:i,onStart:t,onEnd:r,onError:n})]})]})}},wN=class xN extends ce{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,n){return this.bound.batch(t,Ae(r,{callbacks:n?.getChild()}))}withListeners({onStart:t,onEnd:r,onError:n}){return new xN({bound:this.bound.withListeners({onStart:t,onEnd:r,onError:n})})}},Xm=class extends ln{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 n=e>1?`retry:attempt:${e}`:void 0;return Ae(t,{callbacks:r?.getChild(n)})}async _invoke(e,t,r){return ul(n=>super.invoke(e,this._patchConfigForRetry(n,t,r)),{onFailedAttempt:({error:n})=>this.onFailedAttempt(n,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,n){let i={};try{await ul(async o=>{let a=e.map((d,f)=>f).filter(d=>i[d.toString()]===void 0||i[d.toString()]instanceof Error),s=a.map(d=>e[d]),c=a.map(d=>this._patchConfigForRetry(o,t?.[d],r?.[d])),u=await super.batch(s,c,{...n,returnExceptions:!0}),l;for(let d=0;d<u.length;d+=1){let f=u[d],p=a[d];f instanceof Error&&l===void 0&&(l=f,l.input=s[d]),i[p.toString()]=f}if(l)throw l;return u},{onFailedAttempt:({error:o})=>this.onFailedAttempt(o,o.input),retries:Math.max(this.maxAttemptNumber-1,0),randomize:!0})}catch(o){if(n?.returnExceptions!==!0)throw o}return Object.keys(i).sort((o,a)=>parseInt(o,10)-parseInt(a,10)).map(o=>i[parseInt(o,10)])}async batch(e,t,r){return this._batchWithConfig(this._batch.bind(this),e,t,r)}},Jr=class Ll extends ce{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 n=Ee(r),i=await(await tr(n))?.handleChainStart(this.toJSON(),wt(t,"input"),n.runId,void 0,void 0,void 0,n?.runName);delete n.runId;let o=t,a;try{let s=[this.first,...this.middle];for(let c=0;c<s.length;c+=1)o=await Hr(s[c].invoke(o,Ae(n,{callbacks:i?.getChild(this.omitSequenceTags?void 0:`seq:step:${c+1}`)})),n.signal);if(n.signal?.aborted)throw Ao(n.signal);a=await this.last.invoke(o,Ae(n,{callbacks:i?.getChild(this.omitSequenceTags?void 0:`seq:step:${this.steps.length}`)}))}catch(s){throw await i?.handleChainError(s),s}return await i?.handleChainEnd(wt(a,"output")),a}async batch(t,r,n){let i=this._getOptionsList(r??{},t.length),o=await Promise.all(i.map(tr)),a=await Promise.all(o.map(async(c,u)=>{let l=await c?.handleChainStart(this.toJSON(),wt(t[u],"input"),i[u].runId,void 0,void 0,void 0,i[u].runName);return delete i[u].runId,l})),s=t;try{for(let c=0;c<this.steps.length;c+=1)s=await Hr(this.steps[c].batch(s,a.map((u,l)=>{let d=u?.getChild(this.omitSequenceTags?void 0:`seq:step:${c+1}`);return Ae(i[l],{callbacks:d})}),n),i[0]?.signal)}catch(c){throw await Promise.all(a.map(u=>u?.handleChainError(c))),c}return await Promise.all(a.map(c=>c?.handleChainEnd(wt(s,"output")))),s}_concatOutputChunks(t,r){return this.last._concatOutputChunks(t,r)}async*_streamIterator(t,r){let n=await tr(r),{runId:i,...o}=r??{},a=await n?.handleChainStart(this.toJSON(),wt(t,"input"),i,void 0,void 0,void 0,o?.runName),s=[this.first,...this.middle,this.last],c=!0,u;async function*l(){yield t}try{let d=s[0].transform(l(),Ae(o,{callbacks:a?.getChild(this.omitSequenceTags?void 0:"seq:step:1")}));for(let f=1;f<s.length;f+=1)d=await s[f].transform(d,Ae(o,{callbacks:a?.getChild(this.omitSequenceTags?void 0:`seq:step:${f+1}`)}));for await(let f of d)if(r?.signal?.throwIfAborted(),yield f,c)if(u===void 0)u=f;else try{u=this._concatOutputChunks(u,f)}catch{u=void 0,c=!1}}catch(d){throw await a?.handleChainError(d),d}await a?.handleChainEnd(wt(u,"output"))}getGraph(t){let r=new ks,n=null;return this.steps.forEach((i,o)=>{let a=i.getGraph(t);o!==0&&a.trimFirstNode(),o!==this.steps.length-1&&a.trimLastNode(),r.extend(a);let s=a.firstNode();if(!s)throw new Error(`Runnable ${i} has no first node`);n&&r.addEdge(n,s),n=a.lastNode()}),r}pipe(t){return Ll.isRunnableSequence(t)?new Ll({first:this.first,middle:this.middle.concat([this.last,t.first,...t.middle]),last:t.last,name:this.name??t.name}):new Ll({first:this.first,middle:[...this.middle,this.last],last:lt(t),name:this.name})}static isRunnableSequence(t){return Array.isArray(t.middle)&&ce.isRunnable(t)}static from([t,...r],n){let i={};return typeof n=="string"?i.name=n:n!==void 0&&(i=n),new Ll({...i,first:lt(t),middle:r.slice(0,-1).map(lt),last:lt(r[r.length-1])})}},Yo=class SN extends ce{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,n]of Object.entries(t.steps))this.steps[r]=lt(n)}static from(t){return new SN({steps:t})}async invoke(t,r){let n=Ee(r),i=await(await tr(n))?.handleChainStart(this.toJSON(),{input:t},n.runId,void 0,void 0,void 0,n?.runName);delete n.runId;let o={};try{let a=Object.entries(this.steps).map(async([s,c])=>{o[s]=await c.invoke(t,Ae(n,{callbacks:i?.getChild(`map:key:${s}`)}))});await Hr(Promise.all(a),n.signal)}catch(a){throw await i?.handleChainError(a),a}return await i?.handleChainEnd(o),o}async*_transform(t,r,n){let i={...this.steps},o=_p(t,Object.keys(i).length),a=new Map(Object.entries(i).map(([s,c],u)=>{let l=c.transform(o[u],Ae(n,{callbacks:r?.getChild(`map:key:${s}`)}));return[s,l.next().then(d=>({key:s,gen:l,result:d}))]}));for(;a.size;){let{key:s,result:c,gen:u}=await Hr(Promise.race(a.values()),n?.signal);a.delete(s),c.done||(yield{[s]:c.value},a.set(s,u.next().then(l=>({key:s,gen:u,result:l}))))}}transform(t,r){return this._transformStreamWithConfig(t,this._transform.bind(this),r)}async stream(t,r){async function*n(){yield t}let i=Ee(r),o=new Co({generator:this.transform(n(),i),config:i});return await o.setup,bt.fromAsyncGenerator(o)}},p9=class kN extends ce{lc_serializable=!1;lc_namespace=["langchain_core","runnables"];func;constructor(t){if(super(t),!Of(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[n]=this._getOptionsList(r??{},1),i=await tr(n);return Hr(this.func(Ae(n,{callbacks:i}),t),n?.signal)}async*_streamIterator(t,r){let[n]=this._getOptionsList(r??{},1),i=await this.invoke(t,r);if(qm(i)){for await(let o of i)n?.signal?.throwIfAborted(),yield o;return}if(yN(i)){for(;;){n?.signal?.throwIfAborted();let o=i.next();if(o.done)break;yield o.value}return}yield i}static from(t){return new kN({func:t})}};function m9(e){if(Of(e))throw new Error("RunnableLambda requires a function that is not wrapped in traceable higher-order function. This shouldn't happen.")}var ir=class EN extends ce{static lc_name(){return"RunnableLambda"}lc_namespace=["langchain_core","runnables"];func;constructor(t){if(Of(t.func))return p9.from(t.func);super(t),m9(t.func),this.func=t.func}static from(t){return new EN({func:t})}async _invoke(t,r,n){return new Promise((i,o)=>{let a=Ae(r,{callbacks:n?.getChild(),recursionLimit:(r?.recursionLimit??25)-1});Me.runWithConfig(Ar(a),async()=>{try{let s=await this.func(t,{...a});if(s&&ce.isRunnable(s)){if(r?.recursionLimit===0)throw new Error("Recursion limit reached.");s=await s.invoke(t,{...a,recursionLimit:(a.recursionLimit??25)-1})}else if(qm(s)){let c;for await(let u of Km(a,s))if(r?.signal?.throwIfAborted(),c===void 0)c=u;else try{c=this._concatOutputChunks(c,u)}catch{c=u}s=c}else if(o0(s)){let c;for(let u of s0(a,s))if(r?.signal?.throwIfAborted(),c===void 0)c=u;else try{c=this._concatOutputChunks(c,u)}catch{c=u}s=c}i(s)}catch(s){o(s)}})})}async invoke(t,r){return this._callWithConfig(this._invoke.bind(this),t,r)}async*_transform(t,r,n){let i;for await(let s of t)if(i===void 0)i=s;else try{i=this._concatOutputChunks(i,s)}catch{i=s}let o=Ae(n,{callbacks:r?.getChild(),recursionLimit:(n?.recursionLimit??25)-1}),a=await new Promise((s,c)=>{Me.runWithConfig(Ar(o),async()=>{try{s(await this.func(i,{...o,config:o}))}catch(u){c(u)}})});if(a&&ce.isRunnable(a)){if(n?.recursionLimit===0)throw new Error("Recursion limit reached.");let s=await a.stream(i,o);for await(let c of s)yield c}else if(qm(a))for await(let s of Km(o,a))n?.signal?.throwIfAborted(),yield s;else if(o0(a))for(let s of s0(o,a))n?.signal?.throwIfAborted(),yield s;else yield a}transform(t,r){return this._transformStreamWithConfig(t,this._transform.bind(this),r)}async stream(t,r){async function*n(){yield t}let i=Ee(r),o=new Co({generator:this.transform(n(),i),config:i});return await o.setup,bt.fromAsyncGenerator(o)}},IN=class extends Yo{},c0=class extends ce{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=Ee(t),n=await tr(r),{runId:i,...o}=r,a=await n?.handleChainStart(this.toJSON(),wt(e,"input"),i,void 0,void 0,void 0,o?.runName),s=Ae(o,{callbacks:a?.getChild()});return await Me.runWithConfig(s,async()=>{let c;for(let u of this.runnables()){r?.signal?.throwIfAborted();try{let l=await u.invoke(e,s);return await a?.handleChainEnd(wt(l,"output")),l}catch(l){c===void 0&&(c=l)}}throw c===void 0?new Error("No error stored at end of fallback."):(await a?.handleChainError(c),c)})}async*_streamIterator(e,t){let r=Ee(t),n=await tr(r),{runId:i,...o}=r,a=await n?.handleChainStart(this.toJSON(),wt(e,"input"),i,void 0,void 0,void 0,o?.runName),s,c;for(let l of this.runnables()){r?.signal?.throwIfAborted();let d=Ae(o,{callbacks:a?.getChild()});try{c=Km(d,await l.stream(e,d));break}catch(f){s===void 0&&(s=f)}}if(c===void 0){let l=s??new Error("No error stored at end of fallback.");throw await a?.handleChainError(l),l}let u;try{for await(let l of c){yield l;try{u=u===void 0?u:this._concatOutputChunks(u,l)}catch{u=void 0}}}catch(l){throw await a?.handleChainError(l),l}await a?.handleChainEnd(wt(u,"output"))}async batch(e,t,r){if(r?.returnExceptions)throw new Error("Not implemented.");let n=this._getOptionsList(t??{},e.length),i=await Promise.all(n.map(s=>tr(s))),o=await Promise.all(i.map(async(s,c)=>{let u=await s?.handleChainStart(this.toJSON(),wt(e[c],"input"),n[c].runId,void 0,void 0,void 0,n[c].runName);return delete n[c].runId,u})),a;for(let s of this.runnables()){n[0].signal?.throwIfAborted();try{let c=await s.batch(e,o.map((u,l)=>Ae(n[l],{callbacks:u?.getChild()})),r);return await Promise.all(o.map((u,l)=>u?.handleChainEnd(wt(c[l],"output")))),c}catch(c){a===void 0&&(a=c)}}throw a?(await Promise.all(o.map(s=>s?.handleChainError(a))),a):new Error("No error stored at end of fallbacks.")}};function lt(e){if(typeof e=="function")return new ir({func:e});if(ce.isRunnable(e))return e;if(!Array.isArray(e)&&typeof e=="object"){let t={};for(let[r,n]of Object.entries(e))t[r]=lt(n);return new Yo({steps:t})}else throw new Error(`Expected a Runnable, function or object.
249
- Instead got an unsupported type.`)}var Fl=class extends ce{static lc_name(){return"RunnableAssign"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;mapper;constructor(e){e instanceof Yo&&(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 n=this.mapper.getStepsKeys(),[i,o]=_p(e),a=this.mapper.transform(o,Ae(r,{callbacks:t?.getChild()})),s=a.next();for await(let c of i){if(typeof c!="object"||Array.isArray(c))throw new Error(`RunnableAssign can only be used with objects as input, got ${typeof c}`);let u=Object.fromEntries(Object.entries(c).filter(([l])=>!n.includes(l)));Object.keys(u).length>0&&(yield u)}yield(await s).value;for await(let c of a)yield c}transform(e,t){return this._transformStreamWithConfig(e,this._transform.bind(this),t)}async stream(e,t){async function*r(){yield e}let n=Ee(t),i=new Co({generator:this.transform(r(),n),config:n});return await i.setup,bt.fromAsyncGenerator(i)}},u0=class extends ce{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 n=Ee(t),i=new Co({generator:this.transform(r(),n),config:n});return await i.setup,bt.fromAsyncGenerator(i)}},Jm=class extends ln{name;description;schema;constructor(e){let t=Jr.from([ir.from(async r=>{let n;if(_o(r))try{n=await Zo(this.schema,r.args)}catch{throw new Gs("Received tool input did not match expected schema",JSON.stringify(r.args))}else n=r;return n}).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 h9(e,t){let r=t.name??e.getName(),n=t.description??Li(t.schema);return Vc(t.schema)?new Jm({name:r,description:n,schema:Ut.object({input:Ut.string()}).transform(i=>i.input),bound:e}):new Jm({name:r,description:n,schema:t.schema,bound:e})}var Ym=(e,t)=>{let r=[...new Set(t?.map(i=>{if(typeof i=="string")return i;let o=new i({});if(!("getType"in o)||typeof o.getType!="function")throw new Error("Invalid type provided.");return o.getType()}))],n=e.getType();return r.some(i=>i===n)};function ON(e,t){return Array.isArray(e)?$N(e,t):ir.from(r=>$N(r,e))}function $N(e,t={}){let{includeNames:r,excludeNames:n,includeTypes:i,excludeTypes:o,includeIds:a,excludeIds:s}=t,c=[];for(let u of e)if(!(n&&u.name&&n.includes(u.name))){{if(o&&Ym(u,o))continue;if(s&&u.id&&s.includes(u.id))continue}i||a||r?(r&&u.name&&r.some(l=>l===u.name)||i&&Ym(u,i)||a&&u.id&&a.some(l=>l===u.id))&&c.push(u):c.push(u)}return c}function PN(e){return Array.isArray(e)?TN(e):ir.from(TN)}function TN(e){if(!e.length)return[];let t=[];for(let r of e){let n=r,i=t.pop();if(!i)t.push(n);else if(n.getType()==="tool"||n.getType()!==i.getType())t.push(i,n);else{let o=ka(i),a=ka(n),s=o.concat(a);typeof o.content=="string"&&typeof a.content=="string"&&(s.content=`${o.content}
250
- ${a.content}`),t.push(_9(s))}}return t}function NN(e,t){if(Array.isArray(e)){let r=e;if(!t)throw new Error("Options parameter is required when providing messages.");return AN(r,t)}else{let r=e;return ir.from(n=>AN(n,r)).withConfig({runName:"trim_messages"})}}async function AN(e,t){let{maxTokens:r,tokenCounter:n,strategy:i="last",allowPartial:o=!1,endOn:a,startOn:s,includeSystem:c=!1,textSplitter:u}=t;if(s&&i==="first")throw new Error("`startOn` should only be specified if `strategy` is 'last'.");if(c&&i==="first")throw new Error("`includeSystem` should only be specified if `strategy` is 'last'.");let l;"getNumTokens"in n?l=async f=>(await Promise.all(f.map(p=>n.getNumTokens(p.content)))).reduce((p,m)=>p+m,0):l=async f=>n(f);let d=d0;if(u&&("splitText"in u?d=u.splitText.bind(u):d=async f=>u(f)),i==="first")return RN(e,{maxTokens:r,tokenCounter:l,textSplitter:d,partialStrategy:o?"first":void 0,endOn:a});if(i==="last")return g9(e,{maxTokens:r,tokenCounter:l,textSplitter:d,allowPartial:o,includeSystem:c,startOn:s,endOn:a});throw new Error(`Unrecognized strategy: '${i}'. Must be one of 'first' or 'last'.`)}async function RN(e,t){let{maxTokens:r,tokenCounter:n,textSplitter:i,partialStrategy:o,endOn:a}=t,s=[...e],c=0;for(let u=0;u<s.length;u+=1)if(await n(u>0?s.slice(0,-u):s)<=r){c=s.length-u;break}if(c<s.length&&o){let u=!1;if(Array.isArray(s[c].content)){let l=s[c];if(typeof l.content=="string")throw new Error("Expected content to be an array.");let d=l.content.length,f=o==="last"?[...l.content].reverse():l.content;for(let p=1;p<=d;p+=1){let m=o==="first"?f.slice(0,p):f.slice(-p),h=Object.fromEntries(Object.entries(l).filter(([w])=>w!=="type"&&!w.startsWith("lc_"))),_=l0(l.getType(),{...h,content:m}),y=[...s.slice(0,c),_];if(await n(y)<=r)s=y,c+=1,u=!0;else break}u&&o==="last"&&(l.content=[...f].reverse())}if(!u){let l=s[c],d;if(Array.isArray(l.content)&&l.content.some(f=>typeof f=="string"||f.type==="text")?d=l.content.find(f=>f.type==="text"&&f.text)?.text:typeof l.content=="string"&&(d=l.content),d){let f=await i(d),p=f.length;o==="last"&&f.reverse();for(let m=0;m<p-1;m+=1)if(f.pop(),l.content=f.join(""),await n([...s.slice(0,c),l])<=r){o==="last"&&(l.content=[...f].reverse().join("")),s=[...s.slice(0,c),l],c+=1;break}}}}if(a){let u=Array.isArray(a)?a:[a];for(;c>0&&!Ym(s[c-1],u);)c-=1}return s.slice(0,c)}async function g9(e,t){let{allowPartial:r=!1,includeSystem:n=!1,endOn:i,startOn:o,...a}=t,s=e.map(l=>{let d=Object.fromEntries(Object.entries(l).filter(([f])=>f!=="type"&&!f.startsWith("lc_")));return l0(l.getType(),d,$i(l))});if(i){let l=Array.isArray(i)?i:[i];for(;s.length>0&&!Ym(s[s.length-1],l);)s=s.slice(0,-1)}let c=n&&s[0]?.getType()==="system",u=c?s.slice(0,1).concat(s.slice(1).reverse()):s.reverse();return u=await RN(u,{...a,partialStrategy:r?"last":void 0,endOn:o}),c?[u[0],...u.slice(1).reverse()]:u.reverse()}var CN={human:{message:dt,messageChunk:Sa},ai:{message:je,messageChunk:ut},system:{message:mr,messageChunk:Ti},developer:{message:mr,messageChunk:Ti},tool:{message:$t,messageChunk:Zs},function:{message:wa,messageChunk:xa},generic:{message:bn,messageChunk:ba},remove:{message:Vr,messageChunk:Vr}};function l0(e,t,r){let n,i;switch(e){case"human":r?n=new Sa(t):i=new dt(t);break;case"ai":if(r){let o={...t};"tool_calls"in o&&(o={...o,tool_call_chunks:o.tool_calls?.map(a=>({...a,type:"tool_call_chunk",index:void 0,args:JSON.stringify(a.args)}))}),n=new ut(o)}else i=new je(t);break;case"system":r?n=new Ti(t):i=new mr(t);break;case"developer":r?n=new Ti({...t,additional_kwargs:{...t.additional_kwargs,__openai_role__:"developer"}}):i=new mr({...t,additional_kwargs:{...t.additional_kwargs,__openai_role__:"developer"}});break;case"tool":if("tool_call_id"in t)r?n=new Zs(t):i=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)n=new xa(t);else{if(!t.name)throw new Error("FunctionMessage must have a 'name' field");i=new wa(t)}break;case"generic":if("role"in t)r?n=new ba(t):i=new bn(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&&n)return n;if(i)return i;throw new Error(`Unrecognized message type ${e}`)}function _9(e){let t=e.getType(),r,n=Object.fromEntries(Object.entries(e).filter(([i])=>!["type","tool_call_chunks"].includes(i)&&!i.startsWith("lc_")));if(t in CN&&(r=l0(t,n)),!r)throw new Error(`Unrecognized message chunk class ${t}. Supported classes are ${Object.keys(CN)}`);return r}function d0(e){let t=e.split(`
251
- `);return Promise.resolve([...t.slice(0,-1).map(r=>`${r}
252
- `),t[t.length-1]])}var jN=["tool_call","tool_call_chunk","invalid_tool_call","server_tool_call","server_tool_call_chunk","server_tool_call_result"];var MN=["image","video","audio","text-plain","file"];var DN=["text","reasoning",...jN,...MN];var zN=A({AIMessage:()=>je,AIMessageChunk:()=>ut,BaseMessage:()=>Re,BaseMessageChunk:()=>Mt,ChatMessage:()=>bn,ChatMessageChunk:()=>ba,DEFAULT_MERGE_IGNORE_KEYS:()=>v_,FunctionMessage:()=>wa,FunctionMessageChunk:()=>xa,HumanMessage:()=>dt,HumanMessageChunk:()=>Sa,KNOWN_BLOCK_TYPES:()=>DN,RemoveMessage:()=>Vr,SystemMessage:()=>mr,SystemMessageChunk:()=>Ti,ToolMessage:()=>$t,ToolMessageChunk:()=>Zs,_isMessageFieldWithRole:()=>bf,_mergeDicts:()=>it,_mergeLists:()=>go,_mergeObj:()=>vf,_mergeStatus:()=>yf,coerceMessageLikeToMessage:()=>Tt,collapseToolCallChunks:()=>xf,convertToChunk:()=>ka,convertToOpenAIImageBlock:()=>mf,convertToProviderContentBlock:()=>hI,defaultTextSplitter:()=>d0,defaultToolCallParser:()=>Hu,filterMessages:()=>ON,getBufferString:()=>Ks,iife:()=>u$,isAIMessage:()=>qs,isAIMessageChunk:()=>Gu,isBase64ContentBlock:()=>Hs,isBaseMessage:()=>ot,isBaseMessageChunk:()=>$i,isChatMessage:()=>t$,isChatMessageChunk:()=>r$,isDataContentBlock:()=>Wn,isDirectToolOutput:()=>Vu,isFunctionMessage:()=>n$,isFunctionMessageChunk:()=>i$,isHumanMessage:()=>o$,isHumanMessageChunk:()=>a$,isIDContentBlock:()=>pf,isMessage:()=>_f,isOpenAIToolCallArray:()=>CI,isPlainTextContentBlock:()=>pI,isSystemMessage:()=>s$,isSystemMessageChunk:()=>c$,isToolMessage:()=>Zu,isToolMessageChunk:()=>b_,isURLContentBlock:()=>Vs,mapChatMessagesToStoredMessages:()=>d$,mapStoredMessageToChatMessage:()=>Wu,mapStoredMessagesToChatMessages:()=>l$,mergeContent:()=>Jt,mergeMessageRuns:()=>PN,mergeResponseMetadata:()=>wf,mergeUsageMetadata:()=>Ws,parseBase64DataUrl:()=>Bu,parseMimeType:()=>mI,trimMessages:()=>NN});var UN=A({BaseChatMessageHistory:()=>f0,BaseListChatMessageHistory:()=>Qm,InMemoryChatMessageHistory:()=>y9}),f0=class extends yt{async addMessages(e){for(let t of e)await this.addMessage(t)}},Qm=class extends yt{addUserMessage(e){return this.addMessage(new dt(e))}addAIMessage(e){return this.addMessage(new je(e))}async addMessages(e){for(let t of e)await this.addMessage(t)}clear(){throw new Error("Not implemented.")}},y9=class extends Qm{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 Xr=class{pageContent;metadata;id;constructor(e){this.pageContent=e.pageContent!==void 0?e.pageContent.toString():"",this.metadata=e.metadata??{},this.id=e.id}};var p0=class extends ce{lc_namespace=["langchain_core","documents","transformers"];invoke(e,t){return this.transformDocuments(e)}},LN=class extends p0{async transformDocuments(e){let t=[];for(let r of e){let n=await this._transformDocument(r);t.push(n)}return t}};var FN=A({BaseDocumentTransformer:()=>p0,Document:()=>Xr,MappingDocumentTransformer:()=>LN});var BN=A({BaseDocumentLoader:()=>m0}),m0=class{};var VN=A({LangSmithLoader:()=>v9}),v9=class extends m0{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 Xn(e?.clientConfig),this.contentKey=e.contentKey?e.contentKey.split("."):[],this.formatContent=e.formatContent??b9,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 o of this.contentKey)r=r[o];let n=this.formatContent(r),i=t;["created_at","modified_at"].forEach(o=>{o in i&&typeof i[o]=="object"&&(i[o]=i[o].toString())}),e.push({pageContent:n,metadata:i})}return e}};function b9(e){if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}var HN=A({Embeddings:()=>eh}),eh=class{caller;constructor(e){this.caller=new ji(e??{})}};var Qc=class extends yt{lc_namespace=["langchain_core","example_selectors","base"]};var h0=class{async getPromptAsync(e,t){return this.getPrompt(e).partial(t?.partialVariables??{})}},ZN=class extends h0{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 GN(e){return e._modelType()==="base_llm"}function WN(e){return e._modelType()==="base_chat_model"}function qN(e){return e.split(/\n| /).length}var KN=class JN extends Qc{examples=[];examplePrompt;getTextLength=qN;maxLength=2048;exampleTextLengths=[];constructor(t){super(t),this.examplePrompt=t.examplePrompt,this.maxLength=t.maxLength??2048,this.getTextLength=t.getTextLength??qN}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:n,examplePrompt:i}=r;return(await Promise.all(n.map(o=>i.format(o)))).map(o=>this.getTextLength(o))}async selectExamples(t){let r=Object.values(t).join(" "),n=this.maxLength-this.getTextLength(r),i=0,o=[];for(;n>0&&i<this.examples.length;){let a=n-this.exampleTextLengths[i];if(a<0)break;o.push(this.examples[i]),n=a,i+=1}return o}static async fromExamples(t,r){let n=new JN(r);return await Promise.all(t.map(i=>n.addExample(i))),n}};function g0(e){return Object.keys(e).sort().map(t=>e[t])}var XN=class YN extends Qc{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=g0((this.inputKeys??Object.keys(t)).reduce((n,i)=>({...n,[i]:t[i]}),{})).join(" ");await this.vectorStoreRetriever.addDocuments([new Xr({pageContent:r,metadata:t})])}async selectExamples(t){let r=g0((this.inputKeys??Object.keys(t)).reduce((i,o)=>({...i,[o]:t[o]}),{})).join(" "),n=(await this.vectorStoreRetriever.invoke(r)).map(i=>i.metadata);return this.exampleKeys?n.map(i=>this.exampleKeys.reduce((o,a)=>({...o,[a]:i[a]}),{})):n}static async fromExamples(t,r,n,i={}){let o=i.inputKeys??null,a=t.map(s=>g0(o?o.reduce((c,u)=>({...c,[u]:s[u]}),{}):s).join(" "));return new YN({vectorStore:await n.fromTexts(a,t,r,i),k:i.k??4,exampleKeys:i.exampleKeys,inputKeys:i.inputKeys})}};var QN=A({BaseExampleSelector:()=>Qc,BasePromptSelector:()=>h0,ConditionalPromptSelector:()=>ZN,LengthBasedExampleSelector:()=>KN,SemanticSimilarityExampleSelector:()=>XN,isChatModel:()=>WN,isLLM:()=>GN});var Bl="10f90ea3-90a4-4962-bf75-83a0f3c1c62a",e1=class extends yt{lc_namespace=["langchain","recordmanagers"]};var _0=class{uid;hash_;contentHash;metadataHash;pageContent;metadata;keyEncoder=Bs;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 Xr({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 zs(this.keyEncoder(e),Bl)}_hashNestedDictToUUID(e){let t=JSON.stringify(e,Object.keys(e).sort());return zs(this.keyEncoder(t),Bl)}};function y0(e,t){let r=[],n=[];return t.forEach(i=>{n.push(i),n.length>=e&&(r.push(n),n=[])}),n.length>0&&r.push(n),r}function v0(e){let t=new Set,r=[];for(let n of e){if(!n.hash_)throw new Error("Hashed document does not have a hash");t.has(n.hash_)||(t.add(n.hash_),r.push(n))}return r}function b0(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 w0=e=>"load"in e&&typeof e.load=="function"&&"loadAndSplit"in e&&typeof e.loadAndSplit=="function";async function t1(e){let{docsSource:t,recordManager:r,vectorStore:n,options:i}=e,{batchSize:o=100,cleanup:a,sourceIdKey:s,cleanupBatchSize:c=1e3,forceUpdate:u=!1}=i??{};if(a==="incremental"&&!s)throw new Error("sourceIdKey is required when cleanup mode is incremental. Please provide through 'options.sourceIdKey'.");let l=w0(t)?await t.load():t,d=b0(s??null),f=await r.getTime(),p=0,m=0,h=0,_=0,y=y0(o??100,l);for(let w of y){let x=v0(w.map(N=>_0.fromDocument(N))),S=x.map(N=>d(N));a==="incremental"&&x.forEach((N,W)=>{if(S[W]===null)throw new Error("sourceIdKey must be provided when cleanup is incremental")});let E=await r.exists(x.map(N=>N.uid)),C=[],T=[],b=[],L=new Set;if(x.forEach((N,W)=>{if(E[W])if(u)L.add(N.uid);else{b.push(N.uid);return}C.push(N.uid),T.push(N.toDocument())}),b.length>0&&(await r.update(b,{timeAtLeast:f}),_+=b.length),T.length>0&&(await n.addDocuments(T,{ids:C}),p+=T.length-L.size,h+=L.size),await r.update(x.map(N=>N.uid),{timeAtLeast:f,groupIds:S}),a==="incremental"){S.forEach(W=>{if(!W)throw new Error("Source id cannot be null")});let N=await r.listKeys({before:f,groupIds:S});N.length>0&&(await n.delete({ids:N}),await r.deleteKeys(N),m+=N.length)}}if(a==="full"){let w=await r.listKeys({before:f,limit:c});for(;w.length>0;)await n.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 r1=A({RecordManager:()=>e1,UUIDV5_NAMESPACE:()=>Bl,_HashedDocument:()=>_0,_batch:()=>y0,_deduplicateInOrder:()=>v0,_getSourceIdAssigner:()=>b0,_isBaseDocumentLoader:()=>w0,index:()=>t1});var n1=A({BasePromptValue:()=>th,ChatPromptValue:()=>Hl,ImagePromptValue:()=>x0,StringPromptValue:()=>Vl}),th=class extends yt{},Vl=class extends th{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 dt(this.value)]}},Hl=class extends th{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 Ks(this.messages)}toChatMessages(){return this.messages}},x0=class extends th{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 dt({content:[{type:"image_url",image_url:{detail:this.imageUrl.detail,url:this.imageUrl.url}}]})]}};var s1=Vd(a1(),1),T9=Object.defineProperty,A9=(e,t,r)=>t in e?T9(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,C9=(e,t,r)=>(A9(e,typeof t!="symbol"?t+"":t,r),r);function O9(e,t){let r=Array.from({length:e.length},(n,i)=>({start:i,end:i+1}));for(;r.length>1;){let n=null;for(let i=0;i<r.length-1;i++){let o=e.slice(r[i].start,r[i+1].end),a=t.get(o.join(","));a!=null&&(n==null||a<n[0])&&(n=[a,i])}if(n!=null){let i=n[1];r[i]={start:r[i].start,end:r[i+1].end},r.splice(i+1,1)}else break}return r}function P9(e,t){return e.length===1?[t.get(e.join(","))]:O9(e,t).map(r=>t.get(e.slice(r.start,r.end).join(","))).filter(r=>r!=null)}function N9(e){return e.replace(/[\\^$*+?.()|[\]{}]/g,"\\$&")}var k0=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(`
253
- `).filter(Boolean).reduce((n,i)=>{let[o,a,...s]=i.split(" "),c=Number.parseInt(a,10);return s.forEach((u,l)=>n[u]=c+l),n},{});for(let[n,i]of Object.entries(r)){let o=s1.default.toByteArray(n);this.rankMap.set(o.join(","),i),this.textMap.set(i,o)}this.specialTokens={...e.special_tokens,...t},this.inverseSpecialTokens=Object.entries(this.specialTokens).reduce((n,[i,o])=>(n[o]=this.textEncoder.encode(i),n),{})}encode(e,t=[],r="all"){let n=new RegExp(this.patStr,"ug"),i=k0.specialTokenRegex(Object.keys(this.specialTokens)),o=[],a=new Set(t==="all"?Object.keys(this.specialTokens):t),s=new Set(r==="all"?Object.keys(this.specialTokens).filter(u=>!a.has(u)):r);if(s.size>0){let u=k0.specialTokenRegex([...s]),l=e.match(u);if(l!=null)throw new Error(`The text contains a special token that is not allowed: ${l[0]}`)}let c=0;for(;;){let u=null,l=c;for(;i.lastIndex=l,u=i.exec(e),!(u==null||a.has(u[0]));)l=u.index+1;let d=u?.index??e.length;for(let p of e.substring(c,d).matchAll(n)){let m=this.textEncoder.encode(p[0]),h=this.rankMap.get(m.join(","));if(h!=null){o.push(h);continue}o.push(...P9(m,this.rankMap))}if(u==null)break;let f=this.specialTokens[u[0]];o.push(f),c=u.index+u[0].length}return o}decode(e){let t=[],r=0;for(let o=0;o<e.length;++o){let a=e[o],s=this.textMap.get(a)??this.inverseSpecialTokens[a];s!=null&&(t.push(s),r+=s.length)}let n=new Uint8Array(r),i=0;for(let o of t)n.set(o,i),i+=o.length;return this.textDecoder.decode(n)}},nh=k0;C9(nh,"specialTokenRegex",e=>new RegExp(e.map(t=>N9(t)).join("|"),"g"));function E0(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 c1=A({encodingForModel:()=>oh,getEncoding:()=>u1}),ih={},R9=new ji({});async function u1(e){return e in ih||(ih[e]=R9.fetch(`https://tiktoken.pages.dev/js/${e}.json`).then(t=>t.json()).then(t=>new nh(t)).catch(t=>{throw delete ih[e],t})),await ih[e]}async function oh(e){return u1(E0(e))}var l1=A({BaseLangChain:()=>sh,BaseLanguageModel:()=>Zl,calculateMaxTokens:()=>D9,getEmbeddingContextSize:()=>j9,getModelContextSize:()=>d1,getModelNameForTiktoken:()=>ah,isOpenAITool:()=>M9}),ah=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,j9=e=>e==="text-embedding-ada-002"?8191:2046,d1=e=>{switch(ah(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 M9(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 D9=async({prompt:e,modelName:t})=>{let r;try{r=(await oh(ah(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 d1(t)-r},z9=()=>!1,sh=class extends ce{verbose;callbacks;tags;metadata;get lc_attributes(){return{callbacks:void 0,verbose:void 0}}constructor(e){super(e),this.verbose=e.verbose??z9(),this.callbacks=e.callbacks,this.tags=e.tags??[],this.metadata=e.metadata??{},this._addVersion("@langchain/core","1.2.4")}_addVersion(e,t){let r=this.metadata?.versions;this.metadata={...this.metadata,versions:{...typeof r=="object"&&r!==null?r:{},[e]:t}}}},Zl=class extends sh{get callKeys(){return["stop","timeout","signal","tags","metadata","callbacks"]}caller;cache;constructor({callbacks:e,callbackManager:t,...r}){let{cache:n,...i}=r;super({callbacks:e??t,...i}),typeof n=="object"?this.cache=n:n?this.cache=k_.global():this.cache=void 0,this.caller=new ji(r??{})}_encoding;async getNumTokens(e){let t;typeof e=="string"?t=e:t=e.map(n=>typeof n=="string"?n:n.type==="text"&&"text"in n?n.text:"").join("");let r=Math.ceil(t.length/4);if(!this._encoding)try{this._encoding=await oh("modelName"in this?ah(this.modelName):"gpt2")}catch(n){console.warn("Failed to calculate number of tokens, falling back to approximate count",n)}if(this._encoding)try{r=this._encoding.encode(t).length}catch(n){console.warn("Failed to calculate number of tokens, falling back to approximate count",n)}return r}static _convertInputToPromptValue(e){return typeof e=="string"?new Vl(e):Array.isArray(e)?new Hl(e.map(Tt)):e}_identifyingParams(){return{}}_getSerializedCacheKeyParametersForCall({config:e,...t}){let r={...this._identifyingParams(),...t,_type:this._llmType(),_model:this._modelType()};return Object.entries(r).filter(([n,i])=>i!==void 0).map(([n,i])=>`${n}:${JSON.stringify(i)}`).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:n,response_format:i,...o}=e;return o}};var Zi=class extends ce{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=Ee(t);return this.func&&await this.func(e,r),this._callWithConfig(n=>Promise.resolve(n),e,r)}async*transform(e,t){let r=Ee(t),n,i=!0;for await(let o of this._transformStreamWithConfig(e,a=>a,r))if(yield o,i)if(n===void 0)n=o;else try{n=Zr(n,o)}catch{n=void 0,i=!1}this.func&&n!==void 0&&await this.func(n,r)}static assign(e){return new Fl(new Yo({steps:e}))}};var f1=class extends ce{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:n}=e,i=this.runnables[r];if(i===void 0)throw new Error(`No runnable associated with key "${r}".`);return i.invoke(n,Ee(t))}async batch(e,t,r){let n=e.map(l=>l.key),i=e.map(l=>l.input);if(n.find(l=>this.runnables[l]===void 0)!==void 0)throw new Error("One or more keys do not have a corresponding runnable.");let o=n.map(l=>this.runnables[l]),a=this._getOptionsList(t??{},e.length),s=a[0]?.maxConcurrency??r?.maxConcurrency,c=s&&s>0?s:e.length,u=[];for(let l=0;l<i.length;l+=c){let d=i.slice(l,l+c).map((p,m)=>o[m].invoke(p,a[m])),f=await Promise.all(d);u.push(f)}return u.flat()}async stream(e,t){let{key:r,input:n}=e,i=this.runnables[r];if(i===void 0)throw new Error(`No runnable associated with key "${r}".`);return i.stream(n,t)}};var p1=class extends ce{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(([n,i])=>[lt(n),lt(i)]),r=lt(e[e.length-1]);return new this({branches:t,default:r})}async _invoke(e,t,r){let n;for(let i=0;i<this.branches.length;i+=1){let[o,a]=this.branches[i];if(await o.invoke(e,Ae(t,{callbacks:r?.getChild(`condition:${i+1}`)}))){n=await a.invoke(e,Ae(t,{callbacks:r?.getChild(`branch:${i+1}`)}));break}}return n||(n=await this.default.invoke(e,Ae(t,{callbacks:r?.getChild("branch:default")}))),n}async invoke(e,t={}){return this._callWithConfig(this._invoke,e,t)}async*_streamIterator(e,t){let r=await(await tr(t))?.handleChainStart(this.toJSON(),wt(e,"input"),t?.runId,void 0,void 0,void 0,t?.runName),n,i=!0,o;try{for(let a=0;a<this.branches.length;a+=1){let[s,c]=this.branches[a];if(await s.invoke(e,Ae(t,{callbacks:r?.getChild(`condition:${a+1}`)}))){o=await c.stream(e,Ae(t,{callbacks:r?.getChild(`branch:${a+1}`)}));for await(let u of o)if(yield u,i)if(n===void 0)n=u;else try{n=Zr(n,u)}catch{n=void 0,i=!1}break}}if(o===void 0){o=await this.default.stream(e,Ae(t,{callbacks:r?.getChild("branch:default")}));for await(let a of o)if(yield a,i)if(n===void 0)n=a;else try{n=Zr(n,a)}catch{n=void 0,i=!1}}}catch(a){throw await r?.handleChainError(a),a}await r?.handleChainEnd(n??{})}};var m1=class extends ln{runnable;inputMessagesKey;outputMessagesKey;historyMessagesKey;getMessageHistory;constructor(e){let t=ir.from((o,a)=>this._enterHistory(o,a??{})).withConfig({runName:"loadHistory"}),r=e.historyMessagesKey??e.inputMessagesKey;r&&(t=Zi.assign({[r]:t}).withConfig({runName:"insertHistory"}));let n=t.pipe(e.runnable.withListeners({onEnd:(o,a)=>this._exitHistory(o,a??{})})).withConfig({runName:"RunnableWithMessageHistory"}),i=e.config??{};super({...e,config:i,bound:n}),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)&&!ot(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 dt(t)];if(Array.isArray(t))return t;if(ot(t))return[t];throw new Error(`Expected a string, BaseMessage, or array of BaseMessages.
254
- Got ${JSON.stringify(t,null,2)}`)}_getOutputMessages(e){let t;if(!Array.isArray(e)&&!ot(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 je(t)];if(Array.isArray(t))return t;if(ot(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,n;Array.isArray(e.inputs)&&Array.isArray(e.inputs[0])?n=e.inputs[0]:n=e.inputs;let i=this._getInputMessages(n);if(this.historyMessagesKey===void 0){let s=await r.getMessages();i=i.slice(s.length)}let o=e.outputs;if(!o)throw new Error(`Output values from 'Run' undefined. Run: ${JSON.stringify(e,null,2)}`);let a=this._getOutputMessages(o);await r.addMessages([...i,...a])}async _mergeConfig(...e){let t=await super._mergeConfig(...e);if(!t.configurable||!t.configurable.sessionId){let n={[this.inputMessagesKey??"input"]:"foo"};throw new Error(`sessionId is required. Pass it in as part of the config argument to .invoke() or .stream()
255
- eg. chain.invoke(${JSON.stringify(n)}, ${JSON.stringify({configurable:{sessionId:"123"}})})`)}let{sessionId:r}=t.configurable;return t.configurable.messageHistory=await this.getMessageHistory(r),t}};var h1=A({RouterRunnable:()=>f1,Runnable:()=>ce,RunnableAssign:()=>Fl,RunnableBinding:()=>ln,RunnableBranch:()=>p1,RunnableEach:()=>wN,RunnableLambda:()=>ir,RunnableMap:()=>Yo,RunnableParallel:()=>IN,RunnablePassthrough:()=>Zi,RunnablePick:()=>u0,RunnableRetry:()=>Xm,RunnableSequence:()=>Jr,RunnableToolLike:()=>Jm,RunnableWithFallbacks:()=>c0,RunnableWithMessageHistory:()=>m1,_coerceToRunnable:()=>lt,ensureConfig:()=>Ee,getCallbackManagerForConfig:()=>tr,mergeConfigs:()=>Ct,patchConfig:()=>Ae,pickRunnableConfigKeys:()=>Ar,raceWithSignal:()=>Hr});var g1=A({applyPatch:()=>Oo,compare:()=>Po});var eu=class extends ce{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,n)=>this.parseResult([{text:r}],n?.callbacks),e,{...t,runType:"parser"}):this._callWithConfig(async(r,n)=>this.parseResult([{message:r,text:this._baseMessageToString(r)}],n?.callbacks),e,{...t,runType:"parser"})}},An=class extends eu{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")}},or=class extends Error{llmOutput;observation;sendToLLM;constructor(e,t,r,n=!1){if(super(e),this.llmOutput=t,this.observation=r,this.sendToLLM=n,n&&(r===void 0||t===void 0))throw new Error("Arguments 'observation' & 'llmOutput' are required if 'sendToLlm' is true");Ii(this,"OUTPUT_PARSING_FAILURE")}};var Gi=class extends An{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"})}},pi=class extends Gi{diff=!1;constructor(e){super(e),this.diff=e?.diff??this.diff}async*_transform(e){let t,r;for await(let n of e){if(typeof n!="string"&&typeof n.content!="string")throw new Error("Cannot handle non-string output.");let i;if($i(n)){if(typeof n.content!="string")throw new Error("Cannot handle non-string message output.");i=new No({message:n,text:n.content})}else if(ot(n)){if(typeof n.content!="string")throw new Error("Cannot handle non-string message output.");i=new No({message:ka(n),text:n.content})}else i=new Ri({text:n});r===void 0?r=i:r=r.concat(i);let o=await this.parsePartialResult([r]);o!=null&&!li(o,t)&&(this.diff?yield this._diff(t,o):yield o,t=o)}}getFormatInstructions(){return""}};var _1=class extends Gi{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 tu=class extends Gi{re;async*_transform(e){let t="";for await(let r of e)if(typeof r=="string"?t+=r:t+=r.content,this.re){let n=[...t.matchAll(this.re)];if(n.length>1){let i=0;for(let o of n.slice(0,-1))yield[o[1]],i+=(o.index??0)+o[0].length;t=t.slice(i)}}else{let n=await this.parse(t);if(n.length>1){for(let i of n.slice(0,-1))yield[i];t=n[n.length-1]}}for(let r of await this.parse(t))yield[r]}},y1=class extends tu{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 or(`Could not parse output: ${e}`,e)}}getFormatInstructions(){return"Your response should be a list of comma separated values, eg: `foo, bar, baz`"}},v1=class extends tu{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 or(`Incorrect number of items. Expected ${this.length}, got ${t.length}.`);return t}catch(t){throw Object.getPrototypeOf(t)===or.prototype?t:new or(`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\`)`}},b1=class extends tu{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:
256
-
257
- 1. foo
258
-
259
- 2. bar
260
-
261
- 3. baz`}re=/\d+\.\s([^\n]+)/g;async parse(e){return[...e.matchAll(this.re)??[]].map(t=>t[1])}},w1=class extends tu{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:
262
-
263
- 1. foo
264
-
265
- 2. bar
266
-
267
- 3. baz`}re=/^\s*[-*]\s([^\n]+)$/gm;async parse(e){return[...e.matchAll(this.re)??[]].map(t=>t[1])}};var x1=class extends Gi{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 ch=class extends pi{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?Po(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 uh=class extends An{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 or(`Failed to parse. Text: "${e}". Error: ${t}`,e)}}_baseMessageToString(e){return e.text}getFormatInstructions(){return""}};var Gl=class extends An{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=Ut.object(Object.fromEntries(Object.entries(e).map(([r,n])=>[r,Ut.string().describe(n)])));return new this(t)}getFormatInstructions(){return`You must format your output as a JSON value that adheres to a given "JSON Schema" instance.
268
-
269
- "JSON Schema" is a declarative language that allows you to annotate and validate JSON documents.
270
-
271
- For example, the example "JSON Schema" instance {{"properties": {{"foo": {{"description": "a list of test words", "type": "array", "items": {{"type": "string"}}}}}}, "required": ["foo"]}}
272
- 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.
273
- 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.
274
-
275
- 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!
276
-
277
- Here is the JSON Schema instance your output must adhere to. Include the enclosing markdown codeblock:
278
- \`\`\`json
279
- ${JSON.stringify(Ot(this.schema))}
280
- \`\`\`
281
- `}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,(n,i)=>`"${i.replace(/\n/g,"\\n")}"`).replace(/\n/g,"");return await Zo(this.schema,JSON.parse(r))}catch(t){throw new or(`Failed to parse. Text: "${e}". Error: ${t}`,e)}}_baseMessageToString(e){return e.text}},I0=class extends Gl{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:
282
- \`\`\`json
283
- ${this._schemaToInstruction(Ot(this.schema)).replaceAll("{","{".repeat(t)).replaceAll("}","}".repeat(t))}
284
- \`\`\``}_schemaToInstruction(e,t=2){let r=e;if("type"in r){let n=!1,i;if(Array.isArray(r.type)){let s=r.type.findIndex(c=>c==="null");s!==-1&&(n=!0,r.type.splice(s,1)),i=r.type.join(" | ")}else i=r.type;if(r.type==="object"&&r.properties){let s=r.description?` // ${r.description}`:"";return`{
285
- ${Object.entries(r.properties).map(([c,u])=>{let l=r.required?.includes(c)?"":" (optional)";return`${" ".repeat(t)}"${c}": ${this._schemaToInstruction(u,t+2)}${l}`}).join(`
286
- `)}
287
- ${" ".repeat(t-2)}}${s}`}if(r.type==="array"&&r.items){let s=r.description?` // ${r.description}`:"";return`array[
288
- ${" ".repeat(t)}${this._schemaToInstruction(r.items,t+2)}
289
- ${" ".repeat(t-2)}] ${s}`}let o=n?" (nullable)":"",a=r.description?` // ${r.description}`:"";return`${i}${a}${o}`}if("anyOf"in r)return r.anyOf.map(n=>this._schemaToInstruction(n,t)).join(`
290
- ${" ".repeat(t-2)}`);throw new Error("unsupported schema type")}static fromZodSchema(e){return new this(e)}static fromNamesAndDescriptions(e){let t=Ut.object(Object.fromEntries(Object.entries(e).map(([r,n])=>[r,Ut.string().describe(n)])));return new this(t)}},S1=class extends An{structuredInputParser;constructor({inputSchema:e}){super(...arguments),this.structuredInputParser=new I0(e)}async parse(e){let t;try{t=await this.structuredInputParser.parse(e)}catch(r){throw new or(`Failed to parse. Text: "${e}". Error: ${r}`,e)}return this.outputProcessor(t)}getFormatInstructions(){return this.structuredInputParser.getFormatInstructions()}};var U9=function(){let e={};e.parser=function(v,g){return new r(v,g)},e.SAXParser=r,e.SAXStream=u,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(v,g){if(!(this instanceof r))return new r(v,g);var P=this;i(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=!!v,P.noscript=!!(v||P.opt.noscript),P.state=b.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),N(P,"onready")}Object.create||(Object.create=function(v){function g(){}return g.prototype=v,new g}),Object.keys||(Object.keys=function(v){var g=[];for(var P in v)v.hasOwnProperty(P)&&g.push(P);return g});function n(v){for(var g=Math.max(e.MAX_BUFFER_LENGTH,10),P=0,I=0,Pe=t.length;I<Pe;I++){var Be=v[t[I]].length;if(Be>g)switch(t[I]){case"textNode":ie(v);break;case"cdata":W(v,"oncdata",v.cdata),v.cdata="";break;case"script":W(v,"onscript",v.script),v.script="";break;default:$e(v,"Max buffer length exceeded: "+t[I])}P=Math.max(P,Be)}v.bufferCheckPosition=e.MAX_BUFFER_LENGTH-P+v.position}function i(v){for(var g=0,P=t.length;g<P;g++)v[t[g]]=""}function o(v){ie(v),v.cdata!==""&&(W(v,"oncdata",v.cdata),v.cdata=""),v.script!==""&&(W(v,"onscript",v.script),v.script="")}r.prototype={end:function(){ct(this)},write:gn,resume:function(){return this.error=null,this},close:function(){return this.write(null)},flush:function(){o(this)}};var a=ReadableStream;a||(a=function(){});var s=e.EVENTS.filter(function(v){return v!=="error"&&v!=="end"});function c(v,g){return new u(v,g)}function u(v,g){if(!(this instanceof u))return new u(v,g);a.apply(this),this._parser=new r(v,g),this.writable=!0,this.readable=!0;var P=this;this._parser.onend=function(){P.emit("end")},this._parser.onerror=function(I){P.emit("error",I),P._parser.error=null},this._decoder=null,s.forEach(function(I){Object.defineProperty(P,"on"+I,{get:function(){return P._parser["on"+I]},set:function(Pe){if(!Pe)return P.removeAllListeners(I),P._parser["on"+I]=Pe,Pe;P.on(I,Pe)},enumerable:!0,configurable:!1})})}u.prototype=Object.create(a.prototype,{constructor:{value:u}}),u.prototype.write=function(v){return this._parser.write(v.toString()),this.emit("data",v),!0},u.prototype.end=function(v){return v&&v.length&&this.write(v),this._parser.end(),!0},u.prototype.on=function(v,g){var P=this;return!P._parser["on"+v]&&s.indexOf(v)!==-1&&(P._parser["on"+v]=function(){var I=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);I.splice(0,0,v),P.emit.apply(P,I)}),a.prototype.on.call(P,v,g)};var l="[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-]/,y=/[#:_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 x(v){return v===" "||v===`
291
- `||v==="\r"||v===" "}function S(v){return v==='"'||v==="'"}function E(v){return v===">"||x(v)}function C(v,g){return v.test(g)}function T(v,g){return!C(v,g)}var b=0;e.STATE={BEGIN:b++,BEGIN_WHITESPACE:b++,TEXT:b++,TEXT_ENTITY:b++,OPEN_WAKA:b++,SGML_DECL:b++,SGML_DECL_QUOTED:b++,DOCTYPE:b++,DOCTYPE_QUOTED:b++,DOCTYPE_DTD:b++,DOCTYPE_DTD_QUOTED:b++,COMMENT_STARTING:b++,COMMENT:b++,COMMENT_ENDING:b++,COMMENT_ENDED:b++,CDATA:b++,CDATA_ENDING:b++,CDATA_ENDING_2:b++,PROC_INST:b++,PROC_INST_BODY:b++,PROC_INST_ENDING:b++,OPEN_TAG:b++,OPEN_TAG_SLASH:b++,ATTRIB:b++,ATTRIB_NAME:b++,ATTRIB_NAME_SAW_WHITE:b++,ATTRIB_VALUE:b++,ATTRIB_VALUE_QUOTED:b++,ATTRIB_VALUE_CLOSED:b++,ATTRIB_VALUE_UNQUOTED:b++,ATTRIB_VALUE_ENTITY_Q:b++,ATTRIB_VALUE_ENTITY_U:b++,CLOSE_TAG:b++,CLOSE_TAG_SAW_WHITE:b++,SCRIPT:b++,SCRIPT_ENDING:b++},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(v){var g=e.ENTITIES[v],P=typeof g=="number"?String.fromCharCode(g):g;e.ENTITIES[v]=P});for(var L in e.STATE)e.STATE[e.STATE[L]]=L;b=e.STATE;function N(v,g,P){v[g]&&v[g](P)}function W(v,g,P){v.textNode&&ie(v),N(v,g,P)}function ie(v){v.textNode=_e(v.opt,v.textNode),v.textNode&&N(v,"ontext",v.textNode),v.textNode=""}function _e(v,g){return v.trim&&(g=g.trim()),v.normalize&&(g=g.replace(/\s+/g," ")),g}function $e(v,g){return ie(v),v.trackPosition&&(g+=`
292
- Line: `+v.line+`
293
- Column: `+v.column+`
294
- Char: `+v.c),g=new Error(g),v.error=g,N(v,"onerror",g),v}function ct(v){return v.sawRoot&&!v.closedRoot&&be(v,"Unclosed root tag"),v.state!==b.BEGIN&&v.state!==b.BEGIN_WHITESPACE&&v.state!==b.TEXT&&$e(v,"Unexpected end"),ie(v),v.c="",v.closed=!0,N(v,"onend"),r.call(v,v.strict,v.opt),v}function be(v,g){if(typeof v!="object"||!(v instanceof r))throw new Error("bad call to strictFail");v.strict&&$e(v,g)}function V(v){v.strict||(v.tagName=v.tagName[v.looseCase]());var g=v.tags[v.tags.length-1]||v,P=v.tag={name:v.tagName,attributes:{}};v.opt.xmlns&&(P.ns=g.ns),v.attribList.length=0,W(v,"onopentagstart",P)}function Y(v,g){var P=v.indexOf(":")<0?["",v]:v.split(":"),I=P[0],Pe=P[1];return g&&v==="xmlns"&&(I="xmlns",Pe=""),{prefix:I,local:Pe}}function oe(v){if(v.strict||(v.attribName=v.attribName[v.looseCase]()),v.attribList.indexOf(v.attribName)!==-1||v.tag.attributes.hasOwnProperty(v.attribName)){v.attribName=v.attribValue="";return}if(v.opt.xmlns){var g=Y(v.attribName,!0),P=g.prefix,I=g.local;if(P==="xmlns")if(I==="xml"&&v.attribValue!==f)be(v,"xml: prefix must be bound to "+f+`
295
- Actual: `+v.attribValue);else if(I==="xmlns"&&v.attribValue!==p)be(v,"xmlns: prefix must be bound to "+p+`
296
- Actual: `+v.attribValue);else{var Pe=v.tag,Be=v.tags[v.tags.length-1]||v;Pe.ns===Be.ns&&(Pe.ns=Object.create(Be.ns)),Pe.ns[I]=v.attribValue}v.attribList.push([v.attribName,v.attribValue])}else v.tag.attributes[v.attribName]=v.attribValue,W(v,"onattribute",{name:v.attribName,value:v.attribValue});v.attribName=v.attribValue=""}function ae(v,g){if(v.opt.xmlns){var P=v.tag,I=Y(v.tagName);P.prefix=I.prefix,P.local=I.local,P.uri=P.ns[I.prefix]||"",P.prefix&&!P.uri&&(be(v,"Unbound namespace prefix: "+JSON.stringify(v.tagName)),P.uri=I.prefix);var Pe=v.tags[v.tags.length-1]||v;P.ns&&Pe.ns!==P.ns&&Object.keys(P.ns).forEach(function(ua){W(v,"onopennamespace",{prefix:ua,uri:P.ns[ua]})});for(var Be=0,kt=v.attribList.length;Be<kt;Be++){var gt=v.attribList[Be],Wt=gt[0],Yr=gt[1],_t=Y(Wt,!0),Ln=_t.prefix,Ms=_t.local,Bd=Ln===""?"":P.ns[Ln]||"",K={name:Wt,value:Yr,prefix:Ln,local:Ms,uri:Bd};Ln&&Ln!=="xmlns"&&!Bd&&(be(v,"Unbound namespace prefix: "+JSON.stringify(Ln)),K.uri=Ln),v.tag.attributes[Wt]=K,W(v,"onattribute",K)}v.attribList.length=0}v.tag.isSelfClosing=!!g,v.sawRoot=!0,v.tags.push(v.tag),W(v,"onopentag",v.tag),g||(!v.noscript&&v.tagName.toLowerCase()==="script"?v.state=b.SCRIPT:v.state=b.TEXT,v.tag=null,v.tagName=""),v.attribName=v.attribValue="",v.attribList.length=0}function Oe(v){if(!v.tagName){be(v,"Weird empty close tag."),v.textNode+="</>",v.state=b.TEXT;return}if(v.script){if(v.tagName!=="script"){v.script+="</"+v.tagName+">",v.tagName="",v.state=b.SCRIPT;return}W(v,"onscript",v.script),v.script=""}var g=v.tags.length,P=v.tagName;v.strict||(P=P[v.looseCase]());for(var I=P;g--&&v.tags[g].name!==I;)be(v,"Unexpected close tag");if(g<0){be(v,"Unmatched closing tag: "+v.tagName),v.textNode+="</"+v.tagName+">",v.state=b.TEXT;return}v.tagName=P;for(var Pe=v.tags.length;Pe-- >g;){var Be=v.tag=v.tags.pop();v.tagName=v.tag.name,W(v,"onclosetag",v.tagName);var kt={};for(var gt in Be.ns)kt[gt]=Be.ns[gt];var Wt=v.tags[v.tags.length-1]||v;v.opt.xmlns&&Be.ns!==Wt.ns&&Object.keys(Be.ns).forEach(function(Yr){var _t=Be.ns[Yr];W(v,"onclosenamespace",{prefix:Yr,uri:_t})})}g===0&&(v.closedRoot=!0),v.tagName=v.attribValue=v.attribName="",v.attribList.length=0,v.state=b.TEXT}function zr(v){var g=v.entity,P=g.toLowerCase(),I,Pe="";return v.ENTITIES[g]?v.ENTITIES[g]:v.ENTITIES[P]?v.ENTITIES[P]:(g=P,g.charAt(0)==="#"&&(g.charAt(1)==="x"?(g=g.slice(2),I=parseInt(g,16),Pe=I.toString(16)):(g=g.slice(1),I=parseInt(g,10),Pe=I.toString(10))),g=g.replace(/^0+/,""),isNaN(I)||Pe.toLowerCase()!==g?(be(v,"Invalid character entity"),"&"+v.entity+";"):String.fromCodePoint(I))}function no(v,g){g==="<"?(v.state=b.OPEN_WAKA,v.startTagPosition=v.position):x(g)||(be(v,"Non-whitespace before first tag."),v.textNode=g,v.state=b.TEXT)}function io(v,g){var P="";return g<v.length&&(P=v.charAt(g)),P}function gn(v){var g=this;if(this.error)throw this.error;if(g.closed)return $e(g,"Cannot write after close. Assign an onready handler.");if(v===null)return ct(g);typeof v=="object"&&(v=v.toString());for(var P=0,I="";I=io(v,P++),g.c=I,!!I;)switch(g.trackPosition&&(g.position++,I===`
297
- `?(g.line++,g.column=0):g.column++),g.state){case b.BEGIN:if(g.state=b.BEGIN_WHITESPACE,I==="\uFEFF")continue;no(g,I);continue;case b.BEGIN_WHITESPACE:no(g,I);continue;case b.TEXT:if(g.sawRoot&&!g.closedRoot){for(var Pe=P-1;I&&I!=="<"&&I!=="&";)I=io(v,P++),I&&g.trackPosition&&(g.position++,I===`
298
- `?(g.line++,g.column=0):g.column++);g.textNode+=v.substring(Pe,P-1)}I==="<"&&!(g.sawRoot&&g.closedRoot&&!g.strict)?(g.state=b.OPEN_WAKA,g.startTagPosition=g.position):(!x(I)&&(!g.sawRoot||g.closedRoot)&&be(g,"Text data outside of root node."),I==="&"?g.state=b.TEXT_ENTITY:g.textNode+=I);continue;case b.SCRIPT:I==="<"?g.state=b.SCRIPT_ENDING:g.script+=I;continue;case b.SCRIPT_ENDING:I==="/"?g.state=b.CLOSE_TAG:(g.script+="<"+I,g.state=b.SCRIPT);continue;case b.OPEN_WAKA:if(I==="!")g.state=b.SGML_DECL,g.sgmlDecl="";else if(!x(I))if(C(h,I))g.state=b.OPEN_TAG,g.tagName=I;else if(I==="/")g.state=b.CLOSE_TAG,g.tagName="";else if(I==="?")g.state=b.PROC_INST,g.procInstName=g.procInstBody="";else{if(be(g,"Unencoded <"),g.startTagPosition+1<g.position){var Be=g.position-g.startTagPosition;I=new Array(Be).join(" ")+I}g.textNode+="<"+I,g.state=b.TEXT}continue;case b.SGML_DECL:(g.sgmlDecl+I).toUpperCase()===l?(W(g,"onopencdata"),g.state=b.CDATA,g.sgmlDecl="",g.cdata=""):g.sgmlDecl+I==="--"?(g.state=b.COMMENT,g.comment="",g.sgmlDecl=""):(g.sgmlDecl+I).toUpperCase()===d?(g.state=b.DOCTYPE,(g.doctype||g.sawRoot)&&be(g,"Inappropriately located doctype declaration"),g.doctype="",g.sgmlDecl=""):I===">"?(W(g,"onsgmldeclaration",g.sgmlDecl),g.sgmlDecl="",g.state=b.TEXT):(S(I)&&(g.state=b.SGML_DECL_QUOTED),g.sgmlDecl+=I);continue;case b.SGML_DECL_QUOTED:I===g.q&&(g.state=b.SGML_DECL,g.q=""),g.sgmlDecl+=I;continue;case b.DOCTYPE:I===">"?(g.state=b.TEXT,W(g,"ondoctype",g.doctype),g.doctype=!0):(g.doctype+=I,I==="["?g.state=b.DOCTYPE_DTD:S(I)&&(g.state=b.DOCTYPE_QUOTED,g.q=I));continue;case b.DOCTYPE_QUOTED:g.doctype+=I,I===g.q&&(g.q="",g.state=b.DOCTYPE);continue;case b.DOCTYPE_DTD:g.doctype+=I,I==="]"?g.state=b.DOCTYPE:S(I)&&(g.state=b.DOCTYPE_DTD_QUOTED,g.q=I);continue;case b.DOCTYPE_DTD_QUOTED:g.doctype+=I,I===g.q&&(g.state=b.DOCTYPE_DTD,g.q="");continue;case b.COMMENT:I==="-"?g.state=b.COMMENT_ENDING:g.comment+=I;continue;case b.COMMENT_ENDING:I==="-"?(g.state=b.COMMENT_ENDED,g.comment=_e(g.opt,g.comment),g.comment&&W(g,"oncomment",g.comment),g.comment=""):(g.comment+="-"+I,g.state=b.COMMENT);continue;case b.COMMENT_ENDED:I!==">"?(be(g,"Malformed comment"),g.comment+="--"+I,g.state=b.COMMENT):g.state=b.TEXT;continue;case b.CDATA:I==="]"?g.state=b.CDATA_ENDING:g.cdata+=I;continue;case b.CDATA_ENDING:I==="]"?g.state=b.CDATA_ENDING_2:(g.cdata+="]"+I,g.state=b.CDATA);continue;case b.CDATA_ENDING_2:I===">"?(g.cdata&&W(g,"oncdata",g.cdata),W(g,"onclosecdata"),g.cdata="",g.state=b.TEXT):I==="]"?g.cdata+="]":(g.cdata+="]]"+I,g.state=b.CDATA);continue;case b.PROC_INST:I==="?"?g.state=b.PROC_INST_ENDING:x(I)?g.state=b.PROC_INST_BODY:g.procInstName+=I;continue;case b.PROC_INST_BODY:if(!g.procInstBody&&x(I))continue;I==="?"?g.state=b.PROC_INST_ENDING:g.procInstBody+=I;continue;case b.PROC_INST_ENDING:I===">"?(W(g,"onprocessinginstruction",{name:g.procInstName,body:g.procInstBody}),g.procInstName=g.procInstBody="",g.state=b.TEXT):(g.procInstBody+="?"+I,g.state=b.PROC_INST_BODY);continue;case b.OPEN_TAG:C(_,I)?g.tagName+=I:(V(g),I===">"?ae(g):I==="/"?g.state=b.OPEN_TAG_SLASH:(x(I)||be(g,"Invalid character in tag name"),g.state=b.ATTRIB));continue;case b.OPEN_TAG_SLASH:I===">"?(ae(g,!0),Oe(g)):(be(g,"Forward-slash in opening tag not followed by >"),g.state=b.ATTRIB);continue;case b.ATTRIB:if(x(I))continue;I===">"?ae(g):I==="/"?g.state=b.OPEN_TAG_SLASH:C(h,I)?(g.attribName=I,g.attribValue="",g.state=b.ATTRIB_NAME):be(g,"Invalid attribute name");continue;case b.ATTRIB_NAME:I==="="?g.state=b.ATTRIB_VALUE:I===">"?(be(g,"Attribute without value"),g.attribValue=g.attribName,oe(g),ae(g)):x(I)?g.state=b.ATTRIB_NAME_SAW_WHITE:C(_,I)?g.attribName+=I:be(g,"Invalid attribute name");continue;case b.ATTRIB_NAME_SAW_WHITE:if(I==="=")g.state=b.ATTRIB_VALUE;else{if(x(I))continue;be(g,"Attribute without value"),g.tag.attributes[g.attribName]="",g.attribValue="",W(g,"onattribute",{name:g.attribName,value:""}),g.attribName="",I===">"?ae(g):C(h,I)?(g.attribName=I,g.state=b.ATTRIB_NAME):(be(g,"Invalid attribute name"),g.state=b.ATTRIB)}continue;case b.ATTRIB_VALUE:if(x(I))continue;S(I)?(g.q=I,g.state=b.ATTRIB_VALUE_QUOTED):(be(g,"Unquoted attribute value"),g.state=b.ATTRIB_VALUE_UNQUOTED,g.attribValue=I);continue;case b.ATTRIB_VALUE_QUOTED:if(I!==g.q){I==="&"?g.state=b.ATTRIB_VALUE_ENTITY_Q:g.attribValue+=I;continue}oe(g),g.q="",g.state=b.ATTRIB_VALUE_CLOSED;continue;case b.ATTRIB_VALUE_CLOSED:x(I)?g.state=b.ATTRIB:I===">"?ae(g):I==="/"?g.state=b.OPEN_TAG_SLASH:C(h,I)?(be(g,"No whitespace between attributes"),g.attribName=I,g.attribValue="",g.state=b.ATTRIB_NAME):be(g,"Invalid attribute name");continue;case b.ATTRIB_VALUE_UNQUOTED:if(!E(I)){I==="&"?g.state=b.ATTRIB_VALUE_ENTITY_U:g.attribValue+=I;continue}oe(g),I===">"?ae(g):g.state=b.ATTRIB;continue;case b.CLOSE_TAG:if(g.tagName)I===">"?Oe(g):C(_,I)?g.tagName+=I:g.script?(g.script+="</"+g.tagName,g.tagName="",g.state=b.SCRIPT):(x(I)||be(g,"Invalid tagname in closing tag"),g.state=b.CLOSE_TAG_SAW_WHITE);else{if(x(I))continue;T(h,I)?g.script?(g.script+="</"+I,g.state=b.SCRIPT):be(g,"Invalid tagname in closing tag."):g.tagName=I}continue;case b.CLOSE_TAG_SAW_WHITE:if(x(I))continue;I===">"?Oe(g):be(g,"Invalid characters in closing tag");continue;case b.TEXT_ENTITY:case b.ATTRIB_VALUE_ENTITY_Q:case b.ATTRIB_VALUE_ENTITY_U:var kt,gt;switch(g.state){case b.TEXT_ENTITY:kt=b.TEXT,gt="textNode";break;case b.ATTRIB_VALUE_ENTITY_Q:kt=b.ATTRIB_VALUE_QUOTED,gt="attribValue";break;case b.ATTRIB_VALUE_ENTITY_U:kt=b.ATTRIB_VALUE_UNQUOTED,gt="attribValue";break}if(I===";")if(g.opt.unparsedEntities){var Wt=zr(g);g.entity="",g.state=kt,g.write(Wt)}else g[gt]+=zr(g),g.entity="",g.state=kt;else C(g.entity.length?w:y,I)?g.entity+=I:(be(g,"Invalid character in entity name"),g[gt]+="&"+g.entity+I,g.entity="",g.state=kt);continue;default:throw new Error(g,"Unknown state: "+g.state)}return g.position>=g.bufferCheckPosition&&n(g),g}return String.fromCodePoint||(function(){var v=String.fromCharCode,g=Math.floor,P=function(){var I=16384,Pe=[],Be,kt,gt=-1,Wt=arguments.length;if(!Wt)return"";for(var Yr="";++gt<Wt;){var _t=Number(arguments[gt]);if(!isFinite(_t)||_t<0||_t>1114111||g(_t)!==_t)throw RangeError("Invalid code point: "+_t);_t<=65535?Pe.push(_t):(_t-=65536,Be=(_t>>10)+55296,kt=_t%1024+56320,Pe.push(Be,kt)),(gt+1===Wt||Pe.length>I)&&(Yr+=v.apply(null,Pe),Pe.length=0)}return Yr};Object.defineProperty?Object.defineProperty(String,"fromCodePoint",{value:P,configurable:!0,writable:!0}):String.fromCodePoint=P})(),e},k1=U9();var lh=`The output should be formatted as a XML file.
299
- 1. Output should conform to the tags below.
300
- 2. If tags are not given, make them on your own.
301
- 3. Remember to always open and close all the tags.
302
-
303
- As an example, for the tags ["foo", "bar", "baz"]:
304
- 1. String "<foo>
305
- <bar>
306
- <baz></baz>
307
- </bar>
308
- </foo>" is a well-formatted instance of the schema.
309
- 2. String "<foo>
310
- <bar>
311
- </foo>" is a badly-formatted instance.
312
- 3. String "<foo>
313
- <tag>
314
- </tag>
315
- </foo>" is a badly-formatted instance.
316
-
317
- Here are the output tags:
318
- \`\`\`
319
- {tags}
320
- \`\`\``,E1=class extends pi{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?Po(e,t):[{op:"replace",path:"",value:t}]}async parsePartialResult(e){return dh(e[0].text)}async parse(e){return dh(e)}getFormatInstructions(){return this.tags&&this.tags.length>0?lh.replace("{tags}",this.tags?.join(", ")??""):lh}},L9=e=>e.split(`
321
- `).map(t=>t.replace(/^\s+/,"")).join(`
322
- `).trim(),I1=e=>{if(Object.keys(e).length===0)return{};let t={};return e.children.length>0?(t[e.name]=e.children.map(I1),t):(t[e.name]=e.text??void 0,t)};function dh(e){let t=L9(e),r=k1.parser(!0),n={},i=[];r.onopentag=s=>{let c={name:s.name,attributes:s.attributes,children:[],text:"",isSelfClosing:s.isSelfClosing};i.length>0?i[i.length-1].children.push(c):n=c,s.isSelfClosing||i.push(c)},r.onclosetag=()=>{if(i.length>0){let s=i.pop();i.length===0&&s&&(n=s)}},r.ontext=s=>{if(i.length>0){let c=i[i.length-1];c.text+=s}},r.onattribute=s=>{if(i.length>0){let c=i[i.length-1];c.attributes[s.name]=s.value}};let o=/```(xml)?(.*)```/s.exec(t),a=o?o[2]:t;return r.write(a).close(),n&&n.name==="?xml"&&(n=n.children[0]),I1(n)}var $1=A({AsymmetricStructuredOutputParser:()=>S1,BaseCumulativeTransformOutputParser:()=>pi,BaseLLMOutputParser:()=>eu,BaseOutputParser:()=>An,BaseTransformOutputParser:()=>Gi,BytesOutputParser:()=>_1,CommaSeparatedListOutputParser:()=>y1,CustomListOutputParser:()=>v1,JsonMarkdownStructuredOutputParser:()=>I0,JsonOutputParser:()=>ch,ListOutputParser:()=>tu,MarkdownListOutputParser:()=>w1,NumberedListOutputParser:()=>b1,OutputParserException:()=>or,StandardSchemaOutputParser:()=>uh,StringOutputParser:()=>x1,StructuredOutputParser:()=>Gl,XMLOutputParser:()=>E1,XML_FORMAT_INSTRUCTIONS:()=>lh,parseJsonMarkdown:()=>va,parsePartialJson:()=>qn,parseXMLMarkdown:()=>dh});var T1=A({extendInteropZodObject:()=>Nm,getInteropZodDefaultGetter:()=>Rm,getInteropZodObjectShape:()=>Ui,getSchemaDescription:()=>Li,interopParse:()=>Go,interopParseAsync:()=>Zo,interopSafeParse:()=>cP,interopSafeParseAsync:()=>Pm,interopZodObjectMakeFieldsOptional:()=>lP,interopZodObjectPartial:()=>Wo,interopZodObjectPassthrough:()=>Om,interopZodObjectStrict:()=>Bc,interopZodTransformInputSchema:()=>jm,isInteropZodError:()=>Mm,isInteropZodLiteral:()=>sP,isInteropZodObject:()=>rr,isInteropZodSchema:()=>Pr,isShapelessZodSchema:()=>uP,isSimpleStringZodSchema:()=>Vc,isZodArrayV4:()=>Rl,isZodLiteralV3:()=>Zx,isZodLiteralV4:()=>Gx,isZodNullableV4:()=>qx,isZodObjectV3:()=>Nl,isZodObjectV4:()=>an,isZodOptionalV4:()=>Wx,isZodSchema:()=>aP,isZodSchemaV3:()=>mt,isZodSchemaV4:()=>Je});function $0(e,t){if(e.function===void 0)return;let r;if(t?.partial)try{r=qn(e.function.arguments??"{}")}catch{return}else try{r=JSON.parse(e.function.arguments)}catch(i){throw new or([`Function "${e.function.name}" arguments:`,"",e.function.arguments,"","are not valid JSON.",`Error: ${i.message}`].join(`
323
- `))}let n={name:e.function.name,args:r,type:"tool_call"};return t?.returnId&&(n.id=e.id),n}function A1(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 C1(e,t){return{name:e.function?.name,args:e.function?.arguments,id:e.id,error:t,type:"invalid_tool_call"}}var T0=class extends pi{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,n;if(qs(r)&&r.tool_calls?.length?n=r.tool_calls.map(o=>{let{id:a,...s}=o;return this.returnId?{id:a,...s}:s}):r.additional_kwargs.tool_calls!==void 0&&(n=JSON.parse(JSON.stringify(r.additional_kwargs.tool_calls)).map(o=>$0(o,{returnId:this.returnId,partial:t}))),!n)return[];let i=[];for(let o of n)if(o!==void 0){let a={type:o.name,args:o.args,id:o.id};i.push(a)}return i}},fh=class extends T0{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 or(`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 Pm(this.zodSchema,e);if(t.success)return t.data;throw new or(`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(n=>n.type===this.keyName),r=t;if(t.length)return this.returnId||(r=t.map(n=>n.args)),this.returnSingle?r[0]:r}async parseResult(e){let t=(await super.parsePartialResult(e,!1)).filter(n=>n.type===this.keyName),r=t;if(t.length)return this.returnId||(r=t.map(n=>n.args)),this.returnSingle?this._validateResult(r[0]):await Promise.all(r.map(n=>this._validateResult(n)))}};var O1=A({assembleStructuredOutputPipeline:()=>A0,createContentParser:()=>F9,createFunctionCallingParser:()=>B9});function F9(e){return Pr(e)?Gl.fromZodSchema(e):Ja(e)?uh.fromSerializableSchema(e):new ch}function B9(e,t,r){let n=r??fh;return Pr(e)?new n({returnSingle:!0,keyName:t,zodSchema:e}):Ja(e)?new n({returnSingle:!0,keyName:t,serializableSchema:e}):new n({returnSingle:!0,keyName:t})}function A0(e,t,r,n){if(!r){let c=e.pipe(t);return n?c.withConfig({runName:n}):c}let i=Zi.assign({parsed:(c,u)=>t.invoke(c.raw,u)}),o=Zi.assign({parsed:()=>null}),a=i.withFallbacks({fallbacks:[o]}),s=Jr.from([{raw:e},a]);return n?s.withConfig({runName:n}):s}var N1=A({ChatModelStream:()=>Qo,ReasoningContentStream:()=>M1,TextContentStream:()=>R1,ToolCallsStream:()=>j1,UsageMetadataStream:()=>D1}),V9=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 H9(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 Wl(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 P1(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 ph(e){if(e==null||typeof e!="object")return!1;let t=e.type;return t==="reasoning"||t==="thinking"}function ru(e){if(e)return{...e,input_tokens:e.input_tokens??0,output_tokens:e.output_tokens??0,total_tokens:e.total_tokens??0}}function Z9(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 G9(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 n=t.args??t.input;return{...t,type:"tool_call",name:r,args:Z9(n)}}var R1=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 n=Wl(r);n?.type==="text-delta"&&(t+=n.text,yield t)}}}}[Symbol.asyncIterator](){let e=this._buffer;async function*t(){for await(let r of e.iterate()){let n=Wl(r);n?.type==="text-delta"&&(yield n.text)}}return t()}then(e,t){return(async()=>{let r="";for await(let n of this)r+=n;return r})().then(e,t)}},j1=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 n of this)r.push(n);return r})().then(e,t)}},M1=class{_buffer;constructor(e){this._buffer=e}get full(){let e=this._buffer;return{async*[Symbol.asyncIterator](){let t="",r=!1;for await(let n of e.iterate())if(n.event==="content-block-start"){if(!ph(n.content)){if(r)return;continue}r=!0;let i=P1(n.content);if(i==null||i.length===0)continue;t+=i,yield t}else if(n.event==="content-block-delta"){let i=Wl(n);if(i?.type!=="reasoning-delta")continue;r=!0;let o=i.reasoning;if(o==null||o.length===0)continue;t+=o,yield t}else{if(n.event==="content-block-finish"&&ph(n.content))return;if(n.event==="message-finish")return}}}}[Symbol.asyncIterator](){let e=this._buffer;async function*t(){let r=!1;for await(let n of e.iterate())if(n.event==="content-block-start"){if(!ph(n.content)){if(r)return;continue}r=!0;let i=P1(n.content);i!=null&&i.length>0&&(yield i)}else if(n.event==="content-block-delta"){let i=Wl(n);if(i?.type!=="reasoning-delta")continue;r=!0;let o=i.reasoning;o!=null&&o.length>0&&(yield o)}else{if(n.event==="content-block-finish"&&ph(n.content))return;if(n.event==="message-finish")return}}return t()}then(e,t){return(async()=>{let r="";for await(let n of this)r+=n;return r})().then(e,t)}},D1=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 n=ru(r.usage);n&&(yield n)}else if(r.event==="message-start"&&r.usage){let n=ru(r.usage);n&&(yield n)}else if(r.event==="message-finish"&&r.usage){let n=ru(r.usage);n&&(yield n)}}return t()}then(e,t){return(async()=>{let r;for await(let n of this)r=n;return r})().then(e,t)}},Qo=class{_buffer;constructor(e){this._buffer=new V9,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 R1(this._buffer)}get toolCalls(){return new j1(this._buffer)}get reasoning(){return new M1(this._buffer)}get usage(){return new D1(this._buffer)}get output(){return this._assembleMessage()}then(e,t){return this._assembleMessage().then(e,t)}async _assembleMessage(){let e=[],t,r,n={},i;for await(let a of this._buffer.iterate())switch(a.event){case"message-start":t=a.id??t,a.usage&&(r=ru(a.usage));break;case"content-block-start":e[a.index]=a.content;break;case"content-block-delta":{let s=e[a.index],c=Wl(a);s&&c&&(e[a.index]=H9(s,c));break}case"content-block-finish":e[a.index]=a.content;break;case"usage":r=ru(a.usage);break;case"message-finish":i=a.reason,a.usage&&(r=ru(a.usage)),a.responseMetadata&&(n={...n,...a.responseMetadata});break;default:break}let o=e.filter(a=>a!=null).map(G9);return new je({id:t,content:o,usage_metadata:r,response_metadata:{...n,...i?{finish_reason:i}:{},output_version:"v1"}})}};var U1=A({convertChunksToEvents:()=>C0,finalizeContentBlock:()=>mh}),W9={wav:"audio/wav",mp3:"audio/mpeg",flac:"audio/flac",opus:"audio/opus",aac:"audio/aac",pcm16:"audio/pcm"},q9={png:"image/png",jpeg:"image/jpeg",jpg:"image/jpeg",webp:"image/webp",gif:"image/gif"};function z1(e){let t=0;for(let r of e.keys())r>=t&&(t=r+1);return t}function L1(e){let t=e.additional_kwargs;return t!=null&&typeof t=="object"?t:{}}function K9(e){let t=L1(e).tool_outputs;if(!Array.isArray(t))return[];let r=[];for(let n of t){if(n==null||typeof n!="object")continue;let i=n;if(i.type!=="image_generation_call")continue;let o=typeof i.result=="string"?i.result:void 0,a=typeof i.url=="string"?i.url:void 0;if(o==null&&a==null)continue;let s=typeof i.output_format=="string"?i.output_format.toLowerCase():void 0,c=(s!=null?q9[s]:void 0)??"image/png";r.push({type:"image",...typeof i.id=="string"?{id:i.id}:{},...a!=null?{url:a}:{},...o!=null?{data:o}:{},mimeType:c})}return r}function J9(e){let t=L1(e).audio;if(t==null||typeof t!="object")return;let r=t,n=typeof r.data=="string"?r.data:void 0,i=typeof r.url=="string"?r.url:void 0,o=typeof r.transcript=="string"?r.transcript:void 0;if(n==null&&i==null&&o==null)return;let a=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=a??(s!=null?W9[s]:void 0)??(n!=null?"audio/wav":"audio/pcm");return{...typeof r.id=="string"?{id:r.id}:{},...n!=null?{data:n}:{},...i!=null?{url:i}:{},...o!=null?{transcript:o}:{},mimeType:c}}async function*C0(e,t){let r=new Map,n=!1,i,o,a=new Set;for await(let s of e){t?.signal?.throwIfAborted();let c=s.message,u=!1;if(!n){n=!0;let f={event:"message-start",id:c.id??void 0};ut.isInstance(c)&&c.usage_metadata&&(f.usage=c.usage_metadata,i={...c.usage_metadata},u=!0),yield f}let l=c.content;if(typeof l=="string"){if(l!==""){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??"")+l},yield{event:"content-block-delta",index:0,delta:{type:"text-delta",text:l}}}}else if(Array.isArray(l))for(let f of l){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=Y9(f);m.accumulated=X9(m.accumulated,h),yield{event:"content-block-delta",index:p,delta:h}}}if(ut.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=J9(c);if(d!=null){if(o==null){let p=z1(r);o={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(o.index);if(f!=null){let p=f.accumulated;d.id!=null&&o.id==null&&(o.id=d.id,p.id=d.id),d.transcript!=null&&(o.transcript+=d.transcript,p.transcript=o.transcript,yield{event:"content-block-delta",index:o.index,delta:{type:"block-delta",fields:{type:"audio",transcript:o.transcript}}}),d.data!=null&&d.data.length>0&&(p.data=(p.data??"")+d.data,yield{event:"content-block-delta",index:o.index,delta:{type:"data-delta",data:d.data,encoding:"base64"}})}}for(let f of K9(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&&a.has(m))continue;m!=null&&a.add(m);let h=z1(r);r.set(h,{type:"image",accumulated:f}),yield{event:"content-block-start",index:h,content:f}}if(!u&&ut.isInstance(c)&&c.usage_metadata){let f=c.usage_metadata;i?i={input_tokens:i.input_tokens+f.input_tokens,output_tokens:i.output_tokens+f.output_tokens,total_tokens:i.total_tokens+f.total_tokens}:i={...f},yield{event:"usage",usage:{...i}}}}for(let[s,c]of r)yield{event:"content-block-finish",index:s,content:mh(c.accumulated)};yield{event:"message-finish",reason:"stop",...i?{usage:i}:{}}}function X9(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 Y9(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 mh(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 F1=e=>e();function ql(e){let t=e.constructor;return new t({...e,content:e.contentBlocks,response_metadata:{...e.response_metadata,output_version:"v1"}})}var B1=A({BaseChatModel:()=>ea,SimpleChatModel:()=>Q9});function O0(e){let t=[];for(let r of e){let n=r;if(Array.isArray(r.content))for(let i=0;i<r.content.length;i++){let o=r.content[i];(Vs(o)||Hs(o))&&n===r&&(n=new r.constructor({...n,content:[...r.content.slice(0,i),mf(o),...r.content.slice(i+1)]}))}t.push(n)}return t}var ea=class mi extends Zl{lc_namespace=["langchain","chat_models",this._llmType()];disableStreaming=!1;outputVersion;get callKeys(){return[...super.callKeys,"outputVersion"]}constructor(t){super(t),this.outputVersion=F1(()=>{let r=t.outputVersion??pr("LC_OUTPUT_VERSION");return r&&["v0","v1"].includes(r)?r:"v0"})}_separateRunnableConfigFromCallOptionsCompat(t){let[r,n]=super._separateRunnableConfigFromCallOptions(t);return n.signal=r.signal,[r,n]}async invoke(t,r){let n=mi._convertInputToPromptValue(t);return(await this.generatePrompt([n],r,r?.callbacks)).generations[0][0].message}async*_streamResponseChunks(t,r,n){throw new Error("Not implemented.")}async*_streamChatModelEvents(t,r,n){yield*C0(this._streamResponseChunks(t,r,n),{signal:r.signal})}streamEvents(t,r,n){if(r?.version==="v1"||r?.version==="v2")return super.streamEvents(t,r,n);let i=mi._convertInputToPromptValue(t).toChatMessages(),[,o]=this._separateRunnableConfigFromCallOptionsCompat(r);return new Qo(this._streamChatModelEvents(i,o))}streamV2(t,r){return this.streamEvents(t,r)}async*_streamIterator(t,r){if(this._streamResponseChunks===mi.prototype._streamResponseChunks||this.disableStreaming)yield this.invoke(t,r);else{let n=mi._convertInputToPromptValue(t).toChatMessages(),[i,o]=this._separateRunnableConfigFromCallOptionsCompat(r),a={...i.metadata,...this.getLsParamsWithDefaults(o)},s=this.invocationParams(o),c=await tt.configure(i.callbacks,this.callbacks,i.tags,this.tags,a,this.metadata,{verbose:this.verbose,tracerInheritableMetadata:this._filterInvocationParamsForTracing(s)}),u={options:o,invocation_params:s,batch_size:1},l=o.outputVersion??this.outputVersion,d=await c?.handleChatModelStart(this.toJSON(),[O0(n)],i.runId,void 0,u,void 0,void 0,i.runName),f,p;try{for await(let m of this._streamResponseChunks(n,o,d?.[0])){if(o.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},l==="v1"?yield ql(m.message):yield m.message,f?f=f.concat(m):f=m,Gu(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}})}o.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,n,i){let o=t.map(p=>p.map(Tt)),a;if(i!==void 0&&i.length===o.length)a=i;else{let p={...n.metadata,...this.getLsParamsWithDefaults(r)},m=this.invocationParams(r),h=await tt.configure(n.callbacks,this.callbacks,n.tags,this.tags,p,this.metadata,{verbose:this.verbose,tracerInheritableMetadata:this._filterInvocationParamsForTracing(m)}),_={options:r,invocation_params:m,batch_size:1};a=await h?.handleChatModelStart(this.toJSON(),o.map(O0),n.runId,void 0,_,void 0,void 0,n.runName)}let s=r.outputVersion??this.outputVersion,c=[],u=[],l=!!a?.[0].handlers.find(E_),d=!!a?.[0].handlers.find(qu);if(l&&!this.disableStreaming&&o.length===1&&(this._streamChatModelEvents!==mi.prototype._streamChatModelEvents||this._streamResponseChunks!==mi.prototype._streamResponseChunks))try{let p=!1,m=a?.[0],h=this._streamChatModelEvents(o[0],r),_=await new Qo({async*[Symbol.asyncIterator](){for await(let x of h){r.signal?.throwIfAborted(),p=!0;let S=x.event==="message-start"&&x.id==null&&m?.runId!=null?{...x,id:`run-${m.runId}`}:x;await m?.handleChatModelStreamEvent(S),yield S}}});if(r.signal?.throwIfAborted(),!p)throw new Error("Received empty response from chat model call.");if(_.id==null){let x=a?.at(0)?.runId;x!=null&&_._updateId(`run-${x}`)}let y={text:_.text,message:_};c.push([y]);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 a?.[0].handleLLMEnd({generations:c,llmOutput:w})}catch(p){throw await a?.[0].handleLLMError(p),p}else if(d&&!this.disableStreaming&&o.length===1&&this._streamResponseChunks!==mi.prototype._streamResponseChunks)try{let p=await this._streamResponseChunks(o[0],r,a?.[0]),m,h;for await(let _ of p){if(r.signal?.aborted){let y=m?.message;throw new ff("Model invocation was aborted.",y)}if(_.message.id==null){let y=a?.at(0)?.runId;y!=null&&_.message._updateId(`run-${y}`)}m===void 0?m=_:m=Zr(m,_),Gu(_.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 ff("Model invocation was aborted.",_)}if(m===void 0)throw new Error("Received empty response from chat model call.");s==="v1"&&(m.message=ql(m.message)),c.push([m]),await a?.[0].handleLLMEnd({generations:c,llmOutput:h})}catch(p){throw await a?.[0].handleLLMError(p),p}else{let p=await Promise.allSettled(o.map(async(m,h)=>{let _=await this._generate(m,{...r,promptIndex:h},a?.[h]);if(s==="v1")for(let y of _.generations)y.message=ql(y.message);return _}));await Promise.all(p.map(async(m,h)=>{if(m.status==="fulfilled"){let _=m.value;for(let y of _.generations){if(y.message.id==null){let w=a?.at(0)?.runId;w!=null&&y.message._updateId(`run-${w}`)}y.message.response_metadata={...y.generationInfo,...y.message.response_metadata}}return _.generations.length===1&&(_.generations[0].message.response_metadata={..._.llmOutput,..._.generations[0].message.response_metadata}),c[h]=_.generations,u[h]=_.llmOutput,a?.[h]?.handleLLMEnd({generations:[_.generations],llmOutput:_.llmOutput})}else return await a?.[h]?.handleLLMError(m.reason),Promise.reject(m.reason)}))}let f={generations:c,llmOutput:u.length?this._combineLLMOutput?.(...u):void 0};return Object.defineProperty(f,Ka,{value:a?{runIds:a?.map(p=>p.runId)}:void 0,configurable:!0}),f}async _generateCached({messages:t,cache:r,llmStringKey:n,parsedOptions:i,handledOptions:o}){let a=t.map(y=>y.map(Tt)),s={...o.metadata,...this.getLsParamsWithDefaults(i)},c=this.invocationParams(i),u=await tt.configure(o.callbacks,this.callbacks,o.tags,this.tags,s,this.metadata,{verbose:this.verbose,tracerInheritableMetadata:this._filterInvocationParamsForTracing(c)}),l={options:i,invocation_params:c,batch_size:1},d=await u?.handleChatModelStart(this.toJSON(),a.map(O0),o.runId,void 0,l,void 0,void 0,o.runName),f=[],p=(await Promise.allSettled(a.map(async(y,w)=>{let x=mi._convertInputToPromptValue(y).toString(),S=await r.lookup(x,n);return S==null&&f.push(w),S}))).map((y,w)=>({result:y,runManager:d?.[w]})).filter(({result:y})=>y.status==="fulfilled"&&y.value!=null||y.status==="rejected"),m=i.outputVersion??this.outputVersion,h=[];await Promise.all(p.map(async({result:y,runManager:w},x)=>{if(y.status==="fulfilled"){let S=y.value;return h[x]=S.map(E=>("message"in E&&ot(E.message)&&qs(E.message)&&(E.message.usage_metadata={input_tokens:0,output_tokens:0,total_tokens:0},m==="v1"&&(E.message=ql(E.message))),E.generationInfo={...E.generationInfo,tokenUsage:{}},E)),S.length&&await w?.handleLLMNewToken(S[0].text),w?.handleLLMEnd({generations:[S]},void 0,void 0,void 0,{cached:!0})}else return await w?.handleLLMError(y.reason,void 0,void 0,void 0,{cached:!0}),Promise.reject(y.reason)}));let _={generations:h,missingPromptIndices:f,startedRunManagers:d};return Object.defineProperty(_,Ka,{value:d?{runIds:d?.map(y=>y.runId)}:void 0,configurable:!0}),_}async generate(t,r,n){let i;Array.isArray(r)?i={stop:r}:i=r;let o=t.map(m=>m.map(Tt)),[a,s]=this._separateRunnableConfigFromCallOptionsCompat(i);if(a.callbacks=a.callbacks??n,!this.cache)return this._generateUncached(o,s,a);let{cache:c}=this,u=this._getSerializedCacheKeyParametersForCall(s),{generations:l,missingPromptIndices:d,startedRunManagers:f}=await this._generateCached({messages:o,cache:c,llmStringKey:u,parsedOptions:s,handledOptions:a}),p={};if(d.length>0){let m=await this._generateUncached(d.map(h=>o[h]),s,a,f!==void 0?d.map(h=>f?.[h]):void 0);await Promise.all(m.generations.map(async(h,_)=>{let y=d[_];l[y]=h;let w=mi._convertInputToPromptValue(o[y]).toString();return c.update(w,u,h)})),p=m.llmOutput??{}}return{generations:l,llmOutput:p}}invocationParams(t){return{}}_modelType(){return"base_chat_model"}async generatePrompt(t,r,n){let i=t.map(o=>o.toChatMessages());return this.generate(i,r,n)}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 n=t,i=r?.name,o=Li(n)??"A function available to call.",a=r?.method,s=r?.includeRaw;if(a==="jsonMode")throw new Error('Base withStructuredOutput implementation only supports "functionCalling" as a method.');let c=i??"extract";!Pr(n)&&!Ja(n)&&"name"in n&&(c=n.name);let u=Pr(n)||Ja(n)?Ot(n):n,l=[{type:"function",function:{name:c,description:o,parameters:u}}];return A0(this.bindTools(l),ir.from(d=>{if(!ut.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")}},Q9=class extends ea{async _generate(e,t,r){let n=new je(await this._call(e,t,r));if(typeof n.content!="string")throw new Error("Cannot generate with a simple chat model when output is not a string.");return{generations:[{text:n.content,message:n}]}}};var V1=A({convertOpenAICompletionsStream:()=>eH});async function*eH(e,t={}){let r=t.streamUsage??!0,n=t.provider??"openai",i=t.mapChunk,o=new Map,a=new Map,s=0,c=!1,u,l,d,f=!1,p=(m,h)=>{let _=a.get(m);if(_!==void 0)return{index:_,isNew:!1};let y=s++;return a.set(m,y),o.set(y,{...h}),{index:y,isNew:!0}};for await(let m of e){i&&(m=i(m)),c||(c=!0,yield{event:"message-start",id:m.id}),!f&&(m.model||m.service_tier)&&(f=!0,yield{event:"provider",provider:n,name:"stream_metadata",payload:{model:m.model,service_tier:m.service_tier}}),m.usage&&r&&(u=iH(m.usage),yield{event:"usage",usage:u});let h=m.x_groq?.usage;h&&r&&(u=rH(h),yield{event:"usage",usage:u});let _=m.choices?.[0];if(!_)continue;_.finish_reason!=null&&(l=nH(_.finish_reason),d=oH(m,_));let{delta:y}=_;if(!y)continue;let w=tH(y);if(w){let{index:x,isNew:S}=p("reasoning",{type:"reasoning",reasoning:""});S&&(yield{event:"content-block-start",index:x,content:{type:"reasoning",reasoning:""}});let E=o.get(x);E.reasoning=(E.reasoning??"")+w,yield{event:"content-block-delta",index:x,delta:{type:"reasoning-delta",reasoning:w}}}if(y.content){let{index:x,isNew:S}=p("text",{type:"text",text:""});S&&(yield{event:"content-block-start",index:x,content:{type:"text",text:""}});let E=o.get(x);E.text=(E.text??"")+y.content,yield{event:"content-block-delta",index:x,delta:{type:"text-delta",text:y.content}}}if(Array.isArray(y.tool_calls))for(let x of y.tool_calls){let S=x.index??0,{index:E,isNew:C}=p(`tool:${S}`,{type:"tool_call_chunk",id:x.id,name:x.function?.name,args:"",index:S});C&&(yield{event:"content-block-start",index:E,content:{type:"tool_call_chunk",id:x.id,name:x.function?.name,args:"",index:S}});let T=o.get(E);x.id!=null&&(T.id=x.id),x.function?.name!=null&&(T.name=x.function.name);let b=x.function?.arguments??"";T.args=(T.args??"")+b,yield{event:"content-block-delta",index:E,delta:{type:"block-delta",fields:{type:"tool_call_chunk",...T.id!=null?{id:T.id}:{},...T.name!=null?{name:T.name}:{},args:T.args}}}}if(y.audio){let{index:x,isNew:S}=p("audio",{type:"audio",id:y.audio.id,data:"",mimeType:"audio/pcm",transcript:y.audio.transcript??""});S&&(yield{event:"content-block-start",index:x,content:{type:"audio",id:y.audio.id,data:"",mimeType:"audio/pcm",transcript:y.audio.transcript??""}});let E=o.get(x);y.audio.transcript&&(E.transcript=(E.transcript??"")+y.audio.transcript,yield{event:"content-block-delta",index:x,delta:{type:"block-delta",fields:{type:"audio",transcript:E.transcript}}}),y.audio.data&&(E.data=(E.data??"")+y.audio.data,yield{event:"content-block-delta",index:x,delta:{type:"data-delta",data:y.audio.data,encoding:"base64"}})}y.function_call&&(yield{event:"provider",provider:n,name:"function_call",payload:y.function_call}),_.logprobs&&(yield{event:"provider",provider:n,name:"logprobs",payload:_.logprobs})}for(let[m,h]of o)yield{event:"content-block-finish",index:m,content:mh(h)};yield{event:"message-finish",reason:l,...u?{usage:u}:{},...d?{responseMetadata:d}:{}}}function tH(e){let t=e.reasoning_content??e.reasoning;return typeof t=="string"&&t.length>0?t:void 0}function rH(e){return{input_tokens:e.prompt_tokens??0,output_tokens:e.completion_tokens??0,total_tokens:e.total_tokens??0}}function nH(e){switch(e){case"stop":return"stop";case"length":case"max_tokens":return"length";case"tool_calls":case"function_call":return"tool_use";case"content_filter":return"content_filter";default:return"stop"}}function iH(e){let t={...e.prompt_tokens_details?.audio_tokens!=null&&{audio:e.prompt_tokens_details.audio_tokens},...e.prompt_tokens_details?.cached_tokens!=null&&{cache_read:e.prompt_tokens_details.cached_tokens}},r={...e.completion_tokens_details?.audio_tokens!=null&&{audio:e.completion_tokens_details.audio_tokens},...e.completion_tokens_details?.reasoning_tokens!=null&&{reasoning:e.completion_tokens_details.reasoning_tokens}};return{input_tokens:e.prompt_tokens??0,output_tokens:e.completion_tokens??0,total_tokens:e.total_tokens??0,...Object.keys(t).length>0&&{input_token_details:t},...Object.keys(r).length>0&&{output_token_details:r}}}function oH(e,t){return{model_provider:"openai",model_name:e.model,system_fingerprint:e.system_fingerprint,service_tier:e.service_tier,finish_reason:t.finish_reason,...e.usage?{usage:e.usage}:{}}}var H1=A({});var Z1=A({BaseLLM:()=>G1,LLM:()=>hh}),G1=class Kl extends Zl{lc_namespace=["langchain","llms",this._llmType()];async invoke(t,r){let n=Kl._convertInputToPromptValue(t);return(await this.generatePrompt([n],r,r?.callbacks)).generations[0][0].text}async*_streamResponseChunks(t,r,n){throw new Error("Not implemented.")}_separateRunnableConfigFromCallOptionsCompat(t){let[r,n]=super._separateRunnableConfigFromCallOptions(t);return n.signal=r.signal,[r,n]}async*_streamIterator(t,r){if(this._streamResponseChunks===Kl.prototype._streamResponseChunks)yield this.invoke(t,r);else{let n=Kl._convertInputToPromptValue(t),[i,o]=this._separateRunnableConfigFromCallOptionsCompat(r),a=this.invocationParams(o),s=await tt.configure(i.callbacks,this.callbacks,i.tags,this.tags,i.metadata,this.metadata,{verbose:this.verbose,tracerInheritableMetadata:this._filterInvocationParamsForTracing(a)}),c={options:o,invocation_params:a,batch_size:1},u=await s?.handleLLMStart(this.toJSON(),[n.toString()],i.runId,void 0,c,void 0,void 0,i.runName),l=new Ri({text:""});try{for await(let d of this._streamResponseChunks(n.toString(),o,u?.[0]))l?l=l.concat(d):l=d,typeof d.text=="string"&&(yield d.text)}catch(d){throw await Promise.all((u??[]).map(f=>f?.handleLLMError(d))),d}await Promise.all((u??[]).map(d=>d?.handleLLMEnd({generations:[[l]]})))}}async generatePrompt(t,r,n){let i=t.map(o=>o.toString());return this.generate(i,r,n)}invocationParams(t){return{}}_flattenLLMResult(t){let r=[];for(let n=0;n<t.generations.length;n+=1){let i=t.generations[n];if(n===0)r.push({generations:[i],llmOutput:t.llmOutput});else{let o=t.llmOutput?{...t.llmOutput,tokenUsage:{}}:void 0;r.push({generations:[i],llmOutput:o})}}return r}async _generateUncached(t,r,n,i){let o;if(i!==void 0&&i.length===t.length)o=i;else{let u=this.invocationParams(r),l=await tt.configure(n.callbacks,this.callbacks,n.tags,this.tags,n.metadata,this.metadata,{verbose:this.verbose,tracerInheritableMetadata:this._filterInvocationParamsForTracing(u)}),d={options:r,invocation_params:u,batch_size:t.length};o=await l?.handleLLMStart(this.toJSON(),t,n.runId,void 0,d,void 0,void 0,n?.runName)}let a=!!o?.[0].handlers.find(qu),s;if(a&&t.length===1&&this._streamResponseChunks!==Kl.prototype._streamResponseChunks)try{let u=await this._streamResponseChunks(t[0],r,o?.[0]),l;for await(let d of u)l===void 0?l=d:l=Zr(l,d);if(l===void 0)throw new Error("Received empty response from chat model call.");s={generations:[[l]],llmOutput:{}},await o?.[0].handleLLMEnd(s)}catch(u){throw await o?.[0].handleLLMError(u),u}else{try{s=await this._generate(t,r,o?.[0])}catch(l){throw await Promise.all((o??[]).map(d=>d?.handleLLMError(l))),l}let u=this._flattenLLMResult(s);await Promise.all((o??[]).map((l,d)=>l?.handleLLMEnd(u[d])))}let c=o?.map(u=>u.runId)||void 0;return Object.defineProperty(s,Ka,{value:c?{runIds:c}:void 0,configurable:!0}),s}async _generateCached({prompts:t,cache:r,llmStringKey:n,parsedOptions:i,handledOptions:o,runId:a}){let s=this.invocationParams(i),c=await tt.configure(o.callbacks,this.callbacks,o.tags,this.tags,o.metadata,this.metadata,{verbose:this.verbose,tracerInheritableMetadata:this._filterInvocationParamsForTracing(s)}),u={options:i,invocation_params:s,batch_size:t.length},l=await c?.handleLLMStart(this.toJSON(),t,a,void 0,u,void 0,void 0,o?.runName),d=[],f=(await Promise.allSettled(t.map(async(h,_)=>{let y=await r.lookup(h,n);return y==null&&d.push(_),y}))).map((h,_)=>({result:h,runManager:l?.[_]})).filter(({result:h})=>h.status==="fulfilled"&&h.value!=null||h.status==="rejected"),p=[];await Promise.all(f.map(async({result:h,runManager:_},y)=>{if(h.status==="fulfilled"){let w=h.value;return p[y]=w.map(x=>(x.generationInfo={...x.generationInfo,tokenUsage:{}},x)),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:l};return Object.defineProperty(m,Ka,{value:l?{runIds:l?.map(h=>h.runId)}:void 0,configurable:!0}),m}async generate(t,r,n){if(!Array.isArray(t))throw new Error("Argument 'prompts' is expected to be a string[]");let i;Array.isArray(r)?i={stop:r}:i=r;let[o,a]=this._separateRunnableConfigFromCallOptionsCompat(i);if(o.callbacks=o.callbacks??n,!this.cache)return this._generateUncached(t,a,o);let{cache:s}=this,c=this._getSerializedCacheKeyParametersForCall(a),{generations:u,missingPromptIndices:l,startedRunManagers:d}=await this._generateCached({prompts:t,cache:s,llmStringKey:c,parsedOptions:a,handledOptions:o,runId:o.runId}),f={};if(l.length>0){let p=await this._generateUncached(l.map(m=>t[m]),a,o,d!==void 0?l.map(m=>d?.[m]):void 0);await Promise.all(p.generations.map(async(m,h)=>{let _=l[h];return u[_]=m,s.update(t[_],c,m)})),f=p.llmOutput??{}}return{generations:u,llmOutput:f}}_identifyingParams(){return{}}_modelType(){return"base_llm"}},hh=class extends G1{async _generate(e,t,r){return{generations:await Promise.all(e.map((n,i)=>this._call(n,{...t,promptIndex:i},r).then(o=>[{text:o}])))}}};var W1=A({});var q1=A({BaseMemory:()=>aH,getInputValue:()=>sH,getOutputValue:()=>cH,getPromptInputKey:()=>uH}),aH=class{},K1=(e,t)=>{if(t!==void 0)return e[t];let r=Object.keys(e);if(r.length===1)return e[r[0]]},sH=(e,t)=>{let r=K1(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},cH=(e,t)=>{let r=K1(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 uH(e,t){let r=Object.keys(e).filter(n=>!t.includes(n)&&n!=="stop");if(r.length!==1)throw new Error(`One input key expected, but got ${r.length}`);return r[0]}var P0=class extends eu{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)}`)}},N0=class extends pi{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 P0(e)}_diff(e,t){if(t)return Po(e??{},t)}async parsePartialResult(e){let t=e[0];if(!t.message)return;let{message:r}=t,n=r.additional_kwargs.function_call;if(n)return this.argsOnly?qn(n.arguments):{...n,arguments:qn(n.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""}},J1=class extends eu{static lc_name(){return"JsonKeyOutputFunctionsParser"}lc_namespace=["langchain","output_parsers","openai_functions"];lc_serializable=!0;outputParser=new N0;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 X1=A({JsonKeyOutputFunctionsParser:()=>J1,JsonOutputFunctionsParser:()=>N0,OutputFunctionsParser:()=>P0});var Y1=A({JsonOutputKeyToolsParser:()=>fh,JsonOutputToolsParser:()=>T0,convertLangChainToolCallToOpenAI:()=>A1,makeInvalidToolCall:()=>C1,parseToolCall:()=>$0});var hi=class extends ce{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[n,i]of Object.entries(t))typeof i=="string"?r[n]=i:r[n]=await i();return{...r,...e}}async invoke(e,t){let r={...this.metadata,...t?.metadata},n=[...this.tags??[],...t?.tags??[]];return this._callWithConfig(i=>this.formatPromptValue(i),e,{...t,tags:n,metadata:r,runType:"prompt"})}};var Wi=class extends hi{async formatPromptValue(e){return new Vl(await this.format(e))}};var lH=Object.prototype.toString,iu=Array.isArray||function(t){return lH.call(t)==="[object Array]"};function j0(e){return typeof e=="function"}function dH(e){return iu(e)?"array":typeof e}function R0(e){return e.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function Q1(e,t){return e!=null&&typeof e=="object"&&t in e}function fH(e,t){return e!=null&&typeof e!="object"&&e.hasOwnProperty&&e.hasOwnProperty(t)}var pH=RegExp.prototype.test;function mH(e,t){return pH.call(e,t)}var hH=/\S/;function gH(e){return!mH(hH,e)}var _H={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"};function yH(e){return String(e).replace(/[&<>"'`=\/]/g,function(r){return _H[r]})}var vH=/\s*/,bH=/\s+/,eR=/\s*=/,wH=/\s*\}/,xH=/#|\^|\/|>|\{|&|=|!/;function SH(e,t){if(!e)return[];var r=!1,n=[],i=[],o=[],a=!1,s=!1,c="",u=0;function l(){if(a&&!s)for(;o.length;)delete i[o.pop()];else o=[];a=!1,s=!1}var d,f,p;function m(b){if(typeof b=="string"&&(b=b.split(bH,2)),!iu(b)||b.length!==2)throw new Error("Invalid tags: "+b);d=new RegExp(R0(b[0])+"\\s*"),f=new RegExp("\\s*"+R0(b[1])),p=new RegExp("\\s*"+R0("}"+b[1]))}m(t||fn.tags);for(var h=new Xl(e),_,y,w,x,S,E;!h.eos();){if(_=h.pos,w=h.scanUntil(d),w)for(var C=0,T=w.length;C<T;++C)x=w.charAt(C),gH(x)?(o.push(i.length),c+=x):(s=!0,r=!0,c+=" "),i.push(["text",x,_,_+1]),_+=1,x===`
324
- `&&(l(),c="",u=0,r=!1);if(!h.scan(d))break;if(a=!0,y=h.scan(xH)||"name",h.scan(vH),y==="="?(w=h.scanUntil(eR),h.scan(eR),h.scanUntil(f)):y==="{"?(w=h.scanUntil(p),h.scan(wH),h.scanUntil(f),y="&"):w=h.scanUntil(f),!h.scan(f))throw new Error("Unclosed tag at "+h.pos);if(y==">"?S=[y,w,_,h.pos,c,u,r]:S=[y,w,_,h.pos],u++,i.push(S),y==="#"||y==="^")n.push(S);else if(y==="/"){if(E=n.pop(),!E)throw new Error('Unopened section "'+w+'" at '+_);if(E[1]!==w)throw new Error('Unclosed section "'+E[1]+'" at '+_)}else y==="name"||y==="{"||y==="&"?s=!0:y==="="&&m(w)}if(l(),E=n.pop(),E)throw new Error('Unclosed section "'+E[1]+'" at '+h.pos);return EH(kH(i))}function kH(e){for(var t=[],r,n,i=0,o=e.length;i<o;++i)r=e[i],r&&(r[0]==="text"&&n&&n[0]==="text"?(n[1]+=r[1],n[3]=r[3]):(t.push(r),n=r));return t}function EH(e){for(var t=[],r=t,n=[],i,o,a=0,s=e.length;a<s;++a)switch(i=e[a],i[0]){case"#":case"^":r.push(i),n.push(i),r=i[4]=[];break;case"/":o=n.pop(),o[5]=i[2],r=n.length>0?n[n.length-1][4]:t;break;default:r.push(i)}return t}function Xl(e){this.string=e,this.tail=e,this.pos=0}Xl.prototype.eos=function(){return this.tail===""};Xl.prototype.scan=function(t){var r=this.tail.match(t);if(!r||r.index!==0)return"";var n=r[0];return this.tail=this.tail.substring(n.length),this.pos+=n.length,n};Xl.prototype.scanUntil=function(t){var r=this.tail.search(t),n;switch(r){case-1:n=this.tail,this.tail="";break;case 0:n="";break;default:n=this.tail.substring(0,r),this.tail=this.tail.substring(r)}return this.pos+=n.length,n};function nu(e,t){this.view=e,this.cache={".":this.view},this.parent=t}nu.prototype.push=function(t){return new nu(t,this)};nu.prototype.lookup=function(t){var r=this.cache,n;if(r.hasOwnProperty(t))n=r[t];else{for(var i=this,o,a,s,c=!1;i;){if(t.indexOf(".")>0)for(o=i.view,a=t.split("."),s=0;o!=null&&s<a.length;)s===a.length-1&&(c=Q1(o,a[s])||fH(o,a[s])),o=o[a[s++]];else o=i.view[t],c=Q1(i.view,t);if(c){n=o;break}i=i.parent}r[t]=n}return j0(n)&&(n=n.call(this.view)),n};function Sr(){this.templateCache={_cache:{},set:function(t,r){this._cache[t]=r},get:function(t){return this._cache[t]},clear:function(){this._cache={}}}}Sr.prototype.clearCache=function(){typeof this.templateCache<"u"&&this.templateCache.clear()};Sr.prototype.parse=function(t,r){var n=this.templateCache,i=t+":"+(r||fn.tags).join(":"),o=typeof n<"u",a=o?n.get(i):void 0;return a==null&&(a=SH(t,r),o&&n.set(i,a)),a};Sr.prototype.render=function(t,r,n,i){var o=this.getConfigTags(i),a=this.parse(t,o),s=r instanceof nu?r:new nu(r,void 0);return this.renderTokens(a,s,n,t,i)};Sr.prototype.renderTokens=function(t,r,n,i,o){for(var a="",s,c,u,l=0,d=t.length;l<d;++l)u=void 0,s=t[l],c=s[0],c==="#"?u=this.renderSection(s,r,n,i,o):c==="^"?u=this.renderInverted(s,r,n,i,o):c===">"?u=this.renderPartial(s,r,n,o):c==="&"?u=this.unescapedValue(s,r):c==="name"?u=this.escapedValue(s,r,o):c==="text"&&(u=this.rawValue(s)),u!==void 0&&(a+=u);return a};Sr.prototype.renderSection=function(t,r,n,i,o){var a=this,s="",c=r.lookup(t[1]);function u(f){return a.render(f,r,n,o)}if(c){if(iu(c))for(var l=0,d=c.length;l<d;++l)s+=this.renderTokens(t[4],r.push(c[l]),n,i,o);else if(typeof c=="object"||typeof c=="string"||typeof c=="number")s+=this.renderTokens(t[4],r.push(c),n,i,o);else if(j0(c)){if(typeof i!="string")throw new Error("Cannot use higher-order sections without the original template");c=c.call(r.view,i.slice(t[3],t[5]),u),c!=null&&(s+=c)}else s+=this.renderTokens(t[4],r,n,i,o);return s}};Sr.prototype.renderInverted=function(t,r,n,i,o){var a=r.lookup(t[1]);if(!a||iu(a)&&a.length===0)return this.renderTokens(t[4],r,n,i,o)};Sr.prototype.indentPartial=function(t,r,n){for(var i=r.replace(/[^ \t]/g,""),o=t.split(`
325
- `),a=0;a<o.length;a++)o[a].length&&(a>0||!n)&&(o[a]=i+o[a]);return o.join(`
326
- `)};Sr.prototype.renderPartial=function(t,r,n,i){if(n){var o=this.getConfigTags(i),a=j0(n)?n(t[1]):n[t[1]];if(a!=null){var s=t[6],c=t[5],u=t[4],l=a;c==0&&u&&(l=this.indentPartial(a,u,s));var d=this.parse(l,o);return this.renderTokens(d,r,n,l,i)}}};Sr.prototype.unescapedValue=function(t,r){var n=r.lookup(t[1]);if(n!=null)return n};Sr.prototype.escapedValue=function(t,r,n){var i=this.getConfigEscape(n)||fn.escape,o=r.lookup(t[1]);if(o!=null)return typeof o=="number"&&i===fn.escape?String(o):i(o)};Sr.prototype.rawValue=function(t){return t[1]};Sr.prototype.getConfigTags=function(t){return iu(t)?t:t&&typeof t=="object"?t.tags:void 0};Sr.prototype.getConfigEscape=function(t){if(t&&typeof t=="object"&&!iu(t))return t.escape};var fn={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 Sr;fn.clearCache=function(){return Jl.clearCache()};fn.parse=function(t,r){return Jl.parse(t,r)};fn.render=function(t,r,n,i){if(typeof t!="string")throw new TypeError('Invalid template! Template should be a "string" but "'+dH(t)+'" was given as the first argument for mustache#render(template, view, partials)');return Jl.render(t,r,n,i)};fn.escape=yH;fn.Scanner=Xl;fn.Context=nu;fn.Writer=Sr;var gh=fn;function tR(){gh.escape=e=>e}var Is=e=>{let t=e.split(""),r=[],n=(o,a)=>{for(let s=a;s<t.length;s+=1)if(o.includes(t[s]))return s;return-1},i=0;for(;i<t.length;)if(t[i]==="{"&&i+1<t.length&&t[i+1]==="{")r.push({type:"literal",text:"{"}),i+=2;else if(t[i]==="}"&&i+1<t.length&&t[i+1]==="}")r.push({type:"literal",text:"}"}),i+=2;else if(t[i]==="{"){let o=n("}",i);if(o<0)throw new Error("Unclosed '{' in template.");r.push({type:"variable",name:t.slice(i+1,o).join("")}),i=o+1}else{if(t[i]==="}")throw new Error("Single '}' in template.");{let o=n("{}",i),a=(o<0?t.slice(i):t.slice(i,o)).join("");r.push({type:"literal",text:a}),i=o<0?t.length:o}}return r},rR=(e,t=[])=>{let r=[];for(let n of e)if(n[0]==="name"){let i=n[1].includes(".")?n[1].split(".")[0]:n[1];r.push({type:"variable",name:i})}else if(["#","&","^",">"].includes(n[0])){if(r.push({type:"variable",name:n[1]}),n[0]==="#"&&n.length>4&&Array.isArray(n[4])){let i=[...t,n[1]],o=rR(n[4],i);r.push(...o)}}else r.push({type:"literal",text:n[1]});return r},ou=e=>(tR(),rR(gh.parse(e))),M0=(e,t)=>Is(e).reduce((r,n)=>{if(n.type==="variable"){if(n.name in t)return r+(typeof t[n.name]=="string"?t[n.name]:JSON.stringify(t[n.name]));throw new Error(`(f-string) Missing value for input ${n.name}`)}return r+n.text},""),D0=(e,t)=>(tR(),gh.render(e,t)),Yl={"f-string":M0,mustache:D0},z0={"f-string":Is,mustache:ou},ar=(e,t,r)=>{try{return Yl[t](e,r)}catch(n){throw Ii(n,"INVALID_PROMPT_INPUT")}},$s=(e,t)=>z0[t](e),qi=(e,t,r)=>{if(!(t in Yl))throw new Error(`Invalid template format. Got \`${t}\`;
327
- should be one of ${Object.keys(Yl)}`);try{let n=Object.fromEntries(r.map(i=>[i,"foo"]));Array.isArray(e)?e.forEach(i=>{if(i.type==="text"&&"text"in i&&typeof i.text=="string")ar(i.text,t,n);else if(i.type==="image_url"){if(typeof i.image_url=="string")ar(i.image_url,t,n);else if(typeof i.image_url=="object"&&i.image_url!==null&&"url"in i.image_url&&typeof i.image_url.url=="string"){let o=i.image_url.url;ar(o,t,n)}}else throw new Error(`Invalid message template received. ${JSON.stringify(i,null,2)}`)}):ar(e,t,n)}catch(n){throw new Error(`Invalid prompt schema: ${n.message}`)}};var Cn=class Ql extends Wi{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))),qi(this.template,this.templateFormat,r)}}_getPromptType(){return"prompt"}async format(t){let r=await this.mergePartialAndUserVariables(t);return ar(this.template,this.templateFormat,r)}static fromExamples(t,r,n,i=`
328
-
329
- `,o=""){return new Ql({inputVariables:n,template:[o,...t,r].join(i)})}static fromTemplate(t,r){let{templateFormat:n="f-string",...i}=r??{},o=new Set;return $s(t,n).forEach(a=>{a.type==="variable"&&o.add(a.name)}),new Ql({inputVariables:[...o],templateFormat:n,template:t,...i})}async partial(t){let r=this.inputVariables.filter(i=>!(i in t)),n={...this.partialVariables??{},...t};return new Ql({...this,inputVariables:r,partialVariables:n})}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 Ql({inputVariables:t.input_variables,template:t.template,templateFormat:t.template_format})}};var au=class nR extends hi{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))),qi([{type:"image_url",image_url:this.template}],this.templateFormat,r)}}_getPromptType(){return"prompt"}async partial(t){let r=this.inputVariables.filter(i=>!(i in t)),n={...this.partialVariables??{},...t};return new nR({...this,inputVariables:r,partialVariables:n})}async format(t){let r={};for(let[a,s]of Object.entries(this.template))typeof s=="string"?r[a]=ar(s,this.templateFormat,t):r[a]=s;let n=t.url||r.url,i=t.detail||r.detail;if(!n)throw new Error("Must provide either an image URL.");if(typeof n!="string")throw new Error("url must be a string.");let o={url:n};return i&&(o.detail=i),o}async formatPromptValue(t){return new x0(await this.format(t))}};var ed=class extends ce{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=U0(e.template,t);super({inputVariables:r,...e}),this.template=e.template,this.templateFormat=t,this.inputVariables=r}async format(e){return L0(this.template,e,this.templateFormat)}async invoke(e){return await this._callWithConfig(this.format.bind(this),e,{runType:"prompt"})}};function U0(e,t){let r=[];for(let n of Object.values(e))if(typeof n=="string")$s(n,t).forEach(i=>{i.type==="variable"&&r.push(i.name)});else if(Array.isArray(n))for(let i of n)typeof i=="string"?$s(i,t).forEach(o=>{o.type==="variable"&&r.push(o.name)}):typeof i=="object"&&r.push(...U0(i,t));else typeof n=="object"&&n!==null&&r.push(...U0(n,t));return Array.from(new Set(r))}function L0(e,t,r){let n={};for(let[i,o]of Object.entries(e))if(typeof o=="string")n[i]=ar(o,r,t);else if(Array.isArray(o)){let a=[];for(let s of o)typeof s=="string"?a.push(ar(s,r,t)):typeof s=="object"&&a.push(L0(s,t,r));n[i]=a}else typeof o=="object"&&o!==null?n[i]=L0(o,t,r):n[i]=o;return n}var td=class extends ce{lc_namespace=["langchain_core","prompts","chat"];lc_serializable=!0;async invoke(e,t){return this._callWithConfig(r=>this.formatMessages(r),e,{...t,runType:"prompt"})}},yh=class extends td{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 n=new Error(`Field "${this.variableName}" in prompt uses a MessagesPlaceholder, which expects an array of BaseMessages as an input value. Received: undefined`);throw n.name="InputFormatError",n}let r;try{Array.isArray(t)?r=t.map(Tt):r=[Tt(t)]}catch(n){let i=typeof t=="string"?t:JSON.stringify(t,null,2),o=new Error([`Field "${this.variableName}" in prompt uses a MessagesPlaceholder, which expects an array of BaseMessages or coerceable values as input.`,`Received value: ${i}`,`Additional message: ${n.message}`].join(`
330
-
331
- `));throw o.name="InputFormatError",o.lc_error_code=n.lc_error_code,o}return r}},F0=class extends td{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)]}},rd=class extends hi{constructor(e){super(e)}async format(e){return(await this.formatPromptValue(e)).toString()}async formatPromptValue(e){return new Hl(await this.formatMessages(e))}},B0=class extends F0{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 bn(await this.prompt.format(e),this.role)}static fromTemplate(e,t,r){return new this(Cn.fromTemplate(e,{templateFormat:r?.templateFormat}),t)}};function IH(e){return e===null||typeof e!="object"||Array.isArray(e)?!1:Object.keys(e).length===1&&"text"in e&&typeof e.text=="string"}function $H(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 V0=class extends td{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(n=>{"inputVariables"in n&&(r=r.concat(n.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(Cn.fromTemplate(e,t));let r=[];for(let n of e)if(typeof n=="string")r.push(Cn.fromTemplate(n,t));else if(n!==null)if(IH(n)){let i="";typeof n.text=="string"&&(i=n.text??"");let o={...t,additionalContentFields:n};r.push(Cn.fromTemplate(i,o))}else if($H(n)){let i=n.image_url??"",o,a=[];if(typeof i=="string"){let s;t?.templateFormat==="mustache"?s=ou(i):s=Is(i);let c=s.flatMap(u=>u.type==="variable"?[u.name]:[]);if((c?.length??0)>0){if(c.length>1)throw new Error(`Only one format variable allowed per image template.
332
- Got: ${c}
333
- From: ${i}`);a=[c[0]]}else a=[];i={url:i},o=new au({template:i,inputVariables:a,templateFormat:t?.templateFormat,additionalContentFields:n})}else if(typeof i=="object"){if("url"in i){let s;t?.templateFormat==="mustache"?s=ou(i.url):s=Is(i.url),a=s.flatMap(c=>c.type==="variable"?[c.name]:[])}else a=[];o=new au({template:i,inputVariables:a,templateFormat:t?.templateFormat,additionalContentFields:n})}else throw new Error("Invalid image template");r.push(o)}else typeof n=="object"&&r.push(new ed({template:n,templateFormat:t?.templateFormat}));return new this({prompt:r,additionalOptions:t})}async format(e){if(this.prompt instanceof Wi){let t=await this.prompt.format(e);return this.createMessage(t)}else{let t=[];for(let r of this.prompt){let n={};if(!("inputVariables"in r))throw new Error(`Prompt ${r} does not have inputVariables defined.`);for(let i of r.inputVariables)n||(n={[i]:e[i]}),n={...n,[i]:e[i]};if(r instanceof Wi){let i=await r.format(n),o;"additionalContentFields"in r&&(o=r.additionalContentFields),i!==""&&t.push({...o,type:"text",text:i})}else if(r instanceof au){let i=await r.format(n),o;"additionalContentFields"in r&&(o=r.additionalContentFields),t.push({...o,type:"image_url",image_url:i})}else if(r instanceof ed){let i=await r.format(n),o;"additionalContentFields"in r&&(o=r.additionalContentFields),t.push({...o,...i})}}return this.createMessage(t)}}async formatMessages(e){return[await this.format(e)]}},vh=class extends V0{static _messageClass(){return dt}static lc_name(){return"HumanMessagePromptTemplate"}},H0=class extends V0{static _messageClass(){return je}static lc_name(){return"AIMessagePromptTemplate"}},Z0=class extends V0{static _messageClass(){return mr}static lc_name(){return"SystemMessagePromptTemplate"}};function TH(e){return typeof e.formatMessages=="function"}function AH(e,t){if(TH(e)||ot(e))return e;if(Array.isArray(e)&&e[0]==="placeholder"){let i=e[1];if(t?.templateFormat==="mustache"&&typeof i=="string"&&i.slice(0,2)==="{{"&&i.slice(-2)==="}}")return new yh({variableName:i.slice(2,-2),optional:!0});if(typeof i=="string"&&i[0]==="{"&&i[i.length-1]==="}")return new yh({variableName:i.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=Tt(e),n;if(typeof r.content=="string"?n=r.content:n=r.content.map(i=>"text"in i?{...i,text:i.text}:"image_url"in i?{...i,image_url:i.image_url}:i),r._getType()==="human")return vh.fromTemplate(n,t);if(r._getType()==="ai")return H0.fromTemplate(n,t);if(r._getType()==="system")return Z0.fromTemplate(n,t);if(bn.isInstance(r))return B0.fromTemplate(r.content,r.role,t);throw new Error(`Could not coerce message prompt template from input. Received message type: "${r._getType()}".`)}function CH(e){return e.constructor.lc_name()==="MessagesPlaceholder"}var su=class _h extends rd{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 Re))for(let c of s.inputVariables)r.add(c);let n=this.inputVariables,i=new Set(this.partialVariables?n.concat(Object.keys(this.partialVariables)):n),o=new Set([...i].filter(s=>!r.has(s)));if(o.size>0)throw new Error(`Input variables \`${[...o]}\` are not used in any of the prompt messages.`);let a=new Set([...r].filter(s=>!i.has(s)));if(a.size>0)throw new Error(`Input variables \`${[...a]}\` 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 n=>{if(n.type!=="image_url")return n;let i="";typeof n.image_url=="string"?i=n.image_url:typeof n.image_url=="object"&&n.image_url!==null&&"url"in n.image_url&&typeof n.image_url.url=="string"&&(i=n.image_url.url);let o=await Cn.fromTemplate(i,{templateFormat:this.templateFormat}).format(r);return typeof n.image_url=="object"&&n.image_url!==null&&"url"in n.image_url?n.image_url.url=o:n.image_url=o,n}))),t}async formatMessages(t){let r=await this.mergePartialAndUserVariables(t),n=[];for(let i of this.promptMessages)if(i instanceof Re)n.push(await this._parseImagePrompts(i,r));else{let o;this.templateFormat==="mustache"?o={...r}:o=i.inputVariables.reduce((s,c)=>{if(!(c in r)&&!(CH(i)&&i.optional))throw Ii(new Error(`Missing value for input variable \`${c.toString()}\``),"INVALID_PROMPT_INPUT");return s[c]=r[c],s},{});let a=await i.formatMessages(o);n=n.concat(a)}return n}async partial(t){let r=this.inputVariables.filter(i=>!(i in t)),n={...this.partialVariables??{},...t};return new _h({...this,inputVariables:r,partialVariables:n})}static fromTemplate(t,r){let n=new vh({prompt:Cn.fromTemplate(t,r)});return this.fromMessages([n])}static fromMessages(t,r){let n=t.reduce((a,s)=>a.concat(s instanceof _h?s.promptMessages:[AH(s,r)]),[]),i=t.reduce((a,s)=>s instanceof _h?Object.assign(a,s.partialVariables):a,Object.create(null)),o=new Set;for(let a of n)if(!(a instanceof Re))for(let s of a.inputVariables)s in i||o.add(s);return new this({...r,inputVariables:[...o],promptMessages:n,partialVariables:i,templateFormat:r?.templateFormat})}};var iR=class G0 extends Wi{lc_serializable=!1;examples;exampleSelector;examplePrompt;suffix="";exampleSeparator=`
334
-
335
- `;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))),qi(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(i=>!(i in t)),n={...this.partialVariables??{},...t};return new G0({...this,inputVariables:r,partialVariables:n})}async format(t){let r=await this.mergePartialAndUserVariables(t),n=await this.getExamples(r),i=await Promise.all(n.map(o=>this.examplePrompt.format(o)));return ar([this.prefix,...i,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 n=await Cn.deserialize(r),i;if(Array.isArray(t.examples))i=t.examples;else throw new Error("Invalid examples format. Only list or string are supported.");return new G0({inputVariables:t.input_variables,examplePrompt:n,examples:i,exampleSeparator:t.example_separator,prefix:t.prefix,suffix:t.suffix,templateFormat:t.template_format})}},oR=class aR extends rd{lc_serializable=!0;examples;exampleSelector;examplePrompt;suffix="";exampleSeparator=`
336
-
337
- `;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??`
338
-
339
- `,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))),qi(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),n=await this.getExamples(r);n=n.map(o=>{let a={};return this.examplePrompt.inputVariables.forEach(s=>{a[s]=o[s]}),a});let i=[];for(let o of n){let a=await this.examplePrompt.formatMessages(o);i.push(...a)}return i}async format(t){let r=await this.mergePartialAndUserVariables(t),n=await this.getExamples(r),i=(await Promise.all(n.map(o=>this.examplePrompt.formatMessages(o)))).flat().map(o=>o.content);return ar([this.prefix,...i,this.suffix].join(this.exampleSeparator),this.templateFormat,r)}async partial(t){let r=this.inputVariables.filter(i=>!(i in t)),n={...this.partialVariables??{},...t};return new aR({...this,inputVariables:r,partialVariables:n})}};var sR=class bh extends hi{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(n=>n.name),r=this.pipelinePrompts.map(n=>n.prompt.inputVariables.filter(i=>!t.includes(i))).flat();return[...new Set(r)]}static extractRequiredInputValues(t,r){return r.reduce((n,i)=>(n[i]=t[i],n),{})}async formatPipelinePrompts(t){let r=await this.mergePartialAndUserVariables(t);for(let{name:n,prompt:i}of this.pipelinePrompts){let o=bh.extractRequiredInputValues(r,i.inputVariables);i instanceof su?r[n]=await i.formatMessages(o):r[n]=await i.format(o)}return bh.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(n=>!(n in t)),r.partialVariables={...this.partialVariables??{},...t},new bh(r)}serialize(){throw new Error("Not implemented.")}_getPromptType(){return"pipeline"}};function cR(e){return typeof e=="object"&&e!=null&&"withStructuredOutput"in e&&typeof e.withStructuredOutput=="function"}function OH(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 uR=class lR extends su{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(cR(t))return super.pipe(t.withStructuredOutput(this.schema));if(OH(t)&&cR(t.bound))return super.pipe(new ln({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,n){return lR.fromMessages(t,{schema:r,method:n})}};var dR=A({AIMessagePromptTemplate:()=>H0,BaseChatPromptTemplate:()=>rd,BaseMessagePromptTemplate:()=>td,BaseMessageStringPromptTemplate:()=>F0,BasePromptTemplate:()=>hi,BaseStringPromptTemplate:()=>Wi,ChatMessagePromptTemplate:()=>B0,ChatPromptTemplate:()=>su,DEFAULT_FORMATTER_MAPPING:()=>Yl,DEFAULT_PARSER_MAPPING:()=>z0,DictPromptTemplate:()=>ed,FewShotChatMessagePromptTemplate:()=>oR,FewShotPromptTemplate:()=>iR,HumanMessagePromptTemplate:()=>vh,ImagePromptTemplate:()=>au,MessagesPlaceholder:()=>yh,PipelinePromptTemplate:()=>sR,PromptTemplate:()=>Cn,StructuredPrompt:()=>uR,SystemMessagePromptTemplate:()=>Z0,checkValidTemplate:()=>qi,interpolateFString:()=>M0,interpolateMustache:()=>D0,parseFString:()=>Is,parseMustache:()=>ou,parseTemplate:()=>$s,renderTemplate:()=>ar});var fR=A({BaseDocumentCompressor:()=>PH}),PH=class{static isBaseDocumentCompressor(e){return e?.compressDocuments!==void 0}};var pR=A({BaseRetriever:()=>nd}),nd=class extends ce{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=Ee(Ga(t)),n=await(await tt.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 i=await this._getRelevantDocuments(e,n);return await n?.handleRetrieverEnd(i),i}catch(i){throw await n?.handleRetrieverError(i),i}}};var mR=A({BaseStore:()=>hR,InMemoryStore:()=>NH}),hR=class extends yt{},NH=class extends hR{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 On={and:"and",or:"or",not:"not"},Ce={eq:"eq",ne:"ne",lt:"lt",gt:"gt",lte:"lte",gte:"gte"},wh=class{},xh=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")}},Sh=class extends xh{},gR=class extends Sh{exprName="Comparison";constructor(e,t,r){super(),this.comparator=e,this.attribute=t,this.value=r}},_R=class extends Sh{exprName="Operation";constructor(e,t){super(),this.operator=e,this.args=t}},yR=class extends xh{exprName="StructuredQuery";constructor(e,t){super(),this.query=e,this.filter=t}};function W0(e){return e&&typeof e=="object"&&!Array.isArray(e)}function jr(e){return e?typeof e=="string"&&e.length>0||typeof e=="function"?!1:W0(e)&&Object.keys(e).length===0:!0}function q0(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 K0(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 J0(e){return typeof e=="string"&&(Number.isNaN(parseFloat(e))||parseFloat(e).toString()!==e)}function X0(e){return typeof e=="boolean"}function cu(e){let t;if(J0(e))t=e;else if(q0(e))t=parseInt(e,10);else if(K0(e))t=parseFloat(e);else if(X0(e))t=!!e;else throw new Error("Unsupported value type");return t}var id=class extends wh{},vR=class extends id{allowedOperators;allowedComparators;constructor(e){super(),this.allowedOperators=e?.allowedOperators??[On.and,On.or],this.allowedComparators=e?.allowedComparators??[Ce.eq,Ce.ne,Ce.gt,Ce.gte,Ce.lt,Ce.lte]}formatFunction(e){if(e in Ce){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 On){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)]:cu(e.value)}}}visitStructuredQuery(e){let t={};return e.filter&&(t={filter:e.filter.accept(this)}),t}mergeFilters(e,t,r="and",n=!1){if(!(jr(e)&&jr(t))){if(jr(e)||r==="replace")return jr(t)?void 0:t;if(jr(t))return n?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 bR=class extends id{allowedOperators=[On.and,On.or];allowedComparators=[Ce.eq,Ce.ne,Ce.gt,Ce.gte,Ce.lt,Ce.lte];formatFunction(){throw new Error("Not implemented")}getAllowedComparatorsForType(e){switch(e){case"string":return[Ce.eq,Ce.ne,Ce.gt,Ce.gte,Ce.lt,Ce.lte];case"number":return[Ce.eq,Ce.ne,Ce.gt,Ce.gte,Ce.lt,Ce.lte];case"boolean":return[Ce.eq,Ce.ne];default:throw new Error(`Unsupported data type: ${e}`)}}getComparatorFunction(e){switch(e){case Ce.eq:return(t,r)=>t===r;case Ce.ne:return(t,r)=>t!==r;case Ce.gt:return(t,r)=>t>r;case Ce.gte:return(t,r)=>t>=r;case Ce.lt:return(t,r)=>t<r;case Ce.lte:return(t,r)=>t<=r;default:throw new Error("Unknown comparator")}}getOperatorFunction(e){switch(e){case On.and:return(t,r)=>t&&r;case On.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 n=this.getOperatorFunction(t);return i=>r?r.reduce((o,a)=>{let s=a.accept(this);if(typeof s=="function")return n(o,s(i));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:n}=e,i=[Ce.ne];if(this.allowedComparators.includes(t)){if(!this.getAllowedComparatorsForType(typeof n).includes(t))throw new Error(`'${t}' comparator not allowed to be used with ${typeof n}`);let o=this.getComparatorFunction(t);return a=>{let s=a.metadata[r];return s===void 0?!!i.includes(t):o(s,cu(n))}}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(!(jr(e)&&jr(t))){if(jr(e)||r==="replace")return jr(t)?void 0:t;if(jr(t))return r==="and"?void 0:e;if(r==="and")return n=>e(n)&&t(n);if(r==="or")return n=>e(n)||t(n);throw new Error("Unknown merge type")}}};var wR=A({BaseTranslator:()=>id,BasicTranslator:()=>vR,Comparators:()=>Ce,Comparison:()=>gR,Expression:()=>xh,FilterDirective:()=>Sh,FunctionalTranslator:()=>bR,Operation:()=>_R,Operators:()=>On,StructuredQuery:()=>yR,Visitor:()=>wh,castValue:()=>cu,isBoolean:()=>X0,isFilterEmpty:()=>jr,isFloat:()=>K0,isInt:()=>q0,isObject:()=>W0,isString:()=>J0});function od(e){if(e==null||typeof e!="object")return!1;let t=e;return typeof t.text<"u"&&typeof t.toolCalls<"u"&&typeof t.reasoning<"u"&&typeof t.usage<"u"&&typeof t.output<"u"&&typeof t[Symbol.asyncIterator]=="function"}function xR(e,t,r){return e==null?!1:Object.entries(t).every(([n,i])=>r(e[n],i))}function SR(e,t,r){return e==null?!1:xR(e,t,r)}function kR(e){return e.content.find(t=>t.type==="text")?.text}function RH(e,t,r){if(t.id!==void 0&&e.id!==t.id||t.text!==void 0&&kR(e)!==t.text)return!1;if(t.toolCalls!==void 0){let n=e.tool_calls??[];if(n.length!==t.toolCalls.length)return!1;for(let i=0;i<t.toolCalls.length;i++){let o=n[i],a=t.toolCalls[i];if(o?.name!==a.name||!r(o.args,a.args))return!1}}return!(t.usage!==void 0&&!SR(e.usage_metadata,t.usage,r)||t.responseMetadata!==void 0&&!xR(e.response_metadata,t.responseMetadata,r))}function ad(e,t,r){return{pass:!1,message:()=>`${r.matcherHint(t)}
340
-
341
- Expected: ChatModelStream (return value of model.streamEvents("Hello"))
342
- Received: ${r.printReceived(e)}`,actual:e,expected:"ChatModelStream"}}function sd(e,t){return t?!e:e}async function jH(e,t){let{isNot:r,utils:n}=this,i="toHaveStreamText";if(!od(e))return ad(e,i,n);let o=await e.text;return{pass:sd(o===t,r),message:()=>`${n.matcherHint(i,void 0,void 0,{isNot:r})}
343
-
344
- Expected stream text: ${r?"not ":""}${n.printExpected(t)}
345
- Received stream text: ${n.printReceived(o)}`,actual:o,expected:t}}async function MH(e,t){let{isNot:r,utils:n}=this,i="toHaveStreamReasoning";if(!od(e))return ad(e,i,n);let o=await e.reasoning;return{pass:sd(o===t,r),message:()=>`${n.matcherHint(i,void 0,void 0,{isNot:r})}
346
-
347
- Expected stream reasoning: ${r?"not ":""}${n.printExpected(t)}
348
- Received stream reasoning: ${n.printReceived(o)}`,actual:o,expected:t}}async function DH(e,t){let{isNot:r,utils:n}=this,i="toHaveStreamToolCalls";if(!od(e))return ad(e,i,n);let o=await e.toolCalls,a=o.length===t.length&&t.every((s,c)=>{let u=o[c];return u?.name===s.name&&this.equals(u.args,s.args)});return a=sd(a,r),{pass:a,message:()=>`${n.matcherHint(i,void 0,void 0,{isNot:r})}
349
-
350
- Expected stream tool calls: ${n.printExpected(t)}
351
- Received stream tool calls: ${n.printReceived(o.map(s=>({name:s.name,args:s.args})))}`,actual:o.map(s=>({name:s.name,args:s.args})),expected:t}}async function zH(e,t){let{isNot:r,utils:n}=this,i="toHaveStreamUsage";if(!od(e))return ad(e,i,n);let o=await e.usage;return{pass:sd(SR(o,t,this.equals),r),message:()=>`${n.matcherHint(i,void 0,void 0,{isNot:r})}
352
-
353
- Expected stream usage: ${n.printExpected(t)}
354
- Received stream usage: ${n.printReceived(o)}`,actual:o,expected:t}}async function UH(e,t){let{isNot:r,utils:n}=this,i="toHaveStreamOutput";if(!od(e))return ad(e,i,n);let o=await e.output;return{pass:sd(RH(o,t,this.equals),r),message:()=>`${n.matcherHint(i,void 0,void 0,{isNot:r})}
355
-
356
- Expected stream output: ${n.printExpected(t)}
357
- Received stream output: ${n.printReceived({id:o.id,text:kR(o),tool_calls:o.tool_calls?.map(a=>({name:a.name,args:a.args})),usage_metadata:o.usage_metadata,response_metadata:o.response_metadata})}`,actual:o,expected:t}}var uu={toHaveStreamText:jH,toHaveStreamReasoning:MH,toHaveStreamToolCalls:DH,toHaveStreamUsage:zH,toHaveStreamOutput:UH};function cd(e){return Re.isInstance(e)?e.constructor.name||e.type:typeof e}function kh(e,t){return function(r,n){let{isNot:i,utils:o}=this;if(!t(r))return{pass:!1,message:()=>`${o.matcherHint(`toBe${e}`,void 0,void 0)}
358
-
359
- Expected: ${i?"not ":""}${e}
360
- Received: ${cd(r)}`,actual:cd(r),expected:e};if(n===void 0)return{pass:!0,message:()=>`${o.matcherHint(`toBe${e}`,void 0,void 0)}
361
-
362
- Expected: not ${e}
363
- Received: ${e}`};let a=r;return typeof n=="string"?{pass:a.content===n,message:()=>`${o.matcherHint(`toBe${e}`,void 0,void 0)}
364
-
365
- Expected: ${e} with content ${o.printExpected(n)}
366
- Received: ${e} with content ${o.printReceived(a.content)}`,actual:a.content,expected:n}:{pass:Object.entries(n).every(([s,c])=>this.equals(a[s],c)),message:()=>{let s={};for(let c of Object.keys(n))s[c]=a[c];return`${o.matcherHint(`toBe${e}`,void 0,void 0)}
367
-
368
- Expected: ${e} matching ${o.printExpected(n)}
369
- Received: ${e} with ${o.printReceived(s)}`},actual:(()=>{let s={};for(let c of Object.keys(n))s[c]=a[c];return s})(),expected:n}}}var Y0=kh("HumanMessage",dt.isInstance),Q0=kh("AIMessage",je.isInstance),eS=kh("SystemMessage",mr.isInstance),tS=kh("ToolMessage",$t.isInstance);function rS(e,t){let{isNot:r,utils:n}=this;if(!je.isInstance(e))return{pass:!1,message:()=>`${n.matcherHint("toHaveToolCalls")}
370
-
371
- Expected: AIMessage
372
- Received: ${cd(e)}`};let i=e.tool_calls??[];if(i.length!==t.length)return{pass:!1,message:()=>`${n.matcherHint("toHaveToolCalls")}
373
-
374
- Expected ${r?"not ":""}${t.length} tool call(s), received ${i.length}`,actual:i.length,expected:t.length};let o=t.filter(a=>!i.some(s=>Object.entries(a).every(([c,u])=>this.equals(s[c],u))));return o.length>0?{pass:!1,message:()=>`${n.matcherHint("toHaveToolCalls")}
375
-
376
- Could not find matching tool call(s) for:
377
- ${n.printExpected(o)}
378
- Received tool calls: ${n.printReceived(i.map(a=>({name:a.name,id:a.id,args:a.args})))}`,actual:i.map(a=>({name:a.name,id:a.id,args:a.args})),expected:t}:{pass:!0,message:()=>`${n.matcherHint("toHaveToolCalls")}
379
-
380
- Expected AIMessage not to have matching tool calls`}}function nS(e,t){let{isNot:r,utils:n}=this;if(!je.isInstance(e))return{pass:!1,message:()=>`${n.matcherHint("toHaveToolCallCount")}
381
-
382
- Expected: AIMessage
383
- Received: ${cd(e)}`};let i=e.tool_calls?.length??0;return{pass:i===t,message:()=>`${n.matcherHint("toHaveToolCallCount")}
384
-
385
- Expected ${r?"not ":""}${t} tool call(s)
386
- Received: ${i}`,actual:i,expected:t}}function iS(e,t){let{isNot:r,utils:n}=this;if(!je.isInstance(e))return{pass:!1,message:()=>`${n.matcherHint("toContainToolCall")}
387
-
388
- Expected: AIMessage
389
- Received: ${cd(e)}`};let i=e.tool_calls??[];return{pass:i.some(o=>Object.entries(t).every(([a,s])=>this.equals(o[a],s))),message:()=>`${n.matcherHint("toContainToolCall")}
390
-
391
- Expected AIMessage ${r?"not ":""}to contain a tool call matching ${n.printExpected(t)}
392
- Received tool calls: ${n.printReceived(i.map(o=>({name:o.name,id:o.id})))}`,actual:i.map(o=>({name:o.name,id:o.id})),expected:t}}function oS(e,t){let{isNot:r,utils:n}=this;if(!Array.isArray(e))return{pass:!1,message:()=>`${n.matcherHint("toHaveToolMessages")}
393
-
394
- Expected an array of messages
395
- Received: ${typeof e}`};let i=e.filter($t.isInstance);if(i.length!==t.length)return{pass:!1,message:()=>`${n.matcherHint("toHaveToolMessages")}
396
-
397
- Expected ${r?"not ":""}${t.length} tool message(s), found ${i.length}`,actual:i.length,expected:t.length};for(let o=0;o<t.length;o++)if(!Object.entries(t[o]).every(([a,s])=>this.equals(i[o][a],s)))return{pass:!1,message:()=>{let a={};for(let s of Object.keys(t[o]))a[s]=i[o][s];return`${n.matcherHint("toHaveToolMessages")}
398
-
399
- Tool message at index ${o} did not match:
400
- Expected: ${n.printExpected(t[o])}
401
- Received: ${n.printReceived(a)}`},actual:i[o],expected:t[o]};return{pass:!0,message:()=>`${n.matcherHint("toHaveToolMessages")}
402
-
403
- Expected messages not to contain matching tool messages`}}function aS(e,t){let{isNot:r,utils:n}=this,i=e?.__interrupt__;if(!(Array.isArray(i)&&i.length>0))return{pass:!1,message:()=>`${n.matcherHint("toHaveBeenInterrupted")}
404
-
405
- Expected result ${r?"not ":""}to have been interrupted
406
- Received __interrupt__: ${n.printReceived(i)}`};if(t===void 0)return{pass:!0,message:()=>`${n.matcherHint("toHaveBeenInterrupted")}
407
-
408
- Expected result not to have been interrupted
409
- Received ${i.length} interrupt(s)`};let o=i[0]?.value;return{pass:this.equals(o,t),message:()=>`${n.matcherHint("toHaveBeenInterrupted")}
410
-
411
- Expected interrupt value: ${n.printExpected(t)}
412
- Received interrupt value: ${n.printReceived(o)}`,actual:o,expected:t}}function sS(e,t){let{isNot:r,utils:n}=this,i=e?.structuredResponse;return i===void 0?{pass:!1,message:()=>`${n.matcherHint("toHaveStructuredResponse")}
413
-
414
- Expected result ${r?"not ":""}to have a structured response
415
- Received structuredResponse: undefined`}:t===void 0?{pass:!0,message:()=>`${n.matcherHint("toHaveStructuredResponse")}
416
-
417
- Expected result not to have a structured response`}:{pass:Object.entries(t).every(([o,a])=>this.equals(i[o],a)),message:()=>`${n.matcherHint("toHaveStructuredResponse")}
418
-
419
- Expected structured response: ${n.printExpected(t)}
420
- Received structured response: ${n.printReceived(i)}`,actual:i,expected:t}}var ER={toBeHumanMessage:Y0,toBeAIMessage:Q0,toBeSystemMessage:eS,toBeToolMessage:tS,toHaveToolCalls:rS,toHaveToolCallCount:nS,toContainToolCall:iS,toHaveToolMessages:oS,toHaveBeenInterrupted:aS,toHaveStructuredResponse:sS,...uu};function LH(e){return e.map(t=>t.text).filter(Boolean).join("-")}var IR=0;function FH(){return IR+=1,`fake_tc_${IR}`}var cS=class $R extends ea{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}):Re.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??FH(),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],n=new $R;return n.queue=this.queue,n._alwaysThrowError=this._alwaysThrowError,n._structuredResponseValue=this._structuredResponseValue,n._tools=r,n._state=this._state,n.withConfig({})}withStructuredOutput(t,r){let{_structuredResponseValue:n}=this;return ir.from(async()=>n)}async _generate(t,r,n){this._state.calls.push({messages:[...t],options:r});let i=this._state.callIndex;if(this._state.callIndex+=1,this._alwaysThrowError)throw this._alwaysThrowError;let o=this.queue[i];if(!o)throw new Error(`FakeModel: no response queued for invocation ${i} (${this.queue.length} total queued).`);if(o.kind==="error")throw o.error;if(o.kind==="factory"){let s=o.factory(t);if(!Re.isInstance(s))throw s;return{generations:[{text:"",message:s}]}}if(o.kind==="message")return{generations:[{text:"",message:o.message}]};let a=LH(t);return{generations:[{text:a,message:new je({content:a,id:i.toString(),tool_calls:o.toolCalls.length>0?o.toolCalls.map(s=>({...s,type:"tool_call"})):void 0})}],llmOutput:{}}}};function TR(){return new cS}function Eh(e){return{async*[Symbol.asyncIterator](){for(let t of e)yield t}}}function Ih(e="test-model"){let t=ud(e),r=t[t.length-1];return t[t.length-1]={...r,usage:{prompt_tokens:10,completion_tokens:2,total_tokens:12}},t}function ud(e="test-model"){return[{id:"chatcmpl-text",model:e,choices:[{index:0,delta:{role:"assistant",content:"Hello"},finish_reason:null}]},{id:"chatcmpl-text",model:e,choices:[{index:0,delta:{content:" world"},finish_reason:null}]},{id:"chatcmpl-text",model:e,choices:[{index:0,delta:{},finish_reason:"stop"}]}]}function $h(e="test-model"){return[{id:"chatcmpl-reason",model:e,choices:[{index:0,delta:{role:"assistant",reasoning_content:"Let me reason..."},finish_reason:null}]},{id:"chatcmpl-reason",model:e,choices:[{index:0,delta:{content:"Answer."},finish_reason:null}]},{id:"chatcmpl-reason",model:e,choices:[{index:0,delta:{},finish_reason:"stop"}]}]}function Th(e="test-model"){return[{id:"chatcmpl-tools",model:e,choices:[{index:0,delta:{role:"assistant",content:"Let me search."},finish_reason:null}]},{id:"chatcmpl-tools",model:e,choices:[{index:0,delta:{tool_calls:[{index:0,id:"call_abc",type:"function",function:{name:"web_search",arguments:'{"query"'}}]},finish_reason:null}]},{id:"chatcmpl-tools",model:e,choices:[{index:0,delta:{tool_calls:[{index:0,function:{arguments:':"weather"}'}}]},finish_reason:null}]},{id:"chatcmpl-tools",model:e,choices:[{index:0,delta:{},finish_reason:"tool_calls"}]}]}function Ah(e){let t=new TextEncoder;return new Response(new ReadableStream({start(r){for(let n of e)r.enqueue(t.encode(`data: ${JSON.stringify(n)}
421
-
422
- `));r.close()}}),{status:200,headers:{"Content-Type":"text/event-stream"}})}var AR=A({FakeBuiltModel:()=>cS,asAsyncIterable:()=>Eh,fakeModel:()=>TR,langchainMatchers:()=>ER,openAIReasoningTextChunks:()=>$h,openAITextOnlyChunks:()=>ud,openAITextOnlyChunksWithUsage:()=>Ih,openAIToolCallChunks:()=>Th,sseResponseFromOpenAIChunks:()=>Ah,streamMatchers:()=>uu,toBeAIMessage:()=>Q0,toBeHumanMessage:()=>Y0,toBeSystemMessage:()=>eS,toBeToolMessage:()=>tS,toContainToolCall:()=>iS,toHaveBeenInterrupted:()=>aS,toHaveStructuredResponse:()=>sS,toHaveToolCallCount:()=>nS,toHaveToolCalls:()=>rS,toHaveToolMessages:()=>oS});function ld(e){return e!==void 0&&Array.isArray(e.lc_namespace)}function dd(e){return e!==void 0&&ce.isRunnable(e)&&"lc_name"in e.constructor&&typeof e.constructor.lc_name=="function"&&e.constructor.lc_name()==="RunnableToolLike"}function fd(e){return!!e&&typeof e=="object"&&"name"in e&&"schema"in e&&(Pr(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 pd(e){return fd(e)||dd(e)||ld(e)}var pn={};Fn(pn,{$brand:()=>iv,$input:()=>Sw,$output:()=>xw,NEVER:()=>nv,TimePrecision:()=>$w,ZodAny:()=>PS,ZodArray:()=>MS,ZodBase64:()=>Jh,ZodBase64URL:()=>Xh,ZodBigInt:()=>_u,ZodBigIntFormat:()=>eg,ZodBoolean:()=>gu,ZodCIDRv4:()=>qh,ZodCIDRv6:()=>Kh,ZodCUID:()=>Fh,ZodCUID2:()=>Bh,ZodCatch:()=>ik,ZodCodec:()=>Id,ZodCustom:()=>$d,ZodCustomStringFormat:()=>mu,ZodDate:()=>wd,ZodDefault:()=>YS,ZodDiscriminatedUnion:()=>zS,ZodE164:()=>Yh,ZodEmail:()=>zh,ZodEmoji:()=>Uh,ZodEnum:()=>fu,ZodError:()=>BH,ZodExactOptional:()=>KS,ZodFile:()=>WS,ZodFirstPartyTypeKind:()=>_k,ZodFunction:()=>mk,ZodGUID:()=>gd,ZodIPv4:()=>Gh,ZodIPv6:()=>Wh,ZodISODate:()=>Ph,ZodISODateTime:()=>Oh,ZodISODuration:()=>Rh,ZodISOTime:()=>Nh,ZodIntersection:()=>US,ZodIssueCode:()=>HH,ZodJWT:()=>Qh,ZodKSUID:()=>Zh,ZodLazy:()=>dk,ZodLiteral:()=>GS,ZodMAC:()=>ES,ZodMap:()=>HS,ZodNaN:()=>ak,ZodNanoID:()=>Lh,ZodNever:()=>RS,ZodNonOptional:()=>ag,ZodNull:()=>CS,ZodNullable:()=>XS,ZodNumber:()=>hu,ZodNumberFormat:()=>As,ZodObject:()=>Sd,ZodOptional:()=>og,ZodPipe:()=>Ed,ZodPrefault:()=>ek,ZodPreprocess:()=>sk,ZodPromise:()=>pk,ZodReadonly:()=>ck,ZodRealError:()=>Mr,ZodRecord:()=>du,ZodSet:()=>ZS,ZodString:()=>pu,ZodStringFormat:()=>Ze,ZodSuccess:()=>nk,ZodSymbol:()=>TS,ZodTemplateLiteral:()=>lk,ZodTransform:()=>qS,ZodTuple:()=>FS,ZodType:()=>ve,ZodULID:()=>Vh,ZodURL:()=>bd,ZodUUID:()=>gi,ZodUndefined:()=>AS,ZodUnion:()=>kd,ZodUnknown:()=>NS,ZodVoid:()=>jS,ZodXID:()=>Hh,ZodXor:()=>DS,_ZodString:()=>Dh,_default:()=>QS,_function:()=>zj,any:()=>hj,array:()=>xd,base64:()=>YR,base64url:()=>QR,bigint:()=>lj,boolean:()=>$S,catch:()=>ok,check:()=>Uj,cidrv4:()=>JR,cidrv6:()=>XR,clone:()=>rt,codec:()=>Rj,coerce:()=>yk,config:()=>pt,core:()=>zi,cuid:()=>BR,cuid2:()=>VR,custom:()=>Lj,date:()=>_j,decode:()=>yS,decodeAsync:()=>bS,describe:()=>Fj,discriminatedUnion:()=>Sj,e164:()=>ej,email:()=>PR,emoji:()=>LR,encode:()=>_S,encodeAsync:()=>vS,endsWith:()=>Nc,enum:()=>ng,exactOptional:()=>JS,file:()=>Cj,flattenError:()=>_l,float32:()=>aj,float64:()=>sj,formatError:()=>yl,fromJSONSchema:()=>qj,function:()=>zj,getErrorMap:()=>GH,globalRegistry:()=>Le,gt:()=>oi,gte:()=>br,guid:()=>NR,hash:()=>oj,hex:()=>ij,hostname:()=>nj,httpUrl:()=>UR,includes:()=>Oc,instanceof:()=>Vj,int:()=>jh,int32:()=>cj,int64:()=>dj,intersection:()=>LS,invertCodec:()=>jj,ipv4:()=>WR,ipv6:()=>KR,iso:()=>lu,json:()=>Zj,jwt:()=>tj,keyof:()=>yj,ksuid:()=>GR,lazy:()=>fk,length:()=>os,literal:()=>Aj,locales:()=>Tl,looseObject:()=>wj,looseRecord:()=>Ej,lowercase:()=>Ac,lt:()=>ii,lte:()=>qr,mac:()=>qR,map:()=>Ij,maxLength:()=>is,maxSize:()=>Fo,meta:()=>Bj,mime:()=>Rc,minLength:()=>Di,minSize:()=>ai,multipleOf:()=>Lo,nan:()=>Nj,nanoid:()=>FR,nativeEnum:()=>Tj,negative:()=>Sm,never:()=>tg,nonnegative:()=>Em,nonoptional:()=>rk,nonpositive:()=>km,normalize:()=>jc,null:()=>OS,nullable:()=>yd,nullish:()=>Oj,number:()=>IS,object:()=>vj,optional:()=>_d,overwrite:()=>kn,parse:()=>pS,parseAsync:()=>mS,partialRecord:()=>kj,pipe:()=>Mh,positive:()=>xm,prefault:()=>tk,preprocess:()=>Gj,prettifyError:()=>_v,promise:()=>Dj,property:()=>Im,readonly:()=>uk,record:()=>VS,refine:()=>hk,regex:()=>Tc,regexes:()=>Wr,registry:()=>tm,safeDecode:()=>xS,safeDecodeAsync:()=>kS,safeEncode:()=>wS,safeEncodeAsync:()=>SS,safeParse:()=>hS,safeParseAsync:()=>gS,set:()=>$j,setErrorMap:()=>ZH,size:()=>ns,slugify:()=>Uc,startsWith:()=>Pc,strictObject:()=>bj,string:()=>hd,stringFormat:()=>rj,stringbool:()=>Hj,success:()=>Pj,superRefine:()=>gk,symbol:()=>pj,templateLiteral:()=>Mj,toJSONSchema:()=>as,toLowerCase:()=>Dc,toUpperCase:()=>zc,transform:()=>ig,treeifyError:()=>gv,trim:()=>Mc,tuple:()=>BS,uint32:()=>uj,uint64:()=>fj,ulid:()=>HR,undefined:()=>mj,union:()=>rg,unknown:()=>Ts,uppercase:()=>Cc,url:()=>zR,util:()=>D,uuid:()=>RR,uuidv4:()=>jR,uuidv6:()=>MR,uuidv7:()=>DR,void:()=>gj,xid:()=>ZR,xor:()=>xj});var md={};Fn(md,{ZodAny:()=>PS,ZodArray:()=>MS,ZodBase64:()=>Jh,ZodBase64URL:()=>Xh,ZodBigInt:()=>_u,ZodBigIntFormat:()=>eg,ZodBoolean:()=>gu,ZodCIDRv4:()=>qh,ZodCIDRv6:()=>Kh,ZodCUID:()=>Fh,ZodCUID2:()=>Bh,ZodCatch:()=>ik,ZodCodec:()=>Id,ZodCustom:()=>$d,ZodCustomStringFormat:()=>mu,ZodDate:()=>wd,ZodDefault:()=>YS,ZodDiscriminatedUnion:()=>zS,ZodE164:()=>Yh,ZodEmail:()=>zh,ZodEmoji:()=>Uh,ZodEnum:()=>fu,ZodExactOptional:()=>KS,ZodFile:()=>WS,ZodFunction:()=>mk,ZodGUID:()=>gd,ZodIPv4:()=>Gh,ZodIPv6:()=>Wh,ZodIntersection:()=>US,ZodJWT:()=>Qh,ZodKSUID:()=>Zh,ZodLazy:()=>dk,ZodLiteral:()=>GS,ZodMAC:()=>ES,ZodMap:()=>HS,ZodNaN:()=>ak,ZodNanoID:()=>Lh,ZodNever:()=>RS,ZodNonOptional:()=>ag,ZodNull:()=>CS,ZodNullable:()=>XS,ZodNumber:()=>hu,ZodNumberFormat:()=>As,ZodObject:()=>Sd,ZodOptional:()=>og,ZodPipe:()=>Ed,ZodPrefault:()=>ek,ZodPreprocess:()=>sk,ZodPromise:()=>pk,ZodReadonly:()=>ck,ZodRecord:()=>du,ZodSet:()=>ZS,ZodString:()=>pu,ZodStringFormat:()=>Ze,ZodSuccess:()=>nk,ZodSymbol:()=>TS,ZodTemplateLiteral:()=>lk,ZodTransform:()=>qS,ZodTuple:()=>FS,ZodType:()=>ve,ZodULID:()=>Vh,ZodURL:()=>bd,ZodUUID:()=>gi,ZodUndefined:()=>AS,ZodUnion:()=>kd,ZodUnknown:()=>NS,ZodVoid:()=>jS,ZodXID:()=>Hh,ZodXor:()=>DS,_ZodString:()=>Dh,_default:()=>QS,_function:()=>zj,any:()=>hj,array:()=>xd,base64:()=>YR,base64url:()=>QR,bigint:()=>lj,boolean:()=>$S,catch:()=>ok,check:()=>Uj,cidrv4:()=>JR,cidrv6:()=>XR,codec:()=>Rj,cuid:()=>BR,cuid2:()=>VR,custom:()=>Lj,date:()=>_j,describe:()=>Fj,discriminatedUnion:()=>Sj,e164:()=>ej,email:()=>PR,emoji:()=>LR,enum:()=>ng,exactOptional:()=>JS,file:()=>Cj,float32:()=>aj,float64:()=>sj,function:()=>zj,guid:()=>NR,hash:()=>oj,hex:()=>ij,hostname:()=>nj,httpUrl:()=>UR,instanceof:()=>Vj,int:()=>jh,int32:()=>cj,int64:()=>dj,intersection:()=>LS,invertCodec:()=>jj,ipv4:()=>WR,ipv6:()=>KR,json:()=>Zj,jwt:()=>tj,keyof:()=>yj,ksuid:()=>GR,lazy:()=>fk,literal:()=>Aj,looseObject:()=>wj,looseRecord:()=>Ej,mac:()=>qR,map:()=>Ij,meta:()=>Bj,nan:()=>Nj,nanoid:()=>FR,nativeEnum:()=>Tj,never:()=>tg,nonoptional:()=>rk,null:()=>OS,nullable:()=>yd,nullish:()=>Oj,number:()=>IS,object:()=>vj,optional:()=>_d,partialRecord:()=>kj,pipe:()=>Mh,prefault:()=>tk,preprocess:()=>Gj,promise:()=>Dj,readonly:()=>uk,record:()=>VS,refine:()=>hk,set:()=>$j,strictObject:()=>bj,string:()=>hd,stringFormat:()=>rj,stringbool:()=>Hj,success:()=>Pj,superRefine:()=>gk,symbol:()=>pj,templateLiteral:()=>Mj,transform:()=>ig,tuple:()=>BS,uint32:()=>uj,uint64:()=>fj,ulid:()=>HR,undefined:()=>mj,union:()=>rg,unknown:()=>Ts,url:()=>zR,uuid:()=>RR,uuidv4:()=>jR,uuidv6:()=>MR,uuidv7:()=>DR,void:()=>gj,xid:()=>ZR,xor:()=>xj});var Ch={};Fn(Ch,{endsWith:()=>Nc,gt:()=>oi,gte:()=>br,includes:()=>Oc,length:()=>os,lowercase:()=>Ac,lt:()=>ii,lte:()=>qr,maxLength:()=>is,maxSize:()=>Fo,mime:()=>Rc,minLength:()=>Di,minSize:()=>ai,multipleOf:()=>Lo,negative:()=>Sm,nonnegative:()=>Em,nonpositive:()=>km,normalize:()=>jc,overwrite:()=>kn,positive:()=>xm,property:()=>Im,regex:()=>Tc,size:()=>ns,slugify:()=>Uc,startsWith:()=>Pc,toLowerCase:()=>Dc,toUpperCase:()=>zc,trim:()=>Mc,uppercase:()=>Cc});var lu={};Fn(lu,{ZodISODate:()=>Ph,ZodISODateTime:()=>Oh,ZodISODuration:()=>Rh,ZodISOTime:()=>Nh,date:()=>lS,datetime:()=>uS,duration:()=>fS,time:()=>dS});var Oh=k("ZodISODateTime",(e,t)=>{Ib.init(e,t),Ze.init(e,t)});function uS(e){return Tw(Oh,e)}var Ph=k("ZodISODate",(e,t)=>{$b.init(e,t),Ze.init(e,t)});function lS(e){return Aw(Ph,e)}var Nh=k("ZodISOTime",(e,t)=>{Tb.init(e,t),Ze.init(e,t)});function dS(e){return Cw(Nh,e)}var Rh=k("ZodISODuration",(e,t)=>{Ab.init(e,t),Ze.init(e,t)});function fS(e){return Ow(Rh,e)}var CR=(e,t)=>{gl.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>yl(e,r)},flatten:{value:r=>_l(e,r)},addIssue:{value:r=>{e.issues.push(r),e.message=JSON.stringify(e.issues,vc,2)}},addIssues:{value:r=>{e.issues.push(...r),e.message=JSON.stringify(e.issues,vc,2)}},isEmpty:{get(){return e.issues.length===0}}})},BH=k("ZodError",CR),Mr=k("ZodError",CR,{Parent:Error});var pS=xc(Mr),mS=Sc(Mr),hS=kc(Mr),gS=Ec(Mr),_S=Op(Mr),yS=Pp(Mr),vS=Np(Mr),bS=Rp(Mr),wS=jp(Mr),xS=Mp(Mr),SS=Dp(Mr),kS=zp(Mr);var OR=new WeakMap;function vd(e,t,r){let n=Object.getPrototypeOf(e),i=OR.get(n);if(i||(i=new Set,OR.set(n,i)),!i.has(t)){i.add(t);for(let o in r){let a=r[o];Object.defineProperty(n,o,{configurable:!0,enumerable:!1,get(){let s=a.bind(this);return Object.defineProperty(this,o,{configurable:!0,writable:!0,enumerable:!0,value:s}),s},set(s){Object.defineProperty(this,o,{configurable:!0,writable:!0,enumerable:!0,value:s})}})}}}var ve=k("ZodType",(e,t)=>(he.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Fc(e,"input"),output:Fc(e,"output")}}),e.toJSONSchema=sx(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(r,n)=>pS(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>hS(e,r,n),e.parseAsync=async(r,n)=>mS(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>gS(e,r,n),e.spa=e.safeParseAsync,e.encode=(r,n)=>_S(e,r,n),e.decode=(r,n)=>yS(e,r,n),e.encodeAsync=async(r,n)=>vS(e,r,n),e.decodeAsync=async(r,n)=>bS(e,r,n),e.safeEncode=(r,n)=>wS(e,r,n),e.safeDecode=(r,n)=>xS(e,r,n),e.safeEncodeAsync=async(r,n)=>SS(e,r,n),e.safeDecodeAsync=async(r,n)=>kS(e,r,n),vd(e,"ZodType",{check(...r){let n=this.def;return this.clone(D.mergeDefs(n,{checks:[...n.checks??[],...r.map(i=>typeof i=="function"?{_zod:{check:i,def:{check:"custom"},onattach:[]}}:i)]}),{parent:!0})},with(...r){return this.check(...r)},clone(r,n){return rt(this,r,n)},brand(){return this},register(r,n){return r.add(this,n),this},refine(r,n){return this.check(hk(r,n))},superRefine(r,n){return this.check(gk(r,n))},overwrite(r){return this.check(kn(r))},optional(){return _d(this)},exactOptional(){return JS(this)},nullable(){return yd(this)},nullish(){return _d(yd(this))},nonoptional(r){return rk(this,r)},array(){return xd(this)},or(r){return rg([this,r])},and(r){return LS(this,r)},transform(r){return Mh(this,ig(r))},default(r){return QS(this,r)},prefault(r){return tk(this,r)},catch(r){return ok(this,r)},pipe(r){return Mh(this,r)},readonly(){return uk(this)},describe(r){let n=this.clone();return Le.add(n,{description:r}),n},meta(...r){if(r.length===0)return Le.get(this);let n=this.clone();return Le.add(n,r[0]),n},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(r){return r(this)}}),Object.defineProperty(e,"description",{get(){return Le.get(e)?.description},configurable:!0}),e)),Dh=k("_ZodString",(e,t)=>{ts.init(e,t),ve.init(e,t),e._zod.processJSONSchema=(n,i,o)=>cx(e,n,i,o);let r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,vd(e,"_ZodString",{regex(...n){return this.check(Tc(...n))},includes(...n){return this.check(Oc(...n))},startsWith(...n){return this.check(Pc(...n))},endsWith(...n){return this.check(Nc(...n))},min(...n){return this.check(Di(...n))},max(...n){return this.check(is(...n))},length(...n){return this.check(os(...n))},nonempty(...n){return this.check(Di(1,...n))},lowercase(n){return this.check(Ac(n))},uppercase(n){return this.check(Cc(n))},trim(){return this.check(Mc())},normalize(...n){return this.check(jc(...n))},toLowerCase(){return this.check(Dc())},toUpperCase(){return this.check(zc())},slugify(){return this.check(Uc())}})}),pu=k("ZodString",(e,t)=>{ts.init(e,t),Dh.init(e,t),e.email=r=>e.check(rm(zh,r)),e.url=r=>e.check(Cl(bd,r)),e.jwt=r=>e.check(wm(Qh,r)),e.emoji=r=>e.check(sm(Uh,r)),e.guid=r=>e.check(Al(gd,r)),e.uuid=r=>e.check(nm(gi,r)),e.uuidv4=r=>e.check(im(gi,r)),e.uuidv6=r=>e.check(om(gi,r)),e.uuidv7=r=>e.check(am(gi,r)),e.nanoid=r=>e.check(cm(Lh,r)),e.guid=r=>e.check(Al(gd,r)),e.cuid=r=>e.check(um(Fh,r)),e.cuid2=r=>e.check(lm(Bh,r)),e.ulid=r=>e.check(dm(Vh,r)),e.base64=r=>e.check(ym(Jh,r)),e.base64url=r=>e.check(vm(Xh,r)),e.xid=r=>e.check(fm(Hh,r)),e.ksuid=r=>e.check(pm(Zh,r)),e.ipv4=r=>e.check(mm(Gh,r)),e.ipv6=r=>e.check(hm(Wh,r)),e.cidrv4=r=>e.check(gm(qh,r)),e.cidrv6=r=>e.check(_m(Kh,r)),e.e164=r=>e.check(bm(Yh,r)),e.datetime=r=>e.check(uS(r)),e.date=r=>e.check(lS(r)),e.time=r=>e.check(dS(r)),e.duration=r=>e.check(fS(r))});function hd(e){return kw(pu,e)}var Ze=k("ZodStringFormat",(e,t)=>{He.init(e,t),Dh.init(e,t)}),zh=k("ZodEmail",(e,t)=>{_b.init(e,t),Ze.init(e,t)});function PR(e){return rm(zh,e)}var gd=k("ZodGUID",(e,t)=>{hb.init(e,t),Ze.init(e,t)});function NR(e){return Al(gd,e)}var gi=k("ZodUUID",(e,t)=>{gb.init(e,t),Ze.init(e,t)});function RR(e){return nm(gi,e)}function jR(e){return im(gi,e)}function MR(e){return om(gi,e)}function DR(e){return am(gi,e)}var bd=k("ZodURL",(e,t)=>{yb.init(e,t),Ze.init(e,t)});function zR(e){return Cl(bd,e)}function UR(e){return Cl(bd,{protocol:Wr.httpProtocol,hostname:Wr.domain,...D.normalizeParams(e)})}var Uh=k("ZodEmoji",(e,t)=>{vb.init(e,t),Ze.init(e,t)});function LR(e){return sm(Uh,e)}var Lh=k("ZodNanoID",(e,t)=>{bb.init(e,t),Ze.init(e,t)});function FR(e){return cm(Lh,e)}var Fh=k("ZodCUID",(e,t)=>{wb.init(e,t),Ze.init(e,t)});function BR(e){return um(Fh,e)}var Bh=k("ZodCUID2",(e,t)=>{xb.init(e,t),Ze.init(e,t)});function VR(e){return lm(Bh,e)}var Vh=k("ZodULID",(e,t)=>{Sb.init(e,t),Ze.init(e,t)});function HR(e){return dm(Vh,e)}var Hh=k("ZodXID",(e,t)=>{kb.init(e,t),Ze.init(e,t)});function ZR(e){return fm(Hh,e)}var Zh=k("ZodKSUID",(e,t)=>{Eb.init(e,t),Ze.init(e,t)});function GR(e){return pm(Zh,e)}var Gh=k("ZodIPv4",(e,t)=>{Cb.init(e,t),Ze.init(e,t)});function WR(e){return mm(Gh,e)}var ES=k("ZodMAC",(e,t)=>{Pb.init(e,t),Ze.init(e,t)});function qR(e){return Iw(ES,e)}var Wh=k("ZodIPv6",(e,t)=>{Ob.init(e,t),Ze.init(e,t)});function KR(e){return hm(Wh,e)}var qh=k("ZodCIDRv4",(e,t)=>{Nb.init(e,t),Ze.init(e,t)});function JR(e){return gm(qh,e)}var Kh=k("ZodCIDRv6",(e,t)=>{Rb.init(e,t),Ze.init(e,t)});function XR(e){return _m(Kh,e)}var Jh=k("ZodBase64",(e,t)=>{Mb.init(e,t),Ze.init(e,t)});function YR(e){return ym(Jh,e)}var Xh=k("ZodBase64URL",(e,t)=>{Db.init(e,t),Ze.init(e,t)});function QR(e){return vm(Xh,e)}var Yh=k("ZodE164",(e,t)=>{zb.init(e,t),Ze.init(e,t)});function ej(e){return bm(Yh,e)}var Qh=k("ZodJWT",(e,t)=>{Ub.init(e,t),Ze.init(e,t)});function tj(e){return wm(Qh,e)}var mu=k("ZodCustomStringFormat",(e,t)=>{Lb.init(e,t),Ze.init(e,t)});function rj(e,t,r={}){return Lc(mu,e,t,r)}function nj(e){return Lc(mu,"hostname",Wr.hostname,e)}function ij(e){return Lc(mu,"hex",Wr.hex,e)}function oj(e,t){let r=t?.enc??"hex",n=`${e}_${r}`,i=Wr[n];if(!i)throw new Error(`Unrecognized hash format: ${n}`);return Lc(mu,n,i,t)}var hu=k("ZodNumber",(e,t)=>{Wp.init(e,t),ve.init(e,t),e._zod.processJSONSchema=(n,i,o)=>ux(e,n,i,o),vd(e,"ZodNumber",{gt(n,i){return this.check(oi(n,i))},gte(n,i){return this.check(br(n,i))},min(n,i){return this.check(br(n,i))},lt(n,i){return this.check(ii(n,i))},lte(n,i){return this.check(qr(n,i))},max(n,i){return this.check(qr(n,i))},int(n){return this.check(jh(n))},safe(n){return this.check(jh(n))},positive(n){return this.check(oi(0,n))},nonnegative(n){return this.check(br(0,n))},negative(n){return this.check(ii(0,n))},nonpositive(n){return this.check(qr(0,n))},multipleOf(n,i){return this.check(Lo(n,i))},step(n,i){return this.check(Lo(n,i))},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 IS(e){return Pw(hu,e)}var As=k("ZodNumberFormat",(e,t)=>{Fb.init(e,t),hu.init(e,t)});function jh(e){return Rw(As,e)}function aj(e){return jw(As,e)}function sj(e){return Mw(As,e)}function cj(e){return Dw(As,e)}function uj(e){return zw(As,e)}var gu=k("ZodBoolean",(e,t)=>{xl.init(e,t),ve.init(e,t),e._zod.processJSONSchema=(r,n,i)=>lx(e,r,n,i)});function $S(e){return Uw(gu,e)}var _u=k("ZodBigInt",(e,t)=>{qp.init(e,t),ve.init(e,t),e._zod.processJSONSchema=(n,i,o)=>dx(e,n,i,o),e.gte=(n,i)=>e.check(br(n,i)),e.min=(n,i)=>e.check(br(n,i)),e.gt=(n,i)=>e.check(oi(n,i)),e.gte=(n,i)=>e.check(br(n,i)),e.min=(n,i)=>e.check(br(n,i)),e.lt=(n,i)=>e.check(ii(n,i)),e.lte=(n,i)=>e.check(qr(n,i)),e.max=(n,i)=>e.check(qr(n,i)),e.positive=n=>e.check(oi(BigInt(0),n)),e.negative=n=>e.check(ii(BigInt(0),n)),e.nonpositive=n=>e.check(qr(BigInt(0),n)),e.nonnegative=n=>e.check(br(BigInt(0),n)),e.multipleOf=(n,i)=>e.check(Lo(n,i));let r=e._zod.bag;e.minValue=r.minimum??null,e.maxValue=r.maximum??null,e.format=r.format??null});function lj(e){return Fw(_u,e)}var eg=k("ZodBigIntFormat",(e,t)=>{Bb.init(e,t),_u.init(e,t)});function dj(e){return Vw(eg,e)}function fj(e){return Hw(eg,e)}var TS=k("ZodSymbol",(e,t)=>{Vb.init(e,t),ve.init(e,t),e._zod.processJSONSchema=(r,n,i)=>fx(e,r,n,i)});function pj(e){return Zw(TS,e)}var AS=k("ZodUndefined",(e,t)=>{Hb.init(e,t),ve.init(e,t),e._zod.processJSONSchema=(r,n,i)=>mx(e,r,n,i)});function mj(e){return Gw(AS,e)}var CS=k("ZodNull",(e,t)=>{Zb.init(e,t),ve.init(e,t),e._zod.processJSONSchema=(r,n,i)=>px(e,r,n,i)});function OS(e){return Ww(CS,e)}var PS=k("ZodAny",(e,t)=>{Gb.init(e,t),ve.init(e,t),e._zod.processJSONSchema=(r,n,i)=>_x(e,r,n,i)});function hj(){return qw(PS)}var NS=k("ZodUnknown",(e,t)=>{Sl.init(e,t),ve.init(e,t),e._zod.processJSONSchema=(r,n,i)=>yx(e,r,n,i)});function Ts(){return Ol(NS)}var RS=k("ZodNever",(e,t)=>{kl.init(e,t),ve.init(e,t),e._zod.processJSONSchema=(r,n,i)=>gx(e,r,n,i)});function tg(e){return Pl(RS,e)}var jS=k("ZodVoid",(e,t)=>{Wb.init(e,t),ve.init(e,t),e._zod.processJSONSchema=(r,n,i)=>hx(e,r,n,i)});function gj(e){return Kw(jS,e)}var wd=k("ZodDate",(e,t)=>{qb.init(e,t),ve.init(e,t),e._zod.processJSONSchema=(n,i,o)=>vx(e,n,i,o),e.min=(n,i)=>e.check(br(n,i)),e.max=(n,i)=>e.check(qr(n,i));let r=e._zod.bag;e.minDate=r.minimum?new Date(r.minimum):null,e.maxDate=r.maximum?new Date(r.maximum):null});function _j(e){return Jw(wd,e)}var MS=k("ZodArray",(e,t)=>{Kb.init(e,t),ve.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Ox(e,r,n,i),e.element=t.element,vd(e,"ZodArray",{min(r,n){return this.check(Di(r,n))},nonempty(r){return this.check(Di(1,r))},max(r,n){return this.check(is(r,n))},length(r,n){return this.check(os(r,n))},unwrap(){return this.element}})});function xd(e,t){return Qw(MS,e,t)}function yj(e){let t=e._zod.def.shape;return ng(Object.keys(t))}var Sd=k("ZodObject",(e,t)=>{Jb.init(e,t),ve.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Px(e,r,n,i),D.defineLazy(e,"shape",()=>t.shape),vd(e,"ZodObject",{keyof(){return ng(Object.keys(this._zod.def.shape))},catchall(r){return this.clone({...this._zod.def,catchall:r})},passthrough(){return this.clone({...this._zod.def,catchall:Ts()})},loose(){return this.clone({...this._zod.def,catchall:Ts()})},strict(){return this.clone({...this._zod.def,catchall:tg()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(r){return D.extend(this,r)},safeExtend(r){return D.safeExtend(this,r)},merge(r){return D.merge(this,r)},pick(r){return D.pick(this,r)},omit(r){return D.omit(this,r)},partial(...r){return D.partial(og,this,r[0])},required(...r){return D.required(ag,this,r[0])}})});function vj(e,t){let r={type:"object",shape:e??{},...D.normalizeParams(t)};return new Sd(r)}function bj(e,t){return new Sd({type:"object",shape:e,catchall:tg(),...D.normalizeParams(t)})}function wj(e,t){return new Sd({type:"object",shape:e,catchall:Ts(),...D.normalizeParams(t)})}var kd=k("ZodUnion",(e,t)=>{El.init(e,t),ve.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Tm(e,r,n,i),e.options=t.options});function rg(e,t){return new kd({type:"union",options:e,...D.normalizeParams(t)})}var DS=k("ZodXor",(e,t)=>{kd.init(e,t),Xb.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Tm(e,r,n,i),e.options=t.options});function xj(e,t){return new DS({type:"union",options:e,inclusive:!1,...D.normalizeParams(t)})}var zS=k("ZodDiscriminatedUnion",(e,t)=>{kd.init(e,t),Yb.init(e,t)});function Sj(e,t,r){return new zS({type:"union",options:t,discriminator:e,...D.normalizeParams(r)})}var US=k("ZodIntersection",(e,t)=>{Qb.init(e,t),ve.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Nx(e,r,n,i)});function LS(e,t){return new US({type:"intersection",left:e,right:t})}var FS=k("ZodTuple",(e,t)=>{Kp.init(e,t),ve.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Rx(e,r,n,i),e.rest=r=>e.clone({...e._zod.def,rest:r})});function BS(e,t,r){let n=t instanceof he,i=n?r:t,o=n?t:null;return new FS({type:"tuple",items:e,rest:o,...D.normalizeParams(i)})}var du=k("ZodRecord",(e,t)=>{ew.init(e,t),ve.init(e,t),e._zod.processJSONSchema=(r,n,i)=>jx(e,r,n,i),e.keyType=t.keyType,e.valueType=t.valueType});function VS(e,t,r){return!t||!t._zod?new du({type:"record",keyType:hd(),valueType:e,...D.normalizeParams(t)}):new du({type:"record",keyType:e,valueType:t,...D.normalizeParams(r)})}function kj(e,t,r){let n=rt(e);return n._zod.values=void 0,new du({type:"record",keyType:n,valueType:t,...D.normalizeParams(r)})}function Ej(e,t,r){return new du({type:"record",keyType:e,valueType:t,mode:"loose",...D.normalizeParams(r)})}var HS=k("ZodMap",(e,t)=>{tw.init(e,t),ve.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Ax(e,r,n,i),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...r)=>e.check(ai(...r)),e.nonempty=r=>e.check(ai(1,r)),e.max=(...r)=>e.check(Fo(...r)),e.size=(...r)=>e.check(ns(...r))});function Ij(e,t,r){return new HS({type:"map",keyType:e,valueType:t,...D.normalizeParams(r)})}var ZS=k("ZodSet",(e,t)=>{rw.init(e,t),ve.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Cx(e,r,n,i),e.min=(...r)=>e.check(ai(...r)),e.nonempty=r=>e.check(ai(1,r)),e.max=(...r)=>e.check(Fo(...r)),e.size=(...r)=>e.check(ns(...r))});function $j(e,t){return new ZS({type:"set",valueType:e,...D.normalizeParams(t)})}var fu=k("ZodEnum",(e,t)=>{nw.init(e,t),ve.init(e,t),e._zod.processJSONSchema=(n,i,o)=>bx(e,n,i,o),e.enum=t.entries,e.options=Object.values(t.entries);let r=new Set(Object.keys(t.entries));e.extract=(n,i)=>{let o={};for(let a of n)if(r.has(a))o[a]=t.entries[a];else throw new Error(`Key ${a} not found in enum`);return new fu({...t,checks:[],...D.normalizeParams(i),entries:o})},e.exclude=(n,i)=>{let o={...t.entries};for(let a of n)if(r.has(a))delete o[a];else throw new Error(`Key ${a} not found in enum`);return new fu({...t,checks:[],...D.normalizeParams(i),entries:o})}});function ng(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new fu({type:"enum",entries:r,...D.normalizeParams(t)})}function Tj(e,t){return new fu({type:"enum",entries:e,...D.normalizeParams(t)})}var GS=k("ZodLiteral",(e,t)=>{iw.init(e,t),ve.init(e,t),e._zod.processJSONSchema=(r,n,i)=>wx(e,r,n,i),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 Aj(e,t){return new GS({type:"literal",values:Array.isArray(e)?e:[e],...D.normalizeParams(t)})}var WS=k("ZodFile",(e,t)=>{ow.init(e,t),ve.init(e,t),e._zod.processJSONSchema=(r,n,i)=>kx(e,r,n,i),e.min=(r,n)=>e.check(ai(r,n)),e.max=(r,n)=>e.check(Fo(r,n)),e.mime=(r,n)=>e.check(Rc(Array.isArray(r)?r:[r],n))});function Cj(e){return ex(WS,e)}var qS=k("ZodTransform",(e,t)=>{aw.init(e,t),ve.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Tx(e,r,n,i),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Ro(e.constructor.name);r.addIssue=o=>{if(typeof o=="string")r.issues.push(D.issue(o,r.value,t));else{let a=o;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),a.input??(a.input=r.value),a.inst??(a.inst=e),r.issues.push(D.issue(a))}};let i=t.transform(r.value,r);return i instanceof Promise?i.then(o=>(r.value=o,r.fallback=!0,r)):(r.value=i,r.fallback=!0,r)}});function ig(e){return new qS({type:"transform",transform:e})}var og=k("ZodOptional",(e,t)=>{rs.init(e,t),ve.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Am(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function _d(e){return new og({type:"optional",innerType:e})}var KS=k("ZodExactOptional",(e,t)=>{sw.init(e,t),ve.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Am(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function JS(e){return new KS({type:"optional",innerType:e})}var XS=k("ZodNullable",(e,t)=>{cw.init(e,t),ve.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Mx(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function yd(e){return new XS({type:"nullable",innerType:e})}function Oj(e){return _d(yd(e))}var YS=k("ZodDefault",(e,t)=>{uw.init(e,t),ve.init(e,t),e._zod.processJSONSchema=(r,n,i)=>zx(e,r,n,i),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function QS(e,t){return new YS({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():D.shallowClone(t)}})}var ek=k("ZodPrefault",(e,t)=>{lw.init(e,t),ve.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Ux(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function tk(e,t){return new ek({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():D.shallowClone(t)}})}var ag=k("ZodNonOptional",(e,t)=>{dw.init(e,t),ve.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Dx(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function rk(e,t){return new ag({type:"nonoptional",innerType:e,...D.normalizeParams(t)})}var nk=k("ZodSuccess",(e,t)=>{fw.init(e,t),ve.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Ex(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function Pj(e){return new nk({type:"success",innerType:e})}var ik=k("ZodCatch",(e,t)=>{pw.init(e,t),ve.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Lx(e,r,n,i),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function ok(e,t){return new ik({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}var ak=k("ZodNaN",(e,t)=>{mw.init(e,t),ve.init(e,t),e._zod.processJSONSchema=(r,n,i)=>xx(e,r,n,i)});function Nj(e){return Yw(ak,e)}var Ed=k("ZodPipe",(e,t)=>{Jp.init(e,t),ve.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Fx(e,r,n,i),e.in=t.in,e.out=t.out});function Mh(e,t){return new Ed({type:"pipe",in:e,out:t})}var Id=k("ZodCodec",(e,t)=>{Ed.init(e,t),Il.init(e,t)});function Rj(e,t,r){return new Id({type:"pipe",in:e,out:t,transform:r.decode,reverseTransform:r.encode})}function jj(e){let t=e._zod.def;return new Id({type:"pipe",in:t.out,out:t.in,transform:t.reverseTransform,reverseTransform:t.transform})}var sk=k("ZodPreprocess",(e,t)=>{Ed.init(e,t),hw.init(e,t)}),ck=k("ZodReadonly",(e,t)=>{gw.init(e,t),ve.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Bx(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function uk(e){return new ck({type:"readonly",innerType:e})}var lk=k("ZodTemplateLiteral",(e,t)=>{_w.init(e,t),ve.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Sx(e,r,n,i)});function Mj(e,t){return new lk({type:"template_literal",parts:e,...D.normalizeParams(t)})}var dk=k("ZodLazy",(e,t)=>{bw.init(e,t),ve.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Hx(e,r,n,i),e.unwrap=()=>e._zod.def.getter()});function fk(e){return new dk({type:"lazy",getter:e})}var pk=k("ZodPromise",(e,t)=>{vw.init(e,t),ve.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Vx(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function Dj(e){return new pk({type:"promise",innerType:e})}var mk=k("ZodFunction",(e,t)=>{yw.init(e,t),ve.init(e,t),e._zod.processJSONSchema=(r,n,i)=>$x(e,r,n,i)});function zj(e){return new mk({type:"function",input:Array.isArray(e?.input)?BS(e?.input):e?.input??xd(Ts()),output:e?.output??Ts()})}var $d=k("ZodCustom",(e,t)=>{ww.init(e,t),ve.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Ix(e,r,n,i)});function Uj(e){let t=new We({check:"custom"});return t._zod.check=e,t}function Lj(e,t){return tx($d,e??(()=>!0),t)}function hk(e,t={}){return rx($d,e,t)}function gk(e,t){return nx(e,t)}var Fj=ix,Bj=ox;function Vj(e,t={}){let r=new $d({type:"custom",check:"custom",fn:n=>n instanceof e,abort:!0,...D.normalizeParams(t)});return r._zod.bag.Class=e,r._zod.check=n=>{n.value instanceof e||n.issues.push({code:"invalid_type",expected:e.name,input:n.value,inst:r,path:[...r._zod.def.path??[]]})},r}var Hj=(...e)=>ax({Codec:Id,Boolean:gu,String:pu},...e);function Zj(e){let t=fk(()=>rg([hd(e),IS(),$S(),OS(),xd(t),VS(hd(),t)]));return t}function Gj(e,t){return new sk({type:"pipe",in:ig(e),out:t})}var HH={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 ZH(e){pt({customError:e})}function GH(){return pt().customError}var _k;_k||(_k={});var G={...md,...Ch,iso:lu},WH=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 qH(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 KH(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 n=t.version==="draft-2020-12"?"$defs":"definitions";if(r[0]===n){let i=r[1];if(!i||!t.defs[i])throw new Error(`Reference not found: ${e}`);return t.defs[i]}throw new Error(`Reference not found: ${e}`)}function Wj(e,t){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return G.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 i=e.$ref;if(t.refs.has(i))return t.refs.get(i);if(t.processing.has(i))return G.lazy(()=>{if(!t.refs.has(i))throw new Error(`Circular reference not resolved: ${i}`);return t.refs.get(i)});t.processing.add(i);let o=KH(i,t),a=sr(o,t);return t.refs.set(i,a),t.processing.delete(i),a}if(e.enum!==void 0){let i=e.enum;if(t.version==="openapi-3.0"&&e.nullable===!0&&i.length===1&&i[0]===null)return G.null();if(i.length===0)return G.never();if(i.length===1)return G.literal(i[0]);if(i.every(a=>typeof a=="string"))return G.enum(i);let o=i.map(a=>G.literal(a));return o.length<2?o[0]:G.union([o[0],o[1],...o.slice(2)])}if(e.const!==void 0)return G.literal(e.const);let r=e.type;if(Array.isArray(r)){let i=r.map(o=>{let a={...e,type:o};return Wj(a,t)});return i.length===0?G.never():i.length===1?i[0]:G.union(i)}if(!r)return G.any();let n;switch(r){case"string":{let i=G.string();if(e.format){let o=e.format;o==="email"?i=i.check(G.email()):o==="uri"||o==="uri-reference"?i=i.check(G.url()):o==="uuid"||o==="guid"?i=i.check(G.uuid()):o==="date-time"?i=i.check(G.iso.datetime()):o==="date"?i=i.check(G.iso.date()):o==="time"?i=i.check(G.iso.time()):o==="duration"?i=i.check(G.iso.duration()):o==="ipv4"?i=i.check(G.ipv4()):o==="ipv6"?i=i.check(G.ipv6()):o==="mac"?i=i.check(G.mac()):o==="cidr"?i=i.check(G.cidrv4()):o==="cidr-v6"?i=i.check(G.cidrv6()):o==="base64"?i=i.check(G.base64()):o==="base64url"?i=i.check(G.base64url()):o==="e164"?i=i.check(G.e164()):o==="jwt"?i=i.check(G.jwt()):o==="emoji"?i=i.check(G.emoji()):o==="nanoid"?i=i.check(G.nanoid()):o==="cuid"?i=i.check(G.cuid()):o==="cuid2"?i=i.check(G.cuid2()):o==="ulid"?i=i.check(G.ulid()):o==="xid"?i=i.check(G.xid()):o==="ksuid"&&(i=i.check(G.ksuid()))}typeof e.minLength=="number"&&(i=i.min(e.minLength)),typeof e.maxLength=="number"&&(i=i.max(e.maxLength)),e.pattern&&(i=i.regex(new RegExp(e.pattern))),n=i;break}case"number":case"integer":{let i=r==="integer"?G.number().int():G.number();typeof e.minimum=="number"&&(i=i.min(e.minimum)),typeof e.maximum=="number"&&(i=i.max(e.maximum)),typeof e.exclusiveMinimum=="number"?i=i.gt(e.exclusiveMinimum):e.exclusiveMinimum===!0&&typeof e.minimum=="number"&&(i=i.gt(e.minimum)),typeof e.exclusiveMaximum=="number"?i=i.lt(e.exclusiveMaximum):e.exclusiveMaximum===!0&&typeof e.maximum=="number"&&(i=i.lt(e.maximum)),typeof e.multipleOf=="number"&&(i=i.multipleOf(e.multipleOf)),n=i;break}case"boolean":{n=G.boolean();break}case"null":{n=G.null();break}case"object":{let i={},o=e.properties||{},a=new Set(e.required||[]);for(let[c,u]of Object.entries(o)){let l=sr(u,t);i[c]=a.has(c)?l:l.optional()}if(e.propertyNames){let c=sr(e.propertyNames,t),u=e.additionalProperties&&typeof e.additionalProperties=="object"?sr(e.additionalProperties,t):G.any();if(Object.keys(i).length===0){n=G.record(c,u);break}let l=G.object(i).passthrough(),d=G.looseRecord(c,u);n=G.intersection(l,d);break}if(e.patternProperties){let c=e.patternProperties,u=Object.keys(c),l=[];for(let f of u){let p=sr(c[f],t),m=G.string().regex(new RegExp(f));l.push(G.looseRecord(m,p))}let d=[];if(Object.keys(i).length>0&&d.push(G.object(i).passthrough()),d.push(...l),d.length===0)n=G.object({}).passthrough();else if(d.length===1)n=d[0];else{let f=G.intersection(d[0],d[1]);for(let p=2;p<d.length;p++)f=G.intersection(f,d[p]);n=f}break}let s=G.object(i);e.additionalProperties===!1?n=s.strict():typeof e.additionalProperties=="object"?n=s.catchall(sr(e.additionalProperties,t)):n=s.passthrough();break}case"array":{let i=e.prefixItems,o=e.items;if(i&&Array.isArray(i)){let a=i.map(c=>sr(c,t)),s=o&&typeof o=="object"&&!Array.isArray(o)?sr(o,t):void 0;s?n=G.tuple(a).rest(s):n=G.tuple(a),typeof e.minItems=="number"&&(n=n.check(G.minLength(e.minItems))),typeof e.maxItems=="number"&&(n=n.check(G.maxLength(e.maxItems)))}else if(Array.isArray(o)){let a=o.map(c=>sr(c,t)),s=e.additionalItems&&typeof e.additionalItems=="object"?sr(e.additionalItems,t):void 0;s?n=G.tuple(a).rest(s):n=G.tuple(a),typeof e.minItems=="number"&&(n=n.check(G.minLength(e.minItems))),typeof e.maxItems=="number"&&(n=n.check(G.maxLength(e.maxItems)))}else if(o!==void 0){let a=sr(o,t),s=G.array(a);typeof e.minItems=="number"&&(s=s.min(e.minItems)),typeof e.maxItems=="number"&&(s=s.max(e.maxItems)),n=s}else n=G.array(G.any());break}default:throw new Error(`Unsupported type: ${r}`)}return n}function sr(e,t){if(typeof e=="boolean")return e?G.any():G.never();let r=Wj(e,t),n=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){let s=e.anyOf.map(u=>sr(u,t)),c=G.union(s);r=n?G.intersection(r,c):c}if(e.oneOf&&Array.isArray(e.oneOf)){let s=e.oneOf.map(u=>sr(u,t)),c=G.xor(s);r=n?G.intersection(r,c):c}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)r=n?r:G.any();else{let s=n?r:sr(e.allOf[0],t),c=n?0:1;for(let u=c;u<e.allOf.length;u++)s=G.intersection(s,sr(e.allOf[u],t));r=s}e.nullable===!0&&t.version==="openapi-3.0"&&(r=G.nullable(r)),e.readOnly===!0&&(r=G.readonly(r)),e.default!==void 0&&(r=r.default(e.default));let i={},o=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let s of o)s in e&&(i[s]=e[s]);let a=["contentEncoding","contentMediaType","contentSchema"];for(let s of a)s in e&&(i[s]=e[s]);for(let s of Object.keys(e))WH.has(s)||(i[s]=e[s]);return Object.keys(i).length>0&&t.registry.add(r,i),e.description&&(r=r.describe(e.description)),r}function qj(e,t){if(typeof e=="boolean")return e?G.any():G.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 n=qH(r,t?.defaultTarget),i=r.$defs||r.definitions||{},o={version:n,defs:i,refs:new Map,processing:new Set,rootSchema:r,registry:t?.registry??Le};return sr(r,o)}var yk={};Fn(yk,{bigint:()=>QH,boolean:()=>YH,date:()=>e3,number:()=>XH,string:()=>JH});function JH(e){return Ew(pu,e)}function XH(e){return Nw(hu,e)}function YH(e){return Lw(gu,e)}function QH(e){return Bw(_u,e)}function e3(e){return Xw(wd,e)}pt(Xp());var Kj=A({BaseToolkit:()=>t3,DynamicStructuredTool:()=>Yj,DynamicTool:()=>Xj,StructuredTool:()=>Td,Tool:()=>Jj,ToolInputParsingException:()=>Gs,isLangChainTool:()=>pd,isRunnableToolLike:()=>dd,isStructuredTool:()=>ld,isStructuredToolParams:()=>fd,tool:()=>r3}),Td=class extends sh{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,n=Ee(Ct(this.defaultConfig,t));return _o(e)?(r=e.args,n={...n,toolCall:e}):r=e,this.call(r,n)}async call(e,t,r){let n=_o(e)?e.args:e,i;if(Pr(this.schema))try{i=await Zo(this.schema,n)}catch(p){let m="Received tool input did not match expected schema";throw this.verboseParsingErrors&&(m=`${m}
423
- Details: ${p.message}`),Mm(p)&&(m=`${m}
424
-
425
- ${pn.prettifyError(p)}`),new Gs(m,JSON.stringify(e))}else{let p=Xe(n,this.schema);if(!p.valid){let m="Received tool input did not match expected schema";throw this.verboseParsingErrors&&(m=`${m}
426
- Details: ${p.errors.map(h=>`${h.keywordLocation}: ${h.error}`).join(`
427
- `)}`),new Gs(m,JSON.stringify(e))}i=n}let o=Ga(t),a=tt.configure(o.callbacks,this.callbacks,o.tags||r,this.tags,o.metadata,this.metadata,{verbose:this.verbose}),s;_o(e)&&(s=e.id),!s&&NI(o)&&(s=o.toolCall.id);let c=await a?.handleToolStart(this.toJSON(),typeof e=="string"?e:JSON.stringify(e),o.runId,void 0,void 0,void 0,o.runName,s);delete o.runId;let u;try{let p=await this._call(i,c,o);u=a0(p)?await vN(p,async m=>{try{await c?.handleToolEvent(m)}catch(h){await c?.handleToolError(h)}}):p}catch(p){throw await c?.handleToolError(p),p}let l,d;if(this.responseFormat==="content_and_artifact")if(Array.isArray(u)&&u.length===2)[l,d]=u;else throw new Error(`Tool response format is "content_and_artifact" but the output was not a two-tuple.
428
- Result: ${JSON.stringify(u)}`);else l=u;let f=i3({content:l,artifact:d,toolCallId:s,name:this.name,metadata:this.metadata});return await c?.handleToolEnd(f),f}},Jj=class extends Td{schema=Ut.object({input:Ut.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)}},Xj=class extends Jj{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=Ga(t);return r.runName===void 0&&(r.runName=this.name),super.call(e,r)}_call(e,t,r){return this.func(e,t,r)}},Yj=class extends Td{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 n=Ga(t);return n.runName===void 0&&(n.runName=this.name),super.call(e,n,r)}_call(e,t,r){return this.func(e,t,r)}},t3=class{getTools(){return this.tools}};function r3(e,t){let r=Vc(t.schema),n=Yc(t.schema);if(!t.schema||r||n)return new Xj({...t,description:t.description??t.schema?.description??`${t.name} tool`,func:async(a,s,c)=>new Promise((u,l)=>{let d=Ae(c,{callbacks:s?.getChild()});Me.runWithConfig(Ar(d),async()=>{try{u(e(a,d))}catch(f){l(f)}})})});let i=t.schema,o=t.description??t.schema.description??`${t.name} tool`;return new Yj({...t,description:o,schema:i,func:async(a,s,c)=>new Promise((u,l)=>{let d,f=()=>{c?.signal&&d&&c.signal.removeEventListener("abort",d)};c?.signal&&(d=()=>{f(),l(Ao(c.signal))},c.signal.addEventListener("abort",d,{once:!0}));let p=Ae(c,{callbacks:s?.getChild()});Me.runWithConfig(Ar(p),async()=>{try{let m=await e(a,p);if(a0(m)){u(m);return}if(c?.signal?.aborted){f();return}f(),u(m)}catch(m){f(),l(m)}})})})}function n3(e){return typeof e=="object"&&e!==null&&"type"in e}function i3(e){let{content:t,artifact:r,toolCallId:n,metadata:i}=e;return n&&!Vu(t)?typeof t=="string"||Array.isArray(t)&&t.every(n3)?new $t({status:"success",content:t,artifact:r,tool_call_id:n,name:e.name,metadata:i}):new $t({status:"success",content:o3(t),artifact:r,tool_call_id:n,name:e.name,metadata:i}):t}function o3(e){try{return JSON.stringify(e)??""}catch{return`${e}`}}var Qj=A({RunCollectorCallbackHandler:()=>a3}),a3=class extends Ht{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 eM=A({});var tM=A({chunkArray:()=>s3}),s3=(e,t)=>e.reduce((r,n,i)=>{let o=Math.floor(i/t);return r[o]=(r[o]||[]).concat([n]),r},[]);var rM=A({context:()=>c3});function c3(e,...t){let r=e.raw,n="";for(let i=0;i<r.length;i++){let o=r[i].replace(/\\\n[ \t]*/g,"").replace(/\\`/g,"`").replace(/\\\$/g,"$").replace(/\\\{/g,"{");if(n+=o,i<t.length){let a=u3(t[i],n);n+=typeof a=="string"?a:JSON.stringify(a)}}return n=l3(n),n=n.trim(),n=n.replace(/\\n/g,`
429
- `),n}function u3(e,t){if(typeof e!="string"||!e.includes(`
430
- `))return e;let r=t.slice(t.lastIndexOf(`
431
- `)+1).match(/^(\s+)/);if(r){let n=r[1];return e.replace(/\n/g,`
432
- ${n}`)}return e}function l3(e){let t=e.split(`
433
- `),r=null;for(let n of t){let i=n.match(/^(\s+)\S+/);if(i){let o=i[1].length;r===null?r=o:r=Math.min(r,o)}}return r===null?e:t.map(n=>n[0]===" "||n[0]===" "?n.slice(r):n).join(`
434
- `)}var nM=A({EventStreamContentType:()=>d3,convertEventStreamToIterableReadableDataStream:()=>p3,getBytes:()=>iM,getLines:()=>oM,getMessages:()=>aM}),d3="text/event-stream";async function iM(e,t){if(e instanceof ReadableStream){let r=e.getReader();for(;;){let n=await r.read();if(n.done){t(new Uint8Array,!0);break}t(n.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(`
435
- `))}}function oM(e){let t,r,n,i=!1;return function(a,s){if(s){e(a,0,!0);return}t===void 0?(t=a,r=0,n=-1):t=f3(t,a);let c=t.length,u=0;for(;r<c;){i&&(t[r]===10&&(u=++r),i=!1);let l=-1;for(;r<c&&l===-1;++r)switch(t[r]){case 58:n===-1&&(n=r-u);break;case 13:i=!0;case 10:l=r;break}if(l===-1)break;e(t.subarray(u,l),n),u=r,n=-1}u===c?t=void 0:u!==0&&(t=t.subarray(u),r-=u)}}function aM(e,t,r){let n=vk(),i=new TextDecoder;return function(a,s,c){if(c){m3(n)||(e?.(n),n=vk());return}if(a.length===0)e?.(n),n=vk();else if(s>0){let u=i.decode(a.subarray(0,s)),l=s+(a[s+1]===32?2:1),d=i.decode(a.subarray(l));switch(u){case"data":n.data=n.data?n.data+`
436
- `+d:d;break;case"event":n.event=d;break;case"id":t?.(n.id=d);break;case"retry":{let f=parseInt(d,10);Number.isNaN(f)||r?.(n.retry=f);break}}}}}function f3(e,t){let r=new Uint8Array(e.length+t.length);return r.set(e),r.set(t,e.length),r}function vk(){return{data:"",event:"",id:"",retry:void 0}}function p3(e,t){let r=new ReadableStream({async start(n){let i=aM(a=>{if(a.event==="error")throw new Error(a.data??"Unspecified event streaming error.");a.event==="metadata"?t?.(a):a.data&&n.enqueue(a.data)});await iM(e,oM((a,s,c)=>{i(a,s,c),c&&n.close()}))}});return bt.fromReadableStream(r)}function m3(e){return e.data===""&&e.event===""&&e.id===""&&e.retry===void 0}var sM=A({});var cM=A({convertToOpenAIFunction:()=>uM,convertToOpenAITool:()=>h3,isLangChainTool:()=>pd,isRunnableToolLike:()=>dd,isStructuredTool:()=>ld,isStructuredToolParams:()=>fd});function uM(e,t){let r=typeof t=="number"?void 0:t;return{name:e.name,description:e.description,parameters:Ot(e.schema),...r?.strict!==void 0?{strict:r.strict}:{}}}function h3(e,t){let r=typeof t=="number"?void 0:t,n;return pd(e)?n={type:"function",function:uM(e)}:n=e,r?.strict!==void 0&&(n.function.strict=r.strict),n}function sg(e,t){let r=0,n=0,i=0;for(let o=0;o<e.length;o++)r+=e[o]*t[o],n+=e[o]*e[o],i+=t[o]*t[o];return r/(Math.sqrt(n)*Math.sqrt(i))}function lM(e,t){let r=0;for(let n=0;n<e.length;n++)r+=e[n]*t[n];return r}function g3(e,t){let r=0;for(let n=0;n<e.length;n++)r+=(e[n]-t[n])*(e[n]-t[n]);return r}function dM(e,t){return Math.sqrt(g3(e,t))}var fM=A({cosineSimilarity:()=>bk,euclideanDistance:()=>v3,innerProduct:()=>y3,matrixFunc:()=>cg,maximalMarginalRelevance:()=>b3,normalize:()=>_3});function cg(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(n=>t.map(i=>r(n,i)).map(i=>Number.isNaN(i)?0:i))}function _3(e,t=!1){let r=w3(e);return e.map(n=>n.map(i=>t?1-i/r:i/r))}function bk(e,t){return cg(e,t,sg)}function y3(e,t){return cg(e,t,lM)}function v3(e,t){return cg(e,t,dM)}function b3(e,t,r=.5,n=4){if(Math.min(n,t.length)<=0)return[];let i=bk(Array.isArray(e[0])?e:[e],t)[0],o=pM(i).maxIndex,a=[t[o]],s=[o];for(;s.length<Math.min(n,t.length);){let c=-1/0,u=-1,l=bk(t,a);i.forEach((d,f)=>{if(s.includes(f))return;let p=Math.max(...l[f]),m=r*d-(1-r)*p;m>c&&(c=m,u=f)}),a.push(t[u]),s.push(u)}return s}function pM(e){if(e.length===0)return{maxIndex:-1,maxValue:NaN};let t=e[0],r=0;for(let n=1;n<e.length;n+=1)e[n]>t&&(r=n,t=e[n]);return{maxIndex:r,maxValue:t}}function w3(e){return e.reduce((t,r)=>Math.max(t,pM(r).maxValue),0)}var mM=A({isCloudMetadata:()=>wk,isLocalhost:()=>xk,isPrivateIp:()=>vM,isSafeUrl:()=>A3,isSameOrigin:()=>C3,validateSafeUrl:()=>bM}),x3=["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"],S3=["169.254.169.254","169.254.170.2","100.100.100.200"],k3=["metadata.google.internal","metadata","instance-data"],E3=["localhost","localhost.localdomain"],I3=/^(?:(?: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 hM(e){return I3.test(e)}function ug(e){return yM(e)!==null}function gM(e){return hM(e)||ug(e)}function _M(e){if(hM(e))return e.split(".").map(t=>parseInt(t,10));if(ug(e)){let t=yM(e);if(!t)return null;let r=t.split(":"),n=[];for(let i of r)n.push(parseInt(i,16));return n}return null}function yM(e){if(!e||typeof e!="string"||!e.includes(":")||!/^[0-9a-fA-F:]+$/.test(e))return null;let t=e;if(t.includes("::")){let n=t.split("::");if(n.length>2)return null;let[i,o]=n,a=i?i.split(":"):[],s=o?o.split(":"):[],c=8-(a.length+s.length);if(c<0)return null;let u=Array(c).fill("0");t=[...a,...u,...s].filter(l=>l!=="").join(":")}let r=t.split(":");if(r.length!==8)return null;for(let n of r)if(n.length===0||n.length>4||!/^[0-9a-fA-F]+$/.test(n))return null;return r.map(n=>n.padStart(4,"0").toLowerCase()).join(":")}function $3(e){let[t,r]=e.split("/");if(!t||!r)return null;let n=_M(t);if(!n)return null;let i=parseInt(r,10);if(isNaN(i))return null;let o=ug(t);return o&&i>128||!o&&i>32?null:{addr:n,prefixLen:i,isIpv6:o}}function T3(e,t){let r=_M(e);if(!r)return!1;let n=$3(t);if(!n)return!1;let i=ug(e);if(i!==n.isIpv6)return!1;let{addr:o,prefixLen:a}=n;if(i)for(let s=0;s<Math.ceil(a/16);s++){let c=65535<<16-Math.min(16,a-s*16)&65535;if((r[s]&c)!==(o[s]&c))return!1}else for(let s=0;s<Math.ceil(a/8);s++){let c=255<<8-Math.min(8,a-s*8)&255;if((r[s]&c)!==(o[s]&c))return!1}return!0}function vM(e){if(!gM(e))return!1;for(let t of x3)if(T3(e,t))return!0;return!1}function wk(e,t){if(S3.includes(t||""))return!0;let r=e.toLowerCase();return!!k3.includes(r)}function xk(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!!E3.includes(r)}function bM(e,t){let r=t?.allowPrivate??!1,n=t?.allowHttp??!1;try{let i;try{i=new URL(e)}catch{throw new Error(`Invalid URL: ${e}`)}let o=i.hostname;if(!o)throw new Error("URL missing hostname.");if(wk(o))throw new Error(`URL points to cloud metadata endpoint: ${o}`);if(xk(o)){if(!r)throw new Error(`URL points to localhost: ${o}`);return e}let a=i.protocol;if(a!=="http:"&&a!=="https:")throw new Error(`Invalid URL scheme: ${a}. Only http and https are allowed.`);if(a==="http:"&&!n)throw new Error("HTTP scheme not allowed. Use HTTPS or set allowHttp: true.");if(gM(o)){let s=o;if(xk(o,s)){if(!r)throw new Error(`URL points to localhost: ${o}`);return e}if(wk(o,s))throw new Error(`URL resolves to cloud metadata IP: ${s} (${o})`);if(vM(s)&&!r)throw new Error(`URL resolves to private IP: ${s} (${o}). Set allowPrivate: true to allow.`);return e}return e}catch(i){throw i&&typeof i=="object"&&"message"in i?i:new Error(`URL validation failed: ${i}`)}}function A3(e,t){try{return bM(e,t),!0}catch{return!1}}function C3(e,t){try{return new URL(e).origin===new URL(t).origin}catch{return!1}}var wM=A({SaveableVectorStore:()=>O3,VectorStore:()=>dg,VectorStoreRetriever:()=>lg}),lg=class extends nd{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)}},dg=class extends yt{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,n=void 0){return(await this.similaritySearchVectorWithScore(await this.embeddings.embedQuery(e),t,r)).map(i=>i[0])}async similaritySearchWithScore(e,t=4,r=void 0,n=void 0){return this.similaritySearchVectorWithScore(await this.embeddings.embedQuery(e),t,r)}static fromTexts(e,t,r,n){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,n,i,o){if(typeof e=="number")return new lg({vectorStore:this,k:e,filter:t,tags:[...n??[],this._vectorstoreType()],metadata:i,verbose:o,callbacks:r});{let a={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 lg({...a,searchKwargs:e.searchKwargs}):new lg({...a})}}},O3=class extends dg{static load(e,t){throw new Error("Not implemented")}};var xM=class extends ea{_combineLLMOutput(){return[]}_llmType(){return"fake"}async _generate(e,t,r){if(t?.stop?.length)return{generations:[{message:new je(t.stop[0]),text:t.stop[0]}]};let n=e.map(i=>typeof i.content=="string"?i.content:JSON.stringify(i.content,null,2)).join(`
437
- `);return await r?.handleLLMNewToken(n),{generations:[{message:new je(n),text:n}],llmOutput:{}}}},SM=class kM extends ea{sleep=50;responses=[];chunks=[];toolStyle="openai";thrownErrorString;tools=[];constructor({sleep:t=50,responses:r=[],chunks:n=[],toolStyle:i="openai",thrownErrorString:o,...a}){super(a),this.sleep=t,this.responses=r,this.chunks=n,this.toolStyle=i,this.thrownErrorString=o}_llmType(){return"fake"}bindTools(t){let r=[...this.tools,...t],n=r.map(a=>{switch(this.toolStyle){case"openai":return{type:"function",function:{name:a.name,description:a.description,parameters:Ot(a.schema)}};case"anthropic":return{name:a.name,description:a.description,input_schema:Ot(a.schema)};case"bedrock":return{toolSpec:{name:a.name,description:a.description,inputSchema:Ot(a.schema)}};case"google":return{name:a.name,description:a.description,parameters:Ot(a.schema)};default:throw new Error(`Unsupported tool style: ${this.toolStyle}`)}}),i=this.toolStyle==="google"?[{functionDeclarations:n}]:n,o=new kM({sleep:this.sleep,responses:this.responses,chunks:this.chunks,toolStyle:this.toolStyle,thrownErrorString:this.thrownErrorString});return o.tools=r,o.withConfig({tools:i})}async _generate(t,r,n){if(this.thrownErrorString)throw new Error(this.thrownErrorString);return{generations:[{text:"",message:new je({content:this.responses?.[0]?.content??t[0].content??"",tool_calls:this.chunks?.[0]?.tool_calls})}]}}async*_streamResponseChunks(t,r,n){if(this.thrownErrorString)throw new Error(this.thrownErrorString);if(this.chunks?.length){for(let a of this.chunks){let s=new No({message:new ut({content:a.content,tool_calls:a.tool_calls,additional_kwargs:a.additional_kwargs??{}}),text:a.content?.toString()??""});if(r.signal?.aborted)break;yield s,await n?.handleLLMNewToken(a.content,void 0,void 0,void 0,void 0,{chunk:s})}return}let i=this.responses?.[0]??new je(typeof t[0].content=="string"?t[0].content:""),o=typeof i.content=="string"?i.content:"";for(let a of o){await new Promise(c=>setTimeout(c,this.sleep));let s=new No({message:new ut({content:a}),text:a});if(r.signal?.aborted)break;yield s,await n?.handleLLMNewToken(a,void 0,void 0,void 0,void 0,{chunk:s})}}},EM=class IM extends ea{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:n,emitCustomEvent:i,generationInfo:o}=t;this.responses=r,this.sleep=n,this.emitCustomEvent=i??this.emitCustomEvent,this.generationInfo=o}_combineLLMOutput(){return[]}_llmType(){return"fake-list"}async _generate(t,r,n){if(await this._sleepIfRequested(),r?.thrownErrorString)throw new Error(r.thrownErrorString);if(this.emitCustomEvent&&await n?.handleCustomEvent("some_test_event",{someval:!0}),r?.stop?.length)return{generations:[this._formatGeneration(r.stop[0])]};{let i=this._currentResponse();return this._incrementResponse(),{generations:[this._formatGeneration(i)],llmOutput:{}}}}_formatGeneration(t){return{message:new je(t),text:t}}async*_streamResponseChunks(t,r,n){let i=this._currentResponse();this._incrementResponse(),this.emitCustomEvent&&await n?.handleCustomEvent("some_test_event",{someval:!0});let o=[...i];for(let a=0;a<o.length;a++){let s=o[a],c=a===o.length-1;if(await this._sleepIfRequested(),r?.thrownErrorString)throw new Error(r.thrownErrorString);let u=this._createResponseChunk(s,c?this.generationInfo:void 0);if(r.signal?.aborted)break;yield u,n?.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 No({message:new ut({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],n=r.map(a=>{switch(this.toolStyle){case"openai":return{type:"function",function:{name:a.name,description:a.description,parameters:Ot(a.schema)}};case"anthropic":return{name:a.name,description:a.description,input_schema:Ot(a.schema)};case"bedrock":return{toolSpec:{name:a.name,description:a.description,inputSchema:Ot(a.schema)}};case"google":return{name:a.name,description:a.description,parameters:Ot(a.schema)};default:throw new Error(`Unsupported tool style: ${this.toolStyle}`)}}),i=this.toolStyle==="google"?[{functionDeclarations:n}]:n,o=new IM({responses:this.responses,sleep:this.sleep,emitCustomEvent:this.emitCustomEvent,generationInfo:this.generationInfo});return o.tools=r,o.toolStyle=this.toolStyle,o.i=this.i,o.withConfig({tools:i})}withStructuredOutput(t,r){return ir.from(async n=>{let i=await this.invoke(n);if(i.tool_calls?.[0]?.args)return i.tool_calls[0].args;if(typeof i.content=="string")return JSON.parse(i.content);throw new Error("No structured output found")})}};var $M=class extends eh{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,n=r===0?0:this.vectorSize-r,i=t.length+n;t=t.padEnd(i," ");let o=t.length/this.vectorSize,a=[];for(let s=0;s<t.length;s+=o)a.push(t.slice(s,s+o));return a.map(s=>{let c=0;for(let u=0;u<s.length;u+=1)c+=s===" "?0:s.charCodeAt(u);return c%26/26})}},TM=class extends eh{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 AM=class extends hh{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 n=this.response??e;return await r?.handleLLMNewToken(n),n}},CM=class extends hh{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 n=this.responses?.[0];this.responses=this.responses?.slice(1);for(let i of n??e)await new Promise(o=>setTimeout(o,this.sleep)),yield{text:i,generationInfo:{}},await r?.handleLLMNewToken(i)}};var OM=class extends f0{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 dt(e))}async addAIMessage(e){this.messages.push(new je(e))}async clear(){this.messages=[]}},PM=class extends Qm{lc_namespace=["langchain_core","message","fake"];messages=[];constructor(){super()}async addMessage(e){this.messages.push(e)}async getMessages(){return this.messages}},NM=class extends Ht{name="fake_tracer";runs=[];constructor(){super()}persistRun(e){return this.runs.push(e),Promise.resolve()}};var RM=class extends An{lc_namespace=["tests","fake"];getFormatInstructions(){return""}async parse(e){return e.split(",").map(t=>t.trim())}};var jM=class extends nd{lc_namespace=["test","fake"];output=[new Xr({pageContent:"foo"}),new Xr({pageContent:"bar"})];constructor(e){super(),this.output=e?.output??this.output}async _getRelevantDocuments(e){return this.output}};var MM=class extends ce{lc_namespace=["tests","fake"];returnOptions;constructor(e){super(e),this.returnOptions=e.returnOptions}async invoke(e,t){return this.returnOptions?t??{}:{input:e}}};var DM=class extends Td{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 zM=class extends Ht{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 UM=class LM extends dg{memoryVectors=[];similarity;_vectorstoreType(){return"memory"}constructor(t,{similarity:r,...n}={}){super(t,n),this.similarity=r??sg}async addDocuments(t){let r=t.map(({pageContent:n})=>n);return this.addVectors(await this.embeddings.embedDocuments(r),t)}async addVectors(t,r){let n=t.map((i,o)=>({content:r[o].pageContent,embedding:i,metadata:r[o].metadata}));this.memoryVectors=this.memoryVectors.concat(n)}async similaritySearchVectorWithScore(t,r,n){let i=a=>n?n(new Xr({metadata:a.metadata,pageContent:a.content})):!0,o=this.memoryVectors.filter(i);return o.map((a,s)=>({similarity:this.similarity(t,a.embedding),index:s})).sort((a,s)=>a.similarity>s.similarity?-1:0).slice(0,r).map(a=>[new Xr({metadata:o[a.index].metadata,pageContent:o[a.index].content}),a.similarity])}static async fromTexts(t,r,n,i){let o=[];for(let a=0;a<t.length;a+=1){let s=Array.isArray(r)?r[a]:r,c=new Xr({pageContent:t[a],metadata:s});o.push(c)}return LM.fromDocuments(o,n,i)}static async fromDocuments(t,r,n){let i=new this(r,n);return await i.addDocuments(t),i}static async fromExistingIndex(t,r){return new this(t,r)}};var FM=A({FakeChatMessageHistory:()=>OM,FakeChatModel:()=>xM,FakeEmbeddings:()=>TM,FakeLLM:()=>AM,FakeListChatMessageHistory:()=>PM,FakeListChatModel:()=>EM,FakeRetriever:()=>jM,FakeRunnable:()=>MM,FakeSplitIntoListParser:()=>RM,FakeStreamingChatModel:()=>SM,FakeStreamingLLM:()=>CM,FakeTool:()=>DM,FakeTracer:()=>NM,FakeVectorStore:()=>UM,SingleRunExtractor:()=>zM,SyntheticEmbeddings:()=>$M,asAsyncIterable:()=>Eh,openAIReasoningTextChunks:()=>$h,openAITextOnlyChunks:()=>ud,openAITextOnlyChunksWithUsage:()=>Ih,openAIToolCallChunks:()=>Th,sseResponseFromOpenAIChunks:()=>Ah,streamMatchers:()=>uu});var BM=A({agents:()=>sI,caches:()=>f$,callbacks__base:()=>g$,callbacks__manager:()=>JA,callbacks__promises:()=>WA,chat_history:()=>UN,document_loaders__base:()=>BN,document_loaders__langsmith:()=>VN,documents:()=>FN,embeddings:()=>HN,errors:()=>dI,example_selectors:()=>QN,index:()=>aI,indexing:()=>r1,language_models__base:()=>l1,language_models__chat_models:()=>B1,language_models__compat:()=>U1,language_models__event:()=>H1,language_models__llms:()=>Z1,language_models__openai_completions_stream:()=>V1,language_models__profile:()=>W1,language_models__stream:()=>N1,language_models__structured_output:()=>O1,load__serializable:()=>XE,memory:()=>q1,messages:()=>zN,messages__tool:()=>PI,output_parsers:()=>$1,output_parsers__openai_functions:()=>X1,output_parsers__openai_tools:()=>Y1,outputs:()=>pC,prompt_values:()=>n1,prompts:()=>dR,retrievers:()=>pR,retrievers__document_compressors:()=>fR,runnables:()=>h1,runnables__graph:()=>pN,singletons:()=>rC,stores:()=>mR,structured_query:()=>wR,testing:()=>AR,tools:()=>Kj,tracers__base:()=>zA,tracers__console:()=>LA,tracers__log_stream:()=>fC,tracers__run_collector:()=>Qj,tracers__tracer_langchain:()=>VA,types__stream:()=>eM,utils__async_caller:()=>vC,utils__chunk_array:()=>tM,utils__context:()=>rM,utils__env:()=>QE,utils__event_source_parse:()=>nM,utils__format:()=>sM,utils__function_calling:()=>cM,utils__hash:()=>cI,utils__json_patch:()=>g1,utils__json_schema:()=>aN,utils__math:()=>fM,utils__ssrf:()=>mM,utils__standard_schema:()=>EC,utils__stream:()=>nC,utils__testing:()=>FM,utils__tiktoken:()=>c1,utils__types:()=>T1,utils__uuid:()=>VE,vectorstores:()=>wM});var P3=50;function N3(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,[n,i])=>(r[i]=n,r),{})}async function fg(e){let{optionalImportsMap:t,optionalImportEntrypoints:r,importMap:n,secretsMap:i,secretsFromEnv:o,path:a,depth:s,maxDepth:c}=this,u=a.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)=>fg.call({...this,path:[...a,`${p}`],depth:s+1},f)));let l=e;if(p_(l))return cf(l);if("lc"in l&&"type"in l&&"id"in l&&l.lc===1&&l.type==="secret"){let[f]=l.id;if(f in i)return i[f];if(o){let p=pr(f);if(p)return p}throw new Error(`Missing secret "${f}" at ${u}`)}if("lc"in l&&"type"in l&&"id"in l&&l.lc===1&&l.type==="not_implemented"){let f=JSON.stringify(l);throw new Error(`Trying to load an object that doesn't implement serialization: ${u} -> ${f}`)}if("lc"in l&&"type"in l&&"id"in l&&"kwargs"in l&&l.lc===1&&l.type==="constructor"){let f=l,p=JSON.stringify(f),[m,...h]=f.id.slice().reverse(),_=h.reverse(),y={langchain_core:BM,langchain:n},w=null,x=[_.join("/")];_[0]==="langchain_community"&&x.push(["langchain",..._.slice(1)].join("/"));let S=x.find(T=>T in t);if(oI.concat(r).includes(_.join("/"))||S)if(S!==void 0)w=await t[S];else throw new Error(`Missing key "${_.join("/")}" for ${u} in load(optionalImportsMap={})`);else{let T;if(_[0]==="langchain"||_[0]==="langchain_core")T=y[_[0]],_.shift();else throw new Error(`Invalid namespace: ${u} -> ${p}`);if(_.length===0)throw new Error(`Invalid namespace: ${u} -> ${p}`);let b;do{if(b=_.join("__"),b in T)break;_.pop()}while(_.length>0);b in T&&(w=T[b])}if(typeof w!="object"||w===null)throw new Error(`Invalid namespace: ${u} -> ${p}`);let E=w[m]??Object.values(w).find(T=>typeof T=="function"&&Fs(T)===m);if(typeof E!="function")throw new Error(`Invalid identifer: ${u} -> ${p}`);let C=new E(af(await fg.call({...this,path:[...a,"kwargs"],depth:s+1},f.kwargs),qE,N3(E)));return Object.defineProperty(C.constructor,"name",{value:m}),C}let d={};for(let[f,p]of Object.entries(l))d[f]=await fg.call({...this,path:[...a,f],depth:s+1},p);return d}async function VM(e,t){let r=JSON.parse(e),n={optionalImportsMap:t?.optionalImportsMap??{},optionalImportEntrypoints:t?.optionalImportEntrypoints??[],secretsMap:t?.secretsMap??{},secretsFromEnv:t?.secretsFromEnv??!1,importMap:t?.importMap??{},path:["$"],depth:0,maxDepth:t?.maxDepth??P3};return fg.call(n,r)}function R3(e){return e!==null&&e.lc===1&&e.type==="constructor"&&Array.isArray(e.id)}async function Sk(e){if(e&&typeof e=="object"){if(Array.isArray(e))return await Promise.all(e.map(t=>Sk(t)));{let t={};for(let[r,n]of Object.entries(e))t[r]=await Sk(n);if(t.lc===2&&t.type==="undefined")return;if(t.lc===2&&t.type==="delta_snapshot")return new Us(t.value);if(t.lc===2&&t.type==="constructor"&&Array.isArray(t.id))try{let r=t.id[t.id.length-1],n;switch(r){case"Set":n=Set;break;case"Map":n=Map;break;case"RegExp":n=RegExp;break;case"Error":n=Error;break;case"Uint8Array":n=Uint8Array;break;default:return t}return t.method?n[t.method](...t.args||[]):new n(...t.args||[])}catch{return t}else if(R3(t))return VM(JSON.stringify(t));return t}}return e}function pg(e,t,r,n){return{lc:2,type:"constructor",id:[e.name],method:t??null,args:r??[],kwargs:n??{}}}function j3(e){return e===void 0?{lc:2,type:"undefined"}:e instanceof Us?{lc:2,type:"delta_snapshot",value:e.value}:e instanceof Set||e instanceof Map?pg(e.constructor,void 0,[Array.from(e)]):e instanceof RegExp?pg(RegExp,void 0,[e.source,e.flags]):e instanceof Error?pg(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?pg(Uint8Array,"from",[Array.from(e)]):e}var mg=class{_dumps(e){return new TextEncoder().encode(ZE(e,(t,r)=>j3(r)))}async dumpsTyped(e){return e instanceof Uint8Array?["bytes",e]:["json",this._dumps(e)]}async _loads(e){return Sk(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 kk(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]=kk(e[r]));return t}function Cs(){return{v:4,id:Lu(0),ts:new Date().toISOString(),channel_values:{},channel_versions:{},versions_seen:{}}}function Pn(e){return{v:e.v,id:e.id,ts:e.ts,channel_values:{...e.channel_values??{}},channel_versions:{...e.channel_versions??{}},versions_seen:kk(e.versions_seen??{})}}var hg=class{serde=new mg;constructor(e){this.serde=e||this.serde}toJSON(){return`[${this.constructor.name}]`}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 n={},i={},o=new Set(r);for(let c of r)n[c]=[];let a=(await this.getTuple(t))?.parentConfig;for(;a!=null&&o.size>0;){let c=await this.getTuple(a);if(c===void 0)break;if(c.pendingWrites&&c.pendingWrites.length>0){let u={};for(let l of c.pendingWrites){let d=l[1];o.has(d)&&(u[d]??=[]).push(l)}for(let l of Object.keys(u)){let d=u[l];d.sort((f,p)=>f[0]<p[0]?-1:f[0]>p[0]?1:0);for(let f=d.length-1;f>=0;f-=1)n[l].push(d[f])}}for(let u of Array.from(o))Object.prototype.hasOwnProperty.call(c.checkpoint.channel_values,u)&&(i[u]=c.checkpoint.channel_values[u],o.delete(u));a=c.parentConfig}let s={};for(let c of r){let u={writes:n[c].slice().reverse()};Object.prototype.hasOwnProperty.call(i,c)&&(u.seed=i[c]),s[c]=u}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 gg(e,t){return typeof e=="number"&&typeof t=="number"?Math.sign(e-t):String(e).localeCompare(String(t))}function Ad(...e){return e.reduce((t,r,n)=>n===0?r:gg(t,r)>=0?t:r)}var Cd={[s_]:-1,[ya]:-2,[c_]:-3,[u_]:-4},Ek=new Set(["thread_id","checkpoint_id","checkpoint_ns","checkpoint_map","langgraph_step","langgraph_node","langgraph_triggers","langgraph_path","langgraph_checkpoint_ns"]);function _g(e){return e.configurable?.checkpoint_id||e.configurable?.thread_ts||""}var M3=new Set(["__proto__","constructor","prototype"]);function Gt(e,t,r={}){let{allowEmpty:n=!1}=r;if(typeof t!="string"){let i=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 ${i}). This guard protects MemorySaver from prototype pollution.`)}if(!n&&t==="")throw new Error(`Invalid configurable value for key "${e}": empty string is not permitted as an in-memory storage key.`);if(M3.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 yu(e,t,r){return JSON.stringify([e,t,r])}function D3(e){let[t,r,n]=JSON.parse(e);return{threadId:t,checkpointNamespace:r,checkpointId:n}}var HM=class extends hg{storage=Object.create(null);writes=Object.create(null);constructor(e){super(e)}async _migratePendingSends(e,t,r,n){let i=e,o=yu(t,r,n),a=await Promise.all(Object.values(this.writes[o]??{}).filter(([s,c])=>c===Fu).map(async([s,c,u])=>await this.serde.loadsTyped("json",u)));i.channel_values??={},i.channel_values[Fu]=a,i.channel_versions??={},i.channel_versions[Fu]=Object.keys(i.channel_versions).length>0?Ad(...Object.values(i.channel_versions)):this.getNextVersion(void 0)}async getTuple(e){let t=e.configurable?.thread_id,r=e.configurable?.checkpoint_ns??"",n=_g(e);if(t!==void 0&&Gt("thread_id",t),Gt("checkpoint_ns",r,{allowEmpty:!0}),n&&Gt("checkpoint_id",n),n){let i=this.storage[t]?.[r]?.[n];if(i!==void 0){let[o,a,s]=i,c=yu(t,r,n),u=await this.serde.loadsTyped("json",o);u.v<4&&s!==void 0&&await this._migratePendingSends(u,t,r,s);let l=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:u,metadata:await this.serde.loadsTyped("json",a),pendingWrites:l};return s!==void 0&&(d.parentConfig={configurable:{thread_id:t,checkpoint_ns:r,checkpoint_id:s}}),d}}else{let i=this.storage[t]?.[r];if(i!==void 0){n=Object.keys(i).sort((f,p)=>p.localeCompare(f))[0];let[o,a,s]=i[n],c=yu(t,r,n),u=await this.serde.loadsTyped("json",o);u.v<4&&s!==void 0&&await this._migratePendingSends(u,t,r,s);let l=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:n,checkpoint_ns:r}},checkpoint:u,metadata:await this.serde.loadsTyped("json",a),pendingWrites:l};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:n,filter:i}=t??{};e.configurable?.thread_id!==void 0&&Gt("thread_id",e.configurable.thread_id),e.configurable?.checkpoint_ns!==void 0&&Gt("checkpoint_ns",e.configurable.checkpoint_ns,{allowEmpty:!0}),e.configurable?.checkpoint_id&&Gt("checkpoint_id",e.configurable.checkpoint_id),r?.configurable?.checkpoint_id&&Gt("checkpoint_id",r.configurable.checkpoint_id);let o=e.configurable?.thread_id?[e.configurable?.thread_id]:Object.keys(this.storage),a=e.configurable?.checkpoint_ns,s=e.configurable?.checkpoint_id;for(let c of o)for(let u of Object.keys(this.storage[c]??{})){if(a!==void 0&&u!==a)continue;let l=this.storage[c]?.[u]??{},d=Object.entries(l).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(i&&!Object.entries(i).every(([C,T])=>_[C]===T))continue;if(n!==void 0){if(n<=0)break;n-=1}let y=yu(c,u,f),w=Object.values(this.writes[y]||{}),x=await Promise.all(w.map(async([C,T,b])=>[C,T,await this.serde.loadsTyped("json",b)])),S=await this.serde.loadsTyped("json",p);S.v<4&&h!==void 0&&await this._migratePendingSends(S,c,u,h);let E={config:{configurable:{thread_id:c,checkpoint_ns:u,checkpoint_id:f}},checkpoint:S,metadata:_,pendingWrites:x};h!==void 0&&(E.parentConfig={configurable:{thread_id:c,checkpoint_ns:u,checkpoint_id:h}}),yield E}}}async put(e,t,r){let n=Pn(t),i=e.configurable?.thread_id,o=e.configurable?.checkpoint_ns??"";if(i===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" } })');Gt("thread_id",i),Gt("checkpoint_ns",o,{allowEmpty:!0}),Gt("checkpoint_id",t.id),this.storage[i]||(this.storage[i]=Object.create(null)),this.storage[i][o]||(this.storage[i][o]=Object.create(null));let[[,a],[,s]]=await Promise.all([this.serde.dumpsTyped(n),this.serde.dumpsTyped(r)]);return this.storage[i][o][t.id]=[a,s,e.configurable?.checkpoint_id],{configurable:{thread_id:i,checkpoint_ns:o,checkpoint_id:t.id}}}async putWrites(e,t,r){let n=e.configurable?.thread_id,i=e.configurable?.checkpoint_ns,o=e.configurable?.checkpoint_id;if(n===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(o===void 0)throw new Error('Failed to put writes. The passed RunnableConfig is missing a required "checkpoint_id" field in its "configurable" property.');Gt("thread_id",n),Gt("checkpoint_ns",i,{allowEmpty:!0}),Gt("checkpoint_id",o),Gt("task_id",r);let a=yu(n,i,o),s=this.writes[a];this.writes[a]===void 0&&(this.writes[a]=Object.create(null)),await Promise.all(t.map(async([c,u],l)=>{let[,d]=await this.serde.dumpsTyped(u),f=[r,Cd[c]||l],p=`${f[0]},${f[1]}`;f[1]>=0&&s&&p in s||(this.writes[a][p]=[r,c,d])}))}async deleteThread(e){Gt("thread_id",e),delete this.storage[e];for(let t of Object.keys(this.writes))D3(t).threadId===e&&delete this.writes[t]}async getDeltaChannelHistory(e){let{config:t,channels:r}=e;if(r.length===0)return{};let n=t.configurable?.thread_id,i=t.configurable?.checkpoint_ns??"",o=_g(t);n!==void 0&&Gt("thread_id",n),Gt("checkpoint_ns",i,{allowEmpty:!0});let a=this.storage[n]?.[i]??{},s=[],c=(o?a[o]:void 0)?.[2];for(;c!==void 0;){let p=a[c];if(p===void 0)break;s.push(c),c=p[2]}let u={},l={},d=new Set(r);for(let p of r)u[p]=[];for(let p of s){if(d.size===0)break;let m=a[p],h=m!==void 0?await this.serde.loadsTyped("json",m[0]):void 0,_={},y=new Set;if(h!==void 0)for(let S of d)Object.prototype.hasOwnProperty.call(h.channel_values,S)&&h.channel_values[S]!==void 0&&(_[S]=h.channel_values[S],y.add(S));let w=yu(n,i,p),x=Object.entries(this.writes[w]??{});x.sort(([S],[E])=>{let[C,T]=S.split(","),[b,L]=E.split(",");return C!==b?C<b?1:-1:Number(L)-Number(T)});for(let[,[S,E,C]]of x)d.has(E)&&u[E].push([S,E,await this.serde.loadsTyped("json",C)]);for(let S of y)l[S]=_[S],d.delete(S)}let f={};for(let p of r){let m={writes:u[p].slice().reverse()};Object.prototype.hasOwnProperty.call(l,p)&&(m.seed=l[p]),f[p]=m}return f}};var vu=class extends Error{constructor(e){super(e),this.name="InvalidNamespaceError"}};function z3(e){if(e.length===0)throw new vu("Namespace cannot be empty.");for(let t of e){if(typeof t!="string")throw new vu(`Invalid namespace label '${t}' found in ${e}. Namespace labels must be strings, but got ${typeof t}.`);if(t.includes("."))throw new vu(`Invalid namespace label '${t}' found in ${e}. Namespace labels cannot contain periods ('.').`);if(t==="")throw new vu(`Namespace labels cannot be empty strings. Got ${t} in ${e}`)}if(e[0]==="langgraph")throw new vu(`Root label for namespace cannot be "langgraph". Got: ${e}`)}var bu=class{async get(e,t){return(await this.batch([{namespace:e,key:t}]))[0]}async search(e,t={}){let{filter:r,limit:n=10,offset:i=0,query:o}=t;return(await this.batch([{namespacePrefix:e,filter:r,limit:n,offset:i,query:o}]))[0]}async put(e,t,r,n){z3(e),await this.batch([{namespace:e,key:t,value:r,index:n}])}async delete(e,t){await this.batch([{namespace:e,key:t,value:null}])}async listNamespaces(e={}){let{prefix:t,suffix:r,maxDepth:n,limit:i=100,offset:o=0}=e,a=[];return t&&a.push({matchType:"prefix",path:t}),r&&a.push({matchType:"suffix",path:r}),(await this.batch([{matchConditions:a.length?a:void 0,maxDepth:n,limit:i,offset:o}]))[0]}start(){}stop(){}};var U3=e=>"lg_name"in e&&e.lg_name==="AsyncBatchedStore"?e.store:e,yg=class extends bu{lg_name="AsyncBatchedStore";store;queue=new Map;nextKey=0;running=!1;processingTask=null;constructor(e){super(),this.store=U3(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:n=10,offset:i=0,query:o}=t||{};return this.enqueueOperation({namespacePrefix:e,filter:r,limit:n,offset:i,query:o})}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 n=this.nextKey;this.nextKey+=1,this.queue.set(n,{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:n})=>n),r=await this.store.batch(t);e.forEach(({resolve:n},i)=>{n(r[Array.from(e.keys()).indexOf(i)])})}catch(t){e.forEach(({reject:r})=>{r(t)})}}}toJSON(){return{queue:this.queue,nextKey:this.nextKey,running:this.running,store:"[LangGraphStore]"}}};function Od(e){if(!e)return[];let t=[],r=[],n=0;for(;n<e.length;){let i=e[n];if(i==="["){r.length&&(t.push(r.join("")),r=[]);let o=1,a=["["];for(n+=1;n<e.length&&o>0;)e[n]==="["?o+=1:e[n]==="]"&&(o-=1),a.push(e[n]),n+=1;t.push(a.join(""));continue}else if(i==="{"){r.length&&(t.push(r.join("")),r=[]);let o=1,a=["{"];for(n+=1;n<e.length&&o>0;)e[n]==="{"?o+=1:e[n]==="}"&&(o-=1),a.push(e[n]),n+=1;t.push(a.join(""));continue}else i==="."?r.length&&(t.push(r.join("")),r=[]):r.push(i);n+=1}return r.length&&t.push(r.join("")),t}function L3(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 ZM(e,t){return L3(t)?Object.keys(t).filter(r=>r.startsWith("$")).every(r=>{let n=t[r];switch(r){case"$eq":return e===n;case"$ne":return e!==n;case"$gt":return Number(e)>Number(n);case"$gte":return Number(e)>=Number(n);case"$lt":return Number(e)<Number(n);case"$lte":return Number(e)<=Number(n);case"$in":return Array.isArray(n)?n.includes(e):!1;case"$nin":return Array.isArray(n)?!n.includes(e):!0;default:return!1}}):e===t}function GM(e,t){if(!t||t==="$")return[JSON.stringify(e,null,2)];let r=Array.isArray(t)?t:Od(t);function n(i,o,a){if(a>=o.length)return typeof i=="string"||typeof i=="number"||typeof i=="boolean"?[String(i)]:i==null?[]:Array.isArray(i)||typeof i=="object"?[JSON.stringify(i,null,2)]:[];let s=o[a],c=[];if(a===0&&s==="$"&&c.push(JSON.stringify(i,null,2)),s.startsWith("[")&&s.endsWith("]")){if(!Array.isArray(i))return[];let u=s.slice(1,-1);if(u==="*")for(let l of i)c.push(...n(l,o,a+1));else try{let l=parseInt(u,10);l<0&&(l=i.length+l),l>=0&&l<i.length&&c.push(...n(i[l],o,a+1))}catch{return[]}}else if(s.startsWith("{")&&s.endsWith("}")){if(typeof i!="object"||i===null)return[];let u=s.slice(1,-1).split(",").map(l=>l.trim());for(let l of u){let d=Od(l);if(d.length){let f=i;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(i))for(let u of i)c.push(...n(u,o,a+1));else if(typeof i=="object"&&i!==null)for(let u of Object.values(i))c.push(...n(u,o,a+1))}else typeof i=="object"&&i!==null&&s in i&&c.push(...n(i[s],o,a+1));return c}return n(e,r,0)}var WM=class extends bu{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]:Od(t)])})}async batch(e){let t=[],r=new Map,n=new Map;for(let i=0;i<e.length;i+=1){let o=e[i];if("key"in o&&"namespace"in o&&!("value"in o))t.push(this.getOperation(o));else if("namespacePrefix"in o){let a=this.filterItems(o);n.set(i,[o,a]),t.push(null)}else if("value"in o){let a=`${o.namespace.join(":")}:${o.key}`;r.set(a,o),t.push(null)}else"matchConditions"in o&&t.push(this.listNamespacesOperation(o))}if(n.size>0)if(this._indexConfig?.embeddings){let i=new Set;for(let[s]of n.values())s.query&&i.add(s.query);let o=i.size>0?await Promise.all(Array.from(i).map(s=>this._indexConfig.embeddings.embedQuery(s))):[],a=Object.fromEntries(Array.from(i).map((s,c)=>[s,o[c]]));for(let[s,[c,u]]of n.entries())if(c.query&&a[c.query]){let l=a[c.query];t[s]=this.scoreResults(u,l,c.offset??0,c.limit??10)}else t[s]=this.paginateResults(u.map(l=>({...l,score:void 0})),c.offset??0,c.limit??10)}else for(let[i,[o,a]]of n.entries())t[i]=this.paginateResults(a.map(s=>({...s,score:void 0})),o.offset??0,o.limit??10);if(r.size>0&&this._indexConfig?.embeddings){let i=this.extractTexts(Array.from(r.values()));if(Object.keys(i).length>0){let o=await this._indexConfig.embeddings.embedDocuments(Object.keys(i));this.insertVectors(i,o)}}for(let i of r.values())this.putOperation(i);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 n=new Date;if(r.has(e.key)){let i=r.get(e.key);i.value=e.value,i.updatedAt=n}else r.set(e.key,{value:e.value,key:e.key,namespace:e.namespace,createdAt:n,updatedAt:n})}}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(n=>this.doesMatch(n,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,n)=>r.join(":").localeCompare(n.join(":"))),t.slice(e.offset??0,(e.offset??0)+(e.limit??t.length))}doesMatch(e,t){let{matchType:r,path:n}=e;if(r==="prefix")return n.length>t.length?!1:n.every((i,o)=>{let a=t[o];return i==="*"||a===i});if(r==="suffix")return n.length>t.length?!1:n.every((i,o)=>{let a=t[t.length-n.length+o];return i==="*"||a===i});throw new Error(`Unsupported match type: ${r}`)}filterItems(e){let t=[];for(let[n,i]of this.data.entries())n.startsWith(e.namespacePrefix.join(":"))&&t.push(...i.values());let r=t;return e.filter&&(r=t.filter(n=>Object.entries(e.filter).every(([i,o])=>ZM(n.value[i],o)))),r}scoreResults(e,t,r=0,n=10){let i=[],o=[],a=[];for(let l of e){let d=this.getVectors(l);if(d.length)for(let f of d)i.push(l),o.push(f);else a.push(l)}let s=this.cosineSimilarity(t,o).map((l,d)=>[l,i[d]]).sort((l,d)=>d[0]-l[0]),c=new Set,u=[];for(let[l,d]of s){let f=`${d.namespace.join(":")}:${d.key}`;if(c.has(f))continue;let p=c.size;if(p>=r+n)break;if(p<r){c.add(f);continue}c.add(f),u.push([l,d])}if(a.length&&u.length<n)for(let l of a.slice(0,n-u.length)){let d=`${l.namespace.join(":")}:${l.key}`;c.has(d)||(c.add(d),u.push([void 0,l]))}return u.map(([l,d])=>({...d,score:l}))}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 n=r.index===null||r.index===void 0?this._indexConfig.__tokenizedFields??[]:r.index.map(i=>[i,Od(i)]);for(let[i,o]of n){let a=GM(r.value,o);a.length&&(a.length>1?a.forEach((s,c)=>{t[s]||(t[s]=[]),t[s].push([r.namespace,r.key,`${i}.${c}`])}):(t[a[0]]||(t[a[0]]=[]),t[a[0]].push([r.namespace,r.key,i])))}}return t}insertVectors(e,t){for(let[r,n]of Object.entries(e)){let i=t.shift();if(!i)throw new Error(`No embedding found for text: ${r}`);for(let[o,a,s]of n){let c=o.join(":");this.vectors.has(c)||this.vectors.set(c,new Map);let u=this.vectors.get(c);u.has(a)||u.set(a,new Map),u.get(a).set(s,i)}}}getVectors(e){let t=e.namespace.join(":"),r=e.key;if(!this.vectors.has(t))return[];let n=this.vectors.get(t);if(!n.has(r))return[];let i=n.get(r),o=Array.from(i.values());return o.length?o:[]}cosineSimilarity(e,t){if(!t.length)return[];let r=t.map(o=>o.reduce((a,s,c)=>a+s*e[c],0)),n=Math.sqrt(e.reduce((o,a)=>o+a*a,0)),i=t.map(o=>Math.sqrt(o.reduce((a,s)=>a+s*s,0)));return r.map((o,a)=>{let s=i[a];return n&&s?o/(n*s):0})}get indexConfig(){return this._indexConfig}};var vg=class{serde=new mg;constructor(e){this.serde=e||this.serde}};var F3=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function mn(e){return e!=null&&e.lc_graph_name==="DeltaChannel"}function $k(e){return e!=null&&e.lg_is_channel===!0}var xt=class{ValueType;UpdateType;lg_is_channel=!0;consume(){return!1}finish(){return!1}isAvailable(){try{return this.get(),!0}catch(e){if(e.name===Ue.unminifiable_name)return!1;throw e}}equals(e){return this===e}},Ik=Symbol.for("LG_IS_ONLY_BASE_CHANNEL");function wu(e){if(e[Ik]===!0)return e;let t={};for(let r in e){if(!Object.prototype.hasOwnProperty.call(e,r))continue;let n=e[r];$k(n)&&(t[r]=n)}return Object.assign(t,{[Ik]:!0}),t}function bg(e,t){let r=wu(e),n={};for(let i in r){if(!Object.prototype.hasOwnProperty.call(r,i))continue;let o=t.channel_values[i];n[i]=r[i].fromCheckpoint(o)}return Object.assign(n,{[Ik]:!0}),n}function Tk(e,t){if(!F3.test(t))throw new TypeError(`Invalid task id for exit delta: ${t}`);let r=t.toLowerCase().split("-");return`${String(e).padStart(8,"0")}-${r[1]}-${r[2]}-${r[3]}-${r[4]}`}function wg(e,t){let r=new Set,n=xE();for(let i in e){if(!Object.prototype.hasOwnProperty.call(e,i))continue;let o=e[i];if(!mn(o)||!o.isAvailable())continue;let[a,s]=t[i]??[0,0];(a>=o.snapshotFrequency||s>=n)&&r.add(i)}return r}function Nn(e,t,r,n){let i=n?.channelsToSnapshot??new Set,{updatedChannels:o,getNextVersion:a}=n??{},s,c=e.channel_versions;if(t===void 0)s=e.channel_values;else{s={},c={...e.channel_versions};for(let u in t){if(!Object.prototype.hasOwnProperty.call(t,u))continue;let l=t[u];if(i.has(u)){a!==void 0&&(o===void 0||!o.has(u))&&(c[u]=a(c[u])),s[u]=new Us(l.get());continue}if(!mn(l))try{s[u]=l.checkpoint()}catch(d){if(d.name!==Ue.unminifiable_name)throw d}}}return{v:4,id:n?.id??Lu(r),ts:new Date().toISOString(),channel_values:s,channel_versions:c,versions_seen:e.versions_seen}}async function xu(e,t,r){let n=bg(e,t),{saver:i,config:o}=r??{},a=wu(e),s=[];for(let u in a)Object.prototype.hasOwnProperty.call(a,u)&&mn(a[u])&&!Object.prototype.hasOwnProperty.call(t.channel_values,u)&&s.push(u);if(s.length===0||i===void 0||o===void 0)return n;let c=await i.getDeltaChannelHistory({config:o,channels:s});for(let u of s){let l=c[u];if(l===void 0)continue;let d=a[u].fromCheckpoint(l.seed);d.replayWrites(l.writes),n[u]=d}return n}var B3=e=>e!=null&&e.lc_graph_name==="BinaryOperatorAggregate",Ki=class qM extends xt{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 qM(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 i=r[0],[o,a]=_n(i);o?this.value=a:this.value=i,r=r.slice(1)}let n=!1;for(let i of r)if(ma(i)){if(n)throw new we("Can receive only one Overwrite value per step.");let[,o]=_n(i);this.value=o,n=!0;continue}else!n&&this.value!==void 0&&(this.value=this.operator(this.value,i));return!0}get(){if(this.value===void 0)throw new Ue;return this.value}checkpoint(){if(this.value===void 0)throw new Ue;return this.value}isAvailable(){return this.value!==void 0}equals(t){return this===t?!0:B3(t)?this.operator===t.operator:!1}};var Rn=class KM extends xt{lc_graph_name="LastValue";value=[];constructor(t){super(),this.initialValueFactory=t,t&&(this.value=[t()])}fromCheckpoint(t){let r=new KM(this.initialValueFactory);return typeof t<"u"&&(r.value=[t]),r}update(t){if(t.length===0)return!1;if(t.length!==1)throw new we("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 Ue;return this.value[0]}checkpoint(){if(this.value.length===0)throw new Ue;return this.value[0]}isAvailable(){return this.value.length!==0}},Ak=class JM extends xt{lc_graph_name="LastValueAfterFinish";value=[];finished=!1;fromCheckpoint(t){let r=new JM;if(typeof t<"u"){let[n,i]=t;r.value=[n],r.finished=i}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 Ue;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 xg=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"}},Pd=function(e){return e?Sg(e):new Rn};Pd.Root=e=>new xg(e);function Sg(e){return typeof e=="object"&&e&&"reducer"in e&&e.reducer?new Ki(e.reducer,e.default):typeof e=="object"&&e&&"value"in e&&e.value?new Ki(e.value,e.default):new Rn}var V3=["tags","metadata","callbacks","configurable"],H3=["tags","metadata","callbacks","runName","maxConcurrency","recursionLimit","configurable","runId","outputKeys","streamMode","store","writer","interrupt","context","interruptBefore","interruptAfter","checkpointDuring","durability","signal","heartbeat","executionInfo","serverInfo","control"],Z3=25,G3=new Set(["thread_id","checkpoint_id","checkpoint_ns","task_id","run_id","assistant_id","graph_id"]);function W3(e,t){if(!e)return t;let r=t??{};for(let n of G3){if(n in r)continue;let i=e[n];i!==void 0&&(r[n]=i)}return r}function XM(e){if(e==null||e.length===0)return;let t=e.filter(r=>!r.startsWith("seq:step"));return t.length>0?t:void 0}function q3(e,t){if(t===void 0)return e;if(e===void 0)return Array.isArray(t)?[...t]:t.copy();if(Array.isArray(t)){if(Array.isArray(e))return e.concat(t);let r=e.copy();for(let n of t)r.addHandler(Ni(n),!0);return r}if(Array.isArray(e)){let r=t.copy();for(let n of e)r.addHandler(Ni(n),!0);return r}return new tt(t._parentRunId,{handlers:e.handlers.concat(t.handlers),inheritableHandlers:e.inheritableHandlers.concat(t.inheritableHandlers),tags:Array.from(new Set(e.tags.concat(t.tags))),inheritableTags:Array.from(new Set(e.inheritableTags.concat(t.inheritableTags))),metadata:{...e.metadata,...t.metadata},inheritableMetadata:{...e.inheritableMetadata,...t.inheritableMetadata}})}function K3(e){let t;for(let o=e.length-1;o>=0;o-=1)if(e[o]!==void 0){t=e[o];break}let r=t?.configurable?.thread_id!==void 0,n=e.some(o=>o?.configurable?.[cr]!==void 0),i=Me.getRunnableConfig()?.configurable?.[cr]!==void 0;return r&&!n&&!i}function Su(...e){let t={tags:[],metadata:{},callbacks:void 0,recursionLimit:Z3,configurable:{}},r=K3(e),n=Me.getRunnableConfig();if(n!==void 0){for(let[i,o]of Object.entries(n))if(o!==void 0){if(i==="configurable"&&r)continue;if(V3.includes(i)){let a;Array.isArray(o)?a=[...o]:typeof o=="object"?i==="callbacks"&&"copy"in o&&typeof o.copy=="function"?a=o.copy():a={...o}:a=o,t[i]=a}else t[i]=o}}for(let i of e)if(i!==void 0)for(let[o,a]of Object.entries(i))a===void 0||!H3.includes(o)||(o==="configurable"?t.configurable={...t.configurable,...a}:o==="metadata"?t.metadata={...t.metadata,...a}:o==="tags"?t.tags=[...t.tags??[],...a]:o==="callbacks"?t.callbacks=q3(t.callbacks,a):t[o]=a);return t.metadata=W3(t.configurable,t.metadata)??{},t}function J3(e){let t=e??Me.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(`
438
- `));return t?.store}function X3(e){let t=e??Me.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(`
439
- `));return t?.writer||t?.configurable?.writer}function kg(){return Me.getRunnableConfig()}function Y3(e){let t=e??Me.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(`
440
- `));if(t.configurable?.__pregel_scratchpad?.currentTaskInput===void 0)throw new Error("BUG: internal scratchpad not initialized.");return t.configurable[ur].currentTaskInput}function Eg(e){return e.split("|").filter(t=>!t.match(/^\d+$/)).map(t=>t.split(":")[0]).join("|")}function YM(e){let t=e.split("|");for(;t.length>1&&t[t.length-1].match(/^\d+$/);)t.pop();return t.slice(0,-1).join("|")}var Ck=class{#e=void 0;requestDrain(e="shutdown"){this.#e=e}get drainRequested(){return this.#e!==void 0}get drainReason(){return this.#e}};var Ok=["values","updates","messages","tools","custom","tasks"];function ku(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 Q3(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 n=r,i=typeof n.langgraph_node=="string"?n.langgraph_node:void 0,o=typeof n.run_id=="string"?n.run_id:void 0;return{data:o!=null&&t!=null&&typeof t=="object"?{...t,run_id:o}:t,node:i}}function Pk({namespace:e,mode:t,payload:r,seq:n}){let i=Date.now(),o={type:"event"};switch(t){case"messages":{let{data:a,node:s}=Q3(r);return[{...o,seq:n,method:"messages",params:{namespace:e,timestamp:i,...s?{node:s}:{},data:a}}]}case"tools":return[{...o,seq:n,method:"tools",params:{namespace:e,timestamp:i,data:eZ(r)}}];case"checkpoints":return ku(r)?[{...o,seq:n,method:"checkpoints",params:{namespace:e,timestamp:i,data:r}}]:[];case"values":return[{...o,seq:n,method:"values",params:{namespace:e,timestamp:i,data:r}}];case"updates":{let a=tZ(r);return[{...o,seq:n,method:"updates",params:{namespace:e,timestamp:i,...typeof a.node=="string"?{node:a.node}:{},data:a}}]}case"custom":{let a=typeof r=="object"&&r!==null&&!Array.isArray(r)&&"name"in r?r:{payload:r};return[{...o,seq:n,method:"custom",params:{namespace:e,timestamp:i,data:a}}]}case"tasks":return[{...o,seq:n,method:"tasks",params:{namespace:e,timestamp:i,data:r}}];default:return[]}}function eZ(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 n=t.error;return{event:"tool-error",tool_call_id:r,message:typeof n=="object"&&n!==null&&"message"in n&&typeof n.message=="string"?n.message:String(n??"unknown error")}}default:return{event:"tool-error",tool_call_id:"",message:`Unknown tool event: ${String(t.event)}`}}}function tZ(e){if(typeof e!="object"||e===null)return{values:{}};let t=Object.entries(e);if(t.length===0)return{values:{}};let[r,n]=t[0];return{node:r,values:typeof n=="object"&&n!==null?n:{value:n}}}var Nk=Symbol.for("langgraph.stream_channel"),hn=class Rk{[Nk]=!0;channelName;#e=[];#t=[];#n=!1;#o;#i;constructor(t){this.channelName=t}static local(){return new Rk}static remote(t){return new Rk(t)}static isInstance(t){return typeof t=="object"&&t!==null&&Nk in t&&t[Nk]===!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.#o)throw this.#o;return{value:void 0,done:!0}}await new Promise(n=>this.#t.push(n))}}}}toAsyncIterable(t=0){return{[Symbol.asyncIterator]:()=>this.iterate(t)}}toEventStream(t={}){let r=new TextEncoder,n=this.iterate(t.startAt),i=t.event??this.channelName,o=t.serialize??(a=>JSON.stringify(a)??"null");return new ReadableStream({async pull(a){try{let s=await n.next();if(s.done){a.close();return}let c=[];i!=null&&c.push(`event: ${i}`);for(let u of o(s.value).split(/\r\n|\r|\n/))c.push(`data: ${u}`);a.enqueue(r.encode(`${c.join(`
441
- `)}
442
-
443
- `))}catch(s){a.error(s)}},async cancel(){await n.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.#o=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 QM(e){return hn.isInstance(e)}var rZ="custom:";function nZ(e){return`${rZ}${e}`}function iZ(e){return e!=null&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"}var Ig=Symbol("resolveValues"),jk=Symbol("rejectValues"),eD=class{_events=hn.local();_discoveries=hn.local();#e=0;#t=!1;#n;#o=!1;#i=[];#r=[];#s=[];#a=new Map;#u=new Map;#c=[];#l=[];register(e,t){this.#a.set(St(e),t)}addTransformer(e){let t=this._events.size;this.#r.push(e),e.onRegister&&e.onRegister({push:(r,n)=>this.push(r,n)});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(QM(r)){if(this.#s.push(r),typeof r.channelName!="string")continue;let n=nZ(r.channelName);r._wire(i=>{this._events.push({type:"event",seq:this.#e++,method:n,params:{namespace:this.#i,timestamp:Date.now(),data:i}})});continue}iZ(r)&&this.#l.push({name:t,promise:Promise.resolve(r)})}}push(e,t){t.method==="values"&&this.#u.set(St(e),t.params.data);let r=this.#i;this.#i=e;let n=!0;for(let i of this.#r)i.process(t)||(n=!1);this.#i=r,n&&this._events.push({...t,seq:this.#e++})}close(){this.#t=!0;for(let[r,n]of this.#u.entries()){let i=r?r.split("\0"):[];this.#a.get(St(i))?.[Ig](n)}let e=[];for(let r of this.#r){let n=r.finalize?.();n!=null&&typeof n.then=="function"&&e.push(n)}for(let r of this.#s)r._close();let t=this.#l;t.length===0&&e.length===0?(this._events.close(),this._discoveries.close()):Promise.allSettled([...e,...t.map(async({name:r,promise:n})=>{try{let i=await n;this._events.done||this._events.push({type:"event",seq:this.#e++,method:"custom",params:{namespace:[],timestamp:Date.now(),data:{name:r,payload:i}}})}catch{}})]).then(()=>{this._events.close(),this._discoveries.close()});for(let r of this.#a.values())r[Ig](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.#a.values())t[jk](e)}markInterrupted(e){this.#o=!0,this.#c.push(...e)}get interrupted(){return this.#o}get interrupts(){return this.#c}subscribeEvents(e,t=0){let r=this._events.iterate(t);return{async next(){for(;;){let n=await r.next();if(n.done||_i(n.value.params.namespace,e))return n}}}}};async function tD(e,t){let r=0;try{for await(let n of e){let[i,o,a]=n;if(o==="values"&&ha(a)){let c=a[Ve];t.markInterrupted(c.map(u=>({interruptId:u.id??"",payload:u.value})))}let s=Pk({namespace:i,mode:o,payload:a,seq:r});r+=s.length;for(let c of s)t.push(i,c)}}catch(n){t.fail(n);return}t.close()}function St(e){return e.join("\0")}function _i(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 $g(e,t,r=0){return{[Symbol.asyncIterator](){let n=e.iterate(r);return{async next(){for(;;){let i=await n.next();if(i.done)return{value:void 0,done:!0};if(_i(i.value.namespace,t))return{value:i.value,done:!1}}}}}}}var rD="root";function oZ(e){if(e.length===0)return rD;let t=e[e.length-1],r=t.indexOf(":");return r===-1?t:t.slice(0,r)}function aZ(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function yi(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function sZ(e){if(!yi(e)||e.event!=="started")return;let t=e.cause;if(yi(t)&&typeof t.type=="string")return t}function cZ(e){if(yi(e)&&"result"in e&&typeof e.name=="string"&&typeof e.id=="string"&&!e.name.startsWith("__"))return{name:e.name,id:e.id}}function Mk(e={}){let t=e.rootGraphName??rD,r=e.initialStatus??"running",n=e.emitRootOnRegister??!0,i=e.getGraphName??oZ,o=e.serializeError??aZ,a=e.getTerminalStatusOverride,s=hn.local(),c=new Map,u=new Map,l=new Map,d=new Map,f=new Set,p=[],m,h=0,_=!1,y=V=>{if(V.length===0)return t;let Y=l.get(St(V));return typeof Y=="string"&&Y.length>0?Y:i(V)},w=(V,Y)=>{let oe=St(V);if(l.has(oe))return;let ae=(yi(Y)&&yi(Y.metadata)?Y.metadata:void 0)?.lc_agent_name;l.set(oe,typeof ae=="string"?ae:void 0)},x=V=>{if(!yi(V))return;let Y=V.id;if(typeof Y!="string")return;let oe=V.input,ae;if(yi(oe)&&yi(oe.tool_call)){let Oe=oe.tool_call.id;typeof Oe=="string"&&(ae=Oe)}else if(Array.isArray(oe)){for(let Oe of oe)if(yi(Oe)&&typeof Oe.id=="string"){ae=Oe.id;break}}ae!=null&&d.set(Y,ae)},S=V=>{if(V.length===0)return;let Y=l.get(St(V));if(typeof Y!="string"||Y.length===0)return;let oe=V[V.length-1],ae=oe.indexOf(":");if(ae===-1)return;let Oe=oe.slice(ae+1);if(Oe.length===0)return;let zr=d.get(Oe);if(!(typeof zr!="string"||zr.length===0))return{type:"toolCall",tool_call_id:zr}},E=V=>u.get(St(V))??S(V),C=(V,Y,oe)=>{let ae=St(V),Oe=c.get(ae),zr=Oe?.graphName??y(V);if(Oe!=null&&Oe.status===Y&&Oe.graphName===zr&&oe?.error==null)return;Oe==null?(Oe={namespace:V,graphName:zr,status:Y},c.set(ae,Oe)):Oe.status=Y;let no={event:Y,graph_name:zr,...oe?.cause!=null?{cause:oe.cause}:{},...oe?.error!=null?{error:oe.error}:{}},io=Date.now();if(s.push({namespace:V,timestamp:io,...no}),!(V.length===0&&!n)&&m!=null){h+=1;try{m.push(V,{type:"event",seq:0,method:"lifecycle",params:{namespace:V,timestamp:io,data:no}})}finally{h-=1}}},T=V=>{let Y=St(V),oe=c.get(Y);return oe==null&&(oe={namespace:V,graphName:y(V),status:void 0},c.set(Y,oe)),oe},b=()=>{if(p.length===0)return;let V=p.splice(0,p.length);for(let Y of V){let oe=St(Y.namespace),ae=c.get(oe);ae==null||ae.status!=="started"||C(Y.namespace,"completed")}},L=V=>{let Y=St(V.namespace),oe=c.get(Y);oe==null||oe.status!=="started"||p.some(ae=>St(ae.namespace)===Y)||p.push(V)},N=(V,Y)=>{for(let oe=p.length-1;oe>=0;oe-=1){let ae=p[oe];ae.source.type==="node"&&ae.source.node===Y&&St(ae.source.parent)===St(V)&&p.splice(oe,1)}},W=V=>{for(let Y=1;Y<=V.length;Y+=1){let oe=V.slice(0,Y),ae=St(oe);if(c.has(ae))continue;T(oe);let Oe=E(oe);C(oe,"started",Oe!=null?{cause:Oe}:void 0)}},ie=()=>f.size>0?"interrupted":"completed",_e=V=>{for(let Y of c.values())Y.namespace.length!==0&&Y.status==="started"&&C(Y.namespace,V);C([],V),s.close()},$e=async()=>{if(a==null)return ie();try{return await a()??ie()}catch{return ie()}},ct=(V,Y)=>{let oe=`${Y}:`;for(let ae of c.values()){if(ae.namespace.length!==V.length+1||ae.status!=="started"||!_i(ae.namespace,V))continue;let Oe=ae.namespace[ae.namespace.length-1];if(Oe===Y||Oe.startsWith(oe))return ae.namespace}},be=(V,Y)=>{let oe=[...V,`${Y.name}:${Y.id}`];return c.get(St(oe))?.status==="started"?oe:void 0};return{__native:!0,init(){return{_lifecycleLog:s,lifecycle:$g(s,[],0)}},onRegister(V){m=V,T([]),n&&C([],r)},process(V){let Y=V.params.namespace;if(h>0)return!0;let oe=V.method==="tasks"?cZ(V.params.data):void 0;if(oe!=null?N(Y,oe.name):V.method==="tasks"&&(w(Y,V.params.data),x(V.params.data)),b(),V.method==="lifecycle"){let ae=sZ(V.params.data);return ae!=null&&u.set(St(Y),ae),W(Y),!1}if(W(Y),V.method==="input"&&yi(V.params.data)&&V.params.data.event==="requested"){let ae=V.params.data.id;typeof ae=="string"&&f.add(ae)}if(oe!=null){let ae=be(Y,oe);ae!=null&&L({namespace:ae,source:{type:"task"}})}if(V.method==="updates"){let ae=V.params.node;if(typeof ae=="string"&&!ae.startsWith("__")){let Oe=ct(Y,ae);Oe!=null&&L({namespace:Oe,source:{type:"node",parent:Y,node:ae}})}}return!0},finalize(){if(!_){if(_=!0,b(),a==null){_e(ie());return}return $e().then(_e).catch(V=>{s.fail(V)})}},fail(V){if(_)return;_=!0;let Y=o(V);for(let oe of c.values())oe.namespace.length!==0&&oe.status==="started"&&C(oe.namespace,"failed");C([],"failed",{error:Y}),s.fail(V)}}}function Eu(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 Nd(e,t){let r=hn.local(),n=new Map,i=new Set;return{init:()=>({messages:r.toAsyncIterable()}),process(o){if(o.method!=="messages"||!_i(o.params.namespace,e)||o.params.namespace.length!==e.length+1||t!==void 0&&o.params.node!==t)return!0;let a=o.params.data;switch(a.event){case"message-start":{let s=Eu(a);if(a.role==="tool"){i.add(s);break}let c=hn.local(),u=Object.assign(new Qo(c.toAsyncIterable()),{namespace:o.params.namespace,node:o.params.node});n.set(s,{source:c,stream:u}),c.push(a),r.push(u);break}case"content-block-start":case"content-block-delta":case"content-block-finish":if(i.has(Eu(a)))break;n.get(Eu(a))?.source.push(a);break;case"message-finish":{let s=Eu(a);if(i.delete(s))break;let c=n.get(s);c&&(c.source.push(a),c.source.close(),n.delete(s));break}case"error":if(i.has(Eu(a)))break;n.get(Eu(a))?.source.push(a);break}return!0},finalize(){for(let[o,a]of n)a.source.push({event:"message-finish"}),a.source.close(),n.delete(o);i.clear(),r.close()},fail(o){for(let[a,s]of n)s.source.fail(o),n.delete(a);i.clear(),r.fail(o)}}}function Rd(e,t,r=0){let n=t.length+1;return{[Symbol.asyncIterator](){let i=e.iterate(r);return{async next(){for(;;){let o=await i.next();if(o.done)return{value:void 0,done:!0};let{ns:a,stream:s}=o.value;if(a.length===n&&_i(a,t))return{value:s,done:!1}}}}}}}function Dk(e,t){let{createStream:r}=t,n=new Set;return{__native:!0,init(){return{_discoveries:e._discoveries,subgraphs:Rd(e._discoveries,[],0)}},process(i){let o=i.params.namespace;if(o.length===0)return!0;let a=o.slice(0,1),s=St(a);if(n.has(s))return!0;n.add(s);let c=r(a,e._discoveries.size,e._events.size);return e.register(a,c),e._discoveries.push({ns:a,stream:c}),!0}}}function zk(e){let t=hn.local();return{init:()=>({_valuesLog:t}),process(r){return r.method!=="values"||r.params.namespace.length!==e.length||!_i(r.params.namespace,e)||t.push(r.params.data),!0},finalize(){t.close()},fail(r){t.fail(r)}}}function Tg(e){return"__native"in e&&e.__native===!0}var nD=Symbol("setValuesLog"),iD=Symbol("setMessagesIterable"),Uk=Symbol("setLifecycleIterable"),Lk=Symbol("setSubgraphsIterable"),uZ={[Symbol.asyncIterator](){return{next:()=>Promise.resolve({value:void 0,done:!0})}}},Fk=class{path;extensions;_mux;#e;#t;#n;#o;#i;#r;#s;#a;#u;#c;constructor(e,t,r=0,n=0,i,o){this.path=e,this._mux=t,this.#t=r,this.#e=n,this.extensions=i??{},this.#n=o??new AbortController,this.#r=new Promise((a,s)=>{this.#o=a,this.#i=s}),this.#r.catch(()=>{})}[Symbol.asyncIterator](){return this._mux.subscribeEvents(this.path,this.#e)}get subgraphs(){return this.#c?this.#c:Rd(this._mux._discoveries,this.path,this.#t)}get values(){let e=this.#s,t=this.#r,r=this._mux,n=this.#e,i=this.path,o=e?e.toAsyncIterable():{[Symbol.asyncIterator]:()=>{let a=r.subscribeEvents(i,n);return{async next(){for(;;){let s=await a.next();if(s.done)return{value:void 0,done:!0};if(s.value.method==="values"&&s.value.params.namespace.length===i.length)return{value:s.value.params.data,done:!1}}}}}};return{[Symbol.asyncIterator]:()=>o[Symbol.asyncIterator](),then:t.then.bind(t)}}get messages(){if(this.#a)return this.#a;let e=Nd(this.path),t=e.init();return this._mux.addTransformer(e),this.#a=t.messages,this.#a}get lifecycle(){return this.#u??uZ}messagesFrom(e){let t=Nd(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}[Ig](e){this.#o?.(e),this.#o=void 0}[jk](e){this.#i?.(e),this.#i=void 0}[nD](e){this.#s=e}[iD](e){this.#a=e}[Uk](e){this.#u=e}[Lk](e){this.#c=e}},oD=class extends Fk{name;index;constructor(e,t,r=0,n=0,i,o){super(e,t,r,n,i,o);let a=e[e.length-1]??"",s=a.lastIndexOf(":");if(s>=0){this.name=a.slice(0,s);let c=a.slice(s+1);this.index=/^\d+$/.test(c)?Number(c):0}else this.name=a,this.index=0}};function Bk(e,t=[],r){let{abortController:n}=r instanceof AbortController?{abortController:r}:r??{},i=new eD,o=Mk(),a=o.init(),s=a._lifecycleLog,c=Dk(i,{createStream:(y,w,x)=>{let S=new oD(y,i,w,x);return S[Lk](Rd(i._discoveries,y,w)),S[Uk]($g(s,y,s.size)),S}}),u=c.init();i.addTransformer(c),i.addTransformer(o);let l=zk([]),d=Nd([]);i.addTransformer(l),i.addTransformer(d);let f={},p=[];for(let y of t){let w=y();i.addTransformer(w);let x=w.init();Tg(w)?p.push(x):Object.assign(f,x),typeof x=="object"&&x!==null&&!Tg(w)&&i.wireChannels(x)}let m=new Fk([],i,0,0,f,n);for(let y of p)Object.assign(m,y);let h=l.init();m[nD](h._valuesLog);let _=d.init();return m[iD](_.messages),m[Uk](a.lifecycle),m[Lk](u.subgraphs),i.register([],m),tD(e,i).catch(y=>{}),m}var B=e=>BigInt(e),Ge=(e,t=0)=>new DataView(e.buffer,e.byteOffset+t,e.byteLength-t),uD=B("0x9E3779B1"),lD=B("0x85EBCA77"),lZ=B("0xC2B2AE3D"),ta=B("0x9E3779B185EBCA87"),Os=B("0xC2B2AE3D27D4EB4F"),dD=B("0x165667B19E3779F9"),Zk=B("0x85EBCA77C2B2AE63"),dZ=B("0x27D4EB2F165667C5"),fZ=B("0x165667919E3779F9"),pZ=B("0x9FB21C651E98DF25"),mZ=e=>{let t=e.length;if(t%2!==0)throw new Error("String should have an even number of characters");let r=t/2,n=new Uint8Array(r),i=0,o=0;for(;o<r;){let a=e.slice(i,i+=2);n[o]=Number.parseInt(a,16),o+=1}return Ge(n)},vi=mZ("b8fe6c3923a44bbe7c01812cf721ad1cded46de9839097db7240a4a4b7b3671fcb79e64eccc0e578825ad07dccff7221b8084674f743248ee03590e6813a264c3c2852bb91c300cb88d0658b1b532ea371644897a20df94e3819ef46a9deacd8a8fa763fe39c343ff9dcbbc7c70b4f1d8a51e04bcdb45931c89f7ec9d9787364eac5ac8334d3ebc3c581a0fffa1363eb170ddd51b7f0da49d316552629d4689e2b16be587d47a1fc8ff8b8d17ad031ce45cb3a8f95160428afd7fbcabb4b407e"),Iu=(B(1)<<B(128))-B(1),ke=(B(1)<<B(64))-B(1),Pg=(B(1)<<B(32))-B(1),Ji=64,fD=Ji/8,hZ=8,Ag=4;function $u(e){if(!e)throw new Error("Assert failed")}function gZ(e){let t=new DataView(new ArrayBuffer(8));return t.setBigUint64(0,e,!0),t.getBigUint64(0,!1)}function _Z(e){let t=e;return t=(t&B(65535))<<B(16)|(t&B(4294901760))>>B(16),t=(t&B(16711935))<<B(8)|(t&B(4278255360))>>B(8),t}function yZ(e,t){return(e&Pg)*(t&Pg)&ke}function vZ(e,t){return(e<<t|e>>B(32)-t)&Pg}function pD(e,t,r){for(let n=0;n<fD;n+=1){let i=t.getBigUint64(n*8,!0),o=i^r.getBigUint64(n*8,!0);e[n^1]+=i,e[n]+=yZ(o,o>>B(32))}return e}function aD(e,t,r,n){for(let i=0;i<n;i+=1)pD(e,Ge(t,i*Ji),Ge(r,i*8));return e}function bZ(e,t){for(let r=0;r<fD;r+=1){let n=t.getBigUint64(r*8,!0),i=e[r];i=Vk(i,B(47)),i^=n,i*=uD,e[r]=i&ke}return e}function Cg(e,t){return mD(e[0]^t.getBigUint64(0,!0),e[1]^t.getBigUint64(hZ,!0))}function sD(e,t,r){let n=r;return n+=Cg(e.slice(0),Ge(t,0*Ag)),n+=Cg(e.slice(2),Ge(t,4*Ag)),n+=Cg(e.slice(4),Ge(t,8*Ag)),n+=Cg(e.slice(6),Ge(t,12*Ag)),bi(n&ke)}function wZ(e,t,r,n,i){let o=e,a=Math.floor((r.byteLength-Ji)/8),s=Ji*a,c=Math.floor((t.byteLength-1)/s);for(let u=0;u<c;u+=1)o=aD(o,Ge(t,u*s),r,a),o=i(o,Ge(r,r.byteLength-Ji));{let u=Math.floor((t.byteLength-1-s*c)/Ji);o=aD(o,Ge(t,c*s),r,u),o=n(o,Ge(t,t.byteLength-Ji),Ge(r,r.byteLength-Ji-7))}return o}function xZ(e,t){let r=new BigUint64Array([lZ,ta,Os,dD,Zk,lD,dZ,uD]);$u(e.byteLength>128),r=wZ(r,e,t,pD,bZ),$u(r.length*8===64);{let n=sD(r,Ge(t,11),B(e.byteLength)*ta&ke);return sD(r,Ge(t,t.byteLength-Ji-11),~(B(e.byteLength)*Os)&ke)<<B(64)|n}}function mD(e,t){let r=e*t&Iu;return r&ke^r>>B(64)}function cD(e,t,r){return mD((e.getBigUint64(0,!0)^t.getBigUint64(0,!0)+r)&ke,(e.getBigUint64(8,!0)^t.getBigUint64(8,!0)-r)&ke)}function Og(e,t,r,n,i){let o=e&ke,a=e>>B(64)&ke;return o+=cD(t,n,i),o^=r.getBigUint64(0,!0)+r.getBigUint64(8,!0),o&=ke,a+=cD(r,Ge(n,16),i),a^=t.getBigUint64(0,!0)+t.getBigUint64(8,!0),a&=ke,a<<B(64)|o}function bi(e){let t=e;return t^=t>>B(37),t*=fZ,t&=ke,t^=t>>B(32),t}function Ng(e){let t=e;return t^=t>>B(33),t*=Os,t&=ke,t^=t>>B(29),t*=dD,t&=ke,t^=t>>B(32),t}function SZ(e,t,r){let n=e.byteLength;$u(n>0&&n<=3);let i=B(e.getUint8(n-1))|B(n<<8)|B(e.getUint8(0)<<16)|B(e.getUint8(n>>1)<<24),o=(i^(B(t.getUint32(0,!0))^B(t.getUint32(4,!0)))+r)&ke,a=(B(t.getUint32(8,!0))^B(t.getUint32(12,!0)))-r;return(Ng((vZ(_Z(i),B(13))^a)&ke)&ke)<<B(64)|Ng(o)}function Vk(e,t){return e^e>>t}function kZ(e,t,r){let n=e.byteLength;$u(n>=4&&n<=8);{let i=e.getUint32(0,!0),o=e.getUint32(n-4,!0),a=((B(i)|B(o)<<B(32))^(t.getBigUint64(16,!0)^t.getBigUint64(24,!0))+r&ke)*(ta+(B(n)<<B(2)))&Iu;return a+=(a&ke)<<B(65),a&=Iu,a^=a>>B(67),Vk(Vk(a&ke,B(35))*pZ&ke,B(28))|bi(a>>B(64))<<B(64)}}function EZ(e,t,r){let n=e.byteLength;$u(n>=9&&n<=16);{let i=(t.getBigUint64(32,!0)^t.getBigUint64(40,!0))+r&ke,o=(t.getBigUint64(48,!0)^t.getBigUint64(56,!0))-r&ke,a=e.getBigUint64(0,!0),s=e.getBigUint64(n-8,!0),c=(a^s^i)*ta,u=(c&ke)+(B(n-1)<<B(54));c=c&(Iu^ke)|u,s^=o,c+=s+(s&Pg)*(lD-B(1))<<B(64),c&=Iu,c^=gZ(c>>B(64));let l=(c&ke)*Os;return l+=(c>>B(64))*Os<<B(64),l&=Iu,bi(l&ke)|bi(l>>B(64))<<B(64)}}function IZ(e,t){let r=e.byteLength;return $u(r<=16),r>8?EZ(e,vi,t):r>=4?kZ(e,vi,t):r>0?SZ(e,vi,t):Ng(t^vi.getBigUint64(64,!0)^vi.getBigUint64(72,!0))|Ng(t^vi.getBigUint64(80,!0)^vi.getBigUint64(88,!0))<<B(64)}function Hk(e){return~e+B(1)&ke}function $Z(e,t,r){let n=B(e.byteLength)*ta&ke,i=B(e.byteLength-1)/B(32);for(;i>=0;){let s=Number(i);n=Og(n,Ge(e,16*s),Ge(e,e.byteLength-16*(s+1)),Ge(t,32*s),r),i-=B(1)}let o=n+(n>>B(64))&ke;o=bi(o);let a=(n&ke)*ta+(n>>B(64))*Zk+(B(e.byteLength)-r&ke)*Os;return a&=ke,a=Hk(bi(a)),o|a<<B(64)}function TZ(e,t,r){let n=B(e.byteLength)*ta&ke;for(let a=32;a<160;a+=32)n=Og(n,Ge(e,a-32),Ge(e,a-16),Ge(t,a-32),r);n=bi(n&ke)|bi(n>>B(64))<<B(64);for(let a=160;a<=e.byteLength;a+=32)n=Og(n,Ge(e,a-32),Ge(e,a-16),Ge(t,3+a-160),r);n=Og(n,Ge(e,e.byteLength-16),Ge(e,e.byteLength-32),Ge(t,103),Hk(r));let i=n+(n>>B(64))&ke;i=bi(i);let o=(n&ke)*ta+(n>>B(64))*Zk+(B(e.byteLength)-r&ke)*Os;return o&=ke,o=Hk(bi(o)),i|o<<B(64)}function wi(e,t=B(0)){let r=new TextEncoder,n=Ge(typeof e=="string"?r.encode(e):e),i=n.byteLength,o=a=>a.toString(16).padStart(32,"0");return i<=16?o(IZ(n,t)):i<=128?o($Z(n,vi,t)):i<=240?o(TZ(n,vi,t)):o(xZ(n,vi))}function Rg(e){return/^[0-9a-f]{32}$/.test(e)}function Gk(e){let t=Me.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 ga("No checkpointer set",{lc_error_code:"MISSING_CHECKPOINTER"});let n=r[ur];n.interruptCounter+=1;let i=n.interruptCounter;if(n.resume.length>0&&i<n.resume.length)return r[qt]?.([[lr,n.resume]]),n.resume[i];if(n.nullResume!==void 0){if(n.resume.length!==i)throw new Error(`Resume length mismatch: ${n.resume.length} !== ${i}`);let a=n.consumeNullResume();return n.resume.push(a),r[qt]?.([[lr,n.resume]]),a}let o=r[Ur]?.split("|");throw new Si([{id:o?wi(o.join("|")):void 0,value:e}])}var Lt=class extends ce{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((n,i)=>{let o=Ae(t,{callbacks:r?.getChild()});Me.runWithConfig(o,async()=>{try{n(await this.func(e,o))}catch(a){i(a)}})})}async invoke(e,t){let r,n=Su(t),i=Ct(this.config,n);return this.trace?r=await this._callWithConfig(this._tracedInvoke,e,i):r=await Me.runWithConfig(i,async()=>this.func(e,i)),ce.isRunnable(r)&&this.recurse?await Me.runWithConfig(i,async()=>r.invoke(e,i)):r}};function*xi(e,t){if(t===void 0)yield*e;else for(let r of e)yield[t,r]}async function jn(e){let t=[];for await(let r of await e)t.push(r);return t}function ra(e){let t=[];for(let r of e)t.push(r);return t}function Ps(e,t){return e?"configurable"in e?{...e,configurable:{...e.configurable,...t}}:{...e,configurable:t}:{configurable:t}}function Wk(e){return e!=null&&typeof e=="function"&&e instanceof Object.getPrototypeOf(async function*(){}).constructor}function qk(e){return e!=null&&typeof e=="function"&&e instanceof Object.getPrototypeOf(function*(){}).constructor}function AZ(e){return typeof e=="object"&&e?.[Symbol.for("LG_SKIP_WRITE")]!==void 0}var Dr={[Symbol.for("LG_PASSTHROUGH")]:!0};function jg(e){return typeof e=="object"&&e?.[Symbol.for("LG_PASSTHROUGH")]!==void 0}var Kk=Symbol("IS_WRITER"),ht=class Xk extends Lt{writes;constructor(t,r){let n=`ChannelWrite<${t.map(i=>Et(i)?i.node:"channel"in i?i.channel:"...").join(",")}>`;super({writes:t,name:n,tags:r,trace:!1,func:async(i,o)=>this._write(i,o??{})}),this.writes=t}async _write(t,r){let n=this.writes.map(i=>Jk(i)&&jg(i.value)?{mapper:i.mapper,value:t}:Mg(i)&&jg(i.value)?{channel:i.channel,value:t,skipNone:i.skipNone,mapper:i.mapper}:i);return await Xk.doWrite(r,n),t}static async doWrite(t,r){for(let o of r){if(Mg(o)){if(o.channel==="__pregel_tasks")throw new we("Cannot write to the reserved channel TASKS");if(jg(o.value))throw new we("PASSTHROUGH value must be replaced")}if(Jk(o)&&jg(o.value))throw new we("PASSTHROUGH value must be replaced")}let n=[];for(let o of r)if(Et(o))n.push([Zn,o]);else if(Jk(o)){let a=await o.mapper.invoke(o.value,t);a!=null&&a.length>0&&n.push(...a)}else if(Mg(o)){let a=o.mapper!==void 0?await o.mapper.invoke(o.value,t):o.value;if(AZ(a)||o.skipNone&&a===void 0)continue;n.push([o.channel,a])}else throw new Error(`Invalid write entry: ${JSON.stringify(o)}`);let i=t.configurable?.[qt];i(n)}static isWriter(t){return t instanceof Xk||Kk in t&&!!t[Kk]}static registerWriter(t){return Object.defineProperty(t,Kk,{value:!0})}};function Mg(e){return e!==void 0&&typeof e.channel=="string"}function Jk(e){return e!==void 0&&!Mg(e)&&ce.isRunnable(e.mapper)}var hD=class gD extends Lt{lc_graph_name="ChannelRead";channel;fresh=!1;mapper;constructor(t,r,n=!1){super({trace:!1,func:(i,o)=>gD.doRead(o,this.channel,this.fresh,this.mapper)}),this.fresh=n,this.mapper=r,this.channel=t,this.name=Array.isArray(t)?`ChannelRead<${t.join(",")}>`:`ChannelRead<${t}>`}static doRead(t,r,n,i){let o=t.configurable?.[cr];if(!o)throw new Error("Runnable is not configured with a read function. Make sure to call in the context of a Pregel process");return i?i(o(r,n)):o(r,n)}},Tu=new Zi,Mn=class jd extends ln{lc_graph_name="PregelNode";channels;triggers=[];mapper;writers=[];bound=Tu;kwargs={};metadata={};tags=[];retryPolicy;cachePolicy;timeout;subgraphs;ends;isErrorHandler;errorHandlerNode;constructor(t){let{channels:r,triggers:n,mapper:i,writers:o,bound:a,kwargs:s,metadata:c,retryPolicy:u,cachePolicy:l,timeout:d,tags:f,subgraphs:p,ends:m,isErrorHandler:h,errorHandlerNode:_}=t,y=[...t.config?.tags?t.config.tags:[],...f??[]];super({...t,bound:t.bound??Tu,config:{...t.config?t.config:{},tags:y}}),this.channels=r,this.triggers=n,this.mapper=i,this.writers=o??this.writers,this.bound=a??this.bound,this.kwargs=s??this.kwargs,this.metadata=c??this.metadata,this.tags=y,this.retryPolicy=u,this.cachePolicy=l,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 ht&&t[t.length-2]instanceof ht;){let r=t.slice(-2),n=r[0].writes.concat(r[1].writes);t[t.length-2]=new ht(n,r[0].config?.tags),t.pop()}return t}getNode(){let t=this.getWriters();if(!(this.bound===Tu&&t.length===0))return this.bound===Tu&&t.length===1?t[0]:this.bound===Tu?new Jr({first:t[0],middle:t.slice(1,t.length-1),last:t[t.length-1],omitSequenceTags:!0}):t.length>0?new Jr({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 jd({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 ht.isWriter(t)?new jd({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===Tu?new jd({channels:this.channels,triggers:this.triggers,mapper:this.mapper,writers:this.writers,bound:lt(t),config:this.config,kwargs:this.kwargs,retryPolicy:this.retryPolicy,cachePolicy:this.cachePolicy,timeout:this.timeout}):new jd({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 CZ(e){return"steps"in e&&Array.isArray(e.steps)}function Md(e){return"lg_is_pregel"in e&&e.lg_is_pregel===!0}function Dg(e){let t=[e];for(let r of t){if(Md(r))return r;CZ(r)&&t.push(...r.steps)}}function Ns(e,t,r=!0,n=!1){try{return e[t].get()}catch(i){if(i.name===Ue.unminifiable_name){if(n)return i;if(r)return null}throw i}}function Dn(e,t,r=!0){if(Array.isArray(t)){let n={};for(let i of t)try{n[i]=Ns(e,i,!r)}catch(o){if(o.name===Ue.unminifiable_name)continue}return n}else return Ns(e,t)}function*_D(e,t){if(e.graph===Ir.PARENT)throw new we("There is no parent graph.");if(e.goto){let r;Array.isArray(e.goto)?r=e.goto:r=[e.goto];for(let n of r)if(Et(n))yield[fr,Zn,n];else if(typeof n=="string")yield[fr,`branch:to:${n}`,"__start__"];else throw new Error(`In Command.send, expected Send or string, got ${typeof n}`)}if(e.resume)if(typeof e.resume=="object"&&Object.keys(e.resume).length&&Object.keys(e.resume).every(Rg))for(let[r,n]of Object.entries(e.resume)){let i=t.filter(o=>o[0]===r&&o[1]==="__resume__").map(o=>o[2]).slice(0,1)??[];i.push(n),yield[r,lr,i]}else yield[fr,lr,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,n]of e.update)yield[fr,r,n];else for(let[r,n]of Object.entries(e.update))yield[fr,r,n]}}function*zg(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*Ug(e,t,r){Array.isArray(e)?(t===!0||t.find(([n,i])=>e.includes(n)))&&(yield Dn(r,e)):(t===!0||t.some(([n,i])=>n===e))&&(yield Ns(r,e))}function*yD(e,t,r){let n=t.filter(([s,c])=>(s.config===void 0||!s.config.tags?.includes("langsmith:hidden"))&&c[0][0]!=="__error__"&&c[0][0]!=="__interrupt__");if(!n.length)return;let i;n.some(([s])=>s.writes.some(([c,u])=>c==="__return__"))?i=n.flatMap(([s])=>s.writes.filter(([c,u])=>c===uo).map(([c,u])=>[s.name,u])):Array.isArray(e)?i=n.flatMap(([s])=>{let{writes:c}=s,u={};for(let[l]of c)e.includes(l)&&(u[l]=(u[l]||0)+1);return Object.values(u).some(l=>l>1)?c.filter(([l])=>e.includes(l)).map(([l,d])=>[s.name,{[l]:d}]):[[s.name,Object.fromEntries(c.filter(([l])=>e.includes(l)))]]}):i=n.flatMap(([s])=>s.writes.filter(([c,u])=>c===e).map(([c,u])=>[s.name,u]));let o={};for(let[s,c]of i)s in o||(o[s]=[]),o[s].push(c);let a={};for(let s in o)if(o[s].length===1){let[c]=o[s];a[s]=c}else a[s]=o[s];r&&(a.__metadata__={cached:r}),yield a}function Lg(e){let t=typeof e[Ye];if(t==="number")return 0;if(t==="string")return"";for(let r in e){if(!Object.prototype.hasOwnProperty.call(e,r))continue;let n=typeof e[r];if(n==="number")return 0;if(n==="string")return"";break}}function Au(e,t){if(Object.keys(e).length>0){let r=Lg(t);return Object.fromEntries(Object.entries(t).filter(([n,i])=>i>(e[n]??r)))}else return t}function vD(e,t){return e&&!Array.isArray(e)&&!(e instanceof Date)&&typeof e=="object"?e:{[t]:e}}function Pt(e,t){return e===null?{configurable:t}:e?.configurable===void 0?{...e,configurable:t}:{...e,configurable:{...e.configurable,...t}}}function na(e,t){let r=t?.parents??{};return Object.keys(r).length>0?Pt(e,{[Kt]:{...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,n=()=>{let o=t.find(a=>a.aborted)?.reason;r.abort(o),t.forEach(a=>a.removeEventListener("abort",n))};t.forEach(o=>o.addEventListener("abort",n,{once:!0}));let i=t.find(o=>o.aborted);return i&&r.abort(i.reason),{signal:r.signal,dispose:()=>{t.forEach(o=>o.removeEventListener("abort",n))}}}var bD=class{func;name;input;retry;cache;timeout;callbacks;__lg_type="call";constructor({func:e,name:t,input:r,retry:n,cache:i,timeout:o,callbacks:a}){this.func=e,this.name=t,this.input=r,this.retry=n,this.cache=i,this.timeout=o,this.callbacks=a}};function wD(e){return typeof e=="object"&&e!==null&&"__lg_type"in e&&e.__lg_type==="call"}function xD(e,t){return new Jr({name:e,first:new Lt({func:r=>t(...r),name:e,trace:!1,recurse:!1}),last:new ht([{channel:uo,value:Dr}],[vt])})}function SD(e,t){return new Lt({func:(r,n)=>t(r,n),name:e,trace:!1,recurse:!1})}function kD({func:e,name:t,cache:r,retry:n,timeout:i},...o){let a=Me.getRunnableConfig();if(typeof a.configurable?.__pregel_call=="function")return a.configurable[Hn](e,t,o,{retry:n,cache:r,timeout:i,callbacks:a.callbacks});throw new Error("Async local storage not initialized. Please call initializeAsyncLocalStorageSingleton() before using this function.")}var ED=e=>e!==void 0?e+1:1;function OZ(e,t){if(t==null)return!1;for(let r of e)if(t[r])return!0;return!1}function PZ(e){let t;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t==null?t=e[r]:t=Ad(t,e[r]));return t}function Dd(e,t,r){let n=Lg(e.channel_versions),i=e.versions_seen.__interrupt__??{},o=!1;if((e.channel_versions.__start__??n)>(i.__start__??n))o=!0;else for(let s in e.channel_versions)if(Object.prototype.hasOwnProperty.call(e.channel_versions,s)&&e.channel_versions[s]>(i[s]??n)){o=!0;break}let a=r.some(s=>t==="*"?!s.config?.tags?.includes(vt):t.includes(s.name));return o&&a}function Cu(e,t,r,n,i=!1){let o=new Set;if(Array.isArray(n))o=new Set(n.filter(s=>r.writes.some(([c,u])=>c===s)));else{for(let[s]of r.writes)if(s===n){o=new Set([s]);break}o=o||new Set}let a;if(i&&o.size>0){let s=Object.fromEntries(Object.entries(t).filter(([d,f])=>o.has(d))),c=new Set;for(let d in s){if(!Object.prototype.hasOwnProperty.call(s,d))continue;let f=s[d];mn(f)&&f.isAvailable()&&c.add(d)}let u=Nn(e,s,-1,{channelsToSnapshot:c}),l=bg(s,u);kr(Pn(u),l,[r],void 0,void 0),a=Dn({...t,...l},n)}else a=Dn(t,n);return a}function Fg(e,t,r){for(let[n,i]of r)if(["__pregel_push","__pregel_tasks"].includes(n)&&i!=null){if(!Et(i))throw new we(`Invalid packet type, expected SendProtocol, got ${JSON.stringify(i)}`);if(!(i.node in t))throw new we(`Invalid node name "${i.node}" in Send packet`)}e(r)}var NZ=new Set([Mu,dr,lr,Ve,uo,ao,Nu]),RZ=new Set(EE);function kr(e,t,r,n,i){let o=new Map;for(let m of r)o.set(m,m.path?.slice(0,3)||[]);r.sort((m,h)=>{let _=o.get(m),y=o.get(h);for(let w=0;w<Math.min(_.length,y.length);w+=1){if(_[w]<y[w])return-1;if(_[w]>y[w])return 1}return _.length-y.length});let a=wu(t),s=!1,c=new Set;for(let m of r){m.triggers.length>0&&(s=!0),e.versions_seen[m.name]??={};for(let h of m.triggers)h in e.channel_versions&&(e.versions_seen[m.name][h]=e.channel_versions[h]),RZ.has(h)||c.add(h)}let u=PZ(e.channel_versions),l=!1;for(let m of c)m in a&&a[m].consume()&&n!==void 0&&(e.channel_versions[m]=n(u),l=!0);let d={},f={};for(let m of r){let h=m.id??"";for(let[_,y]of m.writes)NZ.has(_)||_ in a&&(d[_]??=[],d[_].push(y),f[_]??=[],f[_].push(h))}for(let[m,h]of Object.entries(d)){if(h.length<2||a[m]?.lc_graph_name!=="DeltaChannel")continue;let _=f[m],y=h.map((w,x)=>({val:w,taskId:_[x]}));y.sort((w,x)=>w.taskId<x.taskId?-1:w.taskId>x.taskId?1:0),d[m]=y.map(w=>w.val)}u!=null&&n!=null&&(u=l?n(u):u);let p=new Set;for(let[m,h]of Object.entries(d))if(m in a){let _=a[m],y;try{y=_.update(h)}catch(w){if(w.name===we.unminifiable_name){let x=new we(`Invalid update for channel "${m}" with values ${JSON.stringify(h)}: ${w.message}`);throw x.lc_error_code=w.lc_error_code,x}else throw w}y&&n!==void 0&&(e.channel_versions[m]=n(u),_.isAvailable()&&p.add(m))}if(s)for(let m in a){if(!Object.prototype.hasOwnProperty.call(a,m))continue;let h=a[m];h.isAvailable()&&!p.has(m)&&h.update([])&&n!==void 0&&(e.channel_versions[m]=n(u),h.isAvailable()&&p.add(m))}if(s&&!OZ(p,i))for(let m in a){if(!Object.prototype.hasOwnProperty.call(a,m))continue;let h=a[m];h.finish()&&n!==void 0&&(e.channel_versions[m]=n(u),h.isAvailable()&&p.add(m))}return p}function*jZ(e,t,r){if(r.updatedChannels!=null&&r.triggerToNodes!=null){let n=new Set;for(let i of r.updatedChannels){let o=r.triggerToNodes[i];for(let a of o??[])n.add(a)}yield*[...n].sort();return}if(!(()=>{for(let n in e.channel_versions)if(e.channel_versions[n]!==null)return!1;return!0})())for(let n in t)Object.prototype.hasOwnProperty.call(t,n)&&(yield n)}function MZ(e){let t,r=new Map,n=new Set;if(e)for(let[i,o,a]of e){if(i==="00000000-0000-0000-0000-000000000000"&&o==="__resume__"&&t===void 0&&(t=a),o==="__resume__"&&i!=="00000000-0000-0000-0000-000000000000"){let s=r.get(i);s||(s=[],r.set(i,s)),s.push(a)}o!=="__error__"&&n.add(i)}return{nullResume:t,resumeByTaskId:r,successfulWriteTaskIds:n}}function oa(e,t,r,n,i,o,a){let s={},c=a.pendingWritesIndex?a:{...a,pendingWritesIndex:MZ(t)},u=n[Zn];if(u?.isAvailable()){let l=u.get().length;for(let d=0;d<l;d+=1){let f=Vg([dr,d],e,t,r,n,i,o,c);f!==void 0&&(s[f.id]=f)}}for(let l of jZ(e,r,c)){let d=Vg([Gd,l],e,t,r,n,i,o,c);d!==void 0&&(s[d.id]=d)}return s}function Vg(e,t,r,n,i,o,a,s){let{step:c,checkpointer:u,manager:l}=s,d=o.configurable??{},f=d.checkpoint_ns??"";if(e[0]==="__pregel_push"&&wD(e[e.length-1])){let p=e[e.length-1],m=xD(p.name,p.func),h=[dr],_=f===""?p.name:`${f}|${p.name}`,y=Gn(JSON.stringify([_,c.toString(),p.name,dr,e[1],e[2]]),t.id),w=`${_}:${y}`,x=[...e.slice(0,3),!0],S={langgraph_step:c,langgraph_node:p.name,langgraph_triggers:h,langgraph_path:x,langgraph_checkpoint_ns:w,checkpoint_ns:w};if(a){let E=[],C={checkpointId:t.id,checkpointNs:w,taskId:y,threadId:d.thread_id,runId:o.runId!=null?String(o.runId):void 0,nodeAttempt:1};return{name:p.name,input:p.input,proc:m,writes:E,config:{...Ae(Ct(o,{metadata:S,store:s.store??o.store}),{runName:p.name,callbacks:l?.getChild(`graph:step:${c}`),configurable:{[Ds]:y,[qt]:T=>Fg(b=>E.push(...b),n,T),[cr]:(T,b=!1)=>Cu(t,i,{name:p.name,writes:E,triggers:h,path:x},T,b),[Qr]:u??d.__pregel_checkpointer,[Kt]:{...d[Kt],[f]:t.id},[ur]:Bg({pendingWrites:r??[],taskId:y,currentTaskInput:p.input,resumeMap:o.configurable?.[pa],namespaceHash:wi(w),pendingWritesIndex:s.pendingWritesIndex}),[so]:t.channel_values[lo],checkpoint_id:void 0,checkpoint_ns:w}}),executionInfo:C},triggers:h,retry_policy:p.retry,cache_key:p.cache?{key:wi((p.cache.keyFunc??JSON.stringify)([p.input])),ns:[Hd,p.name??"__dynamic__"],ttl:p.cache.ttl}:void 0,id:y,path:x,writers:[],timeout:p.timeout}}else return{id:y,name:p.name,interrupts:[],path:x}}else if(e[0]==="__pregel_push"){let p=typeof e[1]=="number"?e[1]:parseInt(e[1],10);if(!i.__pregel_tasks?.isAvailable())return;let m=i[Zn].get();if(p<0||p>=m.length)return;let h=Wd(m[p])&&!Et(m[p])?new da(m[p].node,m[p].args,m[p].timeout!==void 0?{timeout:m[p].timeout}:void 0):m[p];if(!Wd(h)){console.warn(`Ignoring invalid packet ${JSON.stringify(h)} in pending sends.`);return}if(!(h.node in n)){console.warn(`Ignoring unknown node name ${h.node} in pending sends.`);return}let _=[dr],y=f===""?h.node:`${f}|${h.node}`,w=Gn(JSON.stringify([y,c.toString(),h.node,dr,p.toString()]),t.id),x=`${y}:${w}`,S={langgraph_step:c,langgraph_node:h.node,langgraph_triggers:_,langgraph_path:e.slice(0,3),langgraph_checkpoint_ns:x,checkpoint_ns:x};if(a){let E=n[h.node],C=E.getNode();if(C!==void 0){E.metadata!==void 0&&(S={...S,...E.metadata});let T=[],b={checkpointId:t.id,checkpointNs:x,taskId:w,threadId:d.thread_id,runId:o.runId!=null?String(o.runId):void 0,nodeAttempt:1};return{name:h.node,input:h.args,proc:C,subgraphs:E.subgraphs,writes:T,config:{...Ae(Ct(o,{metadata:S,tags:E.tags,store:s.store??o.store}),{runName:h.node,callbacks:l?.getChild(`graph:step:${c}`),configurable:{[Ds]:w,[qt]:L=>Fg(N=>T.push(...N),n,L),[cr]:(L,N=!1)=>Cu(t,i,{name:h.node,writes:T,triggers:_,path:e},L,N),[Qr]:u??d.__pregel_checkpointer,[Kt]:{...d[Kt],[f]:t.id},[ur]:Bg({pendingWrites:r??[],taskId:w,currentTaskInput:h.args,resumeMap:o.configurable?.[pa],namespaceHash:wi(x),pendingWritesIndex:s.pendingWritesIndex}),[so]:t.channel_values[lo],checkpoint_id:void 0,checkpoint_ns:x}}),executionInfo:b},triggers:_,retry_policy:E.retryPolicy,cache_key:E.cachePolicy?{key:wi((E.cachePolicy.keyFunc??JSON.stringify)([h.args])),ns:[Hd,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=n[p];if(m===void 0)return;if(r?.length){let w=f===""?p:`${f}|${p}`,x=Gn(JSON.stringify([w,c.toString(),p,Gd,p]),t.id);if(s.pendingWritesIndex?s.pendingWritesIndex.successfulWriteTaskIds.has(x):r.some(S=>S[0]===x&&S[1]!=="__error__"))return}let h=Lg(t.channel_versions);if(h===void 0)return;let _=t.versions_seen[p]??{},y=m.triggers.find(w=>i[w].isAvailable()?(t.channel_versions[w]??h)>(_[w]??h):!1);if(y!==void 0){let w=DZ(m,i,a);if(w===void 0)return;let x=f===""?p:`${f}|${p}`,S=Gn(JSON.stringify([x,c.toString(),p,Gd,[y]]),t.id),E=`${x}:${S}`,C={langgraph_step:c,langgraph_node:p,langgraph_triggers:[y],langgraph_path:e,langgraph_checkpoint_ns:E,checkpoint_ns:E};if(a){let T=m.getNode();if(T!==void 0){m.metadata!==void 0&&(C={...C,...m.metadata});let b=[],L={checkpointId:t.id,checkpointNs:E,taskId:S,threadId:d.thread_id,runId:o.runId!=null?String(o.runId):void 0,nodeAttempt:1};return{name:p,input:w,proc:T,subgraphs:m.subgraphs,writes:b,config:{...Ae(Ct(o,{metadata:C,tags:m.tags,store:s.store??o.store}),{runName:p,callbacks:l?.getChild(`graph:step:${c}`),configurable:{[Ds]:S,[qt]:N=>Fg(W=>{b.push(...W)},n,N),[cr]:(N,W=!1)=>Cu(t,i,{name:p,writes:b,triggers:[y],path:e},N,W),[Qr]:u??d.__pregel_checkpointer,[Kt]:{...d[Kt],[f]:t.id},[ur]:Bg({pendingWrites:r??[],taskId:S,currentTaskInput:w,resumeMap:o.configurable?.[pa],namespaceHash:wi(E),pendingWritesIndex:s.pendingWritesIndex}),[so]:t.channel_values[lo],checkpoint_id:void 0,checkpoint_ns:E}}),executionInfo:L},triggers:[y],retry_policy:m.retryPolicy,cache_key:m.cachePolicy?{key:wi((m.cachePolicy.keyFunc??JSON.stringify)([w])),ns:[Hd,m.name??"__dynamic__",p],ttl:m.cachePolicy.ttl}:void 0,id:S,path:e,writers:m.getWriters(),timeout:m.timeout}}}else return{id:S,name:p,interrupts:[],path:e}}}}function ID(e,t,r,n,i,o,a,s,c){let{step:u,checkpointer:l,manager:d}=c,f=o[t];if(f===void 0)return;let p=f.getNode();if(p===void 0)return;let m=s.configurable??{},h=m.checkpoint_ns??"",_=[dr],y=h===""?t:`${h}|${t}`,w=Gn(JSON.stringify([y,u.toString(),t,dr,"node_error_handler",e.id]),n.id),x=`${y}:${w}`,S=[dr,String(e.name),t,!1],E={langgraph_step:u,langgraph_node:t,langgraph_triggers:_,langgraph_path:S,langgraph_checkpoint_ns:x,checkpoint_ns:x};f.metadata!==void 0&&(E={...E,...f.metadata});let C=[],T={checkpointId:n.id,checkpointNs:x,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:C,config:{...Ae(Ct(s,{metadata:E,tags:f.tags,store:c.store??s.store}),{runName:t,callbacks:d?.getChild(`graph:step:${u}`),configurable:{[Ds]:w,[qt]:b=>Fg(L=>C.push(...L),o,b),[cr]:(b,L=!1)=>Cu(n,a,{name:t,writes:C,triggers:_,path:S},b,L),[Qr]:l??m.__pregel_checkpointer,[Kt]:{...m[Kt],[h]:n.id},[ur]:Bg({pendingWrites:i??[],taskId:w,currentTaskInput:e.input,resumeMap:s.configurable?.[pa],namespaceHash:wi(x)}),[so]:n.channel_values[lo],[ju]:new Yd(String(e.name),r),checkpoint_id:void 0,checkpoint_ns:x}}),executionInfo:T},triggers:_,retry_policy:f.retryPolicy,cache_key:void 0,id:w,path:S,writers:f.getWriters()}}function DZ(e,t,r){let n;if(typeof e.channels=="object"&&!Array.isArray(e.channels)){n={};for(let[i,o]of Object.entries(e.channels))if(e.triggers.includes(o))try{n[i]=Ns(t,o,!1)}catch(a){if(a.name===Ue.unminifiable_name)return;throw a}else if(o in t)try{n[i]=Ns(t,o,!1)}catch(a){if(a.name===Ue.unminifiable_name)continue;throw a}}else if(Array.isArray(e.channels)){let i=!1;for(let o of e.channels)try{n=Ns(t,o,!1),i=!0;break}catch(a){if(a.name===Ue.unminifiable_name)continue;throw a}if(!i)return}else throw new Error(`Invalid channels type, expected list or dict, got ${e.channels}`);return r&&e.mapper!==void 0&&(n=e.mapper(n)),n}function $D(e,t){if(typeof e.args!="object"||e.args===null)return e;let r={};for(let[n,i]of Object.entries(e.args)){let o=t[n];(!o||o.lc_graph_name!=="UntrackedValue")&&(r[n]=i)}return new da(e.node,r)}function Bg({pendingWrites:e,taskId:t,currentTaskInput:r,resumeMap:n,namespaceHash:i,pendingWritesIndex:o}){let a=o?o.nullResume:e.find(([c,u])=>c==="00000000-0000-0000-0000-000000000000"&&u==="__resume__")?.[2],s={callCounter:0,interruptCounter:-1,resume:(()=>{let c=o?(o.resumeByTaskId.get(t)??[]).flat():e.filter(([u,l])=>u===t&&l==="__resume__").flatMap(([u,l,d])=>d);if(n!=null&&i in n){let u=n[i];c.push(u)}return c})(),nullResume:a,subgraphCounter:0,currentTaskInput:r,consumeNullResume:()=>{if(s.nullResume)return delete s.nullResume,e.splice(e.findIndex(([c,u])=>c==="00000000-0000-0000-0000-000000000000"&&u==="__resume__"),1),a}};return s}var zd={blue:{start:"\x1B[34m",end:"\x1B[0m"},green:{start:"\x1B[32m",end:"\x1B[0m"},yellow:{start:"\x1B[33;1m",end:"\x1B[0m"}},Ud=(e,t)=>`${e.start}${t}${e.end}`;function zZ(e){if(e==null)return;let t={};if(e.metadata!=null)for(let[n,i]of Object.entries(e.metadata))Ek.has(n)||(t[n]=i);let r=XM(e.tags);return r!=null&&(t.tags=r),Object.keys(t).length>0?t:void 0}function*Hg(e){for(let{id:t,name:r,input:n,config:i,triggers:o,writes:a}of e){if(i?.tags?.includes("langsmith:hidden"))continue;let s={id:t,name:r,input:n,triggers:o,interrupts:a.filter(([u,l])=>u===t&&l==="__interrupt__").map(([,u])=>u)},c=zZ(i);c!=null&&(s.metadata=c),yield s}}function UZ(e){return typeof e!="object"||e===null?!1:"$writes"in e&&Array.isArray(e.$writes)}function TD(e){let t={};for(let[r,n]of e){let i=String(r);if(i in t){let o=UZ(t[i])?t[i].$writes:[t[i]];o.push(n),t[i]={$writes:o}}else t[i]=n}return t}function*AD(e,t){for(let[{id:r,name:n,config:i},o]of e)i?.tags?.includes("langsmith:hidden")||(yield{id:r,name:n,result:TD(o.filter(([a])=>Array.isArray(t)?t.includes(a):a===t)),interrupts:o.filter(a=>a[0]===Ve).map(a=>a[1])})}function*CD(e,t,r,n,i,o,a,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 u=e.configurable?.checkpoint_ns,l={};for(let d of i){if(!(d.subgraphs?.length?d.subgraphs:[d.proc]).find(Dg))continue;let f=`${d.name}:${d.id}`;u&&(f=`${u}|${f}`),l[d.id]={configurable:{thread_id:e.configurable?.thread_id,checkpoint_ns:f}}}yield{config:c(e),values:Dn(t,r),metadata:n,next:i.map(d=>d.name),tasks:Yk(i,o,l,s),parentConfig:a?c(a):void 0}}function Yk(e,t,r,n){return e.map(i=>{let o=t.find(([u,l])=>u===i.id&&l==="__error__")?.[2],a=t.filter(([u,l])=>u===i.id&&l==="__interrupt__").map(([,,u])=>u),s=(()=>{if(o||a.length||!t.length)return;let u=t.findIndex(([l,d])=>l===i.id&&d==="__return__");if(u>=0)return t[u][2];if(typeof n=="string")return t.find(([l,d])=>l===i.id&&d===n)?.[2];if(Array.isArray(n)){let l=t.filter(([d,f])=>d===i.id&&n.includes(f)).map(([,d,f])=>[d,f]);return l.length?TD(l):void 0}})();if(o)return{id:i.id,name:i.name,path:i.path,error:o,interrupts:a,result:s};let c=r?.[i.id];return{id:i.id,name:i.name,path:i.path,interrupts:a,...c!==void 0?{state:c}:{},result:s}})}function OD(e,t,r){console.log([`${Ud(zd.blue,`[${e}:checkpoint]`)}`,`\x1B[1m State at the end of step ${e}:\x1B[0m
444
- `,JSON.stringify(Dn(t,r),null,2)].join(""))}function Ld(e,t){let r=t.length;console.log([`${Ud(zd.blue,`[${e}:tasks]`)}`,`\x1B[1m Starting step ${e} with ${r} task${r===1?"":"s"}:\x1B[0m
445
- `,t.map(n=>`- ${Ud(zd.green,String(n.name))} -> ${JSON.stringify(n.input,null,2)}`).join(`
446
- `)].join(""))}function PD(e,t,r){let n={};for(let[i,o]of t)r.includes(i)&&(n[i]||(n[i]=[]),n[i].push(o));console.log([`${Ud(zd.blue,`[${e}:writes]`)}`,`\x1B[1m Finished step ${e} with writes to ${Object.keys(n).length} channel${Object.keys(n).length!==1?"s":""}:\x1B[0m
447
- `,Object.entries(n).map(([i,o])=>`- ${Ud(zd.yellow,i)} -> ${o.map(a=>JSON.stringify(a)).join(", ")}`).join(`
448
- `)].join(""))}var Zg=class extends bt{_abortController;_innerReader;constructor(e,t){let r=e.getReader(),n=t??new AbortController;super({start(i){return o();function o(){return r.read().then(({done:a,value:s})=>{if(a){i.close();return}return i.enqueue(s),o()})}}}),this._abortController=n,this._innerReader=r}async cancel(e){this._abortController.abort(e),this._innerReader.releaseLock()}get signal(){return this._abortController.signal}},eE=class extends bt{modes;controller;passthroughFn;_closed=!1;get closed(){return this._closed}constructor(e){let t,r=new Promise(n=>{t=n});super({start:n=>{t(n)}}),r.then(n=>{this.controller=n}),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}}},jD=class extends hr{name="StreamToolsHandler";awaitHandlers=!0;streamFn;runs={};constructor(e){super(),this.streamFn=e}handleToolStart(e,t,r,n,i,o,a,s){if(!o||i&&i.includes("langsmith:hidden"))return;let c=o.langgraph_checkpoint_ns?.split("|")??[],u={ns:c,toolCallId:s,toolName:a??"unknown",input:t};this.runs[r]=u,this.streamFn([c,"tools",{event:"on_tool_start",toolCallId:u.toolCallId,name:u.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 LZ(e){return JSON.stringify(e,function(t,r){let n=this[t];if(n!=null&&typeof n=="object"&&"toDict"in n&&typeof n.toDict=="function"){let{type:i,data:o}=n.toDict();return{...o,type:i}}return r})}function FZ(e){return e instanceof Error?{error:e.name,message:e.message}:{error:"Error",message:JSON.stringify(e)}}function tE(e){return typeof e!="object"||e==null?!1:"configurable"in e&&typeof e.configurable=="object"&&e.configurable!=null}function Qk(e){return!tE(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 ND(e){if(tE(e)){let t=Object.fromEntries(Object.entries(e.configurable).filter(([n])=>!n.startsWith("__"))),r={...e,configurable:t};return delete r.callbacks,r}return e}function RD(e){let t={...e,checkpoint:Qk(e.config),parent_checkpoint:Qk(e.parentConfig),config:ND(e.config),parent_config:ND(e.parentConfig),tasks:e.tasks.map(r=>{if(tE(r.state)){let n=Qk(r.state);if(n!=null){let i={...r,checkpoint:n};return delete i.state,i}}return r})};return delete t.parentConfig,t}function MD(e){let t=new TextEncoder;return new ReadableStream({async start(r){let n=i=>{r.enqueue(t.encode(`event: ${i.event}
449
- data: ${LZ(i.data)}
450
-
451
- `))};try{for await(let i of e){let[o,a,s]=i,c=s;if(a==="debug"){let u=s;u.type==="checkpoint"&&(c={...u,payload:RD(u.payload)})}a==="checkpoints"&&(c=RD(s)),n({event:o?.length?`${a}|${o.join("|")}`:a,data:c})}}catch(i){n({event:"error",data:FZ(i)})}r.close()}})}function DD(...e){return new eE({passthroughFn:t=>{let r=t[1]==="checkpoints"&&ku(t[2]);for(let n of e)(n.modes.has(t[1])||r)&&n.push(t)},modes:new Set(e.flatMap(t=>Array.from(t.modes)))})}var zD=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 n=[];for await(let i of t.list(r,{before:{configurable:{checkpoint_id:this.checkpointId}},limit:1}))n.push(i);return n.length>0?n[0]:void 0}return await t.getTuple(r)??void 0}};var Gg=Symbol.for("INPUT_DONE"),rE=Symbol.for("INPUT_RESUMING"),BZ=25;function UD(e){if(!(e==null||typeof e!="object")){if(Re.isInstance(e)){let t=e;t.id==null&&(t.id=ho(),t.lc_kwargs!=null&&(t.lc_kwargs.id=t.id));return}if(Array.isArray(e)){for(let t of e)UD(t);return}}}function LD(e){return e===void 0||e===""?[]:e.split("|")}function VZ(e){if(!e)return[];let t="";for(let r of Object.keys(e))r!==""&&r.length>t.length&&(t=r);return LD(t)}var HZ=class extends vg{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}},FD=class BD{input;output;config;checkpointer;checkpointerGetNextVersion;channels;checkpoint;checkpointIdSaved;_exitDeltaWrites;_deltaChannelsWithOverwrite=new Set;_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(n=>(this.checkpointerPromises.delete(r),n),n=>{throw n});this.checkpointerPromises.add(r)}async _awaitCheckpointerPromises(){await Promise.all([...this.checkpointerPromises])}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,n=this.input===null||this.input===void 0,i=Rt(this.input)&&this.input.resume!=null,o=this.input===rE,a=!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||n||i||o||a)}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=ED,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 HZ(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:n}=t;n!==void 0&&r.configurable?.__pregel_stream!==void 0&&(n=DD(n,r.configurable[Ru]));let i=r.configurable?!("checkpoint_id"in r.configurable):!0,o=r.configurable?.[ur];r.configurable&&o&&(o.subgraphCounter>0&&(r=Pt(r,{[Ur]:[r.configurable[Ur],o.subgraphCounter.toString()].join("|")})),o.subgraphCounter+=1);let a=r.configurable?.checkpoint_id,s=cr in(r.configurable??{});!s&&r.configurable?.checkpoint_ns!==void 0&&r.configurable?.checkpoint_ns!==""&&(r=Pt(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=Pt(r,{checkpoint_id:r.configurable[Kt][r.configurable?.checkpoint_ns]}));let u=LD(r.configurable?.checkpoint_ns),l;t.checkpointer?c.configurable?.checkpoint_id?l=await t.checkpointer.getTuple(c):r.configurable?.__pregel_replay_state?(l=await r.configurable[Zd].getCheckpoint(r.configurable?.checkpoint_ns??"",t.checkpointer,c),r.configurable&&delete r.configurable[fa]):l=await t.checkpointer.getTuple(c):l=void 0;let d=l!==void 0;l||(l={config:r,checkpoint:Cs(),metadata:{source:"input",step:-2,parents:{}},pendingWrites:[]}),c={...r,...l.config,configurable:{checkpoint_ns:"",...r.configurable,...l.config.configurable}};let f=l.parentConfig,p=Pn(l.checkpoint),m={...l.metadata},h=l.pendingWrites??[],_=r.configurable?.checkpoint_ns,y=r.configurable?.[Kt];typeof _=="string"&&_!==""&&typeof y=="object"&&y!==null&&_ in y&&h.length>0&&(h=h.filter(([,N])=>N!==lr));let w=!1,x=c.configurable?.thread_id,S=c.configurable?.checkpoint_ns??"";t.checkpointer&&a&&typeof x=="string"&&(w=(await t.checkpointer.getTuple({configurable:{thread_id:x,checkpoint_ns:S}}))?.config.configurable?.checkpoint_id===a&&m.source!=="update"&&m.source!=="fork");let E=await xu(t.channelSpecs,p,{saver:t.checkpointer,config:c}),C=(m.step??0)+1,T=C+(r.recursionLimit??BZ)+1,b={...p.channel_versions},L=t.store?new yg(t.store):void 0;return L&&await L.start(),new BD({input:t.input,config:r,checkpointer:t.checkpointer,checkpoint:p,checkpointMetadata:m,checkpointConfig:c,prevCheckpointConfig:f,checkpointNamespace:u,channels:E,isNested:s,resumeAtHead:w,manager:t.manager,skipDoneTasks:i,step:C,stop:T,checkpointPreviousVersions:b,checkpointPendingWrites:h,outputKeys:t.outputKeys??[],streamKeys:t.streamKeys??[],nodes:t.nodes,stream:n,store:L,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 n=r;if(n.length===0)return;n.every(([c])=>c in Cd)&&(n=Array.from(new Map(n.map(c=>[c[0],c])).values()));let i=!1;for(let c in this.channels)if(Object.prototype.hasOwnProperty.call(this.channels,c)&&this.channels[c].lc_graph_name==="UntrackedValue"){i=!0;break}let o=n;i&&(o=n.filter(([c])=>{let u=this.channels[c];return!u||u.lc_graph_name!=="UntrackedValue"}).map(([c,u])=>c==="__pregel_tasks"&&Et(u)?[c,$D(u,this.channels)]:[c,u])),this.checkpointPendingWrites=this.checkpointPendingWrites.filter(c=>c[0]!==t);for(let[c,u]of o)this.checkpointPendingWrites.push([t,c,u]);for(let[c,u]of o){let l=this.channels[c];l!=null&&mn(l)&&UD(u)}let a=Pt(this.checkpointConfig,{[Ur]:this.config.configurable?.checkpoint_ns??"",[co]:this.checkpoint.id});if(this.durability!=="exit"&&this.checkpointer!=null&&this._trackCheckpointerPromise(this.checkpointer.putWrites(a,o,t)),this.tasks&&this._outputWrites(t,n),!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,n=!1){let i=this.tasks[t];if(i!==void 0){if(i.config!==void 0&&(i.config.tags??[]).includes("langsmith:hidden"))return;if(r.length>0)if(r[0][0]==="__interrupt__"){if(i.path?.[0]==="__pregel_push"&&i.path?.[i.path.length-1]===!0)return;let o=r.filter(a=>a[0]===Ve).flatMap(a=>a[1]);this._emit([["updates",{[Ve]:o}],["values",{[Ve]:o}]])}else r[0][0]!=="__error__"&&this._emit(ra(xi(yD(this.outputKeys,[[i,r]],n),"updates")));n||this._emit(ra(xi(AD([[i,r]],this.streamKeys),"tasks")))}}async _matchCachedWrites(){if(!this.cache)return[];let t=[],r=([a,s])=>`ns:${a.join(",")}|key:${s}`,n=[],i={};for(let a of Object.values(this.tasks))a.cache_key!=null&&!a.writes.length&&(n.push([a.cache_key.ns,a.cache_key.key]),i[r([a.cache_key.ns,a.cache_key.key])]=a);if(n.length===0)return[];let o=await this.cache.get(n);for(let{key:a,value:s}of o){let c=i[r(a)];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(![Gg,rE].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(i=>i.writes.length>0)){let i=Object.values(this.tasks),o=i.flatMap(s=>s.writes);this.updatedChannels=kr(this.checkpoint,this.channels,i,this.checkpointerGetNextVersion,this.triggerToNodes);for(let[s,c]of o){let u=this.channels[s];u!=null&&mn(u)&&ma(c)&&this._deltaChannelsWithOverwrite.add(s)}let a=await jn(xi(Ug(this.outputKeys,o,this.channels),"values"));if(this._exitDeltaWrites!==void 0)for(let[s,c,u]of this.checkpointPendingWrites){let l=this.channels[c];l!=null&&mn(l)&&this._exitDeltaWrites.push([this.step,s,c,u])}if(this.checkpointPendingWrites=[],await this._putCheckpoint({source:"loop"}),this.durability==="sync"&&await this._awaitCheckpointerPromises(),this._emitValuesWithCheckpointMeta(a),Dd(this.checkpoint,this.interruptAfter,i))throw this.status="interrupt_after",new Si;this.config.configurable?.__pregel_resuming!==void 0&&delete this.config.configurable?.[fa]}else return!1}if(this.step>this.stop)return this.status="out_of_steps",!1;this.tasks=oa(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 n=Object.values(this.tasks);if(this.checkpointer&&(this.stream.modes.has("checkpoints")||this.stream.modes.has("debug"))&&this._emit(await jn(xi(CD(this.checkpointConfig,this.channels,this.streamKeys,this.checkpointMetadata,n,this.checkpointPendingWrites,this.prevCheckpointConfig,this.outputKeys),"checkpoints"))),n.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[i,o,a]of this.checkpointPendingWrites){if(o==="__error__"||o==="__error_source_node__"||o==="__interrupt__"||o==="__resume__")continue;let s=n.find(c=>c.id===i);s&&s.writes.push([o,a])}this._resumeErrorHandlersIfApplicable(),n=Object.values(this.tasks);for(let i of n)i.writes.length>0&&this._outputWrites(i.id,i.writes,!0)}if(n.every(i=>i.writes.length>0))return this.tick({inputKeys:r});if(Dd(this.checkpoint,this.interruptBefore,n))throw this.status="interrupt_before",new Si;if(this.stream.modes.has("tasks")||this.stream.modes.has("debug")){let i=await jn(xi(Hg(n),"tasks"));this._emit(i)}return!0}async finishAndHandleError(t){this.durability==="exit"&&(!this.isNested||typeof t<"u"||this.checkpointNamespace.every(n=>!n.includes(":")))&&(await this._putExitDeltaWrites(),this._putCheckpoint(this.checkpointMetadata),this._flushPendingWrites());let r=this._suppressInterrupt(t);return(r||t===void 0)&&(this.output=Dn(this.channels,this.outputKeys)),r&&(this.tasks!==void 0&&this.checkpointPendingWrites.length>0&&Object.values(this.tasks).some(n=>n.writes.length>0)&&(this.updatedChannels=kr(this.checkpoint,this.channels,Object.values(this.tasks),this.checkpointerGetNextVersion,this.triggerToNodes),this._emitValuesWithCheckpointMeta(ra(xi(Ug(this.outputKeys,Object.values(this.tasks).flatMap(n=>n.writes),this.channels),"values")))),ki(t)&&!t.interrupts.length&&this._emit([["updates",{[Ve]:[]}],["values",{[Ve]:[]}]],this.#e())),r}async acceptPush(t,r,n){if(this.interruptAfter?.length>0&&Dd(this.checkpoint,this.interruptAfter,[t])){this.toInterrupt.push(t);return}let i=Vg([dr,t.path??[],r,t.id,n],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(!i)return;if(this.interruptBefore?.length>0&&Dd(this.checkpoint,this.interruptBefore,[i])){this.toInterrupt.push(i);return}(this.stream.modes.has("tasks")||this.stream.modes.has("debug"))&&this._emit(ra(xi(Hg([i]),"tasks"))),this.debug&&Ld(this.step,[i]),this.tasks[i.id]=i,this.skipDoneTasks&&this._matchWrites({[i.id]:i});let o=await this._matchCachedWrites();for(let{task:a}of o)this._outputWrites(a.id,a.writes,!0);return i}getErrorHandlerNode(t){return this.nodes[t]?.errorHandlerNode}isErrorHandlerNode(t){return this.nodes[t]?.isErrorHandler===!0}scheduleErrorHandler(t,r){let n=this.getErrorHandlerNode(String(t.name));if(!n)return;let i=ID(t,n,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(i!==void 0)return this.tasks[i.id]=i,this._emit(ra(xi(Hg([i]),"tasks"))),this.debug&&Ld(this.step,[i]),i}_resumeErrorHandlersIfApplicable(){let t=new Map;for(let[r,n]of this.checkpointPendingWrites){if(n!=="__error_source_node__")continue;let i=this.checkpointPendingWrites.find(([s,c])=>s===r&&c==="__error__");if(i===void 0)continue;let o=i[2],a=new Error(o?.message??String(o));o?.name&&(a.name=o.name),t.set(r,a)}for(let[r,n]of t){let i=this.tasks[r];i!==void 0&&this.getErrorHandlerNode(String(i.name))&&(i.writes.length===0&&i.writes.push([ao,{message:n.message,name:n.name}]),this.scheduleErrorHandler(i,n))}}_suppressInterrupt(t){return ki(t)&&!this.isNested}async _first(t){let{configurable:r}=this.config,n=r?.[ur];if(n&&n.nullResume!==void 0&&this.putWrites(fr,[[lr,n.nullResume]]),Rt(this.input)){let u=this.input.resume!=null;if(this.input.resume!=null&&typeof this.input.resume=="object"&&Object.keys(this.input.resume).every(Rg)&&(this.config.configurable??={},this.config.configurable[pa]=this.input.resume),u&&this.checkpointer==null)throw new Error("Cannot use Command(resume=...) without checkpointer");let l={};for(let[d,f,p]of _D(this.input,this.checkpointPendingWrites))l[d]??=[],l[d].push([f,p]);if(Object.keys(l).length===0)throw new tf("Received empty Command input");for(let[d,f]of Object.entries(l))this.putWrites(d,f)}let i=(this.checkpointPendingWrites??[]).filter(u=>u[0]===fr).map(u=>u.slice(1));i.length>0&&kr(this.checkpoint,this.channels,[{name:Vn,writes:i,triggers:[]}],this.checkpointerGetNextVersion,this.triggerToNodes);let o=Rt(this.input),a=o&&i.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||!(o&&this.input.resume!=null||r?.__pregel_resuming===!0||this.resumeAtHead));s&&(this.checkpointPendingWrites=this.checkpointPendingWrites.filter(u=>u[1]!==lr));let c=this.isResuming;if(c||a){let u={...this.checkpoint.versions_seen[Ve]};for(let d in this.channels)Object.prototype.hasOwnProperty.call(this.channels,d)&&this.checkpoint.channel_versions[d]!==void 0&&(u[d]=this.checkpoint.channel_versions[d]);this.checkpoint.versions_seen[Ve]=u,s&&this.checkpointMetadata.source!=="update"&&this.checkpointMetadata.source!=="fork"&&(this.checkpointPendingWrites=this.checkpointPendingWrites.filter(d=>d[1]!==Ve),await this._putCheckpoint({source:"fork"}));let l=await jn(xi(Ug(this.outputKeys,!0,this.channels),"values"));c?this.input=rE:a&&(await this._putCheckpoint({source:"input"}),this.input=Gg),this._emitValuesWithCheckpointMeta(l)}else{let u=await jn(zg(t,this.input));if(u.length>0){let l=oa(this.checkpoint,this.checkpointPendingWrites,this.nodes,this.channels,this.config,!0,{step:this.step});this.updatedChannels=kr(this.checkpoint,this.channels,Object.values(l).concat([{name:Vn,writes:u,triggers:[]}]),this.checkpointerGetNextVersion,this.triggerToNodes);let d=u.filter(([f])=>{let p=this.channels[f];return p!=null&&mn(p)});for(let[f,p]of d)ma(p)&&this._deltaChannelsWithOverwrite.add(f);if(d.length>0)if(this._exitDeltaWrites!==void 0)for(let[f,p]of d)this._exitDeltaWrites.push([this.step,fr,f,p]);else this.checkpointer!=null&&this.putWrites(fr,d);await this._putCheckpoint({source:"input"}),this.input=Gg}else if("__pregel_resuming"in(this.config.configurable??{}))this.input=Gg;else throw new tf(`Received no input writes for ${JSON.stringify(t,null,2)}`)}if(!this.isNested){let u;if(s){let l=this.checkpoint.id;(this.checkpointMetadata.source==="update"||this.checkpointMetadata.source==="fork")&&this.prevCheckpointConfig&&(l=this.prevCheckpointConfig.configurable?.checkpoint_id??l),u=new zD(l)}this.config=Pt(this.config,{[fa]:this.isResuming,[Zd]:u})}}#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=VZ(this.config.configurable?.[Kt]);return r.length>0?r:t}_emit(t,r=this.checkpointNamespace){for(let[n,i]of t)if(this.stream.modes.has(n)&&this.stream.push([r,n,i]),(n==="checkpoints"||n==="tasks")&&this.stream.modes.has("debug")){let o=n==="checkpoints"?this.step-1:this.step,a=new Date().toISOString(),s=n==="checkpoints"?"checkpoint":typeof i=="object"&&i!=null&&"result"in i?"task_result":"task";this.stream.push([r,"debug",{step:o,type:s,timestamp:a,payload:i}])}}_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[n,i]of t)n==="values"&&r?.checkpoint!=null&&!this.stream.modes.has("checkpoints")&&this.stream.push([this.checkpointNamespace,"checkpoints",r.checkpoint]),this.stream.modes.has(n)&&this.stream.push([this.checkpointNamespace,n,i])}_putCheckpoint(t){let r=this.checkpointMetadata===t,n=this.checkpointer!=null&&(this.durability!=="exit"||r),i=c=>{this.prevCheckpointConfig=this.checkpointConfig?.configurable?.checkpoint_id?this.checkpointConfig:void 0,this.checkpointConfig=Pt(this.checkpointConfig,{[Ur]:this.config.configurable?.checkpoint_ns??""});let u={...this.checkpoint.channel_versions},l=Au(this.checkpointPreviousVersions,u);this.checkpointPreviousVersions=u,this._checkpointerPutAfterPrevious({config:{...this.checkpointConfig},checkpoint:Pn(c),metadata:{...this.checkpointMetadata},newVersions:l}),this.checkpointConfig={...this.checkpointConfig,configurable:{...this.checkpointConfig.configurable,checkpoint_id:this.checkpoint.id}}},o;if(r)o={...this.checkpointMetadata.counters_since_delta_snapshot??{}};else{let c=this.checkpointMetadata.counters_since_delta_snapshot??{};o={};let u=this.updatedChannels??new Set;for(let l in this.channels){if(!Object.prototype.hasOwnProperty.call(this.channels,l)||!mn(this.channels[l]))continue;let[d,f]=c[l]??[0,0];o[l]=[u.has(l)?d+1:d,f+1]}this.checkpointMetadata={...t,step:this.step,parents:this.config.configurable?.checkpoint_map??{}}}let a=n?wg(this.channels,o):new Set;if(n)for(let c of this._deltaChannelsWithOverwrite)a.add(c);this.checkpoint=Nn(this.checkpoint,n?this.channels:void 0,this.step,{id:r?this.checkpoint.id:void 0,channelsToSnapshot:a,updatedChannels:this.updatedChannels,getNextVersion:n?c=>this.checkpointerGetNextVersion(c):void 0});for(let c of a)o[c]=[0,0],this._deltaChannelsWithOverwrite.delete(c);let s={};for(let c in o){if(!Object.prototype.hasOwnProperty.call(o,c))continue;let[u,l]=o[c];(u!==0||l!==0)&&(s[c]=[u,l])}Object.keys(s).length>0?this.checkpointMetadata.counters_since_delta_snapshot=s:delete this.checkpointMetadata.counters_since_delta_snapshot,n&&i(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=wg(this.channels,t);for(let c of this._deltaChannelsWithOverwrite)r.add(c);let n=this._exitDeltaWrites.filter(([,,c])=>!r.has(c));if(n.length===0)return;let i;if(this._hasPersistedParent)i=this._initialCheckpointConfig;else{let c=Cs();c.id=this.checkpointIdSaved??c.id,c.ts=new Date().toISOString();let u=Pt(this._initialCheckpointConfig,{[co]:void 0});i=Pt(this._initialCheckpointConfig,{[co]:c.id}),this._trackCheckpointerPromise(this.checkpointer.put(u,c,{source:"loop",step:-2,parents:{}},{})),this.checkpointConfig=i}let o=Pt(i,{[Ur]:this.config.configurable?.checkpoint_ns??"",[co]:i.configurable?.[co]}),a=new Map,s=[];for(let[c,u,l,d]of n){let f=`${c}\0${u}`,p=a.get(f);p===void 0&&(p=[],a.set(f,p),s.push({key:f,step:c,tid:u})),p.push([l,d])}for(let{key:c,step:u,tid:l}of s){let d=Tk(u,l);this._trackCheckpointerPromise(this.checkpointer.putWrites(o,a.get(c),d))}}_flushPendingWrites(){if(this.checkpointer==null||this.checkpointPendingWrites.length===0)return;let t=Pt(this.checkpointConfig,{[Ur]:this.config.configurable?.checkpoint_ns??"",[co]:this.checkpoint.id}),r={};for(let[n,i,o]of this.checkpointPendingWrites)r[n]??=[],r[n].push([i,o]);for(let[n,i]of Object.entries(r))this._trackCheckpointerPromise(this.checkpointer.putWrites(t,i,n))}_matchWrites(t){for(let[r,n,i]of this.checkpointPendingWrites){if(n==="__error__"||n==="__interrupt__"||n==="__resume__")continue;let o=Object.values(t).find(a=>a.id===r);o&&o.writes.push([n,i])}for(let r of Object.values(t))r.writes.length>0&&this._outputWrites(r.id,r.writes,!0)}};function ZZ(e){return ot(e?.message)}function VD(e,t,r){if(!e)return;let n=e.langgraph_checkpoint_ns,i=e.checkpoint_ns,o=n??i;if(o)return[o.split("|"),{tags:t,name:r,...e}]}var HD=class extends hr{name="StreamMessagesHandler";streamFn;metadatas={};seen={};emittedChatModelRunIds={};stableMessageIdMap={};lc_prefer_streaming=!0;constructor(e){super(),this.streamFn=e}_emit(e,t,r,n=!1){if(n&&t.id!==void 0&&this.seen[t.id]!==void 0)return;let i=t.id;r!=null&&(Zu(t)?i??=`run-${r}-tool-${t.tool_call_id}`:((i==null||i===`run-${r}`)&&(i=this.stableMessageIdMap[r]??i??`run-${r}`),this.stableMessageIdMap[r]??=i)),i!==t.id&&(t.id=i,t.lc_kwargs.id=i),t.id!=null&&(this.seen[t.id]=t),this.streamFn([e[0],"messages",[t,e[1]]])}handleChatModelStart(e,t,r,n,i,o,a,s){a&&(!o||!o.includes("langsmith:nostream")&&!o.includes("nostream"))&&(this.metadatas[r]=VD(a,o,s))}handleLLMNewToken(e,t,r,n,i,o){let a=o?.chunk;this.emittedChatModelRunIds[r]=!0,this.metadatas[r]!==void 0&&(ZZ(a)?this._emit(this.metadatas[r],a.message,r):this._emit(this.metadatas[r],new ut({content:e}),r))}handleLLMEnd(e,t){if(this.metadatas[t]!==void 0){if(!this.emittedChatModelRunIds[t]){let r=e.generations?.[0]?.[0];ot(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,n,i,o,a,s){if(o!==void 0&&s===o.langgraph_node&&(i===void 0||!i.includes("langsmith:hidden"))&&(this.metadatas[r]=VD(o,i,s),typeof t=="object")){for(let c of Object.values(t))if((ot(c)||$i(c))&&c.id!==void 0)this.seen[c.id]=c;else if(Array.isArray(c))for(let u of c)(ot(u)||$i(u))&&u.id!==void 0&&(this.seen[u.id]=u)}}handleChainEnd(e,t){let r=this.metadatas[t];if(delete this.metadatas[t],r!==void 0){if(ot(e))this._emit(r,e,t,!0);else if(Array.isArray(e))for(let n of e)ot(n)&&this._emit(r,n,t,!0);else if(e!=null&&typeof e=="object"){for(let n of Object.values(e))if(ot(n))this._emit(r,n,t,!0);else if(Array.isArray(n))for(let i of n)ot(i)&&this._emit(r,i,t,!0)}}}handleChainError(e,t){delete this.metadatas[t]}};function ZD(e){if("response_metadata"in e&&typeof e.response_metadata=="object"&&e.response_metadata!=null)return e.response_metadata}function GD(e){if("usage_metadata"in e&&typeof e.usage_metadata=="object"&&e.usage_metadata!=null)return e.usage_metadata}function GZ(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 WZ(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 WD=class extends hr{name="StreamProtocolMessagesHandler";streamFn;metadatas={};seen={};streamedRunIds=new Set;stableMessageIdMap={};lc_prefer_chat_model_stream_events=!0;awaitHandlers=!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 n=r!=null?{...e[1],run_id:r}:e[1];this.streamFn([e[0],"messages",[t,n]])}emitFinalMessage(e,t,r,n=!1){let i=t.id??(r!=null?this.stableMessageIdMap[r]:void 0);if(n&&i!=null&&this.seen[i]!==void 0)return;let o=this.normalizeMessageId(t,r),a=t.type==="human"?"human":t.type==="system"?"system":t.type==="tool"?"tool":"ai",s=a==="tool"&&$t.isInstance(t)?t.tool_call_id:void 0;this.emit(e,{event:"message-start",...o!=null?{id:o}:{},...a!=="ai"?{role:a}:{},...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,u)=>{let l=typeof c.index=="number"?c.index:u;this.emit(e,{event:"content-block-start",index:l,content:GZ(c)},r);let d=WZ({...c,index:l});d!=null&&this.emit(e,d,r),this.emit(e,{event:"content-block-finish",index:l,content:c},r)}),this.emit(e,{event:"message-finish",...GD(t)!=null?{usage:GD(t)}:{},...ZD(t)!=null?{responseMetadata:ZD(t)}:{}},r)}handleChatModelStart(e,t,r,n,i,o,a,s){a&&(!o||!o.includes("langsmith:nostream")&&!o.includes("nostream"))&&(this.metadatas[r]=[a.langgraph_checkpoint_ns.split("|"),{tags:o,name:s,...a}])}handleLLMNewToken(){}handleChatModelStreamEvent(e,t){let r=this.metadatas[t];if(r===void 0)return;let n=e;if(e.event==="message-start"){this.streamedRunIds.add(t);let i=e.id??`run-${t}`;this.seen[i]=!0,this.stableMessageIdMap[t]??=i,e.id==null&&(n={...e,id:i})}this.emit(r,n,t)}handleLLMEnd(e,t){let r=this.metadatas[t];if(r===void 0)return;let n=e.generations?.[0]?.[0],i=Re.isInstance(n?.message)?n.message:void 0;if(i!=null)if(this.streamedRunIds.has(t)){let o=this.normalizeMessageId(i,t);o!=null&&(this.seen[o]=i)}else this.emitFinalMessage(r,i,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,n,i,o,a,s){if(o!==void 0&&s===o.langgraph_node&&(i===void 0||!i.includes("langsmith:hidden"))&&(this.metadatas[r]=[o.langgraph_checkpoint_ns.split("|"),{tags:i,name:s,...o}],typeof t=="object")){for(let c of Object.values(t))if((Re.isInstance(c)||Mt.isInstance(c))&&c.id!==void 0)this.seen[c.id]=c;else if(Array.isArray(c))for(let u of c)(Re.isInstance(u)||Mt.isInstance(u))&&u.id!==void 0&&(this.seen[u.id]=u)}}handleChainEnd(e,t){let r=this.metadatas[t];if(delete this.metadatas[t],r===void 0)return;let n=i=>{Re.isInstance(i)&&!$t.isInstance(i)&&this.emitFinalMessage(r,i,t,!0)};if(Re.isInstance(e))n(e);else if(Array.isArray(e))for(let i of e)n(i);else if(e!=null&&typeof e=="object")for(let i of Object.values(e))if(Array.isArray(i))for(let o of i)n(o);else n(i);delete this.stableMessageIdMap[t]}handleChainError(e,t){delete this.metadatas[t],delete this.stableMessageIdMap[t]}};var qZ=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}},KZ=class extends hr{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 JZ(e,t,r,n){let i=e.configurable??{},o={},a=i[qt];typeof a=="function"&&(o[qt]=u=>{if(t.active)return u&&u.length&&t.autoTouch(),a(u)});let s=i[Hn];typeof s=="function"&&(o[Hn]=(...u)=>{if(!t.active)throw new Error(`Node "${n}" attempt was cancelled after its timeout fired`);return t.autoTouch(),s(...u)});let c={...Object.keys(o).length>0?Pt(e,o):e};if(c.heartbeat=()=>{r.idleTimeout!==void 0&&t.touch()},typeof c.writer=="function"){let u=c.writer;c.writer=(l=>{if(t.active)return t.autoTouch(),u(l)})}if((r.refreshOn??"auto")==="auto"&&r.idleTimeout!==void 0){let u=new KZ(t),l=c.callbacks;if(l===void 0)c.callbacks=[u];else if(Array.isArray(l))c.callbacks=[...l,u];else{let d=l.copy();d.addHandler(u,!0),c.callbacks=d}}return c}async function qD(e,t,r,n){let i=new qZ(r.refreshOn??"auto"),o=new AbortController,{signal:a,dispose:s}=ia(t.signal,o.signal),c=JZ({...t,signal:a},i,r,String(e.name)),u=Date.now(),l=n(c).then(y=>({type:"ok",value:y}),y=>({type:"err",error:y})),d,f,p=()=>{d!==void 0&&clearTimeout(d),f!==void 0&&clearTimeout(f)},m=new Promise(y=>{if(r.runTimeout!==void 0&&(d=setTimeout(()=>y({type:"timeout",kind:"run"}),r.runTimeout)),r.idleTimeout!==void 0){let w=r.idleTimeout,x=()=>{let S=i.lastProgress+w-Date.now();S<=0?y({type:"timeout",kind:"idle"}):f=setTimeout(x,S)};f=setTimeout(x,w)}}),h;try{h=await Promise.race([l,m])}finally{p()}if(h.type!=="timeout"){let y=Date.now();r.runTimeout!==void 0&&y-u>=r.runTimeout?h={type:"timeout",kind:"run"}:r.idleTimeout!==void 0&&y-i.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()-u;throw i.close(),e.writes.splice(0,e.writes.length),o.abort(),s?.(),new ef({node:String(e.name),elapsed:_,kind:h.kind,runTimeout:r.runTimeout,idleTimeout:r.idleTimeout})}var XZ=[400,401,402,403,404,405,406,407,409],YZ=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&&XZ.includes(+t)||e?.error?.code==="insufficient_quota")};async function Wg(e,t,r,n){let i=e.retry_policy??t,o=0,a,s,c=e.config??{};r&&(c=Pt(c,r)),c={...c,signal:n};let u=Date.now();for(c.executionInfo!=null&&(c.executionInfo={...c.executionInfo,nodeFirstAttemptTime:u});!n?.aborted;){e.writes.splice(0,e.writes.length),a=void 0;try{e.timeout!==void 0?s=await qD(e,c,e.timeout,l=>e.proc.invoke(e.input,l)):s=await e.proc.invoke(e.input,c);break}catch(l){if(a=l,a.pregelTaskId=e.id,t_(a)){let h=c?.configurable?.checkpoint_ns,_=a.command;if(_.graph===h){for(let y of e.writers)await y.invoke(_,c);a=void 0;break}else if(_.graph===Ir.PARENT){let y=YM(h);a.command=new Ir({...a.command,graph:y})}}if(fo(a)||i===void 0||(o+=1,o>=(i.maxAttempts??3))||!(i.retryOn??YZ)(a))break;let d=i.initialInterval??500,f=Math.min(i.maxInterval??128e3,d*(i.backoffFactor??2)**(o-1)),p=i.jitter??!0?f+Math.random()*1e3:f;await new Promise(h=>setTimeout(h,p));let m=a.name??a.constructor.unminifiable_name??a.constructor.name;(i?.logWarning??!0)&&console.log(`Retrying task "${String(e.name)}" after ${p.toFixed(2)}ms (attempt ${o}) after ${m}: ${a}`),c=Pt(c,{[fa]:!0}),c.executionInfo!=null&&(c.executionInfo={...c.executionInfo,nodeAttempt:o+1,nodeFirstAttemptTime:u})}}return{task:e,result:s,error:a,signalAborted:n?.aborted}}var nE=Symbol.for("promiseAdded");function QZ(){let e={next:()=>{},wait:Promise.resolve(nE)};function t(r){e.next=()=>{e.wait=new Promise(t),r(nE)}}return e.wait=new Promise(t),e}var KD=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:n,maxConcurrency:i}=e,o=new Set,a,s=new AbortController,c=s.signal,u=t?AbortSignal.timeout(t):void 0,l=Object.values(this.loop.tasks),d=l.filter(h=>h.writes.length===0),{signals:f,disposeCombinedSignal:p}=this._initializeAbortSignals({exceptionSignal:c,stepTimeoutSignal:u,signal:e.signal}),m=this._executeTasksWithRetry(d,{signals:f,retryPolicy:r,maxConcurrency:i});for await(let{task:h,error:_,signalAborted:y}of m)this._commit(h,_),!(_!==void 0&&this.handledExceptions.has(_))&&(ki(_)||fo(_)&&!ki(a)?a=_:_&&(o.size===0||!y)&&(s.abort(),o.add(_)));if(p?.(),n?.(this.loop.step,l.map(h=>h.writes).flat()),o.size===1)throw Array.from(o)[0];if(o.size>1)throw new AggregateError(Array.from(o),`Multiple errors occurred during superstep ${this.loop.step}. See the "errors" field of this exception for more details.`);if(ki(a)||Jd(a)||fo(a)&&this.loop.isNested)throw a}_initializeAbortSignals({exceptionSignal:e,stepTimeoutSignal:t,signal:r}){let n=this.loop.config.configurable?.__pregel_abort_signals??{},i=n.externalAbortSignal??r,o=t??n.timeoutAbortSignal,{signal:a,dispose:s}=ia(i,o,e),c={externalAbortSignal:i,timeoutAbortSignal:o,composedAbortSignal:a};return this.loop.config=Pt(this.loop.config,{[kE]:c}),{signals:c,disposeCombinedSignal:s}}async*_executeTasksWithRetry(e,t){let{retryPolicy:r,maxConcurrency:n,signals:i}=t??{},o=QZ(),a={},s={executingTasksMap:a,barrier:o,retryPolicy:r,scheduleTask:async(f,p,m)=>this.loop.acceptPush(f,p,m)};if(i?.composedAbortSignal?.aborted)throw new Error("Abort");let c=0,u,l=ia(i?.externalAbortSignal,i?.timeoutAbortSignal),d=l.signal?new Promise((f,p)=>{u=()=>p(new Error("Abort")),l.signal?.addEventListener("abort",u,{once:!0})}):void 0;for(;(c===0||Object.keys(a).length>0)&&e.length;){for(;Object.values(a).length<(n??e.length)&&c<e.length;c+=1){let _=e[c];a[_.id]=Wg(_,r,{[Hn]:iE?.bind(s,this,_)},i?.composedAbortSignal).catch(y=>({task:_,error:y,signalAborted:i?.composedAbortSignal?.aborted}))}let f=await Promise.race([...Object.values(a),...d?[d]:[],o.wait]);if(f===nE)continue;let p=f,{task:m,error:h}=p;if(h!==void 0&&!fo(h)&&!this.loop.isErrorHandlerNode(String(m.name))&&this.loop.getErrorHandlerNode(String(m.name))!==void 0){let _=this.loop.scheduleErrorHandler(m,h);_!==void 0&&(a[_.id]=Wg(_,r,{[Hn]:iE?.bind(s,this,_)},i?.composedAbortSignal).catch(y=>({task:_,error:y,signalAborted:i?.composedAbortSignal?.aborted})),o.next())}yield p,u!=null&&(l.signal?.removeEventListener("abort",u),l.dispose?.()),delete a[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(ki(t)){if(t.interrupts.length){let r=t.interrupts.map(i=>[Ve,i]),n=e.writes.filter(i=>i[0]===lr);n.length&&r.push(...n),this.loop.putWrites(e.id,r)}}else Jd(t)?e.writes.length&&this.loop.putWrites(e.id,e.writes):fo(t)&&e.writes.length?this.loop.putWrites(e.id,e.writes):(e.writes.push([ao,{message:t.message,name:t.name}]),this._shouldRouteToErrorHandler(e)&&(e.writes.push([Nu,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([Mu,null]),this.loop.putWrites(e.id,e.writes)}};async function iE(e,t,r,n,i,o={}){let a=t.config?.configurable?.[ur];if(!a)throw new Error(`BUG: No scratchpad found on task ${t.name}__${t.id}`);let s=a.callCounter;a.callCounter+=1;let c=new bD({func:r,name:n,input:i,cache:o.cache,retry:o.retry,timeout:o.timeout,callbacks:o.callbacks}),u=await this.scheduleTask(t,s,c);if(!u)return;let l=this.executingTasksMap[u.id];if(l!==void 0)return l;if(u.writes.length>0){let d=u.writes.filter(([p])=>p===uo),f=u.writes.filter(([p])=>p===ao);if(d.length>0){if(d.length===1)return Promise.resolve(d[0][1]);throw new Error(`BUG: multiple returns found for task ${u.name}__${u.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 ${u.name}__${u.id}`)}return}else{let d=Wg(u,o.retry,{[Hn]:iE.bind(this,e,u)});return this.executingTasksMap[u.id]=d,this.barrier.next(),d.then(({result:f,error:p})=>p?Promise.reject(p):f)}}var Xi=class extends Error{constructor(e){super(e),this.name="GraphValidationError"}};function JD({nodes:e,channels:t,inputChannels:r,outputChannels:n,streamChannels:i,interruptAfterNodes:o,interruptBeforeNodes:a}){if(!t)throw new Xi("Channels not provided");let s=new Set,c=new Set;for(let[u,l]of Object.entries(e)){if(u==="__interrupt__")throw new Xi(`"Node name ${Ve} is reserved"`);if(l.constructor===Mn)l.triggers.forEach(d=>s.add(d));else throw new Xi(`Invalid node type ${typeof l}, expected PregelNode`)}for(let u of s)if(!(u in t))throw new Xi(`Subscribed channel '${String(u)}' not in channels`);if(Array.isArray(r)){if(r.every(u=>!s.has(u)))throw new Xi(`None of the input channels ${r} are subscribed to by any node`)}else if(!s.has(r))throw new Xi(`Input channel ${String(r)} is not subscribed to by any node`);Array.isArray(n)?n.forEach(u=>c.add(u)):c.add(n),i&&!Array.isArray(i)?c.add(i):Array.isArray(i)&&i.forEach(u=>c.add(u));for(let u of c)if(!(u in t))throw new Xi(`Output channel '${String(u)}' not in channels`);if(o&&o!=="*"){for(let u of o)if(!(u in e))throw new Xi(`Node ${String(u)} not in nodes`)}if(a&&a!=="*"){for(let u of a)if(!(u in e))throw new Xi(`Node ${String(u)} not in nodes`)}}function oE(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 aE=class XD extends xt{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 XD({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 n=t.flat();if(n.length>0)if(this.unique)for(let i of n)this.seen.has(i)||(r=!0,this.seen.add(i),this.values.push(i));else r=!0,this.values.push(...n);return r}get(){if(this.values.length===0)throw new Ue;return this.values}checkpoint(){return[[...this.seen],this.values]}isAvailable(){return this.values.length!==0}};function e5(e){let t=new TextEncoder;return new ReadableStream({async start(r){try{for await(let n of e){let i=n.params.namespace,o=i.length?`${n.method}|${i.join("|")}`:n.method;r.enqueue(t.encode(`event: ${o}
452
- data: ${JSON.stringify(n.params.data??{})}
453
-
454
- `))}}catch(n){r.enqueue(t.encode(`event: error
455
- data: ${JSON.stringify({message:String(n)})}
456
-
457
- `))}finally{r.close()}}})}var YD=class{static subscribeTo(e,t){let{key:r,tags:n}={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 i;return typeof e=="string"?r?i={[r]:e}:i=[e]:i=Object.fromEntries(e.map(o=>[o,o])),new Mn({channels:i,triggers:Array.isArray(e)?e:[e],tags:n})}static writeTo(e,t){let r=[];for(let n of e)r.push({channel:n,value:Dr,skipNone:!1});for(let[n,i]of Object.entries(t??{}))ce.isRunnable(i)||typeof i=="function"?r.push({channel:n,value:Dr,skipNone:!0,mapper:lt(i)}):r.push({channel:n,value:i,skipNone:!1});return new ht(r)}},t5=class extends ce{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)}},qg=class extends t5{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 '${Zn}' is reserved and cannot be used in the graph.`);this.channels[Zn]=new aE({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,n=Ct(this.config,r),i=[...this.streamTransformers,...t??[]];return new this.constructor({...this,config:n,streamTransformers:i})}validate(){JD({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,n]of Object.entries(this.nodes)){if(e!==void 0&&!e.startsWith(r))continue;let i=n.subgraphs?.length?n.subgraphs:[n.bound];for(let o of i){let a=Dg(o);if(a!==void 0){if(r===e){yield[r,a];return}if(e===void 0&&(yield[r,a]),t){let s=e;e!==void 0&&(s=e.slice(r.length+1));for(let[c,u]of a.getSubgraphs(s,t))yield[`${r}|${c}`,u]}}}}}async*getSubgraphsAsync(e,t){yield*this.getSubgraphs(e,t)}async _prepareStateSnapshot({config:e,saved:t,subgraphCheckpointer:r,applyPendingWrites:n=!1}){if(t===void 0)return{values:{},next:[],config:e,tasks:[]};let i=await xu(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===fr).map(([f,p,m])=>[String(p),m]);d.length>0&&kr(t.checkpoint,i,[{name:Vn,writes:d,triggers:[]}],void 0,this.triggerToNodes)}let o=Object.values(oa(t.checkpoint,t.pendingWrites,this.nodes,i,t.config,!0,{step:(t.metadata?.step??-1)+1,store:this.store})),a=await jn(this.getSubgraphsAsync()),s=t.config.configurable?.checkpoint_ns??"",c={};for(let d of o){let f=a.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:{[Qr]:r,thread_id:t.config.configurable?.thread_id,checkpoint_ns:p}},h=f[1];c[d.id]=await h.getState(m,{subgraphs:!0})}}if(n&&t.pendingWrites?.length){let d=Object.fromEntries(o.map(p=>[p.id,p]));for(let[p,m,h]of t.pendingWrites)["__error__","__interrupt__",ya].includes(m)||p in d&&d[p].writes.push([String(m),h]);let f=o.filter(p=>p.writes.length>0);f.length>0&&kr(t.checkpoint,i,f,void 0,this.triggerToNodes)}let u=t?.metadata;u&&t?.config?.configurable?.thread_id&&(u={...u,thread_id:t.config.configurable.thread_id});let l=o.filter(d=>d.writes.length===0).map(d=>d.name);return{values:Dn(i,this.streamChannelsAsIs),next:l,tasks:Yk(o,t?.pendingWrites??[],c,this.streamChannelsAsIs),metadata:u,config:na(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 ga("No checkpointer set",{lc_error_code:"MISSING_CHECKPOINTER"});let n=e.configurable?.checkpoint_ns??"";if(n!==""&&e.configurable?.__pregel_read===void 0&&e.configurable?.__pregel_checkpointer===void 0){let a=Eg(n);for await(let[s,c]of this.getSubgraphsAsync(a,!0))if(s===a)return await c.getState(Ps(e,{[Qr]:r}),{subgraphs:t?.subgraphs})}let i=Ct(this.config,e),o=await r.getTuple(e);return await this._prepareStateSnapshot({config:i,saved:o,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 ga("No checkpointer set",{lc_error_code:"MISSING_CHECKPOINTER"});let n=e.configurable?.checkpoint_ns??"";if(n!==""&&e.configurable?.__pregel_checkpointer===void 0){let o=Eg(n);for await(let[a,s]of this.getSubgraphsAsync(o,!0))if(a===o){yield*s.getStateHistory(Ps(e,{[Qr]:r}),t);return}}let i=Ct(this.config,e,{configurable:{checkpoint_ns:n}});for await(let o of r.list(i,t))yield this._prepareStateSnapshot({config:o.config,saved:o})}async bulkUpdateState(e,t){let r=e.configurable?.__pregel_checkpointer??this.checkpointer;if(!r)throw new ga("No checkpointer set",{lc_error_code:"MISSING_CHECKPOINTER"});if(t.length===0)throw new Error("No supersteps provided");if(t.some(a=>a.updates.length===0))throw new Error("No updates provided");let n=e.configurable?.checkpoint_ns??"";if(n!==""&&e.configurable?.__pregel_checkpointer===void 0){let a=Eg(n);for await(let[,s]of this.getSubgraphsAsync(a,!0))return await s.bulkUpdateState(Ps(e,{[Qr]:r}),t);throw new Error(`Subgraph "${a}" not found`)}let i=async(a,s)=>{let c=this.config?Ct(this.config,a):a,u=await r.getTuple(c),l=u!==void 0?Pn(u.checkpoint):Cs(),d={...u?.checkpoint.channel_versions},f=u?.metadata?.step??-1,p=Ps(c,{checkpoint_ns:c.configurable?.checkpoint_ns??""}),m=c.metadata??{};u?.config.configurable&&(p=Ps(c,u.config.configurable),m={...u.metadata,...m});let{values:h,asNode:_}=s[0];if(h==null&&_===void 0){if(s.length>1)throw new we("Cannot create empty checkpoint with multiple updates");return na(await r.put(p,Nn(l,void 0,f),{source:"update",step:f+1,parents:u?.metadata?.parents??{}},{}),u?u.metadata:void 0)}let y=await xu(this.channels,l,{saver:r,config:u?.config??p});if(h===null&&_==="__end__"){if(s.length>1)throw new we("Cannot apply multiple updates when clearing state");if(u){let T=oa(l,u.pendingWrites||[],this.nodes,y,u.config,!0,{step:(u.metadata?.step??-1)+1,checkpointer:r,store:this.store}),b=(u.pendingWrites||[]).filter(L=>L[0]===fr).map(L=>L.slice(1));b.length>0&&kr(l,y,[{name:Vn,writes:b,triggers:[]}],r.getNextVersion.bind(r),this.triggerToNodes);for(let[L,N,W]of u.pendingWrites||[])["__error__","__interrupt__",ya].includes(N)||L in T&&T[L].writes.push([N,W]);kr(l,y,Object.values(T),r.getNextVersion.bind(r),this.triggerToNodes)}return na(await r.put(p,Nn(l,y,f),{...m,source:"update",step:f+1,parents:u?.metadata?.parents??{}},Au(d,l.channel_versions)),u?u.metadata:void 0)}if(_==="__copy__"){if(s.length>1)throw new we("Cannot copy checkpoint with multiple updates");if(u==null)throw new we("Cannot copy a non-existent checkpoint");let T=N=>!Array.isArray(N)||N.length===0?!1:N.every(W=>Array.isArray(W)&&W.length===2),b=Nn(l,void 0,f),L=await r.put(u.parentConfig??Ps(u.config,{checkpoint_id:void 0}),b,{source:"fork",step:f+1,parents:u.metadata?.parents??{}},{});if(T(h)){let N=oa(b,u.pendingWrites,this.nodes,y,L,!1,{step:f+2}),W=Object.values(N).reduce((_e,{name:$e,id:ct})=>(_e[$e]??=[],_e[$e].push({id:ct}),_e),{}),ie=h.reduce((_e,$e)=>{let[ct,be]=$e;_e[be]??=[];let V=_e[be].length,Y=W[be]?.[V]?.id;return _e[be].push({values:ct,asNode:be,taskId:Y}),_e},{});return i(na(L,u.metadata),Object.values(ie).flat())}return na(L,u.metadata)}if(_==="__input__"){if(s.length>1)throw new we("Cannot apply multiple updates when updating as input");let T=await jn(zg(this.inputChannels,h));if(T.length===0)throw new we(`Received no input writes for ${JSON.stringify(this.inputChannels,null,2)}`);kr(l,y,[{name:Vn,writes:T,triggers:[]}],r.getNextVersion.bind(this.checkpointer),this.triggerToNodes);let b=u?.metadata?.step!=null?u.metadata.step+1:-1,L=await r.put(p,Nn(l,y,b),{source:"input",step:b,parents:u?.metadata?.parents??{}},Au(d,l.channel_versions));return await r.putWrites(L,T,Gn(Vn,l.id)),na(L,u?u.metadata:void 0)}if(c.configurable?.checkpoint_id===void 0&&u?.pendingWrites!==void 0&&u.pendingWrites.length>0){let T=oa(l,u.pendingWrites,this.nodes,y,u.config,!0,{store:this.store,checkpointer:this.checkpointer,step:(u.metadata?.step??-1)+1}),b=(u.pendingWrites??[]).filter(N=>N[0]===fr).map(N=>N.slice(1));b.length>0&&kr(u.checkpoint,y,[{name:Vn,writes:b,triggers:[]}],void 0,this.triggerToNodes);for(let[N,W,ie]of u.pendingWrites)["__error__","__interrupt__",ya].includes(W)||T[N]===void 0||T[N].writes.push([W,ie]);let L=Object.values(T).filter(N=>N.writes.length>0);L.length>0&&kr(l,y,L,void 0,this.triggerToNodes)}let w=Object.values(l.versions_seen).map(T=>Object.values(T)).flat().find(T=>!!T),x=[];if(s.length===1){let{values:T,asNode:b,taskId:L}=s[0];if(b===void 0&&Object.keys(this.nodes).length===1)[b]=Object.keys(this.nodes);else if(b===void 0&&w===void 0)typeof this.inputChannels=="string"&&this.nodes[this.inputChannels]!==void 0&&(b=this.inputChannels);else if(b===void 0){let N=Object.entries(l.versions_seen).map(([W,ie])=>Object.values(ie).map(_e=>[_e,W])).flat().filter(([W,ie])=>ie!==Ve).sort(([W],[ie])=>gg(W,ie));N&&(N.length===1?b=N[0][1]:N[N.length-1][0]!==N[N.length-2][0]&&(b=N[N.length-1][1]))}if(b===void 0)throw new we('Ambiguous update, specify "asNode"');x.push({values:T,asNode:b,taskId:L})}else for(let{asNode:T,values:b,taskId:L}of s){if(T==null)throw new we('"asNode" is required when applying multiple updates');x.push({values:b,asNode:T,taskId:L})}let S=[];for(let{asNode:T,values:b,taskId:L}of x){if(this.nodes[T]===void 0)throw new we(`Node "${T.toString()}" does not exist`);let N=this.nodes[T].getWriters();if(!N.length)throw new we(`No writers found for node "${T.toString()}"`);S.push({name:T,input:b,proc:N.length>1?Jr.from(N,{omitSequenceTags:!0}):N[0],writes:[],triggers:[Ve],id:L??Gn("__interrupt__",l.id),writers:[]})}for(let T of S)await T.proc.invoke(T.input,Ae({...c,store:c?.store??this.store},{runName:c.runName??`${this.getName()}UpdateState`,configurable:{[qt]:b=>T.writes.push(...b),[cr]:(b,L=!1)=>Cu(l,y,T,b,L)}}));for(let T of S){let b=T.writes.filter(L=>L[0]!==dr);u!==void 0&&b.length>0&&await r.putWrites(p,b,T.id)}kr(l,y,S,r.getNextVersion.bind(this.checkpointer),this.triggerToNodes);let E=Au(d,l.channel_versions),C=await r.put(p,Nn(l,y,f+1),{source:"update",step:f+1,parents:u?.metadata?.parents??{}},E);for(let T of S){let b=T.writes.filter(L=>L[0]===dr);b.length>0&&await r.putWrites(C,b,T.id)}return na(C,u?u.metadata:void 0)},o=e;for(let{updates:a}of t)o=await i(o,a);return o}async updateState(e,t,r){return this.bulkUpdateState(e,[{updates:[{values:t,asNode:r}]}])}_defaults(e){let{debug:t,streamMode:r,inputKeys:n,outputKeys:i,interruptAfter:o,interruptBefore:a,...s}=e,c=!0,u=t!==void 0?t:this.debug,l=i;l===void 0?l=this.streamChannelsAsIs:oE(l,this.channels);let d=n;d===void 0?d=this.inputChannels:oE(d,this.channels);let f=a??this.interruptBefore??[],p=o??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[Qr];else{if(this.checkpointer===!0)throw new Error("checkpointer: true cannot be used for root graphs.");h=this.checkpointer}let _=e.store??this.store,y=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"})(),x=e.durability??w??e?.configurable?.__pregel_durability??"async";return[u,m,d,l,s,f,p,h,_,c,y,x]}async stream(e,t){let r=new AbortController,n=kg()?.configurable;n?.__pregel_read!==void 0&&t?.configurable?.__pregel_read===void 0&&(t={...t,configurable:{...n,...t?.configurable}});let i={recursionLimit:this.config?.recursionLimit,...t,signal:ia(t?.signal,r.signal).signal},o=await super.stream(e,i);return new Zg(t?.encoding==="text/event-stream"?MD(o):o,r)}async#e(e,t){let{version:r,encoding:n,transformers:i,...o}=t,a={recursionLimit:this.config?.recursionLimit,...o,configurable:{...this.config?.configurable,...o?.configurable},version:r,streamMode:Ok,subgraphs:!0,encoding:void 0},s=this.stream(e,a),c=Bk({[Symbol.asyncIterator]:async function*(){let u=await s;for await(let l of u)yield l}},[...this.streamTransformers??[],...i??[]]);if(n==="text/event-stream"){let u=new AbortController;return u.signal.addEventListener("abort",()=>c.abort(u.signal.reason),{once:!0}),new Zg(e5(c),u)}return c}streamEvents(e,t,r){if(t.version==="v3")return this.#e(e,t);let n=new AbortController,i={recursionLimit:this.config?.recursionLimit,...t,signal:ia(t?.signal,n.signal).signal};return new Zg(super.streamEvents(e,i,r),n)}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,n=t?.subgraphs,i=t?.version==="v3",o=Su(this.config,t);if(o.recursionLimit===void 0||o.recursionLimit<1)throw new Error('Passed "recursionLimit" must be at least 1.');if(this.checkpointer!==void 0&&this.checkpointer!==!1&&o.configurable===void 0)throw new Error('Checkpointer requires one or more of the following "configurable" keys: "thread_id", "checkpoint_ns", "checkpoint_id"');let a=await this._validateInput(e),{runId:s,...c}=o,[u,l,,d,f,p,m,h,_,y,w,x]=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 S=new eE({modes:new Set(l)});if(this.checkpointer===!0){f.configurable??={};let ie=f.configurable.checkpoint_ns??"";f.configurable[Ur]=ie.split("|").map(_e=>_e.split(":")[0]).join("|")}if(l.includes("messages")){let ie=i?new WD($e=>S.push($e)):new HD($e=>S.push($e)),{callbacks:_e}=f;if(_e===void 0)f.callbacks=[ie];else if(Array.isArray(_e))f.callbacks=_e.concat(ie);else{let $e=_e.copy();$e.addHandler(ie,!0),f.callbacks=$e}}if(l.includes("tools")){let ie=new jD($e=>S.push($e)),{callbacks:_e}=f;if(_e===void 0)f.callbacks=[ie];else if(Array.isArray(_e))f.callbacks=_e.concat(ie);else{let $e=_e.copy();$e.addHandler(ie,!0),f.callbacks=$e}}f.writer??=ie=>{if(!l.includes("custom"))return;let _e=kg()?.configurable?.[Ur]?.split("|").slice(0,-1);S.push([_e??[],"custom",ie])},f.interrupt??=this.userInterrupt??Gk,f.serverInfo==null&&(f.serverInfo=r5(f)),f.control??=new Ck;let E={tracerInheritableMetadata:o5(f)},C=await(await tt._configureSync(f?.callbacks,void 0,f?.tags,void 0,f?.metadata,void 0,E))?.handleChainStart(this.toJSON(),vD(e,"input"),s,void 0,void 0,void 0,f?.runName??this.getName()),T=wu(this.channels),b,L,W=(async()=>{try{b=await FD.initialize({input:a,config:f,checkpointer:h,nodes:this.nodes,channelSpecs:T,outputKeys:d,streamKeys:this.streamChannelsAsIs,store:_,cache:w,stream:S,interruptAfter:m,interruptBefore:p,manager:C,debug:this.debug,triggerToNodes:this.triggerToNodes,durability:x});let ie=new KD({loop:b,nodeFinished:f.configurable?.[SE]});t?.subgraphs&&(b.config.configurable={...b.config.configurable,[Ru]:b.stream}),await this._runLoop({loop:b,runner:ie,debug:u,config:f}),x==="sync"&&await Promise.all(b?.checkpointerPromises??[])}catch(ie){L=ie}finally{try{b&&(await b.store?.stop(),await b.cache?.stop()),await Promise.all(b?.checkpointerPromises??[])}catch(ie){L=L??ie}L?(await new Promise(ie=>{queueMicrotask(ie)}),S.error(L)):S.close()}})();try{for await(let ie of S){if(ie===void 0)throw new Error("Data structure error.");let[_e,$e,ct]=ie,be="version"in(t??{});if(l.includes($e)||$e==="checkpoints"&&ku(ct)&&(i||be&&n&&l.includes("values"))){if(r==="text/event-stream"){n?yield[_e,$e,ct]:yield[null,$e,ct];continue}n&&!y?yield[_e,$e,ct]:y?n?yield[_e,ct]:yield ct:yield[$e,ct]}}}catch(ie){throw await C?.handleChainError(L),ie}finally{await W}await C?.handleChainEnd(b?.output??{},s,void 0,void 0,void 0)}async invoke(e,t){let r=t?.streamMode??"values",n={...t,outputKeys:t?.outputKeys??this.outputChannels,streamMode:r,encoding:void 0},i=[],o=await this.stream(e,n),a=[],s;for await(let c of o)r==="values"?ha(c)?a.push(c[Ve]):s=c:i.push(c);if(r==="values"){if(a.length>0){let c=a.flat(1);if(s==null)return{[Ve]:c};if(typeof s=="object")return{...s,[Ve]:c}}return s}return i}async _runLoop(e){let{loop:t,runner:r,debug:n,config:i}=e,o;try{for(;await t.tick({inputKeys:this.inputChannels});){for(let{task:a}of await t._matchCachedWrites())t._outputWrites(a.id,a.writes,!0);n&&OD(t.checkpointMetadata.step,t.channels,this.streamChannelsList),n&&Ld(t.step,Object.values(t.tasks)),await r.tick({timeout:this.stepTimeout,retryPolicy:this.retryPolicy,onStepWrite:(a,s)=>{n&&PD(a,s,this.streamChannelsList)},maxConcurrency:i.maxConcurrency,signal:i.signal})}if(t.status==="draining")throw t.control==null?new Error("Draining status requires run control"):new Kd(t.control.drainReason??"shutdown");if(t.status==="out_of_steps")throw new e_([`Recursion limit of ${i.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(a){if(o=a,!await t.finishAndHandleError(o))throw a}finally{o===void 0&&await t.finishAndHandleError()}}async clearCache(){await this.cache?.clear([])}};function r5(e){let t=e.metadata??{},r=e.configurable??{},n=r.assistant_id??t.assistant_id,i=r.graph_id??t.graph_id,o=r.langgraph_auth_user,a;if(o!=null&&typeof o=="object"&&"identity"in o&&(a=o),n!=null||i!=null||a!=null)return{assistantId:n!=null?String(n):"",graphId:i!=null?String(i):"",user:a}}var n5=new Set(["key","token","secret","password","auth"]);function i5(e,t){let r=e.toLowerCase(),n=!1;for(let i of n5)if(r.includes(i)){n=!0;break}return e.startsWith("__")||!(typeof t=="string"||typeof t=="number"||typeof t=="boolean")||n}function o5(e){let t=e.configurable;if(!t)return;let r={};for(let[n,i]of Object.entries(t))i5(n,i)||(r[n]=i);return Object.keys(r).length>0?r:void 0}var zn=class QD extends xt{lc_graph_name="EphemeralValue";guard;value=[];constructor(t=!0){super(),this.guard=t}fromCheckpoint(t){let r=new QD(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 we("EphemeralValue can only receive one value per step.");return this.value=[t[t.length-1]],!0}get(){if(this.value.length===0)throw new Ue;return this.value[0]}checkpoint(){if(this.value.length===0)throw new Ue;return this.value[0]}isAvailable(){return this.value.length!==0}};var sE=class{path;ends;constructor(e){ce.isRunnable(e.path)?this.path=e.path:this.path=lt(e.path),this.ends=Array.isArray(e.pathMap)?e.pathMap.reduce((t,r)=>(t[r]=r,t),{}):e.pathMap}run(e,t){return ht.registerWriter(new Lt({name:"<branch_run>",trace:!1,func:async(r,n)=>{try{return await this._route(r,n,e,t)}catch(i){throw i.name===Xd.unminifiable_name&&console.warn(`[WARN]: 'NodeInterrupt' thrown in conditional edge. This is likely a bug in your graph implementation.
458
- NodeInterrupt should only be thrown inside a node, not in edge conditions.`),i}}}))}async _route(e,t,r,n){let i=await this.path.invoke(n?n(t):e,t);Array.isArray(i)||(i=[i]);let o;if(this.ends?o=i.map(a=>Et(a)?a:this.ends[a]):o=i,o.some(a=>!a))throw new Error("Branch condition returned unknown or null destination");if(o.filter(Et).some(a=>a.node==="__end__"))throw new we("Cannot send a packet to the END node");return await r(o,t)??e}},cE=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(n){return n.length>=1&&typeof n[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[n,i,o]of r){for(let s of["|",":"])if(n.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."),n in this.nodes)throw new Error(`Node \`${n}\` already present.`);if(n==="__end__")throw new Error(`Node \`${n}\` is reserved.`);let a=lt(i);this.nodes[n]={runnable:a,metadata:o?.metadata,subgraphs:Md(a)?[a]:o?.subgraphs,ends:o?.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 n=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."),ce.isRunnable(n.path)||(n.path=lt(n.path));let i=n.path.getName()==="RunnableLambda"?"condition":n.path.getName();if(this.branches[n.source]&&this.branches[n.source][i])throw new Error(`Condition \`${i}\` already present for node \`${e}\``);return this.branches[n.source]??={},this.branches[n.source][i]=new sE(n),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(Ye,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,nt)}compile({checkpointer:e,interruptBefore:t,interruptAfter:r,name:n,transformers:i}={}){this.validate([...Array.isArray(t)?t:[],...Array.isArray(r)?r:[]]);let o=new uE({builder:this,checkpointer:e,interruptAfter:r,interruptBefore:t,autoValidate:!1,nodes:{},channels:{[Ye]:new zn,[nt]:new zn},inputChannels:Ye,outputChannels:nt,streamChannels:[],streamMode:"values",name:n,streamTransformers:i});for(let[a,s]of Object.entries(this.nodes))o.attachNode(a,s);for(let[a,s]of this.edges)o.attachEdge(a,s);for(let[a,s]of Object.entries(this.branches))for(let[c,u]of Object.entries(s))o.attachBranch(a,c,u);return o.validate()}validate(e){let t=new Set([...this.allEdges].map(([n,i])=>n));for(let[n]of Object.entries(this.branches))t.add(n);for(let n of t)if(n!=="__start__"&&!(n in this.nodes))throw new Error(`Found edge starting at unknown node \`${n}\``);let r=new Set([...this.allEdges].map(([n,i])=>i));for(let[n,i]of Object.entries(this.branches))for(let o of Object.values(i))if(o.ends!=null)for(let a of Object.values(o.ends))r.add(a);else{r.add(nt);for(let a of Object.keys(this.nodes))a!==n&&r.add(a)}for(let n of Object.values(this.nodes))for(let i of n.ends??[])r.add(i);if(Object.values(this.nodes).some(n=>n.isErrorHandler))for(let n of Object.keys(this.nodes))r.add(n);for(let n of Object.keys(this.nodes))if(!this.nodes[n].isErrorHandler&&!r.has(n))throw new r_([`Node \`${n}\` 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(`
459
- `),{lc_error_code:"UNREACHABLE_NODE"});for(let n of r)if(n!=="__end__"&&!(n in this.nodes))throw new Error(`Found edge ending at unknown node \`${n}\``);if(e){for(let n of e)if(!(n in this.nodes))throw new Error(`Interrupt node \`${n}\` is not present`)}this.compiled=!0}},uE=class extends qg{builder;constructor({builder:e,...t}){super(t),this.builder=e}withConfig(e){return super.withConfig(e)}attachNode(e,t){this.channels[e]=new zn,this.nodes[e]=new Mn({channels:[],triggers:[],metadata:t.metadata,subgraphs:t.subgraphs,ends:t.ends}).pipe(t.runnable).pipe(new ht([{channel:e,value:Dr}],[vt])),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 ht([{channel:nt,value:Dr}],[vt]))}else this.nodes[t].triggers.push(e),this.nodes[t].channels.push(e)}attachBranch(e,t,r){e==="__start__"&&!this.nodes.__start__&&(this.nodes[Ye]=YD.subscribeTo(Ye,{tags:[vt]})),this.nodes[e].pipe(r.run(i=>new ht(i.map(o=>Et(o)?o:{channel:o==="__end__"?nt:`branch:${e}:${t}:${o}`,value:Dr}),[vt])));let n=r.ends?Object.values(r.ends):Object.keys(this.nodes);for(let i of n)if(i!=="__end__"){let o=`branch:${e}:${t}:${i}`;this.channels[o]=new zn,this.nodes[i].triggers.push(o),this.nodes[i].channels.push(o)}}async getGraphAsync(e){let t=e?.xray,r=new ks,n={[Ye]:r.addNode({schema:pn.any()},Ye)},i={},o={};t&&(o=Object.fromEntries((await jn(this.getSubgraphsAsync())).filter(u=>e4(u[1]))));let a=[];function s(u,l,d,f=!1){if(l==="__end__"&&i.__end__===void 0&&(i[nt]=r.addNode({schema:pn.any()},nt)),n[u]!==void 0){if(i[l]===void 0)throw new Error(`End node ${l} not found!`);return a.push({src:u,dest:l,conditional:f}),r.addEdge(n[u],i[l],d!==l?d:void 0,f)}}for(let[u,l]of Object.entries(this.builder.nodes)){let d=Nt(u),f=l.runnable,p=l.metadata??{};if(this.interruptBefore?.includes(u)&&this.interruptAfter?.includes(u)?p.__interrupt="before,after":this.interruptBefore?.includes(u)?p.__interrupt="before":this.interruptAfter?.includes(u)&&(p.__interrupt="after"),t){let m=typeof t=="number"?t-1:t,h=o[u]!==void 0?await o[u].getGraphAsync({...e,xray:m}):f.getGraph(e);if(h.trimFirstNode(),h.trimLastNode(),Object.keys(h.nodes).length>1){let w=function(S){return S?S.lc_runnable:!1},x=function(S,E){if(S!==void 0&&!Ei(S))return S;if(w(E))try{let C=E.getName();return C=C.startsWith("Runnable")?C.slice(8):C,C}catch{return E.getName()}else return E.name??"UnknownSchema"},[_,y]=r.extend(h,d);if(_===void 0)throw new Error(`Could not extend subgraph "${u}" due to missing entrypoint.`);y!==void 0&&(n[d]={name:x(y.id,y.data),...y}),i[d]={name:x(_.id,_.data),..._}}else{let _=r.addNode(f,d,p);n[d]=_,i[d]=_}}else{let m=r.addNode(f,d,p);n[d]=m,i[d]=m}}let c=[...this.builder.allEdges].sort(([u],[l])=>u<l?-1:l>u?1:0);for(let[u,l]of c)s(Nt(u),Nt(l));for(let[u,l]of Object.entries(this.builder.branches)){let d={...Object.fromEntries(Object.keys(this.builder.nodes).filter(f=>f!==u).map(f=>[Nt(f),Nt(f)])),[nt]:nt};for(let f of Object.values(l)){let p;f.ends!==void 0?p=f.ends:p=d;for(let[m,h]of Object.entries(p))s(Nt(u),Nt(h),m,!0)}}for(let[u,l]of Object.entries(this.builder.nodes))if(l.ends!==void 0)for(let d of l.ends)s(Nt(u),Nt(d),void 0,!0);return t4(this.builder.nodes,a,s),r}getGraph(e){let t=e?.xray,r=new ks,n={[Ye]:r.addNode({schema:pn.any()},Ye)},i={},o={};t&&(o=Object.fromEntries(ra(this.getSubgraphs()).filter(u=>e4(u[1]))));let a=[];function s(u,l,d,f=!1){if(l==="__end__"&&i.__end__===void 0&&(i[nt]=r.addNode({schema:pn.any()},nt)),n[u]!==void 0){if(i[l]===void 0)throw new Error(`End node ${l} not found!`);return a.push({src:u,dest:l,conditional:f}),r.addEdge(n[u],i[l],d!==l?d:void 0,f)}}for(let[u,l]of Object.entries(this.builder.nodes)){let d=Nt(u),f=l.runnable,p=l.metadata??{};if(this.interruptBefore?.includes(u)&&this.interruptAfter?.includes(u)?p.__interrupt="before,after":this.interruptBefore?.includes(u)?p.__interrupt="before":this.interruptAfter?.includes(u)&&(p.__interrupt="after"),t){let m=typeof t=="number"?t-1:t,h=o[u]!==void 0?o[u].getGraph({...e,xray:m}):f.getGraph(e);if(h.trimFirstNode(),h.trimLastNode(),Object.keys(h.nodes).length>1){let w=function(S){return S?S.lc_runnable:!1},x=function(S,E){if(S!==void 0&&!Ei(S))return S;if(w(E))try{let C=E.getName();return C=C.startsWith("Runnable")?C.slice(8):C,C}catch{return E.getName()}else return E.name??"UnknownSchema"},[_,y]=r.extend(h,d);if(_===void 0)throw new Error(`Could not extend subgraph "${u}" due to missing entrypoint.`);y!==void 0&&(n[d]={name:x(y.id,y.data),...y}),i[d]={name:x(_.id,_.data),..._}}else{let _=r.addNode(f,d,p);n[d]=_,i[d]=_}}else{let m=r.addNode(f,d,p);n[d]=m,i[d]=m}}let c=[...this.builder.allEdges].sort(([u],[l])=>u<l?-1:l>u?1:0);for(let[u,l]of c)s(Nt(u),Nt(l));for(let[u,l]of Object.entries(this.builder.branches)){let d={...Object.fromEntries(Object.keys(this.builder.nodes).filter(f=>f!==u).map(f=>[Nt(f),Nt(f)])),[nt]:nt};for(let f of Object.values(l)){let p;f.ends!==void 0?p=f.ends:p=d;for(let[m,h]of Object.entries(p))s(Nt(u),Nt(h),m,!0)}}for(let[u,l]of Object.entries(this.builder.nodes))if(l.ends!==void 0)for(let d of l.ends)s(Nt(u),Nt(d),void 0,!0);return t4(this.builder.nodes,a,s),r}};function e4(e){return typeof e.attachNode=="function"&&typeof e.attachEdge=="function"}function Nt(e){return e==="subgraph"?`"${e}"`:e}function t4(e,t,r){let n=new Set(t.map(o=>o.src)),i=[...new Set(t.filter(o=>!o.conditional&&o.dest!=="__end__").map(o=>o.dest))].sort();for(let o of i){if(n.has(o))continue;let a=Object.keys(e).find(s=>Nt(s)===o);a!==void 0&&e[a]?.isErrorHandler||r(o,nt)}}function Yi(e){return typeof e=="object"&&e!==null&&"~standard"in e&&typeof e["~standard"]=="object"&&e["~standard"]!==null&&"validate"in e["~standard"]}function lE(e){return typeof e=="object"&&e!==null&&"~standard"in e&&typeof e["~standard"]=="object"&&e["~standard"]!==null&&"jsonSchema"in e["~standard"]}function a5(e){return Yi(e)&&lE(e)}function aa(e){if(lE(e))try{return e["~standard"].jsonSchema.input({target:"draft-07"})}catch{return}}function Qi(e){if(e!=null&&Yi(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 n=r.value;return()=>n}}}catch{}}var s5=e=>e!=null&&e.lc_graph_name==="DeltaChannel",Kg=class r4 extends xt{lc_graph_name="DeltaChannel";value;reducer;snapshotFrequency;initialValueFactory;constructor(t,r){super();let n=r?.snapshotFrequency??1e3;if(!Number.isInteger(n)||n<=0)throw new Error(`snapshotFrequency must be a positive integer, got ${n}`);this.reducer=t,this.snapshotFrequency=n,this.initialValueFactory=r?.initialValueFactory??(()=>[]),this.value=void 0}fromCheckpoint(t){let r=new r4(this.reducer,{snapshotFrequency:this.snapshotFrequency,initialValueFactory:this.initialValueFactory});return t===void 0?r.value=this.initialValueFactory():l_(t)?r.value=t.value:r.value=t,r}replayWrites(t){let r=t.map(a=>a[2]);if(r.length===0)return;let n=this.value,i=0;for(let a=0;a<r.length;a+=1){let[s,c]=_n(r[a]);s&&(n=c??this.initialValueFactory(),i=a+1)}let o=r.slice(i);this.value=o.length>0?this.reducer(n,o):n}update(t){if(t.length===0)return!1;let r,n=!1;for(let o of t)if(ma(o)){if(n)throw new we("Can receive only one Overwrite value per step.");n=!0,[,r]=_n(o)}if(n)return this.value=r??this.initialValueFactory(),!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 Ue;return this.value}checkpoint(){}isAvailable(){return this.value!==void 0}equals(t){return this===t?!0:!s5(t)||this.snapshotFrequency!==t.snapshotFrequency?!1:this.reducer===t.reducer}};var dE=Symbol.for("langgraph.channel.missing"),Jg=class n4 extends xt{lc_graph_name="UntrackedValue";guard;_value=dE;initialValueFactory;constructor(t){super(),this.guard=t?.guard??!0,this.initialValueFactory=t?.initialValueFactory,this.initialValueFactory&&(this._value=this.initialValueFactory())}fromCheckpoint(t){return new n4({guard:this.guard,initialValueFactory:this.initialValueFactory})}update(t){if(t.length===0)return!1;if(t.length!==1&&this.guard)throw new we("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===dE)throw new Ue;return this._value}checkpoint(){}isAvailable(){return this._value!==dE}};var sa=(e,t)=>e.size===t.size&&[...e].every(r=>t.has(r)),fE=class i4 extends xt{lc_graph_name="NamedBarrierValue";names;seen;constructor(t){super(),this.names=t,this.seen=new Set}fromCheckpoint(t){let r=new i4(this.names);return typeof t<"u"&&(r.seen=new Set(t)),r}update(t){let r=!1;for(let n of t)if(this.names.has(n))this.seen.has(n)||(this.seen.add(n),r=!0);else throw new we(`Value ${JSON.stringify(n)} not in names ${JSON.stringify(this.names)}`);return r}get(){if(!sa(this.names,this.seen))throw new Ue}checkpoint(){return[...this.seen]}consume(){return this.seen&&this.names&&sa(this.seen,this.names)?(this.seen=new Set,!0):!1}isAvailable(){return!!this.names&&sa(this.names,this.seen)}},pE=class o4 extends xt{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 o4(this.names);if(typeof t<"u"){let[n,i]=t;r.seen=new Set(n),r.finished=i}return r}update(t){let r=!1;for(let n of t)if(this.names.has(n)&&!this.seen.has(n))this.seen.add(n),r=!0;else if(!this.names.has(n))throw new we(`Value ${JSON.stringify(n)} not in names ${JSON.stringify(this.names)}`);return r}get(){if(!this.finished||!sa(this.names,this.seen))throw new Ue}checkpoint(){return[[...this.seen],this.finished]}consume(){return this.finished&&this.seen&&this.names&&sa(this.seen,this.names)?(this.seen=new Set,this.finished=!1,!0):!1}finish(){return!this.finished&&this.names&&sa(this.names,this.seen)?(this.finished=!0,!0):!1}isAvailable(){return this.finished&&!!this.names&&sa(this.names,this.seen)}};var mE=Symbol.for("langgraph.state.reduced_value"),eo=class{[mE]=!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&&mE in e&&e[mE]===!0}};var a4=Symbol.for("langgraph.state.untracked_value"),Rs=class{[a4]=!0;schema;guard;constructor(e,t){this.schema=e,this.guard=t?.guard??!0}static isInstance(e){return typeof e=="object"&&e!==null&&a4 in e}};var hE=Symbol.for("langgraph.state.delta_value"),to=class{[hE]=!0;valueSchema;inputSchema;reducer;snapshotFrequency;jsonSchemaExtra;constructor(e,t){this.reducer=t.reducer,this.valueSchema=e,this.inputSchema="inputSchema"in t?t.inputSchema:e,this.snapshotFrequency=t.snapshotFrequency,this.jsonSchemaExtra=t.jsonSchemaExtra}static isInstance(e){return typeof e=="object"&&e!==null&&hE in e&&e[hE]===!0}};var gE=Symbol.for("langgraph.state.state_schema"),Un=class{[gE]=!0;constructor(e){this.fields=e}getChannels(){let e={};for(let[t,r]of Object.entries(this.fields))if(to.isInstance(r)){let n=Qi(r.valueSchema);e[t]=new Kg(r.reducer,{snapshotFrequency:r.snapshotFrequency,initialValueFactory:n})}else if(eo.isInstance(r)){let n=Qi(r.valueSchema);e[t]=new Ki(r.reducer,n)}else if(Rs.isInstance(r)){let n=r.schema?Qi(r.schema):void 0;e[t]=new Jg({guard:r.guard,initialValueFactory:n})}else if(Yi(r))e[t]=new Rn(Qi(r));else throw new Error(`Invalid state field "${t}": must be a schema, ReducedValue, DeltaValue, UntrackedValue, or ManagedValue`);return e}getJsonSchema(){let e={},t=[];for(let[r,n]of Object.entries(this.fields)){let i;if(to.isInstance(n)||eo.isInstance(n)?(i=aa(n.valueSchema),n.jsonSchemaExtra&&(i={...i??{},...n.jsonSchemaExtra})):Rs.isInstance(n)?i=n.schema?aa(n.schema):void 0:Yi(n)&&(i=aa(n)),i){e[r]=i;let o=!1;to.isInstance(n)||eo.isInstance(n)?o=Qi(n.valueSchema)!==void 0:Rs.isInstance(n)?o=n.schema?Qi(n.schema)!==void 0:!1:o=Qi(n)!==void 0,o||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 n;to.isInstance(r)||eo.isInstance(r)?(n=aa(r.inputSchema),r.jsonSchemaExtra&&(n={...n??{},...r.jsonSchemaExtra})):Rs.isInstance(r)?n=r.schema?aa(r.schema):void 0:Yi(r)&&(n=aa(r)),n&&(e[t]=n)}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,n]of Object.entries(e)){let i=this.fields[r];if(i===void 0){t[r]=n;continue}let o;if(to.isInstance(i)||eo.isInstance(i)){let[a,s]=_n(n);if(a){o=i.valueSchema;let c=await o["~standard"].validate(s);if(c.issues)throw new Error(`Validation failed for field "${r}": ${JSON.stringify(c.issues)}`);t[r]={[Bn]:c.value};continue}o=i.inputSchema}else Rs.isInstance(i)?o=i.schema:Yi(i)&&(o=i);if(o){let a=await o["~standard"].validate(n);if(a.issues)throw new Error(`Validation failed for field "${r}": ${JSON.stringify(a.issues)}`);t[r]=a.value}else t[r]=n}return t}static isInstance(e){return typeof e=="object"&&e!==null&&gE in e&&e[gE]===!0}};var c5="__remove_all__";function ca(e,t){let r=Array.isArray(e)?e:[e],n=Array.isArray(t)?t:[t],i=r.map(Tt),o=n.map(Tt);for(let l of i)(l.id===null||l.id===void 0)&&(l.id=ho(),l.lc_kwargs.id=l.id);let a;for(let l=0;l<o.length;l+=1){let d=o[l];(d.id===null||d.id===void 0)&&(d.id=ho(),d.lc_kwargs.id=d.id),Vr.isInstance(d)&&d.id==="__remove_all__"&&(a=l)}if(a!=null)return o.slice(a+1);let s=[...i],c=new Map(s.map((l,d)=>[l.id,d])),u=new Set;for(let l of o){let d=c.get(l.id);if(d!==void 0)Vr.isInstance(l)?u.add(l.id):(u.delete(l.id),s[d]=l);else{if(Vr.isInstance(l))throw new Error(`Attempting to delete a message with an ID that doesn't exist ('${l.id}')`);c.set(l.id,s.length),s.push(l)}}return s.filter(l=>!u.has(l.id))}function _E(e,t){let r=[];for(let s of t)Array.isArray(s)?r.push(...s):r.push(s);let n=e.length>0&&Re.isInstance(e[0])?e:e.map(Tt),i=r.map(Tt),o=new Map;for(let s=0;s<n.length;s+=1){let c=n[s].id;c!=null&&o.set(c,s)}let a=[...n];for(let s of i){let c=s.id;Vr.isInstance(s)&&c==="__remove_all__"?(a.length=0,o.clear()):c==null?a.push(s):Vr.isInstance(s)?o.has(c)&&(a[o.get(c)]=null,o.delete(c)):o.has(c)?a[o.get(c)]=s:(o.set(c,a.length),a.push(s))}return a.filter(s=>s!==null)}var s4=pn.custom().default(()=>[]),c4=pn.custom(),u5=new eo(s4,{inputSchema:c4,reducer:ca,jsonSchemaExtra:{langgraph_type:"messages",description:"A list of chat messages"}}),l5=new to(s4,{inputSchema:c4,reducer:_E,jsonSchemaExtra:{langgraph_type:"messages",description:"A list of chat messages"}});var d5=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=Ui(e);for(let[n,i]of Object.entries(r)){let o=this.get(i);o?.reducer?t[n]=new Ki(o.reducer.fn,o.default):t[n]=new Rn(o?.default)}return t}getExtendedChannelSchemas(e,t){if(Object.keys(t).length===0)return e;let r=Object.entries(t).filter(([,o])=>o===!0).sort(([o],[a])=>o.localeCompare(a)).map(([o,a])=>`${o}:${a}`).join("|"),n=this._extensionCache.get(r)??new Map;if(n.has(e))return n.get(e);let i=e;if(t.withReducerSchema||t.withJsonSchemaExtrasAsDescription){let o=Object.entries(Ui(e)).map(([a,s])=>{let c=this.get(s),u=t.withReducerSchema?c?.reducer?.schema??s:s;if(t.withJsonSchemaExtrasAsDescription&&c?.jsonSchemaExtra){let l=Li(u)??Li(s),d=JSON.stringify({...c.jsonSchemaExtra,description:l});u=u.describe(`lg:${d}`)}return[a,u]});i=Nm(e,Object.fromEntries(o)),mt(i)&&(i._def.unknownKeys="strip")}return t.asPartial&&(i=Wo(i)),n.set(e,i),this._extensionCache.set(r,n),i}},Fd=new d5;function u4(e,t){if(t.reducer&&!t.default){let r=Rm(e);r!=null&&(t.default=r)}if(t.reducer){let r=Object.assign(e,{lg_reducer_schema:t.reducer?.schema??e});return Fd.extend(r,()=>t),r}else return Fd.extend(e,()=>t),e}function js(e){return e==null?!1:!!(Un.isInstance(e)||rr(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"||$k(t)))}function l4(e){if(typeof e!="object"||e==null)return!1;let t=e,r="state"in t&&js(t.state),n="stateSchema"in t&&js(t.stateSchema),i="input"in t&&js(t.input);return!(!r&&!n&&!i||"input"in t&&t.input!=null&&!js(t.input)||"output"in t&&t.output!=null&&!js(t.output))}var ro="__root__",Ou="__default_error_handler__",Xg=Symbol.for("langgraph.state.partial"),yE=class extends cE{channels={};waitingEdges=new Set;_schemaDefinition;_schemaRuntimeDefinition;_inputDefinition;_inputRuntimeDefinition;_outputDefinition;_outputRuntimeDefinition;_schemaDefinitions=new Map;_metaRegistry=Fd;_configSchema;_configRuntimeSchema;_interrupt;_writer;_nodeDefaults={};constructor(e,t){super();let r=this._normalizeToStateGraphInit(e,t),n=r.state??r.stateSchema??r.input;if(!n)throw new Du;let i=this._getChannelsFromSchema(n);this._schemaDefinition=i,Un.isInstance(n)?this._schemaRuntimeDefinition=n:rr(n)&&(this._schemaRuntimeDefinition=n),r.input?Un.isInstance(r.input)?this._inputRuntimeDefinition=r.input:rr(r.input)?this._inputRuntimeDefinition=r.input:this._inputRuntimeDefinition=Xg:this._inputRuntimeDefinition=Xg,r.output?Un.isInstance(r.output)?this._outputRuntimeDefinition=r.output:rr(r.output)?this._outputRuntimeDefinition=r.output:this._outputRuntimeDefinition=this._schemaRuntimeDefinition:this._outputRuntimeDefinition=this._schemaRuntimeDefinition;let o=r.input?this._getChannelsFromSchema(r.input):i,a=r.output?this._getChannelsFromSchema(r.output):i;this._inputDefinition=o,this._outputDefinition=a,this._addSchema(this._schemaDefinition),this._addSchema(this._inputDefinition),this._addSchema(this._outputDefinition),r.context&&rr(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=oo(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 Lt({func:(t,r)=>{let n=r?.configurable?.[ju];return e(t,n,r)},name:Ou,trace:!1}),metadata:void 0,input:this._schemaDefinition,retryPolicy:void 0,cachePolicy:void 0,isErrorHandler:!0}}_normalizeToStateGraphInit(e,t){if(l4(e)){if(rr(t)||xg.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(js(e)){if(rr(t)||xg.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(p5(e))return{state:f5(e.channels)};throw new Du}_getChannelsFromSchema(e){if(Un.isInstance(e))return e.getChannels();if(rr(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 Du("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 n;if(typeof r=="function"?n=r():n=r,this.channels[t]!==void 0){if(!this.channels[t].equals(n)&&n.lc_graph_name!=="LastValue")throw new Error(`Channel "${t}" already exists with a different type.`)}else this.channels[t]=n}}}addNode(...e){function t(n){return n.length>=1&&typeof n[0]!="string"}let r=t(e)?Array.isArray(e[0])?e[0]:Object.entries(e[0]).map(([n,i])=>[n,i]):[[e[0],e[1],e[2]]];if(r.length===0)throw new Error("No nodes provided in `addNode`");for(let[n,i,o]of r){if(n in this.channels)throw new Error(`${n} 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(n.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."),n in this.nodes)throw new Error(`Node \`${n}\` already present.`);if(n==="__end__"||n==="__start__")throw new Error(`Node \`${n}\` is reserved.`);let a=this._schemaDefinition;o?.input!==void 0&&(a=this._getChannelsFromSchema(o.input)),this._addSchema(a);let s;ce.isRunnable(i)?s=i:typeof i=="function"?s=new Lt({func:i,name:n,trace:!1}):s=lt(i);let c=o?.cachePolicy,u;c!==void 0&&(u=typeof c=="boolean"?c?{}:!1:c);let l;if(o?.errorHandler!==void 0){if(l=`__error_handler__${n}`,l in this.nodes)throw new Error(`Cannot add error handler to node \`${n}\`: the reserved name \`${l}\` 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=o.errorHandler,p={runnable:new Lt({func:(m,h)=>{let _=h?.configurable?.[ju];return f(m,_,h)},name:l,trace:!1}),metadata:void 0,input:a??this._schemaDefinition,retryPolicy:void 0,cachePolicy:void 0,isErrorHandler:!0};this.nodes[l]=p}let d={runnable:s,retryPolicy:o?.retryPolicy,cachePolicy:u,timeout:oo(o?.timeout),metadata:o?.metadata,input:a??this._schemaDefinition,subgraphs:Md(s)?[s]:o?.subgraphs,ends:o?.ends,defer:o?.defer,errorHandlerNode:l};this.nodes[n]=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(n=>n===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[n,i,o]of t){if(n in this.nodes)throw new Error(`Node names must be unique: node with the name "${n}" already exists.`);let a=n;this.addNode(n,i,o),r!=null&&this.addEdge(r,a),r=a}return this}compile({checkpointer:e,store:t,cache:r,interruptBefore:n,interruptAfter:i,name:o,description:a,transformers:s}={}){let c=this._createDefaultErrorHandlerSpec();if(c!==void 0){if(Ou in this.nodes)throw new Error(`Cannot apply a default error handler: the reserved node name \`${Ou}\` is already in use. setNodeDefaults({ errorHandler }) registers a node with that name; rename the conflicting node.`);this.nodes[Ou]=c}try{return this._compileResolved({checkpointer:e,store:t,cache:r,interruptBefore:n,interruptAfter:i,name:o,description:a,transformers:s,defaultErrorHandlerNode:c!==void 0?Ou:void 0})}finally{c!==void 0&&delete this.nodes[Ou]}}_compileResolved({checkpointer:e,store:t,cache:r,interruptBefore:n,interruptAfter:i,name:o,description:a,transformers:s,defaultErrorHandlerNode:c}){this.validate([...Array.isArray(n)?n:[],...Array.isArray(i)?i:[]]);let u=Object.keys(this._schemaDefinitions.get(this._outputDefinition)),l=u.length===1&&u[0]===ro?ro:u,d=Object.keys(this.channels),f=d.length===1&&d[0]===ro?ro:d,p=this._interrupt,m=new f4({builder:this,checkpointer:e,interruptAfter:i,interruptBefore:n,autoValidate:!1,nodes:{},channels:{...this.channels,[Ye]:new zn},inputChannels:Ye,outputChannels:l,streamChannels:f,streamMode:"updates",store:t,cache:r,name:o,description:a,userInterrupt:p,streamTransformers:s});m.attachNode(Ye);let h=this._nodeDefaults,_=h.retryPolicy!==void 0||h.cachePolicy!==void 0||h.timeout!==void 0||c!==void 0;for(let[y,w]of Object.entries(this.nodes)){let x=w.isErrorHandler===!0,S=_?{...w,retryPolicy:w.retryPolicy??h.retryPolicy,cachePolicy:x||w.cachePolicy===!1?void 0:w.cachePolicy??h.cachePolicy,timeout:w.timeout??h.timeout,errorHandlerNode:!x&&c!==void 0&&w.errorHandlerNode===void 0?c:w.errorHandlerNode}:w;m.attachNode(y,S)}m.attachBranch(Ye,Qg,d4(),{withReader:!1});for(let[y]of Object.entries(this.nodes))m.attachBranch(y,Qg,d4(),{withReader:!1});for(let[y,w]of this.edges)m.attachEdge(y,w);for(let[y,w]of this.waitingEdges)m.attachEdge(y,w);for(let[y,w]of Object.entries(this.branches))for(let[x,S]of Object.entries(w))m.attachBranch(y,x,S);return m.validate()}};function f5(e){let t={};for(let[r,n]of Object.entries(e))r===ro?t[r]=Sg(n):t[r]=Sg(n);return t}var f4=class extends uE{description;_metaRegistry=Fd;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 n(c){if(Rt(c))return c.graph===Ir.PARENT?null:c._updateAsTuples();if(Array.isArray(c)&&c.length>0&&c.some(u=>Rt(u))){let u=[];for(let l of c)if(Rt(l)){if(l.graph===Ir.PARENT)continue;u.push(...l._updateAsTuples())}else u.push([ro,l]);return u}else if(c!=null)return[[ro,c]];return null}let i=e,o=async c=>{if(c==null||c.length===0)return c;let u=this.builder._schemaRuntimeDefinition;if(Un.isInstance(u)){let l=new Set(u.getChannelKeys());return Promise.all(c.map(async([d,f])=>{if(!l.has(d))return[d,f];let p=await u.validateInput({[d]:f});return[d,Object.prototype.hasOwnProperty.call(p,d)?p[d]:f]}))}if(rr(u)){let l=new Set(Object.keys(Ui(u)));if(c.filter(([p])=>l.has(p)).length===0)return c;let d=Wo(this._metaRegistry.getExtendedChannelSchemas(u,{withReducerSchema:!0})),f=Wo(u);return c.map(([p,m])=>{if(!l.has(p))return[p,m];let[h,_]=_n(m);if(h){let w=Go(f,{[p]:_});return[p,Object.prototype.hasOwnProperty.call(w,p)?{[Bn]:w[p]}:m]}let y=Go(d,{[p]:m});return[p,Object.prototype.hasOwnProperty.call(y,p)?y[p]:m]})}return c};async function a(c){if(c){if(Rt(c))return c.graph===Ir.PARENT?null:o(c._updateAsTuples().filter(([u])=>r.includes(u)));if(Array.isArray(c)&&c.length>0&&c.some(Rt)){let u=[];for(let l of c)if(Rt(l)){if(l.graph===Ir.PARENT)continue;u.push(...l._updateAsTuples().filter(([d])=>r.includes(d)))}else{let d=await a(l);d&&u.push(...d??[])}return o(u)}else{if(typeof c=="object"&&!Array.isArray(c))return o(Object.entries(c).filter(([u])=>r.includes(u)));{let u=Array.isArray(c)?"array":typeof c;throw new we(`Expected node "${i.toString()}" to return an object or an array containing at least one Command object, received ${u}`,{lc_error_code:"INVALID_GRAPH_NODE_RETURN_VALUE"})}}}else return null}let s=[{value:Dr,mapper:new Lt({func:r.length&&r[0]===ro?n:a,trace:!1,recurse:!1})}];if(e==="__start__")this.nodes[e]=new Mn({tags:[vt],triggers:[Ye],channels:[Ye],writers:[new ht(s,[vt])]});else{let c=t?.input??this.builder._schemaDefinition,u=Object.fromEntries(Object.keys(this.builder._schemaDefinitions.get(c)).map(m=>[m,m])),l=Object.keys(u).length===1&&ro in u,d=`branch:to:${e}`;this.channels[d]=t?.defer?new Ak:new zn(!1);let f=t?.cachePolicy,p=f===!1?void 0:f;this.nodes[e]=new Mn({triggers:[d],channels:l?Object.keys(u):u,writers:[new ht(s,[vt])],mapper:l?void 0:m=>Object.fromEntries(Object.entries(m).filter(([h])=>h in u)),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 ht([{channel:`branch:to:${t}`,value:null}],[vt]));else if(Array.isArray(e)){let r=`join:${e.join("+")}:${t}`;this.channels[r]=this.builder.nodes[t].defer?new pE(new Set(e)):new fE(new Set(e)),this.nodes[t].triggers.push(r);for(let n of e)this.nodes[n].writers.push(new ht([{channel:r,value:n}],[vt]))}}}attachBranch(e,t,r,n={withReader:!0}){let i=async(o,a)=>{let s=o.filter(u=>u!==nt);if(!s.length)return;let c=s.map(u=>Et(u)?u:{channel:u==="__end__"?u:`branch:to:${u}`,value:e});await ht.doWrite({...a,tags:(a.tags??[]).concat([vt])},c)};this.nodes[e].writers.push(r.run(i,n.withReader?o=>hD.doRead(o,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(Un.isInstance(t)){if(Rt(e)){let i=e;return e.update&&(i.update=await t.validateInput(Array.isArray(e.update)?Object.fromEntries(e.update):e.update)),i}return await t.validateInput(e)}if(t===Xg&&Un.isInstance(r)){if(Rt(e)){let i=e;return e.update&&(i.update=await r.validateInput(Array.isArray(e.update)?Object.fromEntries(e.update):e.update)),i}return await r.validateInput(e)}let n=(()=>{let i=o=>{if(o!=null)return this._metaRegistry.getExtendedChannelSchemas(o,{withReducerSchema:!0})};if(rr(t))return i(t);if(t===Xg)return rr(r)?Wo(i(r)):void 0})();if(Rt(e)){let i=e;if(e.update&&n!=null){let o=Array.isArray(e.update)?Object.fromEntries(e.update):e.update,a=Go(n,o);i.update=Object.fromEntries(Object.keys(o).map(s=>[s,a[s]]))}return i}return n!=null?Go(n,e):e}isInterrupted(e){return ha(e)}async _validateContext(e){let t=this.builder._configRuntimeSchema;return rr(t)&&Go(t,e),e}};function p5(e){return typeof e=="object"&&e!==null&&e.channels!==void 0}function m5(e){if(Et(e))return[e];let t=[];Rt(e)?t.push(e):Array.isArray(e)&&t.push(...e.filter(Rt));let r=[];for(let n of t){if(n.graph===Ir.PARENT)throw new Qd(n);Et(n.goto)||typeof n.goto=="string"?r.push(n.goto):Array.isArray(n.goto)&&r.push(...n.goto)}return r}function d4(){return new sE({path:new Lt({func:m5,tags:[vt],trace:!1,recurse:!1,name:"<control_branch>"})})}var h5=class extends yE{constructor(){super({channels:{__root__:{reducer:ca,default:()=>[]}}})}};function g5(e,t){let{stateKey:r,...n}=t??{},i=Su(n),o=r??"messages";r===null&&(o=void 0);let a=Tt(e);if(!a.id)throw new Error("Message ID is required.");let s=(Array.isArray(i.callbacks)?i.callbacks:typeof i.callbacks<"u"?i.callbacks.handlers:[]).find(c=>"name"in c&&c.name==="StreamMessagesHandler");if(s){let c=i.metadata??{},u=(c.langgraph_checkpoint_ns??"").split("|");s._emit([u,c],a,void 0,!1)}return o&&i.configurable?.__pregel_send?.([[o,a]]),a}function _5(e,t){let r=typeof e=="string"?{name:e,retry:void 0,cachePolicy:void 0,timeout:void 0}:e,{name:n,retry:i}=r,o=oo(r.timeout);if(Wk(t)||qk(t))throw new Error("Generators are disallowed as tasks. For streaming responses, use config.write.");let a=r.cachePolicy??("cache"in r?r.cache:void 0),s;return typeof a=="boolean"?s=a?{}:void 0:s=a,(...c)=>kD({func:t,name:n,retry:i,cache:s,timeout:o},...c)}var p4=function(t,r){let{name:n,checkpointer:i,store:o,cache:a}=typeof t=="string"?{name:t,checkpointer:void 0,store:void 0}:t,s=oo(typeof t=="string"?void 0:t.timeout);if(Wk(r)||qk(r))throw new Error("Generators are disallowed as entrypoints. For streaming responses, use config.write.");let c="updates",u=SD(n,r);function l(m){return typeof m=="object"&&m!==null&&"__lg_type"in m&&m.__lg_type==="__pregel_final"}let d=new Lt({name:"pluckReturnValue",func:m=>l(m)?m.value:m}),f=new Lt({name:"pluckSaveValue",func:m=>l(m)?m.save:m}),p=new Mn({bound:u,triggers:[Ye],channels:[Ye],timeout:s,writers:[new ht([{channel:nt,value:Dr,mapper:d},{channel:lo,value:Dr,mapper:f}],[vt])]});return new qg({name:n,checkpointer:i,nodes:{[n]:p},channels:{[Ye]:new zn,[nt]:new Rn,[lo]:new Rn},inputChannels:Ye,outputChannels:nt,streamChannels:nt,streamMode:c,store:o,cache:a})};p4.final=function({value:t,save:r}){return{value:t,save:r,__lg_type:"__pregel_final"}};function y5(){return Me.getRunnableConfig().configurable?.[so]}var v5=Pd.Root({messages:Pd({reducer:ca,default:()=>[]})}),m4={reducer:{fn:ca},jsonSchemaExtra:{langgraph_type:"messages"},default:()=>[]},b5=Ut.object({messages:u4(Ut.custom(),m4)});function w5(e){let t=Me.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{Ye as a,nt as b,Ve as c,Yg as d,IE as e,da as f,Et as g,_4 as h,ha as i,Ir as j,Rt as k,en as l,qd as m,e_ as n,ga as o,Kd as p,Jd as q,Si as r,Xd as s,Yd as t,v4 as u,Qd as v,t_ as w,fo as x,ki as y,ef as z,b4 as A,tf as B,Ue as C,we as D,w4 as E,r_ as F,x4 as G,Du as H,S4 as I,iI as J,pr as K,J4 as L,Wn as M,mI as N,Bu as O,hI as P,ot as Q,$t as R,Zs as S,je as T,qs as U,ut as V,bn as W,ba as X,xa as Y,Sa as Z,Ti as _,u$ as $,tr as aa,No as ba,Ja as ca,Uo as da,em as ea,tm as fa,as as ga,Je as ha,mt as ia,Pr as ja,Li as ka,Rm as la,U as ma,Ut as na,Ot as oa,ir as pa,eh as qa,M9 as ra,Zl as sa,ch as ta,$0 as ua,A1 as va,C1 as wa,F9 as xa,B9 as ya,A0 as za,Qo as Aa,mh as Ba,ea as Ca,eH as Da,Z0 as Ea,su as Fa,pd as Ga,pS as Ha,pn as Ia,r3 as Ja,s3 as Ka,h3 as La,Cs as Ma,Pn as Na,hg as Oa,HM as Pa,bu as Qa,yg as Ra,WM as Sa,xt as Ta,Ki as Ua,Pd as Va,J3 as Wa,X3 as Xa,kg as Ya,Y3 as Za,Ck as _a,Ok as $a,ku as ab,Pk as bb,hn as cb,$g as db,Mk as eb,Nd as fb,Rd as gb,Dk as hb,zk as ib,Tg as jb,Fk as kb,oD as lb,Bk as mb,Gk as nb,Lt as ob,cE as pb,Yi as qb,a5 as rb,aa as sb,Qi as tb,Kg as ub,Jg as vb,eo as wb,Rs as xb,to as yb,Un as zb,c5 as Ab,ca as Bb,_E as Cb,u5 as Db,l5 as Eb,Fd as Fb,u4 as Gb,yE as Hb,f4 as Ib,h5 as Jb,g5 as Kb,_5 as Lb,p4 as Mb,y5 as Nb,v5 as Ob,m4 as Pb,b5 as Qb,w5 as Rb};