edgeone 1.6.25 → 1.6.27
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.
|
@@ -142,7 +142,7 @@ Read about how to prevent this error on https://github.com/vadimdemedes/ink/#isr
|
|
|
142
142
|
`.repeat(e));Cz.displayName="Newline";Fb.default=Cz});var Iz=J(Lb=>{"use strict";var Dz=Lb&&Lb.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Lb,"__esModule",{value:!0});var Ike=Dz(yo()),Oke=Dz(pC()),kz=()=>Ike.default.createElement(Oke.default,{flexGrow:1});kz.displayName="Spacer";Lb.default=kz});var mC=J(Mb=>{"use strict";var Nke=Mb&&Mb.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Mb,"__esModule",{value:!0});var Rke=yo(),Fke=Nke(kR()),Lke=()=>Rke.useContext(Fke.default);Mb.default=Lke});var Nz=J(Bb=>{"use strict";var Mke=Bb&&Bb.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Bb,"__esModule",{value:!0});var Oz=yo(),Bke=Mke(mC()),jke=(e,t={})=>{let{stdin:r,setRawMode:s,internal_exitOnCtrlC:a}=Bke.default();Oz.useEffect(()=>{if(t.isActive!==!1)return s(!0),()=>{s(!1)}},[t.isActive,s]),Oz.useEffect(()=>{if(t.isActive===!1)return;let n=l=>{let f=String(l),m={upArrow:f==="\x1B[A",downArrow:f==="\x1B[B",leftArrow:f==="\x1B[D",rightArrow:f==="\x1B[C",pageDown:f==="\x1B[6~",pageUp:f==="\x1B[5~",return:f==="\r",escape:f==="\x1B",ctrl:!1,shift:!1,tab:f===" "||f==="\x1B[Z",backspace:f==="\b",delete:f==="\x7F"||f==="\x1B[3~",meta:!1};f<=""&&!m.return&&(f=String.fromCharCode(f.charCodeAt(0)+97-1),m.ctrl=!0),f.startsWith("\x1B")&&(f=f.slice(1),m.meta=!0);let y=f>="A"&&f<="Z",v=f>="\u0410"&&f<="\u042F";f.length===1&&(y||v)&&(m.shift=!0),m.tab&&f==="[Z"&&(m.shift=!0),(m.tab||m.backspace||m.delete)&&(f=""),(!(f==="c"&&m.ctrl)||!a)&&e(f,m)};return r==null||r.on("data",n),()=>{r==null||r.off("data",n)}},[t.isActive,r,a,e])};Bb.default=jke});var Rz=J(jb=>{"use strict";var qke=jb&&jb.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(jb,"__esModule",{value:!0});var Uke=yo(),$ke=qke(AR()),Vke=()=>Uke.useContext($ke.default);jb.default=Vke});var Fz=J(qb=>{"use strict";var Hke=qb&&qb.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(qb,"__esModule",{value:!0});var Wke=yo(),zke=Hke(OR()),Gke=()=>Wke.useContext(zke.default);qb.default=Gke});var Lz=J(Ub=>{"use strict";var Kke=Ub&&Ub.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Ub,"__esModule",{value:!0});var Yke=yo(),Jke=Kke(RR()),Xke=()=>Yke.useContext(Jke.default);Ub.default=Xke});var Bz=J(Vb=>{"use strict";var Mz=Vb&&Vb.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Vb,"__esModule",{value:!0});var $b=yo(),Qke=Mz(lC()),Zke=Mz(mC()),eIe=({isActive:e=!0,autoFocus:t=!1,id:r}={})=>{let{isRawModeSupported:s,setRawMode:a}=Zke.default(),{activeId:n,add:l,remove:f,activate:m,deactivate:y,focus:v}=$b.useContext(Qke.default),b=$b.useMemo(()=>r!=null?r:Math.random().toString().slice(2,7),[r]);return $b.useEffect(()=>(l(b,{autoFocus:t}),()=>{f(b)}),[b,t]),$b.useEffect(()=>{e?m(b):y(b)},[e,b]),$b.useEffect(()=>{if(!(!s||!e))return a(!0),()=>{a(!1)}},[e]),{isFocused:!!b&&n===b,focus:v}};Vb.default=eIe});var jz=J(Hb=>{"use strict";var tIe=Hb&&Hb.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Hb,"__esModule",{value:!0});var rIe=yo(),nIe=tIe(lC()),iIe=()=>{let e=rIe.useContext(nIe.default);return{enableFocus:e.enableFocus,disableFocus:e.disableFocus,focusNext:e.focusNext,focusPrevious:e.focusPrevious,focus:e.focus}};Hb.default=iIe});var qz=J($R=>{"use strict";Object.defineProperty($R,"__esModule",{value:!0});$R.default=e=>{var t,r,s,a;return{width:(r=(t=e.yogaNode)===null||t===void 0?void 0:t.getComputedWidth())!==null&&r!==void 0?r:0,height:(a=(s=e.yogaNode)===null||s===void 0?void 0:s.getComputedHeight())!==null&&a!==void 0?a:0}}});var yC=J(pc=>{"use strict";Object.defineProperty(pc,"__esModule",{value:!0});var sIe=bz();Object.defineProperty(pc,"render",{enumerable:!0,get:function(){return sIe.default}});var oIe=pC();Object.defineProperty(pc,"Box",{enumerable:!0,get:function(){return oIe.default}});var aIe=qR();Object.defineProperty(pc,"Text",{enumerable:!0,get:function(){return aIe.default}});var uIe=wz();Object.defineProperty(pc,"Static",{enumerable:!0,get:function(){return uIe.default}});var cIe=Pz();Object.defineProperty(pc,"Transform",{enumerable:!0,get:function(){return cIe.default}});var lIe=Az();Object.defineProperty(pc,"Newline",{enumerable:!0,get:function(){return lIe.default}});var pIe=Iz();Object.defineProperty(pc,"Spacer",{enumerable:!0,get:function(){return pIe.default}});var fIe=Nz();Object.defineProperty(pc,"useInput",{enumerable:!0,get:function(){return fIe.default}});var dIe=Rz();Object.defineProperty(pc,"useApp",{enumerable:!0,get:function(){return dIe.default}});var hIe=mC();Object.defineProperty(pc,"useStdin",{enumerable:!0,get:function(){return hIe.default}});var mIe=Fz();Object.defineProperty(pc,"useStdout",{enumerable:!0,get:function(){return mIe.default}});var yIe=Lz();Object.defineProperty(pc,"useStderr",{enumerable:!0,get:function(){return yIe.default}});var gIe=Bz();Object.defineProperty(pc,"useFocus",{enumerable:!0,get:function(){return gIe.default}});var vIe=jz();Object.defineProperty(pc,"useFocusManager",{enumerable:!0,get:function(){return vIe.default}});var xIe=qz();Object.defineProperty(pc,"measureElement",{enumerable:!0,get:function(){return xIe.default}})});var Uz=J((VR,_2)=>{(function(e,t){typeof VR=="object"&&typeof _2<"u"?_2.exports=t():typeof define=="function"&&define.amd?define(t):e.moment=t()})(VR,function(){"use strict";var e;function t(){return e.apply(null,arguments)}function r(E){e=E}function s(E){return E instanceof Array||Object.prototype.toString.call(E)==="[object Array]"}function a(E){return E!=null&&Object.prototype.toString.call(E)==="[object Object]"}function n(E,I){return Object.prototype.hasOwnProperty.call(E,I)}function l(E){if(Object.getOwnPropertyNames)return Object.getOwnPropertyNames(E).length===0;var I;for(I in E)if(n(E,I))return!1;return!0}function f(E){return E===void 0}function m(E){return typeof E=="number"||Object.prototype.toString.call(E)==="[object Number]"}function y(E){return E instanceof Date||Object.prototype.toString.call(E)==="[object Date]"}function v(E,I){var q=[],z,ee=E.length;for(z=0;z<ee;++z)q.push(I(E[z],z));return q}function b(E,I){for(var q in I)n(I,q)&&(E[q]=I[q]);return n(I,"toString")&&(E.toString=I.toString),n(I,"valueOf")&&(E.valueOf=I.valueOf),E}function P(E,I,q,z){return Yh(E,I,q,z,!0).utc()}function k(){return{empty:!1,unusedTokens:[],unusedInput:[],overflow:-2,charsLeftOver:0,nullInput:!1,invalidEra:null,invalidMonth:null,invalidFormat:!1,userInvalidated:!1,iso:!1,parsedDateParts:[],era:null,meridiem:null,rfc2822:!1,weekdayMismatch:!1}}function g(E){return E._pf==null&&(E._pf=k()),E._pf}var B;Array.prototype.some?B=Array.prototype.some:B=function(E){var I=Object(this),q=I.length>>>0,z;for(z=0;z<q;z++)if(z in I&&E.call(this,I[z],z,I))return!0;return!1};function F(E){var I=null,q=!1,z=E._d&&!isNaN(E._d.getTime());if(z&&(I=g(E),q=B.call(I.parsedDateParts,function(ee){return ee!=null}),z=I.overflow<0&&!I.empty&&!I.invalidEra&&!I.invalidMonth&&!I.invalidWeekday&&!I.weekdayMismatch&&!I.nullInput&&!I.invalidFormat&&!I.userInvalidated&&(!I.meridiem||I.meridiem&&q),E._strict&&(z=z&&I.charsLeftOver===0&&I.unusedTokens.length===0&&I.bigHour===void 0)),Object.isFrozen==null||!Object.isFrozen(E))E._isValid=z;else return z;return E._isValid}function M(E){var I=P(NaN);return E!=null?b(g(I),E):g(I).userInvalidated=!0,I}var G=t.momentProperties=[],oe=!1;function te(E,I){var q,z,ee,ke=G.length;if(f(I._isAMomentObject)||(E._isAMomentObject=I._isAMomentObject),f(I._i)||(E._i=I._i),f(I._f)||(E._f=I._f),f(I._l)||(E._l=I._l),f(I._strict)||(E._strict=I._strict),f(I._tzm)||(E._tzm=I._tzm),f(I._isUTC)||(E._isUTC=I._isUTC),f(I._offset)||(E._offset=I._offset),f(I._pf)||(E._pf=g(I)),f(I._locale)||(E._locale=I._locale),ke>0)for(q=0;q<ke;q++)z=G[q],ee=I[z],f(ee)||(E[z]=ee);return E}function me(E){te(this,E),this._d=new Date(E._d!=null?E._d.getTime():NaN),this.isValid()||(this._d=new Date(NaN)),oe===!1&&(oe=!0,t.updateOffset(this),oe=!1)}function Ce(E){return E instanceof me||E!=null&&E._isAMomentObject!=null}function Ie(E){t.suppressDeprecationWarnings===!1&&typeof console<"u"&&console.warn&&console.warn("Deprecation warning: "+E)}function Ve(E,I){var q=!0;return b(function(){if(t.deprecationHandler!=null&&t.deprecationHandler(null,E),q){var z=[],ee,ke,xt,fr=arguments.length;for(ke=0;ke<fr;ke++){if(ee="",typeof arguments[ke]=="object"){ee+=`
|
|
143
143
|
[`+ke+"] ";for(xt in arguments[0])n(arguments[0],xt)&&(ee+=xt+": "+arguments[0][xt]+", ");ee=ee.slice(0,-2)}else ee=arguments[ke];z.push(ee)}Ie(E+`
|
|
144
144
|
Arguments: `+Array.prototype.slice.call(z).join("")+`
|
|
145
|
-
`+new Error().stack),q=!1}return I.apply(this,arguments)},I)}var Re={};function Ct(E,I){t.deprecationHandler!=null&&t.deprecationHandler(E,I),Re[E]||(Ie(I),Re[E]=!0)}t.suppressDeprecationWarnings=!1,t.deprecationHandler=null;function ct(E){return typeof Function<"u"&&E instanceof Function||Object.prototype.toString.call(E)==="[object Function]"}function ot(E){var I,q;for(q in E)n(E,q)&&(I=E[q],ct(I)?this[q]=I:this["_"+q]=I);this._config=E,this._dayOfMonthOrdinalParseLenient=new RegExp((this._dayOfMonthOrdinalParse.source||this._ordinalParse.source)+"|"+/\d{1,2}/.source)}function je(E,I){var q=b({},E),z;for(z in I)n(I,z)&&(a(E[z])&&a(I[z])?(q[z]={},b(q[z],E[z]),b(q[z],I[z])):I[z]!=null?q[z]=I[z]:delete q[z]);for(z in E)n(E,z)&&!n(I,z)&&a(E[z])&&(q[z]=b({},q[z]));return q}function se(E){E!=null&&this.set(E)}var De;Object.keys?De=Object.keys:De=function(E){var I,q=[];for(I in E)n(E,I)&&q.push(I);return q};var ze={sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"};function _e(E,I,q){var z=this._calendar[E]||this._calendar.sameElse;return ct(z)?z.call(I,q):z}function Ee(E,I,q){var z=""+Math.abs(E),ee=I-z.length,ke=E>=0;return(ke?q?"+":"":"-")+Math.pow(10,Math.max(0,ee)).toString().substr(1)+z}var Fe=/(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|N{1,5}|YYYYYY|YYYYY|YYYY|YY|y{2,4}|yo?|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g,nt=/(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g,vt={},jt={};function Ye(E,I,q,z){var ee=z;typeof z=="string"&&(ee=function(){return this[z]()}),E&&(jt[E]=ee),I&&(jt[I[0]]=function(){return Ee(ee.apply(this,arguments),I[1],I[2])}),q&&(jt[q]=function(){return this.localeData().ordinal(ee.apply(this,arguments),E)})}function At(E){return E.match(/\[[\s\S]/)?E.replace(/^\[|\]$/g,""):E.replace(/\\/g,"")}function Ae(E){var I=E.match(Fe),q,z;for(q=0,z=I.length;q<z;q++)jt[I[q]]?I[q]=jt[I[q]]:I[q]=At(I[q]);return function(ee){var ke="",xt;for(xt=0;xt<z;xt++)ke+=ct(I[xt])?I[xt].call(ee,E):I[xt];return ke}}function Ze(E,I){return E.isValid()?(I=lt(I,E.localeData()),vt[I]=vt[I]||Ae(I),vt[I](E)):E.localeData().invalidDate()}function lt(E,I){var q=5;function z(ee){return I.longDateFormat(ee)||ee}for(nt.lastIndex=0;q>=0&&nt.test(E);)E=E.replace(nt,z),nt.lastIndex=0,q-=1;return E}var Ut={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"};function Tt(E){var I=this._longDateFormat[E],q=this._longDateFormat[E.toUpperCase()];return I||!q?I:(this._longDateFormat[E]=q.match(Fe).map(function(z){return z==="MMMM"||z==="MM"||z==="DD"||z==="dddd"?z.slice(1):z}).join(""),this._longDateFormat[E])}var ft="Invalid date";function mt(){return this._invalidDate}var C="%d",kt=/\d{1,2}/;function Yt(E){return this._ordinal.replace("%d",E)}var Jr={future:"in %s",past:"%s ago",s:"a few seconds",ss:"%d seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",w:"a week",ww:"%d weeks",M:"a month",MM:"%d months",y:"a year",yy:"%d years"};function _t(E,I,q,z){var ee=this._relativeTime[q];return ct(ee)?ee(E,I,q,z):ee.replace(/%d/i,E)}function bt(E,I){var q=this._relativeTime[E>0?"future":"past"];return ct(q)?q(I):q.replace(/%s/i,I)}var tr={D:"date",dates:"date",date:"date",d:"day",days:"day",day:"day",e:"weekday",weekdays:"weekday",weekday:"weekday",E:"isoWeekday",isoweekdays:"isoWeekday",isoweekday:"isoWeekday",DDD:"dayOfYear",dayofyears:"dayOfYear",dayofyear:"dayOfYear",h:"hour",hours:"hour",hour:"hour",ms:"millisecond",milliseconds:"millisecond",millisecond:"millisecond",m:"minute",minutes:"minute",minute:"minute",M:"month",months:"month",month:"month",Q:"quarter",quarters:"quarter",quarter:"quarter",s:"second",seconds:"second",second:"second",gg:"weekYear",weekyears:"weekYear",weekyear:"weekYear",GG:"isoWeekYear",isoweekyears:"isoWeekYear",isoweekyear:"isoWeekYear",w:"week",weeks:"week",week:"week",W:"isoWeek",isoweeks:"isoWeek",isoweek:"isoWeek",y:"year",years:"year",year:"year"};function ge(E){return typeof E=="string"?tr[E]||tr[E.toLowerCase()]:void 0}function Je(E){var I={},q,z;for(z in E)n(E,z)&&(q=ge(z),q&&(I[q]=E[z]));return I}var $t={date:9,day:11,weekday:11,isoWeekday:11,dayOfYear:4,hour:13,millisecond:16,minute:14,month:8,quarter:7,second:15,weekYear:1,isoWeekYear:1,week:5,isoWeek:5,year:1};function rr(E){var I=[],q;for(q in E)n(E,q)&&I.push({unit:q,priority:$t[q]});return I.sort(function(z,ee){return z.priority-ee.priority}),I}var $r=/\d/,Vr=/\d\d/,Hn=/\d{3}/,jn=/\d{4}/,ei=/[+-]?\d{6}/,En=/\d\d?/,$o=/\d\d\d\d?/,Qo=/\d\d\d\d\d\d?/,ps=/\d{1,3}/,Vo=/\d{1,4}/,Vu=/[+-]?\d{1,6}/,za=/\d+/,rt=/[+-]?\d+/,Ft=/Z|[+-]\d\d:?\d\d/gi,It=/Z|[+-]\d\d(?::?\d\d)?/gi,Xt=/[+-]?\d+(\.\d{1,3})?/,Ir=/[0-9]{0,256}['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFF07\uFF10-\uFFEF]{1,256}|[\u0600-\u06FF\/]{1,256}(\s*?[\u0600-\u06FF]{1,256}){1,2}/i,xr=/^[1-9]\d?/,In=/^([1-9]\d|\d)/,_i;_i={};function Mt(E,I,q){_i[E]=ct(I)?I:function(z,ee){return z&&q?q:I}}function Ai(E,I){return n(_i,E)?_i[E](I._strict,I._locale):new RegExp(Ps(E))}function Ps(E){return Di(E.replace("\\","").replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,function(I,q,z,ee,ke){return q||z||ee||ke}))}function Di(E){return E.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}function Si(E){return E<0?Math.ceil(E)||0:Math.floor(E)}function sn(E){var I=+E,q=0;return I!==0&&isFinite(I)&&(q=Si(I)),q}var Ws={};function On(E,I){var q,z=I,ee;for(typeof E=="string"&&(E=[E]),m(I)&&(z=function(ke,xt){xt[I]=sn(ke)}),ee=E.length,q=0;q<ee;q++)Ws[E[q]]=z}function Ss(E,I){On(E,function(q,z,ee,ke){ee._w=ee._w||{},I(q,ee._w,ee,ke)})}function Hu(E,I,q){I!=null&&n(Ws,E)&&Ws[E](I,q._a,q,E)}function to(E){return E%4===0&&E%100!==0||E%400===0}var ur=0,Ao=1,co=2,Cs=3,Do=4,lo=5,js=6,Zc=7,fu=8;Ye("Y",0,0,function(){var E=this.year();return E<=9999?Ee(E,4):"+"+E}),Ye(0,["YY",2],0,function(){return this.year()%100}),Ye(0,["YYYY",4],0,"year"),Ye(0,["YYYYY",5],0,"year"),Ye(0,["YYYYYY",6,!0],0,"year"),Mt("Y",rt),Mt("YY",En,Vr),Mt("YYYY",Vo,jn),Mt("YYYYY",Vu,ei),Mt("YYYYYY",Vu,ei),On(["YYYYY","YYYYYY"],ur),On("YYYY",function(E,I){I[ur]=E.length===2?t.parseTwoDigitYear(E):sn(E)}),On("YY",function(E,I){I[ur]=t.parseTwoDigitYear(E)}),On("Y",function(E,I){I[ur]=parseInt(E,10)});function Oa(E){return to(E)?366:365}t.parseTwoDigitYear=function(E){return sn(E)+(sn(E)>68?1900:2e3)};var Wu=tn("FullYear",!0);function Fl(){return to(this.year())}function tn(E,I){return function(q){return q!=null?(el(this,E,q),t.updateOffset(this,I),this):vc(this,E)}}function vc(E,I){if(!E.isValid())return NaN;var q=E._d,z=E._isUTC;switch(I){case"Milliseconds":return z?q.getUTCMilliseconds():q.getMilliseconds();case"Seconds":return z?q.getUTCSeconds():q.getSeconds();case"Minutes":return z?q.getUTCMinutes():q.getMinutes();case"Hours":return z?q.getUTCHours():q.getHours();case"Date":return z?q.getUTCDate():q.getDate();case"Day":return z?q.getUTCDay():q.getDay();case"Month":return z?q.getUTCMonth():q.getMonth();case"FullYear":return z?q.getUTCFullYear():q.getFullYear();default:return NaN}}function el(E,I,q){var z,ee,ke,xt,fr;if(!(!E.isValid()||isNaN(q))){switch(z=E._d,ee=E._isUTC,I){case"Milliseconds":return void(ee?z.setUTCMilliseconds(q):z.setMilliseconds(q));case"Seconds":return void(ee?z.setUTCSeconds(q):z.setSeconds(q));case"Minutes":return void(ee?z.setUTCMinutes(q):z.setMinutes(q));case"Hours":return void(ee?z.setUTCHours(q):z.setHours(q));case"Date":return void(ee?z.setUTCDate(q):z.setDate(q));case"FullYear":break;default:return}ke=q,xt=E.month(),fr=E.date(),fr=fr===29&&xt===1&&!to(ke)?28:fr,ee?z.setUTCFullYear(ke,xt,fr):z.setFullYear(ke,xt,fr)}}function du(E){return E=ge(E),ct(this[E])?this[E]():this}function fs(E,I){if(typeof E=="object"){E=Je(E);var q=rr(E),z,ee=q.length;for(z=0;z<ee;z++)this[q[z].unit](E[q[z].unit])}else if(E=ge(E),ct(this[E]))return this[E](I);return this}function Ji(E,I){return(E%I+I)%I}var Bi;Array.prototype.indexOf?Bi=Array.prototype.indexOf:Bi=function(E){var I;for(I=0;I<this.length;++I)if(this[I]===E)return I;return-1};function zs(E,I){if(isNaN(E)||isNaN(I))return NaN;var q=Ji(I,12);return E+=(I-q)/12,q===1?to(E)?29:28:31-q%7%2}Ye("M",["MM",2],"Mo",function(){return this.month()+1}),Ye("MMM",0,0,function(E){return this.localeData().monthsShort(this,E)}),Ye("MMMM",0,0,function(E){return this.localeData().months(this,E)}),Mt("M",En,xr),Mt("MM",En,Vr),Mt("MMM",function(E,I){return I.monthsShortRegex(E)}),Mt("MMMM",function(E,I){return I.monthsRegex(E)}),On(["M","MM"],function(E,I){I[Ao]=sn(E)-1}),On(["MMM","MMMM"],function(E,I,q,z){var ee=q._locale.monthsParse(E,z,q._strict);ee!=null?I[Ao]=ee:g(q).invalidMonth=E});var ko="January_February_March_April_May_June_July_August_September_October_November_December".split("_"),Na="Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),Zo=/D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/,Io=Ir,Ll=Ir;function Z0(E,I){return E?s(this._months)?this._months[E.month()]:this._months[(this._months.isFormat||Zo).test(I)?"format":"standalone"][E.month()]:s(this._months)?this._months:this._months.standalone}function kp(E,I){return E?s(this._monthsShort)?this._monthsShort[E.month()]:this._monthsShort[Zo.test(I)?"format":"standalone"][E.month()]:s(this._monthsShort)?this._monthsShort:this._monthsShort.standalone}function Ml(E,I,q){var z,ee,ke,xt=E.toLocaleLowerCase();if(!this._monthsParse)for(this._monthsParse=[],this._longMonthsParse=[],this._shortMonthsParse=[],z=0;z<12;++z)ke=P([2e3,z]),this._shortMonthsParse[z]=this.monthsShort(ke,"").toLocaleLowerCase(),this._longMonthsParse[z]=this.months(ke,"").toLocaleLowerCase();return q?I==="MMM"?(ee=Bi.call(this._shortMonthsParse,xt),ee!==-1?ee:null):(ee=Bi.call(this._longMonthsParse,xt),ee!==-1?ee:null):I==="MMM"?(ee=Bi.call(this._shortMonthsParse,xt),ee!==-1?ee:(ee=Bi.call(this._longMonthsParse,xt),ee!==-1?ee:null)):(ee=Bi.call(this._longMonthsParse,xt),ee!==-1?ee:(ee=Bi.call(this._shortMonthsParse,xt),ee!==-1?ee:null))}function ga(E,I,q){var z,ee,ke;if(this._monthsParseExact)return Ml.call(this,E,I,q);for(this._monthsParse||(this._monthsParse=[],this._longMonthsParse=[],this._shortMonthsParse=[]),z=0;z<12;z++){if(ee=P([2e3,z]),q&&!this._longMonthsParse[z]&&(this._longMonthsParse[z]=new RegExp("^"+this.months(ee,"").replace(".","")+"$","i"),this._shortMonthsParse[z]=new RegExp("^"+this.monthsShort(ee,"").replace(".","")+"$","i")),!q&&!this._monthsParse[z]&&(ke="^"+this.months(ee,"")+"|^"+this.monthsShort(ee,""),this._monthsParse[z]=new RegExp(ke.replace(".",""),"i")),q&&I==="MMMM"&&this._longMonthsParse[z].test(E))return z;if(q&&I==="MMM"&&this._shortMonthsParse[z].test(E))return z;if(!q&&this._monthsParse[z].test(E))return z}}function qt(E,I){if(!E.isValid())return E;if(typeof I=="string"){if(/^\d+$/.test(I))I=sn(I);else if(I=E.localeData().monthsParse(I),!m(I))return E}var q=I,z=E.date();return z=z<29?z:Math.min(z,zs(E.year(),q)),E._isUTC?E._d.setUTCMonth(q,z):E._d.setMonth(q,z),E}function hu(E){return E!=null?(qt(this,E),t.updateOffset(this,!0),this):vc(this,"Month")}function em(){return zs(this.year(),this.month())}function Ip(E){return this._monthsParseExact?(n(this,"_monthsRegex")||xc.call(this),E?this._monthsShortStrictRegex:this._monthsShortRegex):(n(this,"_monthsShortRegex")||(this._monthsShortRegex=Io),this._monthsShortStrictRegex&&E?this._monthsShortStrictRegex:this._monthsShortRegex)}function ns(E){return this._monthsParseExact?(n(this,"_monthsRegex")||xc.call(this),E?this._monthsStrictRegex:this._monthsRegex):(n(this,"_monthsRegex")||(this._monthsRegex=Ll),this._monthsStrictRegex&&E?this._monthsStrictRegex:this._monthsRegex)}function xc(){function E(dn,fi){return fi.length-dn.length}var I=[],q=[],z=[],ee,ke,xt,fr;for(ee=0;ee<12;ee++)ke=P([2e3,ee]),xt=Di(this.monthsShort(ke,"")),fr=Di(this.months(ke,"")),I.push(xt),q.push(fr),z.push(fr),z.push(xt);I.sort(E),q.sort(E),z.sort(E),this._monthsRegex=new RegExp("^("+z.join("|")+")","i"),this._monthsShortRegex=this._monthsRegex,this._monthsStrictRegex=new RegExp("^("+q.join("|")+")","i"),this._monthsShortStrictRegex=new RegExp("^("+I.join("|")+")","i")}function Vh(E,I,q,z,ee,ke,xt){var fr;return E<100&&E>=0?(fr=new Date(E+400,I,q,z,ee,ke,xt),isFinite(fr.getFullYear())&&fr.setFullYear(E)):fr=new Date(E,I,q,z,ee,ke,xt),fr}function Sf(E){var I,q;return E<100&&E>=0?(q=Array.prototype.slice.call(arguments),q[0]=E+400,I=new Date(Date.UTC.apply(null,q)),isFinite(I.getUTCFullYear())&&I.setUTCFullYear(E)):I=new Date(Date.UTC.apply(null,arguments)),I}function tl(E,I,q){var z=7+I-q,ee=(7+Sf(E,0,z).getUTCDay()-I)%7;return-ee+z-1}function Od(E,I,q,z,ee){var ke=(7+q-z)%7,xt=tl(E,z,ee),fr=1+7*(I-1)+ke+xt,dn,fi;return fr<=0?(dn=E-1,fi=Oa(dn)+fr):fr>Oa(E)?(dn=E+1,fi=fr-Oa(E)):(dn=E,fi=fr),{year:dn,dayOfYear:fi}}function or(E,I,q){var z=tl(E.year(),I,q),ee=Math.floor((E.dayOfYear()-z-1)/7)+1,ke,xt;return ee<1?(xt=E.year()-1,ke=ee+ji(xt,I,q)):ee>ji(E.year(),I,q)?(ke=ee-ji(E.year(),I,q),xt=E.year()+1):(xt=E.year(),ke=ee),{week:ke,year:xt}}function ji(E,I,q){var z=tl(E,I,q),ee=tl(E+1,I,q);return(Oa(E)-z+ee)/7}Ye("w",["ww",2],"wo","week"),Ye("W",["WW",2],"Wo","isoWeek"),Mt("w",En,xr),Mt("ww",En,Vr),Mt("W",En,xr),Mt("WW",En,Vr),Ss(["w","ww","W","WW"],function(E,I,q,z){I[z.substr(0,1)]=sn(E)});function Nd(E){return or(E,this._week.dow,this._week.doy).week}var Bl={dow:0,doy:6};function mu(){return this._week.dow}function bf(){return this._week.doy}function tm(E){var I=this.localeData().week(this);return E==null?I:this.add((E-I)*7,"d")}function Hh(E){var I=or(this,1,4).week;return E==null?I:this.add((E-I)*7,"d")}Ye("d",0,"do","day"),Ye("dd",0,0,function(E){return this.localeData().weekdaysMin(this,E)}),Ye("ddd",0,0,function(E){return this.localeData().weekdaysShort(this,E)}),Ye("dddd",0,0,function(E){return this.localeData().weekdays(this,E)}),Ye("e",0,0,"weekday"),Ye("E",0,0,"isoWeekday"),Mt("d",En),Mt("e",En),Mt("E",En),Mt("dd",function(E,I){return I.weekdaysMinRegex(E)}),Mt("ddd",function(E,I){return I.weekdaysShortRegex(E)}),Mt("dddd",function(E,I){return I.weekdaysRegex(E)}),Ss(["dd","ddd","dddd"],function(E,I,q,z){var ee=q._locale.weekdaysParse(E,z,q._strict);ee!=null?I.d=ee:g(q).invalidWeekday=E}),Ss(["d","e","E"],function(E,I,q,z){I[z]=sn(E)});function rm(E,I){return typeof E!="string"?E:isNaN(E)?(E=I.weekdaysParse(E),typeof E=="number"?E:null):parseInt(E,10)}function Ra(E,I){return typeof E=="string"?I.weekdaysParse(E)%7||7:isNaN(E)?null:E}function Fa(E,I){return E.slice(I,7).concat(E.slice(0,I))}var Wh="Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),zh="Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),Op="Su_Mo_Tu_We_Th_Fr_Sa".split("_"),ea=Ir,Np=Ir,La=Ir;function rl(E,I){var q=s(this._weekdays)?this._weekdays:this._weekdays[E&&E!==!0&&this._weekdays.isFormat.test(I)?"format":"standalone"];return E===!0?Fa(q,this._week.dow):E?q[E.day()]:q}function yu(E){return E===!0?Fa(this._weekdaysShort,this._week.dow):E?this._weekdaysShort[E.day()]:this._weekdaysShort}function zu(E){return E===!0?Fa(this._weekdaysMin,this._week.dow):E?this._weekdaysMin[E.day()]:this._weekdaysMin}function _c(E,I,q){var z,ee,ke,xt=E.toLocaleLowerCase();if(!this._weekdaysParse)for(this._weekdaysParse=[],this._shortWeekdaysParse=[],this._minWeekdaysParse=[],z=0;z<7;++z)ke=P([2e3,1]).day(z),this._minWeekdaysParse[z]=this.weekdaysMin(ke,"").toLocaleLowerCase(),this._shortWeekdaysParse[z]=this.weekdaysShort(ke,"").toLocaleLowerCase(),this._weekdaysParse[z]=this.weekdays(ke,"").toLocaleLowerCase();return q?I==="dddd"?(ee=Bi.call(this._weekdaysParse,xt),ee!==-1?ee:null):I==="ddd"?(ee=Bi.call(this._shortWeekdaysParse,xt),ee!==-1?ee:null):(ee=Bi.call(this._minWeekdaysParse,xt),ee!==-1?ee:null):I==="dddd"?(ee=Bi.call(this._weekdaysParse,xt),ee!==-1||(ee=Bi.call(this._shortWeekdaysParse,xt),ee!==-1)?ee:(ee=Bi.call(this._minWeekdaysParse,xt),ee!==-1?ee:null)):I==="ddd"?(ee=Bi.call(this._shortWeekdaysParse,xt),ee!==-1||(ee=Bi.call(this._weekdaysParse,xt),ee!==-1)?ee:(ee=Bi.call(this._minWeekdaysParse,xt),ee!==-1?ee:null)):(ee=Bi.call(this._minWeekdaysParse,xt),ee!==-1||(ee=Bi.call(this._weekdaysParse,xt),ee!==-1)?ee:(ee=Bi.call(this._shortWeekdaysParse,xt),ee!==-1?ee:null))}function Sc(E,I,q){var z,ee,ke;if(this._weekdaysParseExact)return _c.call(this,E,I,q);for(this._weekdaysParse||(this._weekdaysParse=[],this._minWeekdaysParse=[],this._shortWeekdaysParse=[],this._fullWeekdaysParse=[]),z=0;z<7;z++){if(ee=P([2e3,1]).day(z),q&&!this._fullWeekdaysParse[z]&&(this._fullWeekdaysParse[z]=new RegExp("^"+this.weekdays(ee,"").replace(".","\\.?")+"$","i"),this._shortWeekdaysParse[z]=new RegExp("^"+this.weekdaysShort(ee,"").replace(".","\\.?")+"$","i"),this._minWeekdaysParse[z]=new RegExp("^"+this.weekdaysMin(ee,"").replace(".","\\.?")+"$","i")),this._weekdaysParse[z]||(ke="^"+this.weekdays(ee,"")+"|^"+this.weekdaysShort(ee,"")+"|^"+this.weekdaysMin(ee,""),this._weekdaysParse[z]=new RegExp(ke.replace(".",""),"i")),q&&I==="dddd"&&this._fullWeekdaysParse[z].test(E))return z;if(q&&I==="ddd"&&this._shortWeekdaysParse[z].test(E))return z;if(q&&I==="dd"&&this._minWeekdaysParse[z].test(E))return z;if(!q&&this._weekdaysParse[z].test(E))return z}}function Ns(E){if(!this.isValid())return E!=null?this:NaN;var I=vc(this,"Day");return E!=null?(E=rm(E,this.localeData()),this.add(E-I,"d")):I}function wn(E){if(!this.isValid())return E!=null?this:NaN;var I=(this.day()+7-this.localeData()._week.dow)%7;return E==null?I:this.add(E-I,"d")}function Gu(E){if(!this.isValid())return E!=null?this:NaN;if(E!=null){var I=Ra(E,this.localeData());return this.day(this.day()%7?I:I-7)}else return this.day()||7}function Gh(E){return this._weekdaysParseExact?(n(this,"_weekdaysRegex")||ql.call(this),E?this._weekdaysStrictRegex:this._weekdaysRegex):(n(this,"_weekdaysRegex")||(this._weekdaysRegex=ea),this._weekdaysStrictRegex&&E?this._weekdaysStrictRegex:this._weekdaysRegex)}function Gs(E){return this._weekdaysParseExact?(n(this,"_weekdaysRegex")||ql.call(this),E?this._weekdaysShortStrictRegex:this._weekdaysShortRegex):(n(this,"_weekdaysShortRegex")||(this._weekdaysShortRegex=Np),this._weekdaysShortStrictRegex&&E?this._weekdaysShortStrictRegex:this._weekdaysShortRegex)}function jl(E){return this._weekdaysParseExact?(n(this,"_weekdaysRegex")||ql.call(this),E?this._weekdaysMinStrictRegex:this._weekdaysMinRegex):(n(this,"_weekdaysMinRegex")||(this._weekdaysMinRegex=La),this._weekdaysMinStrictRegex&&E?this._weekdaysMinStrictRegex:this._weekdaysMinRegex)}function ql(){function E(ia,eu){return eu.length-ia.length}var I=[],q=[],z=[],ee=[],ke,xt,fr,dn,fi;for(ke=0;ke<7;ke++)xt=P([2e3,1]).day(ke),fr=Di(this.weekdaysMin(xt,"")),dn=Di(this.weekdaysShort(xt,"")),fi=Di(this.weekdays(xt,"")),I.push(fr),q.push(dn),z.push(fi),ee.push(fr),ee.push(dn),ee.push(fi);I.sort(E),q.sort(E),z.sort(E),ee.sort(E),this._weekdaysRegex=new RegExp("^("+ee.join("|")+")","i"),this._weekdaysShortRegex=this._weekdaysRegex,this._weekdaysMinRegex=this._weekdaysRegex,this._weekdaysStrictRegex=new RegExp("^("+z.join("|")+")","i"),this._weekdaysShortStrictRegex=new RegExp("^("+q.join("|")+")","i"),this._weekdaysMinStrictRegex=new RegExp("^("+I.join("|")+")","i")}function Ma(){return this.hours()%12||12}function Rp(){return this.hours()||24}Ye("H",["HH",2],0,"hour"),Ye("h",["hh",2],0,Ma),Ye("k",["kk",2],0,Rp),Ye("hmm",0,0,function(){return""+Ma.apply(this)+Ee(this.minutes(),2)}),Ye("hmmss",0,0,function(){return""+Ma.apply(this)+Ee(this.minutes(),2)+Ee(this.seconds(),2)}),Ye("Hmm",0,0,function(){return""+this.hours()+Ee(this.minutes(),2)}),Ye("Hmmss",0,0,function(){return""+this.hours()+Ee(this.minutes(),2)+Ee(this.seconds(),2)});function Oo(E,I){Ye(E,0,0,function(){return this.localeData().meridiem(this.hours(),this.minutes(),I)})}Oo("a",!0),Oo("A",!1);function Fp(E,I){return I._meridiemParse}Mt("a",Fp),Mt("A",Fp),Mt("H",En,In),Mt("h",En,xr),Mt("k",En,xr),Mt("HH",En,Vr),Mt("hh",En,Vr),Mt("kk",En,Vr),Mt("hmm",$o),Mt("hmmss",Qo),Mt("Hmm",$o),Mt("Hmmss",Qo),On(["H","HH"],Cs),On(["k","kk"],function(E,I,q){var z=sn(E);I[Cs]=z===24?0:z}),On(["a","A"],function(E,I,q){q._isPm=q._locale.isPM(E),q._meridiem=E}),On(["h","hh"],function(E,I,q){I[Cs]=sn(E),g(q).bigHour=!0}),On("hmm",function(E,I,q){var z=E.length-2;I[Cs]=sn(E.substr(0,z)),I[Do]=sn(E.substr(z)),g(q).bigHour=!0}),On("hmmss",function(E,I,q){var z=E.length-4,ee=E.length-2;I[Cs]=sn(E.substr(0,z)),I[Do]=sn(E.substr(z,2)),I[lo]=sn(E.substr(ee)),g(q).bigHour=!0}),On("Hmm",function(E,I,q){var z=E.length-2;I[Cs]=sn(E.substr(0,z)),I[Do]=sn(E.substr(z))}),On("Hmmss",function(E,I,q){var z=E.length-4,ee=E.length-2;I[Cs]=sn(E.substr(0,z)),I[Do]=sn(E.substr(z,2)),I[lo]=sn(E.substr(ee))});function Kh(E){return(E+"").toLowerCase().charAt(0)==="p"}var Ga=/[ap]\.?m?\.?/i,va=tn("Hours",!0);function Lp(E,I,q){return E>11?q?"pm":"PM":q?"am":"AM"}var nl={calendar:ze,longDateFormat:Ut,invalidDate:ft,ordinal:C,dayOfMonthOrdinalParse:kt,relativeTime:Jr,months:ko,monthsShort:Na,week:Bl,weekdays:Wh,weekdaysMin:Op,weekdaysShort:zh,meridiemParse:Ga},bs={},ro={},Ku;function Ef(E,I){var q,z=Math.min(E.length,I.length);for(q=0;q<z;q+=1)if(E[q]!==I[q])return q;return z}function gu(E){return E&&E.toLowerCase().replace("_","-")}function il(E){for(var I=0,q,z,ee,ke;I<E.length;){for(ke=gu(E[I]).split("-"),q=ke.length,z=gu(E[I+1]),z=z?z.split("-"):null;q>0;){if(ee=Z(ke.slice(0,q).join("-")),ee)return ee;if(z&&z.length>=q&&Ef(ke,z)>=q-1)break;q--}I++}return Ku}function ue(E){return!!(E&&E.match("^[^/\\\\]*$"))}function Z(E){var I=null,q;if(bs[E]===void 0&&typeof _2<"u"&&_2&&_2.exports&&ue(E))try{I=Ku._abbr,q=require,q("./locale/"+E),ae(I)}catch{bs[E]=null}return bs[E]}function ae(E,I){var q;return E&&(f(I)?q=Xe(E):q=Me(E,I),q?Ku=q:typeof console<"u"&&console.warn&&console.warn("Locale "+E+" not found. Did you forget to load it?")),Ku._abbr}function Me(E,I){if(I!==null){var q,z=nl;if(I.abbr=E,bs[E]!=null)Ct("defineLocaleOverride","use moment.updateLocale(localeName, config) to change an existing locale. moment.defineLocale(localeName, config) should only be used for creating a new locale See http://momentjs.com/guides/#/warnings/define-locale/ for more info."),z=bs[E]._config;else if(I.parentLocale!=null)if(bs[I.parentLocale]!=null)z=bs[I.parentLocale]._config;else if(q=Z(I.parentLocale),q!=null)z=q._config;else return ro[I.parentLocale]||(ro[I.parentLocale]=[]),ro[I.parentLocale].push({name:E,config:I}),null;return bs[E]=new se(je(z,I)),ro[E]&&ro[E].forEach(function(ee){Me(ee.name,ee.config)}),ae(E),bs[E]}else return delete bs[E],null}function it(E,I){if(I!=null){var q,z,ee=nl;bs[E]!=null&&bs[E].parentLocale!=null?bs[E].set(je(bs[E]._config,I)):(z=Z(E),z!=null&&(ee=z._config),I=je(ee,I),z==null&&(I.abbr=E),q=new se(I),q.parentLocale=bs[E],bs[E]=q),ae(E)}else bs[E]!=null&&(bs[E].parentLocale!=null?(bs[E]=bs[E].parentLocale,E===ae()&&ae(E)):bs[E]!=null&&delete bs[E]);return bs[E]}function Xe(E){var I;if(E&&E._locale&&E._locale._abbr&&(E=E._locale._abbr),!E)return Ku;if(!s(E)){if(I=Z(E),I)return I;E=[E]}return il(E)}function gt(){return De(bs)}function St(E){var I,q=E._a;return q&&g(E).overflow===-2&&(I=q[Ao]<0||q[Ao]>11?Ao:q[co]<1||q[co]>zs(q[ur],q[Ao])?co:q[Cs]<0||q[Cs]>24||q[Cs]===24&&(q[Do]!==0||q[lo]!==0||q[js]!==0)?Cs:q[Do]<0||q[Do]>59?Do:q[lo]<0||q[lo]>59?lo:q[js]<0||q[js]>999?js:-1,g(E)._overflowDayOfYear&&(I<ur||I>co)&&(I=co),g(E)._overflowWeeks&&I===-1&&(I=Zc),g(E)._overflowWeekday&&I===-1&&(I=fu),g(E).overflow=I),E}var Vt=/^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,_r=/^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d|))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,An=/Z|[+-]\d\d(?::?\d\d)?/,ti=[["YYYYYY-MM-DD",/[+-]\d{6}-\d\d-\d\d/],["YYYY-MM-DD",/\d{4}-\d\d-\d\d/],["GGGG-[W]WW-E",/\d{4}-W\d\d-\d/],["GGGG-[W]WW",/\d{4}-W\d\d/,!1],["YYYY-DDD",/\d{4}-\d{3}/],["YYYY-MM",/\d{4}-\d\d/,!1],["YYYYYYMMDD",/[+-]\d{10}/],["YYYYMMDD",/\d{8}/],["GGGG[W]WWE",/\d{4}W\d{3}/],["GGGG[W]WW",/\d{4}W\d{2}/,!1],["YYYYDDD",/\d{7}/],["YYYYMM",/\d{6}/,!1],["YYYY",/\d{4}/,!1]],Nn=[["HH:mm:ss.SSSS",/\d\d:\d\d:\d\d\.\d+/],["HH:mm:ss,SSSS",/\d\d:\d\d:\d\d,\d+/],["HH:mm:ss",/\d\d:\d\d:\d\d/],["HH:mm",/\d\d:\d\d/],["HHmmss.SSSS",/\d\d\d\d\d\d\.\d+/],["HHmmss,SSSS",/\d\d\d\d\d\d,\d+/],["HHmmss",/\d\d\d\d\d\d/],["HHmm",/\d\d\d\d/],["HH",/\d\d/]],Ba=/^\/?Date\((-?\d+)/i,Ul=/^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|([+-]\d{4}))$/,xa={UT:0,GMT:0,EDT:-4*60,EST:-5*60,CDT:-5*60,CST:-6*60,MDT:-6*60,MST:-7*60,PDT:-7*60,PST:-8*60};function No(E){var I,q,z=E._i,ee=Vt.exec(z)||_r.exec(z),ke,xt,fr,dn,fi=ti.length,ia=Nn.length;if(ee){for(g(E).iso=!0,I=0,q=fi;I<q;I++)if(ti[I][1].exec(ee[1])){xt=ti[I][0],ke=ti[I][2]!==!1;break}if(xt==null){E._isValid=!1;return}if(ee[3]){for(I=0,q=ia;I<q;I++)if(Nn[I][1].exec(ee[3])){fr=(ee[2]||" ")+Nn[I][0];break}if(fr==null){E._isValid=!1;return}}if(!ke&&fr!=null){E._isValid=!1;return}if(ee[4])if(An.exec(ee[4]))dn="Z";else{E._isValid=!1;return}E._f=xt+(fr||"")+(dn||""),Ho(E)}else E._isValid=!1}function ui(E,I,q,z,ee,ke){var xt=[on(E),Na.indexOf(I),parseInt(q,10),parseInt(z,10),parseInt(ee,10)];return ke&&xt.push(parseInt(ke,10)),xt}function on(E){var I=parseInt(E,10);return I<=49?2e3+I:I<=999?1900+I:I}function Nr(E){return E.replace(/\([^()]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").replace(/^\s\s*/,"").replace(/\s\s*$/,"")}function rn(E,I,q){if(E){var z=zh.indexOf(E),ee=new Date(I[0],I[1],I[2]).getDay();if(z!==ee)return g(q).weekdayMismatch=!0,q._isValid=!1,!1}return!0}function ri(E,I,q){if(E)return xa[E];if(I)return 0;var z=parseInt(q,10),ee=z%100,ke=(z-ee)/100;return ke*60+ee}function Ii(E){var I=Ul.exec(Nr(E._i)),q;if(I){if(q=ui(I[4],I[3],I[2],I[5],I[6],I[7]),!rn(I[1],q,E))return;E._a=q,E._tzm=ri(I[8],I[9],I[10]),E._d=Sf.apply(null,E._a),E._d.setUTCMinutes(E._d.getUTCMinutes()-E._tzm),g(E).rfc2822=!0}else E._isValid=!1}function Ks(E){var I=Ba.exec(E._i);if(I!==null){E._d=new Date(+I[1]);return}if(No(E),E._isValid===!1)delete E._isValid;else return;if(Ii(E),E._isValid===!1)delete E._isValid;else return;E._strict?E._isValid=!1:t.createFromInputFallback(E)}t.createFromInputFallback=Ve("value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are discouraged. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.",function(E){E._d=new Date(E._i+(E._useUTC?" UTC":""))});function _o(E,I,q){return E!=null?E:I!=null?I:q}function bc(E){var I=new Date(t.now());return E._useUTC?[I.getUTCFullYear(),I.getUTCMonth(),I.getUTCDate()]:[I.getFullYear(),I.getMonth(),I.getDate()]}function no(E){var I,q,z=[],ee,ke,xt;if(!E._d){for(ee=bc(E),E._w&&E._a[co]==null&&E._a[Ao]==null&&ja(E),E._dayOfYear!=null&&(xt=_o(E._a[ur],ee[ur]),(E._dayOfYear>Oa(xt)||E._dayOfYear===0)&&(g(E)._overflowDayOfYear=!0),q=Sf(xt,0,E._dayOfYear),E._a[Ao]=q.getUTCMonth(),E._a[co]=q.getUTCDate()),I=0;I<3&&E._a[I]==null;++I)E._a[I]=z[I]=ee[I];for(;I<7;I++)E._a[I]=z[I]=E._a[I]==null?I===2?1:0:E._a[I];E._a[Cs]===24&&E._a[Do]===0&&E._a[lo]===0&&E._a[js]===0&&(E._nextDay=!0,E._a[Cs]=0),E._d=(E._useUTC?Sf:Vh).apply(null,z),ke=E._useUTC?E._d.getUTCDay():E._d.getDay(),E._tzm!=null&&E._d.setUTCMinutes(E._d.getUTCMinutes()-E._tzm),E._nextDay&&(E._a[Cs]=24),E._w&&typeof E._w.d<"u"&&E._w.d!==ke&&(g(E).weekdayMismatch=!0)}}function ja(E){var I,q,z,ee,ke,xt,fr,dn,fi;I=E._w,I.GG!=null||I.W!=null||I.E!=null?(ke=1,xt=4,q=_o(I.GG,E._a[ur],or(Tn(),1,4).year),z=_o(I.W,1),ee=_o(I.E,1),(ee<1||ee>7)&&(dn=!0)):(ke=E._locale._week.dow,xt=E._locale._week.doy,fi=or(Tn(),ke,xt),q=_o(I.gg,E._a[ur],fi.year),z=_o(I.w,fi.week),I.d!=null?(ee=I.d,(ee<0||ee>6)&&(dn=!0)):I.e!=null?(ee=I.e+ke,(I.e<0||I.e>6)&&(dn=!0)):ee=ke),z<1||z>ji(q,ke,xt)?g(E)._overflowWeeks=!0:dn!=null?g(E)._overflowWeekday=!0:(fr=Od(q,z,ee,ke,xt),E._a[ur]=fr.year,E._dayOfYear=fr.dayOfYear)}t.ISO_8601=function(){},t.RFC_2822=function(){};function Ho(E){if(E._f===t.ISO_8601){No(E);return}if(E._f===t.RFC_2822){Ii(E);return}E._a=[],g(E).empty=!0;var I=""+E._i,q,z,ee,ke,xt,fr=I.length,dn=0,fi,ia;for(ee=lt(E._f,E._locale).match(Fe)||[],ia=ee.length,q=0;q<ia;q++)ke=ee[q],z=(I.match(Ai(ke,E))||[])[0],z&&(xt=I.substr(0,I.indexOf(z)),xt.length>0&&g(E).unusedInput.push(xt),I=I.slice(I.indexOf(z)+z.length),dn+=z.length),jt[ke]?(z?g(E).empty=!1:g(E).unusedTokens.push(ke),Hu(ke,z,E)):E._strict&&!z&&g(E).unusedTokens.push(ke);g(E).charsLeftOver=fr-dn,I.length>0&&g(E).unusedInput.push(I),E._a[Cs]<=12&&g(E).bigHour===!0&&E._a[Cs]>0&&(g(E).bigHour=void 0),g(E).parsedDateParts=E._a.slice(0),g(E).meridiem=E._meridiem,E._a[Cs]=$l(E._locale,E._a[Cs],E._meridiem),fi=g(E).era,fi!==null&&(E._a[ur]=E._locale.erasConvertYear(fi,E._a[ur])),no(E),St(E)}function $l(E,I,q){var z;return q==null?I:E.meridiemHour!=null?E.meridiemHour(I,q):(E.isPM!=null&&(z=E.isPM(q),z&&I<12&&(I+=12),!z&&I===12&&(I=0)),I)}function Mp(E){var I,q,z,ee,ke,xt,fr=!1,dn=E._f.length;if(dn===0){g(E).invalidFormat=!0,E._d=new Date(NaN);return}for(ee=0;ee<dn;ee++)ke=0,xt=!1,I=te({},E),E._useUTC!=null&&(I._useUTC=E._useUTC),I._f=E._f[ee],Ho(I),F(I)&&(xt=!0),ke+=g(I).charsLeftOver,ke+=g(I).unusedTokens.length*10,g(I).score=ke,fr?ke<z&&(z=ke,q=I):(z==null||ke<z||xt)&&(z=ke,q=I,xt&&(fr=!0));b(E,q||I)}function Yu(E){if(!E._d){var I=Je(E._i),q=I.day===void 0?I.date:I.day;E._a=v([I.year,I.month,q,I.hour,I.minute,I.second,I.millisecond],function(z){return z&&parseInt(z,10)}),no(E)}}function Bp(E){var I=new me(St(Wo(E)));return I._nextDay&&(I.add(1,"d"),I._nextDay=void 0),I}function Wo(E){var I=E._i,q=E._f;return E._locale=E._locale||Xe(E._l),I===null||q===void 0&&I===""?M({nullInput:!0}):(typeof I=="string"&&(E._i=I=E._locale.preparse(I)),Ce(I)?new me(St(I)):(y(I)?E._d=I:s(q)?Mp(E):q?Ho(E):qi(E),F(E)||(E._d=null),E))}function qi(E){var I=E._i;f(I)?E._d=new Date(t.now()):y(I)?E._d=new Date(I.valueOf()):typeof I=="string"?Ks(E):s(I)?(E._a=v(I.slice(0),function(q){return parseInt(q,10)}),no(E)):a(I)?Yu(E):m(I)?E._d=new Date(I):t.createFromInputFallback(E)}function Yh(E,I,q,z,ee){var ke={};return(I===!0||I===!1)&&(z=I,I=void 0),(q===!0||q===!1)&&(z=q,q=void 0),(a(E)&&l(E)||s(E)&&E.length===0)&&(E=void 0),ke._isAMomentObject=!0,ke._useUTC=ke._isUTC=ee,ke._l=q,ke._i=E,ke._f=I,ke._strict=z,Bp(ke)}function Tn(E,I,q,z){return Yh(E,I,q,z,!1)}var Jh=Ve("moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/",function(){var E=Tn.apply(null,arguments);return this.isValid()&&E.isValid()?E<this?this:E:M()}),zo=Ve("moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/",function(){var E=Tn.apply(null,arguments);return this.isValid()&&E.isValid()?E>this?this:E:M()});function oi(E,I){var q,z;if(I.length===1&&s(I[0])&&(I=I[0]),!I.length)return Tn();for(q=I[0],z=1;z<I.length;++z)(!I[z].isValid()||I[z][E](q))&&(q=I[z]);return q}function Ka(){var E=[].slice.call(arguments,0);return oi("isBefore",E)}function Rd(){var E=[].slice.call(arguments,0);return oi("isAfter",E)}var wf=function(){return Date.now?Date.now():+new Date},Tf=["year","quarter","month","week","day","hour","minute","second","millisecond"];function gv(E){var I,q=!1,z,ee=Tf.length;for(I in E)if(n(E,I)&&!(Bi.call(Tf,I)!==-1&&(E[I]==null||!isNaN(E[I]))))return!1;for(z=0;z<ee;++z)if(E[Tf[z]]){if(q)return!1;parseFloat(E[Tf[z]])!==sn(E[Tf[z]])&&(q=!0)}return!0}function Fd(){return this._isValid}function nm(){return So(NaN)}function Ec(E){var I=Je(E),q=I.year||0,z=I.quarter||0,ee=I.month||0,ke=I.week||I.isoWeek||0,xt=I.day||0,fr=I.hour||0,dn=I.minute||0,fi=I.second||0,ia=I.millisecond||0;this._isValid=gv(I),this._milliseconds=+ia+fi*1e3+dn*6e4+fr*1e3*60*60,this._days=+xt+ke*7,this._months=+ee+z*3+q*12,this._data={},this._locale=Xe(),this._bubble()}function qa(E){return E instanceof Ec}function sl(E){return E<0?Math.round(-1*E)*-1:Math.round(E)}function Ya(E,I,q){var z=Math.min(E.length,I.length),ee=Math.abs(E.length-I.length),ke=0,xt;for(xt=0;xt<z;xt++)(q&&E[xt]!==I[xt]||!q&&sn(E[xt])!==sn(I[xt]))&&ke++;return ke+ee}function jp(E,I){Ye(E,0,0,function(){var q=this.utcOffset(),z="+";return q<0&&(q=-q,z="-"),z+Ee(~~(q/60),2)+I+Ee(~~q%60,2)})}jp("Z",":"),jp("ZZ",""),Mt("Z",It),Mt("ZZ",It),On(["Z","ZZ"],function(E,I,q){q._useUTC=!0,q._tzm=Ro(It,E)});var Ys=/([\+\-]|\d\d)/gi;function Ro(E,I){var q=(I||"").match(E),z,ee,ke;return q===null?null:(z=q[q.length-1]||[],ee=(z+"").match(Ys)||["-",0,0],ke=+(ee[1]*60)+sn(ee[2]),ke===0?0:ee[0]==="+"?ke:-ke)}function io(E,I){var q,z;return I._isUTC?(q=I.clone(),z=(Ce(E)||y(E)?E.valueOf():Tn(E).valueOf())-q.valueOf(),q._d.setTime(q._d.valueOf()+z),t.updateOffset(q,!1),q):Tn(E).local()}function wc(E){return-Math.round(E._d.getTimezoneOffset())}t.updateOffset=function(){};function Pf(E,I,q){var z=this._offset||0,ee;if(!this.isValid())return E!=null?this:NaN;if(E!=null){if(typeof E=="string"){if(E=Ro(It,E),E===null)return this}else Math.abs(E)<16&&!q&&(E=E*60);return!this._isUTC&&I&&(ee=wc(this)),this._offset=E,this._isUTC=!0,ee!=null&&this.add(ee,"m"),z!==E&&(!I||this._changeInProgress?ba(this,So(E-z,"m"),1,!1):this._changeInProgress||(this._changeInProgress=!0,t.updateOffset(this,!0),this._changeInProgress=null)),this}else return this._isUTC?z:wc(this)}function bi(E,I){return E!=null?(typeof E!="string"&&(E=-E),this.utcOffset(E,I),this):-this.utcOffset()}function im(E){return this.utcOffset(0,E)}function sm(E){return this._isUTC&&(this.utcOffset(0,E),this._isUTC=!1,E&&this.subtract(wc(this),"m")),this}function ta(){if(this._tzm!=null)this.utcOffset(this._tzm,!1,!0);else if(typeof this._i=="string"){var E=Ro(Ft,this._i);E!=null?this.utcOffset(E):this.utcOffset(0,!0)}return this}function Sa(E){return this.isValid()?(E=E?Tn(E).utcOffset():0,(this.utcOffset()-E)%60===0):!1}function Ja(){return this.utcOffset()>this.clone().month(0).utcOffset()||this.utcOffset()>this.clone().month(5).utcOffset()}function Vl(){if(!f(this._isDSTShifted))return this._isDSTShifted;var E={},I;return te(E,this),E=Wo(E),E._a?(I=E._isUTC?P(E._a):Tn(E._a),this._isDSTShifted=this.isValid()&&Ya(E._a,I.toArray())>0):this._isDSTShifted=!1,this._isDSTShifted}function Hl(){return this.isValid()?!this._isUTC:!1}function Wl(){return this.isValid()?this._isUTC:!1}function Ei(){return this.isValid()?this._isUTC&&this._offset===0:!1}var Ju=/^(-|\+)?(?:(\d*)[. ])?(\d+):(\d+)(?::(\d+)(\.\d*)?)?$/,zl=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/;function So(E,I){var q=E,z=null,ee,ke,xt;return qa(E)?q={ms:E._milliseconds,d:E._days,M:E._months}:m(E)||!isNaN(+E)?(q={},I?q[I]=+E:q.milliseconds=+E):(z=Ju.exec(E))?(ee=z[1]==="-"?-1:1,q={y:0,d:sn(z[co])*ee,h:sn(z[Cs])*ee,m:sn(z[Do])*ee,s:sn(z[lo])*ee,ms:sn(sl(z[js]*1e3))*ee}):(z=zl.exec(E))?(ee=z[1]==="-"?-1:1,q={y:ol(z[2],ee),M:ol(z[3],ee),w:ol(z[4],ee),d:ol(z[5],ee),h:ol(z[6],ee),m:ol(z[7],ee),s:ol(z[8],ee)}):q==null?q={}:typeof q=="object"&&("from"in q||"to"in q)&&(xt=om(Tn(q.from),Tn(q.to)),q={},q.ms=xt.milliseconds,q.M=xt.months),ke=new Ec(q),qa(E)&&n(E,"_locale")&&(ke._locale=E._locale),qa(E)&&n(E,"_isValid")&&(ke._isValid=E._isValid),ke}So.fn=Ec.prototype,So.invalid=nm;function ol(E,I){var q=E&&parseFloat(E.replace(",","."));return(isNaN(q)?0:q)*I}function Xu(E,I){var q={};return q.months=I.month()-E.month()+(I.year()-E.year())*12,E.clone().add(q.months,"M").isAfter(I)&&--q.months,q.milliseconds=+I-+E.clone().add(q.months,"M"),q}function om(E,I){var q;return E.isValid()&&I.isValid()?(I=io(I,E),E.isBefore(I)?q=Xu(E,I):(q=Xu(I,E),q.milliseconds=-q.milliseconds,q.months=-q.months),q):{milliseconds:0,months:0}}function qp(E,I){return function(q,z){var ee,ke;return z!==null&&!isNaN(+z)&&(Ct(I,"moment()."+I+"(period, number) is deprecated. Please use moment()."+I+"(number, period). See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info."),ke=q,q=z,z=ke),ee=So(q,z),ba(this,ee,E),this}}function ba(E,I,q,z){var ee=I._milliseconds,ke=sl(I._days),xt=sl(I._months);E.isValid()&&(z=z==null?!0:z,xt&&qt(E,vc(E,"Month")+xt*q),ke&&el(E,"Date",vc(E,"Date")+ke*q),ee&&E._d.setTime(E._d.valueOf()+ee*q),z&&t.updateOffset(E,ke||xt))}var ni=qp(1,"add"),Ld=qp(-1,"subtract");function Xh(E){return typeof E=="string"||E instanceof String}function Qh(E){return Ce(E)||y(E)||Xh(E)||m(E)||Wy(E)||Hy(E)||E===null||E===void 0}function Hy(E){var I=a(E)&&!l(E),q=!1,z=["years","year","y","months","month","M","days","day","d","dates","date","D","hours","hour","h","minutes","minute","m","seconds","second","s","milliseconds","millisecond","ms"],ee,ke,xt=z.length;for(ee=0;ee<xt;ee+=1)ke=z[ee],q=q||n(E,ke);return I&&q}function Wy(E){var I=s(E),q=!1;return I&&(q=E.filter(function(z){return!m(z)&&Xh(E)}).length===0),I&&q}function vv(E){var I=a(E)&&!l(E),q=!1,z=["sameDay","nextDay","lastDay","nextWeek","lastWeek","sameElse"],ee,ke;for(ee=0;ee<z.length;ee+=1)ke=z[ee],q=q||n(E,ke);return I&&q}function xx(E,I){var q=E.diff(I,"days",!0);return q<-6?"sameElse":q<-1?"lastWeek":q<0?"lastDay":q<1?"sameDay":q<2?"nextDay":q<7?"nextWeek":"sameElse"}function am(E,I){arguments.length===1&&(arguments[0]?Qh(arguments[0])?(E=arguments[0],I=void 0):vv(arguments[0])&&(I=arguments[0],E=void 0):(E=void 0,I=void 0));var q=E||Tn(),z=io(q,this).startOf("day"),ee=t.calendarFormat(this,z)||"sameElse",ke=I&&(ct(I[ee])?I[ee].call(this,q):I[ee]);return this.format(ke||this.localeData().calendar(ee,this,Tn(q)))}function Zh(){return new me(this)}function xv(E,I){var q=Ce(E)?E:Tn(E);return this.isValid()&&q.isValid()?(I=ge(I)||"millisecond",I==="millisecond"?this.valueOf()>q.valueOf():q.valueOf()<this.clone().startOf(I).valueOf()):!1}function Qu(E,I){var q=Ce(E)?E:Tn(E);return this.isValid()&&q.isValid()?(I=ge(I)||"millisecond",I==="millisecond"?this.valueOf()<q.valueOf():this.clone().endOf(I).valueOf()<q.valueOf()):!1}function Gl(E,I,q,z){var ee=Ce(E)?E:Tn(E),ke=Ce(I)?I:Tn(I);return this.isValid()&&ee.isValid()&&ke.isValid()?(z=z||"()",(z[0]==="("?this.isAfter(ee,q):!this.isBefore(ee,q))&&(z[1]===")"?this.isBefore(ke,q):!this.isAfter(ke,q))):!1}function Ea(E,I){var q=Ce(E)?E:Tn(E),z;return this.isValid()&&q.isValid()?(I=ge(I)||"millisecond",I==="millisecond"?this.valueOf()===q.valueOf():(z=q.valueOf(),this.clone().startOf(I).valueOf()<=z&&z<=this.clone().endOf(I).valueOf())):!1}function vu(E,I){return this.isSame(E,I)||this.isAfter(E,I)}function wa(E,I){return this.isSame(E,I)||this.isBefore(E,I)}function Up(E,I,q){var z,ee,ke;if(!this.isValid())return NaN;if(z=io(E,this),!z.isValid())return NaN;switch(ee=(z.utcOffset()-this.utcOffset())*6e4,I=ge(I),I){case"year":ke=xu(this,z)/12;break;case"month":ke=xu(this,z);break;case"quarter":ke=xu(this,z)/3;break;case"second":ke=(this-z)/1e3;break;case"minute":ke=(this-z)/6e4;break;case"hour":ke=(this-z)/36e5;break;case"day":ke=(this-z-ee)/864e5;break;case"week":ke=(this-z-ee)/6048e5;break;default:ke=this-z}return q?ke:Si(ke)}function xu(E,I){if(E.date()<I.date())return-xu(I,E);var q=(I.year()-E.year())*12+(I.month()-E.month()),z=E.clone().add(q,"months"),ee,ke;return I-z<0?(ee=E.clone().add(q-1,"months"),ke=(I-z)/(z-ee)):(ee=E.clone().add(q+1,"months"),ke=(I-z)/(ee-z)),-(q+ke)||0}t.defaultFormat="YYYY-MM-DDTHH:mm:ssZ",t.defaultFormatUtc="YYYY-MM-DDTHH:mm:ss[Z]";function al(){return this.clone().locale("en").format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ")}function Cf(E){if(!this.isValid())return null;var I=E!==!0,q=I?this.clone().utc():this;return q.year()<0||q.year()>9999?Ze(q,I?"YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]":"YYYYYY-MM-DD[T]HH:mm:ss.SSSZ"):ct(Date.prototype.toISOString)?I?this.toDate().toISOString():new Date(this.valueOf()+this.utcOffset()*60*1e3).toISOString().replace("Z",Ze(q,"Z")):Ze(q,I?"YYYY-MM-DD[T]HH:mm:ss.SSS[Z]":"YYYY-MM-DD[T]HH:mm:ss.SSSZ")}function Af(){if(!this.isValid())return"moment.invalid(/* "+this._i+" */)";var E="moment",I="",q,z,ee,ke;return this.isLocal()||(E=this.utcOffset()===0?"moment.utc":"moment.parseZone",I="Z"),q="["+E+'("]',z=0<=this.year()&&this.year()<=9999?"YYYY":"YYYYYY",ee="-MM-DD[T]HH:mm:ss.SSS",ke=I+'[")]',this.format(q+z+ee+ke)}function Md(E){E||(E=this.isUtc()?t.defaultFormatUtc:t.defaultFormat);var I=Ze(this,E);return this.localeData().postformat(I)}function zy(E,I){return this.isValid()&&(Ce(E)&&E.isValid()||Tn(E).isValid())?So({to:this,from:E}).locale(this.locale()).humanize(!I):this.localeData().invalidDate()}function um(E){return this.from(Tn(),E)}function Df(E,I){return this.isValid()&&(Ce(E)&&E.isValid()||Tn(E).isValid())?So({from:this,to:E}).locale(this.locale()).humanize(!I):this.localeData().invalidDate()}function Kl(E){return this.to(Tn(),E)}function cm(E){var I;return E===void 0?this._locale._abbr:(I=Xe(E),I!=null&&(this._locale=I),this)}var _u=Ve("moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.",function(E){return E===void 0?this.localeData():this.locale(E)});function lm(){return this._locale}var ul=1e3,Tc=60*ul,Yl=60*Tc,Gy=(365*400+97)*24*Yl;function wi(E,I){return(E%I+I)%I}function Fo(E,I,q){return E<100&&E>=0?new Date(E+400,I,q)-Gy:new Date(E,I,q).valueOf()}function Su(E,I,q){return E<100&&E>=0?Date.UTC(E+400,I,q)-Gy:Date.UTC(E,I,q)}function Zu(E){var I,q;if(E=ge(E),E===void 0||E==="millisecond"||!this.isValid())return this;switch(q=this._isUTC?Su:Fo,E){case"year":I=q(this.year(),0,1);break;case"quarter":I=q(this.year(),this.month()-this.month()%3,1);break;case"month":I=q(this.year(),this.month(),1);break;case"week":I=q(this.year(),this.month(),this.date()-this.weekday());break;case"isoWeek":I=q(this.year(),this.month(),this.date()-(this.isoWeekday()-1));break;case"day":case"date":I=q(this.year(),this.month(),this.date());break;case"hour":I=this._d.valueOf(),I-=wi(I+(this._isUTC?0:this.utcOffset()*Tc),Yl);break;case"minute":I=this._d.valueOf(),I-=wi(I,Tc);break;case"second":I=this._d.valueOf(),I-=wi(I,ul);break}return this._d.setTime(I),t.updateOffset(this,!0),this}function cl(E){var I,q;if(E=ge(E),E===void 0||E==="millisecond"||!this.isValid())return this;switch(q=this._isUTC?Su:Fo,E){case"year":I=q(this.year()+1,0,1)-1;break;case"quarter":I=q(this.year(),this.month()-this.month()%3+3,1)-1;break;case"month":I=q(this.year(),this.month()+1,1)-1;break;case"week":I=q(this.year(),this.month(),this.date()-this.weekday()+7)-1;break;case"isoWeek":I=q(this.year(),this.month(),this.date()-(this.isoWeekday()-1)+7)-1;break;case"day":case"date":I=q(this.year(),this.month(),this.date()+1)-1;break;case"hour":I=this._d.valueOf(),I+=Yl-wi(I+(this._isUTC?0:this.utcOffset()*Tc),Yl)-1;break;case"minute":I=this._d.valueOf(),I+=Tc-wi(I,Tc)-1;break;case"second":I=this._d.valueOf(),I+=ul-wi(I,ul)-1;break}return this._d.setTime(I),t.updateOffset(this,!0),this}function Xa(){return this._d.valueOf()-(this._offset||0)*6e4}function $p(){return Math.floor(this.valueOf()/1e3)}function ll(){return new Date(this.valueOf())}function _v(){var E=this;return[E.year(),E.month(),E.date(),E.hour(),E.minute(),E.second(),E.millisecond()]}function pm(){var E=this;return{years:E.year(),months:E.month(),date:E.date(),hours:E.hours(),minutes:E.minutes(),seconds:E.seconds(),milliseconds:E.milliseconds()}}function kf(){return this.isValid()?this.toISOString():null}function Bd(){return F(this)}function _x(){return b({},g(this))}function Ky(){return g(this).overflow}function e0(){return{input:this._i,format:this._f,locale:this._locale,isUTC:this._isUTC,strict:this._strict}}Ye("N",0,0,"eraAbbr"),Ye("NN",0,0,"eraAbbr"),Ye("NNN",0,0,"eraAbbr"),Ye("NNNN",0,0,"eraName"),Ye("NNNNN",0,0,"eraNarrow"),Ye("y",["y",1],"yo","eraYear"),Ye("y",["yy",2],0,"eraYear"),Ye("y",["yyy",3],0,"eraYear"),Ye("y",["yyyy",4],0,"eraYear"),Mt("N",qd),Mt("NN",qd),Mt("NNN",qd),Mt("NNNN",r0),Mt("NNNNN",n0),On(["N","NN","NNN","NNNN","NNNNN"],function(E,I,q,z){var ee=q._locale.erasParse(E,z,q._strict);ee?g(q).era=ee:g(q).invalidEra=E}),Mt("y",za),Mt("yy",za),Mt("yyy",za),Mt("yyyy",za),Mt("yo",dm),On(["y","yy","yyy","yyyy"],ur),On(["yo"],function(E,I,q,z){var ee;q._locale._eraYearOrdinalRegex&&(ee=E.match(q._locale._eraYearOrdinalRegex)),q._locale.eraYearOrdinalParse?I[ur]=q._locale.eraYearOrdinalParse(E,ee):I[ur]=parseInt(E,10)});function Yy(E,I){var q,z,ee,ke=this._eras||Xe("en")._eras;for(q=0,z=ke.length;q<z;++q){switch(typeof ke[q].since){case"string":ee=t(ke[q].since).startOf("day"),ke[q].since=ee.valueOf();break}switch(typeof ke[q].until){case"undefined":ke[q].until=1/0;break;case"string":ee=t(ke[q].until).startOf("day").valueOf(),ke[q].until=ee.valueOf();break}}return ke}function Jy(E,I,q){var z,ee,ke=this.eras(),xt,fr,dn;for(E=E.toUpperCase(),z=0,ee=ke.length;z<ee;++z)if(xt=ke[z].name.toUpperCase(),fr=ke[z].abbr.toUpperCase(),dn=ke[z].narrow.toUpperCase(),q)switch(I){case"N":case"NN":case"NNN":if(fr===E)return ke[z];break;case"NNNN":if(xt===E)return ke[z];break;case"NNNNN":if(dn===E)return ke[z];break}else if([xt,fr,dn].indexOf(E)>=0)return ke[z]}function fm(E,I){var q=E.since<=E.until?1:-1;return I===void 0?t(E.since).year():t(E.since).year()+(I-E.offset)*q}function Vp(){var E,I,q,z=this.localeData().eras();for(E=0,I=z.length;E<I;++E)if(q=this.clone().startOf("day").valueOf(),z[E].since<=q&&q<=z[E].until||z[E].until<=q&&q<=z[E].since)return z[E].name;return""}function Xy(){var E,I,q,z=this.localeData().eras();for(E=0,I=z.length;E<I;++E)if(q=this.clone().startOf("day").valueOf(),z[E].since<=q&&q<=z[E].until||z[E].until<=q&&q<=z[E].since)return z[E].narrow;return""}function Sv(){var E,I,q,z=this.localeData().eras();for(E=0,I=z.length;E<I;++E)if(q=this.clone().startOf("day").valueOf(),z[E].since<=q&&q<=z[E].until||z[E].until<=q&&q<=z[E].since)return z[E].abbr;return""}function jd(){var E,I,q,z,ee=this.localeData().eras();for(E=0,I=ee.length;E<I;++E)if(q=ee[E].since<=ee[E].until?1:-1,z=this.clone().startOf("day").valueOf(),ee[E].since<=z&&z<=ee[E].until||ee[E].until<=z&&z<=ee[E].since)return(this.year()-t(ee[E].since).year())*q+ee[E].offset;return this.year()}function Ta(E){return n(this,"_erasNameRegex")||Of.call(this),E?this._erasNameRegex:this._erasRegex}function t0(E){return n(this,"_erasAbbrRegex")||Of.call(this),E?this._erasAbbrRegex:this._erasRegex}function If(E){return n(this,"_erasNarrowRegex")||Of.call(this),E?this._erasNarrowRegex:this._erasRegex}function qd(E,I){return I.erasAbbrRegex(E)}function r0(E,I){return I.erasNameRegex(E)}function n0(E,I){return I.erasNarrowRegex(E)}function dm(E,I){return I._eraYearOrdinalRegex||za}function Of(){var E=[],I=[],q=[],z=[],ee,ke,xt,fr,dn,fi=this.eras();for(ee=0,ke=fi.length;ee<ke;++ee)xt=Di(fi[ee].name),fr=Di(fi[ee].abbr),dn=Di(fi[ee].narrow),I.push(xt),E.push(fr),q.push(dn),z.push(xt),z.push(fr),z.push(dn);this._erasRegex=new RegExp("^("+z.join("|")+")","i"),this._erasNameRegex=new RegExp("^("+I.join("|")+")","i"),this._erasAbbrRegex=new RegExp("^("+E.join("|")+")","i"),this._erasNarrowRegex=new RegExp("^("+q.join("|")+")","i")}Ye(0,["gg",2],0,function(){return this.weekYear()%100}),Ye(0,["GG",2],0,function(){return this.isoWeekYear()%100});function Nf(E,I){Ye(0,[E,E.length],0,I)}Nf("gggg","weekYear"),Nf("ggggg","weekYear"),Nf("GGGG","isoWeekYear"),Nf("GGGGG","isoWeekYear"),Mt("G",rt),Mt("g",rt),Mt("GG",En,Vr),Mt("gg",En,Vr),Mt("GGGG",Vo,jn),Mt("gggg",Vo,jn),Mt("GGGGG",Vu,ei),Mt("ggggg",Vu,ei),Ss(["gggg","ggggg","GGGG","GGGGG"],function(E,I,q,z){I[z.substr(0,2)]=sn(E)}),Ss(["gg","GG"],function(E,I,q,z){I[z]=t.parseTwoDigitYear(E)});function Rf(E){return bu.call(this,E,this.week(),this.weekday()+this.localeData()._week.dow,this.localeData()._week.dow,this.localeData()._week.doy)}function Qy(E){return bu.call(this,E,this.isoWeek(),this.isoWeekday(),1,4)}function i0(){return ji(this.year(),1,4)}function s0(){return ji(this.isoWeekYear(),1,4)}function Jl(){var E=this.localeData()._week;return ji(this.year(),E.dow,E.doy)}function Hp(){var E=this.localeData()._week;return ji(this.weekYear(),E.dow,E.doy)}function bu(E,I,q,z,ee){var ke;return E==null?or(this,z,ee).year:(ke=ji(E,z,ee),I>ke&&(I=ke),Wp.call(this,E,I,q,z,ee))}function Wp(E,I,q,z,ee){var ke=Od(E,I,q,z,ee),xt=Sf(ke.year,0,ke.dayOfYear);return this.year(xt.getUTCFullYear()),this.month(xt.getUTCMonth()),this.date(xt.getUTCDate()),this}Ye("Q",0,"Qo","quarter"),Mt("Q",$r),On("Q",function(E,I){I[Ao]=(sn(E)-1)*3});function hm(E){return E==null?Math.ceil((this.month()+1)/3):this.month((E-1)*3+this.month()%3)}Ye("D",["DD",2],"Do","date"),Mt("D",En,xr),Mt("DD",En,Vr),Mt("Do",function(E,I){return E?I._dayOfMonthOrdinalParse||I._ordinalParse:I._dayOfMonthOrdinalParseLenient}),On(["D","DD"],co),On("Do",function(E,I){I[co]=sn(E.match(En)[0])});var Xl=tn("Date",!0);Ye("DDD",["DDDD",3],"DDDo","dayOfYear"),Mt("DDD",ps),Mt("DDDD",Hn),On(["DDD","DDDD"],function(E,I,q){q._dayOfYear=sn(E)});function Pc(E){var I=Math.round((this.clone().startOf("day")-this.clone().startOf("year"))/864e5)+1;return E==null?I:this.add(E-I,"d")}Ye("m",["mm",2],0,"minute"),Mt("m",En,In),Mt("mm",En,Vr),On(["m","mm"],Do);var mm=tn("Minutes",!1);Ye("s",["ss",2],0,"second"),Mt("s",En,In),Mt("ss",En,Vr),On(["s","ss"],lo);var Ud=tn("Seconds",!1);Ye("S",0,0,function(){return~~(this.millisecond()/100)}),Ye(0,["SS",2],0,function(){return~~(this.millisecond()/10)}),Ye(0,["SSS",3],0,"millisecond"),Ye(0,["SSSS",4],0,function(){return this.millisecond()*10}),Ye(0,["SSSSS",5],0,function(){return this.millisecond()*100}),Ye(0,["SSSSSS",6],0,function(){return this.millisecond()*1e3}),Ye(0,["SSSSSSS",7],0,function(){return this.millisecond()*1e4}),Ye(0,["SSSSSSSS",8],0,function(){return this.millisecond()*1e5}),Ye(0,["SSSSSSSSS",9],0,function(){return this.millisecond()*1e6}),Mt("S",ps,$r),Mt("SS",ps,Vr),Mt("SSS",ps,Hn);var ec,ym;for(ec="SSSS";ec.length<=9;ec+="S")Mt(ec,za);function Zy(E,I){I[js]=sn(("0."+E)*1e3)}for(ec="S";ec.length<=9;ec+="S")On(ec,Zy);ym=tn("Milliseconds",!1),Ye("z",0,0,"zoneAbbr"),Ye("zz",0,0,"zoneName");function o0(){return this._isUTC?"UTC":""}function a0(){return this._isUTC?"Coordinated Universal Time":""}var Jt=me.prototype;Jt.add=ni,Jt.calendar=am,Jt.clone=Zh,Jt.diff=Up,Jt.endOf=cl,Jt.format=Md,Jt.from=zy,Jt.fromNow=um,Jt.to=Df,Jt.toNow=Kl,Jt.get=du,Jt.invalidAt=Ky,Jt.isAfter=xv,Jt.isBefore=Qu,Jt.isBetween=Gl,Jt.isSame=Ea,Jt.isSameOrAfter=vu,Jt.isSameOrBefore=wa,Jt.isValid=Bd,Jt.lang=_u,Jt.locale=cm,Jt.localeData=lm,Jt.max=zo,Jt.min=Jh,Jt.parsingFlags=_x,Jt.set=fs,Jt.startOf=Zu,Jt.subtract=Ld,Jt.toArray=_v,Jt.toObject=pm,Jt.toDate=ll,Jt.toISOString=Cf,Jt.inspect=Af,typeof Symbol<"u"&&Symbol.for!=null&&(Jt[Symbol.for("nodejs.util.inspect.custom")]=function(){return"Moment<"+this.format()+">"}),Jt.toJSON=kf,Jt.toString=al,Jt.unix=$p,Jt.valueOf=Xa,Jt.creationData=e0,Jt.eraName=Vp,Jt.eraNarrow=Xy,Jt.eraAbbr=Sv,Jt.eraYear=jd,Jt.year=Wu,Jt.isLeapYear=Fl,Jt.weekYear=Rf,Jt.isoWeekYear=Qy,Jt.quarter=Jt.quarters=hm,Jt.month=hu,Jt.daysInMonth=em,Jt.week=Jt.weeks=tm,Jt.isoWeek=Jt.isoWeeks=Hh,Jt.weeksInYear=Jl,Jt.weeksInWeekYear=Hp,Jt.isoWeeksInYear=i0,Jt.isoWeeksInISOWeekYear=s0,Jt.date=Xl,Jt.day=Jt.days=Ns,Jt.weekday=wn,Jt.isoWeekday=Gu,Jt.dayOfYear=Pc,Jt.hour=Jt.hours=va,Jt.minute=Jt.minutes=mm,Jt.second=Jt.seconds=Ud,Jt.millisecond=Jt.milliseconds=ym,Jt.utcOffset=Pf,Jt.utc=im,Jt.local=sm,Jt.parseZone=ta,Jt.hasAlignedHourOffset=Sa,Jt.isDST=Ja,Jt.isLocal=Hl,Jt.isUtcOffset=Wl,Jt.isUtc=Ei,Jt.isUTC=Ei,Jt.zoneAbbr=o0,Jt.zoneName=a0,Jt.dates=Ve("dates accessor is deprecated. Use date instead.",Xl),Jt.months=Ve("months accessor is deprecated. Use month instead",hu),Jt.years=Ve("years accessor is deprecated. Use year instead",Wu),Jt.zone=Ve("moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/",bi),Jt.isDSTShifted=Ve("isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information",Vl);function fn(E){return Tn(E*1e3)}function ra(){return Tn.apply(null,arguments).parseZone()}function po(E){return E}var Pn=se.prototype;Pn.calendar=_e,Pn.longDateFormat=Tt,Pn.invalidDate=mt,Pn.ordinal=Yt,Pn.preparse=po,Pn.postformat=po,Pn.relativeTime=_t,Pn.pastFuture=bt,Pn.set=ot,Pn.eras=Yy,Pn.erasParse=Jy,Pn.erasConvertYear=fm,Pn.erasAbbrRegex=t0,Pn.erasNameRegex=Ta,Pn.erasNarrowRegex=If,Pn.months=Z0,Pn.monthsShort=kp,Pn.monthsParse=ga,Pn.monthsRegex=ns,Pn.monthsShortRegex=Ip,Pn.week=Nd,Pn.firstDayOfYear=bf,Pn.firstDayOfWeek=mu,Pn.weekdays=rl,Pn.weekdaysMin=zu,Pn.weekdaysShort=yu,Pn.weekdaysParse=Sc,Pn.weekdaysRegex=Gh,Pn.weekdaysShortRegex=Gs,Pn.weekdaysMinRegex=jl,Pn.isPM=Kh,Pn.meridiem=Lp;function Ua(E,I,q,z){var ee=Xe(),ke=P().set(z,I);return ee[q](ke,E)}function $d(E,I,q){if(m(E)&&(I=E,E=void 0),E=E||"",I!=null)return Ua(E,I,q,"month");var z,ee=[];for(z=0;z<12;z++)ee[z]=Ua(E,z,q,"month");return ee}function Js(E,I,q,z){typeof E=="boolean"?(m(I)&&(q=I,I=void 0),I=I||""):(I=E,q=I,E=!1,m(I)&&(q=I,I=void 0),I=I||"");var ee=Xe(),ke=E?ee._week.dow:0,xt,fr=[];if(q!=null)return Ua(I,(q+ke)%7,z,"day");for(xt=0;xt<7;xt++)fr[xt]=Ua(I,(xt+ke)%7,z,"day");return fr}function Vd(E,I){return $d(E,I,"months")}function Rn(E,I){return $d(E,I,"monthsShort")}function Ff(E,I,q){return Js(E,I,q,"weekdays")}function zp(E,I,q){return Js(E,I,q,"weekdaysShort")}function gm(E,I,q){return Js(E,I,q,"weekdaysMin")}ae("en",{eras:[{since:"0001-01-01",until:1/0,offset:1,name:"Anno Domini",narrow:"AD",abbr:"AD"},{since:"0000-12-31",until:-1/0,offset:1,name:"Before Christ",narrow:"BC",abbr:"BC"}],dayOfMonthOrdinalParse:/\d{1,2}(th|st|nd|rd)/,ordinal:function(E){var I=E%10,q=sn(E%100/10)===1?"th":I===1?"st":I===2?"nd":I===3?"rd":"th";return E+q}}),t.lang=Ve("moment.lang is deprecated. Use moment.locale instead.",ae),t.langData=Ve("moment.langData is deprecated. Use moment.localeData instead.",Xe);var Cc=Math.abs;function vm(){var E=this._data;return this._milliseconds=Cc(this._milliseconds),this._days=Cc(this._days),this._months=Cc(this._months),E.milliseconds=Cc(E.milliseconds),E.seconds=Cc(E.seconds),E.minutes=Cc(E.minutes),E.hours=Cc(E.hours),E.months=Cc(E.months),E.years=Cc(E.years),this}function u0(E,I,q,z){var ee=So(I,q);return E._milliseconds+=z*ee._milliseconds,E._days+=z*ee._days,E._months+=z*ee._months,E._bubble()}function Ql(E,I){return u0(this,E,I,1)}function Ar(E,I){return u0(this,E,I,-1)}function Gp(E){return E<0?Math.floor(E):Math.ceil(E)}function xm(){var E=this._milliseconds,I=this._days,q=this._months,z=this._data,ee,ke,xt,fr,dn;return E>=0&&I>=0&&q>=0||E<=0&&I<=0&&q<=0||(E+=Gp(Ac(q)+I)*864e5,I=0,q=0),z.milliseconds=E%1e3,ee=Si(E/1e3),z.seconds=ee%60,ke=Si(ee/60),z.minutes=ke%60,xt=Si(ke/60),z.hours=xt%24,I+=Si(xt/24),dn=Si(Eu(I)),q+=dn,I-=Gp(Ac(dn)),fr=Si(q/12),q%=12,z.days=I,z.months=q,z.years=fr,this}function Eu(E){return E*4800/146097}function Ac(E){return E*146097/4800}function Hd(E){if(!this.isValid())return NaN;var I,q,z=this._milliseconds;if(E=ge(E),E==="month"||E==="quarter"||E==="year")switch(I=this._days+z/864e5,q=this._months+Eu(I),E){case"month":return q;case"quarter":return q/3;case"year":return q/12}else switch(I=this._days+Math.round(Ac(this._months)),E){case"week":return I/7+z/6048e5;case"day":return I+z/864e5;case"hour":return I*24+z/36e5;case"minute":return I*1440+z/6e4;case"second":return I*86400+z/1e3;case"millisecond":return Math.floor(I*864e5)+z;default:throw new Error("Unknown unit "+E)}}function Qa(E){return function(){return this.as(E)}}var Lf=Qa("ms"),_m=Qa("s"),pl=Qa("m"),Wd=Qa("h"),Kp=Qa("d"),Mf=Qa("w"),tc=Qa("M"),Dc=Qa("Q"),zd=Qa("y"),Yp=Lf;function Pa(){return So(this)}function Ui(E){return E=ge(E),this.isValid()?this[E+"s"]():NaN}function Oi(E){return function(){return this.isValid()?this._data[E]:NaN}}var c0=Oi("milliseconds"),Za=Oi("seconds"),eg=Oi("minutes"),Bf=Oi("hours"),Sm=Oi("days"),bv=Oi("months"),bm=Oi("years");function l0(){return Si(this.days()/7)}var wu=Math.round,Zl={ss:44,s:45,m:45,h:22,d:26,w:null,M:11};function jf(E,I,q,z,ee){return ee.relativeTime(I||1,!!q,E,z)}function tg(E,I,q,z){var ee=So(E).abs(),ke=wu(ee.as("s")),xt=wu(ee.as("m")),fr=wu(ee.as("h")),dn=wu(ee.as("d")),fi=wu(ee.as("M")),ia=wu(ee.as("w")),eu=wu(ee.as("y")),qs=ke<=q.ss&&["s",ke]||ke<q.s&&["ss",ke]||xt<=1&&["m"]||xt<q.m&&["mm",xt]||fr<=1&&["h"]||fr<q.h&&["hh",fr]||dn<=1&&["d"]||dn<q.d&&["dd",dn];return q.w!=null&&(qs=qs||ia<=1&&["w"]||ia<q.w&&["ww",ia]),qs=qs||fi<=1&&["M"]||fi<q.M&&["MM",fi]||eu<=1&&["y"]||["yy",eu],qs[2]=I,qs[3]=+E>0,qs[4]=z,jf.apply(null,qs)}function rg(E){return E===void 0?wu:typeof E=="function"?(wu=E,!0):!1}function Gd(E,I){return Zl[E]===void 0?!1:I===void 0?Zl[E]:(Zl[E]=I,E==="s"&&(Zl.ss=I-1),!0)}function Ev(E,I){if(!this.isValid())return this.localeData().invalidDate();var q=!1,z=Zl,ee,ke;return typeof E=="object"&&(I=E,E=!1),typeof E=="boolean"&&(q=E),typeof I=="object"&&(z=Object.assign({},Zl,I),I.s!=null&&I.ss==null&&(z.ss=I.s-1)),ee=this.localeData(),ke=tg(this,!q,z,ee),q&&(ke=ee.pastFuture(+this,ke)),ee.postformat(ke)}var p0=Math.abs;function ep(E){return(E>0)-(E<0)||+E}function na(){if(!this.isValid())return this.localeData().invalidDate();var E=p0(this._milliseconds)/1e3,I=p0(this._days),q=p0(this._months),z,ee,ke,xt,fr=this.asSeconds(),dn,fi,ia,eu;return fr?(z=Si(E/60),ee=Si(z/60),E%=60,z%=60,ke=Si(q/12),q%=12,xt=E?E.toFixed(3).replace(/\.?0+$/,""):"",dn=fr<0?"-":"",fi=ep(this._months)!==ep(fr)?"-":"",ia=ep(this._days)!==ep(fr)?"-":"",eu=ep(this._milliseconds)!==ep(fr)?"-":"",dn+"P"+(ke?fi+ke+"Y":"")+(q?fi+q+"M":"")+(I?ia+I+"D":"")+(ee||z||E?"T":"")+(ee?eu+ee+"H":"")+(z?eu+z+"M":"")+(E?eu+xt+"S":"")):"P0D"}var qn=Ec.prototype;qn.isValid=Fd,qn.abs=vm,qn.add=Ql,qn.subtract=Ar,qn.as=Hd,qn.asMilliseconds=Lf,qn.asSeconds=_m,qn.asMinutes=pl,qn.asHours=Wd,qn.asDays=Kp,qn.asWeeks=Mf,qn.asMonths=tc,qn.asQuarters=Dc,qn.asYears=zd,qn.valueOf=Yp,qn._bubble=xm,qn.clone=Pa,qn.get=Ui,qn.milliseconds=c0,qn.seconds=Za,qn.minutes=eg,qn.hours=Bf,qn.days=Sm,qn.weeks=l0,qn.months=bv,qn.years=bm,qn.humanize=Ev,qn.toISOString=na,qn.toString=na,qn.toJSON=na,qn.locale=cm,qn.localeData=lm,qn.toIsoString=Ve("toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)",na),qn.lang=_u,Ye("X",0,0,"unix"),Ye("x",0,0,"valueOf"),Mt("x",rt),Mt("X",Xt),On("X",function(E,I,q){q._d=new Date(parseFloat(E)*1e3)}),On("x",function(E,I,q){q._d=new Date(sn(E))});return t.version="2.30.1",r(Tn),t.fn=Jt,t.min=Ka,t.max=Rd,t.now=wf,t.utc=P,t.unix=fn,t.months=Vd,t.isDate=y,t.locale=ae,t.invalid=M,t.duration=So,t.isMoment=Ce,t.weekdays=Ff,t.parseZone=ra,t.localeData=Xe,t.isDuration=qa,t.monthsShort=Rn,t.weekdaysMin=gm,t.defineLocale=Me,t.updateLocale=it,t.locales=gt,t.weekdaysShort=zp,t.normalizeUnits=ge,t.relativeTimeRounding=rg,t.relativeTimeThreshold=Gd,t.calendarFormat=xx,t.prototype=Jt,t.HTML5_FMT={DATETIME_LOCAL:"YYYY-MM-DDTHH:mm",DATETIME_LOCAL_SECONDS:"YYYY-MM-DDTHH:mm:ss",DATETIME_LOCAL_MS:"YYYY-MM-DDTHH:mm:ss.SSS",DATE:"YYYY-MM-DD",TIME:"HH:mm",TIME_SECONDS:"HH:mm:ss",TIME_MS:"HH:mm:ss.SSS",WEEK:"GGGG-[W]WW",MONTH:"YYYY-MM"},t})});function D0(){return!process.stdout.isTTY||process.env.FORCE_NON_TTY==="1"||process.env.CI==="true"||process.env.CI==="1"||process.env.PAGES_SOURCE==="skills"||process.env.EDGEONE_NON_INTERACTIVE==="1"}function gC({prefix:e="cli"}){return Vs.default.createElement(Bs.Text,{color:"grey"},"[",e,"]")}function yi(e,t="cli"){if(D0()){console.log(`\x1B[90m[${t}]\x1B[0m\x1B[31m[\u2718] \x1B[0m${e}`);return}let{unmount:r}=(0,Bs.render)(Vs.default.createElement(Bs.Text,null,Vs.default.createElement(gC,{prefix:t}),Vs.default.createElement(Bs.Text,{color:"red"},"[\u2718] "),e));r()}function vC(e,t="cli"){if(D0()){console.log(`\x1B[90m[${t}]\x1B[0m\x1B[32m[\u2714] \x1B[0m${e}`);return}let{unmount:r}=(0,Bs.render)(Vs.default.createElement(Bs.Text,null,Vs.default.createElement(gC,{prefix:t}),Vs.default.createElement(Bs.Text,{color:"green"},"[\u2714] "),e));r()}function pi(e,t="cli"){if(D0()){console.log(`\x1B[90m[${t}]\x1B[0m \x1B[33mWARNING:\x1B[0m ${e}`);return}let{unmount:r}=(0,Bs.render)(Vs.default.createElement(Bs.Text,null,Vs.default.createElement(gC,{prefix:t}),Vs.default.createElement(Bs.Text,{color:"orange"},"\u2757\uFE0F "),e));r()}function $z(e){if(D0()){console.log(e);return}let{unmount:t}=(0,Bs.render)(Vs.default.createElement(Bs.Text,{color:"cyan"},e));t()}function Dt(e,t="cli"){if(D0()){console.log(`\x1B[90m[${t}]\x1B[0m ${e}`);return}let{unmount:r}=(0,Bs.render)(Vs.default.createElement(Bs.Text,null,Vs.default.createElement(gC,{prefix:t})," ",e));r()}function HR({timestamp:e}){return Vs.default.createElement(Bs.Box,{width:13},Vs.default.createElement(Bs.Text,{color:"grey"},(0,Wb.default)(e).format("HH:mm:ss.SSS")))}function Vz(e,t){if(D0()){console.log(`${(0,Wb.default)(t).format("HH:mm:ss.SSS")} ${e}`);return}let{unmount:r}=(0,Bs.render)(Vs.default.createElement(Bs.Box,null,Vs.default.createElement(HR,{timestamp:t}),Vs.default.createElement(Bs.Text,null,e)));r()}function Hz(e,t){if(D0()){console.log(`${(0,Wb.default)(t).format("HH:mm:ss.SSS")} [WARNING] ${e}`);return}let{unmount:r}=(0,Bs.render)(Vs.default.createElement(Bs.Box,null,Vs.default.createElement(HR,{timestamp:t}),Vs.default.createElement(Bs.Text,{color:"white",backgroundColor:"yellow"},"[WARNING]"),Vs.default.createElement(Bs.Text,null," ",e)));r()}function WR(e,t){if(D0()){console.log(`${(0,Wb.default)(t).format("HH:mm:ss.SSS")} [ERROR] ${e}`);return}let{unmount:r}=(0,Bs.render)(Vs.default.createElement(Bs.Box,null,Vs.default.createElement(HR,{timestamp:t}),Vs.default.createElement(Bs.Text,{color:"white",backgroundColor:"red"},"[ERROR]"),Vs.default.createElement(Bs.Text,null," ",e)));r()}var Bs,Vs,Wb,ua=ht(()=>{Bs=Lt(yC()),Vs=Lt(yo()),Wb=Lt(Uz())});var zz,Wz=ht(()=>{zz={name:"edgeone",version:"1.6.25",description:"Command-line interface for TencentCloud Pages Functions",bin:{edgeone:"./edgeone-bin/edgeone.js"},files:["./edgeone-bin/edgeone.js","./edgeone-dist/cli.js","./edgeone-dist/pages/templates","./edgeone-dist/pages/dev/runner-worker.js","./edgeone-dist/pages/observability-python/**","./edgeone-dist/libs-pages-blob-python/**","./edgeone-dist/libs-pages-agent-toolkit/**","./edgeone-dist/studio/**","./libs-pages-blob-python/**","./libs-pages-agent-toolkit/**"],author:"",keywords:["tencent","edgeone","edgefunctions","edgeone","cli","typescript"],scripts:{clean:"rimraf ./edgeone-dist ./edgeone-bin ./libs-node-ai ./libs-kv-client",bundle:"node -r esbuild-register ./scripts/bundle.ts",watch:"node -r esbuild-register ./scripts/bundle.ts watch",build:"npm run clean && npm run build:pages-ai && npm run build:kv-client && npm run prepare:blob-wheel && npm run prepare:agent-toolkit-wheel && npm run bundle","build:pages-ai":"node ./scripts/build-pages-ai.js","build:kv-client":"node ./scripts/build-kv-client.js","prepare:blob-wheel":"node ./scripts/prepare-pages-blob-wheel.js","prepare:agent-toolkit-wheel":"node ./scripts/prepare-pages-agent-toolkit-wheel.js","verify:publish-assets":"node ./scripts/verify-publish-assets.js","upload:agent-version-manifest":"node ./scripts/upload-agent-version-manifest.js",format:'prettier --write "src/**/*.{ts,tsx,js,jsx,json,md}" "scripts/**/*.{ts,js}" "*.{json,md}"',prepack:"npm run build && npm run verify:publish-assets",prepublishOnly:"npm run build && npm run verify:publish-assets",test:"vitest run","test:watch":"vitest","test:coverage":"vitest run --coverage","test:observability":"vitest run --config src/agent/observability/node/tests/vitest.config.ts && cd src/agent/observability/python && uv run pytest tests/ -q"},dependencies:{"@edgeone/framework-detect":"^0.0.2","@edgeone/is-spa":"^0.0.3","@edgeone/nuxt-pages":"1.1.0","@edgeone/opennextjs-pages":"0.2.10","@edgeone/pages-agent-toolkit":"^0.1.34","@edgeone/pages-blob":"^0.0.16",archiver:"^7.0.1",chokidar:"^4.0.1","common-path-prefix":"^1.0.0","cos-nodejs-sdk-v5":"^2.14.7","cross-spawn":"^7.0.6",crypto:"^1.0.1","detect-port":"^2.1.0",esbuild:"^0.19.2","esbuild-plugin-polyfill-node":"^0.3.0","esbuild-plugin-vue":"^0.2.4","fast-glob":"^3.3.0","fs-extra":"^11.3.1",giget:"^2.0.0","ink-table":"^3.1.0",inquirer:"^8.2.4",install:"^0.13.0",lodash:"^4.17.21","mime-types":"^3.0.1",minimatch:"^9.0.5","node-persist":"^4.0.3",npm:"^10.9.1",open:"^8.4.2","p-map":"^5.5.0","parse-gitignore":"^2.0.0",portfinder:"^1.0.32",undici:"^5.29.0",vitest:"^4.0.17"},devDependencies:{"@babel/generator":"^7.28.0","@babel/parser":"^7.28.0","@babel/traverse":"^7.28.0","@babel/types":"^7.28.0","@opentelemetry/api":"^1.9.1","@opentelemetry/core":"^1.30.1","@opentelemetry/exporter-metrics-otlp-http":"^0.55.0","@opentelemetry/exporter-trace-otlp-http":"^0.55.0","@opentelemetry/instrumentation":"^0.55.0","@opentelemetry/otlp-transformer":"^0.55.0","@opentelemetry/resources":"^1.30.1","@opentelemetry/sdk-metrics":"^1.30.1","@opentelemetry/sdk-trace-base":"^1.30.1","@opentelemetry/sdk-trace-node":"^1.30.1","@opentelemetry/semantic-conventions":"^1.40.0","@tencent/capi-nodejs-sdk":"^2.3.2","@types/http-proxy":"^1.17.12","@types/inquirer":"^9.0.8","@types/ip":"^1.1.0","@types/lodash":"^4.14.198","@types/prompts":"^2.4.4","@types/react":"^17.0.2","@types/uuid":"^9.0.3","@types/ws":"^8.5.7","@types/yargs":"^17.0.24","@vitest/coverage-v8":"^4.0.17",axios:"^1.7.9",chalk:"^5.3.0",cookie:"^1.0.2",dotenv:"^16.3.1","esbuild-register":"^3.6.0",execa:"^7.1.1","http-proxy":"^1.18.1",husky:"^8.0.3",ink:"^3.2.0",ip:"^2.0.1",json5:"^2.2.3","lint-staged":"^15.2.0",lodash:"^4.17.21",moment:"^2.30.1","node-fetch":"^3.3.2",prettier:"^3.1.1",prompts:"^2.4.2",protobufjs:"^8.4.2",react:"^17.0.2",rimraf:"^6.0.1",semiver:"^1.1.0",sirv:"^2.0.3","tencentcloud-cls-sdk-js-web":"^1.0.13","ts-node":"^10.9.2",typescript:"^5.9.3","update-check":"^1.5.4",uuid:"^9.0.0",ws:"^8.14.2",yargs:"^17.6.2",zod:"^3.23.8","zod-to-json-schema":"^3.23.5"},engines:{node:">=12"},"lint-staged":{"*.{ts,tsx,js,jsx,json,md}":["prettier --write"]}}});function bIe(){var e,t;return{run_id:SIe,cli_version:(t=(e=zz)==null?void 0:e.version)!=null?t:"unknown",node_version:process.version,os_platform:GR.default.platform(),os_arch:GR.default.arch(),app_type:"cli",app_id:process.env.AppId||void 0,uin:process.env.Uin||void 0,instance_id:process.env.ProjectId||void 0,is_ci:process.env.CI==="true"}}function EIe(e,t){try{if(typeof process.send!="function")return;process.send(JSON.stringify({name:e,value:JSON.stringify(t)}))}catch{}}function lu(e){var r;let t={...bIe(),...e};EIe((r=t.event_name)!=null?r:"unknown",t)}function ld(e){if(e==null)return{message:"unknown error",stack:""};if(typeof e=="string")return{message:xC(e,zR),stack:""};if(typeof e=="object"){let t=e,r=xC(typeof t.message=="string"?t.message:String(t),zR),s=xC(typeof t.stack=="string"?t.stack:"",wIe);return{message:r,stack:s}}return{message:xC(String(e),zR),stack:""}}function xC(e,t){return e.length>t?e.slice(0,t)+"\u2026[truncated]":e}var GR,uu,cu,SIe,KR,zR,wIe,dy=ht(()=>{GR=Lt(require("os"));Wz();uu={COMMAND:"command",REQUEST:"request",LOCAL_FLOW:"local_flow",EXIT:"exit"},cu={SUCCESS:"success",FAIL:"fail",START:"start"},SIe=`cli-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;KR=(e,t)=>{let r=ld(t);lu({event_name:"error",event_scope:uu.COMMAND,event_result:cu.FAIL,error_message:`${e} ${r.message}`.trim(),error_stack:r.stack})},zR=500,wIe=2e3});var zb,S2,YR=ht(()=>{zb={NEXTJS:"nextjs",NUXTJS:"nuxtjs",ASTRO:"astro",UNKNOWN:"unknown"},S2={FRAMEWORK_DETECT:"framework_detect",PLUGIN_RESOLVE:"plugin_resolve",PLUGIN_LOAD:"plugin_load",PLUGIN_HOOK:"plugin_hook",CONFIG_LOAD:"config_load"}});function CIe(e){if((e==null?void 0:e.code)===PIe)return!0;let t=typeof e=="string"?e:e==null?void 0:e.message;return t==null?void 0:t.includes(TIe)}async function Mg(e=!1){try{let t=await PP(e);return lu({event_name:"Config:Load:Success",event_scope:uu.LOCAL_FLOW,event_phase:S2.CONFIG_LOAD,event_result:cu.SUCCESS,has_build_command:(t==null?void 0:t.buildCommand)!=null,has_install_command:(t==null?void 0:t.installCommand)!=null,has_output_directory:(t==null?void 0:t.outputDirectory)!=null,has_node_version:(t==null?void 0:t.nodeVersion)!=null}),t}catch(t){let r=ld(t);if(lu({event_name:"Config:Load:Fail",event_scope:uu.LOCAL_FLOW,event_phase:S2.CONFIG_LOAD,event_result:cu.FAIL,error_message:r.message}),CIe(t))throw t;return od()&&console.error("%c [ error ]-80","font-size:13px; background:pink; color:#bf2c9f;",t),null}}var TIe,PIe,JR=ht(()=>{n2();_P();dy();YR();TIe="[BLOCKING_CONFIG_ERROR]",PIe="BLOCKING_CONFIG_ERROR"});var _C,fc,SC=ht(()=>{_C=[{funcName:"onRequestGet",method:"GET"},{funcName:"onRequestPost",method:"POST"},{funcName:"onRequestDelete",method:"DELETE"},{funcName:"onRequestPatch",method:"PATCH"},{funcName:"onRequestPut",method:"PUT"},{funcName:"onRequestHead",method:"HEAD"},{funcName:"onRequestOptions",method:"OPTIONS"}],fc=["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"]});async function AIe(e){let t;bC.default.statSync(e).isFile()?t=b2.default.resolve(b2.default.dirname(e)):t=e;let r=b2.default.parse(t).root;if(t===r)return null;for(;t!==r;){let s=b2.default.join(t,"package.json");try{return await bC.default.promises.access(s),s}catch{if(t=b2.default.dirname(t),t===r)break}}return null}async function E2(e){if(e.endsWith(".mjs"))return"esm";if(e.endsWith(".cjs"))return"commonjs";try{let t=await AIe(e);if(t&&JSON.parse(await bC.default.promises.readFile(t,"utf-8")).type==="module")return"esm"}catch(t){console.warn("Failed to read package.json:",t)}return"commonjs"}var bC,b2,Gb=ht(()=>{bC=Lt(require("fs")),b2=Lt(require("path"))});function kIe(e){let t=XR.default.extname(e);return DIe[t]||"ts"}function NIe(e){return e.split(",").map(t=>t.trim()).map(t=>{let r=t.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(!r)return"";let[,s,a]=r;return!OIe.has(a)||s===a?"":`const ${a} = ${s};`}).filter(Boolean).join(`
|
|
145
|
+
`+new Error().stack),q=!1}return I.apply(this,arguments)},I)}var Re={};function Ct(E,I){t.deprecationHandler!=null&&t.deprecationHandler(E,I),Re[E]||(Ie(I),Re[E]=!0)}t.suppressDeprecationWarnings=!1,t.deprecationHandler=null;function ct(E){return typeof Function<"u"&&E instanceof Function||Object.prototype.toString.call(E)==="[object Function]"}function ot(E){var I,q;for(q in E)n(E,q)&&(I=E[q],ct(I)?this[q]=I:this["_"+q]=I);this._config=E,this._dayOfMonthOrdinalParseLenient=new RegExp((this._dayOfMonthOrdinalParse.source||this._ordinalParse.source)+"|"+/\d{1,2}/.source)}function je(E,I){var q=b({},E),z;for(z in I)n(I,z)&&(a(E[z])&&a(I[z])?(q[z]={},b(q[z],E[z]),b(q[z],I[z])):I[z]!=null?q[z]=I[z]:delete q[z]);for(z in E)n(E,z)&&!n(I,z)&&a(E[z])&&(q[z]=b({},q[z]));return q}function se(E){E!=null&&this.set(E)}var De;Object.keys?De=Object.keys:De=function(E){var I,q=[];for(I in E)n(E,I)&&q.push(I);return q};var ze={sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"};function _e(E,I,q){var z=this._calendar[E]||this._calendar.sameElse;return ct(z)?z.call(I,q):z}function Ee(E,I,q){var z=""+Math.abs(E),ee=I-z.length,ke=E>=0;return(ke?q?"+":"":"-")+Math.pow(10,Math.max(0,ee)).toString().substr(1)+z}var Fe=/(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|N{1,5}|YYYYYY|YYYYY|YYYY|YY|y{2,4}|yo?|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g,nt=/(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g,vt={},jt={};function Ye(E,I,q,z){var ee=z;typeof z=="string"&&(ee=function(){return this[z]()}),E&&(jt[E]=ee),I&&(jt[I[0]]=function(){return Ee(ee.apply(this,arguments),I[1],I[2])}),q&&(jt[q]=function(){return this.localeData().ordinal(ee.apply(this,arguments),E)})}function At(E){return E.match(/\[[\s\S]/)?E.replace(/^\[|\]$/g,""):E.replace(/\\/g,"")}function Ae(E){var I=E.match(Fe),q,z;for(q=0,z=I.length;q<z;q++)jt[I[q]]?I[q]=jt[I[q]]:I[q]=At(I[q]);return function(ee){var ke="",xt;for(xt=0;xt<z;xt++)ke+=ct(I[xt])?I[xt].call(ee,E):I[xt];return ke}}function Ze(E,I){return E.isValid()?(I=lt(I,E.localeData()),vt[I]=vt[I]||Ae(I),vt[I](E)):E.localeData().invalidDate()}function lt(E,I){var q=5;function z(ee){return I.longDateFormat(ee)||ee}for(nt.lastIndex=0;q>=0&&nt.test(E);)E=E.replace(nt,z),nt.lastIndex=0,q-=1;return E}var Ut={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"};function Tt(E){var I=this._longDateFormat[E],q=this._longDateFormat[E.toUpperCase()];return I||!q?I:(this._longDateFormat[E]=q.match(Fe).map(function(z){return z==="MMMM"||z==="MM"||z==="DD"||z==="dddd"?z.slice(1):z}).join(""),this._longDateFormat[E])}var ft="Invalid date";function mt(){return this._invalidDate}var C="%d",kt=/\d{1,2}/;function Yt(E){return this._ordinal.replace("%d",E)}var Jr={future:"in %s",past:"%s ago",s:"a few seconds",ss:"%d seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",w:"a week",ww:"%d weeks",M:"a month",MM:"%d months",y:"a year",yy:"%d years"};function _t(E,I,q,z){var ee=this._relativeTime[q];return ct(ee)?ee(E,I,q,z):ee.replace(/%d/i,E)}function bt(E,I){var q=this._relativeTime[E>0?"future":"past"];return ct(q)?q(I):q.replace(/%s/i,I)}var tr={D:"date",dates:"date",date:"date",d:"day",days:"day",day:"day",e:"weekday",weekdays:"weekday",weekday:"weekday",E:"isoWeekday",isoweekdays:"isoWeekday",isoweekday:"isoWeekday",DDD:"dayOfYear",dayofyears:"dayOfYear",dayofyear:"dayOfYear",h:"hour",hours:"hour",hour:"hour",ms:"millisecond",milliseconds:"millisecond",millisecond:"millisecond",m:"minute",minutes:"minute",minute:"minute",M:"month",months:"month",month:"month",Q:"quarter",quarters:"quarter",quarter:"quarter",s:"second",seconds:"second",second:"second",gg:"weekYear",weekyears:"weekYear",weekyear:"weekYear",GG:"isoWeekYear",isoweekyears:"isoWeekYear",isoweekyear:"isoWeekYear",w:"week",weeks:"week",week:"week",W:"isoWeek",isoweeks:"isoWeek",isoweek:"isoWeek",y:"year",years:"year",year:"year"};function ge(E){return typeof E=="string"?tr[E]||tr[E.toLowerCase()]:void 0}function Je(E){var I={},q,z;for(z in E)n(E,z)&&(q=ge(z),q&&(I[q]=E[z]));return I}var $t={date:9,day:11,weekday:11,isoWeekday:11,dayOfYear:4,hour:13,millisecond:16,minute:14,month:8,quarter:7,second:15,weekYear:1,isoWeekYear:1,week:5,isoWeek:5,year:1};function rr(E){var I=[],q;for(q in E)n(E,q)&&I.push({unit:q,priority:$t[q]});return I.sort(function(z,ee){return z.priority-ee.priority}),I}var $r=/\d/,Vr=/\d\d/,Hn=/\d{3}/,jn=/\d{4}/,ei=/[+-]?\d{6}/,En=/\d\d?/,$o=/\d\d\d\d?/,Qo=/\d\d\d\d\d\d?/,ps=/\d{1,3}/,Vo=/\d{1,4}/,Vu=/[+-]?\d{1,6}/,za=/\d+/,rt=/[+-]?\d+/,Ft=/Z|[+-]\d\d:?\d\d/gi,It=/Z|[+-]\d\d(?::?\d\d)?/gi,Xt=/[+-]?\d+(\.\d{1,3})?/,Ir=/[0-9]{0,256}['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFF07\uFF10-\uFFEF]{1,256}|[\u0600-\u06FF\/]{1,256}(\s*?[\u0600-\u06FF]{1,256}){1,2}/i,xr=/^[1-9]\d?/,In=/^([1-9]\d|\d)/,_i;_i={};function Mt(E,I,q){_i[E]=ct(I)?I:function(z,ee){return z&&q?q:I}}function Ai(E,I){return n(_i,E)?_i[E](I._strict,I._locale):new RegExp(Ps(E))}function Ps(E){return Di(E.replace("\\","").replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,function(I,q,z,ee,ke){return q||z||ee||ke}))}function Di(E){return E.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}function Si(E){return E<0?Math.ceil(E)||0:Math.floor(E)}function sn(E){var I=+E,q=0;return I!==0&&isFinite(I)&&(q=Si(I)),q}var Ws={};function On(E,I){var q,z=I,ee;for(typeof E=="string"&&(E=[E]),m(I)&&(z=function(ke,xt){xt[I]=sn(ke)}),ee=E.length,q=0;q<ee;q++)Ws[E[q]]=z}function Ss(E,I){On(E,function(q,z,ee,ke){ee._w=ee._w||{},I(q,ee._w,ee,ke)})}function Hu(E,I,q){I!=null&&n(Ws,E)&&Ws[E](I,q._a,q,E)}function to(E){return E%4===0&&E%100!==0||E%400===0}var ur=0,Ao=1,co=2,Cs=3,Do=4,lo=5,js=6,Zc=7,fu=8;Ye("Y",0,0,function(){var E=this.year();return E<=9999?Ee(E,4):"+"+E}),Ye(0,["YY",2],0,function(){return this.year()%100}),Ye(0,["YYYY",4],0,"year"),Ye(0,["YYYYY",5],0,"year"),Ye(0,["YYYYYY",6,!0],0,"year"),Mt("Y",rt),Mt("YY",En,Vr),Mt("YYYY",Vo,jn),Mt("YYYYY",Vu,ei),Mt("YYYYYY",Vu,ei),On(["YYYYY","YYYYYY"],ur),On("YYYY",function(E,I){I[ur]=E.length===2?t.parseTwoDigitYear(E):sn(E)}),On("YY",function(E,I){I[ur]=t.parseTwoDigitYear(E)}),On("Y",function(E,I){I[ur]=parseInt(E,10)});function Oa(E){return to(E)?366:365}t.parseTwoDigitYear=function(E){return sn(E)+(sn(E)>68?1900:2e3)};var Wu=tn("FullYear",!0);function Fl(){return to(this.year())}function tn(E,I){return function(q){return q!=null?(el(this,E,q),t.updateOffset(this,I),this):vc(this,E)}}function vc(E,I){if(!E.isValid())return NaN;var q=E._d,z=E._isUTC;switch(I){case"Milliseconds":return z?q.getUTCMilliseconds():q.getMilliseconds();case"Seconds":return z?q.getUTCSeconds():q.getSeconds();case"Minutes":return z?q.getUTCMinutes():q.getMinutes();case"Hours":return z?q.getUTCHours():q.getHours();case"Date":return z?q.getUTCDate():q.getDate();case"Day":return z?q.getUTCDay():q.getDay();case"Month":return z?q.getUTCMonth():q.getMonth();case"FullYear":return z?q.getUTCFullYear():q.getFullYear();default:return NaN}}function el(E,I,q){var z,ee,ke,xt,fr;if(!(!E.isValid()||isNaN(q))){switch(z=E._d,ee=E._isUTC,I){case"Milliseconds":return void(ee?z.setUTCMilliseconds(q):z.setMilliseconds(q));case"Seconds":return void(ee?z.setUTCSeconds(q):z.setSeconds(q));case"Minutes":return void(ee?z.setUTCMinutes(q):z.setMinutes(q));case"Hours":return void(ee?z.setUTCHours(q):z.setHours(q));case"Date":return void(ee?z.setUTCDate(q):z.setDate(q));case"FullYear":break;default:return}ke=q,xt=E.month(),fr=E.date(),fr=fr===29&&xt===1&&!to(ke)?28:fr,ee?z.setUTCFullYear(ke,xt,fr):z.setFullYear(ke,xt,fr)}}function du(E){return E=ge(E),ct(this[E])?this[E]():this}function fs(E,I){if(typeof E=="object"){E=Je(E);var q=rr(E),z,ee=q.length;for(z=0;z<ee;z++)this[q[z].unit](E[q[z].unit])}else if(E=ge(E),ct(this[E]))return this[E](I);return this}function Ji(E,I){return(E%I+I)%I}var Bi;Array.prototype.indexOf?Bi=Array.prototype.indexOf:Bi=function(E){var I;for(I=0;I<this.length;++I)if(this[I]===E)return I;return-1};function zs(E,I){if(isNaN(E)||isNaN(I))return NaN;var q=Ji(I,12);return E+=(I-q)/12,q===1?to(E)?29:28:31-q%7%2}Ye("M",["MM",2],"Mo",function(){return this.month()+1}),Ye("MMM",0,0,function(E){return this.localeData().monthsShort(this,E)}),Ye("MMMM",0,0,function(E){return this.localeData().months(this,E)}),Mt("M",En,xr),Mt("MM",En,Vr),Mt("MMM",function(E,I){return I.monthsShortRegex(E)}),Mt("MMMM",function(E,I){return I.monthsRegex(E)}),On(["M","MM"],function(E,I){I[Ao]=sn(E)-1}),On(["MMM","MMMM"],function(E,I,q,z){var ee=q._locale.monthsParse(E,z,q._strict);ee!=null?I[Ao]=ee:g(q).invalidMonth=E});var ko="January_February_March_April_May_June_July_August_September_October_November_December".split("_"),Na="Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),Zo=/D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/,Io=Ir,Ll=Ir;function Z0(E,I){return E?s(this._months)?this._months[E.month()]:this._months[(this._months.isFormat||Zo).test(I)?"format":"standalone"][E.month()]:s(this._months)?this._months:this._months.standalone}function kp(E,I){return E?s(this._monthsShort)?this._monthsShort[E.month()]:this._monthsShort[Zo.test(I)?"format":"standalone"][E.month()]:s(this._monthsShort)?this._monthsShort:this._monthsShort.standalone}function Ml(E,I,q){var z,ee,ke,xt=E.toLocaleLowerCase();if(!this._monthsParse)for(this._monthsParse=[],this._longMonthsParse=[],this._shortMonthsParse=[],z=0;z<12;++z)ke=P([2e3,z]),this._shortMonthsParse[z]=this.monthsShort(ke,"").toLocaleLowerCase(),this._longMonthsParse[z]=this.months(ke,"").toLocaleLowerCase();return q?I==="MMM"?(ee=Bi.call(this._shortMonthsParse,xt),ee!==-1?ee:null):(ee=Bi.call(this._longMonthsParse,xt),ee!==-1?ee:null):I==="MMM"?(ee=Bi.call(this._shortMonthsParse,xt),ee!==-1?ee:(ee=Bi.call(this._longMonthsParse,xt),ee!==-1?ee:null)):(ee=Bi.call(this._longMonthsParse,xt),ee!==-1?ee:(ee=Bi.call(this._shortMonthsParse,xt),ee!==-1?ee:null))}function ga(E,I,q){var z,ee,ke;if(this._monthsParseExact)return Ml.call(this,E,I,q);for(this._monthsParse||(this._monthsParse=[],this._longMonthsParse=[],this._shortMonthsParse=[]),z=0;z<12;z++){if(ee=P([2e3,z]),q&&!this._longMonthsParse[z]&&(this._longMonthsParse[z]=new RegExp("^"+this.months(ee,"").replace(".","")+"$","i"),this._shortMonthsParse[z]=new RegExp("^"+this.monthsShort(ee,"").replace(".","")+"$","i")),!q&&!this._monthsParse[z]&&(ke="^"+this.months(ee,"")+"|^"+this.monthsShort(ee,""),this._monthsParse[z]=new RegExp(ke.replace(".",""),"i")),q&&I==="MMMM"&&this._longMonthsParse[z].test(E))return z;if(q&&I==="MMM"&&this._shortMonthsParse[z].test(E))return z;if(!q&&this._monthsParse[z].test(E))return z}}function qt(E,I){if(!E.isValid())return E;if(typeof I=="string"){if(/^\d+$/.test(I))I=sn(I);else if(I=E.localeData().monthsParse(I),!m(I))return E}var q=I,z=E.date();return z=z<29?z:Math.min(z,zs(E.year(),q)),E._isUTC?E._d.setUTCMonth(q,z):E._d.setMonth(q,z),E}function hu(E){return E!=null?(qt(this,E),t.updateOffset(this,!0),this):vc(this,"Month")}function em(){return zs(this.year(),this.month())}function Ip(E){return this._monthsParseExact?(n(this,"_monthsRegex")||xc.call(this),E?this._monthsShortStrictRegex:this._monthsShortRegex):(n(this,"_monthsShortRegex")||(this._monthsShortRegex=Io),this._monthsShortStrictRegex&&E?this._monthsShortStrictRegex:this._monthsShortRegex)}function ns(E){return this._monthsParseExact?(n(this,"_monthsRegex")||xc.call(this),E?this._monthsStrictRegex:this._monthsRegex):(n(this,"_monthsRegex")||(this._monthsRegex=Ll),this._monthsStrictRegex&&E?this._monthsStrictRegex:this._monthsRegex)}function xc(){function E(dn,fi){return fi.length-dn.length}var I=[],q=[],z=[],ee,ke,xt,fr;for(ee=0;ee<12;ee++)ke=P([2e3,ee]),xt=Di(this.monthsShort(ke,"")),fr=Di(this.months(ke,"")),I.push(xt),q.push(fr),z.push(fr),z.push(xt);I.sort(E),q.sort(E),z.sort(E),this._monthsRegex=new RegExp("^("+z.join("|")+")","i"),this._monthsShortRegex=this._monthsRegex,this._monthsStrictRegex=new RegExp("^("+q.join("|")+")","i"),this._monthsShortStrictRegex=new RegExp("^("+I.join("|")+")","i")}function Vh(E,I,q,z,ee,ke,xt){var fr;return E<100&&E>=0?(fr=new Date(E+400,I,q,z,ee,ke,xt),isFinite(fr.getFullYear())&&fr.setFullYear(E)):fr=new Date(E,I,q,z,ee,ke,xt),fr}function Sf(E){var I,q;return E<100&&E>=0?(q=Array.prototype.slice.call(arguments),q[0]=E+400,I=new Date(Date.UTC.apply(null,q)),isFinite(I.getUTCFullYear())&&I.setUTCFullYear(E)):I=new Date(Date.UTC.apply(null,arguments)),I}function tl(E,I,q){var z=7+I-q,ee=(7+Sf(E,0,z).getUTCDay()-I)%7;return-ee+z-1}function Od(E,I,q,z,ee){var ke=(7+q-z)%7,xt=tl(E,z,ee),fr=1+7*(I-1)+ke+xt,dn,fi;return fr<=0?(dn=E-1,fi=Oa(dn)+fr):fr>Oa(E)?(dn=E+1,fi=fr-Oa(E)):(dn=E,fi=fr),{year:dn,dayOfYear:fi}}function or(E,I,q){var z=tl(E.year(),I,q),ee=Math.floor((E.dayOfYear()-z-1)/7)+1,ke,xt;return ee<1?(xt=E.year()-1,ke=ee+ji(xt,I,q)):ee>ji(E.year(),I,q)?(ke=ee-ji(E.year(),I,q),xt=E.year()+1):(xt=E.year(),ke=ee),{week:ke,year:xt}}function ji(E,I,q){var z=tl(E,I,q),ee=tl(E+1,I,q);return(Oa(E)-z+ee)/7}Ye("w",["ww",2],"wo","week"),Ye("W",["WW",2],"Wo","isoWeek"),Mt("w",En,xr),Mt("ww",En,Vr),Mt("W",En,xr),Mt("WW",En,Vr),Ss(["w","ww","W","WW"],function(E,I,q,z){I[z.substr(0,1)]=sn(E)});function Nd(E){return or(E,this._week.dow,this._week.doy).week}var Bl={dow:0,doy:6};function mu(){return this._week.dow}function bf(){return this._week.doy}function tm(E){var I=this.localeData().week(this);return E==null?I:this.add((E-I)*7,"d")}function Hh(E){var I=or(this,1,4).week;return E==null?I:this.add((E-I)*7,"d")}Ye("d",0,"do","day"),Ye("dd",0,0,function(E){return this.localeData().weekdaysMin(this,E)}),Ye("ddd",0,0,function(E){return this.localeData().weekdaysShort(this,E)}),Ye("dddd",0,0,function(E){return this.localeData().weekdays(this,E)}),Ye("e",0,0,"weekday"),Ye("E",0,0,"isoWeekday"),Mt("d",En),Mt("e",En),Mt("E",En),Mt("dd",function(E,I){return I.weekdaysMinRegex(E)}),Mt("ddd",function(E,I){return I.weekdaysShortRegex(E)}),Mt("dddd",function(E,I){return I.weekdaysRegex(E)}),Ss(["dd","ddd","dddd"],function(E,I,q,z){var ee=q._locale.weekdaysParse(E,z,q._strict);ee!=null?I.d=ee:g(q).invalidWeekday=E}),Ss(["d","e","E"],function(E,I,q,z){I[z]=sn(E)});function rm(E,I){return typeof E!="string"?E:isNaN(E)?(E=I.weekdaysParse(E),typeof E=="number"?E:null):parseInt(E,10)}function Ra(E,I){return typeof E=="string"?I.weekdaysParse(E)%7||7:isNaN(E)?null:E}function Fa(E,I){return E.slice(I,7).concat(E.slice(0,I))}var Wh="Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),zh="Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),Op="Su_Mo_Tu_We_Th_Fr_Sa".split("_"),ea=Ir,Np=Ir,La=Ir;function rl(E,I){var q=s(this._weekdays)?this._weekdays:this._weekdays[E&&E!==!0&&this._weekdays.isFormat.test(I)?"format":"standalone"];return E===!0?Fa(q,this._week.dow):E?q[E.day()]:q}function yu(E){return E===!0?Fa(this._weekdaysShort,this._week.dow):E?this._weekdaysShort[E.day()]:this._weekdaysShort}function zu(E){return E===!0?Fa(this._weekdaysMin,this._week.dow):E?this._weekdaysMin[E.day()]:this._weekdaysMin}function _c(E,I,q){var z,ee,ke,xt=E.toLocaleLowerCase();if(!this._weekdaysParse)for(this._weekdaysParse=[],this._shortWeekdaysParse=[],this._minWeekdaysParse=[],z=0;z<7;++z)ke=P([2e3,1]).day(z),this._minWeekdaysParse[z]=this.weekdaysMin(ke,"").toLocaleLowerCase(),this._shortWeekdaysParse[z]=this.weekdaysShort(ke,"").toLocaleLowerCase(),this._weekdaysParse[z]=this.weekdays(ke,"").toLocaleLowerCase();return q?I==="dddd"?(ee=Bi.call(this._weekdaysParse,xt),ee!==-1?ee:null):I==="ddd"?(ee=Bi.call(this._shortWeekdaysParse,xt),ee!==-1?ee:null):(ee=Bi.call(this._minWeekdaysParse,xt),ee!==-1?ee:null):I==="dddd"?(ee=Bi.call(this._weekdaysParse,xt),ee!==-1||(ee=Bi.call(this._shortWeekdaysParse,xt),ee!==-1)?ee:(ee=Bi.call(this._minWeekdaysParse,xt),ee!==-1?ee:null)):I==="ddd"?(ee=Bi.call(this._shortWeekdaysParse,xt),ee!==-1||(ee=Bi.call(this._weekdaysParse,xt),ee!==-1)?ee:(ee=Bi.call(this._minWeekdaysParse,xt),ee!==-1?ee:null)):(ee=Bi.call(this._minWeekdaysParse,xt),ee!==-1||(ee=Bi.call(this._weekdaysParse,xt),ee!==-1)?ee:(ee=Bi.call(this._shortWeekdaysParse,xt),ee!==-1?ee:null))}function Sc(E,I,q){var z,ee,ke;if(this._weekdaysParseExact)return _c.call(this,E,I,q);for(this._weekdaysParse||(this._weekdaysParse=[],this._minWeekdaysParse=[],this._shortWeekdaysParse=[],this._fullWeekdaysParse=[]),z=0;z<7;z++){if(ee=P([2e3,1]).day(z),q&&!this._fullWeekdaysParse[z]&&(this._fullWeekdaysParse[z]=new RegExp("^"+this.weekdays(ee,"").replace(".","\\.?")+"$","i"),this._shortWeekdaysParse[z]=new RegExp("^"+this.weekdaysShort(ee,"").replace(".","\\.?")+"$","i"),this._minWeekdaysParse[z]=new RegExp("^"+this.weekdaysMin(ee,"").replace(".","\\.?")+"$","i")),this._weekdaysParse[z]||(ke="^"+this.weekdays(ee,"")+"|^"+this.weekdaysShort(ee,"")+"|^"+this.weekdaysMin(ee,""),this._weekdaysParse[z]=new RegExp(ke.replace(".",""),"i")),q&&I==="dddd"&&this._fullWeekdaysParse[z].test(E))return z;if(q&&I==="ddd"&&this._shortWeekdaysParse[z].test(E))return z;if(q&&I==="dd"&&this._minWeekdaysParse[z].test(E))return z;if(!q&&this._weekdaysParse[z].test(E))return z}}function Ns(E){if(!this.isValid())return E!=null?this:NaN;var I=vc(this,"Day");return E!=null?(E=rm(E,this.localeData()),this.add(E-I,"d")):I}function wn(E){if(!this.isValid())return E!=null?this:NaN;var I=(this.day()+7-this.localeData()._week.dow)%7;return E==null?I:this.add(E-I,"d")}function Gu(E){if(!this.isValid())return E!=null?this:NaN;if(E!=null){var I=Ra(E,this.localeData());return this.day(this.day()%7?I:I-7)}else return this.day()||7}function Gh(E){return this._weekdaysParseExact?(n(this,"_weekdaysRegex")||ql.call(this),E?this._weekdaysStrictRegex:this._weekdaysRegex):(n(this,"_weekdaysRegex")||(this._weekdaysRegex=ea),this._weekdaysStrictRegex&&E?this._weekdaysStrictRegex:this._weekdaysRegex)}function Gs(E){return this._weekdaysParseExact?(n(this,"_weekdaysRegex")||ql.call(this),E?this._weekdaysShortStrictRegex:this._weekdaysShortRegex):(n(this,"_weekdaysShortRegex")||(this._weekdaysShortRegex=Np),this._weekdaysShortStrictRegex&&E?this._weekdaysShortStrictRegex:this._weekdaysShortRegex)}function jl(E){return this._weekdaysParseExact?(n(this,"_weekdaysRegex")||ql.call(this),E?this._weekdaysMinStrictRegex:this._weekdaysMinRegex):(n(this,"_weekdaysMinRegex")||(this._weekdaysMinRegex=La),this._weekdaysMinStrictRegex&&E?this._weekdaysMinStrictRegex:this._weekdaysMinRegex)}function ql(){function E(ia,eu){return eu.length-ia.length}var I=[],q=[],z=[],ee=[],ke,xt,fr,dn,fi;for(ke=0;ke<7;ke++)xt=P([2e3,1]).day(ke),fr=Di(this.weekdaysMin(xt,"")),dn=Di(this.weekdaysShort(xt,"")),fi=Di(this.weekdays(xt,"")),I.push(fr),q.push(dn),z.push(fi),ee.push(fr),ee.push(dn),ee.push(fi);I.sort(E),q.sort(E),z.sort(E),ee.sort(E),this._weekdaysRegex=new RegExp("^("+ee.join("|")+")","i"),this._weekdaysShortRegex=this._weekdaysRegex,this._weekdaysMinRegex=this._weekdaysRegex,this._weekdaysStrictRegex=new RegExp("^("+z.join("|")+")","i"),this._weekdaysShortStrictRegex=new RegExp("^("+q.join("|")+")","i"),this._weekdaysMinStrictRegex=new RegExp("^("+I.join("|")+")","i")}function Ma(){return this.hours()%12||12}function Rp(){return this.hours()||24}Ye("H",["HH",2],0,"hour"),Ye("h",["hh",2],0,Ma),Ye("k",["kk",2],0,Rp),Ye("hmm",0,0,function(){return""+Ma.apply(this)+Ee(this.minutes(),2)}),Ye("hmmss",0,0,function(){return""+Ma.apply(this)+Ee(this.minutes(),2)+Ee(this.seconds(),2)}),Ye("Hmm",0,0,function(){return""+this.hours()+Ee(this.minutes(),2)}),Ye("Hmmss",0,0,function(){return""+this.hours()+Ee(this.minutes(),2)+Ee(this.seconds(),2)});function Oo(E,I){Ye(E,0,0,function(){return this.localeData().meridiem(this.hours(),this.minutes(),I)})}Oo("a",!0),Oo("A",!1);function Fp(E,I){return I._meridiemParse}Mt("a",Fp),Mt("A",Fp),Mt("H",En,In),Mt("h",En,xr),Mt("k",En,xr),Mt("HH",En,Vr),Mt("hh",En,Vr),Mt("kk",En,Vr),Mt("hmm",$o),Mt("hmmss",Qo),Mt("Hmm",$o),Mt("Hmmss",Qo),On(["H","HH"],Cs),On(["k","kk"],function(E,I,q){var z=sn(E);I[Cs]=z===24?0:z}),On(["a","A"],function(E,I,q){q._isPm=q._locale.isPM(E),q._meridiem=E}),On(["h","hh"],function(E,I,q){I[Cs]=sn(E),g(q).bigHour=!0}),On("hmm",function(E,I,q){var z=E.length-2;I[Cs]=sn(E.substr(0,z)),I[Do]=sn(E.substr(z)),g(q).bigHour=!0}),On("hmmss",function(E,I,q){var z=E.length-4,ee=E.length-2;I[Cs]=sn(E.substr(0,z)),I[Do]=sn(E.substr(z,2)),I[lo]=sn(E.substr(ee)),g(q).bigHour=!0}),On("Hmm",function(E,I,q){var z=E.length-2;I[Cs]=sn(E.substr(0,z)),I[Do]=sn(E.substr(z))}),On("Hmmss",function(E,I,q){var z=E.length-4,ee=E.length-2;I[Cs]=sn(E.substr(0,z)),I[Do]=sn(E.substr(z,2)),I[lo]=sn(E.substr(ee))});function Kh(E){return(E+"").toLowerCase().charAt(0)==="p"}var Ga=/[ap]\.?m?\.?/i,va=tn("Hours",!0);function Lp(E,I,q){return E>11?q?"pm":"PM":q?"am":"AM"}var nl={calendar:ze,longDateFormat:Ut,invalidDate:ft,ordinal:C,dayOfMonthOrdinalParse:kt,relativeTime:Jr,months:ko,monthsShort:Na,week:Bl,weekdays:Wh,weekdaysMin:Op,weekdaysShort:zh,meridiemParse:Ga},bs={},ro={},Ku;function Ef(E,I){var q,z=Math.min(E.length,I.length);for(q=0;q<z;q+=1)if(E[q]!==I[q])return q;return z}function gu(E){return E&&E.toLowerCase().replace("_","-")}function il(E){for(var I=0,q,z,ee,ke;I<E.length;){for(ke=gu(E[I]).split("-"),q=ke.length,z=gu(E[I+1]),z=z?z.split("-"):null;q>0;){if(ee=Z(ke.slice(0,q).join("-")),ee)return ee;if(z&&z.length>=q&&Ef(ke,z)>=q-1)break;q--}I++}return Ku}function ue(E){return!!(E&&E.match("^[^/\\\\]*$"))}function Z(E){var I=null,q;if(bs[E]===void 0&&typeof _2<"u"&&_2&&_2.exports&&ue(E))try{I=Ku._abbr,q=require,q("./locale/"+E),ae(I)}catch{bs[E]=null}return bs[E]}function ae(E,I){var q;return E&&(f(I)?q=Xe(E):q=Me(E,I),q?Ku=q:typeof console<"u"&&console.warn&&console.warn("Locale "+E+" not found. Did you forget to load it?")),Ku._abbr}function Me(E,I){if(I!==null){var q,z=nl;if(I.abbr=E,bs[E]!=null)Ct("defineLocaleOverride","use moment.updateLocale(localeName, config) to change an existing locale. moment.defineLocale(localeName, config) should only be used for creating a new locale See http://momentjs.com/guides/#/warnings/define-locale/ for more info."),z=bs[E]._config;else if(I.parentLocale!=null)if(bs[I.parentLocale]!=null)z=bs[I.parentLocale]._config;else if(q=Z(I.parentLocale),q!=null)z=q._config;else return ro[I.parentLocale]||(ro[I.parentLocale]=[]),ro[I.parentLocale].push({name:E,config:I}),null;return bs[E]=new se(je(z,I)),ro[E]&&ro[E].forEach(function(ee){Me(ee.name,ee.config)}),ae(E),bs[E]}else return delete bs[E],null}function it(E,I){if(I!=null){var q,z,ee=nl;bs[E]!=null&&bs[E].parentLocale!=null?bs[E].set(je(bs[E]._config,I)):(z=Z(E),z!=null&&(ee=z._config),I=je(ee,I),z==null&&(I.abbr=E),q=new se(I),q.parentLocale=bs[E],bs[E]=q),ae(E)}else bs[E]!=null&&(bs[E].parentLocale!=null?(bs[E]=bs[E].parentLocale,E===ae()&&ae(E)):bs[E]!=null&&delete bs[E]);return bs[E]}function Xe(E){var I;if(E&&E._locale&&E._locale._abbr&&(E=E._locale._abbr),!E)return Ku;if(!s(E)){if(I=Z(E),I)return I;E=[E]}return il(E)}function gt(){return De(bs)}function St(E){var I,q=E._a;return q&&g(E).overflow===-2&&(I=q[Ao]<0||q[Ao]>11?Ao:q[co]<1||q[co]>zs(q[ur],q[Ao])?co:q[Cs]<0||q[Cs]>24||q[Cs]===24&&(q[Do]!==0||q[lo]!==0||q[js]!==0)?Cs:q[Do]<0||q[Do]>59?Do:q[lo]<0||q[lo]>59?lo:q[js]<0||q[js]>999?js:-1,g(E)._overflowDayOfYear&&(I<ur||I>co)&&(I=co),g(E)._overflowWeeks&&I===-1&&(I=Zc),g(E)._overflowWeekday&&I===-1&&(I=fu),g(E).overflow=I),E}var Vt=/^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,_r=/^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d|))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,An=/Z|[+-]\d\d(?::?\d\d)?/,ti=[["YYYYYY-MM-DD",/[+-]\d{6}-\d\d-\d\d/],["YYYY-MM-DD",/\d{4}-\d\d-\d\d/],["GGGG-[W]WW-E",/\d{4}-W\d\d-\d/],["GGGG-[W]WW",/\d{4}-W\d\d/,!1],["YYYY-DDD",/\d{4}-\d{3}/],["YYYY-MM",/\d{4}-\d\d/,!1],["YYYYYYMMDD",/[+-]\d{10}/],["YYYYMMDD",/\d{8}/],["GGGG[W]WWE",/\d{4}W\d{3}/],["GGGG[W]WW",/\d{4}W\d{2}/,!1],["YYYYDDD",/\d{7}/],["YYYYMM",/\d{6}/,!1],["YYYY",/\d{4}/,!1]],Nn=[["HH:mm:ss.SSSS",/\d\d:\d\d:\d\d\.\d+/],["HH:mm:ss,SSSS",/\d\d:\d\d:\d\d,\d+/],["HH:mm:ss",/\d\d:\d\d:\d\d/],["HH:mm",/\d\d:\d\d/],["HHmmss.SSSS",/\d\d\d\d\d\d\.\d+/],["HHmmss,SSSS",/\d\d\d\d\d\d,\d+/],["HHmmss",/\d\d\d\d\d\d/],["HHmm",/\d\d\d\d/],["HH",/\d\d/]],Ba=/^\/?Date\((-?\d+)/i,Ul=/^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|([+-]\d{4}))$/,xa={UT:0,GMT:0,EDT:-4*60,EST:-5*60,CDT:-5*60,CST:-6*60,MDT:-6*60,MST:-7*60,PDT:-7*60,PST:-8*60};function No(E){var I,q,z=E._i,ee=Vt.exec(z)||_r.exec(z),ke,xt,fr,dn,fi=ti.length,ia=Nn.length;if(ee){for(g(E).iso=!0,I=0,q=fi;I<q;I++)if(ti[I][1].exec(ee[1])){xt=ti[I][0],ke=ti[I][2]!==!1;break}if(xt==null){E._isValid=!1;return}if(ee[3]){for(I=0,q=ia;I<q;I++)if(Nn[I][1].exec(ee[3])){fr=(ee[2]||" ")+Nn[I][0];break}if(fr==null){E._isValid=!1;return}}if(!ke&&fr!=null){E._isValid=!1;return}if(ee[4])if(An.exec(ee[4]))dn="Z";else{E._isValid=!1;return}E._f=xt+(fr||"")+(dn||""),Ho(E)}else E._isValid=!1}function ui(E,I,q,z,ee,ke){var xt=[on(E),Na.indexOf(I),parseInt(q,10),parseInt(z,10),parseInt(ee,10)];return ke&&xt.push(parseInt(ke,10)),xt}function on(E){var I=parseInt(E,10);return I<=49?2e3+I:I<=999?1900+I:I}function Nr(E){return E.replace(/\([^()]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").replace(/^\s\s*/,"").replace(/\s\s*$/,"")}function rn(E,I,q){if(E){var z=zh.indexOf(E),ee=new Date(I[0],I[1],I[2]).getDay();if(z!==ee)return g(q).weekdayMismatch=!0,q._isValid=!1,!1}return!0}function ri(E,I,q){if(E)return xa[E];if(I)return 0;var z=parseInt(q,10),ee=z%100,ke=(z-ee)/100;return ke*60+ee}function Ii(E){var I=Ul.exec(Nr(E._i)),q;if(I){if(q=ui(I[4],I[3],I[2],I[5],I[6],I[7]),!rn(I[1],q,E))return;E._a=q,E._tzm=ri(I[8],I[9],I[10]),E._d=Sf.apply(null,E._a),E._d.setUTCMinutes(E._d.getUTCMinutes()-E._tzm),g(E).rfc2822=!0}else E._isValid=!1}function Ks(E){var I=Ba.exec(E._i);if(I!==null){E._d=new Date(+I[1]);return}if(No(E),E._isValid===!1)delete E._isValid;else return;if(Ii(E),E._isValid===!1)delete E._isValid;else return;E._strict?E._isValid=!1:t.createFromInputFallback(E)}t.createFromInputFallback=Ve("value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are discouraged. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.",function(E){E._d=new Date(E._i+(E._useUTC?" UTC":""))});function _o(E,I,q){return E!=null?E:I!=null?I:q}function bc(E){var I=new Date(t.now());return E._useUTC?[I.getUTCFullYear(),I.getUTCMonth(),I.getUTCDate()]:[I.getFullYear(),I.getMonth(),I.getDate()]}function no(E){var I,q,z=[],ee,ke,xt;if(!E._d){for(ee=bc(E),E._w&&E._a[co]==null&&E._a[Ao]==null&&ja(E),E._dayOfYear!=null&&(xt=_o(E._a[ur],ee[ur]),(E._dayOfYear>Oa(xt)||E._dayOfYear===0)&&(g(E)._overflowDayOfYear=!0),q=Sf(xt,0,E._dayOfYear),E._a[Ao]=q.getUTCMonth(),E._a[co]=q.getUTCDate()),I=0;I<3&&E._a[I]==null;++I)E._a[I]=z[I]=ee[I];for(;I<7;I++)E._a[I]=z[I]=E._a[I]==null?I===2?1:0:E._a[I];E._a[Cs]===24&&E._a[Do]===0&&E._a[lo]===0&&E._a[js]===0&&(E._nextDay=!0,E._a[Cs]=0),E._d=(E._useUTC?Sf:Vh).apply(null,z),ke=E._useUTC?E._d.getUTCDay():E._d.getDay(),E._tzm!=null&&E._d.setUTCMinutes(E._d.getUTCMinutes()-E._tzm),E._nextDay&&(E._a[Cs]=24),E._w&&typeof E._w.d<"u"&&E._w.d!==ke&&(g(E).weekdayMismatch=!0)}}function ja(E){var I,q,z,ee,ke,xt,fr,dn,fi;I=E._w,I.GG!=null||I.W!=null||I.E!=null?(ke=1,xt=4,q=_o(I.GG,E._a[ur],or(Tn(),1,4).year),z=_o(I.W,1),ee=_o(I.E,1),(ee<1||ee>7)&&(dn=!0)):(ke=E._locale._week.dow,xt=E._locale._week.doy,fi=or(Tn(),ke,xt),q=_o(I.gg,E._a[ur],fi.year),z=_o(I.w,fi.week),I.d!=null?(ee=I.d,(ee<0||ee>6)&&(dn=!0)):I.e!=null?(ee=I.e+ke,(I.e<0||I.e>6)&&(dn=!0)):ee=ke),z<1||z>ji(q,ke,xt)?g(E)._overflowWeeks=!0:dn!=null?g(E)._overflowWeekday=!0:(fr=Od(q,z,ee,ke,xt),E._a[ur]=fr.year,E._dayOfYear=fr.dayOfYear)}t.ISO_8601=function(){},t.RFC_2822=function(){};function Ho(E){if(E._f===t.ISO_8601){No(E);return}if(E._f===t.RFC_2822){Ii(E);return}E._a=[],g(E).empty=!0;var I=""+E._i,q,z,ee,ke,xt,fr=I.length,dn=0,fi,ia;for(ee=lt(E._f,E._locale).match(Fe)||[],ia=ee.length,q=0;q<ia;q++)ke=ee[q],z=(I.match(Ai(ke,E))||[])[0],z&&(xt=I.substr(0,I.indexOf(z)),xt.length>0&&g(E).unusedInput.push(xt),I=I.slice(I.indexOf(z)+z.length),dn+=z.length),jt[ke]?(z?g(E).empty=!1:g(E).unusedTokens.push(ke),Hu(ke,z,E)):E._strict&&!z&&g(E).unusedTokens.push(ke);g(E).charsLeftOver=fr-dn,I.length>0&&g(E).unusedInput.push(I),E._a[Cs]<=12&&g(E).bigHour===!0&&E._a[Cs]>0&&(g(E).bigHour=void 0),g(E).parsedDateParts=E._a.slice(0),g(E).meridiem=E._meridiem,E._a[Cs]=$l(E._locale,E._a[Cs],E._meridiem),fi=g(E).era,fi!==null&&(E._a[ur]=E._locale.erasConvertYear(fi,E._a[ur])),no(E),St(E)}function $l(E,I,q){var z;return q==null?I:E.meridiemHour!=null?E.meridiemHour(I,q):(E.isPM!=null&&(z=E.isPM(q),z&&I<12&&(I+=12),!z&&I===12&&(I=0)),I)}function Mp(E){var I,q,z,ee,ke,xt,fr=!1,dn=E._f.length;if(dn===0){g(E).invalidFormat=!0,E._d=new Date(NaN);return}for(ee=0;ee<dn;ee++)ke=0,xt=!1,I=te({},E),E._useUTC!=null&&(I._useUTC=E._useUTC),I._f=E._f[ee],Ho(I),F(I)&&(xt=!0),ke+=g(I).charsLeftOver,ke+=g(I).unusedTokens.length*10,g(I).score=ke,fr?ke<z&&(z=ke,q=I):(z==null||ke<z||xt)&&(z=ke,q=I,xt&&(fr=!0));b(E,q||I)}function Yu(E){if(!E._d){var I=Je(E._i),q=I.day===void 0?I.date:I.day;E._a=v([I.year,I.month,q,I.hour,I.minute,I.second,I.millisecond],function(z){return z&&parseInt(z,10)}),no(E)}}function Bp(E){var I=new me(St(Wo(E)));return I._nextDay&&(I.add(1,"d"),I._nextDay=void 0),I}function Wo(E){var I=E._i,q=E._f;return E._locale=E._locale||Xe(E._l),I===null||q===void 0&&I===""?M({nullInput:!0}):(typeof I=="string"&&(E._i=I=E._locale.preparse(I)),Ce(I)?new me(St(I)):(y(I)?E._d=I:s(q)?Mp(E):q?Ho(E):qi(E),F(E)||(E._d=null),E))}function qi(E){var I=E._i;f(I)?E._d=new Date(t.now()):y(I)?E._d=new Date(I.valueOf()):typeof I=="string"?Ks(E):s(I)?(E._a=v(I.slice(0),function(q){return parseInt(q,10)}),no(E)):a(I)?Yu(E):m(I)?E._d=new Date(I):t.createFromInputFallback(E)}function Yh(E,I,q,z,ee){var ke={};return(I===!0||I===!1)&&(z=I,I=void 0),(q===!0||q===!1)&&(z=q,q=void 0),(a(E)&&l(E)||s(E)&&E.length===0)&&(E=void 0),ke._isAMomentObject=!0,ke._useUTC=ke._isUTC=ee,ke._l=q,ke._i=E,ke._f=I,ke._strict=z,Bp(ke)}function Tn(E,I,q,z){return Yh(E,I,q,z,!1)}var Jh=Ve("moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/",function(){var E=Tn.apply(null,arguments);return this.isValid()&&E.isValid()?E<this?this:E:M()}),zo=Ve("moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/",function(){var E=Tn.apply(null,arguments);return this.isValid()&&E.isValid()?E>this?this:E:M()});function oi(E,I){var q,z;if(I.length===1&&s(I[0])&&(I=I[0]),!I.length)return Tn();for(q=I[0],z=1;z<I.length;++z)(!I[z].isValid()||I[z][E](q))&&(q=I[z]);return q}function Ka(){var E=[].slice.call(arguments,0);return oi("isBefore",E)}function Rd(){var E=[].slice.call(arguments,0);return oi("isAfter",E)}var wf=function(){return Date.now?Date.now():+new Date},Tf=["year","quarter","month","week","day","hour","minute","second","millisecond"];function gv(E){var I,q=!1,z,ee=Tf.length;for(I in E)if(n(E,I)&&!(Bi.call(Tf,I)!==-1&&(E[I]==null||!isNaN(E[I]))))return!1;for(z=0;z<ee;++z)if(E[Tf[z]]){if(q)return!1;parseFloat(E[Tf[z]])!==sn(E[Tf[z]])&&(q=!0)}return!0}function Fd(){return this._isValid}function nm(){return So(NaN)}function Ec(E){var I=Je(E),q=I.year||0,z=I.quarter||0,ee=I.month||0,ke=I.week||I.isoWeek||0,xt=I.day||0,fr=I.hour||0,dn=I.minute||0,fi=I.second||0,ia=I.millisecond||0;this._isValid=gv(I),this._milliseconds=+ia+fi*1e3+dn*6e4+fr*1e3*60*60,this._days=+xt+ke*7,this._months=+ee+z*3+q*12,this._data={},this._locale=Xe(),this._bubble()}function qa(E){return E instanceof Ec}function sl(E){return E<0?Math.round(-1*E)*-1:Math.round(E)}function Ya(E,I,q){var z=Math.min(E.length,I.length),ee=Math.abs(E.length-I.length),ke=0,xt;for(xt=0;xt<z;xt++)(q&&E[xt]!==I[xt]||!q&&sn(E[xt])!==sn(I[xt]))&&ke++;return ke+ee}function jp(E,I){Ye(E,0,0,function(){var q=this.utcOffset(),z="+";return q<0&&(q=-q,z="-"),z+Ee(~~(q/60),2)+I+Ee(~~q%60,2)})}jp("Z",":"),jp("ZZ",""),Mt("Z",It),Mt("ZZ",It),On(["Z","ZZ"],function(E,I,q){q._useUTC=!0,q._tzm=Ro(It,E)});var Ys=/([\+\-]|\d\d)/gi;function Ro(E,I){var q=(I||"").match(E),z,ee,ke;return q===null?null:(z=q[q.length-1]||[],ee=(z+"").match(Ys)||["-",0,0],ke=+(ee[1]*60)+sn(ee[2]),ke===0?0:ee[0]==="+"?ke:-ke)}function io(E,I){var q,z;return I._isUTC?(q=I.clone(),z=(Ce(E)||y(E)?E.valueOf():Tn(E).valueOf())-q.valueOf(),q._d.setTime(q._d.valueOf()+z),t.updateOffset(q,!1),q):Tn(E).local()}function wc(E){return-Math.round(E._d.getTimezoneOffset())}t.updateOffset=function(){};function Pf(E,I,q){var z=this._offset||0,ee;if(!this.isValid())return E!=null?this:NaN;if(E!=null){if(typeof E=="string"){if(E=Ro(It,E),E===null)return this}else Math.abs(E)<16&&!q&&(E=E*60);return!this._isUTC&&I&&(ee=wc(this)),this._offset=E,this._isUTC=!0,ee!=null&&this.add(ee,"m"),z!==E&&(!I||this._changeInProgress?ba(this,So(E-z,"m"),1,!1):this._changeInProgress||(this._changeInProgress=!0,t.updateOffset(this,!0),this._changeInProgress=null)),this}else return this._isUTC?z:wc(this)}function bi(E,I){return E!=null?(typeof E!="string"&&(E=-E),this.utcOffset(E,I),this):-this.utcOffset()}function im(E){return this.utcOffset(0,E)}function sm(E){return this._isUTC&&(this.utcOffset(0,E),this._isUTC=!1,E&&this.subtract(wc(this),"m")),this}function ta(){if(this._tzm!=null)this.utcOffset(this._tzm,!1,!0);else if(typeof this._i=="string"){var E=Ro(Ft,this._i);E!=null?this.utcOffset(E):this.utcOffset(0,!0)}return this}function Sa(E){return this.isValid()?(E=E?Tn(E).utcOffset():0,(this.utcOffset()-E)%60===0):!1}function Ja(){return this.utcOffset()>this.clone().month(0).utcOffset()||this.utcOffset()>this.clone().month(5).utcOffset()}function Vl(){if(!f(this._isDSTShifted))return this._isDSTShifted;var E={},I;return te(E,this),E=Wo(E),E._a?(I=E._isUTC?P(E._a):Tn(E._a),this._isDSTShifted=this.isValid()&&Ya(E._a,I.toArray())>0):this._isDSTShifted=!1,this._isDSTShifted}function Hl(){return this.isValid()?!this._isUTC:!1}function Wl(){return this.isValid()?this._isUTC:!1}function Ei(){return this.isValid()?this._isUTC&&this._offset===0:!1}var Ju=/^(-|\+)?(?:(\d*)[. ])?(\d+):(\d+)(?::(\d+)(\.\d*)?)?$/,zl=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/;function So(E,I){var q=E,z=null,ee,ke,xt;return qa(E)?q={ms:E._milliseconds,d:E._days,M:E._months}:m(E)||!isNaN(+E)?(q={},I?q[I]=+E:q.milliseconds=+E):(z=Ju.exec(E))?(ee=z[1]==="-"?-1:1,q={y:0,d:sn(z[co])*ee,h:sn(z[Cs])*ee,m:sn(z[Do])*ee,s:sn(z[lo])*ee,ms:sn(sl(z[js]*1e3))*ee}):(z=zl.exec(E))?(ee=z[1]==="-"?-1:1,q={y:ol(z[2],ee),M:ol(z[3],ee),w:ol(z[4],ee),d:ol(z[5],ee),h:ol(z[6],ee),m:ol(z[7],ee),s:ol(z[8],ee)}):q==null?q={}:typeof q=="object"&&("from"in q||"to"in q)&&(xt=om(Tn(q.from),Tn(q.to)),q={},q.ms=xt.milliseconds,q.M=xt.months),ke=new Ec(q),qa(E)&&n(E,"_locale")&&(ke._locale=E._locale),qa(E)&&n(E,"_isValid")&&(ke._isValid=E._isValid),ke}So.fn=Ec.prototype,So.invalid=nm;function ol(E,I){var q=E&&parseFloat(E.replace(",","."));return(isNaN(q)?0:q)*I}function Xu(E,I){var q={};return q.months=I.month()-E.month()+(I.year()-E.year())*12,E.clone().add(q.months,"M").isAfter(I)&&--q.months,q.milliseconds=+I-+E.clone().add(q.months,"M"),q}function om(E,I){var q;return E.isValid()&&I.isValid()?(I=io(I,E),E.isBefore(I)?q=Xu(E,I):(q=Xu(I,E),q.milliseconds=-q.milliseconds,q.months=-q.months),q):{milliseconds:0,months:0}}function qp(E,I){return function(q,z){var ee,ke;return z!==null&&!isNaN(+z)&&(Ct(I,"moment()."+I+"(period, number) is deprecated. Please use moment()."+I+"(number, period). See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info."),ke=q,q=z,z=ke),ee=So(q,z),ba(this,ee,E),this}}function ba(E,I,q,z){var ee=I._milliseconds,ke=sl(I._days),xt=sl(I._months);E.isValid()&&(z=z==null?!0:z,xt&&qt(E,vc(E,"Month")+xt*q),ke&&el(E,"Date",vc(E,"Date")+ke*q),ee&&E._d.setTime(E._d.valueOf()+ee*q),z&&t.updateOffset(E,ke||xt))}var ni=qp(1,"add"),Ld=qp(-1,"subtract");function Xh(E){return typeof E=="string"||E instanceof String}function Qh(E){return Ce(E)||y(E)||Xh(E)||m(E)||Wy(E)||Hy(E)||E===null||E===void 0}function Hy(E){var I=a(E)&&!l(E),q=!1,z=["years","year","y","months","month","M","days","day","d","dates","date","D","hours","hour","h","minutes","minute","m","seconds","second","s","milliseconds","millisecond","ms"],ee,ke,xt=z.length;for(ee=0;ee<xt;ee+=1)ke=z[ee],q=q||n(E,ke);return I&&q}function Wy(E){var I=s(E),q=!1;return I&&(q=E.filter(function(z){return!m(z)&&Xh(E)}).length===0),I&&q}function vv(E){var I=a(E)&&!l(E),q=!1,z=["sameDay","nextDay","lastDay","nextWeek","lastWeek","sameElse"],ee,ke;for(ee=0;ee<z.length;ee+=1)ke=z[ee],q=q||n(E,ke);return I&&q}function xx(E,I){var q=E.diff(I,"days",!0);return q<-6?"sameElse":q<-1?"lastWeek":q<0?"lastDay":q<1?"sameDay":q<2?"nextDay":q<7?"nextWeek":"sameElse"}function am(E,I){arguments.length===1&&(arguments[0]?Qh(arguments[0])?(E=arguments[0],I=void 0):vv(arguments[0])&&(I=arguments[0],E=void 0):(E=void 0,I=void 0));var q=E||Tn(),z=io(q,this).startOf("day"),ee=t.calendarFormat(this,z)||"sameElse",ke=I&&(ct(I[ee])?I[ee].call(this,q):I[ee]);return this.format(ke||this.localeData().calendar(ee,this,Tn(q)))}function Zh(){return new me(this)}function xv(E,I){var q=Ce(E)?E:Tn(E);return this.isValid()&&q.isValid()?(I=ge(I)||"millisecond",I==="millisecond"?this.valueOf()>q.valueOf():q.valueOf()<this.clone().startOf(I).valueOf()):!1}function Qu(E,I){var q=Ce(E)?E:Tn(E);return this.isValid()&&q.isValid()?(I=ge(I)||"millisecond",I==="millisecond"?this.valueOf()<q.valueOf():this.clone().endOf(I).valueOf()<q.valueOf()):!1}function Gl(E,I,q,z){var ee=Ce(E)?E:Tn(E),ke=Ce(I)?I:Tn(I);return this.isValid()&&ee.isValid()&&ke.isValid()?(z=z||"()",(z[0]==="("?this.isAfter(ee,q):!this.isBefore(ee,q))&&(z[1]===")"?this.isBefore(ke,q):!this.isAfter(ke,q))):!1}function Ea(E,I){var q=Ce(E)?E:Tn(E),z;return this.isValid()&&q.isValid()?(I=ge(I)||"millisecond",I==="millisecond"?this.valueOf()===q.valueOf():(z=q.valueOf(),this.clone().startOf(I).valueOf()<=z&&z<=this.clone().endOf(I).valueOf())):!1}function vu(E,I){return this.isSame(E,I)||this.isAfter(E,I)}function wa(E,I){return this.isSame(E,I)||this.isBefore(E,I)}function Up(E,I,q){var z,ee,ke;if(!this.isValid())return NaN;if(z=io(E,this),!z.isValid())return NaN;switch(ee=(z.utcOffset()-this.utcOffset())*6e4,I=ge(I),I){case"year":ke=xu(this,z)/12;break;case"month":ke=xu(this,z);break;case"quarter":ke=xu(this,z)/3;break;case"second":ke=(this-z)/1e3;break;case"minute":ke=(this-z)/6e4;break;case"hour":ke=(this-z)/36e5;break;case"day":ke=(this-z-ee)/864e5;break;case"week":ke=(this-z-ee)/6048e5;break;default:ke=this-z}return q?ke:Si(ke)}function xu(E,I){if(E.date()<I.date())return-xu(I,E);var q=(I.year()-E.year())*12+(I.month()-E.month()),z=E.clone().add(q,"months"),ee,ke;return I-z<0?(ee=E.clone().add(q-1,"months"),ke=(I-z)/(z-ee)):(ee=E.clone().add(q+1,"months"),ke=(I-z)/(ee-z)),-(q+ke)||0}t.defaultFormat="YYYY-MM-DDTHH:mm:ssZ",t.defaultFormatUtc="YYYY-MM-DDTHH:mm:ss[Z]";function al(){return this.clone().locale("en").format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ")}function Cf(E){if(!this.isValid())return null;var I=E!==!0,q=I?this.clone().utc():this;return q.year()<0||q.year()>9999?Ze(q,I?"YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]":"YYYYYY-MM-DD[T]HH:mm:ss.SSSZ"):ct(Date.prototype.toISOString)?I?this.toDate().toISOString():new Date(this.valueOf()+this.utcOffset()*60*1e3).toISOString().replace("Z",Ze(q,"Z")):Ze(q,I?"YYYY-MM-DD[T]HH:mm:ss.SSS[Z]":"YYYY-MM-DD[T]HH:mm:ss.SSSZ")}function Af(){if(!this.isValid())return"moment.invalid(/* "+this._i+" */)";var E="moment",I="",q,z,ee,ke;return this.isLocal()||(E=this.utcOffset()===0?"moment.utc":"moment.parseZone",I="Z"),q="["+E+'("]',z=0<=this.year()&&this.year()<=9999?"YYYY":"YYYYYY",ee="-MM-DD[T]HH:mm:ss.SSS",ke=I+'[")]',this.format(q+z+ee+ke)}function Md(E){E||(E=this.isUtc()?t.defaultFormatUtc:t.defaultFormat);var I=Ze(this,E);return this.localeData().postformat(I)}function zy(E,I){return this.isValid()&&(Ce(E)&&E.isValid()||Tn(E).isValid())?So({to:this,from:E}).locale(this.locale()).humanize(!I):this.localeData().invalidDate()}function um(E){return this.from(Tn(),E)}function Df(E,I){return this.isValid()&&(Ce(E)&&E.isValid()||Tn(E).isValid())?So({from:this,to:E}).locale(this.locale()).humanize(!I):this.localeData().invalidDate()}function Kl(E){return this.to(Tn(),E)}function cm(E){var I;return E===void 0?this._locale._abbr:(I=Xe(E),I!=null&&(this._locale=I),this)}var _u=Ve("moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.",function(E){return E===void 0?this.localeData():this.locale(E)});function lm(){return this._locale}var ul=1e3,Tc=60*ul,Yl=60*Tc,Gy=(365*400+97)*24*Yl;function wi(E,I){return(E%I+I)%I}function Fo(E,I,q){return E<100&&E>=0?new Date(E+400,I,q)-Gy:new Date(E,I,q).valueOf()}function Su(E,I,q){return E<100&&E>=0?Date.UTC(E+400,I,q)-Gy:Date.UTC(E,I,q)}function Zu(E){var I,q;if(E=ge(E),E===void 0||E==="millisecond"||!this.isValid())return this;switch(q=this._isUTC?Su:Fo,E){case"year":I=q(this.year(),0,1);break;case"quarter":I=q(this.year(),this.month()-this.month()%3,1);break;case"month":I=q(this.year(),this.month(),1);break;case"week":I=q(this.year(),this.month(),this.date()-this.weekday());break;case"isoWeek":I=q(this.year(),this.month(),this.date()-(this.isoWeekday()-1));break;case"day":case"date":I=q(this.year(),this.month(),this.date());break;case"hour":I=this._d.valueOf(),I-=wi(I+(this._isUTC?0:this.utcOffset()*Tc),Yl);break;case"minute":I=this._d.valueOf(),I-=wi(I,Tc);break;case"second":I=this._d.valueOf(),I-=wi(I,ul);break}return this._d.setTime(I),t.updateOffset(this,!0),this}function cl(E){var I,q;if(E=ge(E),E===void 0||E==="millisecond"||!this.isValid())return this;switch(q=this._isUTC?Su:Fo,E){case"year":I=q(this.year()+1,0,1)-1;break;case"quarter":I=q(this.year(),this.month()-this.month()%3+3,1)-1;break;case"month":I=q(this.year(),this.month()+1,1)-1;break;case"week":I=q(this.year(),this.month(),this.date()-this.weekday()+7)-1;break;case"isoWeek":I=q(this.year(),this.month(),this.date()-(this.isoWeekday()-1)+7)-1;break;case"day":case"date":I=q(this.year(),this.month(),this.date()+1)-1;break;case"hour":I=this._d.valueOf(),I+=Yl-wi(I+(this._isUTC?0:this.utcOffset()*Tc),Yl)-1;break;case"minute":I=this._d.valueOf(),I+=Tc-wi(I,Tc)-1;break;case"second":I=this._d.valueOf(),I+=ul-wi(I,ul)-1;break}return this._d.setTime(I),t.updateOffset(this,!0),this}function Xa(){return this._d.valueOf()-(this._offset||0)*6e4}function $p(){return Math.floor(this.valueOf()/1e3)}function ll(){return new Date(this.valueOf())}function _v(){var E=this;return[E.year(),E.month(),E.date(),E.hour(),E.minute(),E.second(),E.millisecond()]}function pm(){var E=this;return{years:E.year(),months:E.month(),date:E.date(),hours:E.hours(),minutes:E.minutes(),seconds:E.seconds(),milliseconds:E.milliseconds()}}function kf(){return this.isValid()?this.toISOString():null}function Bd(){return F(this)}function _x(){return b({},g(this))}function Ky(){return g(this).overflow}function e0(){return{input:this._i,format:this._f,locale:this._locale,isUTC:this._isUTC,strict:this._strict}}Ye("N",0,0,"eraAbbr"),Ye("NN",0,0,"eraAbbr"),Ye("NNN",0,0,"eraAbbr"),Ye("NNNN",0,0,"eraName"),Ye("NNNNN",0,0,"eraNarrow"),Ye("y",["y",1],"yo","eraYear"),Ye("y",["yy",2],0,"eraYear"),Ye("y",["yyy",3],0,"eraYear"),Ye("y",["yyyy",4],0,"eraYear"),Mt("N",qd),Mt("NN",qd),Mt("NNN",qd),Mt("NNNN",r0),Mt("NNNNN",n0),On(["N","NN","NNN","NNNN","NNNNN"],function(E,I,q,z){var ee=q._locale.erasParse(E,z,q._strict);ee?g(q).era=ee:g(q).invalidEra=E}),Mt("y",za),Mt("yy",za),Mt("yyy",za),Mt("yyyy",za),Mt("yo",dm),On(["y","yy","yyy","yyyy"],ur),On(["yo"],function(E,I,q,z){var ee;q._locale._eraYearOrdinalRegex&&(ee=E.match(q._locale._eraYearOrdinalRegex)),q._locale.eraYearOrdinalParse?I[ur]=q._locale.eraYearOrdinalParse(E,ee):I[ur]=parseInt(E,10)});function Yy(E,I){var q,z,ee,ke=this._eras||Xe("en")._eras;for(q=0,z=ke.length;q<z;++q){switch(typeof ke[q].since){case"string":ee=t(ke[q].since).startOf("day"),ke[q].since=ee.valueOf();break}switch(typeof ke[q].until){case"undefined":ke[q].until=1/0;break;case"string":ee=t(ke[q].until).startOf("day").valueOf(),ke[q].until=ee.valueOf();break}}return ke}function Jy(E,I,q){var z,ee,ke=this.eras(),xt,fr,dn;for(E=E.toUpperCase(),z=0,ee=ke.length;z<ee;++z)if(xt=ke[z].name.toUpperCase(),fr=ke[z].abbr.toUpperCase(),dn=ke[z].narrow.toUpperCase(),q)switch(I){case"N":case"NN":case"NNN":if(fr===E)return ke[z];break;case"NNNN":if(xt===E)return ke[z];break;case"NNNNN":if(dn===E)return ke[z];break}else if([xt,fr,dn].indexOf(E)>=0)return ke[z]}function fm(E,I){var q=E.since<=E.until?1:-1;return I===void 0?t(E.since).year():t(E.since).year()+(I-E.offset)*q}function Vp(){var E,I,q,z=this.localeData().eras();for(E=0,I=z.length;E<I;++E)if(q=this.clone().startOf("day").valueOf(),z[E].since<=q&&q<=z[E].until||z[E].until<=q&&q<=z[E].since)return z[E].name;return""}function Xy(){var E,I,q,z=this.localeData().eras();for(E=0,I=z.length;E<I;++E)if(q=this.clone().startOf("day").valueOf(),z[E].since<=q&&q<=z[E].until||z[E].until<=q&&q<=z[E].since)return z[E].narrow;return""}function Sv(){var E,I,q,z=this.localeData().eras();for(E=0,I=z.length;E<I;++E)if(q=this.clone().startOf("day").valueOf(),z[E].since<=q&&q<=z[E].until||z[E].until<=q&&q<=z[E].since)return z[E].abbr;return""}function jd(){var E,I,q,z,ee=this.localeData().eras();for(E=0,I=ee.length;E<I;++E)if(q=ee[E].since<=ee[E].until?1:-1,z=this.clone().startOf("day").valueOf(),ee[E].since<=z&&z<=ee[E].until||ee[E].until<=z&&z<=ee[E].since)return(this.year()-t(ee[E].since).year())*q+ee[E].offset;return this.year()}function Ta(E){return n(this,"_erasNameRegex")||Of.call(this),E?this._erasNameRegex:this._erasRegex}function t0(E){return n(this,"_erasAbbrRegex")||Of.call(this),E?this._erasAbbrRegex:this._erasRegex}function If(E){return n(this,"_erasNarrowRegex")||Of.call(this),E?this._erasNarrowRegex:this._erasRegex}function qd(E,I){return I.erasAbbrRegex(E)}function r0(E,I){return I.erasNameRegex(E)}function n0(E,I){return I.erasNarrowRegex(E)}function dm(E,I){return I._eraYearOrdinalRegex||za}function Of(){var E=[],I=[],q=[],z=[],ee,ke,xt,fr,dn,fi=this.eras();for(ee=0,ke=fi.length;ee<ke;++ee)xt=Di(fi[ee].name),fr=Di(fi[ee].abbr),dn=Di(fi[ee].narrow),I.push(xt),E.push(fr),q.push(dn),z.push(xt),z.push(fr),z.push(dn);this._erasRegex=new RegExp("^("+z.join("|")+")","i"),this._erasNameRegex=new RegExp("^("+I.join("|")+")","i"),this._erasAbbrRegex=new RegExp("^("+E.join("|")+")","i"),this._erasNarrowRegex=new RegExp("^("+q.join("|")+")","i")}Ye(0,["gg",2],0,function(){return this.weekYear()%100}),Ye(0,["GG",2],0,function(){return this.isoWeekYear()%100});function Nf(E,I){Ye(0,[E,E.length],0,I)}Nf("gggg","weekYear"),Nf("ggggg","weekYear"),Nf("GGGG","isoWeekYear"),Nf("GGGGG","isoWeekYear"),Mt("G",rt),Mt("g",rt),Mt("GG",En,Vr),Mt("gg",En,Vr),Mt("GGGG",Vo,jn),Mt("gggg",Vo,jn),Mt("GGGGG",Vu,ei),Mt("ggggg",Vu,ei),Ss(["gggg","ggggg","GGGG","GGGGG"],function(E,I,q,z){I[z.substr(0,2)]=sn(E)}),Ss(["gg","GG"],function(E,I,q,z){I[z]=t.parseTwoDigitYear(E)});function Rf(E){return bu.call(this,E,this.week(),this.weekday()+this.localeData()._week.dow,this.localeData()._week.dow,this.localeData()._week.doy)}function Qy(E){return bu.call(this,E,this.isoWeek(),this.isoWeekday(),1,4)}function i0(){return ji(this.year(),1,4)}function s0(){return ji(this.isoWeekYear(),1,4)}function Jl(){var E=this.localeData()._week;return ji(this.year(),E.dow,E.doy)}function Hp(){var E=this.localeData()._week;return ji(this.weekYear(),E.dow,E.doy)}function bu(E,I,q,z,ee){var ke;return E==null?or(this,z,ee).year:(ke=ji(E,z,ee),I>ke&&(I=ke),Wp.call(this,E,I,q,z,ee))}function Wp(E,I,q,z,ee){var ke=Od(E,I,q,z,ee),xt=Sf(ke.year,0,ke.dayOfYear);return this.year(xt.getUTCFullYear()),this.month(xt.getUTCMonth()),this.date(xt.getUTCDate()),this}Ye("Q",0,"Qo","quarter"),Mt("Q",$r),On("Q",function(E,I){I[Ao]=(sn(E)-1)*3});function hm(E){return E==null?Math.ceil((this.month()+1)/3):this.month((E-1)*3+this.month()%3)}Ye("D",["DD",2],"Do","date"),Mt("D",En,xr),Mt("DD",En,Vr),Mt("Do",function(E,I){return E?I._dayOfMonthOrdinalParse||I._ordinalParse:I._dayOfMonthOrdinalParseLenient}),On(["D","DD"],co),On("Do",function(E,I){I[co]=sn(E.match(En)[0])});var Xl=tn("Date",!0);Ye("DDD",["DDDD",3],"DDDo","dayOfYear"),Mt("DDD",ps),Mt("DDDD",Hn),On(["DDD","DDDD"],function(E,I,q){q._dayOfYear=sn(E)});function Pc(E){var I=Math.round((this.clone().startOf("day")-this.clone().startOf("year"))/864e5)+1;return E==null?I:this.add(E-I,"d")}Ye("m",["mm",2],0,"minute"),Mt("m",En,In),Mt("mm",En,Vr),On(["m","mm"],Do);var mm=tn("Minutes",!1);Ye("s",["ss",2],0,"second"),Mt("s",En,In),Mt("ss",En,Vr),On(["s","ss"],lo);var Ud=tn("Seconds",!1);Ye("S",0,0,function(){return~~(this.millisecond()/100)}),Ye(0,["SS",2],0,function(){return~~(this.millisecond()/10)}),Ye(0,["SSS",3],0,"millisecond"),Ye(0,["SSSS",4],0,function(){return this.millisecond()*10}),Ye(0,["SSSSS",5],0,function(){return this.millisecond()*100}),Ye(0,["SSSSSS",6],0,function(){return this.millisecond()*1e3}),Ye(0,["SSSSSSS",7],0,function(){return this.millisecond()*1e4}),Ye(0,["SSSSSSSS",8],0,function(){return this.millisecond()*1e5}),Ye(0,["SSSSSSSSS",9],0,function(){return this.millisecond()*1e6}),Mt("S",ps,$r),Mt("SS",ps,Vr),Mt("SSS",ps,Hn);var ec,ym;for(ec="SSSS";ec.length<=9;ec+="S")Mt(ec,za);function Zy(E,I){I[js]=sn(("0."+E)*1e3)}for(ec="S";ec.length<=9;ec+="S")On(ec,Zy);ym=tn("Milliseconds",!1),Ye("z",0,0,"zoneAbbr"),Ye("zz",0,0,"zoneName");function o0(){return this._isUTC?"UTC":""}function a0(){return this._isUTC?"Coordinated Universal Time":""}var Jt=me.prototype;Jt.add=ni,Jt.calendar=am,Jt.clone=Zh,Jt.diff=Up,Jt.endOf=cl,Jt.format=Md,Jt.from=zy,Jt.fromNow=um,Jt.to=Df,Jt.toNow=Kl,Jt.get=du,Jt.invalidAt=Ky,Jt.isAfter=xv,Jt.isBefore=Qu,Jt.isBetween=Gl,Jt.isSame=Ea,Jt.isSameOrAfter=vu,Jt.isSameOrBefore=wa,Jt.isValid=Bd,Jt.lang=_u,Jt.locale=cm,Jt.localeData=lm,Jt.max=zo,Jt.min=Jh,Jt.parsingFlags=_x,Jt.set=fs,Jt.startOf=Zu,Jt.subtract=Ld,Jt.toArray=_v,Jt.toObject=pm,Jt.toDate=ll,Jt.toISOString=Cf,Jt.inspect=Af,typeof Symbol<"u"&&Symbol.for!=null&&(Jt[Symbol.for("nodejs.util.inspect.custom")]=function(){return"Moment<"+this.format()+">"}),Jt.toJSON=kf,Jt.toString=al,Jt.unix=$p,Jt.valueOf=Xa,Jt.creationData=e0,Jt.eraName=Vp,Jt.eraNarrow=Xy,Jt.eraAbbr=Sv,Jt.eraYear=jd,Jt.year=Wu,Jt.isLeapYear=Fl,Jt.weekYear=Rf,Jt.isoWeekYear=Qy,Jt.quarter=Jt.quarters=hm,Jt.month=hu,Jt.daysInMonth=em,Jt.week=Jt.weeks=tm,Jt.isoWeek=Jt.isoWeeks=Hh,Jt.weeksInYear=Jl,Jt.weeksInWeekYear=Hp,Jt.isoWeeksInYear=i0,Jt.isoWeeksInISOWeekYear=s0,Jt.date=Xl,Jt.day=Jt.days=Ns,Jt.weekday=wn,Jt.isoWeekday=Gu,Jt.dayOfYear=Pc,Jt.hour=Jt.hours=va,Jt.minute=Jt.minutes=mm,Jt.second=Jt.seconds=Ud,Jt.millisecond=Jt.milliseconds=ym,Jt.utcOffset=Pf,Jt.utc=im,Jt.local=sm,Jt.parseZone=ta,Jt.hasAlignedHourOffset=Sa,Jt.isDST=Ja,Jt.isLocal=Hl,Jt.isUtcOffset=Wl,Jt.isUtc=Ei,Jt.isUTC=Ei,Jt.zoneAbbr=o0,Jt.zoneName=a0,Jt.dates=Ve("dates accessor is deprecated. Use date instead.",Xl),Jt.months=Ve("months accessor is deprecated. Use month instead",hu),Jt.years=Ve("years accessor is deprecated. Use year instead",Wu),Jt.zone=Ve("moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/",bi),Jt.isDSTShifted=Ve("isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information",Vl);function fn(E){return Tn(E*1e3)}function ra(){return Tn.apply(null,arguments).parseZone()}function po(E){return E}var Pn=se.prototype;Pn.calendar=_e,Pn.longDateFormat=Tt,Pn.invalidDate=mt,Pn.ordinal=Yt,Pn.preparse=po,Pn.postformat=po,Pn.relativeTime=_t,Pn.pastFuture=bt,Pn.set=ot,Pn.eras=Yy,Pn.erasParse=Jy,Pn.erasConvertYear=fm,Pn.erasAbbrRegex=t0,Pn.erasNameRegex=Ta,Pn.erasNarrowRegex=If,Pn.months=Z0,Pn.monthsShort=kp,Pn.monthsParse=ga,Pn.monthsRegex=ns,Pn.monthsShortRegex=Ip,Pn.week=Nd,Pn.firstDayOfYear=bf,Pn.firstDayOfWeek=mu,Pn.weekdays=rl,Pn.weekdaysMin=zu,Pn.weekdaysShort=yu,Pn.weekdaysParse=Sc,Pn.weekdaysRegex=Gh,Pn.weekdaysShortRegex=Gs,Pn.weekdaysMinRegex=jl,Pn.isPM=Kh,Pn.meridiem=Lp;function Ua(E,I,q,z){var ee=Xe(),ke=P().set(z,I);return ee[q](ke,E)}function $d(E,I,q){if(m(E)&&(I=E,E=void 0),E=E||"",I!=null)return Ua(E,I,q,"month");var z,ee=[];for(z=0;z<12;z++)ee[z]=Ua(E,z,q,"month");return ee}function Js(E,I,q,z){typeof E=="boolean"?(m(I)&&(q=I,I=void 0),I=I||""):(I=E,q=I,E=!1,m(I)&&(q=I,I=void 0),I=I||"");var ee=Xe(),ke=E?ee._week.dow:0,xt,fr=[];if(q!=null)return Ua(I,(q+ke)%7,z,"day");for(xt=0;xt<7;xt++)fr[xt]=Ua(I,(xt+ke)%7,z,"day");return fr}function Vd(E,I){return $d(E,I,"months")}function Rn(E,I){return $d(E,I,"monthsShort")}function Ff(E,I,q){return Js(E,I,q,"weekdays")}function zp(E,I,q){return Js(E,I,q,"weekdaysShort")}function gm(E,I,q){return Js(E,I,q,"weekdaysMin")}ae("en",{eras:[{since:"0001-01-01",until:1/0,offset:1,name:"Anno Domini",narrow:"AD",abbr:"AD"},{since:"0000-12-31",until:-1/0,offset:1,name:"Before Christ",narrow:"BC",abbr:"BC"}],dayOfMonthOrdinalParse:/\d{1,2}(th|st|nd|rd)/,ordinal:function(E){var I=E%10,q=sn(E%100/10)===1?"th":I===1?"st":I===2?"nd":I===3?"rd":"th";return E+q}}),t.lang=Ve("moment.lang is deprecated. Use moment.locale instead.",ae),t.langData=Ve("moment.langData is deprecated. Use moment.localeData instead.",Xe);var Cc=Math.abs;function vm(){var E=this._data;return this._milliseconds=Cc(this._milliseconds),this._days=Cc(this._days),this._months=Cc(this._months),E.milliseconds=Cc(E.milliseconds),E.seconds=Cc(E.seconds),E.minutes=Cc(E.minutes),E.hours=Cc(E.hours),E.months=Cc(E.months),E.years=Cc(E.years),this}function u0(E,I,q,z){var ee=So(I,q);return E._milliseconds+=z*ee._milliseconds,E._days+=z*ee._days,E._months+=z*ee._months,E._bubble()}function Ql(E,I){return u0(this,E,I,1)}function Ar(E,I){return u0(this,E,I,-1)}function Gp(E){return E<0?Math.floor(E):Math.ceil(E)}function xm(){var E=this._milliseconds,I=this._days,q=this._months,z=this._data,ee,ke,xt,fr,dn;return E>=0&&I>=0&&q>=0||E<=0&&I<=0&&q<=0||(E+=Gp(Ac(q)+I)*864e5,I=0,q=0),z.milliseconds=E%1e3,ee=Si(E/1e3),z.seconds=ee%60,ke=Si(ee/60),z.minutes=ke%60,xt=Si(ke/60),z.hours=xt%24,I+=Si(xt/24),dn=Si(Eu(I)),q+=dn,I-=Gp(Ac(dn)),fr=Si(q/12),q%=12,z.days=I,z.months=q,z.years=fr,this}function Eu(E){return E*4800/146097}function Ac(E){return E*146097/4800}function Hd(E){if(!this.isValid())return NaN;var I,q,z=this._milliseconds;if(E=ge(E),E==="month"||E==="quarter"||E==="year")switch(I=this._days+z/864e5,q=this._months+Eu(I),E){case"month":return q;case"quarter":return q/3;case"year":return q/12}else switch(I=this._days+Math.round(Ac(this._months)),E){case"week":return I/7+z/6048e5;case"day":return I+z/864e5;case"hour":return I*24+z/36e5;case"minute":return I*1440+z/6e4;case"second":return I*86400+z/1e3;case"millisecond":return Math.floor(I*864e5)+z;default:throw new Error("Unknown unit "+E)}}function Qa(E){return function(){return this.as(E)}}var Lf=Qa("ms"),_m=Qa("s"),pl=Qa("m"),Wd=Qa("h"),Kp=Qa("d"),Mf=Qa("w"),tc=Qa("M"),Dc=Qa("Q"),zd=Qa("y"),Yp=Lf;function Pa(){return So(this)}function Ui(E){return E=ge(E),this.isValid()?this[E+"s"]():NaN}function Oi(E){return function(){return this.isValid()?this._data[E]:NaN}}var c0=Oi("milliseconds"),Za=Oi("seconds"),eg=Oi("minutes"),Bf=Oi("hours"),Sm=Oi("days"),bv=Oi("months"),bm=Oi("years");function l0(){return Si(this.days()/7)}var wu=Math.round,Zl={ss:44,s:45,m:45,h:22,d:26,w:null,M:11};function jf(E,I,q,z,ee){return ee.relativeTime(I||1,!!q,E,z)}function tg(E,I,q,z){var ee=So(E).abs(),ke=wu(ee.as("s")),xt=wu(ee.as("m")),fr=wu(ee.as("h")),dn=wu(ee.as("d")),fi=wu(ee.as("M")),ia=wu(ee.as("w")),eu=wu(ee.as("y")),qs=ke<=q.ss&&["s",ke]||ke<q.s&&["ss",ke]||xt<=1&&["m"]||xt<q.m&&["mm",xt]||fr<=1&&["h"]||fr<q.h&&["hh",fr]||dn<=1&&["d"]||dn<q.d&&["dd",dn];return q.w!=null&&(qs=qs||ia<=1&&["w"]||ia<q.w&&["ww",ia]),qs=qs||fi<=1&&["M"]||fi<q.M&&["MM",fi]||eu<=1&&["y"]||["yy",eu],qs[2]=I,qs[3]=+E>0,qs[4]=z,jf.apply(null,qs)}function rg(E){return E===void 0?wu:typeof E=="function"?(wu=E,!0):!1}function Gd(E,I){return Zl[E]===void 0?!1:I===void 0?Zl[E]:(Zl[E]=I,E==="s"&&(Zl.ss=I-1),!0)}function Ev(E,I){if(!this.isValid())return this.localeData().invalidDate();var q=!1,z=Zl,ee,ke;return typeof E=="object"&&(I=E,E=!1),typeof E=="boolean"&&(q=E),typeof I=="object"&&(z=Object.assign({},Zl,I),I.s!=null&&I.ss==null&&(z.ss=I.s-1)),ee=this.localeData(),ke=tg(this,!q,z,ee),q&&(ke=ee.pastFuture(+this,ke)),ee.postformat(ke)}var p0=Math.abs;function ep(E){return(E>0)-(E<0)||+E}function na(){if(!this.isValid())return this.localeData().invalidDate();var E=p0(this._milliseconds)/1e3,I=p0(this._days),q=p0(this._months),z,ee,ke,xt,fr=this.asSeconds(),dn,fi,ia,eu;return fr?(z=Si(E/60),ee=Si(z/60),E%=60,z%=60,ke=Si(q/12),q%=12,xt=E?E.toFixed(3).replace(/\.?0+$/,""):"",dn=fr<0?"-":"",fi=ep(this._months)!==ep(fr)?"-":"",ia=ep(this._days)!==ep(fr)?"-":"",eu=ep(this._milliseconds)!==ep(fr)?"-":"",dn+"P"+(ke?fi+ke+"Y":"")+(q?fi+q+"M":"")+(I?ia+I+"D":"")+(ee||z||E?"T":"")+(ee?eu+ee+"H":"")+(z?eu+z+"M":"")+(E?eu+xt+"S":"")):"P0D"}var qn=Ec.prototype;qn.isValid=Fd,qn.abs=vm,qn.add=Ql,qn.subtract=Ar,qn.as=Hd,qn.asMilliseconds=Lf,qn.asSeconds=_m,qn.asMinutes=pl,qn.asHours=Wd,qn.asDays=Kp,qn.asWeeks=Mf,qn.asMonths=tc,qn.asQuarters=Dc,qn.asYears=zd,qn.valueOf=Yp,qn._bubble=xm,qn.clone=Pa,qn.get=Ui,qn.milliseconds=c0,qn.seconds=Za,qn.minutes=eg,qn.hours=Bf,qn.days=Sm,qn.weeks=l0,qn.months=bv,qn.years=bm,qn.humanize=Ev,qn.toISOString=na,qn.toString=na,qn.toJSON=na,qn.locale=cm,qn.localeData=lm,qn.toIsoString=Ve("toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)",na),qn.lang=_u,Ye("X",0,0,"unix"),Ye("x",0,0,"valueOf"),Mt("x",rt),Mt("X",Xt),On("X",function(E,I,q){q._d=new Date(parseFloat(E)*1e3)}),On("x",function(E,I,q){q._d=new Date(sn(E))});return t.version="2.30.1",r(Tn),t.fn=Jt,t.min=Ka,t.max=Rd,t.now=wf,t.utc=P,t.unix=fn,t.months=Vd,t.isDate=y,t.locale=ae,t.invalid=M,t.duration=So,t.isMoment=Ce,t.weekdays=Ff,t.parseZone=ra,t.localeData=Xe,t.isDuration=qa,t.monthsShort=Rn,t.weekdaysMin=gm,t.defineLocale=Me,t.updateLocale=it,t.locales=gt,t.weekdaysShort=zp,t.normalizeUnits=ge,t.relativeTimeRounding=rg,t.relativeTimeThreshold=Gd,t.calendarFormat=xx,t.prototype=Jt,t.HTML5_FMT={DATETIME_LOCAL:"YYYY-MM-DDTHH:mm",DATETIME_LOCAL_SECONDS:"YYYY-MM-DDTHH:mm:ss",DATETIME_LOCAL_MS:"YYYY-MM-DDTHH:mm:ss.SSS",DATE:"YYYY-MM-DD",TIME:"HH:mm",TIME_SECONDS:"HH:mm:ss",TIME_MS:"HH:mm:ss.SSS",WEEK:"GGGG-[W]WW",MONTH:"YYYY-MM"},t})});function D0(){return!process.stdout.isTTY||process.env.FORCE_NON_TTY==="1"||process.env.CI==="true"||process.env.CI==="1"||process.env.PAGES_SOURCE==="skills"||process.env.EDGEONE_NON_INTERACTIVE==="1"}function gC({prefix:e="cli"}){return Vs.default.createElement(Bs.Text,{color:"grey"},"[",e,"]")}function yi(e,t="cli"){if(D0()){console.log(`\x1B[90m[${t}]\x1B[0m\x1B[31m[\u2718] \x1B[0m${e}`);return}let{unmount:r}=(0,Bs.render)(Vs.default.createElement(Bs.Text,null,Vs.default.createElement(gC,{prefix:t}),Vs.default.createElement(Bs.Text,{color:"red"},"[\u2718] "),e));r()}function vC(e,t="cli"){if(D0()){console.log(`\x1B[90m[${t}]\x1B[0m\x1B[32m[\u2714] \x1B[0m${e}`);return}let{unmount:r}=(0,Bs.render)(Vs.default.createElement(Bs.Text,null,Vs.default.createElement(gC,{prefix:t}),Vs.default.createElement(Bs.Text,{color:"green"},"[\u2714] "),e));r()}function pi(e,t="cli"){if(D0()){console.log(`\x1B[90m[${t}]\x1B[0m \x1B[33mWARNING:\x1B[0m ${e}`);return}let{unmount:r}=(0,Bs.render)(Vs.default.createElement(Bs.Text,null,Vs.default.createElement(gC,{prefix:t}),Vs.default.createElement(Bs.Text,{color:"orange"},"\u2757\uFE0F "),e));r()}function $z(e){if(D0()){console.log(e);return}let{unmount:t}=(0,Bs.render)(Vs.default.createElement(Bs.Text,{color:"cyan"},e));t()}function Dt(e,t="cli"){if(D0()){console.log(`\x1B[90m[${t}]\x1B[0m ${e}`);return}let{unmount:r}=(0,Bs.render)(Vs.default.createElement(Bs.Text,null,Vs.default.createElement(gC,{prefix:t})," ",e));r()}function HR({timestamp:e}){return Vs.default.createElement(Bs.Box,{width:13},Vs.default.createElement(Bs.Text,{color:"grey"},(0,Wb.default)(e).format("HH:mm:ss.SSS")))}function Vz(e,t){if(D0()){console.log(`${(0,Wb.default)(t).format("HH:mm:ss.SSS")} ${e}`);return}let{unmount:r}=(0,Bs.render)(Vs.default.createElement(Bs.Box,null,Vs.default.createElement(HR,{timestamp:t}),Vs.default.createElement(Bs.Text,null,e)));r()}function Hz(e,t){if(D0()){console.log(`${(0,Wb.default)(t).format("HH:mm:ss.SSS")} [WARNING] ${e}`);return}let{unmount:r}=(0,Bs.render)(Vs.default.createElement(Bs.Box,null,Vs.default.createElement(HR,{timestamp:t}),Vs.default.createElement(Bs.Text,{color:"white",backgroundColor:"yellow"},"[WARNING]"),Vs.default.createElement(Bs.Text,null," ",e)));r()}function WR(e,t){if(D0()){console.log(`${(0,Wb.default)(t).format("HH:mm:ss.SSS")} [ERROR] ${e}`);return}let{unmount:r}=(0,Bs.render)(Vs.default.createElement(Bs.Box,null,Vs.default.createElement(HR,{timestamp:t}),Vs.default.createElement(Bs.Text,{color:"white",backgroundColor:"red"},"[ERROR]"),Vs.default.createElement(Bs.Text,null," ",e)));r()}var Bs,Vs,Wb,ua=ht(()=>{Bs=Lt(yC()),Vs=Lt(yo()),Wb=Lt(Uz())});var zz,Wz=ht(()=>{zz={name:"edgeone",version:"1.6.27",description:"Command-line interface for TencentCloud Pages Functions",bin:{edgeone:"./edgeone-bin/edgeone.js"},files:["./edgeone-bin/edgeone.js","./edgeone-dist/cli.js","./edgeone-dist/pages/templates","./edgeone-dist/pages/dev/runner-worker.js","./edgeone-dist/pages/observability-python/**","./edgeone-dist/libs-pages-blob-python/**","./edgeone-dist/libs-pages-agent-toolkit/**","./edgeone-dist/studio/**","./edgeone-dist/plugins/**","./libs-pages-blob-python/**","./libs-pages-agent-toolkit/**"],author:"",keywords:["tencent","edgeone","edgefunctions","edgeone","cli","typescript"],scripts:{clean:"rimraf ./edgeone-dist ./edgeone-bin ./libs-node-ai ./libs-kv-client",bundle:"node -r esbuild-register ./scripts/bundle.ts",watch:"node -r esbuild-register ./scripts/bundle.ts watch",build:"npm run clean && npm run build:pages-ai && npm run build:kv-client && npm run prepare:blob-wheel && npm run prepare:agent-toolkit-wheel && npm run bundle","build:pages-ai":"node ./scripts/build-pages-ai.js","build:kv-client":"node ./scripts/build-kv-client.js","prepare:blob-wheel":"node ./scripts/prepare-pages-blob-wheel.js","prepare:agent-toolkit-wheel":"node ./scripts/prepare-pages-agent-toolkit-wheel.js","verify:publish-assets":"node ./scripts/verify-publish-assets.js","upload:agent-version-manifest":"node ./scripts/upload-agent-version-manifest.js",format:'prettier --write "src/**/*.{ts,tsx,js,jsx,json,md}" "scripts/**/*.{ts,js}" "*.{json,md}"',prepack:"npm run build && npm run verify:publish-assets",prepublishOnly:"npm run build && npm run verify:publish-assets",test:"vitest run","test:watch":"vitest","test:coverage":"vitest run --coverage","test:observability":"vitest run --config src/agent/observability/node/tests/vitest.config.ts && cd src/agent/observability/python && uv run pytest tests/ -q"},dependencies:{"@edgeone/framework-detect":"^0.0.2","@edgeone/is-spa":"^0.0.3","@edgeone/nuxt-pages":"1.1.0","@edgeone/opennextjs-pages":"0.2.10","@edgeone/pages-agent-toolkit":"^0.1.34","@edgeone/pages-blob":"^0.0.16",archiver:"^7.0.1",chokidar:"^4.0.1","common-path-prefix":"^1.0.0","cos-nodejs-sdk-v5":"^2.14.7","cross-spawn":"^7.0.6",crypto:"^1.0.1","detect-port":"^2.1.0",esbuild:"^0.19.2","esbuild-plugin-polyfill-node":"^0.3.0","esbuild-plugin-vue":"^0.2.4","fast-glob":"^3.3.0","fs-extra":"^11.3.1",giget:"^2.0.0","ink-table":"^3.1.0",inquirer:"^8.2.4",install:"^0.13.0",lodash:"^4.17.21","mime-types":"^3.0.1",minimatch:"^9.0.5","node-persist":"^4.0.3",npm:"^10.9.1",open:"^8.4.2","p-map":"^5.5.0","parse-gitignore":"^2.0.0",portfinder:"^1.0.32",undici:"^5.29.0",vitest:"^4.0.17"},devDependencies:{"@babel/generator":"^7.28.0","@babel/parser":"^7.28.0","@babel/traverse":"^7.28.0","@babel/types":"^7.28.0","@opentelemetry/api":"^1.9.1","@opentelemetry/core":"^1.30.1","@opentelemetry/exporter-metrics-otlp-http":"^0.55.0","@opentelemetry/exporter-trace-otlp-http":"^0.55.0","@opentelemetry/instrumentation":"^0.55.0","@opentelemetry/otlp-transformer":"^0.55.0","@opentelemetry/resources":"^1.30.1","@opentelemetry/sdk-metrics":"^1.30.1","@opentelemetry/sdk-trace-base":"^1.30.1","@opentelemetry/sdk-trace-node":"^1.30.1","@opentelemetry/semantic-conventions":"^1.40.0","@tencent/capi-nodejs-sdk":"^2.3.2","@types/http-proxy":"^1.17.12","@types/inquirer":"^9.0.8","@types/ip":"^1.1.0","@types/lodash":"^4.14.198","@types/prompts":"^2.4.4","@types/react":"^17.0.2","@types/uuid":"^9.0.3","@types/ws":"^8.5.7","@types/yargs":"^17.0.24","@vitest/coverage-v8":"^4.0.17",axios:"^1.7.9",chalk:"^5.3.0",cookie:"^1.0.2",dotenv:"^16.3.1","esbuild-register":"^3.6.0",execa:"^7.1.1","http-proxy":"^1.18.1",husky:"^8.0.3",ink:"^3.2.0",ip:"^2.0.1",json5:"^2.2.3","lint-staged":"^15.2.0",lodash:"^4.17.21",moment:"^2.30.1","node-fetch":"^3.3.2",prettier:"^3.1.1",prompts:"^2.4.2",protobufjs:"^8.4.2",react:"^17.0.2",rimraf:"^6.0.1",semiver:"^1.1.0",sirv:"^2.0.3","tencentcloud-cls-sdk-js-web":"^1.0.13","ts-node":"^10.9.2",typescript:"^5.9.3","update-check":"^1.5.4",uuid:"^9.0.0",ws:"^8.14.2",yargs:"^17.6.2",zod:"^3.23.8","zod-to-json-schema":"^3.23.5"},engines:{node:">=12"},"lint-staged":{"*.{ts,tsx,js,jsx,json,md}":["prettier --write"]}}});function bIe(){var e,t;return{run_id:SIe,cli_version:(t=(e=zz)==null?void 0:e.version)!=null?t:"unknown",node_version:process.version,os_platform:GR.default.platform(),os_arch:GR.default.arch(),app_type:"cli",app_id:process.env.AppId||void 0,uin:process.env.Uin||void 0,instance_id:process.env.ProjectId||void 0,is_ci:process.env.CI==="true"}}function EIe(e,t){try{if(typeof process.send!="function")return;process.send(JSON.stringify({name:e,value:JSON.stringify(t)}))}catch{}}function lu(e){var r;let t={...bIe(),...e};EIe((r=t.event_name)!=null?r:"unknown",t)}function ld(e){if(e==null)return{message:"unknown error",stack:""};if(typeof e=="string")return{message:xC(e,zR),stack:""};if(typeof e=="object"){let t=e,r=xC(typeof t.message=="string"?t.message:String(t),zR),s=xC(typeof t.stack=="string"?t.stack:"",wIe);return{message:r,stack:s}}return{message:xC(String(e),zR),stack:""}}function xC(e,t){return e.length>t?e.slice(0,t)+"\u2026[truncated]":e}var GR,uu,cu,SIe,KR,zR,wIe,dy=ht(()=>{GR=Lt(require("os"));Wz();uu={COMMAND:"command",REQUEST:"request",LOCAL_FLOW:"local_flow",EXIT:"exit"},cu={SUCCESS:"success",FAIL:"fail",START:"start"},SIe=`cli-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;KR=(e,t)=>{let r=ld(t);lu({event_name:"error",event_scope:uu.COMMAND,event_result:cu.FAIL,error_message:`${e} ${r.message}`.trim(),error_stack:r.stack})},zR=500,wIe=2e3});var zb,S2,YR=ht(()=>{zb={NEXTJS:"nextjs",NUXTJS:"nuxtjs",ASTRO:"astro",UNKNOWN:"unknown"},S2={FRAMEWORK_DETECT:"framework_detect",PLUGIN_RESOLVE:"plugin_resolve",PLUGIN_LOAD:"plugin_load",PLUGIN_HOOK:"plugin_hook",CONFIG_LOAD:"config_load"}});function CIe(e){if((e==null?void 0:e.code)===PIe)return!0;let t=typeof e=="string"?e:e==null?void 0:e.message;return t==null?void 0:t.includes(TIe)}async function Mg(e=!1){try{let t=await PP(e);return lu({event_name:"Config:Load:Success",event_scope:uu.LOCAL_FLOW,event_phase:S2.CONFIG_LOAD,event_result:cu.SUCCESS,has_build_command:(t==null?void 0:t.buildCommand)!=null,has_install_command:(t==null?void 0:t.installCommand)!=null,has_output_directory:(t==null?void 0:t.outputDirectory)!=null,has_node_version:(t==null?void 0:t.nodeVersion)!=null}),t}catch(t){let r=ld(t);if(lu({event_name:"Config:Load:Fail",event_scope:uu.LOCAL_FLOW,event_phase:S2.CONFIG_LOAD,event_result:cu.FAIL,error_message:r.message}),CIe(t))throw t;return od()&&console.error("%c [ error ]-80","font-size:13px; background:pink; color:#bf2c9f;",t),null}}var TIe,PIe,JR=ht(()=>{n2();_P();dy();YR();TIe="[BLOCKING_CONFIG_ERROR]",PIe="BLOCKING_CONFIG_ERROR"});var _C,fc,SC=ht(()=>{_C=[{funcName:"onRequestGet",method:"GET"},{funcName:"onRequestPost",method:"POST"},{funcName:"onRequestDelete",method:"DELETE"},{funcName:"onRequestPatch",method:"PATCH"},{funcName:"onRequestPut",method:"PUT"},{funcName:"onRequestHead",method:"HEAD"},{funcName:"onRequestOptions",method:"OPTIONS"}],fc=["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"]});async function AIe(e){let t;bC.default.statSync(e).isFile()?t=b2.default.resolve(b2.default.dirname(e)):t=e;let r=b2.default.parse(t).root;if(t===r)return null;for(;t!==r;){let s=b2.default.join(t,"package.json");try{return await bC.default.promises.access(s),s}catch{if(t=b2.default.dirname(t),t===r)break}}return null}async function E2(e){if(e.endsWith(".mjs"))return"esm";if(e.endsWith(".cjs"))return"commonjs";try{let t=await AIe(e);if(t&&JSON.parse(await bC.default.promises.readFile(t,"utf-8")).type==="module")return"esm"}catch(t){console.warn("Failed to read package.json:",t)}return"commonjs"}var bC,b2,Gb=ht(()=>{bC=Lt(require("fs")),b2=Lt(require("path"))});function kIe(e){let t=XR.default.extname(e);return DIe[t]||"ts"}function NIe(e){return e.split(",").map(t=>t.trim()).map(t=>{let r=t.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(!r)return"";let[,s,a]=r;return!OIe.has(a)||s===a?"":`const ${a} = ${s};`}).filter(Boolean).join(`
|
|
146
146
|
`)}async function Yz(e,t,r,s){let a=`mod_${IIe++}`,l=(await Kz.default.build({stdin:{contents:e,loader:kIe(r),resolveDir:XR.default.dirname(r)},write:!1,bundle:!0,format:"esm",platform:"node",target:"node14",minify:!1,resolveExtensions:[".ts",".js",".mjs",".json"],nodePaths:[process.cwd()],absWorkingDir:process.cwd(),external:(s==null?void 0:s.externalModules)||[]})).outputFiles[0].text,f=[];l=l.replace(/^import\s+[^'"]*['"][^'"]*['"]\s*;?\n/gm,b=>(f.push(b),"")),l=l.replace(/export (async )?function/g,"$1function"),l=l.replace(/export const/g,"const"),l=l.replace(/export let/g,"let"),l=l.replace(/export var/g,"var"),l=l.replace(/export default/g,""),l=l.replace(/export\s*\{([^}]+)\};?/g,(b,P)=>NIe(P)),l=l.replace(/export class/g,"class");let m=/const\s+app\s*=/.test(l),y=`${f.join(`
|
|
147
147
|
`)}`;return{code:s!=null&&s.isFramework?`
|
|
148
148
|
const ${a} = (() => {
|
|
@@ -1702,6 +1702,9 @@ var LANGGRAPH_STORE_PREFIX = "langgraph_store";
|
|
|
1702
1702
|
var LANGGRAPH_STORE_KEY_SEPARATOR = "__key__";
|
|
1703
1703
|
var LANGGRAPH_SERDE_VERSION = 1;
|
|
1704
1704
|
var CLAUDE_SESSION_PREFIX = "claude_sessions";
|
|
1705
|
+
var CLAUDE_SESSION_MAPPING_PREFIX = "claude_session_mapping";
|
|
1706
|
+
var STATE_PREFIX = "state";
|
|
1707
|
+
var MAX_STATE_KEY_LENGTH = 256;
|
|
1705
1708
|
var SESSION_METADATA_MARKER = { agent_sdk_session: true };
|
|
1706
1709
|
var VALID_ROLES = /* @__PURE__ */ new Set([
|
|
1707
1710
|
"user",
|
|
@@ -1748,6 +1751,15 @@ var MemoryStorageError = class extends Error {
|
|
|
1748
1751
|
this.cause = cause;
|
|
1749
1752
|
}
|
|
1750
1753
|
};
|
|
1754
|
+
var MemoryCorruptError = class extends Error {
|
|
1755
|
+
code = "MemoryCorruptError";
|
|
1756
|
+
cause;
|
|
1757
|
+
constructor(message, cause) {
|
|
1758
|
+
super(message);
|
|
1759
|
+
this.name = "MemoryCorruptError";
|
|
1760
|
+
this.cause = cause;
|
|
1761
|
+
}
|
|
1762
|
+
};
|
|
1751
1763
|
var dynamicImport = new Function(
|
|
1752
1764
|
"specifier",
|
|
1753
1765
|
"return import(specifier);"
|
|
@@ -1755,7 +1767,7 @@ var dynamicImport = new Function(
|
|
|
1755
1767
|
var langchainLoadPromise;
|
|
1756
1768
|
var langchainMessagesPromise;
|
|
1757
1769
|
function isMemoryError(error) {
|
|
1758
|
-
return error instanceof MemoryValidationError || error instanceof MemoryNotFoundError || error instanceof MemoryQuotaExceededError || error instanceof MemoryStorageError;
|
|
1770
|
+
return error instanceof MemoryValidationError || error instanceof MemoryNotFoundError || error instanceof MemoryQuotaExceededError || error instanceof MemoryStorageError || error instanceof MemoryCorruptError;
|
|
1759
1771
|
}
|
|
1760
1772
|
async function wrapStorage(operation) {
|
|
1761
1773
|
try {
|
|
@@ -1923,10 +1935,17 @@ async function reviveLangGraphJsonValue(value) {
|
|
|
1923
1935
|
return revived;
|
|
1924
1936
|
}
|
|
1925
1937
|
async function deserializeLangGraphJson(value) {
|
|
1926
|
-
|
|
1927
|
-
|
|
1938
|
+
try {
|
|
1939
|
+
if (isLangGraphSerializedJson(value)) {
|
|
1940
|
+
return reviveLangGraphJsonValue(JSON.parse(value.data));
|
|
1941
|
+
}
|
|
1942
|
+
return reviveLangGraphJsonValue(value);
|
|
1943
|
+
} catch (error) {
|
|
1944
|
+
throw new MemoryCorruptError(
|
|
1945
|
+
"LangGraph persisted state is corrupt or incompatible.",
|
|
1946
|
+
error
|
|
1947
|
+
);
|
|
1928
1948
|
}
|
|
1929
|
-
return reviveLangGraphJsonValue(value);
|
|
1930
1949
|
}
|
|
1931
1950
|
function normalizeStoreLimit(value, fallback) {
|
|
1932
1951
|
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
@@ -2038,6 +2057,115 @@ function validateMessageId(messageId) {
|
|
|
2038
2057
|
throw new MemoryValidationError("messageId is required.");
|
|
2039
2058
|
}
|
|
2040
2059
|
}
|
|
2060
|
+
function validateStateKey(key) {
|
|
2061
|
+
if (typeof key !== "string" || key.length === 0) {
|
|
2062
|
+
throw new MemoryValidationError("state key is required.");
|
|
2063
|
+
}
|
|
2064
|
+
if (key.length > MAX_STATE_KEY_LENGTH) {
|
|
2065
|
+
throw new MemoryValidationError(
|
|
2066
|
+
\`state key must be at most \${MAX_STATE_KEY_LENGTH} characters.\`
|
|
2067
|
+
);
|
|
2068
|
+
}
|
|
2069
|
+
}
|
|
2070
|
+
function assertStateSerializable(value, path = "state value", seen = /* @__PURE__ */ new Set()) {
|
|
2071
|
+
if (value === null || typeof value === "string" || typeof value === "boolean") {
|
|
2072
|
+
return;
|
|
2073
|
+
}
|
|
2074
|
+
if (typeof value === "number") {
|
|
2075
|
+
if (Number.isFinite(value))
|
|
2076
|
+
return;
|
|
2077
|
+
throw new MemoryValidationError(\`\${path} must contain only JSON values.\`);
|
|
2078
|
+
}
|
|
2079
|
+
if (value === void 0 || typeof value === "function" || typeof value === "symbol" || typeof value === "bigint") {
|
|
2080
|
+
throw new MemoryValidationError(\`\${path} must be JSON serializable.\`);
|
|
2081
|
+
}
|
|
2082
|
+
if (typeof value !== "object") {
|
|
2083
|
+
throw new MemoryValidationError(\`\${path} must be JSON serializable.\`);
|
|
2084
|
+
}
|
|
2085
|
+
if (seen.has(value)) {
|
|
2086
|
+
throw new MemoryValidationError(\`\${path} must not contain circular references.\`);
|
|
2087
|
+
}
|
|
2088
|
+
seen.add(value);
|
|
2089
|
+
if (Array.isArray(value)) {
|
|
2090
|
+
value.forEach((item, index) => assertStateSerializable(item, \`\${path}[\${index}]\`, seen));
|
|
2091
|
+
} else if (isPlainObject(value)) {
|
|
2092
|
+
for (const [key, item] of Object.entries(value)) {
|
|
2093
|
+
assertStateSerializable(item, \`\${path}.\${key}\`, seen);
|
|
2094
|
+
}
|
|
2095
|
+
} else {
|
|
2096
|
+
throw new MemoryValidationError(\`\${path} must contain only JSON values.\`);
|
|
2097
|
+
}
|
|
2098
|
+
seen.delete(value);
|
|
2099
|
+
}
|
|
2100
|
+
function stateConversationPrefix(conversationId) {
|
|
2101
|
+
return \`\${STATE_PREFIX}/\${encodeKeySegment(conversationId)}/\`;
|
|
2102
|
+
}
|
|
2103
|
+
function createAgentStateStore(store, boundConversationId) {
|
|
2104
|
+
const requireConversation = () => {
|
|
2105
|
+
if (!boundConversationId) {
|
|
2106
|
+
throw new MemoryValidationError(
|
|
2107
|
+
"State operations require a bound conversationId."
|
|
2108
|
+
);
|
|
2109
|
+
}
|
|
2110
|
+
validateConversationId(boundConversationId);
|
|
2111
|
+
return boundConversationId;
|
|
2112
|
+
};
|
|
2113
|
+
return {
|
|
2114
|
+
async get(key) {
|
|
2115
|
+
validateStateKey(key);
|
|
2116
|
+
const conversationId = requireConversation();
|
|
2117
|
+
return wrapStorage(async () => {
|
|
2118
|
+
const raw = await store.get(
|
|
2119
|
+
\`\${stateConversationPrefix(conversationId)}\${encodeKeySegment(key)}\`,
|
|
2120
|
+
{ consistency: "strong" }
|
|
2121
|
+
);
|
|
2122
|
+
if (raw === null)
|
|
2123
|
+
return null;
|
|
2124
|
+
if (typeof raw !== "string") {
|
|
2125
|
+
throw new MemoryStorageError("Stored state value is not valid JSON text.");
|
|
2126
|
+
}
|
|
2127
|
+
try {
|
|
2128
|
+
return JSON.parse(raw);
|
|
2129
|
+
} catch (error) {
|
|
2130
|
+
throw new MemoryStorageError("Stored state value is invalid JSON.", error);
|
|
2131
|
+
}
|
|
2132
|
+
});
|
|
2133
|
+
},
|
|
2134
|
+
async set(key, value) {
|
|
2135
|
+
validateStateKey(key);
|
|
2136
|
+
const conversationId = requireConversation();
|
|
2137
|
+
assertStateSerializable(value);
|
|
2138
|
+
let serialized;
|
|
2139
|
+
try {
|
|
2140
|
+
serialized = JSON.stringify(value);
|
|
2141
|
+
} catch (error) {
|
|
2142
|
+
throw new MemoryValidationError(\`state value must be JSON serializable: \${String(error)}\`);
|
|
2143
|
+
}
|
|
2144
|
+
await wrapStorage(
|
|
2145
|
+
() => store.set(
|
|
2146
|
+
\`\${stateConversationPrefix(conversationId)}\${encodeKeySegment(key)}\`,
|
|
2147
|
+
serialized
|
|
2148
|
+
)
|
|
2149
|
+
);
|
|
2150
|
+
},
|
|
2151
|
+
async delete(key) {
|
|
2152
|
+
validateStateKey(key);
|
|
2153
|
+
const conversationId = requireConversation();
|
|
2154
|
+
await wrapStorage(
|
|
2155
|
+
() => store.delete(
|
|
2156
|
+
\`\${stateConversationPrefix(conversationId)}\${encodeKeySegment(key)}\`
|
|
2157
|
+
)
|
|
2158
|
+
);
|
|
2159
|
+
}
|
|
2160
|
+
};
|
|
2161
|
+
}
|
|
2162
|
+
async function deleteAgentState(store, conversationId) {
|
|
2163
|
+
const listed = await store.list({
|
|
2164
|
+
prefix: stateConversationPrefix(conversationId),
|
|
2165
|
+
consistency: "strong"
|
|
2166
|
+
});
|
|
2167
|
+
await Promise.all(listed.keys.map((key) => store.delete(key)));
|
|
2168
|
+
}
|
|
2041
2169
|
function validateUserId(userId) {
|
|
2042
2170
|
if (userId === void 0) {
|
|
2043
2171
|
return;
|
|
@@ -2170,6 +2298,9 @@ function cursorSortKey(cursor) {
|
|
|
2170
2298
|
const payload = decodeConversationCursor(cursor);
|
|
2171
2299
|
return \`\${reverseTimestamp(payload.lastMessageAt)}_\${encodeKeySegment(payload.conversationId)}\`;
|
|
2172
2300
|
}
|
|
2301
|
+
function cursorListCursor(cursor) {
|
|
2302
|
+
return cursor ? decodeConversationCursor(cursor).listCursor : void 0;
|
|
2303
|
+
}
|
|
2173
2304
|
function indexSortKey(key, prefix) {
|
|
2174
2305
|
return key.slice(prefix.length);
|
|
2175
2306
|
}
|
|
@@ -2337,6 +2468,51 @@ function claudeSessionBase(projectKey, sessionId) {
|
|
|
2337
2468
|
function claudeProjectPrefix(projectKey) {
|
|
2338
2469
|
return \`\${CLAUDE_SESSION_PREFIX}/\${encodeKeySegment(projectKey)}/\`;
|
|
2339
2470
|
}
|
|
2471
|
+
function claudeSessionMappingKey(conversationId) {
|
|
2472
|
+
return \`\${CLAUDE_SESSION_MAPPING_PREFIX}/\${encodeKeySegment(conversationId)}\`;
|
|
2473
|
+
}
|
|
2474
|
+
function normalizeClaudeUuid(value) {
|
|
2475
|
+
const trimmed = value.trim().toLowerCase();
|
|
2476
|
+
return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/.test(trimmed) ? trimmed : null;
|
|
2477
|
+
}
|
|
2478
|
+
function claudeSessionIdFromKey(key) {
|
|
2479
|
+
const prefix = \`\${CLAUDE_SESSION_PREFIX}/\`;
|
|
2480
|
+
if (!key.startsWith(prefix)) {
|
|
2481
|
+
return null;
|
|
2482
|
+
}
|
|
2483
|
+
const segments = key.slice(prefix.length).split("/");
|
|
2484
|
+
return segments.length >= 3 && segments[1] ? decodeKeySegment(segments[1]) : null;
|
|
2485
|
+
}
|
|
2486
|
+
async function deleteClaudeSessionForConversation(store, conversationId) {
|
|
2487
|
+
const mappingKey = claudeSessionMappingKey(conversationId);
|
|
2488
|
+
const mapping = await store.get(mappingKey, {
|
|
2489
|
+
consistency: "strong"
|
|
2490
|
+
});
|
|
2491
|
+
let sessionId = null;
|
|
2492
|
+
if (typeof mapping === "string") {
|
|
2493
|
+
sessionId = mapping;
|
|
2494
|
+
} else if (isPlainObject(mapping) && typeof mapping.sessionId === "string") {
|
|
2495
|
+
sessionId = mapping.sessionId;
|
|
2496
|
+
} else if (isPlainObject(mapping) && typeof mapping.session_id === "string") {
|
|
2497
|
+
sessionId = mapping.session_id;
|
|
2498
|
+
}
|
|
2499
|
+
if (!sessionId) {
|
|
2500
|
+
sessionId = normalizeClaudeUuid(conversationId);
|
|
2501
|
+
}
|
|
2502
|
+
await store.delete(mappingKey);
|
|
2503
|
+
if (!sessionId) {
|
|
2504
|
+
return;
|
|
2505
|
+
}
|
|
2506
|
+
const listed = await store.list({
|
|
2507
|
+
prefix: \`\${CLAUDE_SESSION_PREFIX}/\`,
|
|
2508
|
+
consistency: "strong"
|
|
2509
|
+
});
|
|
2510
|
+
for (const key of listed.keys) {
|
|
2511
|
+
if (claudeSessionIdFromKey(key) === sessionId) {
|
|
2512
|
+
await store.delete(key);
|
|
2513
|
+
}
|
|
2514
|
+
}
|
|
2515
|
+
}
|
|
2340
2516
|
function claudePartsPrefix(key) {
|
|
2341
2517
|
let base = claudeSessionBase(key.projectKey, key.sessionId).slice(0, -1);
|
|
2342
2518
|
if (key.subpath) {
|
|
@@ -2374,7 +2550,9 @@ function createClaudeSessionStore(store) {
|
|
|
2374
2550
|
consistency: "strong"
|
|
2375
2551
|
});
|
|
2376
2552
|
if (typeof raw !== "string") {
|
|
2377
|
-
|
|
2553
|
+
throw new MemoryCorruptError(
|
|
2554
|
+
\`Claude session part '\${partKey}' is not valid JSONL text.\`
|
|
2555
|
+
);
|
|
2378
2556
|
}
|
|
2379
2557
|
for (const line of raw.split("\\n")) {
|
|
2380
2558
|
const trimmed = line.trim();
|
|
@@ -2383,7 +2561,11 @@ function createClaudeSessionStore(store) {
|
|
|
2383
2561
|
}
|
|
2384
2562
|
try {
|
|
2385
2563
|
entries.push(JSON.parse(trimmed));
|
|
2386
|
-
} catch {
|
|
2564
|
+
} catch (error) {
|
|
2565
|
+
throw new MemoryCorruptError(
|
|
2566
|
+
\`Claude session part '\${partKey}' contains malformed JSONL.\`,
|
|
2567
|
+
error
|
|
2568
|
+
);
|
|
2387
2569
|
}
|
|
2388
2570
|
}
|
|
2389
2571
|
}
|
|
@@ -2509,8 +2691,70 @@ async function listConversationsByUser(store, userId, options) {
|
|
|
2509
2691
|
});
|
|
2510
2692
|
}
|
|
2511
2693
|
async function listConversationsFromIndex(store, options) {
|
|
2694
|
+
if (!options.before) {
|
|
2695
|
+
const fast = await listConversationsFromIndexFast(store, options);
|
|
2696
|
+
if (fast)
|
|
2697
|
+
return fast;
|
|
2698
|
+
}
|
|
2512
2699
|
return listConversationsFromIndexFull(store, options);
|
|
2513
2700
|
}
|
|
2701
|
+
async function listConversationsFromIndexFast(store, options) {
|
|
2702
|
+
var _a, _b;
|
|
2703
|
+
let listCursor = cursorListCursor(options.after);
|
|
2704
|
+
if (options.after && !listCursor) {
|
|
2705
|
+
return null;
|
|
2706
|
+
}
|
|
2707
|
+
const pageItems = [];
|
|
2708
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2709
|
+
let lastCursor;
|
|
2710
|
+
while (pageItems.length < options.limit) {
|
|
2711
|
+
const listed = await store.list({
|
|
2712
|
+
prefix: options.prefix,
|
|
2713
|
+
cursor: listCursor,
|
|
2714
|
+
limit: options.limit - pageItems.length,
|
|
2715
|
+
paginate: false,
|
|
2716
|
+
consistency: "strong"
|
|
2717
|
+
});
|
|
2718
|
+
lastCursor = listed.cursor;
|
|
2719
|
+
if (!listed.keys.length) {
|
|
2720
|
+
break;
|
|
2721
|
+
}
|
|
2722
|
+
const indexItems = [...listed.keys].sort(
|
|
2723
|
+
(left, right) => options.order === "desc" ? left.localeCompare(right) : right.localeCompare(left)
|
|
2724
|
+
).map((key) => {
|
|
2725
|
+
const conversationId = options.conversationIdFromKey(key);
|
|
2726
|
+
if (!conversationId || seen.has(conversationId)) {
|
|
2727
|
+
return null;
|
|
2728
|
+
}
|
|
2729
|
+
seen.add(conversationId);
|
|
2730
|
+
return {
|
|
2731
|
+
key,
|
|
2732
|
+
sortKey: indexSortKey(key, options.prefix),
|
|
2733
|
+
conversationId
|
|
2734
|
+
};
|
|
2735
|
+
}).filter((item) => item !== null);
|
|
2736
|
+
const metas = await Promise.all(
|
|
2737
|
+
indexItems.map((item) => readConversationMeta(store, item.conversationId))
|
|
2738
|
+
);
|
|
2739
|
+
for (let i = 0; i < indexItems.length; i++) {
|
|
2740
|
+
const meta = metas[i];
|
|
2741
|
+
if (meta) {
|
|
2742
|
+
pageItems.push({ indexItem: indexItems[i], meta });
|
|
2743
|
+
}
|
|
2744
|
+
}
|
|
2745
|
+
if (!listed.cursor) {
|
|
2746
|
+
break;
|
|
2747
|
+
}
|
|
2748
|
+
listCursor = listed.cursor;
|
|
2749
|
+
}
|
|
2750
|
+
const firstItem = (_a = pageItems[0]) == null ? void 0 : _a.indexItem;
|
|
2751
|
+
const lastItem = (_b = pageItems[pageItems.length - 1]) == null ? void 0 : _b.indexItem;
|
|
2752
|
+
return {
|
|
2753
|
+
items: pageItems.map((item) => item.meta),
|
|
2754
|
+
nextCursor: lastItem ? encodeConversationCursorFromIndexItem(lastItem, lastCursor) : void 0,
|
|
2755
|
+
previousCursor: firstItem ? encodeConversationCursorFromIndexItem(firstItem) : void 0
|
|
2756
|
+
};
|
|
2757
|
+
}
|
|
2514
2758
|
async function listConversationsFromIndexFull(store, options) {
|
|
2515
2759
|
var _a, _b;
|
|
2516
2760
|
const afterSortKey = options.after ? cursorSortKey(options.after) : void 0;
|
|
@@ -2947,6 +3191,7 @@ function createAgentMemory(store, options = {}) {
|
|
|
2947
3191
|
const maxMessagesPerConversation = options.maxMessagesPerConversation ?? DEFAULT_MAX_MESSAGES_PER_CONVERSATION;
|
|
2948
3192
|
const langgraphCheckpointer = createLangGraphCheckpointer(store);
|
|
2949
3193
|
const langgraphStore = createLangGraphStore(store);
|
|
3194
|
+
const state = createAgentStateStore(store, options.conversationId);
|
|
2950
3195
|
let claudeStoreCache = null;
|
|
2951
3196
|
let lastMessageCreatedAt = 0;
|
|
2952
3197
|
const appendMessagesInternal = async (inputs) => {
|
|
@@ -3232,8 +3477,13 @@ function createAgentMemory(store, options = {}) {
|
|
|
3232
3477
|
listMessageKeys(store, input.conversationId)
|
|
3233
3478
|
]);
|
|
3234
3479
|
if (!meta) {
|
|
3480
|
+
if (options.conversationId === input.conversationId) {
|
|
3481
|
+
await deleteAgentState(store, input.conversationId);
|
|
3482
|
+
}
|
|
3483
|
+
await deleteClaudeSessionForConversation(store, input.conversationId);
|
|
3484
|
+
await langgraphCheckpointer.deleteThread(input.conversationId);
|
|
3235
3485
|
throw new MemoryNotFoundError(
|
|
3236
|
-
"Conversation not found by
|
|
3486
|
+
"Conversation not found by deleteConversation."
|
|
3237
3487
|
);
|
|
3238
3488
|
}
|
|
3239
3489
|
const deleteOps = [];
|
|
@@ -3250,6 +3500,11 @@ function createAgentMemory(store, options = {}) {
|
|
|
3250
3500
|
deleteOps.push(store.delete(metaKey(input.conversationId)));
|
|
3251
3501
|
deleteOps.push(store.delete(conversationIndexKey(meta)));
|
|
3252
3502
|
await Promise.all(deleteOps);
|
|
3503
|
+
if (options.conversationId === input.conversationId) {
|
|
3504
|
+
await deleteAgentState(store, input.conversationId);
|
|
3505
|
+
}
|
|
3506
|
+
await deleteClaudeSessionForConversation(store, input.conversationId);
|
|
3507
|
+
await langgraphCheckpointer.deleteThread(input.conversationId);
|
|
3253
3508
|
});
|
|
3254
3509
|
},
|
|
3255
3510
|
async updateConversation(input) {
|
|
@@ -3285,14 +3540,49 @@ function createAgentMemory(store, options = {}) {
|
|
|
3285
3540
|
}));
|
|
3286
3541
|
},
|
|
3287
3542
|
openaiSession(sessionId, sessionOptions = {}) {
|
|
3543
|
+
const boundSessionId = sessionId ?? options.conversationId;
|
|
3544
|
+
if (!boundSessionId) {
|
|
3545
|
+
throw new MemoryValidationError(
|
|
3546
|
+
"openaiSession requires a sessionId or bound conversationId."
|
|
3547
|
+
);
|
|
3548
|
+
}
|
|
3288
3549
|
const maxItems = sessionOptions.maxItems ?? MAX_LIMIT;
|
|
3289
3550
|
return createOpenAISession(
|
|
3290
3551
|
memory,
|
|
3291
|
-
|
|
3552
|
+
boundSessionId,
|
|
3292
3553
|
maxItems,
|
|
3293
3554
|
appendMessagesInternal
|
|
3294
3555
|
);
|
|
3295
3556
|
},
|
|
3557
|
+
async claudeSessionBinding(conversationId) {
|
|
3558
|
+
const resolvedConversationId = conversationId ?? options.conversationId;
|
|
3559
|
+
if (!resolvedConversationId) {
|
|
3560
|
+
throw new MemoryValidationError(
|
|
3561
|
+
"claudeSessionBinding requires a conversationId or bound conversationId."
|
|
3562
|
+
);
|
|
3563
|
+
}
|
|
3564
|
+
validateConversationId(resolvedConversationId);
|
|
3565
|
+
return wrapStorage(async () => {
|
|
3566
|
+
const mappingKey = claudeSessionMappingKey(resolvedConversationId);
|
|
3567
|
+
const existing = await store.get(
|
|
3568
|
+
mappingKey,
|
|
3569
|
+
{ consistency: "strong" }
|
|
3570
|
+
);
|
|
3571
|
+
if (typeof existing === "string" && existing) {
|
|
3572
|
+
return existing;
|
|
3573
|
+
}
|
|
3574
|
+
if (isPlainObject(existing) && (typeof existing.sessionId === "string" || typeof existing.session_id === "string") && (existing.sessionId || existing.session_id)) {
|
|
3575
|
+
return String(existing.sessionId || existing.session_id);
|
|
3576
|
+
}
|
|
3577
|
+
const sessionId = normalizeClaudeUuid(resolvedConversationId) ?? randomUUID();
|
|
3578
|
+
const binding = {
|
|
3579
|
+
conversationId: resolvedConversationId,
|
|
3580
|
+
sessionId
|
|
3581
|
+
};
|
|
3582
|
+
await store.set(mappingKey, binding);
|
|
3583
|
+
return sessionId;
|
|
3584
|
+
});
|
|
3585
|
+
},
|
|
3296
3586
|
claudeSessionStore() {
|
|
3297
3587
|
if (!claudeStoreCache) {
|
|
3298
3588
|
claudeStoreCache = createClaudeSessionStore(store);
|
|
@@ -3300,7 +3590,8 @@ function createAgentMemory(store, options = {}) {
|
|
|
3300
3590
|
return claudeStoreCache;
|
|
3301
3591
|
},
|
|
3302
3592
|
langgraphCheckpointer,
|
|
3303
|
-
langgraphStore
|
|
3593
|
+
langgraphStore,
|
|
3594
|
+
state
|
|
3304
3595
|
};
|
|
3305
3596
|
return memory;
|
|
3306
3597
|
}
|
|
@@ -3545,24 +3836,24 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
3545
3836
|
var require_dist = __commonJS({
|
|
3546
3837
|
"node_modules/@edgeone/pages-blob/dist/index.js"(exports, module) {
|
|
3547
3838
|
"use strict";
|
|
3548
|
-
var
|
|
3839
|
+
var U = Object.defineProperty;
|
|
3549
3840
|
var le = Object.getOwnPropertyDescriptor;
|
|
3550
3841
|
var ue = Object.getOwnPropertyNames;
|
|
3551
3842
|
var ge = Object.prototype.hasOwnProperty;
|
|
3552
3843
|
var fe = (t, e) => {
|
|
3553
3844
|
for (var r in e)
|
|
3554
|
-
|
|
3845
|
+
U(t, r, { get: e[r], enumerable: true });
|
|
3555
3846
|
};
|
|
3556
3847
|
var he = (t, e, r, n) => {
|
|
3557
3848
|
if (e && typeof e == "object" || typeof e == "function")
|
|
3558
3849
|
for (let s of ue(e))
|
|
3559
|
-
!ge.call(t, s) && s !== r &&
|
|
3850
|
+
!ge.call(t, s) && s !== r && U(t, s, { get: () => e[s], enumerable: !(n = le(e, s)) || n.enumerable });
|
|
3560
3851
|
return t;
|
|
3561
3852
|
};
|
|
3562
|
-
var me = (t) => he(
|
|
3563
|
-
var
|
|
3564
|
-
fe(
|
|
3565
|
-
module.exports = me(
|
|
3853
|
+
var me = (t) => he(U({}, "__esModule", { value: true }), t);
|
|
3854
|
+
var Oe = {};
|
|
3855
|
+
fe(Oe, { InvalidKeyError: () => w, InvalidStoreNameError: () => y, MissingProjectIdError: () => T, PagesBlobError: () => h, PreconditionFailedError: () => x, QuotaExceededError: () => O, RateLimitedError: () => j, Store: () => E, getStore: () => Me, listStores: () => De });
|
|
3856
|
+
module.exports = me(Oe);
|
|
3566
3857
|
var h = class extends Error {
|
|
3567
3858
|
code;
|
|
3568
3859
|
constructor(e, r) {
|
|
@@ -3584,12 +3875,12 @@ var require_dist = __commonJS({
|
|
|
3584
3875
|
super("MISSING_ENVIRONMENT", \`Environment not configured for Pages Blob. Missing: \${e.join(", ")}. Supply these properties when creating a store, or ensure the function is running in a Pages environment.\`);
|
|
3585
3876
|
}
|
|
3586
3877
|
};
|
|
3587
|
-
var
|
|
3878
|
+
var O = class extends h {
|
|
3588
3879
|
constructor() {
|
|
3589
3880
|
super("QUOTA_EXCEEDED", "storage quota exceeded");
|
|
3590
3881
|
}
|
|
3591
3882
|
};
|
|
3592
|
-
var
|
|
3883
|
+
var j = class extends h {
|
|
3593
3884
|
constructor() {
|
|
3594
3885
|
super("RATE_LIMITED", "request rate limited, please retry later");
|
|
3595
3886
|
}
|
|
@@ -3622,7 +3913,7 @@ var require_dist = __commonJS({
|
|
|
3622
3913
|
if (new TextEncoder().encode(t).length > 600)
|
|
3623
3914
|
throw new w("Blob key must be a sequence of Unicode characters whose UTF-8 encoding is at most 600 bytes long.");
|
|
3624
3915
|
}
|
|
3625
|
-
function
|
|
3916
|
+
function z(t) {
|
|
3626
3917
|
if (t === "")
|
|
3627
3918
|
throw new y("Store name must not be empty.");
|
|
3628
3919
|
if (t.includes("/") || t.includes(":"))
|
|
@@ -3710,45 +4001,48 @@ var require_dist = __commonJS({
|
|
|
3710
4001
|
}
|
|
3711
4002
|
};
|
|
3712
4003
|
var ye = new TextEncoder();
|
|
3713
|
-
function
|
|
4004
|
+
function _(t) {
|
|
3714
4005
|
let e = ye.encode(t), r = new ArrayBuffer(e.byteLength), n = new Uint8Array(r);
|
|
3715
4006
|
return n.set(e), n;
|
|
3716
4007
|
}
|
|
3717
|
-
function
|
|
4008
|
+
function G(t) {
|
|
3718
4009
|
let e = t instanceof Uint8Array ? t : new Uint8Array(t), r = "";
|
|
3719
4010
|
for (let n = 0; n < e.length; n++)
|
|
3720
4011
|
r += e[n].toString(16).padStart(2, "0");
|
|
3721
4012
|
return r;
|
|
3722
4013
|
}
|
|
3723
|
-
async function
|
|
3724
|
-
let r = await crypto.subtle.importKey("raw",
|
|
3725
|
-
return
|
|
4014
|
+
async function H(t, e) {
|
|
4015
|
+
let r = await crypto.subtle.importKey("raw", _(t), { name: "HMAC", hash: "SHA-1" }, false, ["sign"]), n = await crypto.subtle.sign("HMAC", r, _(e));
|
|
4016
|
+
return G(n);
|
|
3726
4017
|
}
|
|
3727
4018
|
async function pe(t) {
|
|
3728
|
-
let e = await crypto.subtle.digest("SHA-1",
|
|
3729
|
-
return
|
|
4019
|
+
let e = await crypto.subtle.digest("SHA-1", _(t));
|
|
4020
|
+
return G(e);
|
|
3730
4021
|
}
|
|
3731
|
-
function
|
|
4022
|
+
function $(t) {
|
|
3732
4023
|
return encodeURIComponent(t).replace(/[!'()*]/g, (e) => "%" + e.charCodeAt(0).toString(16).toUpperCase());
|
|
3733
4024
|
}
|
|
3734
|
-
function
|
|
4025
|
+
function P(t) {
|
|
3735
4026
|
try {
|
|
3736
4027
|
return decodeURIComponent(t);
|
|
3737
4028
|
} catch {
|
|
3738
4029
|
return t;
|
|
3739
4030
|
}
|
|
3740
4031
|
}
|
|
3741
|
-
function
|
|
3742
|
-
return t.split("/").map((e) =>
|
|
4032
|
+
function we(t) {
|
|
4033
|
+
return t.split("/").map((e) => P(e)).join("/");
|
|
4034
|
+
}
|
|
4035
|
+
function I(t) {
|
|
4036
|
+
return we(P(t));
|
|
3743
4037
|
}
|
|
3744
4038
|
function W(t) {
|
|
3745
|
-
return t.split("/").map((e) =>
|
|
4039
|
+
return t.split("/").map((e) => $(P(e))).join("/");
|
|
3746
4040
|
}
|
|
3747
|
-
var
|
|
3748
|
-
function
|
|
3749
|
-
return t === "host" || t === "x-cos-security-token" ? false : !!(
|
|
4041
|
+
var Ce = /* @__PURE__ */ new Set(["cache-control", "content-disposition", "content-encoding", "content-length", "content-md5", "content-type", "expect", "expires", "if-match", "if-modified-since", "if-none-match", "if-unmodified-since", "origin", "range", "transfer-encoding"]);
|
|
4042
|
+
function xe(t) {
|
|
4043
|
+
return t === "host" || t === "x-cos-security-token" ? false : !!(Ce.has(t) || t.startsWith("x-cos-"));
|
|
3750
4044
|
}
|
|
3751
|
-
function
|
|
4045
|
+
function X(t) {
|
|
3752
4046
|
if (!t)
|
|
3753
4047
|
return [];
|
|
3754
4048
|
let e = [];
|
|
@@ -3756,27 +4050,27 @@ var require_dist = __commonJS({
|
|
|
3756
4050
|
n != null && e.push([r.toLowerCase(), String(n)]);
|
|
3757
4051
|
return e.sort(([r], [n]) => r < n ? -1 : r > n ? 1 : 0), e;
|
|
3758
4052
|
}
|
|
3759
|
-
function X(t) {
|
|
3760
|
-
return t.map(([e, r]) => \`\${O(e)}=\${O(r)}\`).join("&");
|
|
3761
|
-
}
|
|
3762
4053
|
function Y(t) {
|
|
3763
|
-
return t.map(([e]) =>
|
|
4054
|
+
return t.map(([e, r]) => \`\${$(e)}=\${$(r)}\`).join("&");
|
|
4055
|
+
}
|
|
4056
|
+
function F(t) {
|
|
4057
|
+
return t.map(([e]) => $(e)).join(";");
|
|
3764
4058
|
}
|
|
3765
4059
|
async function V(t) {
|
|
3766
|
-
let e = t.method.toLowerCase(), r = t.pathname.startsWith("/") ? t.pathname : \`/\${t.pathname}\`, n = Math.floor(Date.now() / 1e3), s = n + (t.expireSeconds ?? 3600), i = \`\${n};\${s}\`, o =
|
|
4060
|
+
let e = t.method.toLowerCase(), r = t.pathname.startsWith("/") ? t.pathname : \`/\${t.pathname}\`, n = Math.floor(Date.now() / 1e3), s = n + (t.expireSeconds ?? 3600), i = \`\${n};\${s}\`, o = X(t.headers).filter(([N]) => xe(N)), c = F(o), d = Y(o), u = X(t.query), l = F(u), g = Y(u), p = \`\${e}
|
|
3767
4061
|
\${r}
|
|
3768
4062
|
\${g}
|
|
3769
4063
|
\${d}
|
|
3770
4064
|
\`, oe = \`sha1
|
|
3771
4065
|
\${i}
|
|
3772
4066
|
\${await pe(p)}
|
|
3773
|
-
\`, ie = await
|
|
3774
|
-
for (let [
|
|
3775
|
-
|
|
3776
|
-
return { authorization: ce, signedHeaders:
|
|
4067
|
+
\`, ie = await H(t.secretKey, i), ae = await H(ie, oe), ce = ["q-sign-algorithm=sha1", \`q-ak=\${t.secretId}\`, \`q-sign-time=\${i}\`, \`q-key-time=\${i}\`, \`q-header-list=\${c}\`, \`q-url-param-list=\${l}\`, \`q-signature=\${ae}\`].join("&"), q = {};
|
|
4068
|
+
for (let [N, de] of o)
|
|
4069
|
+
q[N] = de;
|
|
4070
|
+
return { authorization: ce, signedHeaders: q };
|
|
3777
4071
|
}
|
|
3778
4072
|
async function J(t) {
|
|
3779
|
-
let e = new URL(t.domain), r =
|
|
4073
|
+
let e = new URL(t.domain), r = P(t.key), n = \`/\${I(t.key)}\`, s = \`/\${W(r)}\`;
|
|
3780
4074
|
e.pathname = s;
|
|
3781
4075
|
let { authorization: i } = await V({ method: t.method, pathname: n, query: t.query, headers: t.headers, secretId: t.credential.secretId, secretKey: t.credential.secretKey, expireSeconds: t.expireSeconds });
|
|
3782
4076
|
if (t.query)
|
|
@@ -3792,7 +4086,7 @@ var require_dist = __commonJS({
|
|
|
3792
4086
|
return t.credential.sessionToken && e.searchParams.set("x-cos-security-token", t.credential.sessionToken), e.toString();
|
|
3793
4087
|
}
|
|
3794
4088
|
async function S(t) {
|
|
3795
|
-
let e = new URL(t.domain), r = t.key ?
|
|
4089
|
+
let e = new URL(t.domain), r = t.key ? P(t.key) : "", n = t.key ? \`/\${I(t.key)}\` : "/", s = r ? \`/\${W(r)}\` : "/";
|
|
3796
4090
|
if (e.pathname = s, t.query)
|
|
3797
4091
|
for (let [l, g] of Object.entries(t.query))
|
|
3798
4092
|
g != null && e.searchParams.set(l, String(g));
|
|
@@ -3812,9 +4106,9 @@ var require_dist = __commonJS({
|
|
|
3812
4106
|
}
|
|
3813
4107
|
throw u;
|
|
3814
4108
|
}
|
|
3815
|
-
var
|
|
3816
|
-
var
|
|
3817
|
-
var
|
|
4109
|
+
var be = "blob.edgeone.site";
|
|
4110
|
+
var Te = "blob-nocache.edgeone.site";
|
|
4111
|
+
var M = class t {
|
|
3818
4112
|
credentialManager;
|
|
3819
4113
|
bucket = "";
|
|
3820
4114
|
region = "";
|
|
@@ -3824,7 +4118,7 @@ var require_dist = __commonJS({
|
|
|
3824
4118
|
initialized = false;
|
|
3825
4119
|
static buildErrorDetail(e, r, n, s, i) {
|
|
3826
4120
|
let a = n ? \`\${r}/\${n}\` : r, o = i ? \` [request-id: \${i}]\` : "";
|
|
3827
|
-
return \`\${e} \${a} - \${
|
|
4121
|
+
return \`\${e} \${a} - \${Ee(s)}\${o}\`;
|
|
3828
4122
|
}
|
|
3829
4123
|
constructor(e) {
|
|
3830
4124
|
this.credentialManager = e;
|
|
@@ -3850,7 +4144,7 @@ var require_dist = __commonJS({
|
|
|
3850
4144
|
let a = this.computeSubdomain(e);
|
|
3851
4145
|
if (!a)
|
|
3852
4146
|
throw new f(0, "unable to derive tenant subdomain from credential; missing appId/zoneId/projectId or resourcePrefix");
|
|
3853
|
-
this.cachedDomain = \`https://\${a}.\${
|
|
4147
|
+
this.cachedDomain = \`https://\${a}.\${be}\`, this.uncachedDomain = \`https://\${a}.\${Te}\`, this.initialized = true;
|
|
3854
4148
|
}
|
|
3855
4149
|
async resolveDomain(e) {
|
|
3856
4150
|
return await this.ensureInitialized(), e === "strong" ? this.uncachedDomain : this.cachedDomain;
|
|
@@ -3874,14 +4168,14 @@ var require_dist = __commonJS({
|
|
|
3874
4168
|
return await l.arrayBuffer().catch(() => {
|
|
3875
4169
|
}), { etag: "", statusCode: 412 };
|
|
3876
4170
|
if (!l.ok) {
|
|
3877
|
-
let p = await
|
|
3878
|
-
throw new f(l.status, t.buildErrorDetail("PUT", i, o, p || \`status \${l.status}\`,
|
|
4171
|
+
let p = await k(l);
|
|
4172
|
+
throw new f(l.status, t.buildErrorDetail("PUT", i, o, p || \`status \${l.status}\`, R(l)));
|
|
3879
4173
|
}
|
|
3880
4174
|
let g = l.headers.get("etag") || "";
|
|
3881
4175
|
return await l.arrayBuffer().catch(() => {
|
|
3882
4176
|
}), { etag: g, statusCode: l.status };
|
|
3883
4177
|
} catch (l) {
|
|
3884
|
-
throw l instanceof f ? l : new f(0, t.buildErrorDetail("PUT", i, o,
|
|
4178
|
+
throw l instanceof f ? l : new f(0, t.buildErrorDetail("PUT", i, o, A(l)));
|
|
3885
4179
|
}
|
|
3886
4180
|
}
|
|
3887
4181
|
async createPresignedPutUrl(e, r, n) {
|
|
@@ -3898,13 +4192,13 @@ var require_dist = __commonJS({
|
|
|
3898
4192
|
return await o.arrayBuffer().catch(() => {
|
|
3899
4193
|
}), null;
|
|
3900
4194
|
if (!o.ok) {
|
|
3901
|
-
let u = await
|
|
3902
|
-
throw new f(o.status, t.buildErrorDetail("GET", s, a, u || \`status \${o.status}\`,
|
|
4195
|
+
let u = await k(o);
|
|
4196
|
+
throw new f(o.status, t.buildErrorDetail("GET", s, a, u || \`status \${o.status}\`, R(o)));
|
|
3903
4197
|
}
|
|
3904
4198
|
let c = new Uint8Array(await o.arrayBuffer()), d = Z(o.headers);
|
|
3905
4199
|
return { body: c, contentType: d["content-type"], headers: d };
|
|
3906
4200
|
} catch (o) {
|
|
3907
|
-
throw o instanceof f ? o : new f(0, t.buildErrorDetail("GET", s, a,
|
|
4201
|
+
throw o instanceof f ? o : new f(0, t.buildErrorDetail("GET", s, a, A(o)));
|
|
3908
4202
|
}
|
|
3909
4203
|
}
|
|
3910
4204
|
async headObject(e, r, n) {
|
|
@@ -3914,13 +4208,13 @@ var require_dist = __commonJS({
|
|
|
3914
4208
|
if (o.status === 404)
|
|
3915
4209
|
return null;
|
|
3916
4210
|
if (!o.ok) {
|
|
3917
|
-
let d = await
|
|
3918
|
-
throw new f(o.status, t.buildErrorDetail("HEAD", s, a, d || \`status \${o.status}\`,
|
|
4211
|
+
let d = await k(o);
|
|
4212
|
+
throw new f(o.status, t.buildErrorDetail("HEAD", s, a, d || \`status \${o.status}\`, R(o)));
|
|
3919
4213
|
}
|
|
3920
4214
|
let c = Z(o.headers);
|
|
3921
4215
|
return { cacheControl: c["cache-control"], contentType: c["content-type"], etag: c.etag, headers: c };
|
|
3922
4216
|
} catch (o) {
|
|
3923
|
-
throw o instanceof f ? o : new f(0, t.buildErrorDetail("HEAD", s, a,
|
|
4217
|
+
throw o instanceof f ? o : new f(0, t.buildErrorDetail("HEAD", s, a, A(o)));
|
|
3924
4218
|
}
|
|
3925
4219
|
}
|
|
3926
4220
|
async deleteObject(e, r) {
|
|
@@ -3932,10 +4226,10 @@ var require_dist = __commonJS({
|
|
|
3932
4226
|
});
|
|
3933
4227
|
return;
|
|
3934
4228
|
}
|
|
3935
|
-
let o = await
|
|
3936
|
-
throw new f(a.status, t.buildErrorDetail("DELETE", n, i, o || \`status \${a.status}\`,
|
|
4229
|
+
let o = await k(a);
|
|
4230
|
+
throw new f(a.status, t.buildErrorDetail("DELETE", n, i, o || \`status \${a.status}\`, R(a)));
|
|
3937
4231
|
} catch (a) {
|
|
3938
|
-
throw a instanceof f ? a : new f(0, t.buildErrorDetail("DELETE", n, i,
|
|
4232
|
+
throw a instanceof f ? a : new f(0, t.buildErrorDetail("DELETE", n, i, A(a)));
|
|
3939
4233
|
}
|
|
3940
4234
|
}
|
|
3941
4235
|
async listObjects(e, r) {
|
|
@@ -3961,35 +4255,35 @@ var require_dist = __commonJS({
|
|
|
3961
4255
|
return r;
|
|
3962
4256
|
}
|
|
3963
4257
|
async getBucketRaw(e) {
|
|
3964
|
-
let r = await this.resolveDomain(e.consistency), n = await this.resolveCredential(), s = { prefix: e.prefix };
|
|
3965
|
-
e.delimiter && (s.delimiter = e.delimiter), e.marker && (s.marker = e.marker), e.maxKeys && (s["max-keys"] = e.maxKeys);
|
|
4258
|
+
let r = await this.resolveDomain(e.consistency), n = await this.resolveCredential(), s = { prefix: I(e.prefix) };
|
|
4259
|
+
e.delimiter && (s.delimiter = e.delimiter), e.marker && (s.marker = I(e.marker)), e.maxKeys && (s["max-keys"] = e.maxKeys);
|
|
3966
4260
|
try {
|
|
3967
4261
|
let i = await S({ domain: r, method: "GET", query: s, credential: n });
|
|
3968
4262
|
if (!i.ok) {
|
|
3969
|
-
let o = await
|
|
3970
|
-
throw new f(i.status, t.buildErrorDetail("LIST", r, e.prefix, o || \`status \${i.status}\`,
|
|
4263
|
+
let o = await k(i);
|
|
4264
|
+
throw new f(i.status, t.buildErrorDetail("LIST", r, e.prefix, o || \`status \${i.status}\`, R(i)));
|
|
3971
4265
|
}
|
|
3972
4266
|
let a = await i.text();
|
|
3973
|
-
return
|
|
4267
|
+
return Se(a);
|
|
3974
4268
|
} catch (i) {
|
|
3975
|
-
throw i instanceof f ? i : new f(0, t.buildErrorDetail("LIST", r, e.prefix,
|
|
4269
|
+
throw i instanceof f ? i : new f(0, t.buildErrorDetail("LIST", r, e.prefix, A(i)));
|
|
3976
4270
|
}
|
|
3977
4271
|
}
|
|
3978
4272
|
};
|
|
3979
|
-
function
|
|
4273
|
+
function Ee(t) {
|
|
3980
4274
|
return t.replace(/[a-zA-Z0-9\\-]+\\.cos\\.[a-zA-Z0-9\\-.]+\\.myqcloud\\.com/gi, "[cos-origin]").replace(/[a-zA-Z0-9\\-]+\\.cos\\.[a-zA-Z0-9\\-.]+\\.tencentcos\\.cn/gi, "[cos-origin]");
|
|
3981
4275
|
}
|
|
3982
|
-
async function
|
|
4276
|
+
async function k(t) {
|
|
3983
4277
|
try {
|
|
3984
4278
|
return await t.text();
|
|
3985
4279
|
} catch {
|
|
3986
4280
|
return "";
|
|
3987
4281
|
}
|
|
3988
4282
|
}
|
|
3989
|
-
function
|
|
4283
|
+
function R(t) {
|
|
3990
4284
|
return t.headers.get("x-cos-request-id") || t.headers.get("x-eo-log-id") || void 0;
|
|
3991
4285
|
}
|
|
3992
|
-
function
|
|
4286
|
+
function A(t) {
|
|
3993
4287
|
let e = t, r = e.message || String(t), n = e.cause;
|
|
3994
4288
|
if (n) {
|
|
3995
4289
|
let s = n.message || n.code || "";
|
|
@@ -4003,43 +4297,43 @@ var require_dist = __commonJS({
|
|
|
4003
4297
|
e[n.toLowerCase()] = r;
|
|
4004
4298
|
}), e;
|
|
4005
4299
|
}
|
|
4006
|
-
function
|
|
4300
|
+
function Se(t) {
|
|
4007
4301
|
let e = [], r = /<Contents>([\\s\\S]*?)<\\/Contents>/g, n;
|
|
4008
4302
|
for (; (n = r.exec(t)) !== null; ) {
|
|
4009
|
-
let d = n[1], u =
|
|
4010
|
-
u !== null && e.push({ key:
|
|
4303
|
+
let d = n[1], u = v(d, "Key"), l = v(d, "ETag");
|
|
4304
|
+
u !== null && e.push({ key: L(u), etag: l || "" });
|
|
4011
4305
|
}
|
|
4012
4306
|
let s = [], i = /<CommonPrefixes>([\\s\\S]*?)<\\/CommonPrefixes>/g;
|
|
4013
4307
|
for (; (n = i.exec(t)) !== null; ) {
|
|
4014
|
-
let d = n[1], u =
|
|
4015
|
-
u !== null && s.push(
|
|
4308
|
+
let d = n[1], u = v(d, "Prefix");
|
|
4309
|
+
u !== null && s.push(L(u));
|
|
4016
4310
|
}
|
|
4017
|
-
let o =
|
|
4018
|
-
return { contents: e, commonPrefixes: s, isTruncated: o, nextMarker:
|
|
4311
|
+
let o = v(t, "IsTruncated") === "true", c = v(t, "NextMarker") || "";
|
|
4312
|
+
return { contents: e, commonPrefixes: s, isTruncated: o, nextMarker: L(c) };
|
|
4019
4313
|
}
|
|
4020
|
-
function
|
|
4314
|
+
function v(t, e) {
|
|
4021
4315
|
let n = new RegExp(\`<\${e}>([\\\\s\\\\S]*?)<\\\\/\${e}>\`).exec(t);
|
|
4022
4316
|
return n ? n[1] : null;
|
|
4023
4317
|
}
|
|
4024
|
-
function
|
|
4318
|
+
function L(t) {
|
|
4025
4319
|
return t.replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/'/g, "'").replace(/&/g, "&");
|
|
4026
4320
|
}
|
|
4027
|
-
var
|
|
4028
|
-
async function
|
|
4321
|
+
var Pe = "X-RateLimit-Reset";
|
|
4322
|
+
async function B(t, e, r = 2) {
|
|
4029
4323
|
var _a, _b;
|
|
4030
4324
|
(_b = (_a = e.signal) == null ? void 0 : _a.throwIfAborted) == null ? void 0 : _b.call(_a);
|
|
4031
4325
|
try {
|
|
4032
4326
|
let n = await fetch(t, e);
|
|
4033
4327
|
if (r > 0 && (n.status === 429 || n.status >= 500)) {
|
|
4034
|
-
let s = Q(n.headers.get(
|
|
4035
|
-
return await ee(s, e.signal),
|
|
4328
|
+
let s = Q(n.headers.get(Pe));
|
|
4329
|
+
return await ee(s, e.signal), B(t, e, r - 1);
|
|
4036
4330
|
}
|
|
4037
4331
|
return n;
|
|
4038
4332
|
} catch (n) {
|
|
4039
4333
|
if (r === 0 || n instanceof DOMException && n.name === "AbortError")
|
|
4040
4334
|
throw n;
|
|
4041
4335
|
let s = Q();
|
|
4042
|
-
return await ee(s, e.signal),
|
|
4336
|
+
return await ee(s, e.signal), B(t, e, r - 1);
|
|
4043
4337
|
}
|
|
4044
4338
|
}
|
|
4045
4339
|
function Q(t) {
|
|
@@ -4057,14 +4351,14 @@ var require_dist = __commonJS({
|
|
|
4057
4351
|
e == null ? void 0 : e.addEventListener("abort", i, { once: true });
|
|
4058
4352
|
});
|
|
4059
4353
|
}
|
|
4060
|
-
var
|
|
4354
|
+
var Ie = "prod";
|
|
4061
4355
|
function te() {
|
|
4062
4356
|
let t = typeof process < "u" ? process.env.PAGES_BLOB_STS_ENV : void 0;
|
|
4063
|
-
return t === "test" || t === "prod" ? t :
|
|
4357
|
+
return t === "test" || t === "prod" ? t : Ie;
|
|
4064
4358
|
}
|
|
4065
|
-
var
|
|
4066
|
-
var
|
|
4067
|
-
var
|
|
4359
|
+
var ke = 300;
|
|
4360
|
+
var Re = "https://blob-sts.edgeone.site/";
|
|
4361
|
+
var D = class {
|
|
4068
4362
|
authToken;
|
|
4069
4363
|
projectId;
|
|
4070
4364
|
cached = null;
|
|
@@ -4082,16 +4376,16 @@ var require_dist = __commonJS({
|
|
|
4082
4376
|
}
|
|
4083
4377
|
isExpired(e) {
|
|
4084
4378
|
let r = Math.floor(Date.now() / 1e3);
|
|
4085
|
-
return e.expiredTime - r <
|
|
4379
|
+
return e.expiredTime - r < ke;
|
|
4086
4380
|
}
|
|
4087
4381
|
async fetchCredential() {
|
|
4088
4382
|
for (let n = 1; n <= 3; n++) {
|
|
4089
4383
|
let s = new AbortController(), i = setTimeout(() => s.abort(), 1e4), a;
|
|
4090
4384
|
try {
|
|
4091
|
-
a = await
|
|
4385
|
+
a = await B(Re, { method: "POST", headers: { "Content-Type": "application/json", Authorization: \`Bearer \${this.authToken}\`, "X-Env": te() }, body: JSON.stringify(this.projectId ? { ProjectId: this.projectId } : {}), signal: s.signal });
|
|
4092
4386
|
} catch (d) {
|
|
4093
4387
|
if (n < 3) {
|
|
4094
|
-
await
|
|
4388
|
+
await K(500 * n);
|
|
4095
4389
|
continue;
|
|
4096
4390
|
}
|
|
4097
4391
|
throw new m(\`failed to obtain STS credential: \${d.message || "timeout"}\`);
|
|
@@ -4104,7 +4398,7 @@ var require_dist = __commonJS({
|
|
|
4104
4398
|
throw new m("rate limited, please retry later");
|
|
4105
4399
|
if (!a.ok) {
|
|
4106
4400
|
if (a.status >= 500 && n < 3) {
|
|
4107
|
-
await
|
|
4401
|
+
await K(500 * n);
|
|
4108
4402
|
continue;
|
|
4109
4403
|
}
|
|
4110
4404
|
let d = await a.text().catch(() => "unknown error");
|
|
@@ -4124,7 +4418,7 @@ var require_dist = __commonJS({
|
|
|
4124
4418
|
throw new m(\`credential exchange failed (code=\${o.code}): \${d}\`);
|
|
4125
4419
|
}
|
|
4126
4420
|
if (n < 3) {
|
|
4127
|
-
await
|
|
4421
|
+
await K(500 * n);
|
|
4128
4422
|
continue;
|
|
4129
4423
|
}
|
|
4130
4424
|
throw new m("invalid STS credential response");
|
|
@@ -4132,12 +4426,12 @@ var require_dist = __commonJS({
|
|
|
4132
4426
|
throw new m("invalid STS credential response");
|
|
4133
4427
|
}
|
|
4134
4428
|
};
|
|
4135
|
-
function
|
|
4429
|
+
function K(t) {
|
|
4136
4430
|
return new Promise((e) => setTimeout(e, t));
|
|
4137
4431
|
}
|
|
4138
|
-
var
|
|
4432
|
+
var Ae = "{{PAGES_BLOB_DEPLOY_CREDENTIAL}}";
|
|
4139
4433
|
function re() {
|
|
4140
|
-
let t = {}, e =
|
|
4434
|
+
let t = {}, e = ve();
|
|
4141
4435
|
if (e)
|
|
4142
4436
|
t.deployCredential = e;
|
|
4143
4437
|
else {
|
|
@@ -4147,8 +4441,8 @@ var require_dist = __commonJS({
|
|
|
4147
4441
|
let r = ne("PAGES_PROJECT_ID");
|
|
4148
4442
|
return r && (t.projectId = r), t;
|
|
4149
4443
|
}
|
|
4150
|
-
function
|
|
4151
|
-
let t =
|
|
4444
|
+
function ve() {
|
|
4445
|
+
let t = Ae;
|
|
4152
4446
|
if (!(t.startsWith("{{") && t.endsWith("}}")))
|
|
4153
4447
|
return t || void 0;
|
|
4154
4448
|
}
|
|
@@ -4156,15 +4450,15 @@ var require_dist = __commonJS({
|
|
|
4156
4450
|
if (typeof process < "u" && process.env)
|
|
4157
4451
|
return process.env[t];
|
|
4158
4452
|
}
|
|
4159
|
-
function
|
|
4453
|
+
function Me(t) {
|
|
4160
4454
|
let e = typeof t == "string" ? t : t.name;
|
|
4161
|
-
|
|
4162
|
-
let r = se(typeof t == "string" ? void 0 : t), n = new
|
|
4455
|
+
z(e);
|
|
4456
|
+
let r = se(typeof t == "string" ? void 0 : t), n = new D(r.authToken, r.projectId), s = new M(n);
|
|
4163
4457
|
return new E(s, e, r.consistency ?? "eventual");
|
|
4164
4458
|
}
|
|
4165
|
-
async function
|
|
4166
|
-
let e = se(t ? { name: "__list__", projectId: t.projectId, token: t.token, consistency: t.consistency } : void 0), r = new
|
|
4167
|
-
return { stores: (await new
|
|
4459
|
+
async function De(t) {
|
|
4460
|
+
let e = se(t ? { name: "__list__", projectId: t.projectId, token: t.token, consistency: t.consistency } : void 0), r = new D(e.authToken, e.projectId);
|
|
4461
|
+
return { stores: (await new M(r).listStores(e.consistency)).map((i) => ({ name: i })) };
|
|
4168
4462
|
}
|
|
4169
4463
|
function se(t) {
|
|
4170
4464
|
let e = re(), r = (t == null ? void 0 : t.token) || e.deployCredential, n = (t == null ? void 0 : t.projectId) || e.projectId;
|
|
@@ -4200,6 +4494,9 @@ var LANGGRAPH_STORE_PREFIX = "langgraph_store";
|
|
|
4200
4494
|
var LANGGRAPH_STORE_KEY_SEPARATOR = "__key__";
|
|
4201
4495
|
var LANGGRAPH_SERDE_VERSION = 1;
|
|
4202
4496
|
var CLAUDE_SESSION_PREFIX = "claude_sessions";
|
|
4497
|
+
var CLAUDE_SESSION_MAPPING_PREFIX = "claude_session_mapping";
|
|
4498
|
+
var STATE_PREFIX = "state";
|
|
4499
|
+
var MAX_STATE_KEY_LENGTH = 256;
|
|
4203
4500
|
var SESSION_METADATA_MARKER = { agent_sdk_session: true };
|
|
4204
4501
|
var VALID_ROLES = /* @__PURE__ */ new Set([
|
|
4205
4502
|
"user",
|
|
@@ -4246,6 +4543,15 @@ var MemoryStorageError = class extends Error {
|
|
|
4246
4543
|
this.cause = cause;
|
|
4247
4544
|
}
|
|
4248
4545
|
};
|
|
4546
|
+
var MemoryCorruptError = class extends Error {
|
|
4547
|
+
code = "MemoryCorruptError";
|
|
4548
|
+
cause;
|
|
4549
|
+
constructor(message, cause) {
|
|
4550
|
+
super(message);
|
|
4551
|
+
this.name = "MemoryCorruptError";
|
|
4552
|
+
this.cause = cause;
|
|
4553
|
+
}
|
|
4554
|
+
};
|
|
4249
4555
|
var dynamicImport = new Function(
|
|
4250
4556
|
"specifier",
|
|
4251
4557
|
"return import(specifier);"
|
|
@@ -4253,7 +4559,7 @@ var dynamicImport = new Function(
|
|
|
4253
4559
|
var langchainLoadPromise;
|
|
4254
4560
|
var langchainMessagesPromise;
|
|
4255
4561
|
function isMemoryError(error) {
|
|
4256
|
-
return error instanceof MemoryValidationError || error instanceof MemoryNotFoundError || error instanceof MemoryQuotaExceededError || error instanceof MemoryStorageError;
|
|
4562
|
+
return error instanceof MemoryValidationError || error instanceof MemoryNotFoundError || error instanceof MemoryQuotaExceededError || error instanceof MemoryStorageError || error instanceof MemoryCorruptError;
|
|
4257
4563
|
}
|
|
4258
4564
|
async function wrapStorage(operation) {
|
|
4259
4565
|
try {
|
|
@@ -4421,10 +4727,17 @@ async function reviveLangGraphJsonValue(value) {
|
|
|
4421
4727
|
return revived;
|
|
4422
4728
|
}
|
|
4423
4729
|
async function deserializeLangGraphJson(value) {
|
|
4424
|
-
|
|
4425
|
-
|
|
4730
|
+
try {
|
|
4731
|
+
if (isLangGraphSerializedJson(value)) {
|
|
4732
|
+
return reviveLangGraphJsonValue(JSON.parse(value.data));
|
|
4733
|
+
}
|
|
4734
|
+
return reviveLangGraphJsonValue(value);
|
|
4735
|
+
} catch (error) {
|
|
4736
|
+
throw new MemoryCorruptError(
|
|
4737
|
+
"LangGraph persisted state is corrupt or incompatible.",
|
|
4738
|
+
error
|
|
4739
|
+
);
|
|
4426
4740
|
}
|
|
4427
|
-
return reviveLangGraphJsonValue(value);
|
|
4428
4741
|
}
|
|
4429
4742
|
function normalizeStoreLimit(value, fallback) {
|
|
4430
4743
|
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
@@ -4536,6 +4849,115 @@ function validateMessageId(messageId) {
|
|
|
4536
4849
|
throw new MemoryValidationError("messageId is required.");
|
|
4537
4850
|
}
|
|
4538
4851
|
}
|
|
4852
|
+
function validateStateKey(key) {
|
|
4853
|
+
if (typeof key !== "string" || key.length === 0) {
|
|
4854
|
+
throw new MemoryValidationError("state key is required.");
|
|
4855
|
+
}
|
|
4856
|
+
if (key.length > MAX_STATE_KEY_LENGTH) {
|
|
4857
|
+
throw new MemoryValidationError(
|
|
4858
|
+
\`state key must be at most \${MAX_STATE_KEY_LENGTH} characters.\`
|
|
4859
|
+
);
|
|
4860
|
+
}
|
|
4861
|
+
}
|
|
4862
|
+
function assertStateSerializable(value, path = "state value", seen = /* @__PURE__ */ new Set()) {
|
|
4863
|
+
if (value === null || typeof value === "string" || typeof value === "boolean") {
|
|
4864
|
+
return;
|
|
4865
|
+
}
|
|
4866
|
+
if (typeof value === "number") {
|
|
4867
|
+
if (Number.isFinite(value))
|
|
4868
|
+
return;
|
|
4869
|
+
throw new MemoryValidationError(\`\${path} must contain only JSON values.\`);
|
|
4870
|
+
}
|
|
4871
|
+
if (value === void 0 || typeof value === "function" || typeof value === "symbol" || typeof value === "bigint") {
|
|
4872
|
+
throw new MemoryValidationError(\`\${path} must be JSON serializable.\`);
|
|
4873
|
+
}
|
|
4874
|
+
if (typeof value !== "object") {
|
|
4875
|
+
throw new MemoryValidationError(\`\${path} must be JSON serializable.\`);
|
|
4876
|
+
}
|
|
4877
|
+
if (seen.has(value)) {
|
|
4878
|
+
throw new MemoryValidationError(\`\${path} must not contain circular references.\`);
|
|
4879
|
+
}
|
|
4880
|
+
seen.add(value);
|
|
4881
|
+
if (Array.isArray(value)) {
|
|
4882
|
+
value.forEach((item, index) => assertStateSerializable(item, \`\${path}[\${index}]\`, seen));
|
|
4883
|
+
} else if (isPlainObject(value)) {
|
|
4884
|
+
for (const [key, item] of Object.entries(value)) {
|
|
4885
|
+
assertStateSerializable(item, \`\${path}.\${key}\`, seen);
|
|
4886
|
+
}
|
|
4887
|
+
} else {
|
|
4888
|
+
throw new MemoryValidationError(\`\${path} must contain only JSON values.\`);
|
|
4889
|
+
}
|
|
4890
|
+
seen.delete(value);
|
|
4891
|
+
}
|
|
4892
|
+
function stateConversationPrefix(conversationId) {
|
|
4893
|
+
return \`\${STATE_PREFIX}/\${encodeKeySegment(conversationId)}/\`;
|
|
4894
|
+
}
|
|
4895
|
+
function createAgentStateStore(store, boundConversationId) {
|
|
4896
|
+
const requireConversation = () => {
|
|
4897
|
+
if (!boundConversationId) {
|
|
4898
|
+
throw new MemoryValidationError(
|
|
4899
|
+
"State operations require a bound conversationId."
|
|
4900
|
+
);
|
|
4901
|
+
}
|
|
4902
|
+
validateConversationId(boundConversationId);
|
|
4903
|
+
return boundConversationId;
|
|
4904
|
+
};
|
|
4905
|
+
return {
|
|
4906
|
+
async get(key) {
|
|
4907
|
+
validateStateKey(key);
|
|
4908
|
+
const conversationId = requireConversation();
|
|
4909
|
+
return wrapStorage(async () => {
|
|
4910
|
+
const raw = await store.get(
|
|
4911
|
+
\`\${stateConversationPrefix(conversationId)}\${encodeKeySegment(key)}\`,
|
|
4912
|
+
{ consistency: "strong" }
|
|
4913
|
+
);
|
|
4914
|
+
if (raw === null)
|
|
4915
|
+
return null;
|
|
4916
|
+
if (typeof raw !== "string") {
|
|
4917
|
+
throw new MemoryStorageError("Stored state value is not valid JSON text.");
|
|
4918
|
+
}
|
|
4919
|
+
try {
|
|
4920
|
+
return JSON.parse(raw);
|
|
4921
|
+
} catch (error) {
|
|
4922
|
+
throw new MemoryStorageError("Stored state value is invalid JSON.", error);
|
|
4923
|
+
}
|
|
4924
|
+
});
|
|
4925
|
+
},
|
|
4926
|
+
async set(key, value) {
|
|
4927
|
+
validateStateKey(key);
|
|
4928
|
+
const conversationId = requireConversation();
|
|
4929
|
+
assertStateSerializable(value);
|
|
4930
|
+
let serialized;
|
|
4931
|
+
try {
|
|
4932
|
+
serialized = JSON.stringify(value);
|
|
4933
|
+
} catch (error) {
|
|
4934
|
+
throw new MemoryValidationError(\`state value must be JSON serializable: \${String(error)}\`);
|
|
4935
|
+
}
|
|
4936
|
+
await wrapStorage(
|
|
4937
|
+
() => store.set(
|
|
4938
|
+
\`\${stateConversationPrefix(conversationId)}\${encodeKeySegment(key)}\`,
|
|
4939
|
+
serialized
|
|
4940
|
+
)
|
|
4941
|
+
);
|
|
4942
|
+
},
|
|
4943
|
+
async delete(key) {
|
|
4944
|
+
validateStateKey(key);
|
|
4945
|
+
const conversationId = requireConversation();
|
|
4946
|
+
await wrapStorage(
|
|
4947
|
+
() => store.delete(
|
|
4948
|
+
\`\${stateConversationPrefix(conversationId)}\${encodeKeySegment(key)}\`
|
|
4949
|
+
)
|
|
4950
|
+
);
|
|
4951
|
+
}
|
|
4952
|
+
};
|
|
4953
|
+
}
|
|
4954
|
+
async function deleteAgentState(store, conversationId) {
|
|
4955
|
+
const listed = await store.list({
|
|
4956
|
+
prefix: stateConversationPrefix(conversationId),
|
|
4957
|
+
consistency: "strong"
|
|
4958
|
+
});
|
|
4959
|
+
await Promise.all(listed.keys.map((key) => store.delete(key)));
|
|
4960
|
+
}
|
|
4539
4961
|
function validateUserId(userId) {
|
|
4540
4962
|
if (userId === void 0) {
|
|
4541
4963
|
return;
|
|
@@ -4668,6 +5090,9 @@ function cursorSortKey(cursor) {
|
|
|
4668
5090
|
const payload = decodeConversationCursor(cursor);
|
|
4669
5091
|
return \`\${reverseTimestamp(payload.lastMessageAt)}_\${encodeKeySegment(payload.conversationId)}\`;
|
|
4670
5092
|
}
|
|
5093
|
+
function cursorListCursor(cursor) {
|
|
5094
|
+
return cursor ? decodeConversationCursor(cursor).listCursor : void 0;
|
|
5095
|
+
}
|
|
4671
5096
|
function indexSortKey(key, prefix) {
|
|
4672
5097
|
return key.slice(prefix.length);
|
|
4673
5098
|
}
|
|
@@ -4835,6 +5260,51 @@ function claudeSessionBase(projectKey, sessionId) {
|
|
|
4835
5260
|
function claudeProjectPrefix(projectKey) {
|
|
4836
5261
|
return \`\${CLAUDE_SESSION_PREFIX}/\${encodeKeySegment(projectKey)}/\`;
|
|
4837
5262
|
}
|
|
5263
|
+
function claudeSessionMappingKey(conversationId) {
|
|
5264
|
+
return \`\${CLAUDE_SESSION_MAPPING_PREFIX}/\${encodeKeySegment(conversationId)}\`;
|
|
5265
|
+
}
|
|
5266
|
+
function normalizeClaudeUuid(value) {
|
|
5267
|
+
const trimmed = value.trim().toLowerCase();
|
|
5268
|
+
return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/.test(trimmed) ? trimmed : null;
|
|
5269
|
+
}
|
|
5270
|
+
function claudeSessionIdFromKey(key) {
|
|
5271
|
+
const prefix = \`\${CLAUDE_SESSION_PREFIX}/\`;
|
|
5272
|
+
if (!key.startsWith(prefix)) {
|
|
5273
|
+
return null;
|
|
5274
|
+
}
|
|
5275
|
+
const segments = key.slice(prefix.length).split("/");
|
|
5276
|
+
return segments.length >= 3 && segments[1] ? decodeKeySegment(segments[1]) : null;
|
|
5277
|
+
}
|
|
5278
|
+
async function deleteClaudeSessionForConversation(store, conversationId) {
|
|
5279
|
+
const mappingKey = claudeSessionMappingKey(conversationId);
|
|
5280
|
+
const mapping = await store.get(mappingKey, {
|
|
5281
|
+
consistency: "strong"
|
|
5282
|
+
});
|
|
5283
|
+
let sessionId = null;
|
|
5284
|
+
if (typeof mapping === "string") {
|
|
5285
|
+
sessionId = mapping;
|
|
5286
|
+
} else if (isPlainObject(mapping) && typeof mapping.sessionId === "string") {
|
|
5287
|
+
sessionId = mapping.sessionId;
|
|
5288
|
+
} else if (isPlainObject(mapping) && typeof mapping.session_id === "string") {
|
|
5289
|
+
sessionId = mapping.session_id;
|
|
5290
|
+
}
|
|
5291
|
+
if (!sessionId) {
|
|
5292
|
+
sessionId = normalizeClaudeUuid(conversationId);
|
|
5293
|
+
}
|
|
5294
|
+
await store.delete(mappingKey);
|
|
5295
|
+
if (!sessionId) {
|
|
5296
|
+
return;
|
|
5297
|
+
}
|
|
5298
|
+
const listed = await store.list({
|
|
5299
|
+
prefix: \`\${CLAUDE_SESSION_PREFIX}/\`,
|
|
5300
|
+
consistency: "strong"
|
|
5301
|
+
});
|
|
5302
|
+
for (const key of listed.keys) {
|
|
5303
|
+
if (claudeSessionIdFromKey(key) === sessionId) {
|
|
5304
|
+
await store.delete(key);
|
|
5305
|
+
}
|
|
5306
|
+
}
|
|
5307
|
+
}
|
|
4838
5308
|
function claudePartsPrefix(key) {
|
|
4839
5309
|
let base = claudeSessionBase(key.projectKey, key.sessionId).slice(0, -1);
|
|
4840
5310
|
if (key.subpath) {
|
|
@@ -4872,7 +5342,9 @@ function createClaudeSessionStore(store) {
|
|
|
4872
5342
|
consistency: "strong"
|
|
4873
5343
|
});
|
|
4874
5344
|
if (typeof raw !== "string") {
|
|
4875
|
-
|
|
5345
|
+
throw new MemoryCorruptError(
|
|
5346
|
+
\`Claude session part '\${partKey}' is not valid JSONL text.\`
|
|
5347
|
+
);
|
|
4876
5348
|
}
|
|
4877
5349
|
for (const line of raw.split("\\n")) {
|
|
4878
5350
|
const trimmed = line.trim();
|
|
@@ -4881,7 +5353,11 @@ function createClaudeSessionStore(store) {
|
|
|
4881
5353
|
}
|
|
4882
5354
|
try {
|
|
4883
5355
|
entries.push(JSON.parse(trimmed));
|
|
4884
|
-
} catch {
|
|
5356
|
+
} catch (error) {
|
|
5357
|
+
throw new MemoryCorruptError(
|
|
5358
|
+
\`Claude session part '\${partKey}' contains malformed JSONL.\`,
|
|
5359
|
+
error
|
|
5360
|
+
);
|
|
4885
5361
|
}
|
|
4886
5362
|
}
|
|
4887
5363
|
}
|
|
@@ -5007,8 +5483,70 @@ async function listConversationsByUser(store, userId, options) {
|
|
|
5007
5483
|
});
|
|
5008
5484
|
}
|
|
5009
5485
|
async function listConversationsFromIndex(store, options) {
|
|
5486
|
+
if (!options.before) {
|
|
5487
|
+
const fast = await listConversationsFromIndexFast(store, options);
|
|
5488
|
+
if (fast)
|
|
5489
|
+
return fast;
|
|
5490
|
+
}
|
|
5010
5491
|
return listConversationsFromIndexFull(store, options);
|
|
5011
5492
|
}
|
|
5493
|
+
async function listConversationsFromIndexFast(store, options) {
|
|
5494
|
+
var _a, _b;
|
|
5495
|
+
let listCursor = cursorListCursor(options.after);
|
|
5496
|
+
if (options.after && !listCursor) {
|
|
5497
|
+
return null;
|
|
5498
|
+
}
|
|
5499
|
+
const pageItems = [];
|
|
5500
|
+
const seen = /* @__PURE__ */ new Set();
|
|
5501
|
+
let lastCursor;
|
|
5502
|
+
while (pageItems.length < options.limit) {
|
|
5503
|
+
const listed = await store.list({
|
|
5504
|
+
prefix: options.prefix,
|
|
5505
|
+
cursor: listCursor,
|
|
5506
|
+
limit: options.limit - pageItems.length,
|
|
5507
|
+
paginate: false,
|
|
5508
|
+
consistency: "strong"
|
|
5509
|
+
});
|
|
5510
|
+
lastCursor = listed.cursor;
|
|
5511
|
+
if (!listed.keys.length) {
|
|
5512
|
+
break;
|
|
5513
|
+
}
|
|
5514
|
+
const indexItems = [...listed.keys].sort(
|
|
5515
|
+
(left, right) => options.order === "desc" ? left.localeCompare(right) : right.localeCompare(left)
|
|
5516
|
+
).map((key) => {
|
|
5517
|
+
const conversationId = options.conversationIdFromKey(key);
|
|
5518
|
+
if (!conversationId || seen.has(conversationId)) {
|
|
5519
|
+
return null;
|
|
5520
|
+
}
|
|
5521
|
+
seen.add(conversationId);
|
|
5522
|
+
return {
|
|
5523
|
+
key,
|
|
5524
|
+
sortKey: indexSortKey(key, options.prefix),
|
|
5525
|
+
conversationId
|
|
5526
|
+
};
|
|
5527
|
+
}).filter((item) => item !== null);
|
|
5528
|
+
const metas = await Promise.all(
|
|
5529
|
+
indexItems.map((item) => readConversationMeta(store, item.conversationId))
|
|
5530
|
+
);
|
|
5531
|
+
for (let i = 0; i < indexItems.length; i++) {
|
|
5532
|
+
const meta = metas[i];
|
|
5533
|
+
if (meta) {
|
|
5534
|
+
pageItems.push({ indexItem: indexItems[i], meta });
|
|
5535
|
+
}
|
|
5536
|
+
}
|
|
5537
|
+
if (!listed.cursor) {
|
|
5538
|
+
break;
|
|
5539
|
+
}
|
|
5540
|
+
listCursor = listed.cursor;
|
|
5541
|
+
}
|
|
5542
|
+
const firstItem = (_a = pageItems[0]) == null ? void 0 : _a.indexItem;
|
|
5543
|
+
const lastItem = (_b = pageItems[pageItems.length - 1]) == null ? void 0 : _b.indexItem;
|
|
5544
|
+
return {
|
|
5545
|
+
items: pageItems.map((item) => item.meta),
|
|
5546
|
+
nextCursor: lastItem ? encodeConversationCursorFromIndexItem(lastItem, lastCursor) : void 0,
|
|
5547
|
+
previousCursor: firstItem ? encodeConversationCursorFromIndexItem(firstItem) : void 0
|
|
5548
|
+
};
|
|
5549
|
+
}
|
|
5012
5550
|
async function listConversationsFromIndexFull(store, options) {
|
|
5013
5551
|
var _a, _b;
|
|
5014
5552
|
const afterSortKey = options.after ? cursorSortKey(options.after) : void 0;
|
|
@@ -5445,6 +5983,7 @@ function createAgentMemory(store, options = {}) {
|
|
|
5445
5983
|
const maxMessagesPerConversation = options.maxMessagesPerConversation ?? DEFAULT_MAX_MESSAGES_PER_CONVERSATION;
|
|
5446
5984
|
const langgraphCheckpointer = createLangGraphCheckpointer(store);
|
|
5447
5985
|
const langgraphStore = createLangGraphStore(store);
|
|
5986
|
+
const state = createAgentStateStore(store, options.conversationId);
|
|
5448
5987
|
let claudeStoreCache = null;
|
|
5449
5988
|
let lastMessageCreatedAt = 0;
|
|
5450
5989
|
const appendMessagesInternal = async (inputs) => {
|
|
@@ -5730,8 +6269,13 @@ function createAgentMemory(store, options = {}) {
|
|
|
5730
6269
|
listMessageKeys(store, input.conversationId)
|
|
5731
6270
|
]);
|
|
5732
6271
|
if (!meta) {
|
|
6272
|
+
if (options.conversationId === input.conversationId) {
|
|
6273
|
+
await deleteAgentState(store, input.conversationId);
|
|
6274
|
+
}
|
|
6275
|
+
await deleteClaudeSessionForConversation(store, input.conversationId);
|
|
6276
|
+
await langgraphCheckpointer.deleteThread(input.conversationId);
|
|
5733
6277
|
throw new MemoryNotFoundError(
|
|
5734
|
-
"Conversation not found by
|
|
6278
|
+
"Conversation not found by deleteConversation."
|
|
5735
6279
|
);
|
|
5736
6280
|
}
|
|
5737
6281
|
const deleteOps = [];
|
|
@@ -5748,6 +6292,11 @@ function createAgentMemory(store, options = {}) {
|
|
|
5748
6292
|
deleteOps.push(store.delete(metaKey(input.conversationId)));
|
|
5749
6293
|
deleteOps.push(store.delete(conversationIndexKey(meta)));
|
|
5750
6294
|
await Promise.all(deleteOps);
|
|
6295
|
+
if (options.conversationId === input.conversationId) {
|
|
6296
|
+
await deleteAgentState(store, input.conversationId);
|
|
6297
|
+
}
|
|
6298
|
+
await deleteClaudeSessionForConversation(store, input.conversationId);
|
|
6299
|
+
await langgraphCheckpointer.deleteThread(input.conversationId);
|
|
5751
6300
|
});
|
|
5752
6301
|
},
|
|
5753
6302
|
async updateConversation(input) {
|
|
@@ -5783,14 +6332,49 @@ function createAgentMemory(store, options = {}) {
|
|
|
5783
6332
|
}));
|
|
5784
6333
|
},
|
|
5785
6334
|
openaiSession(sessionId, sessionOptions = {}) {
|
|
6335
|
+
const boundSessionId = sessionId ?? options.conversationId;
|
|
6336
|
+
if (!boundSessionId) {
|
|
6337
|
+
throw new MemoryValidationError(
|
|
6338
|
+
"openaiSession requires a sessionId or bound conversationId."
|
|
6339
|
+
);
|
|
6340
|
+
}
|
|
5786
6341
|
const maxItems = sessionOptions.maxItems ?? MAX_LIMIT;
|
|
5787
6342
|
return createOpenAISession(
|
|
5788
6343
|
memory,
|
|
5789
|
-
|
|
6344
|
+
boundSessionId,
|
|
5790
6345
|
maxItems,
|
|
5791
6346
|
appendMessagesInternal
|
|
5792
6347
|
);
|
|
5793
6348
|
},
|
|
6349
|
+
async claudeSessionBinding(conversationId) {
|
|
6350
|
+
const resolvedConversationId = conversationId ?? options.conversationId;
|
|
6351
|
+
if (!resolvedConversationId) {
|
|
6352
|
+
throw new MemoryValidationError(
|
|
6353
|
+
"claudeSessionBinding requires a conversationId or bound conversationId."
|
|
6354
|
+
);
|
|
6355
|
+
}
|
|
6356
|
+
validateConversationId(resolvedConversationId);
|
|
6357
|
+
return wrapStorage(async () => {
|
|
6358
|
+
const mappingKey = claudeSessionMappingKey(resolvedConversationId);
|
|
6359
|
+
const existing = await store.get(
|
|
6360
|
+
mappingKey,
|
|
6361
|
+
{ consistency: "strong" }
|
|
6362
|
+
);
|
|
6363
|
+
if (typeof existing === "string" && existing) {
|
|
6364
|
+
return existing;
|
|
6365
|
+
}
|
|
6366
|
+
if (isPlainObject(existing) && (typeof existing.sessionId === "string" || typeof existing.session_id === "string") && (existing.sessionId || existing.session_id)) {
|
|
6367
|
+
return String(existing.sessionId || existing.session_id);
|
|
6368
|
+
}
|
|
6369
|
+
const sessionId = normalizeClaudeUuid(resolvedConversationId) ?? randomUUID();
|
|
6370
|
+
const binding = {
|
|
6371
|
+
conversationId: resolvedConversationId,
|
|
6372
|
+
sessionId
|
|
6373
|
+
};
|
|
6374
|
+
await store.set(mappingKey, binding);
|
|
6375
|
+
return sessionId;
|
|
6376
|
+
});
|
|
6377
|
+
},
|
|
5794
6378
|
claudeSessionStore() {
|
|
5795
6379
|
if (!claudeStoreCache) {
|
|
5796
6380
|
claudeStoreCache = createClaudeSessionStore(store);
|
|
@@ -5798,7 +6382,8 @@ function createAgentMemory(store, options = {}) {
|
|
|
5798
6382
|
return claudeStoreCache;
|
|
5799
6383
|
},
|
|
5800
6384
|
langgraphCheckpointer,
|
|
5801
|
-
langgraphStore
|
|
6385
|
+
langgraphStore,
|
|
6386
|
+
state
|
|
5802
6387
|
};
|
|
5803
6388
|
return memory;
|
|
5804
6389
|
}
|
|
@@ -8625,6 +9210,9 @@ var LANGGRAPH_STORE_PREFIX = "langgraph_store";
|
|
|
8625
9210
|
var LANGGRAPH_STORE_KEY_SEPARATOR = "__key__";
|
|
8626
9211
|
var LANGGRAPH_SERDE_VERSION = 1;
|
|
8627
9212
|
var CLAUDE_SESSION_PREFIX = "claude_sessions";
|
|
9213
|
+
var CLAUDE_SESSION_MAPPING_PREFIX = "claude_session_mapping";
|
|
9214
|
+
var STATE_PREFIX = "state";
|
|
9215
|
+
var MAX_STATE_KEY_LENGTH = 256;
|
|
8628
9216
|
var SESSION_METADATA_MARKER = { agent_sdk_session: true };
|
|
8629
9217
|
var VALID_ROLES = /* @__PURE__ */ new Set([
|
|
8630
9218
|
"user",
|
|
@@ -8671,6 +9259,15 @@ var MemoryStorageError = class extends Error {
|
|
|
8671
9259
|
this.cause = cause;
|
|
8672
9260
|
}
|
|
8673
9261
|
};
|
|
9262
|
+
var MemoryCorruptError = class extends Error {
|
|
9263
|
+
code = "MemoryCorruptError";
|
|
9264
|
+
cause;
|
|
9265
|
+
constructor(message, cause) {
|
|
9266
|
+
super(message);
|
|
9267
|
+
this.name = "MemoryCorruptError";
|
|
9268
|
+
this.cause = cause;
|
|
9269
|
+
}
|
|
9270
|
+
};
|
|
8674
9271
|
var dynamicImport = new Function(
|
|
8675
9272
|
"specifier",
|
|
8676
9273
|
"return import(specifier);"
|
|
@@ -8678,7 +9275,7 @@ var dynamicImport = new Function(
|
|
|
8678
9275
|
var langchainLoadPromise;
|
|
8679
9276
|
var langchainMessagesPromise;
|
|
8680
9277
|
function isMemoryError(error) {
|
|
8681
|
-
return error instanceof MemoryValidationError || error instanceof MemoryNotFoundError || error instanceof MemoryQuotaExceededError || error instanceof MemoryStorageError;
|
|
9278
|
+
return error instanceof MemoryValidationError || error instanceof MemoryNotFoundError || error instanceof MemoryQuotaExceededError || error instanceof MemoryStorageError || error instanceof MemoryCorruptError;
|
|
8682
9279
|
}
|
|
8683
9280
|
async function wrapStorage(operation) {
|
|
8684
9281
|
try {
|
|
@@ -8846,10 +9443,17 @@ async function reviveLangGraphJsonValue(value) {
|
|
|
8846
9443
|
return revived;
|
|
8847
9444
|
}
|
|
8848
9445
|
async function deserializeLangGraphJson(value) {
|
|
8849
|
-
|
|
8850
|
-
|
|
9446
|
+
try {
|
|
9447
|
+
if (isLangGraphSerializedJson(value)) {
|
|
9448
|
+
return reviveLangGraphJsonValue(JSON.parse(value.data));
|
|
9449
|
+
}
|
|
9450
|
+
return reviveLangGraphJsonValue(value);
|
|
9451
|
+
} catch (error) {
|
|
9452
|
+
throw new MemoryCorruptError(
|
|
9453
|
+
"LangGraph persisted state is corrupt or incompatible.",
|
|
9454
|
+
error
|
|
9455
|
+
);
|
|
8851
9456
|
}
|
|
8852
|
-
return reviveLangGraphJsonValue(value);
|
|
8853
9457
|
}
|
|
8854
9458
|
function normalizeStoreLimit(value, fallback) {
|
|
8855
9459
|
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
@@ -8961,6 +9565,115 @@ function validateMessageId(messageId) {
|
|
|
8961
9565
|
throw new MemoryValidationError("messageId is required.");
|
|
8962
9566
|
}
|
|
8963
9567
|
}
|
|
9568
|
+
function validateStateKey(key) {
|
|
9569
|
+
if (typeof key !== "string" || key.length === 0) {
|
|
9570
|
+
throw new MemoryValidationError("state key is required.");
|
|
9571
|
+
}
|
|
9572
|
+
if (key.length > MAX_STATE_KEY_LENGTH) {
|
|
9573
|
+
throw new MemoryValidationError(
|
|
9574
|
+
\`state key must be at most \${MAX_STATE_KEY_LENGTH} characters.\`
|
|
9575
|
+
);
|
|
9576
|
+
}
|
|
9577
|
+
}
|
|
9578
|
+
function assertStateSerializable(value, path2 = "state value", seen = /* @__PURE__ */ new Set()) {
|
|
9579
|
+
if (value === null || typeof value === "string" || typeof value === "boolean") {
|
|
9580
|
+
return;
|
|
9581
|
+
}
|
|
9582
|
+
if (typeof value === "number") {
|
|
9583
|
+
if (Number.isFinite(value))
|
|
9584
|
+
return;
|
|
9585
|
+
throw new MemoryValidationError(\`\${path2} must contain only JSON values.\`);
|
|
9586
|
+
}
|
|
9587
|
+
if (value === void 0 || typeof value === "function" || typeof value === "symbol" || typeof value === "bigint") {
|
|
9588
|
+
throw new MemoryValidationError(\`\${path2} must be JSON serializable.\`);
|
|
9589
|
+
}
|
|
9590
|
+
if (typeof value !== "object") {
|
|
9591
|
+
throw new MemoryValidationError(\`\${path2} must be JSON serializable.\`);
|
|
9592
|
+
}
|
|
9593
|
+
if (seen.has(value)) {
|
|
9594
|
+
throw new MemoryValidationError(\`\${path2} must not contain circular references.\`);
|
|
9595
|
+
}
|
|
9596
|
+
seen.add(value);
|
|
9597
|
+
if (Array.isArray(value)) {
|
|
9598
|
+
value.forEach((item, index) => assertStateSerializable(item, \`\${path2}[\${index}]\`, seen));
|
|
9599
|
+
} else if (isPlainObject(value)) {
|
|
9600
|
+
for (const [key, item] of Object.entries(value)) {
|
|
9601
|
+
assertStateSerializable(item, \`\${path2}.\${key}\`, seen);
|
|
9602
|
+
}
|
|
9603
|
+
} else {
|
|
9604
|
+
throw new MemoryValidationError(\`\${path2} must contain only JSON values.\`);
|
|
9605
|
+
}
|
|
9606
|
+
seen.delete(value);
|
|
9607
|
+
}
|
|
9608
|
+
function stateConversationPrefix(conversationId) {
|
|
9609
|
+
return \`\${STATE_PREFIX}/\${encodeKeySegment(conversationId)}/\`;
|
|
9610
|
+
}
|
|
9611
|
+
function createAgentStateStore(store, boundConversationId) {
|
|
9612
|
+
const requireConversation = () => {
|
|
9613
|
+
if (!boundConversationId) {
|
|
9614
|
+
throw new MemoryValidationError(
|
|
9615
|
+
"State operations require a bound conversationId."
|
|
9616
|
+
);
|
|
9617
|
+
}
|
|
9618
|
+
validateConversationId(boundConversationId);
|
|
9619
|
+
return boundConversationId;
|
|
9620
|
+
};
|
|
9621
|
+
return {
|
|
9622
|
+
async get(key) {
|
|
9623
|
+
validateStateKey(key);
|
|
9624
|
+
const conversationId = requireConversation();
|
|
9625
|
+
return wrapStorage(async () => {
|
|
9626
|
+
const raw = await store.get(
|
|
9627
|
+
\`\${stateConversationPrefix(conversationId)}\${encodeKeySegment(key)}\`,
|
|
9628
|
+
{ consistency: "strong" }
|
|
9629
|
+
);
|
|
9630
|
+
if (raw === null)
|
|
9631
|
+
return null;
|
|
9632
|
+
if (typeof raw !== "string") {
|
|
9633
|
+
throw new MemoryStorageError("Stored state value is not valid JSON text.");
|
|
9634
|
+
}
|
|
9635
|
+
try {
|
|
9636
|
+
return JSON.parse(raw);
|
|
9637
|
+
} catch (error) {
|
|
9638
|
+
throw new MemoryStorageError("Stored state value is invalid JSON.", error);
|
|
9639
|
+
}
|
|
9640
|
+
});
|
|
9641
|
+
},
|
|
9642
|
+
async set(key, value) {
|
|
9643
|
+
validateStateKey(key);
|
|
9644
|
+
const conversationId = requireConversation();
|
|
9645
|
+
assertStateSerializable(value);
|
|
9646
|
+
let serialized;
|
|
9647
|
+
try {
|
|
9648
|
+
serialized = JSON.stringify(value);
|
|
9649
|
+
} catch (error) {
|
|
9650
|
+
throw new MemoryValidationError(\`state value must be JSON serializable: \${String(error)}\`);
|
|
9651
|
+
}
|
|
9652
|
+
await wrapStorage(
|
|
9653
|
+
() => store.set(
|
|
9654
|
+
\`\${stateConversationPrefix(conversationId)}\${encodeKeySegment(key)}\`,
|
|
9655
|
+
serialized
|
|
9656
|
+
)
|
|
9657
|
+
);
|
|
9658
|
+
},
|
|
9659
|
+
async delete(key) {
|
|
9660
|
+
validateStateKey(key);
|
|
9661
|
+
const conversationId = requireConversation();
|
|
9662
|
+
await wrapStorage(
|
|
9663
|
+
() => store.delete(
|
|
9664
|
+
\`\${stateConversationPrefix(conversationId)}\${encodeKeySegment(key)}\`
|
|
9665
|
+
)
|
|
9666
|
+
);
|
|
9667
|
+
}
|
|
9668
|
+
};
|
|
9669
|
+
}
|
|
9670
|
+
async function deleteAgentState(store, conversationId) {
|
|
9671
|
+
const listed = await store.list({
|
|
9672
|
+
prefix: stateConversationPrefix(conversationId),
|
|
9673
|
+
consistency: "strong"
|
|
9674
|
+
});
|
|
9675
|
+
await Promise.all(listed.keys.map((key) => store.delete(key)));
|
|
9676
|
+
}
|
|
8964
9677
|
function validateUserId(userId) {
|
|
8965
9678
|
if (userId === void 0) {
|
|
8966
9679
|
return;
|
|
@@ -9093,6 +9806,9 @@ function cursorSortKey(cursor) {
|
|
|
9093
9806
|
const payload = decodeConversationCursor(cursor);
|
|
9094
9807
|
return \`\${reverseTimestamp(payload.lastMessageAt)}_\${encodeKeySegment(payload.conversationId)}\`;
|
|
9095
9808
|
}
|
|
9809
|
+
function cursorListCursor(cursor) {
|
|
9810
|
+
return cursor ? decodeConversationCursor(cursor).listCursor : void 0;
|
|
9811
|
+
}
|
|
9096
9812
|
function indexSortKey(key, prefix) {
|
|
9097
9813
|
return key.slice(prefix.length);
|
|
9098
9814
|
}
|
|
@@ -9260,6 +9976,51 @@ function claudeSessionBase(projectKey, sessionId) {
|
|
|
9260
9976
|
function claudeProjectPrefix(projectKey) {
|
|
9261
9977
|
return \`\${CLAUDE_SESSION_PREFIX}/\${encodeKeySegment(projectKey)}/\`;
|
|
9262
9978
|
}
|
|
9979
|
+
function claudeSessionMappingKey(conversationId) {
|
|
9980
|
+
return \`\${CLAUDE_SESSION_MAPPING_PREFIX}/\${encodeKeySegment(conversationId)}\`;
|
|
9981
|
+
}
|
|
9982
|
+
function normalizeClaudeUuid(value) {
|
|
9983
|
+
const trimmed = value.trim().toLowerCase();
|
|
9984
|
+
return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/.test(trimmed) ? trimmed : null;
|
|
9985
|
+
}
|
|
9986
|
+
function claudeSessionIdFromKey(key) {
|
|
9987
|
+
const prefix = \`\${CLAUDE_SESSION_PREFIX}/\`;
|
|
9988
|
+
if (!key.startsWith(prefix)) {
|
|
9989
|
+
return null;
|
|
9990
|
+
}
|
|
9991
|
+
const segments = key.slice(prefix.length).split("/");
|
|
9992
|
+
return segments.length >= 3 && segments[1] ? decodeKeySegment(segments[1]) : null;
|
|
9993
|
+
}
|
|
9994
|
+
async function deleteClaudeSessionForConversation(store, conversationId) {
|
|
9995
|
+
const mappingKey = claudeSessionMappingKey(conversationId);
|
|
9996
|
+
const mapping = await store.get(mappingKey, {
|
|
9997
|
+
consistency: "strong"
|
|
9998
|
+
});
|
|
9999
|
+
let sessionId = null;
|
|
10000
|
+
if (typeof mapping === "string") {
|
|
10001
|
+
sessionId = mapping;
|
|
10002
|
+
} else if (isPlainObject(mapping) && typeof mapping.sessionId === "string") {
|
|
10003
|
+
sessionId = mapping.sessionId;
|
|
10004
|
+
} else if (isPlainObject(mapping) && typeof mapping.session_id === "string") {
|
|
10005
|
+
sessionId = mapping.session_id;
|
|
10006
|
+
}
|
|
10007
|
+
if (!sessionId) {
|
|
10008
|
+
sessionId = normalizeClaudeUuid(conversationId);
|
|
10009
|
+
}
|
|
10010
|
+
await store.delete(mappingKey);
|
|
10011
|
+
if (!sessionId) {
|
|
10012
|
+
return;
|
|
10013
|
+
}
|
|
10014
|
+
const listed = await store.list({
|
|
10015
|
+
prefix: \`\${CLAUDE_SESSION_PREFIX}/\`,
|
|
10016
|
+
consistency: "strong"
|
|
10017
|
+
});
|
|
10018
|
+
for (const key of listed.keys) {
|
|
10019
|
+
if (claudeSessionIdFromKey(key) === sessionId) {
|
|
10020
|
+
await store.delete(key);
|
|
10021
|
+
}
|
|
10022
|
+
}
|
|
10023
|
+
}
|
|
9263
10024
|
function claudePartsPrefix(key) {
|
|
9264
10025
|
let base = claudeSessionBase(key.projectKey, key.sessionId).slice(0, -1);
|
|
9265
10026
|
if (key.subpath) {
|
|
@@ -9297,7 +10058,9 @@ function createClaudeSessionStore(store) {
|
|
|
9297
10058
|
consistency: "strong"
|
|
9298
10059
|
});
|
|
9299
10060
|
if (typeof raw !== "string") {
|
|
9300
|
-
|
|
10061
|
+
throw new MemoryCorruptError(
|
|
10062
|
+
\`Claude session part '\${partKey}' is not valid JSONL text.\`
|
|
10063
|
+
);
|
|
9301
10064
|
}
|
|
9302
10065
|
for (const line of raw.split("\\n")) {
|
|
9303
10066
|
const trimmed = line.trim();
|
|
@@ -9306,7 +10069,11 @@ function createClaudeSessionStore(store) {
|
|
|
9306
10069
|
}
|
|
9307
10070
|
try {
|
|
9308
10071
|
entries.push(JSON.parse(trimmed));
|
|
9309
|
-
} catch {
|
|
10072
|
+
} catch (error) {
|
|
10073
|
+
throw new MemoryCorruptError(
|
|
10074
|
+
\`Claude session part '\${partKey}' contains malformed JSONL.\`,
|
|
10075
|
+
error
|
|
10076
|
+
);
|
|
9310
10077
|
}
|
|
9311
10078
|
}
|
|
9312
10079
|
}
|
|
@@ -9432,8 +10199,70 @@ async function listConversationsByUser(store, userId, options) {
|
|
|
9432
10199
|
});
|
|
9433
10200
|
}
|
|
9434
10201
|
async function listConversationsFromIndex(store, options) {
|
|
10202
|
+
if (!options.before) {
|
|
10203
|
+
const fast = await listConversationsFromIndexFast(store, options);
|
|
10204
|
+
if (fast)
|
|
10205
|
+
return fast;
|
|
10206
|
+
}
|
|
9435
10207
|
return listConversationsFromIndexFull(store, options);
|
|
9436
10208
|
}
|
|
10209
|
+
async function listConversationsFromIndexFast(store, options) {
|
|
10210
|
+
var _a, _b;
|
|
10211
|
+
let listCursor = cursorListCursor(options.after);
|
|
10212
|
+
if (options.after && !listCursor) {
|
|
10213
|
+
return null;
|
|
10214
|
+
}
|
|
10215
|
+
const pageItems = [];
|
|
10216
|
+
const seen = /* @__PURE__ */ new Set();
|
|
10217
|
+
let lastCursor;
|
|
10218
|
+
while (pageItems.length < options.limit) {
|
|
10219
|
+
const listed = await store.list({
|
|
10220
|
+
prefix: options.prefix,
|
|
10221
|
+
cursor: listCursor,
|
|
10222
|
+
limit: options.limit - pageItems.length,
|
|
10223
|
+
paginate: false,
|
|
10224
|
+
consistency: "strong"
|
|
10225
|
+
});
|
|
10226
|
+
lastCursor = listed.cursor;
|
|
10227
|
+
if (!listed.keys.length) {
|
|
10228
|
+
break;
|
|
10229
|
+
}
|
|
10230
|
+
const indexItems = [...listed.keys].sort(
|
|
10231
|
+
(left, right) => options.order === "desc" ? left.localeCompare(right) : right.localeCompare(left)
|
|
10232
|
+
).map((key) => {
|
|
10233
|
+
const conversationId = options.conversationIdFromKey(key);
|
|
10234
|
+
if (!conversationId || seen.has(conversationId)) {
|
|
10235
|
+
return null;
|
|
10236
|
+
}
|
|
10237
|
+
seen.add(conversationId);
|
|
10238
|
+
return {
|
|
10239
|
+
key,
|
|
10240
|
+
sortKey: indexSortKey(key, options.prefix),
|
|
10241
|
+
conversationId
|
|
10242
|
+
};
|
|
10243
|
+
}).filter((item) => item !== null);
|
|
10244
|
+
const metas = await Promise.all(
|
|
10245
|
+
indexItems.map((item) => readConversationMeta(store, item.conversationId))
|
|
10246
|
+
);
|
|
10247
|
+
for (let i = 0; i < indexItems.length; i++) {
|
|
10248
|
+
const meta = metas[i];
|
|
10249
|
+
if (meta) {
|
|
10250
|
+
pageItems.push({ indexItem: indexItems[i], meta });
|
|
10251
|
+
}
|
|
10252
|
+
}
|
|
10253
|
+
if (!listed.cursor) {
|
|
10254
|
+
break;
|
|
10255
|
+
}
|
|
10256
|
+
listCursor = listed.cursor;
|
|
10257
|
+
}
|
|
10258
|
+
const firstItem = (_a = pageItems[0]) == null ? void 0 : _a.indexItem;
|
|
10259
|
+
const lastItem = (_b = pageItems[pageItems.length - 1]) == null ? void 0 : _b.indexItem;
|
|
10260
|
+
return {
|
|
10261
|
+
items: pageItems.map((item) => item.meta),
|
|
10262
|
+
nextCursor: lastItem ? encodeConversationCursorFromIndexItem(lastItem, lastCursor) : void 0,
|
|
10263
|
+
previousCursor: firstItem ? encodeConversationCursorFromIndexItem(firstItem) : void 0
|
|
10264
|
+
};
|
|
10265
|
+
}
|
|
9437
10266
|
async function listConversationsFromIndexFull(store, options) {
|
|
9438
10267
|
var _a, _b;
|
|
9439
10268
|
const afterSortKey = options.after ? cursorSortKey(options.after) : void 0;
|
|
@@ -9870,6 +10699,7 @@ function createAgentMemory(store, options = {}) {
|
|
|
9870
10699
|
const maxMessagesPerConversation = options.maxMessagesPerConversation ?? DEFAULT_MAX_MESSAGES_PER_CONVERSATION;
|
|
9871
10700
|
const langgraphCheckpointer = createLangGraphCheckpointer(store);
|
|
9872
10701
|
const langgraphStore = createLangGraphStore(store);
|
|
10702
|
+
const state = createAgentStateStore(store, options.conversationId);
|
|
9873
10703
|
let claudeStoreCache = null;
|
|
9874
10704
|
let lastMessageCreatedAt = 0;
|
|
9875
10705
|
const appendMessagesInternal = async (inputs) => {
|
|
@@ -10155,8 +10985,13 @@ function createAgentMemory(store, options = {}) {
|
|
|
10155
10985
|
listMessageKeys(store, input.conversationId)
|
|
10156
10986
|
]);
|
|
10157
10987
|
if (!meta) {
|
|
10988
|
+
if (options.conversationId === input.conversationId) {
|
|
10989
|
+
await deleteAgentState(store, input.conversationId);
|
|
10990
|
+
}
|
|
10991
|
+
await deleteClaudeSessionForConversation(store, input.conversationId);
|
|
10992
|
+
await langgraphCheckpointer.deleteThread(input.conversationId);
|
|
10158
10993
|
throw new MemoryNotFoundError(
|
|
10159
|
-
"Conversation not found by
|
|
10994
|
+
"Conversation not found by deleteConversation."
|
|
10160
10995
|
);
|
|
10161
10996
|
}
|
|
10162
10997
|
const deleteOps = [];
|
|
@@ -10173,6 +11008,11 @@ function createAgentMemory(store, options = {}) {
|
|
|
10173
11008
|
deleteOps.push(store.delete(metaKey(input.conversationId)));
|
|
10174
11009
|
deleteOps.push(store.delete(conversationIndexKey(meta)));
|
|
10175
11010
|
await Promise.all(deleteOps);
|
|
11011
|
+
if (options.conversationId === input.conversationId) {
|
|
11012
|
+
await deleteAgentState(store, input.conversationId);
|
|
11013
|
+
}
|
|
11014
|
+
await deleteClaudeSessionForConversation(store, input.conversationId);
|
|
11015
|
+
await langgraphCheckpointer.deleteThread(input.conversationId);
|
|
10176
11016
|
});
|
|
10177
11017
|
},
|
|
10178
11018
|
async updateConversation(input) {
|
|
@@ -10208,14 +11048,49 @@ function createAgentMemory(store, options = {}) {
|
|
|
10208
11048
|
}));
|
|
10209
11049
|
},
|
|
10210
11050
|
openaiSession(sessionId, sessionOptions = {}) {
|
|
11051
|
+
const boundSessionId = sessionId ?? options.conversationId;
|
|
11052
|
+
if (!boundSessionId) {
|
|
11053
|
+
throw new MemoryValidationError(
|
|
11054
|
+
"openaiSession requires a sessionId or bound conversationId."
|
|
11055
|
+
);
|
|
11056
|
+
}
|
|
10211
11057
|
const maxItems = sessionOptions.maxItems ?? MAX_LIMIT;
|
|
10212
11058
|
return createOpenAISession(
|
|
10213
11059
|
memory,
|
|
10214
|
-
|
|
11060
|
+
boundSessionId,
|
|
10215
11061
|
maxItems,
|
|
10216
11062
|
appendMessagesInternal
|
|
10217
11063
|
);
|
|
10218
11064
|
},
|
|
11065
|
+
async claudeSessionBinding(conversationId) {
|
|
11066
|
+
const resolvedConversationId = conversationId ?? options.conversationId;
|
|
11067
|
+
if (!resolvedConversationId) {
|
|
11068
|
+
throw new MemoryValidationError(
|
|
11069
|
+
"claudeSessionBinding requires a conversationId or bound conversationId."
|
|
11070
|
+
);
|
|
11071
|
+
}
|
|
11072
|
+
validateConversationId(resolvedConversationId);
|
|
11073
|
+
return wrapStorage(async () => {
|
|
11074
|
+
const mappingKey = claudeSessionMappingKey(resolvedConversationId);
|
|
11075
|
+
const existing = await store.get(
|
|
11076
|
+
mappingKey,
|
|
11077
|
+
{ consistency: "strong" }
|
|
11078
|
+
);
|
|
11079
|
+
if (typeof existing === "string" && existing) {
|
|
11080
|
+
return existing;
|
|
11081
|
+
}
|
|
11082
|
+
if (isPlainObject(existing) && (typeof existing.sessionId === "string" || typeof existing.session_id === "string") && (existing.sessionId || existing.session_id)) {
|
|
11083
|
+
return String(existing.sessionId || existing.session_id);
|
|
11084
|
+
}
|
|
11085
|
+
const sessionId = normalizeClaudeUuid(resolvedConversationId) ?? randomUUID();
|
|
11086
|
+
const binding = {
|
|
11087
|
+
conversationId: resolvedConversationId,
|
|
11088
|
+
sessionId
|
|
11089
|
+
};
|
|
11090
|
+
await store.set(mappingKey, binding);
|
|
11091
|
+
return sessionId;
|
|
11092
|
+
});
|
|
11093
|
+
},
|
|
10219
11094
|
claudeSessionStore() {
|
|
10220
11095
|
if (!claudeStoreCache) {
|
|
10221
11096
|
claudeStoreCache = createClaudeSessionStore(store);
|
|
@@ -10223,7 +11098,8 @@ function createAgentMemory(store, options = {}) {
|
|
|
10223
11098
|
return claudeStoreCache;
|
|
10224
11099
|
},
|
|
10225
11100
|
langgraphCheckpointer,
|
|
10226
|
-
langgraphStore
|
|
11101
|
+
langgraphStore,
|
|
11102
|
+
state
|
|
10227
11103
|
};
|
|
10228
11104
|
return memory;
|
|
10229
11105
|
}
|
|
@@ -10904,6 +11780,7 @@ function createAgentRuntime(options) {
|
|
|
10904
11780
|
env,
|
|
10905
11781
|
store: createAgentMemory(createLazyStore(resolveMemoryStore), {
|
|
10906
11782
|
runId: run_id,
|
|
11783
|
+
conversationId: conversation_id,
|
|
10907
11784
|
maxMessagesPerConversation: (_a = defaults == null ? void 0 : defaults.memoryQuota) == null ? void 0 : _a.maxMessagesPerConversation
|
|
10908
11785
|
}),
|
|
10909
11786
|
agents: {
|
|
@@ -23438,6 +24315,9 @@ var LANGGRAPH_STORE_PREFIX = "langgraph_store";
|
|
|
23438
24315
|
var LANGGRAPH_STORE_KEY_SEPARATOR = "__key__";
|
|
23439
24316
|
var LANGGRAPH_SERDE_VERSION = 1;
|
|
23440
24317
|
var CLAUDE_SESSION_PREFIX = "claude_sessions";
|
|
24318
|
+
var CLAUDE_SESSION_MAPPING_PREFIX = "claude_session_mapping";
|
|
24319
|
+
var STATE_PREFIX = "state";
|
|
24320
|
+
var MAX_STATE_KEY_LENGTH = 256;
|
|
23441
24321
|
var SESSION_METADATA_MARKER = { agent_sdk_session: true };
|
|
23442
24322
|
var VALID_ROLES = /* @__PURE__ */ new Set([
|
|
23443
24323
|
"user",
|
|
@@ -23484,6 +24364,15 @@ var MemoryStorageError = class extends Error {
|
|
|
23484
24364
|
this.cause = cause;
|
|
23485
24365
|
}
|
|
23486
24366
|
};
|
|
24367
|
+
var MemoryCorruptError = class extends Error {
|
|
24368
|
+
code = "MemoryCorruptError";
|
|
24369
|
+
cause;
|
|
24370
|
+
constructor(message, cause) {
|
|
24371
|
+
super(message);
|
|
24372
|
+
this.name = "MemoryCorruptError";
|
|
24373
|
+
this.cause = cause;
|
|
24374
|
+
}
|
|
24375
|
+
};
|
|
23487
24376
|
var dynamicImport = new Function(
|
|
23488
24377
|
"specifier",
|
|
23489
24378
|
"return import(specifier);"
|
|
@@ -23491,7 +24380,7 @@ var dynamicImport = new Function(
|
|
|
23491
24380
|
var langchainLoadPromise;
|
|
23492
24381
|
var langchainMessagesPromise;
|
|
23493
24382
|
function isMemoryError(error51) {
|
|
23494
|
-
return error51 instanceof MemoryValidationError || error51 instanceof MemoryNotFoundError || error51 instanceof MemoryQuotaExceededError || error51 instanceof MemoryStorageError;
|
|
24383
|
+
return error51 instanceof MemoryValidationError || error51 instanceof MemoryNotFoundError || error51 instanceof MemoryQuotaExceededError || error51 instanceof MemoryStorageError || error51 instanceof MemoryCorruptError;
|
|
23495
24384
|
}
|
|
23496
24385
|
async function wrapStorage(operation) {
|
|
23497
24386
|
try {
|
|
@@ -23659,10 +24548,17 @@ async function reviveLangGraphJsonValue(value) {
|
|
|
23659
24548
|
return revived;
|
|
23660
24549
|
}
|
|
23661
24550
|
async function deserializeLangGraphJson(value) {
|
|
23662
|
-
|
|
23663
|
-
|
|
24551
|
+
try {
|
|
24552
|
+
if (isLangGraphSerializedJson(value)) {
|
|
24553
|
+
return reviveLangGraphJsonValue(JSON.parse(value.data));
|
|
24554
|
+
}
|
|
24555
|
+
return reviveLangGraphJsonValue(value);
|
|
24556
|
+
} catch (error51) {
|
|
24557
|
+
throw new MemoryCorruptError(
|
|
24558
|
+
"LangGraph persisted state is corrupt or incompatible.",
|
|
24559
|
+
error51
|
|
24560
|
+
);
|
|
23664
24561
|
}
|
|
23665
|
-
return reviveLangGraphJsonValue(value);
|
|
23666
24562
|
}
|
|
23667
24563
|
function normalizeStoreLimit(value, fallback) {
|
|
23668
24564
|
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
@@ -23774,6 +24670,115 @@ function validateMessageId(messageId) {
|
|
|
23774
24670
|
throw new MemoryValidationError("messageId is required.");
|
|
23775
24671
|
}
|
|
23776
24672
|
}
|
|
24673
|
+
function validateStateKey(key) {
|
|
24674
|
+
if (typeof key !== "string" || key.length === 0) {
|
|
24675
|
+
throw new MemoryValidationError("state key is required.");
|
|
24676
|
+
}
|
|
24677
|
+
if (key.length > MAX_STATE_KEY_LENGTH) {
|
|
24678
|
+
throw new MemoryValidationError(
|
|
24679
|
+
\`state key must be at most \${MAX_STATE_KEY_LENGTH} characters.\`
|
|
24680
|
+
);
|
|
24681
|
+
}
|
|
24682
|
+
}
|
|
24683
|
+
function assertStateSerializable(value, path2 = "state value", seen = /* @__PURE__ */ new Set()) {
|
|
24684
|
+
if (value === null || typeof value === "string" || typeof value === "boolean") {
|
|
24685
|
+
return;
|
|
24686
|
+
}
|
|
24687
|
+
if (typeof value === "number") {
|
|
24688
|
+
if (Number.isFinite(value))
|
|
24689
|
+
return;
|
|
24690
|
+
throw new MemoryValidationError(\`\${path2} must contain only JSON values.\`);
|
|
24691
|
+
}
|
|
24692
|
+
if (value === void 0 || typeof value === "function" || typeof value === "symbol" || typeof value === "bigint") {
|
|
24693
|
+
throw new MemoryValidationError(\`\${path2} must be JSON serializable.\`);
|
|
24694
|
+
}
|
|
24695
|
+
if (typeof value !== "object") {
|
|
24696
|
+
throw new MemoryValidationError(\`\${path2} must be JSON serializable.\`);
|
|
24697
|
+
}
|
|
24698
|
+
if (seen.has(value)) {
|
|
24699
|
+
throw new MemoryValidationError(\`\${path2} must not contain circular references.\`);
|
|
24700
|
+
}
|
|
24701
|
+
seen.add(value);
|
|
24702
|
+
if (Array.isArray(value)) {
|
|
24703
|
+
value.forEach((item, index) => assertStateSerializable(item, \`\${path2}[\${index}]\`, seen));
|
|
24704
|
+
} else if (isPlainObject(value)) {
|
|
24705
|
+
for (const [key, item] of Object.entries(value)) {
|
|
24706
|
+
assertStateSerializable(item, \`\${path2}.\${key}\`, seen);
|
|
24707
|
+
}
|
|
24708
|
+
} else {
|
|
24709
|
+
throw new MemoryValidationError(\`\${path2} must contain only JSON values.\`);
|
|
24710
|
+
}
|
|
24711
|
+
seen.delete(value);
|
|
24712
|
+
}
|
|
24713
|
+
function stateConversationPrefix(conversationId) {
|
|
24714
|
+
return \`\${STATE_PREFIX}/\${encodeKeySegment(conversationId)}/\`;
|
|
24715
|
+
}
|
|
24716
|
+
function createAgentStateStore(store, boundConversationId) {
|
|
24717
|
+
const requireConversation = () => {
|
|
24718
|
+
if (!boundConversationId) {
|
|
24719
|
+
throw new MemoryValidationError(
|
|
24720
|
+
"State operations require a bound conversationId."
|
|
24721
|
+
);
|
|
24722
|
+
}
|
|
24723
|
+
validateConversationId(boundConversationId);
|
|
24724
|
+
return boundConversationId;
|
|
24725
|
+
};
|
|
24726
|
+
return {
|
|
24727
|
+
async get(key) {
|
|
24728
|
+
validateStateKey(key);
|
|
24729
|
+
const conversationId = requireConversation();
|
|
24730
|
+
return wrapStorage(async () => {
|
|
24731
|
+
const raw = await store.get(
|
|
24732
|
+
\`\${stateConversationPrefix(conversationId)}\${encodeKeySegment(key)}\`,
|
|
24733
|
+
{ consistency: "strong" }
|
|
24734
|
+
);
|
|
24735
|
+
if (raw === null)
|
|
24736
|
+
return null;
|
|
24737
|
+
if (typeof raw !== "string") {
|
|
24738
|
+
throw new MemoryStorageError("Stored state value is not valid JSON text.");
|
|
24739
|
+
}
|
|
24740
|
+
try {
|
|
24741
|
+
return JSON.parse(raw);
|
|
24742
|
+
} catch (error51) {
|
|
24743
|
+
throw new MemoryStorageError("Stored state value is invalid JSON.", error51);
|
|
24744
|
+
}
|
|
24745
|
+
});
|
|
24746
|
+
},
|
|
24747
|
+
async set(key, value) {
|
|
24748
|
+
validateStateKey(key);
|
|
24749
|
+
const conversationId = requireConversation();
|
|
24750
|
+
assertStateSerializable(value);
|
|
24751
|
+
let serialized;
|
|
24752
|
+
try {
|
|
24753
|
+
serialized = JSON.stringify(value);
|
|
24754
|
+
} catch (error51) {
|
|
24755
|
+
throw new MemoryValidationError(\`state value must be JSON serializable: \${String(error51)}\`);
|
|
24756
|
+
}
|
|
24757
|
+
await wrapStorage(
|
|
24758
|
+
() => store.set(
|
|
24759
|
+
\`\${stateConversationPrefix(conversationId)}\${encodeKeySegment(key)}\`,
|
|
24760
|
+
serialized
|
|
24761
|
+
)
|
|
24762
|
+
);
|
|
24763
|
+
},
|
|
24764
|
+
async delete(key) {
|
|
24765
|
+
validateStateKey(key);
|
|
24766
|
+
const conversationId = requireConversation();
|
|
24767
|
+
await wrapStorage(
|
|
24768
|
+
() => store.delete(
|
|
24769
|
+
\`\${stateConversationPrefix(conversationId)}\${encodeKeySegment(key)}\`
|
|
24770
|
+
)
|
|
24771
|
+
);
|
|
24772
|
+
}
|
|
24773
|
+
};
|
|
24774
|
+
}
|
|
24775
|
+
async function deleteAgentState(store, conversationId) {
|
|
24776
|
+
const listed = await store.list({
|
|
24777
|
+
prefix: stateConversationPrefix(conversationId),
|
|
24778
|
+
consistency: "strong"
|
|
24779
|
+
});
|
|
24780
|
+
await Promise.all(listed.keys.map((key) => store.delete(key)));
|
|
24781
|
+
}
|
|
23777
24782
|
function validateUserId(userId) {
|
|
23778
24783
|
if (userId === void 0) {
|
|
23779
24784
|
return;
|
|
@@ -23906,6 +24911,9 @@ function cursorSortKey(cursor) {
|
|
|
23906
24911
|
const payload = decodeConversationCursor(cursor);
|
|
23907
24912
|
return \`\${reverseTimestamp(payload.lastMessageAt)}_\${encodeKeySegment(payload.conversationId)}\`;
|
|
23908
24913
|
}
|
|
24914
|
+
function cursorListCursor(cursor) {
|
|
24915
|
+
return cursor ? decodeConversationCursor(cursor).listCursor : void 0;
|
|
24916
|
+
}
|
|
23909
24917
|
function indexSortKey(key, prefix) {
|
|
23910
24918
|
return key.slice(prefix.length);
|
|
23911
24919
|
}
|
|
@@ -24073,6 +25081,51 @@ function claudeSessionBase(projectKey, sessionId) {
|
|
|
24073
25081
|
function claudeProjectPrefix(projectKey) {
|
|
24074
25082
|
return \`\${CLAUDE_SESSION_PREFIX}/\${encodeKeySegment(projectKey)}/\`;
|
|
24075
25083
|
}
|
|
25084
|
+
function claudeSessionMappingKey(conversationId) {
|
|
25085
|
+
return \`\${CLAUDE_SESSION_MAPPING_PREFIX}/\${encodeKeySegment(conversationId)}\`;
|
|
25086
|
+
}
|
|
25087
|
+
function normalizeClaudeUuid(value) {
|
|
25088
|
+
const trimmed = value.trim().toLowerCase();
|
|
25089
|
+
return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/.test(trimmed) ? trimmed : null;
|
|
25090
|
+
}
|
|
25091
|
+
function claudeSessionIdFromKey(key) {
|
|
25092
|
+
const prefix = \`\${CLAUDE_SESSION_PREFIX}/\`;
|
|
25093
|
+
if (!key.startsWith(prefix)) {
|
|
25094
|
+
return null;
|
|
25095
|
+
}
|
|
25096
|
+
const segments = key.slice(prefix.length).split("/");
|
|
25097
|
+
return segments.length >= 3 && segments[1] ? decodeKeySegment(segments[1]) : null;
|
|
25098
|
+
}
|
|
25099
|
+
async function deleteClaudeSessionForConversation(store, conversationId) {
|
|
25100
|
+
const mappingKey = claudeSessionMappingKey(conversationId);
|
|
25101
|
+
const mapping = await store.get(mappingKey, {
|
|
25102
|
+
consistency: "strong"
|
|
25103
|
+
});
|
|
25104
|
+
let sessionId = null;
|
|
25105
|
+
if (typeof mapping === "string") {
|
|
25106
|
+
sessionId = mapping;
|
|
25107
|
+
} else if (isPlainObject(mapping) && typeof mapping.sessionId === "string") {
|
|
25108
|
+
sessionId = mapping.sessionId;
|
|
25109
|
+
} else if (isPlainObject(mapping) && typeof mapping.session_id === "string") {
|
|
25110
|
+
sessionId = mapping.session_id;
|
|
25111
|
+
}
|
|
25112
|
+
if (!sessionId) {
|
|
25113
|
+
sessionId = normalizeClaudeUuid(conversationId);
|
|
25114
|
+
}
|
|
25115
|
+
await store.delete(mappingKey);
|
|
25116
|
+
if (!sessionId) {
|
|
25117
|
+
return;
|
|
25118
|
+
}
|
|
25119
|
+
const listed = await store.list({
|
|
25120
|
+
prefix: \`\${CLAUDE_SESSION_PREFIX}/\`,
|
|
25121
|
+
consistency: "strong"
|
|
25122
|
+
});
|
|
25123
|
+
for (const key of listed.keys) {
|
|
25124
|
+
if (claudeSessionIdFromKey(key) === sessionId) {
|
|
25125
|
+
await store.delete(key);
|
|
25126
|
+
}
|
|
25127
|
+
}
|
|
25128
|
+
}
|
|
24076
25129
|
function claudePartsPrefix(key) {
|
|
24077
25130
|
let base = claudeSessionBase(key.projectKey, key.sessionId).slice(0, -1);
|
|
24078
25131
|
if (key.subpath) {
|
|
@@ -24110,7 +25163,9 @@ function createClaudeSessionStore(store) {
|
|
|
24110
25163
|
consistency: "strong"
|
|
24111
25164
|
});
|
|
24112
25165
|
if (typeof raw !== "string") {
|
|
24113
|
-
|
|
25166
|
+
throw new MemoryCorruptError(
|
|
25167
|
+
\`Claude session part '\${partKey}' is not valid JSONL text.\`
|
|
25168
|
+
);
|
|
24114
25169
|
}
|
|
24115
25170
|
for (const line of raw.split("\\n")) {
|
|
24116
25171
|
const trimmed = line.trim();
|
|
@@ -24119,7 +25174,11 @@ function createClaudeSessionStore(store) {
|
|
|
24119
25174
|
}
|
|
24120
25175
|
try {
|
|
24121
25176
|
entries.push(JSON.parse(trimmed));
|
|
24122
|
-
} catch {
|
|
25177
|
+
} catch (error51) {
|
|
25178
|
+
throw new MemoryCorruptError(
|
|
25179
|
+
\`Claude session part '\${partKey}' contains malformed JSONL.\`,
|
|
25180
|
+
error51
|
|
25181
|
+
);
|
|
24123
25182
|
}
|
|
24124
25183
|
}
|
|
24125
25184
|
}
|
|
@@ -24245,8 +25304,70 @@ async function listConversationsByUser(store, userId, options) {
|
|
|
24245
25304
|
});
|
|
24246
25305
|
}
|
|
24247
25306
|
async function listConversationsFromIndex(store, options) {
|
|
25307
|
+
if (!options.before) {
|
|
25308
|
+
const fast = await listConversationsFromIndexFast(store, options);
|
|
25309
|
+
if (fast)
|
|
25310
|
+
return fast;
|
|
25311
|
+
}
|
|
24248
25312
|
return listConversationsFromIndexFull(store, options);
|
|
24249
25313
|
}
|
|
25314
|
+
async function listConversationsFromIndexFast(store, options) {
|
|
25315
|
+
var _a3, _b;
|
|
25316
|
+
let listCursor = cursorListCursor(options.after);
|
|
25317
|
+
if (options.after && !listCursor) {
|
|
25318
|
+
return null;
|
|
25319
|
+
}
|
|
25320
|
+
const pageItems = [];
|
|
25321
|
+
const seen = /* @__PURE__ */ new Set();
|
|
25322
|
+
let lastCursor;
|
|
25323
|
+
while (pageItems.length < options.limit) {
|
|
25324
|
+
const listed = await store.list({
|
|
25325
|
+
prefix: options.prefix,
|
|
25326
|
+
cursor: listCursor,
|
|
25327
|
+
limit: options.limit - pageItems.length,
|
|
25328
|
+
paginate: false,
|
|
25329
|
+
consistency: "strong"
|
|
25330
|
+
});
|
|
25331
|
+
lastCursor = listed.cursor;
|
|
25332
|
+
if (!listed.keys.length) {
|
|
25333
|
+
break;
|
|
25334
|
+
}
|
|
25335
|
+
const indexItems = [...listed.keys].sort(
|
|
25336
|
+
(left, right) => options.order === "desc" ? left.localeCompare(right) : right.localeCompare(left)
|
|
25337
|
+
).map((key) => {
|
|
25338
|
+
const conversationId = options.conversationIdFromKey(key);
|
|
25339
|
+
if (!conversationId || seen.has(conversationId)) {
|
|
25340
|
+
return null;
|
|
25341
|
+
}
|
|
25342
|
+
seen.add(conversationId);
|
|
25343
|
+
return {
|
|
25344
|
+
key,
|
|
25345
|
+
sortKey: indexSortKey(key, options.prefix),
|
|
25346
|
+
conversationId
|
|
25347
|
+
};
|
|
25348
|
+
}).filter((item) => item !== null);
|
|
25349
|
+
const metas = await Promise.all(
|
|
25350
|
+
indexItems.map((item) => readConversationMeta(store, item.conversationId))
|
|
25351
|
+
);
|
|
25352
|
+
for (let i = 0; i < indexItems.length; i++) {
|
|
25353
|
+
const meta3 = metas[i];
|
|
25354
|
+
if (meta3) {
|
|
25355
|
+
pageItems.push({ indexItem: indexItems[i], meta: meta3 });
|
|
25356
|
+
}
|
|
25357
|
+
}
|
|
25358
|
+
if (!listed.cursor) {
|
|
25359
|
+
break;
|
|
25360
|
+
}
|
|
25361
|
+
listCursor = listed.cursor;
|
|
25362
|
+
}
|
|
25363
|
+
const firstItem = (_a3 = pageItems[0]) == null ? void 0 : _a3.indexItem;
|
|
25364
|
+
const lastItem = (_b = pageItems[pageItems.length - 1]) == null ? void 0 : _b.indexItem;
|
|
25365
|
+
return {
|
|
25366
|
+
items: pageItems.map((item) => item.meta),
|
|
25367
|
+
nextCursor: lastItem ? encodeConversationCursorFromIndexItem(lastItem, lastCursor) : void 0,
|
|
25368
|
+
previousCursor: firstItem ? encodeConversationCursorFromIndexItem(firstItem) : void 0
|
|
25369
|
+
};
|
|
25370
|
+
}
|
|
24250
25371
|
async function listConversationsFromIndexFull(store, options) {
|
|
24251
25372
|
var _a3, _b;
|
|
24252
25373
|
const afterSortKey = options.after ? cursorSortKey(options.after) : void 0;
|
|
@@ -24683,6 +25804,7 @@ function createAgentMemory(store, options = {}) {
|
|
|
24683
25804
|
const maxMessagesPerConversation = options.maxMessagesPerConversation ?? DEFAULT_MAX_MESSAGES_PER_CONVERSATION;
|
|
24684
25805
|
const langgraphCheckpointer = createLangGraphCheckpointer(store);
|
|
24685
25806
|
const langgraphStore = createLangGraphStore(store);
|
|
25807
|
+
const state = createAgentStateStore(store, options.conversationId);
|
|
24686
25808
|
let claudeStoreCache = null;
|
|
24687
25809
|
let lastMessageCreatedAt = 0;
|
|
24688
25810
|
const appendMessagesInternal = async (inputs) => {
|
|
@@ -24968,8 +26090,13 @@ function createAgentMemory(store, options = {}) {
|
|
|
24968
26090
|
listMessageKeys(store, input.conversationId)
|
|
24969
26091
|
]);
|
|
24970
26092
|
if (!meta3) {
|
|
26093
|
+
if (options.conversationId === input.conversationId) {
|
|
26094
|
+
await deleteAgentState(store, input.conversationId);
|
|
26095
|
+
}
|
|
26096
|
+
await deleteClaudeSessionForConversation(store, input.conversationId);
|
|
26097
|
+
await langgraphCheckpointer.deleteThread(input.conversationId);
|
|
24971
26098
|
throw new MemoryNotFoundError(
|
|
24972
|
-
"Conversation not found by
|
|
26099
|
+
"Conversation not found by deleteConversation."
|
|
24973
26100
|
);
|
|
24974
26101
|
}
|
|
24975
26102
|
const deleteOps = [];
|
|
@@ -24986,6 +26113,11 @@ function createAgentMemory(store, options = {}) {
|
|
|
24986
26113
|
deleteOps.push(store.delete(metaKey(input.conversationId)));
|
|
24987
26114
|
deleteOps.push(store.delete(conversationIndexKey(meta3)));
|
|
24988
26115
|
await Promise.all(deleteOps);
|
|
26116
|
+
if (options.conversationId === input.conversationId) {
|
|
26117
|
+
await deleteAgentState(store, input.conversationId);
|
|
26118
|
+
}
|
|
26119
|
+
await deleteClaudeSessionForConversation(store, input.conversationId);
|
|
26120
|
+
await langgraphCheckpointer.deleteThread(input.conversationId);
|
|
24989
26121
|
});
|
|
24990
26122
|
},
|
|
24991
26123
|
async updateConversation(input) {
|
|
@@ -25021,14 +26153,49 @@ function createAgentMemory(store, options = {}) {
|
|
|
25021
26153
|
}));
|
|
25022
26154
|
},
|
|
25023
26155
|
openaiSession(sessionId, sessionOptions = {}) {
|
|
26156
|
+
const boundSessionId = sessionId ?? options.conversationId;
|
|
26157
|
+
if (!boundSessionId) {
|
|
26158
|
+
throw new MemoryValidationError(
|
|
26159
|
+
"openaiSession requires a sessionId or bound conversationId."
|
|
26160
|
+
);
|
|
26161
|
+
}
|
|
25024
26162
|
const maxItems = sessionOptions.maxItems ?? MAX_LIMIT;
|
|
25025
26163
|
return createOpenAISession(
|
|
25026
26164
|
memory,
|
|
25027
|
-
|
|
26165
|
+
boundSessionId,
|
|
25028
26166
|
maxItems,
|
|
25029
26167
|
appendMessagesInternal
|
|
25030
26168
|
);
|
|
25031
26169
|
},
|
|
26170
|
+
async claudeSessionBinding(conversationId) {
|
|
26171
|
+
const resolvedConversationId = conversationId ?? options.conversationId;
|
|
26172
|
+
if (!resolvedConversationId) {
|
|
26173
|
+
throw new MemoryValidationError(
|
|
26174
|
+
"claudeSessionBinding requires a conversationId or bound conversationId."
|
|
26175
|
+
);
|
|
26176
|
+
}
|
|
26177
|
+
validateConversationId(resolvedConversationId);
|
|
26178
|
+
return wrapStorage(async () => {
|
|
26179
|
+
const mappingKey = claudeSessionMappingKey(resolvedConversationId);
|
|
26180
|
+
const existing = await store.get(
|
|
26181
|
+
mappingKey,
|
|
26182
|
+
{ consistency: "strong" }
|
|
26183
|
+
);
|
|
26184
|
+
if (typeof existing === "string" && existing) {
|
|
26185
|
+
return existing;
|
|
26186
|
+
}
|
|
26187
|
+
if (isPlainObject(existing) && (typeof existing.sessionId === "string" || typeof existing.session_id === "string") && (existing.sessionId || existing.session_id)) {
|
|
26188
|
+
return String(existing.sessionId || existing.session_id);
|
|
26189
|
+
}
|
|
26190
|
+
const sessionId = normalizeClaudeUuid(resolvedConversationId) ?? randomUUID();
|
|
26191
|
+
const binding = {
|
|
26192
|
+
conversationId: resolvedConversationId,
|
|
26193
|
+
sessionId
|
|
26194
|
+
};
|
|
26195
|
+
await store.set(mappingKey, binding);
|
|
26196
|
+
return sessionId;
|
|
26197
|
+
});
|
|
26198
|
+
},
|
|
25032
26199
|
claudeSessionStore() {
|
|
25033
26200
|
if (!claudeStoreCache) {
|
|
25034
26201
|
claudeStoreCache = createClaudeSessionStore(store);
|
|
@@ -25036,7 +26203,8 @@ function createAgentMemory(store, options = {}) {
|
|
|
25036
26203
|
return claudeStoreCache;
|
|
25037
26204
|
},
|
|
25038
26205
|
langgraphCheckpointer,
|
|
25039
|
-
langgraphStore
|
|
26206
|
+
langgraphStore,
|
|
26207
|
+
state
|
|
25040
26208
|
};
|
|
25041
26209
|
return memory;
|
|
25042
26210
|
}
|
|
@@ -25717,6 +26885,7 @@ function createAgentRuntime(options) {
|
|
|
25717
26885
|
env,
|
|
25718
26886
|
store: createAgentMemory(createLazyStore(resolveMemoryStore), {
|
|
25719
26887
|
runId: run_id,
|
|
26888
|
+
conversationId: conversation_id,
|
|
25720
26889
|
maxMessagesPerConversation: (_a3 = defaults2 == null ? void 0 : defaults2.memoryQuota) == null ? void 0 : _a3.maxMessagesPerConversation
|
|
25721
26890
|
}),
|
|
25722
26891
|
agents: {
|
|
@@ -47609,24 +48778,24 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
47609
48778
|
var require_dist = __commonJS({
|
|
47610
48779
|
"node_modules/@edgeone/pages-blob/dist/index.js"(exports, module) {
|
|
47611
48780
|
"use strict";
|
|
47612
|
-
var
|
|
48781
|
+
var U = Object.defineProperty;
|
|
47613
48782
|
var le = Object.getOwnPropertyDescriptor;
|
|
47614
48783
|
var ue = Object.getOwnPropertyNames;
|
|
47615
48784
|
var ge = Object.prototype.hasOwnProperty;
|
|
47616
48785
|
var fe = (t, e) => {
|
|
47617
48786
|
for (var r in e)
|
|
47618
|
-
|
|
48787
|
+
U(t, r, { get: e[r], enumerable: true });
|
|
47619
48788
|
};
|
|
47620
48789
|
var he = (t, e, r, n) => {
|
|
47621
48790
|
if (e && typeof e == "object" || typeof e == "function")
|
|
47622
48791
|
for (let s of ue(e))
|
|
47623
|
-
!ge.call(t, s) && s !== r &&
|
|
48792
|
+
!ge.call(t, s) && s !== r && U(t, s, { get: () => e[s], enumerable: !(n = le(e, s)) || n.enumerable });
|
|
47624
48793
|
return t;
|
|
47625
48794
|
};
|
|
47626
|
-
var me = (t) => he(
|
|
47627
|
-
var
|
|
47628
|
-
fe(
|
|
47629
|
-
module.exports = me(
|
|
48795
|
+
var me = (t) => he(U({}, "__esModule", { value: true }), t);
|
|
48796
|
+
var Oe = {};
|
|
48797
|
+
fe(Oe, { InvalidKeyError: () => w, InvalidStoreNameError: () => y, MissingProjectIdError: () => T, PagesBlobError: () => h, PreconditionFailedError: () => x, QuotaExceededError: () => O, RateLimitedError: () => j, Store: () => E, getStore: () => Me, listStores: () => De });
|
|
48798
|
+
module.exports = me(Oe);
|
|
47630
48799
|
var h = class extends Error {
|
|
47631
48800
|
code;
|
|
47632
48801
|
constructor(e, r) {
|
|
@@ -47648,12 +48817,12 @@ var require_dist = __commonJS({
|
|
|
47648
48817
|
super("MISSING_ENVIRONMENT", \`Environment not configured for Pages Blob. Missing: \${e.join(", ")}. Supply these properties when creating a store, or ensure the function is running in a Pages environment.\`);
|
|
47649
48818
|
}
|
|
47650
48819
|
};
|
|
47651
|
-
var
|
|
48820
|
+
var O = class extends h {
|
|
47652
48821
|
constructor() {
|
|
47653
48822
|
super("QUOTA_EXCEEDED", "storage quota exceeded");
|
|
47654
48823
|
}
|
|
47655
48824
|
};
|
|
47656
|
-
var
|
|
48825
|
+
var j = class extends h {
|
|
47657
48826
|
constructor() {
|
|
47658
48827
|
super("RATE_LIMITED", "request rate limited, please retry later");
|
|
47659
48828
|
}
|
|
@@ -47686,7 +48855,7 @@ var require_dist = __commonJS({
|
|
|
47686
48855
|
if (new TextEncoder().encode(t).length > 600)
|
|
47687
48856
|
throw new w("Blob key must be a sequence of Unicode characters whose UTF-8 encoding is at most 600 bytes long.");
|
|
47688
48857
|
}
|
|
47689
|
-
function
|
|
48858
|
+
function z(t) {
|
|
47690
48859
|
if (t === "")
|
|
47691
48860
|
throw new y("Store name must not be empty.");
|
|
47692
48861
|
if (t.includes("/") || t.includes(":"))
|
|
@@ -47774,45 +48943,48 @@ var require_dist = __commonJS({
|
|
|
47774
48943
|
}
|
|
47775
48944
|
};
|
|
47776
48945
|
var ye = new TextEncoder();
|
|
47777
|
-
function
|
|
48946
|
+
function _(t) {
|
|
47778
48947
|
let e = ye.encode(t), r = new ArrayBuffer(e.byteLength), n = new Uint8Array(r);
|
|
47779
48948
|
return n.set(e), n;
|
|
47780
48949
|
}
|
|
47781
|
-
function
|
|
48950
|
+
function G(t) {
|
|
47782
48951
|
let e = t instanceof Uint8Array ? t : new Uint8Array(t), r = "";
|
|
47783
48952
|
for (let n = 0; n < e.length; n++)
|
|
47784
48953
|
r += e[n].toString(16).padStart(2, "0");
|
|
47785
48954
|
return r;
|
|
47786
48955
|
}
|
|
47787
|
-
async function
|
|
47788
|
-
let r = await crypto.subtle.importKey("raw",
|
|
47789
|
-
return
|
|
48956
|
+
async function H(t, e) {
|
|
48957
|
+
let r = await crypto.subtle.importKey("raw", _(t), { name: "HMAC", hash: "SHA-1" }, false, ["sign"]), n = await crypto.subtle.sign("HMAC", r, _(e));
|
|
48958
|
+
return G(n);
|
|
47790
48959
|
}
|
|
47791
48960
|
async function pe(t) {
|
|
47792
|
-
let e = await crypto.subtle.digest("SHA-1",
|
|
47793
|
-
return
|
|
48961
|
+
let e = await crypto.subtle.digest("SHA-1", _(t));
|
|
48962
|
+
return G(e);
|
|
47794
48963
|
}
|
|
47795
|
-
function
|
|
48964
|
+
function $(t) {
|
|
47796
48965
|
return encodeURIComponent(t).replace(/[!'()*]/g, (e) => "%" + e.charCodeAt(0).toString(16).toUpperCase());
|
|
47797
48966
|
}
|
|
47798
|
-
function
|
|
48967
|
+
function P(t) {
|
|
47799
48968
|
try {
|
|
47800
48969
|
return decodeURIComponent(t);
|
|
47801
48970
|
} catch {
|
|
47802
48971
|
return t;
|
|
47803
48972
|
}
|
|
47804
48973
|
}
|
|
47805
|
-
function
|
|
47806
|
-
return t.split("/").map((e) =>
|
|
48974
|
+
function we(t) {
|
|
48975
|
+
return t.split("/").map((e) => P(e)).join("/");
|
|
48976
|
+
}
|
|
48977
|
+
function I(t) {
|
|
48978
|
+
return we(P(t));
|
|
47807
48979
|
}
|
|
47808
48980
|
function W(t) {
|
|
47809
|
-
return t.split("/").map((e) =>
|
|
48981
|
+
return t.split("/").map((e) => $(P(e))).join("/");
|
|
47810
48982
|
}
|
|
47811
|
-
var
|
|
47812
|
-
function
|
|
47813
|
-
return t === "host" || t === "x-cos-security-token" ? false : !!(
|
|
48983
|
+
var Ce = /* @__PURE__ */ new Set(["cache-control", "content-disposition", "content-encoding", "content-length", "content-md5", "content-type", "expect", "expires", "if-match", "if-modified-since", "if-none-match", "if-unmodified-since", "origin", "range", "transfer-encoding"]);
|
|
48984
|
+
function xe(t) {
|
|
48985
|
+
return t === "host" || t === "x-cos-security-token" ? false : !!(Ce.has(t) || t.startsWith("x-cos-"));
|
|
47814
48986
|
}
|
|
47815
|
-
function
|
|
48987
|
+
function X(t) {
|
|
47816
48988
|
if (!t)
|
|
47817
48989
|
return [];
|
|
47818
48990
|
let e = [];
|
|
@@ -47820,27 +48992,27 @@ var require_dist = __commonJS({
|
|
|
47820
48992
|
n != null && e.push([r.toLowerCase(), String(n)]);
|
|
47821
48993
|
return e.sort(([r], [n]) => r < n ? -1 : r > n ? 1 : 0), e;
|
|
47822
48994
|
}
|
|
47823
|
-
function X(t) {
|
|
47824
|
-
return t.map(([e, r]) => \`\${O(e)}=\${O(r)}\`).join("&");
|
|
47825
|
-
}
|
|
47826
48995
|
function Y(t) {
|
|
47827
|
-
return t.map(([e]) =>
|
|
48996
|
+
return t.map(([e, r]) => \`\${$(e)}=\${$(r)}\`).join("&");
|
|
48997
|
+
}
|
|
48998
|
+
function F(t) {
|
|
48999
|
+
return t.map(([e]) => $(e)).join(";");
|
|
47828
49000
|
}
|
|
47829
49001
|
async function V(t) {
|
|
47830
|
-
let e = t.method.toLowerCase(), r = t.pathname.startsWith("/") ? t.pathname : \`/\${t.pathname}\`, n = Math.floor(Date.now() / 1e3), s = n + (t.expireSeconds ?? 3600), i = \`\${n};\${s}\`, o =
|
|
49002
|
+
let e = t.method.toLowerCase(), r = t.pathname.startsWith("/") ? t.pathname : \`/\${t.pathname}\`, n = Math.floor(Date.now() / 1e3), s = n + (t.expireSeconds ?? 3600), i = \`\${n};\${s}\`, o = X(t.headers).filter(([N]) => xe(N)), c = F(o), d = Y(o), u = X(t.query), l = F(u), g = Y(u), p = \`\${e}
|
|
47831
49003
|
\${r}
|
|
47832
49004
|
\${g}
|
|
47833
49005
|
\${d}
|
|
47834
49006
|
\`, oe = \`sha1
|
|
47835
49007
|
\${i}
|
|
47836
49008
|
\${await pe(p)}
|
|
47837
|
-
\`, ie = await
|
|
47838
|
-
for (let [
|
|
47839
|
-
|
|
47840
|
-
return { authorization: ce, signedHeaders:
|
|
49009
|
+
\`, ie = await H(t.secretKey, i), ae = await H(ie, oe), ce = ["q-sign-algorithm=sha1", \`q-ak=\${t.secretId}\`, \`q-sign-time=\${i}\`, \`q-key-time=\${i}\`, \`q-header-list=\${c}\`, \`q-url-param-list=\${l}\`, \`q-signature=\${ae}\`].join("&"), q = {};
|
|
49010
|
+
for (let [N, de] of o)
|
|
49011
|
+
q[N] = de;
|
|
49012
|
+
return { authorization: ce, signedHeaders: q };
|
|
47841
49013
|
}
|
|
47842
49014
|
async function J(t) {
|
|
47843
|
-
let e = new URL(t.domain), r =
|
|
49015
|
+
let e = new URL(t.domain), r = P(t.key), n = \`/\${I(t.key)}\`, s = \`/\${W(r)}\`;
|
|
47844
49016
|
e.pathname = s;
|
|
47845
49017
|
let { authorization: i } = await V({ method: t.method, pathname: n, query: t.query, headers: t.headers, secretId: t.credential.secretId, secretKey: t.credential.secretKey, expireSeconds: t.expireSeconds });
|
|
47846
49018
|
if (t.query)
|
|
@@ -47856,7 +49028,7 @@ var require_dist = __commonJS({
|
|
|
47856
49028
|
return t.credential.sessionToken && e.searchParams.set("x-cos-security-token", t.credential.sessionToken), e.toString();
|
|
47857
49029
|
}
|
|
47858
49030
|
async function S(t) {
|
|
47859
|
-
let e = new URL(t.domain), r = t.key ?
|
|
49031
|
+
let e = new URL(t.domain), r = t.key ? P(t.key) : "", n = t.key ? \`/\${I(t.key)}\` : "/", s = r ? \`/\${W(r)}\` : "/";
|
|
47860
49032
|
if (e.pathname = s, t.query)
|
|
47861
49033
|
for (let [l, g] of Object.entries(t.query))
|
|
47862
49034
|
g != null && e.searchParams.set(l, String(g));
|
|
@@ -47876,9 +49048,9 @@ var require_dist = __commonJS({
|
|
|
47876
49048
|
}
|
|
47877
49049
|
throw u;
|
|
47878
49050
|
}
|
|
47879
|
-
var
|
|
47880
|
-
var
|
|
47881
|
-
var
|
|
49051
|
+
var be = "blob.edgeone.site";
|
|
49052
|
+
var Te = "blob-nocache.edgeone.site";
|
|
49053
|
+
var M = class t {
|
|
47882
49054
|
credentialManager;
|
|
47883
49055
|
bucket = "";
|
|
47884
49056
|
region = "";
|
|
@@ -47888,7 +49060,7 @@ var require_dist = __commonJS({
|
|
|
47888
49060
|
initialized = false;
|
|
47889
49061
|
static buildErrorDetail(e, r, n, s, i) {
|
|
47890
49062
|
let a = n ? \`\${r}/\${n}\` : r, o = i ? \` [request-id: \${i}]\` : "";
|
|
47891
|
-
return \`\${e} \${a} - \${
|
|
49063
|
+
return \`\${e} \${a} - \${Ee(s)}\${o}\`;
|
|
47892
49064
|
}
|
|
47893
49065
|
constructor(e) {
|
|
47894
49066
|
this.credentialManager = e;
|
|
@@ -47914,7 +49086,7 @@ var require_dist = __commonJS({
|
|
|
47914
49086
|
let a = this.computeSubdomain(e);
|
|
47915
49087
|
if (!a)
|
|
47916
49088
|
throw new f(0, "unable to derive tenant subdomain from credential; missing appId/zoneId/projectId or resourcePrefix");
|
|
47917
|
-
this.cachedDomain = \`https://\${a}.\${
|
|
49089
|
+
this.cachedDomain = \`https://\${a}.\${be}\`, this.uncachedDomain = \`https://\${a}.\${Te}\`, this.initialized = true;
|
|
47918
49090
|
}
|
|
47919
49091
|
async resolveDomain(e) {
|
|
47920
49092
|
return await this.ensureInitialized(), e === "strong" ? this.uncachedDomain : this.cachedDomain;
|
|
@@ -47938,14 +49110,14 @@ var require_dist = __commonJS({
|
|
|
47938
49110
|
return await l.arrayBuffer().catch(() => {
|
|
47939
49111
|
}), { etag: "", statusCode: 412 };
|
|
47940
49112
|
if (!l.ok) {
|
|
47941
|
-
let p = await
|
|
47942
|
-
throw new f(l.status, t.buildErrorDetail("PUT", i, o, p || \`status \${l.status}\`,
|
|
49113
|
+
let p = await k(l);
|
|
49114
|
+
throw new f(l.status, t.buildErrorDetail("PUT", i, o, p || \`status \${l.status}\`, R(l)));
|
|
47943
49115
|
}
|
|
47944
49116
|
let g = l.headers.get("etag") || "";
|
|
47945
49117
|
return await l.arrayBuffer().catch(() => {
|
|
47946
49118
|
}), { etag: g, statusCode: l.status };
|
|
47947
49119
|
} catch (l) {
|
|
47948
|
-
throw l instanceof f ? l : new f(0, t.buildErrorDetail("PUT", i, o,
|
|
49120
|
+
throw l instanceof f ? l : new f(0, t.buildErrorDetail("PUT", i, o, A(l)));
|
|
47949
49121
|
}
|
|
47950
49122
|
}
|
|
47951
49123
|
async createPresignedPutUrl(e, r, n) {
|
|
@@ -47962,13 +49134,13 @@ var require_dist = __commonJS({
|
|
|
47962
49134
|
return await o.arrayBuffer().catch(() => {
|
|
47963
49135
|
}), null;
|
|
47964
49136
|
if (!o.ok) {
|
|
47965
|
-
let u = await
|
|
47966
|
-
throw new f(o.status, t.buildErrorDetail("GET", s, a, u || \`status \${o.status}\`,
|
|
49137
|
+
let u = await k(o);
|
|
49138
|
+
throw new f(o.status, t.buildErrorDetail("GET", s, a, u || \`status \${o.status}\`, R(o)));
|
|
47967
49139
|
}
|
|
47968
49140
|
let c = new Uint8Array(await o.arrayBuffer()), d = Z(o.headers);
|
|
47969
49141
|
return { body: c, contentType: d["content-type"], headers: d };
|
|
47970
49142
|
} catch (o) {
|
|
47971
|
-
throw o instanceof f ? o : new f(0, t.buildErrorDetail("GET", s, a,
|
|
49143
|
+
throw o instanceof f ? o : new f(0, t.buildErrorDetail("GET", s, a, A(o)));
|
|
47972
49144
|
}
|
|
47973
49145
|
}
|
|
47974
49146
|
async headObject(e, r, n) {
|
|
@@ -47978,13 +49150,13 @@ var require_dist = __commonJS({
|
|
|
47978
49150
|
if (o.status === 404)
|
|
47979
49151
|
return null;
|
|
47980
49152
|
if (!o.ok) {
|
|
47981
|
-
let d = await
|
|
47982
|
-
throw new f(o.status, t.buildErrorDetail("HEAD", s, a, d || \`status \${o.status}\`,
|
|
49153
|
+
let d = await k(o);
|
|
49154
|
+
throw new f(o.status, t.buildErrorDetail("HEAD", s, a, d || \`status \${o.status}\`, R(o)));
|
|
47983
49155
|
}
|
|
47984
49156
|
let c = Z(o.headers);
|
|
47985
49157
|
return { cacheControl: c["cache-control"], contentType: c["content-type"], etag: c.etag, headers: c };
|
|
47986
49158
|
} catch (o) {
|
|
47987
|
-
throw o instanceof f ? o : new f(0, t.buildErrorDetail("HEAD", s, a,
|
|
49159
|
+
throw o instanceof f ? o : new f(0, t.buildErrorDetail("HEAD", s, a, A(o)));
|
|
47988
49160
|
}
|
|
47989
49161
|
}
|
|
47990
49162
|
async deleteObject(e, r) {
|
|
@@ -47996,10 +49168,10 @@ var require_dist = __commonJS({
|
|
|
47996
49168
|
});
|
|
47997
49169
|
return;
|
|
47998
49170
|
}
|
|
47999
|
-
let o = await
|
|
48000
|
-
throw new f(a.status, t.buildErrorDetail("DELETE", n, i, o || \`status \${a.status}\`,
|
|
49171
|
+
let o = await k(a);
|
|
49172
|
+
throw new f(a.status, t.buildErrorDetail("DELETE", n, i, o || \`status \${a.status}\`, R(a)));
|
|
48001
49173
|
} catch (a) {
|
|
48002
|
-
throw a instanceof f ? a : new f(0, t.buildErrorDetail("DELETE", n, i,
|
|
49174
|
+
throw a instanceof f ? a : new f(0, t.buildErrorDetail("DELETE", n, i, A(a)));
|
|
48003
49175
|
}
|
|
48004
49176
|
}
|
|
48005
49177
|
async listObjects(e, r) {
|
|
@@ -48025,35 +49197,35 @@ var require_dist = __commonJS({
|
|
|
48025
49197
|
return r;
|
|
48026
49198
|
}
|
|
48027
49199
|
async getBucketRaw(e) {
|
|
48028
|
-
let r = await this.resolveDomain(e.consistency), n = await this.resolveCredential(), s = { prefix: e.prefix };
|
|
48029
|
-
e.delimiter && (s.delimiter = e.delimiter), e.marker && (s.marker = e.marker), e.maxKeys && (s["max-keys"] = e.maxKeys);
|
|
49200
|
+
let r = await this.resolveDomain(e.consistency), n = await this.resolveCredential(), s = { prefix: I(e.prefix) };
|
|
49201
|
+
e.delimiter && (s.delimiter = e.delimiter), e.marker && (s.marker = I(e.marker)), e.maxKeys && (s["max-keys"] = e.maxKeys);
|
|
48030
49202
|
try {
|
|
48031
49203
|
let i = await S({ domain: r, method: "GET", query: s, credential: n });
|
|
48032
49204
|
if (!i.ok) {
|
|
48033
|
-
let o = await
|
|
48034
|
-
throw new f(i.status, t.buildErrorDetail("LIST", r, e.prefix, o || \`status \${i.status}\`,
|
|
49205
|
+
let o = await k(i);
|
|
49206
|
+
throw new f(i.status, t.buildErrorDetail("LIST", r, e.prefix, o || \`status \${i.status}\`, R(i)));
|
|
48035
49207
|
}
|
|
48036
49208
|
let a = await i.text();
|
|
48037
|
-
return
|
|
49209
|
+
return Se(a);
|
|
48038
49210
|
} catch (i) {
|
|
48039
|
-
throw i instanceof f ? i : new f(0, t.buildErrorDetail("LIST", r, e.prefix,
|
|
49211
|
+
throw i instanceof f ? i : new f(0, t.buildErrorDetail("LIST", r, e.prefix, A(i)));
|
|
48040
49212
|
}
|
|
48041
49213
|
}
|
|
48042
49214
|
};
|
|
48043
|
-
function
|
|
49215
|
+
function Ee(t) {
|
|
48044
49216
|
return t.replace(/[a-zA-Z0-9\\-]+\\.cos\\.[a-zA-Z0-9\\-.]+\\.myqcloud\\.com/gi, "[cos-origin]").replace(/[a-zA-Z0-9\\-]+\\.cos\\.[a-zA-Z0-9\\-.]+\\.tencentcos\\.cn/gi, "[cos-origin]");
|
|
48045
49217
|
}
|
|
48046
|
-
async function
|
|
49218
|
+
async function k(t) {
|
|
48047
49219
|
try {
|
|
48048
49220
|
return await t.text();
|
|
48049
49221
|
} catch {
|
|
48050
49222
|
return "";
|
|
48051
49223
|
}
|
|
48052
49224
|
}
|
|
48053
|
-
function
|
|
49225
|
+
function R(t) {
|
|
48054
49226
|
return t.headers.get("x-cos-request-id") || t.headers.get("x-eo-log-id") || void 0;
|
|
48055
49227
|
}
|
|
48056
|
-
function
|
|
49228
|
+
function A(t) {
|
|
48057
49229
|
let e = t, r = e.message || String(t), n = e.cause;
|
|
48058
49230
|
if (n) {
|
|
48059
49231
|
let s = n.message || n.code || "";
|
|
@@ -48067,43 +49239,43 @@ var require_dist = __commonJS({
|
|
|
48067
49239
|
e[n.toLowerCase()] = r;
|
|
48068
49240
|
}), e;
|
|
48069
49241
|
}
|
|
48070
|
-
function
|
|
49242
|
+
function Se(t) {
|
|
48071
49243
|
let e = [], r = /<Contents>([\\s\\S]*?)<\\/Contents>/g, n;
|
|
48072
49244
|
for (; (n = r.exec(t)) !== null; ) {
|
|
48073
|
-
let d = n[1], u =
|
|
48074
|
-
u !== null && e.push({ key:
|
|
49245
|
+
let d = n[1], u = v(d, "Key"), l = v(d, "ETag");
|
|
49246
|
+
u !== null && e.push({ key: L(u), etag: l || "" });
|
|
48075
49247
|
}
|
|
48076
49248
|
let s = [], i = /<CommonPrefixes>([\\s\\S]*?)<\\/CommonPrefixes>/g;
|
|
48077
49249
|
for (; (n = i.exec(t)) !== null; ) {
|
|
48078
|
-
let d = n[1], u =
|
|
48079
|
-
u !== null && s.push(
|
|
49250
|
+
let d = n[1], u = v(d, "Prefix");
|
|
49251
|
+
u !== null && s.push(L(u));
|
|
48080
49252
|
}
|
|
48081
|
-
let o =
|
|
48082
|
-
return { contents: e, commonPrefixes: s, isTruncated: o, nextMarker:
|
|
49253
|
+
let o = v(t, "IsTruncated") === "true", c = v(t, "NextMarker") || "";
|
|
49254
|
+
return { contents: e, commonPrefixes: s, isTruncated: o, nextMarker: L(c) };
|
|
48083
49255
|
}
|
|
48084
|
-
function
|
|
49256
|
+
function v(t, e) {
|
|
48085
49257
|
let n = new RegExp(\`<\${e}>([\\\\s\\\\S]*?)<\\\\/\${e}>\`).exec(t);
|
|
48086
49258
|
return n ? n[1] : null;
|
|
48087
49259
|
}
|
|
48088
|
-
function
|
|
49260
|
+
function L(t) {
|
|
48089
49261
|
return t.replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/'/g, "'").replace(/&/g, "&");
|
|
48090
49262
|
}
|
|
48091
|
-
var
|
|
48092
|
-
async function
|
|
49263
|
+
var Pe = "X-RateLimit-Reset";
|
|
49264
|
+
async function B(t, e, r = 2) {
|
|
48093
49265
|
var _a, _b;
|
|
48094
49266
|
(_b = (_a = e.signal) == null ? void 0 : _a.throwIfAborted) == null ? void 0 : _b.call(_a);
|
|
48095
49267
|
try {
|
|
48096
49268
|
let n = await fetch(t, e);
|
|
48097
49269
|
if (r > 0 && (n.status === 429 || n.status >= 500)) {
|
|
48098
|
-
let s = Q(n.headers.get(
|
|
48099
|
-
return await ee(s, e.signal),
|
|
49270
|
+
let s = Q(n.headers.get(Pe));
|
|
49271
|
+
return await ee(s, e.signal), B(t, e, r - 1);
|
|
48100
49272
|
}
|
|
48101
49273
|
return n;
|
|
48102
49274
|
} catch (n) {
|
|
48103
49275
|
if (r === 0 || n instanceof DOMException && n.name === "AbortError")
|
|
48104
49276
|
throw n;
|
|
48105
49277
|
let s = Q();
|
|
48106
|
-
return await ee(s, e.signal),
|
|
49278
|
+
return await ee(s, e.signal), B(t, e, r - 1);
|
|
48107
49279
|
}
|
|
48108
49280
|
}
|
|
48109
49281
|
function Q(t) {
|
|
@@ -48121,14 +49293,14 @@ var require_dist = __commonJS({
|
|
|
48121
49293
|
e == null ? void 0 : e.addEventListener("abort", i, { once: true });
|
|
48122
49294
|
});
|
|
48123
49295
|
}
|
|
48124
|
-
var
|
|
49296
|
+
var Ie = "prod";
|
|
48125
49297
|
function te() {
|
|
48126
49298
|
let t = typeof process < "u" ? process.env.PAGES_BLOB_STS_ENV : void 0;
|
|
48127
|
-
return t === "test" || t === "prod" ? t :
|
|
49299
|
+
return t === "test" || t === "prod" ? t : Ie;
|
|
48128
49300
|
}
|
|
48129
|
-
var
|
|
48130
|
-
var
|
|
48131
|
-
var
|
|
49301
|
+
var ke = 300;
|
|
49302
|
+
var Re = "https://blob-sts.edgeone.site/";
|
|
49303
|
+
var D = class {
|
|
48132
49304
|
authToken;
|
|
48133
49305
|
projectId;
|
|
48134
49306
|
cached = null;
|
|
@@ -48146,16 +49318,16 @@ var require_dist = __commonJS({
|
|
|
48146
49318
|
}
|
|
48147
49319
|
isExpired(e) {
|
|
48148
49320
|
let r = Math.floor(Date.now() / 1e3);
|
|
48149
|
-
return e.expiredTime - r <
|
|
49321
|
+
return e.expiredTime - r < ke;
|
|
48150
49322
|
}
|
|
48151
49323
|
async fetchCredential() {
|
|
48152
49324
|
for (let n = 1; n <= 3; n++) {
|
|
48153
49325
|
let s = new AbortController(), i = setTimeout(() => s.abort(), 1e4), a;
|
|
48154
49326
|
try {
|
|
48155
|
-
a = await
|
|
49327
|
+
a = await B(Re, { method: "POST", headers: { "Content-Type": "application/json", Authorization: \`Bearer \${this.authToken}\`, "X-Env": te() }, body: JSON.stringify(this.projectId ? { ProjectId: this.projectId } : {}), signal: s.signal });
|
|
48156
49328
|
} catch (d) {
|
|
48157
49329
|
if (n < 3) {
|
|
48158
|
-
await
|
|
49330
|
+
await K(500 * n);
|
|
48159
49331
|
continue;
|
|
48160
49332
|
}
|
|
48161
49333
|
throw new m(\`failed to obtain STS credential: \${d.message || "timeout"}\`);
|
|
@@ -48168,7 +49340,7 @@ var require_dist = __commonJS({
|
|
|
48168
49340
|
throw new m("rate limited, please retry later");
|
|
48169
49341
|
if (!a.ok) {
|
|
48170
49342
|
if (a.status >= 500 && n < 3) {
|
|
48171
|
-
await
|
|
49343
|
+
await K(500 * n);
|
|
48172
49344
|
continue;
|
|
48173
49345
|
}
|
|
48174
49346
|
let d = await a.text().catch(() => "unknown error");
|
|
@@ -48188,7 +49360,7 @@ var require_dist = __commonJS({
|
|
|
48188
49360
|
throw new m(\`credential exchange failed (code=\${o.code}): \${d}\`);
|
|
48189
49361
|
}
|
|
48190
49362
|
if (n < 3) {
|
|
48191
|
-
await
|
|
49363
|
+
await K(500 * n);
|
|
48192
49364
|
continue;
|
|
48193
49365
|
}
|
|
48194
49366
|
throw new m("invalid STS credential response");
|
|
@@ -48196,12 +49368,12 @@ var require_dist = __commonJS({
|
|
|
48196
49368
|
throw new m("invalid STS credential response");
|
|
48197
49369
|
}
|
|
48198
49370
|
};
|
|
48199
|
-
function
|
|
49371
|
+
function K(t) {
|
|
48200
49372
|
return new Promise((e) => setTimeout(e, t));
|
|
48201
49373
|
}
|
|
48202
|
-
var
|
|
49374
|
+
var Ae = "{{PAGES_BLOB_DEPLOY_CREDENTIAL}}";
|
|
48203
49375
|
function re() {
|
|
48204
|
-
let t = {}, e =
|
|
49376
|
+
let t = {}, e = ve();
|
|
48205
49377
|
if (e)
|
|
48206
49378
|
t.deployCredential = e;
|
|
48207
49379
|
else {
|
|
@@ -48211,8 +49383,8 @@ var require_dist = __commonJS({
|
|
|
48211
49383
|
let r = ne("PAGES_PROJECT_ID");
|
|
48212
49384
|
return r && (t.projectId = r), t;
|
|
48213
49385
|
}
|
|
48214
|
-
function
|
|
48215
|
-
let t =
|
|
49386
|
+
function ve() {
|
|
49387
|
+
let t = Ae;
|
|
48216
49388
|
if (!(t.startsWith("{{") && t.endsWith("}}")))
|
|
48217
49389
|
return t || void 0;
|
|
48218
49390
|
}
|
|
@@ -48220,15 +49392,15 @@ var require_dist = __commonJS({
|
|
|
48220
49392
|
if (typeof process < "u" && process.env)
|
|
48221
49393
|
return process.env[t];
|
|
48222
49394
|
}
|
|
48223
|
-
function
|
|
49395
|
+
function Me(t) {
|
|
48224
49396
|
let e = typeof t == "string" ? t : t.name;
|
|
48225
|
-
|
|
48226
|
-
let r = se(typeof t == "string" ? void 0 : t), n = new
|
|
49397
|
+
z(e);
|
|
49398
|
+
let r = se(typeof t == "string" ? void 0 : t), n = new D(r.authToken, r.projectId), s = new M(n);
|
|
48227
49399
|
return new E(s, e, r.consistency ?? "eventual");
|
|
48228
49400
|
}
|
|
48229
|
-
async function
|
|
48230
|
-
let e = se(t ? { name: "__list__", projectId: t.projectId, token: t.token, consistency: t.consistency } : void 0), r = new
|
|
48231
|
-
return { stores: (await new
|
|
49401
|
+
async function De(t) {
|
|
49402
|
+
let e = se(t ? { name: "__list__", projectId: t.projectId, token: t.token, consistency: t.consistency } : void 0), r = new D(e.authToken, e.projectId);
|
|
49403
|
+
return { stores: (await new M(r).listStores(e.consistency)).map((i) => ({ name: i })) };
|
|
48232
49404
|
}
|
|
48233
49405
|
function se(t) {
|
|
48234
49406
|
let e = re(), r = (t == null ? void 0 : t.token) || e.deployCredential, n = (t == null ? void 0 : t.projectId) || e.projectId;
|
|
@@ -48270,6 +49442,9 @@ var LANGGRAPH_STORE_PREFIX = "langgraph_store";
|
|
|
48270
49442
|
var LANGGRAPH_STORE_KEY_SEPARATOR = "__key__";
|
|
48271
49443
|
var LANGGRAPH_SERDE_VERSION = 1;
|
|
48272
49444
|
var CLAUDE_SESSION_PREFIX = "claude_sessions";
|
|
49445
|
+
var CLAUDE_SESSION_MAPPING_PREFIX = "claude_session_mapping";
|
|
49446
|
+
var STATE_PREFIX = "state";
|
|
49447
|
+
var MAX_STATE_KEY_LENGTH = 256;
|
|
48273
49448
|
var SESSION_METADATA_MARKER = { agent_sdk_session: true };
|
|
48274
49449
|
var VALID_ROLES = /* @__PURE__ */ new Set([
|
|
48275
49450
|
"user",
|
|
@@ -48316,6 +49491,15 @@ var MemoryStorageError = class extends Error {
|
|
|
48316
49491
|
this.cause = cause;
|
|
48317
49492
|
}
|
|
48318
49493
|
};
|
|
49494
|
+
var MemoryCorruptError = class extends Error {
|
|
49495
|
+
code = "MemoryCorruptError";
|
|
49496
|
+
cause;
|
|
49497
|
+
constructor(message, cause) {
|
|
49498
|
+
super(message);
|
|
49499
|
+
this.name = "MemoryCorruptError";
|
|
49500
|
+
this.cause = cause;
|
|
49501
|
+
}
|
|
49502
|
+
};
|
|
48319
49503
|
var dynamicImport = new Function(
|
|
48320
49504
|
"specifier",
|
|
48321
49505
|
"return import(specifier);"
|
|
@@ -48323,7 +49507,7 @@ var dynamicImport = new Function(
|
|
|
48323
49507
|
var langchainLoadPromise;
|
|
48324
49508
|
var langchainMessagesPromise;
|
|
48325
49509
|
function isMemoryError(error) {
|
|
48326
|
-
return error instanceof MemoryValidationError || error instanceof MemoryNotFoundError || error instanceof MemoryQuotaExceededError || error instanceof MemoryStorageError;
|
|
49510
|
+
return error instanceof MemoryValidationError || error instanceof MemoryNotFoundError || error instanceof MemoryQuotaExceededError || error instanceof MemoryStorageError || error instanceof MemoryCorruptError;
|
|
48327
49511
|
}
|
|
48328
49512
|
async function wrapStorage(operation) {
|
|
48329
49513
|
try {
|
|
@@ -48491,10 +49675,17 @@ async function reviveLangGraphJsonValue(value) {
|
|
|
48491
49675
|
return revived;
|
|
48492
49676
|
}
|
|
48493
49677
|
async function deserializeLangGraphJson(value) {
|
|
48494
|
-
|
|
48495
|
-
|
|
49678
|
+
try {
|
|
49679
|
+
if (isLangGraphSerializedJson(value)) {
|
|
49680
|
+
return reviveLangGraphJsonValue(JSON.parse(value.data));
|
|
49681
|
+
}
|
|
49682
|
+
return reviveLangGraphJsonValue(value);
|
|
49683
|
+
} catch (error) {
|
|
49684
|
+
throw new MemoryCorruptError(
|
|
49685
|
+
"LangGraph persisted state is corrupt or incompatible.",
|
|
49686
|
+
error
|
|
49687
|
+
);
|
|
48496
49688
|
}
|
|
48497
|
-
return reviveLangGraphJsonValue(value);
|
|
48498
49689
|
}
|
|
48499
49690
|
function normalizeStoreLimit(value, fallback) {
|
|
48500
49691
|
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
@@ -48606,6 +49797,115 @@ function validateMessageId(messageId) {
|
|
|
48606
49797
|
throw new MemoryValidationError("messageId is required.");
|
|
48607
49798
|
}
|
|
48608
49799
|
}
|
|
49800
|
+
function validateStateKey(key) {
|
|
49801
|
+
if (typeof key !== "string" || key.length === 0) {
|
|
49802
|
+
throw new MemoryValidationError("state key is required.");
|
|
49803
|
+
}
|
|
49804
|
+
if (key.length > MAX_STATE_KEY_LENGTH) {
|
|
49805
|
+
throw new MemoryValidationError(
|
|
49806
|
+
\`state key must be at most \${MAX_STATE_KEY_LENGTH} characters.\`
|
|
49807
|
+
);
|
|
49808
|
+
}
|
|
49809
|
+
}
|
|
49810
|
+
function assertStateSerializable(value, path2 = "state value", seen = /* @__PURE__ */ new Set()) {
|
|
49811
|
+
if (value === null || typeof value === "string" || typeof value === "boolean") {
|
|
49812
|
+
return;
|
|
49813
|
+
}
|
|
49814
|
+
if (typeof value === "number") {
|
|
49815
|
+
if (Number.isFinite(value))
|
|
49816
|
+
return;
|
|
49817
|
+
throw new MemoryValidationError(\`\${path2} must contain only JSON values.\`);
|
|
49818
|
+
}
|
|
49819
|
+
if (value === void 0 || typeof value === "function" || typeof value === "symbol" || typeof value === "bigint") {
|
|
49820
|
+
throw new MemoryValidationError(\`\${path2} must be JSON serializable.\`);
|
|
49821
|
+
}
|
|
49822
|
+
if (typeof value !== "object") {
|
|
49823
|
+
throw new MemoryValidationError(\`\${path2} must be JSON serializable.\`);
|
|
49824
|
+
}
|
|
49825
|
+
if (seen.has(value)) {
|
|
49826
|
+
throw new MemoryValidationError(\`\${path2} must not contain circular references.\`);
|
|
49827
|
+
}
|
|
49828
|
+
seen.add(value);
|
|
49829
|
+
if (Array.isArray(value)) {
|
|
49830
|
+
value.forEach((item, index) => assertStateSerializable(item, \`\${path2}[\${index}]\`, seen));
|
|
49831
|
+
} else if (isPlainObject(value)) {
|
|
49832
|
+
for (const [key, item] of Object.entries(value)) {
|
|
49833
|
+
assertStateSerializable(item, \`\${path2}.\${key}\`, seen);
|
|
49834
|
+
}
|
|
49835
|
+
} else {
|
|
49836
|
+
throw new MemoryValidationError(\`\${path2} must contain only JSON values.\`);
|
|
49837
|
+
}
|
|
49838
|
+
seen.delete(value);
|
|
49839
|
+
}
|
|
49840
|
+
function stateConversationPrefix(conversationId) {
|
|
49841
|
+
return \`\${STATE_PREFIX}/\${encodeKeySegment(conversationId)}/\`;
|
|
49842
|
+
}
|
|
49843
|
+
function createAgentStateStore(store, boundConversationId) {
|
|
49844
|
+
const requireConversation = () => {
|
|
49845
|
+
if (!boundConversationId) {
|
|
49846
|
+
throw new MemoryValidationError(
|
|
49847
|
+
"State operations require a bound conversationId."
|
|
49848
|
+
);
|
|
49849
|
+
}
|
|
49850
|
+
validateConversationId(boundConversationId);
|
|
49851
|
+
return boundConversationId;
|
|
49852
|
+
};
|
|
49853
|
+
return {
|
|
49854
|
+
async get(key) {
|
|
49855
|
+
validateStateKey(key);
|
|
49856
|
+
const conversationId = requireConversation();
|
|
49857
|
+
return wrapStorage(async () => {
|
|
49858
|
+
const raw = await store.get(
|
|
49859
|
+
\`\${stateConversationPrefix(conversationId)}\${encodeKeySegment(key)}\`,
|
|
49860
|
+
{ consistency: "strong" }
|
|
49861
|
+
);
|
|
49862
|
+
if (raw === null)
|
|
49863
|
+
return null;
|
|
49864
|
+
if (typeof raw !== "string") {
|
|
49865
|
+
throw new MemoryStorageError("Stored state value is not valid JSON text.");
|
|
49866
|
+
}
|
|
49867
|
+
try {
|
|
49868
|
+
return JSON.parse(raw);
|
|
49869
|
+
} catch (error) {
|
|
49870
|
+
throw new MemoryStorageError("Stored state value is invalid JSON.", error);
|
|
49871
|
+
}
|
|
49872
|
+
});
|
|
49873
|
+
},
|
|
49874
|
+
async set(key, value) {
|
|
49875
|
+
validateStateKey(key);
|
|
49876
|
+
const conversationId = requireConversation();
|
|
49877
|
+
assertStateSerializable(value);
|
|
49878
|
+
let serialized;
|
|
49879
|
+
try {
|
|
49880
|
+
serialized = JSON.stringify(value);
|
|
49881
|
+
} catch (error) {
|
|
49882
|
+
throw new MemoryValidationError(\`state value must be JSON serializable: \${String(error)}\`);
|
|
49883
|
+
}
|
|
49884
|
+
await wrapStorage(
|
|
49885
|
+
() => store.set(
|
|
49886
|
+
\`\${stateConversationPrefix(conversationId)}\${encodeKeySegment(key)}\`,
|
|
49887
|
+
serialized
|
|
49888
|
+
)
|
|
49889
|
+
);
|
|
49890
|
+
},
|
|
49891
|
+
async delete(key) {
|
|
49892
|
+
validateStateKey(key);
|
|
49893
|
+
const conversationId = requireConversation();
|
|
49894
|
+
await wrapStorage(
|
|
49895
|
+
() => store.delete(
|
|
49896
|
+
\`\${stateConversationPrefix(conversationId)}\${encodeKeySegment(key)}\`
|
|
49897
|
+
)
|
|
49898
|
+
);
|
|
49899
|
+
}
|
|
49900
|
+
};
|
|
49901
|
+
}
|
|
49902
|
+
async function deleteAgentState(store, conversationId) {
|
|
49903
|
+
const listed = await store.list({
|
|
49904
|
+
prefix: stateConversationPrefix(conversationId),
|
|
49905
|
+
consistency: "strong"
|
|
49906
|
+
});
|
|
49907
|
+
await Promise.all(listed.keys.map((key) => store.delete(key)));
|
|
49908
|
+
}
|
|
48609
49909
|
function validateUserId(userId) {
|
|
48610
49910
|
if (userId === void 0) {
|
|
48611
49911
|
return;
|
|
@@ -48738,6 +50038,9 @@ function cursorSortKey(cursor) {
|
|
|
48738
50038
|
const payload = decodeConversationCursor(cursor);
|
|
48739
50039
|
return \`\${reverseTimestamp(payload.lastMessageAt)}_\${encodeKeySegment(payload.conversationId)}\`;
|
|
48740
50040
|
}
|
|
50041
|
+
function cursorListCursor(cursor) {
|
|
50042
|
+
return cursor ? decodeConversationCursor(cursor).listCursor : void 0;
|
|
50043
|
+
}
|
|
48741
50044
|
function indexSortKey(key, prefix) {
|
|
48742
50045
|
return key.slice(prefix.length);
|
|
48743
50046
|
}
|
|
@@ -48905,6 +50208,51 @@ function claudeSessionBase(projectKey, sessionId) {
|
|
|
48905
50208
|
function claudeProjectPrefix(projectKey) {
|
|
48906
50209
|
return \`\${CLAUDE_SESSION_PREFIX}/\${encodeKeySegment(projectKey)}/\`;
|
|
48907
50210
|
}
|
|
50211
|
+
function claudeSessionMappingKey(conversationId) {
|
|
50212
|
+
return \`\${CLAUDE_SESSION_MAPPING_PREFIX}/\${encodeKeySegment(conversationId)}\`;
|
|
50213
|
+
}
|
|
50214
|
+
function normalizeClaudeUuid(value) {
|
|
50215
|
+
const trimmed = value.trim().toLowerCase();
|
|
50216
|
+
return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/.test(trimmed) ? trimmed : null;
|
|
50217
|
+
}
|
|
50218
|
+
function claudeSessionIdFromKey(key) {
|
|
50219
|
+
const prefix = \`\${CLAUDE_SESSION_PREFIX}/\`;
|
|
50220
|
+
if (!key.startsWith(prefix)) {
|
|
50221
|
+
return null;
|
|
50222
|
+
}
|
|
50223
|
+
const segments = key.slice(prefix.length).split("/");
|
|
50224
|
+
return segments.length >= 3 && segments[1] ? decodeKeySegment(segments[1]) : null;
|
|
50225
|
+
}
|
|
50226
|
+
async function deleteClaudeSessionForConversation(store, conversationId) {
|
|
50227
|
+
const mappingKey = claudeSessionMappingKey(conversationId);
|
|
50228
|
+
const mapping = await store.get(mappingKey, {
|
|
50229
|
+
consistency: "strong"
|
|
50230
|
+
});
|
|
50231
|
+
let sessionId = null;
|
|
50232
|
+
if (typeof mapping === "string") {
|
|
50233
|
+
sessionId = mapping;
|
|
50234
|
+
} else if (isPlainObject(mapping) && typeof mapping.sessionId === "string") {
|
|
50235
|
+
sessionId = mapping.sessionId;
|
|
50236
|
+
} else if (isPlainObject(mapping) && typeof mapping.session_id === "string") {
|
|
50237
|
+
sessionId = mapping.session_id;
|
|
50238
|
+
}
|
|
50239
|
+
if (!sessionId) {
|
|
50240
|
+
sessionId = normalizeClaudeUuid(conversationId);
|
|
50241
|
+
}
|
|
50242
|
+
await store.delete(mappingKey);
|
|
50243
|
+
if (!sessionId) {
|
|
50244
|
+
return;
|
|
50245
|
+
}
|
|
50246
|
+
const listed = await store.list({
|
|
50247
|
+
prefix: \`\${CLAUDE_SESSION_PREFIX}/\`,
|
|
50248
|
+
consistency: "strong"
|
|
50249
|
+
});
|
|
50250
|
+
for (const key of listed.keys) {
|
|
50251
|
+
if (claudeSessionIdFromKey(key) === sessionId) {
|
|
50252
|
+
await store.delete(key);
|
|
50253
|
+
}
|
|
50254
|
+
}
|
|
50255
|
+
}
|
|
48908
50256
|
function claudePartsPrefix(key) {
|
|
48909
50257
|
let base = claudeSessionBase(key.projectKey, key.sessionId).slice(0, -1);
|
|
48910
50258
|
if (key.subpath) {
|
|
@@ -48942,7 +50290,9 @@ function createClaudeSessionStore(store) {
|
|
|
48942
50290
|
consistency: "strong"
|
|
48943
50291
|
});
|
|
48944
50292
|
if (typeof raw !== "string") {
|
|
48945
|
-
|
|
50293
|
+
throw new MemoryCorruptError(
|
|
50294
|
+
\`Claude session part '\${partKey}' is not valid JSONL text.\`
|
|
50295
|
+
);
|
|
48946
50296
|
}
|
|
48947
50297
|
for (const line of raw.split("\\n")) {
|
|
48948
50298
|
const trimmed = line.trim();
|
|
@@ -48951,7 +50301,11 @@ function createClaudeSessionStore(store) {
|
|
|
48951
50301
|
}
|
|
48952
50302
|
try {
|
|
48953
50303
|
entries.push(JSON.parse(trimmed));
|
|
48954
|
-
} catch {
|
|
50304
|
+
} catch (error) {
|
|
50305
|
+
throw new MemoryCorruptError(
|
|
50306
|
+
\`Claude session part '\${partKey}' contains malformed JSONL.\`,
|
|
50307
|
+
error
|
|
50308
|
+
);
|
|
48955
50309
|
}
|
|
48956
50310
|
}
|
|
48957
50311
|
}
|
|
@@ -49077,8 +50431,70 @@ async function listConversationsByUser(store, userId, options) {
|
|
|
49077
50431
|
});
|
|
49078
50432
|
}
|
|
49079
50433
|
async function listConversationsFromIndex(store, options) {
|
|
50434
|
+
if (!options.before) {
|
|
50435
|
+
const fast = await listConversationsFromIndexFast(store, options);
|
|
50436
|
+
if (fast)
|
|
50437
|
+
return fast;
|
|
50438
|
+
}
|
|
49080
50439
|
return listConversationsFromIndexFull(store, options);
|
|
49081
50440
|
}
|
|
50441
|
+
async function listConversationsFromIndexFast(store, options) {
|
|
50442
|
+
var _a, _b;
|
|
50443
|
+
let listCursor = cursorListCursor(options.after);
|
|
50444
|
+
if (options.after && !listCursor) {
|
|
50445
|
+
return null;
|
|
50446
|
+
}
|
|
50447
|
+
const pageItems = [];
|
|
50448
|
+
const seen = /* @__PURE__ */ new Set();
|
|
50449
|
+
let lastCursor;
|
|
50450
|
+
while (pageItems.length < options.limit) {
|
|
50451
|
+
const listed = await store.list({
|
|
50452
|
+
prefix: options.prefix,
|
|
50453
|
+
cursor: listCursor,
|
|
50454
|
+
limit: options.limit - pageItems.length,
|
|
50455
|
+
paginate: false,
|
|
50456
|
+
consistency: "strong"
|
|
50457
|
+
});
|
|
50458
|
+
lastCursor = listed.cursor;
|
|
50459
|
+
if (!listed.keys.length) {
|
|
50460
|
+
break;
|
|
50461
|
+
}
|
|
50462
|
+
const indexItems = [...listed.keys].sort(
|
|
50463
|
+
(left, right) => options.order === "desc" ? left.localeCompare(right) : right.localeCompare(left)
|
|
50464
|
+
).map((key) => {
|
|
50465
|
+
const conversationId = options.conversationIdFromKey(key);
|
|
50466
|
+
if (!conversationId || seen.has(conversationId)) {
|
|
50467
|
+
return null;
|
|
50468
|
+
}
|
|
50469
|
+
seen.add(conversationId);
|
|
50470
|
+
return {
|
|
50471
|
+
key,
|
|
50472
|
+
sortKey: indexSortKey(key, options.prefix),
|
|
50473
|
+
conversationId
|
|
50474
|
+
};
|
|
50475
|
+
}).filter((item) => item !== null);
|
|
50476
|
+
const metas = await Promise.all(
|
|
50477
|
+
indexItems.map((item) => readConversationMeta(store, item.conversationId))
|
|
50478
|
+
);
|
|
50479
|
+
for (let i = 0; i < indexItems.length; i++) {
|
|
50480
|
+
const meta = metas[i];
|
|
50481
|
+
if (meta) {
|
|
50482
|
+
pageItems.push({ indexItem: indexItems[i], meta });
|
|
50483
|
+
}
|
|
50484
|
+
}
|
|
50485
|
+
if (!listed.cursor) {
|
|
50486
|
+
break;
|
|
50487
|
+
}
|
|
50488
|
+
listCursor = listed.cursor;
|
|
50489
|
+
}
|
|
50490
|
+
const firstItem = (_a = pageItems[0]) == null ? void 0 : _a.indexItem;
|
|
50491
|
+
const lastItem = (_b = pageItems[pageItems.length - 1]) == null ? void 0 : _b.indexItem;
|
|
50492
|
+
return {
|
|
50493
|
+
items: pageItems.map((item) => item.meta),
|
|
50494
|
+
nextCursor: lastItem ? encodeConversationCursorFromIndexItem(lastItem, lastCursor) : void 0,
|
|
50495
|
+
previousCursor: firstItem ? encodeConversationCursorFromIndexItem(firstItem) : void 0
|
|
50496
|
+
};
|
|
50497
|
+
}
|
|
49082
50498
|
async function listConversationsFromIndexFull(store, options) {
|
|
49083
50499
|
var _a, _b;
|
|
49084
50500
|
const afterSortKey = options.after ? cursorSortKey(options.after) : void 0;
|
|
@@ -49515,6 +50931,7 @@ function createAgentMemory(store, options = {}) {
|
|
|
49515
50931
|
const maxMessagesPerConversation = options.maxMessagesPerConversation ?? DEFAULT_MAX_MESSAGES_PER_CONVERSATION;
|
|
49516
50932
|
const langgraphCheckpointer = createLangGraphCheckpointer(store);
|
|
49517
50933
|
const langgraphStore = createLangGraphStore(store);
|
|
50934
|
+
const state = createAgentStateStore(store, options.conversationId);
|
|
49518
50935
|
let claudeStoreCache = null;
|
|
49519
50936
|
let lastMessageCreatedAt = 0;
|
|
49520
50937
|
const appendMessagesInternal = async (inputs) => {
|
|
@@ -49800,8 +51217,13 @@ function createAgentMemory(store, options = {}) {
|
|
|
49800
51217
|
listMessageKeys(store, input.conversationId)
|
|
49801
51218
|
]);
|
|
49802
51219
|
if (!meta) {
|
|
51220
|
+
if (options.conversationId === input.conversationId) {
|
|
51221
|
+
await deleteAgentState(store, input.conversationId);
|
|
51222
|
+
}
|
|
51223
|
+
await deleteClaudeSessionForConversation(store, input.conversationId);
|
|
51224
|
+
await langgraphCheckpointer.deleteThread(input.conversationId);
|
|
49803
51225
|
throw new MemoryNotFoundError(
|
|
49804
|
-
"Conversation not found by
|
|
51226
|
+
"Conversation not found by deleteConversation."
|
|
49805
51227
|
);
|
|
49806
51228
|
}
|
|
49807
51229
|
const deleteOps = [];
|
|
@@ -49818,6 +51240,11 @@ function createAgentMemory(store, options = {}) {
|
|
|
49818
51240
|
deleteOps.push(store.delete(metaKey(input.conversationId)));
|
|
49819
51241
|
deleteOps.push(store.delete(conversationIndexKey(meta)));
|
|
49820
51242
|
await Promise.all(deleteOps);
|
|
51243
|
+
if (options.conversationId === input.conversationId) {
|
|
51244
|
+
await deleteAgentState(store, input.conversationId);
|
|
51245
|
+
}
|
|
51246
|
+
await deleteClaudeSessionForConversation(store, input.conversationId);
|
|
51247
|
+
await langgraphCheckpointer.deleteThread(input.conversationId);
|
|
49821
51248
|
});
|
|
49822
51249
|
},
|
|
49823
51250
|
async updateConversation(input) {
|
|
@@ -49853,14 +51280,49 @@ function createAgentMemory(store, options = {}) {
|
|
|
49853
51280
|
}));
|
|
49854
51281
|
},
|
|
49855
51282
|
openaiSession(sessionId, sessionOptions = {}) {
|
|
51283
|
+
const boundSessionId = sessionId ?? options.conversationId;
|
|
51284
|
+
if (!boundSessionId) {
|
|
51285
|
+
throw new MemoryValidationError(
|
|
51286
|
+
"openaiSession requires a sessionId or bound conversationId."
|
|
51287
|
+
);
|
|
51288
|
+
}
|
|
49856
51289
|
const maxItems = sessionOptions.maxItems ?? MAX_LIMIT;
|
|
49857
51290
|
return createOpenAISession(
|
|
49858
51291
|
memory,
|
|
49859
|
-
|
|
51292
|
+
boundSessionId,
|
|
49860
51293
|
maxItems,
|
|
49861
51294
|
appendMessagesInternal
|
|
49862
51295
|
);
|
|
49863
51296
|
},
|
|
51297
|
+
async claudeSessionBinding(conversationId) {
|
|
51298
|
+
const resolvedConversationId = conversationId ?? options.conversationId;
|
|
51299
|
+
if (!resolvedConversationId) {
|
|
51300
|
+
throw new MemoryValidationError(
|
|
51301
|
+
"claudeSessionBinding requires a conversationId or bound conversationId."
|
|
51302
|
+
);
|
|
51303
|
+
}
|
|
51304
|
+
validateConversationId(resolvedConversationId);
|
|
51305
|
+
return wrapStorage(async () => {
|
|
51306
|
+
const mappingKey = claudeSessionMappingKey(resolvedConversationId);
|
|
51307
|
+
const existing = await store.get(
|
|
51308
|
+
mappingKey,
|
|
51309
|
+
{ consistency: "strong" }
|
|
51310
|
+
);
|
|
51311
|
+
if (typeof existing === "string" && existing) {
|
|
51312
|
+
return existing;
|
|
51313
|
+
}
|
|
51314
|
+
if (isPlainObject(existing) && (typeof existing.sessionId === "string" || typeof existing.session_id === "string") && (existing.sessionId || existing.session_id)) {
|
|
51315
|
+
return String(existing.sessionId || existing.session_id);
|
|
51316
|
+
}
|
|
51317
|
+
const sessionId = normalizeClaudeUuid(resolvedConversationId) ?? randomUUID();
|
|
51318
|
+
const binding = {
|
|
51319
|
+
conversationId: resolvedConversationId,
|
|
51320
|
+
sessionId
|
|
51321
|
+
};
|
|
51322
|
+
await store.set(mappingKey, binding);
|
|
51323
|
+
return sessionId;
|
|
51324
|
+
});
|
|
51325
|
+
},
|
|
49864
51326
|
claudeSessionStore() {
|
|
49865
51327
|
if (!claudeStoreCache) {
|
|
49866
51328
|
claudeStoreCache = createClaudeSessionStore(store);
|
|
@@ -49868,7 +51330,8 @@ function createAgentMemory(store, options = {}) {
|
|
|
49868
51330
|
return claudeStoreCache;
|
|
49869
51331
|
},
|
|
49870
51332
|
langgraphCheckpointer,
|
|
49871
|
-
langgraphStore
|
|
51333
|
+
langgraphStore,
|
|
51334
|
+
state
|
|
49872
51335
|
};
|
|
49873
51336
|
return memory;
|
|
49874
51337
|
}
|
|
@@ -50549,6 +52012,7 @@ function createAgentRuntime(options) {
|
|
|
50549
52012
|
env,
|
|
50550
52013
|
store: createAgentMemory(createLazyStore(resolveMemoryStore), {
|
|
50551
52014
|
runId: run_id,
|
|
52015
|
+
conversationId: conversation_id,
|
|
50552
52016
|
maxMessagesPerConversation: (_a = defaults == null ? void 0 : defaults.memoryQuota) == null ? void 0 : _a.maxMessagesPerConversation
|
|
50553
52017
|
}),
|
|
50554
52018
|
agents: {
|
|
@@ -51049,24 +52513,24 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
51049
52513
|
var require_dist = __commonJS({
|
|
51050
52514
|
"node_modules/@edgeone/pages-blob/dist/index.js"(exports, module) {
|
|
51051
52515
|
"use strict";
|
|
51052
|
-
var
|
|
52516
|
+
var U = Object.defineProperty;
|
|
51053
52517
|
var le = Object.getOwnPropertyDescriptor;
|
|
51054
52518
|
var ue = Object.getOwnPropertyNames;
|
|
51055
52519
|
var ge = Object.prototype.hasOwnProperty;
|
|
51056
52520
|
var fe = (t, e) => {
|
|
51057
52521
|
for (var r in e)
|
|
51058
|
-
|
|
52522
|
+
U(t, r, { get: e[r], enumerable: true });
|
|
51059
52523
|
};
|
|
51060
52524
|
var he = (t, e, r, n) => {
|
|
51061
52525
|
if (e && typeof e == "object" || typeof e == "function")
|
|
51062
52526
|
for (let s of ue(e))
|
|
51063
|
-
!ge.call(t, s) && s !== r &&
|
|
52527
|
+
!ge.call(t, s) && s !== r && U(t, s, { get: () => e[s], enumerable: !(n = le(e, s)) || n.enumerable });
|
|
51064
52528
|
return t;
|
|
51065
52529
|
};
|
|
51066
|
-
var me = (t) => he(
|
|
51067
|
-
var
|
|
51068
|
-
fe(
|
|
51069
|
-
module.exports = me(
|
|
52530
|
+
var me = (t) => he(U({}, "__esModule", { value: true }), t);
|
|
52531
|
+
var Oe = {};
|
|
52532
|
+
fe(Oe, { InvalidKeyError: () => w, InvalidStoreNameError: () => y, MissingProjectIdError: () => T, PagesBlobError: () => h, PreconditionFailedError: () => x, QuotaExceededError: () => O, RateLimitedError: () => j, Store: () => E, getStore: () => Me, listStores: () => De });
|
|
52533
|
+
module.exports = me(Oe);
|
|
51070
52534
|
var h = class extends Error {
|
|
51071
52535
|
code;
|
|
51072
52536
|
constructor(e, r) {
|
|
@@ -51088,12 +52552,12 @@ var require_dist = __commonJS({
|
|
|
51088
52552
|
super("MISSING_ENVIRONMENT", \`Environment not configured for Pages Blob. Missing: \${e.join(", ")}. Supply these properties when creating a store, or ensure the function is running in a Pages environment.\`);
|
|
51089
52553
|
}
|
|
51090
52554
|
};
|
|
51091
|
-
var
|
|
52555
|
+
var O = class extends h {
|
|
51092
52556
|
constructor() {
|
|
51093
52557
|
super("QUOTA_EXCEEDED", "storage quota exceeded");
|
|
51094
52558
|
}
|
|
51095
52559
|
};
|
|
51096
|
-
var
|
|
52560
|
+
var j = class extends h {
|
|
51097
52561
|
constructor() {
|
|
51098
52562
|
super("RATE_LIMITED", "request rate limited, please retry later");
|
|
51099
52563
|
}
|
|
@@ -51126,7 +52590,7 @@ var require_dist = __commonJS({
|
|
|
51126
52590
|
if (new TextEncoder().encode(t).length > 600)
|
|
51127
52591
|
throw new w("Blob key must be a sequence of Unicode characters whose UTF-8 encoding is at most 600 bytes long.");
|
|
51128
52592
|
}
|
|
51129
|
-
function
|
|
52593
|
+
function z2(t) {
|
|
51130
52594
|
if (t === "")
|
|
51131
52595
|
throw new y("Store name must not be empty.");
|
|
51132
52596
|
if (t.includes("/") || t.includes(":"))
|
|
@@ -51214,45 +52678,48 @@ var require_dist = __commonJS({
|
|
|
51214
52678
|
}
|
|
51215
52679
|
};
|
|
51216
52680
|
var ye = new TextEncoder();
|
|
51217
|
-
function
|
|
52681
|
+
function _(t) {
|
|
51218
52682
|
let e = ye.encode(t), r = new ArrayBuffer(e.byteLength), n = new Uint8Array(r);
|
|
51219
52683
|
return n.set(e), n;
|
|
51220
52684
|
}
|
|
51221
|
-
function
|
|
52685
|
+
function G2(t) {
|
|
51222
52686
|
let e = t instanceof Uint8Array ? t : new Uint8Array(t), r = "";
|
|
51223
52687
|
for (let n = 0; n < e.length; n++)
|
|
51224
52688
|
r += e[n].toString(16).padStart(2, "0");
|
|
51225
52689
|
return r;
|
|
51226
52690
|
}
|
|
51227
|
-
async function
|
|
51228
|
-
let r = await crypto.subtle.importKey("raw",
|
|
51229
|
-
return
|
|
52691
|
+
async function H(t, e) {
|
|
52692
|
+
let r = await crypto.subtle.importKey("raw", _(t), { name: "HMAC", hash: "SHA-1" }, false, ["sign"]), n = await crypto.subtle.sign("HMAC", r, _(e));
|
|
52693
|
+
return G2(n);
|
|
51230
52694
|
}
|
|
51231
52695
|
async function pe(t) {
|
|
51232
|
-
let e = await crypto.subtle.digest("SHA-1",
|
|
51233
|
-
return
|
|
52696
|
+
let e = await crypto.subtle.digest("SHA-1", _(t));
|
|
52697
|
+
return G2(e);
|
|
51234
52698
|
}
|
|
51235
|
-
function
|
|
52699
|
+
function $(t) {
|
|
51236
52700
|
return encodeURIComponent(t).replace(/[!'()*]/g, (e) => "%" + e.charCodeAt(0).toString(16).toUpperCase());
|
|
51237
52701
|
}
|
|
51238
|
-
function
|
|
52702
|
+
function P(t) {
|
|
51239
52703
|
try {
|
|
51240
52704
|
return decodeURIComponent(t);
|
|
51241
52705
|
} catch {
|
|
51242
52706
|
return t;
|
|
51243
52707
|
}
|
|
51244
52708
|
}
|
|
51245
|
-
function
|
|
51246
|
-
return t.split("/").map((e) =>
|
|
52709
|
+
function we(t) {
|
|
52710
|
+
return t.split("/").map((e) => P(e)).join("/");
|
|
52711
|
+
}
|
|
52712
|
+
function I(t) {
|
|
52713
|
+
return we(P(t));
|
|
51247
52714
|
}
|
|
51248
52715
|
function W(t) {
|
|
51249
|
-
return t.split("/").map((e) =>
|
|
52716
|
+
return t.split("/").map((e) => $(P(e))).join("/");
|
|
51250
52717
|
}
|
|
51251
|
-
var
|
|
51252
|
-
function
|
|
51253
|
-
return t === "host" || t === "x-cos-security-token" ? false : !!(
|
|
52718
|
+
var Ce = /* @__PURE__ */ new Set(["cache-control", "content-disposition", "content-encoding", "content-length", "content-md5", "content-type", "expect", "expires", "if-match", "if-modified-since", "if-none-match", "if-unmodified-since", "origin", "range", "transfer-encoding"]);
|
|
52719
|
+
function xe(t) {
|
|
52720
|
+
return t === "host" || t === "x-cos-security-token" ? false : !!(Ce.has(t) || t.startsWith("x-cos-"));
|
|
51254
52721
|
}
|
|
51255
|
-
function
|
|
52722
|
+
function X(t) {
|
|
51256
52723
|
if (!t)
|
|
51257
52724
|
return [];
|
|
51258
52725
|
let e = [];
|
|
@@ -51260,27 +52727,27 @@ var require_dist = __commonJS({
|
|
|
51260
52727
|
n != null && e.push([r.toLowerCase(), String(n)]);
|
|
51261
52728
|
return e.sort(([r], [n]) => r < n ? -1 : r > n ? 1 : 0), e;
|
|
51262
52729
|
}
|
|
51263
|
-
function X(t) {
|
|
51264
|
-
return t.map(([e, r]) => \`\${O(e)}=\${O(r)}\`).join("&");
|
|
51265
|
-
}
|
|
51266
52730
|
function Y(t) {
|
|
51267
|
-
return t.map(([e]) =>
|
|
52731
|
+
return t.map(([e, r]) => \`\${$(e)}=\${$(r)}\`).join("&");
|
|
52732
|
+
}
|
|
52733
|
+
function F(t) {
|
|
52734
|
+
return t.map(([e]) => $(e)).join(";");
|
|
51268
52735
|
}
|
|
51269
52736
|
async function V(t) {
|
|
51270
|
-
let e = t.method.toLowerCase(), r = t.pathname.startsWith("/") ? t.pathname : \`/\${t.pathname}\`, n = Math.floor(Date.now() / 1e3), s = n + (t.expireSeconds ?? 3600), i = \`\${n};\${s}\`, o =
|
|
52737
|
+
let e = t.method.toLowerCase(), r = t.pathname.startsWith("/") ? t.pathname : \`/\${t.pathname}\`, n = Math.floor(Date.now() / 1e3), s = n + (t.expireSeconds ?? 3600), i = \`\${n};\${s}\`, o = X(t.headers).filter(([N]) => xe(N)), c = F(o), d = Y(o), u = X(t.query), l = F(u), g = Y(u), p = \`\${e}
|
|
51271
52738
|
\${r}
|
|
51272
52739
|
\${g}
|
|
51273
52740
|
\${d}
|
|
51274
52741
|
\`, oe = \`sha1
|
|
51275
52742
|
\${i}
|
|
51276
52743
|
\${await pe(p)}
|
|
51277
|
-
\`, ie = await
|
|
51278
|
-
for (let [
|
|
51279
|
-
|
|
51280
|
-
return { authorization: ce, signedHeaders:
|
|
52744
|
+
\`, ie = await H(t.secretKey, i), ae = await H(ie, oe), ce = ["q-sign-algorithm=sha1", \`q-ak=\${t.secretId}\`, \`q-sign-time=\${i}\`, \`q-key-time=\${i}\`, \`q-header-list=\${c}\`, \`q-url-param-list=\${l}\`, \`q-signature=\${ae}\`].join("&"), q = {};
|
|
52745
|
+
for (let [N, de] of o)
|
|
52746
|
+
q[N] = de;
|
|
52747
|
+
return { authorization: ce, signedHeaders: q };
|
|
51281
52748
|
}
|
|
51282
52749
|
async function J(t) {
|
|
51283
|
-
let e = new URL(t.domain), r =
|
|
52750
|
+
let e = new URL(t.domain), r = P(t.key), n = \`/\${I(t.key)}\`, s = \`/\${W(r)}\`;
|
|
51284
52751
|
e.pathname = s;
|
|
51285
52752
|
let { authorization: i } = await V({ method: t.method, pathname: n, query: t.query, headers: t.headers, secretId: t.credential.secretId, secretKey: t.credential.secretKey, expireSeconds: t.expireSeconds });
|
|
51286
52753
|
if (t.query)
|
|
@@ -51296,7 +52763,7 @@ var require_dist = __commonJS({
|
|
|
51296
52763
|
return t.credential.sessionToken && e.searchParams.set("x-cos-security-token", t.credential.sessionToken), e.toString();
|
|
51297
52764
|
}
|
|
51298
52765
|
async function S(t) {
|
|
51299
|
-
let e = new URL(t.domain), r = t.key ?
|
|
52766
|
+
let e = new URL(t.domain), r = t.key ? P(t.key) : "", n = t.key ? \`/\${I(t.key)}\` : "/", s = r ? \`/\${W(r)}\` : "/";
|
|
51300
52767
|
if (e.pathname = s, t.query)
|
|
51301
52768
|
for (let [l, g] of Object.entries(t.query))
|
|
51302
52769
|
g != null && e.searchParams.set(l, String(g));
|
|
@@ -51316,9 +52783,9 @@ var require_dist = __commonJS({
|
|
|
51316
52783
|
}
|
|
51317
52784
|
throw u;
|
|
51318
52785
|
}
|
|
51319
|
-
var
|
|
51320
|
-
var
|
|
51321
|
-
var
|
|
52786
|
+
var be = "blob.edgeone.site";
|
|
52787
|
+
var Te = "blob-nocache.edgeone.site";
|
|
52788
|
+
var M = class t {
|
|
51322
52789
|
credentialManager;
|
|
51323
52790
|
bucket = "";
|
|
51324
52791
|
region = "";
|
|
@@ -51328,7 +52795,7 @@ var require_dist = __commonJS({
|
|
|
51328
52795
|
initialized = false;
|
|
51329
52796
|
static buildErrorDetail(e, r, n, s, i) {
|
|
51330
52797
|
let a = n ? \`\${r}/\${n}\` : r, o = i ? \` [request-id: \${i}]\` : "";
|
|
51331
|
-
return \`\${e} \${a} - \${
|
|
52798
|
+
return \`\${e} \${a} - \${Ee(s)}\${o}\`;
|
|
51332
52799
|
}
|
|
51333
52800
|
constructor(e) {
|
|
51334
52801
|
this.credentialManager = e;
|
|
@@ -51354,7 +52821,7 @@ var require_dist = __commonJS({
|
|
|
51354
52821
|
let a = this.computeSubdomain(e);
|
|
51355
52822
|
if (!a)
|
|
51356
52823
|
throw new f(0, "unable to derive tenant subdomain from credential; missing appId/zoneId/projectId or resourcePrefix");
|
|
51357
|
-
this.cachedDomain = \`https://\${a}.\${
|
|
52824
|
+
this.cachedDomain = \`https://\${a}.\${be}\`, this.uncachedDomain = \`https://\${a}.\${Te}\`, this.initialized = true;
|
|
51358
52825
|
}
|
|
51359
52826
|
async resolveDomain(e) {
|
|
51360
52827
|
return await this.ensureInitialized(), e === "strong" ? this.uncachedDomain : this.cachedDomain;
|
|
@@ -51378,14 +52845,14 @@ var require_dist = __commonJS({
|
|
|
51378
52845
|
return await l.arrayBuffer().catch(() => {
|
|
51379
52846
|
}), { etag: "", statusCode: 412 };
|
|
51380
52847
|
if (!l.ok) {
|
|
51381
|
-
let p = await
|
|
51382
|
-
throw new f(l.status, t.buildErrorDetail("PUT", i, o, p || \`status \${l.status}\`,
|
|
52848
|
+
let p = await k(l);
|
|
52849
|
+
throw new f(l.status, t.buildErrorDetail("PUT", i, o, p || \`status \${l.status}\`, R(l)));
|
|
51383
52850
|
}
|
|
51384
52851
|
let g = l.headers.get("etag") || "";
|
|
51385
52852
|
return await l.arrayBuffer().catch(() => {
|
|
51386
52853
|
}), { etag: g, statusCode: l.status };
|
|
51387
52854
|
} catch (l) {
|
|
51388
|
-
throw l instanceof f ? l : new f(0, t.buildErrorDetail("PUT", i, o,
|
|
52855
|
+
throw l instanceof f ? l : new f(0, t.buildErrorDetail("PUT", i, o, A(l)));
|
|
51389
52856
|
}
|
|
51390
52857
|
}
|
|
51391
52858
|
async createPresignedPutUrl(e, r, n) {
|
|
@@ -51402,13 +52869,13 @@ var require_dist = __commonJS({
|
|
|
51402
52869
|
return await o.arrayBuffer().catch(() => {
|
|
51403
52870
|
}), null;
|
|
51404
52871
|
if (!o.ok) {
|
|
51405
|
-
let u = await
|
|
51406
|
-
throw new f(o.status, t.buildErrorDetail("GET", s, a, u || \`status \${o.status}\`,
|
|
52872
|
+
let u = await k(o);
|
|
52873
|
+
throw new f(o.status, t.buildErrorDetail("GET", s, a, u || \`status \${o.status}\`, R(o)));
|
|
51407
52874
|
}
|
|
51408
52875
|
let c = new Uint8Array(await o.arrayBuffer()), d = Z(o.headers);
|
|
51409
52876
|
return { body: c, contentType: d["content-type"], headers: d };
|
|
51410
52877
|
} catch (o) {
|
|
51411
|
-
throw o instanceof f ? o : new f(0, t.buildErrorDetail("GET", s, a,
|
|
52878
|
+
throw o instanceof f ? o : new f(0, t.buildErrorDetail("GET", s, a, A(o)));
|
|
51412
52879
|
}
|
|
51413
52880
|
}
|
|
51414
52881
|
async headObject(e, r, n) {
|
|
@@ -51418,13 +52885,13 @@ var require_dist = __commonJS({
|
|
|
51418
52885
|
if (o.status === 404)
|
|
51419
52886
|
return null;
|
|
51420
52887
|
if (!o.ok) {
|
|
51421
|
-
let d = await
|
|
51422
|
-
throw new f(o.status, t.buildErrorDetail("HEAD", s, a, d || \`status \${o.status}\`,
|
|
52888
|
+
let d = await k(o);
|
|
52889
|
+
throw new f(o.status, t.buildErrorDetail("HEAD", s, a, d || \`status \${o.status}\`, R(o)));
|
|
51423
52890
|
}
|
|
51424
52891
|
let c = Z(o.headers);
|
|
51425
52892
|
return { cacheControl: c["cache-control"], contentType: c["content-type"], etag: c.etag, headers: c };
|
|
51426
52893
|
} catch (o) {
|
|
51427
|
-
throw o instanceof f ? o : new f(0, t.buildErrorDetail("HEAD", s, a,
|
|
52894
|
+
throw o instanceof f ? o : new f(0, t.buildErrorDetail("HEAD", s, a, A(o)));
|
|
51428
52895
|
}
|
|
51429
52896
|
}
|
|
51430
52897
|
async deleteObject(e, r) {
|
|
@@ -51436,10 +52903,10 @@ var require_dist = __commonJS({
|
|
|
51436
52903
|
});
|
|
51437
52904
|
return;
|
|
51438
52905
|
}
|
|
51439
|
-
let o = await
|
|
51440
|
-
throw new f(a.status, t.buildErrorDetail("DELETE", n, i, o || \`status \${a.status}\`,
|
|
52906
|
+
let o = await k(a);
|
|
52907
|
+
throw new f(a.status, t.buildErrorDetail("DELETE", n, i, o || \`status \${a.status}\`, R(a)));
|
|
51441
52908
|
} catch (a) {
|
|
51442
|
-
throw a instanceof f ? a : new f(0, t.buildErrorDetail("DELETE", n, i,
|
|
52909
|
+
throw a instanceof f ? a : new f(0, t.buildErrorDetail("DELETE", n, i, A(a)));
|
|
51443
52910
|
}
|
|
51444
52911
|
}
|
|
51445
52912
|
async listObjects(e, r) {
|
|
@@ -51465,35 +52932,35 @@ var require_dist = __commonJS({
|
|
|
51465
52932
|
return r;
|
|
51466
52933
|
}
|
|
51467
52934
|
async getBucketRaw(e) {
|
|
51468
|
-
let r = await this.resolveDomain(e.consistency), n = await this.resolveCredential(), s = { prefix: e.prefix };
|
|
51469
|
-
e.delimiter && (s.delimiter = e.delimiter), e.marker && (s.marker = e.marker), e.maxKeys && (s["max-keys"] = e.maxKeys);
|
|
52935
|
+
let r = await this.resolveDomain(e.consistency), n = await this.resolveCredential(), s = { prefix: I(e.prefix) };
|
|
52936
|
+
e.delimiter && (s.delimiter = e.delimiter), e.marker && (s.marker = I(e.marker)), e.maxKeys && (s["max-keys"] = e.maxKeys);
|
|
51470
52937
|
try {
|
|
51471
52938
|
let i = await S({ domain: r, method: "GET", query: s, credential: n });
|
|
51472
52939
|
if (!i.ok) {
|
|
51473
|
-
let o = await
|
|
51474
|
-
throw new f(i.status, t.buildErrorDetail("LIST", r, e.prefix, o || \`status \${i.status}\`,
|
|
52940
|
+
let o = await k(i);
|
|
52941
|
+
throw new f(i.status, t.buildErrorDetail("LIST", r, e.prefix, o || \`status \${i.status}\`, R(i)));
|
|
51475
52942
|
}
|
|
51476
52943
|
let a = await i.text();
|
|
51477
|
-
return
|
|
52944
|
+
return Se(a);
|
|
51478
52945
|
} catch (i) {
|
|
51479
|
-
throw i instanceof f ? i : new f(0, t.buildErrorDetail("LIST", r, e.prefix,
|
|
52946
|
+
throw i instanceof f ? i : new f(0, t.buildErrorDetail("LIST", r, e.prefix, A(i)));
|
|
51480
52947
|
}
|
|
51481
52948
|
}
|
|
51482
52949
|
};
|
|
51483
|
-
function
|
|
52950
|
+
function Ee(t) {
|
|
51484
52951
|
return t.replace(/[a-zA-Z0-9\\-]+\\.cos\\.[a-zA-Z0-9\\-.]+\\.myqcloud\\.com/gi, "[cos-origin]").replace(/[a-zA-Z0-9\\-]+\\.cos\\.[a-zA-Z0-9\\-.]+\\.tencentcos\\.cn/gi, "[cos-origin]");
|
|
51485
52952
|
}
|
|
51486
|
-
async function
|
|
52953
|
+
async function k(t) {
|
|
51487
52954
|
try {
|
|
51488
52955
|
return await t.text();
|
|
51489
52956
|
} catch {
|
|
51490
52957
|
return "";
|
|
51491
52958
|
}
|
|
51492
52959
|
}
|
|
51493
|
-
function
|
|
52960
|
+
function R(t) {
|
|
51494
52961
|
return t.headers.get("x-cos-request-id") || t.headers.get("x-eo-log-id") || void 0;
|
|
51495
52962
|
}
|
|
51496
|
-
function
|
|
52963
|
+
function A(t) {
|
|
51497
52964
|
let e = t, r = e.message || String(t), n = e.cause;
|
|
51498
52965
|
if (n) {
|
|
51499
52966
|
let s = n.message || n.code || "";
|
|
@@ -51507,43 +52974,43 @@ var require_dist = __commonJS({
|
|
|
51507
52974
|
e[n.toLowerCase()] = r;
|
|
51508
52975
|
}), e;
|
|
51509
52976
|
}
|
|
51510
|
-
function
|
|
52977
|
+
function Se(t) {
|
|
51511
52978
|
let e = [], r = /<Contents>([\\s\\S]*?)<\\/Contents>/g, n;
|
|
51512
52979
|
for (; (n = r.exec(t)) !== null; ) {
|
|
51513
|
-
let d = n[1], u =
|
|
51514
|
-
u !== null && e.push({ key:
|
|
52980
|
+
let d = n[1], u = v(d, "Key"), l = v(d, "ETag");
|
|
52981
|
+
u !== null && e.push({ key: L(u), etag: l || "" });
|
|
51515
52982
|
}
|
|
51516
52983
|
let s = [], i = /<CommonPrefixes>([\\s\\S]*?)<\\/CommonPrefixes>/g;
|
|
51517
52984
|
for (; (n = i.exec(t)) !== null; ) {
|
|
51518
|
-
let d = n[1], u =
|
|
51519
|
-
u !== null && s.push(
|
|
52985
|
+
let d = n[1], u = v(d, "Prefix");
|
|
52986
|
+
u !== null && s.push(L(u));
|
|
51520
52987
|
}
|
|
51521
|
-
let o =
|
|
51522
|
-
return { contents: e, commonPrefixes: s, isTruncated: o, nextMarker:
|
|
52988
|
+
let o = v(t, "IsTruncated") === "true", c = v(t, "NextMarker") || "";
|
|
52989
|
+
return { contents: e, commonPrefixes: s, isTruncated: o, nextMarker: L(c) };
|
|
51523
52990
|
}
|
|
51524
|
-
function
|
|
52991
|
+
function v(t, e) {
|
|
51525
52992
|
let n = new RegExp(\`<\${e}>([\\\\s\\\\S]*?)<\\\\/\${e}>\`).exec(t);
|
|
51526
52993
|
return n ? n[1] : null;
|
|
51527
52994
|
}
|
|
51528
|
-
function
|
|
52995
|
+
function L(t) {
|
|
51529
52996
|
return t.replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/'/g, "'").replace(/&/g, "&");
|
|
51530
52997
|
}
|
|
51531
|
-
var
|
|
51532
|
-
async function
|
|
52998
|
+
var Pe = "X-RateLimit-Reset";
|
|
52999
|
+
async function B(t, e, r = 2) {
|
|
51533
53000
|
var _a3, _b;
|
|
51534
53001
|
(_b = (_a3 = e.signal) == null ? void 0 : _a3.throwIfAborted) == null ? void 0 : _b.call(_a3);
|
|
51535
53002
|
try {
|
|
51536
53003
|
let n = await fetch(t, e);
|
|
51537
53004
|
if (r > 0 && (n.status === 429 || n.status >= 500)) {
|
|
51538
|
-
let s = Q(n.headers.get(
|
|
51539
|
-
return await ee(s, e.signal),
|
|
53005
|
+
let s = Q(n.headers.get(Pe));
|
|
53006
|
+
return await ee(s, e.signal), B(t, e, r - 1);
|
|
51540
53007
|
}
|
|
51541
53008
|
return n;
|
|
51542
53009
|
} catch (n) {
|
|
51543
53010
|
if (r === 0 || n instanceof DOMException && n.name === "AbortError")
|
|
51544
53011
|
throw n;
|
|
51545
53012
|
let s = Q();
|
|
51546
|
-
return await ee(s, e.signal),
|
|
53013
|
+
return await ee(s, e.signal), B(t, e, r - 1);
|
|
51547
53014
|
}
|
|
51548
53015
|
}
|
|
51549
53016
|
function Q(t) {
|
|
@@ -51561,14 +53028,14 @@ var require_dist = __commonJS({
|
|
|
51561
53028
|
e == null ? void 0 : e.addEventListener("abort", i, { once: true });
|
|
51562
53029
|
});
|
|
51563
53030
|
}
|
|
51564
|
-
var
|
|
53031
|
+
var Ie = "prod";
|
|
51565
53032
|
function te() {
|
|
51566
53033
|
let t = typeof process < "u" ? process.env.PAGES_BLOB_STS_ENV : void 0;
|
|
51567
|
-
return t === "test" || t === "prod" ? t :
|
|
53034
|
+
return t === "test" || t === "prod" ? t : Ie;
|
|
51568
53035
|
}
|
|
51569
|
-
var
|
|
51570
|
-
var
|
|
51571
|
-
var
|
|
53036
|
+
var ke = 300;
|
|
53037
|
+
var Re = "https://blob-sts.edgeone.site/";
|
|
53038
|
+
var D = class {
|
|
51572
53039
|
authToken;
|
|
51573
53040
|
projectId;
|
|
51574
53041
|
cached = null;
|
|
@@ -51586,16 +53053,16 @@ var require_dist = __commonJS({
|
|
|
51586
53053
|
}
|
|
51587
53054
|
isExpired(e) {
|
|
51588
53055
|
let r = Math.floor(Date.now() / 1e3);
|
|
51589
|
-
return e.expiredTime - r <
|
|
53056
|
+
return e.expiredTime - r < ke;
|
|
51590
53057
|
}
|
|
51591
53058
|
async fetchCredential() {
|
|
51592
53059
|
for (let n = 1; n <= 3; n++) {
|
|
51593
53060
|
let s = new AbortController(), i = setTimeout(() => s.abort(), 1e4), a;
|
|
51594
53061
|
try {
|
|
51595
|
-
a = await
|
|
53062
|
+
a = await B(Re, { method: "POST", headers: { "Content-Type": "application/json", Authorization: \`Bearer \${this.authToken}\`, "X-Env": te() }, body: JSON.stringify(this.projectId ? { ProjectId: this.projectId } : {}), signal: s.signal });
|
|
51596
53063
|
} catch (d) {
|
|
51597
53064
|
if (n < 3) {
|
|
51598
|
-
await
|
|
53065
|
+
await K(500 * n);
|
|
51599
53066
|
continue;
|
|
51600
53067
|
}
|
|
51601
53068
|
throw new m(\`failed to obtain STS credential: \${d.message || "timeout"}\`);
|
|
@@ -51608,7 +53075,7 @@ var require_dist = __commonJS({
|
|
|
51608
53075
|
throw new m("rate limited, please retry later");
|
|
51609
53076
|
if (!a.ok) {
|
|
51610
53077
|
if (a.status >= 500 && n < 3) {
|
|
51611
|
-
await
|
|
53078
|
+
await K(500 * n);
|
|
51612
53079
|
continue;
|
|
51613
53080
|
}
|
|
51614
53081
|
let d = await a.text().catch(() => "unknown error");
|
|
@@ -51628,7 +53095,7 @@ var require_dist = __commonJS({
|
|
|
51628
53095
|
throw new m(\`credential exchange failed (code=\${o.code}): \${d}\`);
|
|
51629
53096
|
}
|
|
51630
53097
|
if (n < 3) {
|
|
51631
|
-
await
|
|
53098
|
+
await K(500 * n);
|
|
51632
53099
|
continue;
|
|
51633
53100
|
}
|
|
51634
53101
|
throw new m("invalid STS credential response");
|
|
@@ -51636,12 +53103,12 @@ var require_dist = __commonJS({
|
|
|
51636
53103
|
throw new m("invalid STS credential response");
|
|
51637
53104
|
}
|
|
51638
53105
|
};
|
|
51639
|
-
function
|
|
53106
|
+
function K(t) {
|
|
51640
53107
|
return new Promise((e) => setTimeout(e, t));
|
|
51641
53108
|
}
|
|
51642
|
-
var
|
|
53109
|
+
var Ae = "{{PAGES_BLOB_DEPLOY_CREDENTIAL}}";
|
|
51643
53110
|
function re() {
|
|
51644
|
-
let t = {}, e =
|
|
53111
|
+
let t = {}, e = ve();
|
|
51645
53112
|
if (e)
|
|
51646
53113
|
t.deployCredential = e;
|
|
51647
53114
|
else {
|
|
@@ -51651,8 +53118,8 @@ var require_dist = __commonJS({
|
|
|
51651
53118
|
let r = ne("PAGES_PROJECT_ID");
|
|
51652
53119
|
return r && (t.projectId = r), t;
|
|
51653
53120
|
}
|
|
51654
|
-
function
|
|
51655
|
-
let t =
|
|
53121
|
+
function ve() {
|
|
53122
|
+
let t = Ae;
|
|
51656
53123
|
if (!(t.startsWith("{{") && t.endsWith("}}")))
|
|
51657
53124
|
return t || void 0;
|
|
51658
53125
|
}
|
|
@@ -51660,15 +53127,15 @@ var require_dist = __commonJS({
|
|
|
51660
53127
|
if (typeof process < "u" && process.env)
|
|
51661
53128
|
return process.env[t];
|
|
51662
53129
|
}
|
|
51663
|
-
function
|
|
53130
|
+
function Me(t) {
|
|
51664
53131
|
let e = typeof t == "string" ? t : t.name;
|
|
51665
|
-
|
|
51666
|
-
let r = se(typeof t == "string" ? void 0 : t), n = new
|
|
53132
|
+
z2(e);
|
|
53133
|
+
let r = se(typeof t == "string" ? void 0 : t), n = new D(r.authToken, r.projectId), s = new M(n);
|
|
51667
53134
|
return new E(s, e, r.consistency ?? "eventual");
|
|
51668
53135
|
}
|
|
51669
|
-
async function
|
|
51670
|
-
let e = se(t ? { name: "__list__", projectId: t.projectId, token: t.token, consistency: t.consistency } : void 0), r = new
|
|
51671
|
-
return { stores: (await new
|
|
53136
|
+
async function De(t) {
|
|
53137
|
+
let e = se(t ? { name: "__list__", projectId: t.projectId, token: t.token, consistency: t.consistency } : void 0), r = new D(e.authToken, e.projectId);
|
|
53138
|
+
return { stores: (await new M(r).listStores(e.consistency)).map((i) => ({ name: i })) };
|
|
51672
53139
|
}
|
|
51673
53140
|
function se(t) {
|
|
51674
53141
|
let e = re(), r = (t == null ? void 0 : t.token) || e.deployCredential, n = (t == null ? void 0 : t.projectId) || e.projectId;
|
|
@@ -63726,6 +65193,9 @@ var LANGGRAPH_STORE_PREFIX = "langgraph_store";
|
|
|
63726
65193
|
var LANGGRAPH_STORE_KEY_SEPARATOR = "__key__";
|
|
63727
65194
|
var LANGGRAPH_SERDE_VERSION = 1;
|
|
63728
65195
|
var CLAUDE_SESSION_PREFIX = "claude_sessions";
|
|
65196
|
+
var CLAUDE_SESSION_MAPPING_PREFIX = "claude_session_mapping";
|
|
65197
|
+
var STATE_PREFIX = "state";
|
|
65198
|
+
var MAX_STATE_KEY_LENGTH = 256;
|
|
63729
65199
|
var SESSION_METADATA_MARKER = { agent_sdk_session: true };
|
|
63730
65200
|
var VALID_ROLES = /* @__PURE__ */ new Set([
|
|
63731
65201
|
"user",
|
|
@@ -63772,6 +65242,15 @@ var MemoryStorageError = class extends Error {
|
|
|
63772
65242
|
this.cause = cause;
|
|
63773
65243
|
}
|
|
63774
65244
|
};
|
|
65245
|
+
var MemoryCorruptError = class extends Error {
|
|
65246
|
+
code = "MemoryCorruptError";
|
|
65247
|
+
cause;
|
|
65248
|
+
constructor(message, cause) {
|
|
65249
|
+
super(message);
|
|
65250
|
+
this.name = "MemoryCorruptError";
|
|
65251
|
+
this.cause = cause;
|
|
65252
|
+
}
|
|
65253
|
+
};
|
|
63775
65254
|
var dynamicImport = new Function(
|
|
63776
65255
|
"specifier",
|
|
63777
65256
|
"return import(specifier);"
|
|
@@ -63779,7 +65258,7 @@ var dynamicImport = new Function(
|
|
|
63779
65258
|
var langchainLoadPromise;
|
|
63780
65259
|
var langchainMessagesPromise;
|
|
63781
65260
|
function isMemoryError(error51) {
|
|
63782
|
-
return error51 instanceof MemoryValidationError || error51 instanceof MemoryNotFoundError || error51 instanceof MemoryQuotaExceededError || error51 instanceof MemoryStorageError;
|
|
65261
|
+
return error51 instanceof MemoryValidationError || error51 instanceof MemoryNotFoundError || error51 instanceof MemoryQuotaExceededError || error51 instanceof MemoryStorageError || error51 instanceof MemoryCorruptError;
|
|
63783
65262
|
}
|
|
63784
65263
|
async function wrapStorage(operation) {
|
|
63785
65264
|
try {
|
|
@@ -63947,10 +65426,17 @@ async function reviveLangGraphJsonValue(value) {
|
|
|
63947
65426
|
return revived;
|
|
63948
65427
|
}
|
|
63949
65428
|
async function deserializeLangGraphJson(value) {
|
|
63950
|
-
|
|
63951
|
-
|
|
65429
|
+
try {
|
|
65430
|
+
if (isLangGraphSerializedJson(value)) {
|
|
65431
|
+
return reviveLangGraphJsonValue(JSON.parse(value.data));
|
|
65432
|
+
}
|
|
65433
|
+
return reviveLangGraphJsonValue(value);
|
|
65434
|
+
} catch (error51) {
|
|
65435
|
+
throw new MemoryCorruptError(
|
|
65436
|
+
"LangGraph persisted state is corrupt or incompatible.",
|
|
65437
|
+
error51
|
|
65438
|
+
);
|
|
63952
65439
|
}
|
|
63953
|
-
return reviveLangGraphJsonValue(value);
|
|
63954
65440
|
}
|
|
63955
65441
|
function normalizeStoreLimit(value, fallback) {
|
|
63956
65442
|
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
@@ -64062,6 +65548,115 @@ function validateMessageId(messageId) {
|
|
|
64062
65548
|
throw new MemoryValidationError("messageId is required.");
|
|
64063
65549
|
}
|
|
64064
65550
|
}
|
|
65551
|
+
function validateStateKey(key) {
|
|
65552
|
+
if (typeof key !== "string" || key.length === 0) {
|
|
65553
|
+
throw new MemoryValidationError("state key is required.");
|
|
65554
|
+
}
|
|
65555
|
+
if (key.length > MAX_STATE_KEY_LENGTH) {
|
|
65556
|
+
throw new MemoryValidationError(
|
|
65557
|
+
\`state key must be at most \${MAX_STATE_KEY_LENGTH} characters.\`
|
|
65558
|
+
);
|
|
65559
|
+
}
|
|
65560
|
+
}
|
|
65561
|
+
function assertStateSerializable(value, path2 = "state value", seen = /* @__PURE__ */ new Set()) {
|
|
65562
|
+
if (value === null || typeof value === "string" || typeof value === "boolean") {
|
|
65563
|
+
return;
|
|
65564
|
+
}
|
|
65565
|
+
if (typeof value === "number") {
|
|
65566
|
+
if (Number.isFinite(value))
|
|
65567
|
+
return;
|
|
65568
|
+
throw new MemoryValidationError(\`\${path2} must contain only JSON values.\`);
|
|
65569
|
+
}
|
|
65570
|
+
if (value === void 0 || typeof value === "function" || typeof value === "symbol" || typeof value === "bigint") {
|
|
65571
|
+
throw new MemoryValidationError(\`\${path2} must be JSON serializable.\`);
|
|
65572
|
+
}
|
|
65573
|
+
if (typeof value !== "object") {
|
|
65574
|
+
throw new MemoryValidationError(\`\${path2} must be JSON serializable.\`);
|
|
65575
|
+
}
|
|
65576
|
+
if (seen.has(value)) {
|
|
65577
|
+
throw new MemoryValidationError(\`\${path2} must not contain circular references.\`);
|
|
65578
|
+
}
|
|
65579
|
+
seen.add(value);
|
|
65580
|
+
if (Array.isArray(value)) {
|
|
65581
|
+
value.forEach((item, index) => assertStateSerializable(item, \`\${path2}[\${index}]\`, seen));
|
|
65582
|
+
} else if (isPlainObject(value)) {
|
|
65583
|
+
for (const [key, item] of Object.entries(value)) {
|
|
65584
|
+
assertStateSerializable(item, \`\${path2}.\${key}\`, seen);
|
|
65585
|
+
}
|
|
65586
|
+
} else {
|
|
65587
|
+
throw new MemoryValidationError(\`\${path2} must contain only JSON values.\`);
|
|
65588
|
+
}
|
|
65589
|
+
seen.delete(value);
|
|
65590
|
+
}
|
|
65591
|
+
function stateConversationPrefix(conversationId) {
|
|
65592
|
+
return \`\${STATE_PREFIX}/\${encodeKeySegment(conversationId)}/\`;
|
|
65593
|
+
}
|
|
65594
|
+
function createAgentStateStore(store, boundConversationId) {
|
|
65595
|
+
const requireConversation = () => {
|
|
65596
|
+
if (!boundConversationId) {
|
|
65597
|
+
throw new MemoryValidationError(
|
|
65598
|
+
"State operations require a bound conversationId."
|
|
65599
|
+
);
|
|
65600
|
+
}
|
|
65601
|
+
validateConversationId(boundConversationId);
|
|
65602
|
+
return boundConversationId;
|
|
65603
|
+
};
|
|
65604
|
+
return {
|
|
65605
|
+
async get(key) {
|
|
65606
|
+
validateStateKey(key);
|
|
65607
|
+
const conversationId = requireConversation();
|
|
65608
|
+
return wrapStorage(async () => {
|
|
65609
|
+
const raw = await store.get(
|
|
65610
|
+
\`\${stateConversationPrefix(conversationId)}\${encodeKeySegment(key)}\`,
|
|
65611
|
+
{ consistency: "strong" }
|
|
65612
|
+
);
|
|
65613
|
+
if (raw === null)
|
|
65614
|
+
return null;
|
|
65615
|
+
if (typeof raw !== "string") {
|
|
65616
|
+
throw new MemoryStorageError("Stored state value is not valid JSON text.");
|
|
65617
|
+
}
|
|
65618
|
+
try {
|
|
65619
|
+
return JSON.parse(raw);
|
|
65620
|
+
} catch (error51) {
|
|
65621
|
+
throw new MemoryStorageError("Stored state value is invalid JSON.", error51);
|
|
65622
|
+
}
|
|
65623
|
+
});
|
|
65624
|
+
},
|
|
65625
|
+
async set(key, value) {
|
|
65626
|
+
validateStateKey(key);
|
|
65627
|
+
const conversationId = requireConversation();
|
|
65628
|
+
assertStateSerializable(value);
|
|
65629
|
+
let serialized;
|
|
65630
|
+
try {
|
|
65631
|
+
serialized = JSON.stringify(value);
|
|
65632
|
+
} catch (error51) {
|
|
65633
|
+
throw new MemoryValidationError(\`state value must be JSON serializable: \${String(error51)}\`);
|
|
65634
|
+
}
|
|
65635
|
+
await wrapStorage(
|
|
65636
|
+
() => store.set(
|
|
65637
|
+
\`\${stateConversationPrefix(conversationId)}\${encodeKeySegment(key)}\`,
|
|
65638
|
+
serialized
|
|
65639
|
+
)
|
|
65640
|
+
);
|
|
65641
|
+
},
|
|
65642
|
+
async delete(key) {
|
|
65643
|
+
validateStateKey(key);
|
|
65644
|
+
const conversationId = requireConversation();
|
|
65645
|
+
await wrapStorage(
|
|
65646
|
+
() => store.delete(
|
|
65647
|
+
\`\${stateConversationPrefix(conversationId)}\${encodeKeySegment(key)}\`
|
|
65648
|
+
)
|
|
65649
|
+
);
|
|
65650
|
+
}
|
|
65651
|
+
};
|
|
65652
|
+
}
|
|
65653
|
+
async function deleteAgentState(store, conversationId) {
|
|
65654
|
+
const listed = await store.list({
|
|
65655
|
+
prefix: stateConversationPrefix(conversationId),
|
|
65656
|
+
consistency: "strong"
|
|
65657
|
+
});
|
|
65658
|
+
await Promise.all(listed.keys.map((key) => store.delete(key)));
|
|
65659
|
+
}
|
|
64065
65660
|
function validateUserId(userId) {
|
|
64066
65661
|
if (userId === void 0) {
|
|
64067
65662
|
return;
|
|
@@ -64194,6 +65789,9 @@ function cursorSortKey(cursor) {
|
|
|
64194
65789
|
const payload = decodeConversationCursor(cursor);
|
|
64195
65790
|
return \`\${reverseTimestamp(payload.lastMessageAt)}_\${encodeKeySegment(payload.conversationId)}\`;
|
|
64196
65791
|
}
|
|
65792
|
+
function cursorListCursor(cursor) {
|
|
65793
|
+
return cursor ? decodeConversationCursor(cursor).listCursor : void 0;
|
|
65794
|
+
}
|
|
64197
65795
|
function indexSortKey(key, prefix) {
|
|
64198
65796
|
return key.slice(prefix.length);
|
|
64199
65797
|
}
|
|
@@ -64361,6 +65959,51 @@ function claudeSessionBase(projectKey, sessionId) {
|
|
|
64361
65959
|
function claudeProjectPrefix(projectKey) {
|
|
64362
65960
|
return \`\${CLAUDE_SESSION_PREFIX}/\${encodeKeySegment(projectKey)}/\`;
|
|
64363
65961
|
}
|
|
65962
|
+
function claudeSessionMappingKey(conversationId) {
|
|
65963
|
+
return \`\${CLAUDE_SESSION_MAPPING_PREFIX}/\${encodeKeySegment(conversationId)}\`;
|
|
65964
|
+
}
|
|
65965
|
+
function normalizeClaudeUuid(value) {
|
|
65966
|
+
const trimmed = value.trim().toLowerCase();
|
|
65967
|
+
return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/.test(trimmed) ? trimmed : null;
|
|
65968
|
+
}
|
|
65969
|
+
function claudeSessionIdFromKey(key) {
|
|
65970
|
+
const prefix = \`\${CLAUDE_SESSION_PREFIX}/\`;
|
|
65971
|
+
if (!key.startsWith(prefix)) {
|
|
65972
|
+
return null;
|
|
65973
|
+
}
|
|
65974
|
+
const segments = key.slice(prefix.length).split("/");
|
|
65975
|
+
return segments.length >= 3 && segments[1] ? decodeKeySegment(segments[1]) : null;
|
|
65976
|
+
}
|
|
65977
|
+
async function deleteClaudeSessionForConversation(store, conversationId) {
|
|
65978
|
+
const mappingKey = claudeSessionMappingKey(conversationId);
|
|
65979
|
+
const mapping = await store.get(mappingKey, {
|
|
65980
|
+
consistency: "strong"
|
|
65981
|
+
});
|
|
65982
|
+
let sessionId = null;
|
|
65983
|
+
if (typeof mapping === "string") {
|
|
65984
|
+
sessionId = mapping;
|
|
65985
|
+
} else if (isPlainObject(mapping) && typeof mapping.sessionId === "string") {
|
|
65986
|
+
sessionId = mapping.sessionId;
|
|
65987
|
+
} else if (isPlainObject(mapping) && typeof mapping.session_id === "string") {
|
|
65988
|
+
sessionId = mapping.session_id;
|
|
65989
|
+
}
|
|
65990
|
+
if (!sessionId) {
|
|
65991
|
+
sessionId = normalizeClaudeUuid(conversationId);
|
|
65992
|
+
}
|
|
65993
|
+
await store.delete(mappingKey);
|
|
65994
|
+
if (!sessionId) {
|
|
65995
|
+
return;
|
|
65996
|
+
}
|
|
65997
|
+
const listed = await store.list({
|
|
65998
|
+
prefix: \`\${CLAUDE_SESSION_PREFIX}/\`,
|
|
65999
|
+
consistency: "strong"
|
|
66000
|
+
});
|
|
66001
|
+
for (const key of listed.keys) {
|
|
66002
|
+
if (claudeSessionIdFromKey(key) === sessionId) {
|
|
66003
|
+
await store.delete(key);
|
|
66004
|
+
}
|
|
66005
|
+
}
|
|
66006
|
+
}
|
|
64364
66007
|
function claudePartsPrefix(key) {
|
|
64365
66008
|
let base = claudeSessionBase(key.projectKey, key.sessionId).slice(0, -1);
|
|
64366
66009
|
if (key.subpath) {
|
|
@@ -64398,7 +66041,9 @@ function createClaudeSessionStore(store) {
|
|
|
64398
66041
|
consistency: "strong"
|
|
64399
66042
|
});
|
|
64400
66043
|
if (typeof raw !== "string") {
|
|
64401
|
-
|
|
66044
|
+
throw new MemoryCorruptError(
|
|
66045
|
+
\`Claude session part '\${partKey}' is not valid JSONL text.\`
|
|
66046
|
+
);
|
|
64402
66047
|
}
|
|
64403
66048
|
for (const line of raw.split("\\n")) {
|
|
64404
66049
|
const trimmed = line.trim();
|
|
@@ -64407,7 +66052,11 @@ function createClaudeSessionStore(store) {
|
|
|
64407
66052
|
}
|
|
64408
66053
|
try {
|
|
64409
66054
|
entries.push(JSON.parse(trimmed));
|
|
64410
|
-
} catch {
|
|
66055
|
+
} catch (error51) {
|
|
66056
|
+
throw new MemoryCorruptError(
|
|
66057
|
+
\`Claude session part '\${partKey}' contains malformed JSONL.\`,
|
|
66058
|
+
error51
|
|
66059
|
+
);
|
|
64411
66060
|
}
|
|
64412
66061
|
}
|
|
64413
66062
|
}
|
|
@@ -64533,8 +66182,70 @@ async function listConversationsByUser(store, userId, options) {
|
|
|
64533
66182
|
});
|
|
64534
66183
|
}
|
|
64535
66184
|
async function listConversationsFromIndex(store, options) {
|
|
66185
|
+
if (!options.before) {
|
|
66186
|
+
const fast = await listConversationsFromIndexFast(store, options);
|
|
66187
|
+
if (fast)
|
|
66188
|
+
return fast;
|
|
66189
|
+
}
|
|
64536
66190
|
return listConversationsFromIndexFull(store, options);
|
|
64537
66191
|
}
|
|
66192
|
+
async function listConversationsFromIndexFast(store, options) {
|
|
66193
|
+
var _a3, _b;
|
|
66194
|
+
let listCursor = cursorListCursor(options.after);
|
|
66195
|
+
if (options.after && !listCursor) {
|
|
66196
|
+
return null;
|
|
66197
|
+
}
|
|
66198
|
+
const pageItems = [];
|
|
66199
|
+
const seen = /* @__PURE__ */ new Set();
|
|
66200
|
+
let lastCursor;
|
|
66201
|
+
while (pageItems.length < options.limit) {
|
|
66202
|
+
const listed = await store.list({
|
|
66203
|
+
prefix: options.prefix,
|
|
66204
|
+
cursor: listCursor,
|
|
66205
|
+
limit: options.limit - pageItems.length,
|
|
66206
|
+
paginate: false,
|
|
66207
|
+
consistency: "strong"
|
|
66208
|
+
});
|
|
66209
|
+
lastCursor = listed.cursor;
|
|
66210
|
+
if (!listed.keys.length) {
|
|
66211
|
+
break;
|
|
66212
|
+
}
|
|
66213
|
+
const indexItems = [...listed.keys].sort(
|
|
66214
|
+
(left, right) => options.order === "desc" ? left.localeCompare(right) : right.localeCompare(left)
|
|
66215
|
+
).map((key) => {
|
|
66216
|
+
const conversationId = options.conversationIdFromKey(key);
|
|
66217
|
+
if (!conversationId || seen.has(conversationId)) {
|
|
66218
|
+
return null;
|
|
66219
|
+
}
|
|
66220
|
+
seen.add(conversationId);
|
|
66221
|
+
return {
|
|
66222
|
+
key,
|
|
66223
|
+
sortKey: indexSortKey(key, options.prefix),
|
|
66224
|
+
conversationId
|
|
66225
|
+
};
|
|
66226
|
+
}).filter((item) => item !== null);
|
|
66227
|
+
const metas = await Promise.all(
|
|
66228
|
+
indexItems.map((item) => readConversationMeta(store, item.conversationId))
|
|
66229
|
+
);
|
|
66230
|
+
for (let i = 0; i < indexItems.length; i++) {
|
|
66231
|
+
const meta3 = metas[i];
|
|
66232
|
+
if (meta3) {
|
|
66233
|
+
pageItems.push({ indexItem: indexItems[i], meta: meta3 });
|
|
66234
|
+
}
|
|
66235
|
+
}
|
|
66236
|
+
if (!listed.cursor) {
|
|
66237
|
+
break;
|
|
66238
|
+
}
|
|
66239
|
+
listCursor = listed.cursor;
|
|
66240
|
+
}
|
|
66241
|
+
const firstItem = (_a3 = pageItems[0]) == null ? void 0 : _a3.indexItem;
|
|
66242
|
+
const lastItem = (_b = pageItems[pageItems.length - 1]) == null ? void 0 : _b.indexItem;
|
|
66243
|
+
return {
|
|
66244
|
+
items: pageItems.map((item) => item.meta),
|
|
66245
|
+
nextCursor: lastItem ? encodeConversationCursorFromIndexItem(lastItem, lastCursor) : void 0,
|
|
66246
|
+
previousCursor: firstItem ? encodeConversationCursorFromIndexItem(firstItem) : void 0
|
|
66247
|
+
};
|
|
66248
|
+
}
|
|
64538
66249
|
async function listConversationsFromIndexFull(store, options) {
|
|
64539
66250
|
var _a3, _b;
|
|
64540
66251
|
const afterSortKey = options.after ? cursorSortKey(options.after) : void 0;
|
|
@@ -64971,6 +66682,7 @@ function createAgentMemory(store, options = {}) {
|
|
|
64971
66682
|
const maxMessagesPerConversation = options.maxMessagesPerConversation ?? DEFAULT_MAX_MESSAGES_PER_CONVERSATION;
|
|
64972
66683
|
const langgraphCheckpointer = createLangGraphCheckpointer(store);
|
|
64973
66684
|
const langgraphStore = createLangGraphStore(store);
|
|
66685
|
+
const state = createAgentStateStore(store, options.conversationId);
|
|
64974
66686
|
let claudeStoreCache = null;
|
|
64975
66687
|
let lastMessageCreatedAt = 0;
|
|
64976
66688
|
const appendMessagesInternal = async (inputs) => {
|
|
@@ -65256,8 +66968,13 @@ function createAgentMemory(store, options = {}) {
|
|
|
65256
66968
|
listMessageKeys(store, input.conversationId)
|
|
65257
66969
|
]);
|
|
65258
66970
|
if (!meta3) {
|
|
66971
|
+
if (options.conversationId === input.conversationId) {
|
|
66972
|
+
await deleteAgentState(store, input.conversationId);
|
|
66973
|
+
}
|
|
66974
|
+
await deleteClaudeSessionForConversation(store, input.conversationId);
|
|
66975
|
+
await langgraphCheckpointer.deleteThread(input.conversationId);
|
|
65259
66976
|
throw new MemoryNotFoundError(
|
|
65260
|
-
"Conversation not found by
|
|
66977
|
+
"Conversation not found by deleteConversation."
|
|
65261
66978
|
);
|
|
65262
66979
|
}
|
|
65263
66980
|
const deleteOps = [];
|
|
@@ -65274,6 +66991,11 @@ function createAgentMemory(store, options = {}) {
|
|
|
65274
66991
|
deleteOps.push(store.delete(metaKey(input.conversationId)));
|
|
65275
66992
|
deleteOps.push(store.delete(conversationIndexKey(meta3)));
|
|
65276
66993
|
await Promise.all(deleteOps);
|
|
66994
|
+
if (options.conversationId === input.conversationId) {
|
|
66995
|
+
await deleteAgentState(store, input.conversationId);
|
|
66996
|
+
}
|
|
66997
|
+
await deleteClaudeSessionForConversation(store, input.conversationId);
|
|
66998
|
+
await langgraphCheckpointer.deleteThread(input.conversationId);
|
|
65277
66999
|
});
|
|
65278
67000
|
},
|
|
65279
67001
|
async updateConversation(input) {
|
|
@@ -65309,14 +67031,49 @@ function createAgentMemory(store, options = {}) {
|
|
|
65309
67031
|
}));
|
|
65310
67032
|
},
|
|
65311
67033
|
openaiSession(sessionId, sessionOptions = {}) {
|
|
67034
|
+
const boundSessionId = sessionId ?? options.conversationId;
|
|
67035
|
+
if (!boundSessionId) {
|
|
67036
|
+
throw new MemoryValidationError(
|
|
67037
|
+
"openaiSession requires a sessionId or bound conversationId."
|
|
67038
|
+
);
|
|
67039
|
+
}
|
|
65312
67040
|
const maxItems = sessionOptions.maxItems ?? MAX_LIMIT;
|
|
65313
67041
|
return createOpenAISession(
|
|
65314
67042
|
memory,
|
|
65315
|
-
|
|
67043
|
+
boundSessionId,
|
|
65316
67044
|
maxItems,
|
|
65317
67045
|
appendMessagesInternal
|
|
65318
67046
|
);
|
|
65319
67047
|
},
|
|
67048
|
+
async claudeSessionBinding(conversationId) {
|
|
67049
|
+
const resolvedConversationId = conversationId ?? options.conversationId;
|
|
67050
|
+
if (!resolvedConversationId) {
|
|
67051
|
+
throw new MemoryValidationError(
|
|
67052
|
+
"claudeSessionBinding requires a conversationId or bound conversationId."
|
|
67053
|
+
);
|
|
67054
|
+
}
|
|
67055
|
+
validateConversationId(resolvedConversationId);
|
|
67056
|
+
return wrapStorage(async () => {
|
|
67057
|
+
const mappingKey = claudeSessionMappingKey(resolvedConversationId);
|
|
67058
|
+
const existing = await store.get(
|
|
67059
|
+
mappingKey,
|
|
67060
|
+
{ consistency: "strong" }
|
|
67061
|
+
);
|
|
67062
|
+
if (typeof existing === "string" && existing) {
|
|
67063
|
+
return existing;
|
|
67064
|
+
}
|
|
67065
|
+
if (isPlainObject(existing) && (typeof existing.sessionId === "string" || typeof existing.session_id === "string") && (existing.sessionId || existing.session_id)) {
|
|
67066
|
+
return String(existing.sessionId || existing.session_id);
|
|
67067
|
+
}
|
|
67068
|
+
const sessionId = normalizeClaudeUuid(resolvedConversationId) ?? randomUUID();
|
|
67069
|
+
const binding = {
|
|
67070
|
+
conversationId: resolvedConversationId,
|
|
67071
|
+
sessionId
|
|
67072
|
+
};
|
|
67073
|
+
await store.set(mappingKey, binding);
|
|
67074
|
+
return sessionId;
|
|
67075
|
+
});
|
|
67076
|
+
},
|
|
65320
67077
|
claudeSessionStore() {
|
|
65321
67078
|
if (!claudeStoreCache) {
|
|
65322
67079
|
claudeStoreCache = createClaudeSessionStore(store);
|
|
@@ -65324,7 +67081,8 @@ function createAgentMemory(store, options = {}) {
|
|
|
65324
67081
|
return claudeStoreCache;
|
|
65325
67082
|
},
|
|
65326
67083
|
langgraphCheckpointer,
|
|
65327
|
-
langgraphStore
|
|
67084
|
+
langgraphStore,
|
|
67085
|
+
state
|
|
65328
67086
|
};
|
|
65329
67087
|
return memory;
|
|
65330
67088
|
}
|
|
@@ -66005,6 +67763,7 @@ function createAgentRuntime(options) {
|
|
|
66005
67763
|
env,
|
|
66006
67764
|
store: createAgentMemory(createLazyStore(resolveMemoryStore), {
|
|
66007
67765
|
runId: run_id,
|
|
67766
|
+
conversationId: conversation_id,
|
|
66008
67767
|
maxMessagesPerConversation: (_a3 = defaults2 == null ? void 0 : defaults2.memoryQuota) == null ? void 0 : _a3.maxMessagesPerConversation
|
|
66009
67768
|
}),
|
|
66010
67769
|
agents: {
|