UNPKG

@imgly/plugin-ai-text-generation-web

Version:

AI text generation plugin for the CE.SDK editor

66 lines (62 loc) 72.4 kB
var Br=typeof global=="object"&&global&&global.Object===Object&&global,rr=Br,Ur=typeof self=="object"&&self&&self.Object===Object&&self,Fr=rr||Ur||Function("return this")(),C=Fr,zr=C.Symbol,Y=zr,nr=Object.prototype,qr=nr.hasOwnProperty,Vr=nr.toString,ce=Y?Y.toStringTag:void 0;function Gr(r){var e=qr.call(r,ce),t=r[ce];try{r[ce]=void 0;var n=!0}catch{}var i=Vr.call(r);return n&&(e?r[ce]=t:delete r[ce]),i}var Wr=Gr,Hr=Object.prototype,Kr=Hr.toString;function Qr(r){return Kr.call(r)}var Yr=Qr,Jr="[object Null]",Xr="[object Undefined]",zt=Y?Y.toStringTag:void 0;function Zr(r){return r==null?r===void 0?Xr:Jr:zt&&zt in Object(r)?Wr(r):Yr(r)}var ge=Zr;function en(r){return r!=null&&typeof r=="object"}var xt=en,Ms=Array.isArray;function tn(r){var e=typeof r;return r!=null&&(e=="object"||e=="function")}var ir=tn,rn="[object AsyncFunction]",nn="[object Function]",on="[object GeneratorFunction]",sn="[object Proxy]";function an(r){if(!ir(r))return!1;var e=ge(r);return e==nn||e==on||e==rn||e==sn}var ln=an,un=C["__core-js_shared__"],gt=un,qt=function(){var r=/[^.]+$/.exec(gt&&gt.keys&&gt.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""}();function cn(r){return!!qt&&qt in r}var dn=cn,pn=Function.prototype,fn=pn.toString;function gn(r){if(r!=null){try{return fn.call(r)}catch{}try{return r+""}catch{}}return""}var B=gn,hn=/[\\^$.*+?()[\]{}|]/g,mn=/^\[object .+?Constructor\]$/,yn=Function.prototype,bn=Object.prototype,wn=yn.toString,kn=bn.hasOwnProperty,vn=RegExp("^"+wn.call(kn).replace(hn,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function xn(r){if(!ir(r)||dn(r))return!1;var e=ln(r)?vn:mn;return e.test(B(r))}var Sn=xn;function _n(r,e){return r?.[e]}var An=_n;function Mn(r,e){var t=An(r,e);return Sn(t)?t:void 0}var J=Mn,In=J(C,"WeakMap"),yt=In;function En(r,e){return r===e||r!==r&&e!==e}var Cn=En,Pn=9007199254740991;function Tn(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=Pn}var $n=Tn,Is=Object.prototype,jn="[object Arguments]";function Rn(r){return xt(r)&&ge(r)==jn}var Vt=Rn,or=Object.prototype,Ln=or.hasOwnProperty,Nn=or.propertyIsEnumerable,Es=Vt(function(){return arguments}())?Vt:function(r){return xt(r)&&Ln.call(r,"callee")&&!Nn.call(r,"callee")},sr=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Gt=sr&&typeof module=="object"&&module&&!module.nodeType&&module,On=Gt&&Gt.exports===sr,Wt=On?C.Buffer:void 0,Cs=Wt?Wt.isBuffer:void 0,Dn="[object Arguments]",Bn="[object Array]",Un="[object Boolean]",Fn="[object Date]",zn="[object Error]",qn="[object Function]",Vn="[object Map]",Gn="[object Number]",Wn="[object Object]",Hn="[object RegExp]",Kn="[object Set]",Qn="[object String]",Yn="[object WeakMap]",Jn="[object ArrayBuffer]",Xn="[object DataView]",Zn="[object Float32Array]",ei="[object Float64Array]",ti="[object Int8Array]",ri="[object Int16Array]",ni="[object Int32Array]",ii="[object Uint8Array]",oi="[object Uint8ClampedArray]",si="[object Uint16Array]",ai="[object Uint32Array]",p={};p[Zn]=p[ei]=p[ti]=p[ri]=p[ni]=p[ii]=p[oi]=p[si]=p[ai]=!0;p[Dn]=p[Bn]=p[Jn]=p[Un]=p[Xn]=p[Fn]=p[zn]=p[qn]=p[Vn]=p[Gn]=p[Wn]=p[Hn]=p[Kn]=p[Qn]=p[Yn]=!1;function li(r){return xt(r)&&$n(r.length)&&!!p[ge(r)]}var ui=li;function ci(r){return function(e){return r(e)}}var di=ci,ar=typeof exports=="object"&&exports&&!exports.nodeType&&exports,de=ar&&typeof module=="object"&&module&&!module.nodeType&&module,pi=de&&de.exports===ar,ht=pi&&rr.process,fi=function(){try{var r=de&&de.require&&de.require("util").types;return r||ht&&ht.binding&&ht.binding("util")}catch{}}(),Ht=fi,Kt=Ht&&Ht.isTypedArray,Ps=Kt?di(Kt):ui,gi=Object.prototype,Ts=gi.hasOwnProperty;function hi(r,e){return function(t){return r(e(t))}}var mi=hi,$s=mi(Object.keys,Object),yi=Object.prototype,js=yi.hasOwnProperty,bi=J(Object,"create"),pe=bi;function wi(){this.__data__=pe?pe(null):{},this.size=0}var ki=wi;function vi(r){var e=this.has(r)&&delete this.__data__[r];return this.size-=e?1:0,e}var xi=vi,Si="__lodash_hash_undefined__",_i=Object.prototype,Ai=_i.hasOwnProperty;function Mi(r){var e=this.__data__;if(pe){var t=e[r];return t===Si?void 0:t}return Ai.call(e,r)?e[r]:void 0}var Ii=Mi,Ei=Object.prototype,Ci=Ei.hasOwnProperty;function Pi(r){var e=this.__data__;return pe?e[r]!==void 0:Ci.call(e,r)}var Ti=Pi,$i="__lodash_hash_undefined__";function ji(r,e){var t=this.__data__;return this.size+=this.has(r)?0:1,t[r]=pe&&e===void 0?$i:e,this}var Ri=ji;function X(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var n=r[e];this.set(n[0],n[1])}}X.prototype.clear=ki;X.prototype.delete=xi;X.prototype.get=Ii;X.prototype.has=Ti;X.prototype.set=Ri;var Qt=X;function Li(){this.__data__=[],this.size=0}var Ni=Li;function Oi(r,e){for(var t=r.length;t--;)if(Cn(r[t][0],e))return t;return-1}var Oe=Oi,Di=Array.prototype,Bi=Di.splice;function Ui(r){var e=this.__data__,t=Oe(e,r);if(t<0)return!1;var n=e.length-1;return t==n?e.pop():Bi.call(e,t,1),--this.size,!0}var Fi=Ui;function zi(r){var e=this.__data__,t=Oe(e,r);return t<0?void 0:e[t][1]}var qi=zi;function Vi(r){return Oe(this.__data__,r)>-1}var Gi=Vi;function Wi(r,e){var t=this.__data__,n=Oe(t,r);return n<0?(++this.size,t.push([r,e])):t[n][1]=e,this}var Hi=Wi;function Z(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var n=r[e];this.set(n[0],n[1])}}Z.prototype.clear=Ni;Z.prototype.delete=Fi;Z.prototype.get=qi;Z.prototype.has=Gi;Z.prototype.set=Hi;var De=Z,Ki=J(C,"Map"),fe=Ki;function Qi(){this.size=0,this.__data__={hash:new Qt,map:new(fe||De),string:new Qt}}var Yi=Qi;function Ji(r){var e=typeof r;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?r!=="__proto__":r===null}var Xi=Ji;function Zi(r,e){var t=r.__data__;return Xi(e)?t[typeof e=="string"?"string":"hash"]:t.map}var Be=Zi;function eo(r){var e=Be(this,r).delete(r);return this.size-=e?1:0,e}var to=eo;function ro(r){return Be(this,r).get(r)}var no=ro;function io(r){return Be(this,r).has(r)}var oo=io;function so(r,e){var t=Be(this,r),n=t.size;return t.set(r,e),this.size+=t.size==n?0:1,this}var ao=so;function ee(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var n=r[e];this.set(n[0],n[1])}}ee.prototype.clear=Yi;ee.prototype.delete=to;ee.prototype.get=no;ee.prototype.has=oo;ee.prototype.set=ao;var lr=ee;function lo(){this.__data__=new De,this.size=0}var uo=lo;function co(r){var e=this.__data__,t=e.delete(r);return this.size=e.size,t}var po=co;function fo(r){return this.__data__.get(r)}var go=fo;function ho(r){return this.__data__.has(r)}var mo=ho,yo=200;function bo(r,e){var t=this.__data__;if(t instanceof De){var n=t.__data__;if(!fe||n.length<yo-1)return n.push([r,e]),this.size=++t.size,this;t=this.__data__=new lr(n)}return t.set(r,e),this.size=t.size,this}var wo=bo;function he(r){var e=this.__data__=new De(r);this.size=e.size}he.prototype.clear=uo;he.prototype.delete=po;he.prototype.get=go;he.prototype.has=mo;he.prototype.set=wo;var ko=Object.prototype,Rs=ko.propertyIsEnumerable,vo=J(C,"DataView"),bt=vo,xo=J(C,"Promise"),wt=xo,So=J(C,"Set"),kt=So,Yt="[object Map]",_o="[object Object]",Jt="[object Promise]",Xt="[object Set]",Zt="[object WeakMap]",er="[object DataView]",Ao=B(bt),Mo=B(fe),Io=B(wt),Eo=B(kt),Co=B(yt),Q=ge;(bt&&Q(new bt(new ArrayBuffer(1)))!=er||fe&&Q(new fe)!=Yt||wt&&Q(wt.resolve())!=Jt||kt&&Q(new kt)!=Xt||yt&&Q(new yt)!=Zt)&&(Q=function(r){var e=ge(r),t=e==_o?r.constructor:void 0,n=t?B(t):"";if(n)switch(n){case Ao:return er;case Mo:return Yt;case Io:return Jt;case Eo:return Xt;case Co:return Zt}return e});var Ls=C.Uint8Array,Po="__lodash_hash_undefined__";function To(r){return this.__data__.set(r,Po),this}var $o=To;function jo(r){return this.__data__.has(r)}var Ro=jo;function vt(r){var e=-1,t=r==null?0:r.length;for(this.__data__=new lr;++e<t;)this.add(r[e])}vt.prototype.add=vt.prototype.push=$o;vt.prototype.has=Ro;var tr=Y?Y.prototype:void 0,Ns=tr?tr.valueOf:void 0,Lo=Object.prototype,Os=Lo.hasOwnProperty,No=Object.prototype,Ds=No.hasOwnProperty,Bs=new RegExp(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,"i"),Us=new RegExp(/[A-Fa-f0-9]{1}/,"g"),Fs=new RegExp(/[A-Fa-f0-9]{2}/,"g");function ur(r,e){let t={...r};if(!e)return t;for(let[n,i]of Object.entries(e))i===!1||i===null||i===void 0?delete t[n]:i===!0?n in r||(t[n]=!0):t[n]=i;return t}var mt="@imgly/plugin-ai-generation",zs=` <svg> <symbol fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" id="@imgly/Sparkle" > <path d="M5.35545 2.06745C5.24149 1.72556 4.7579 1.72556 4.64394 2.06745L4.05898 3.82232C4.02166 3.93429 3.9338 4.02215 3.82184 4.05948L2.06694 4.64459C1.72506 4.75858 1.72509 5.24217 2.06699 5.3561L3.82179 5.9409C3.93378 5.97822 4.02166 6.06609 4.05899 6.17808L4.64394 7.93291C4.7579 8.2748 5.24149 8.2748 5.35545 7.93291L5.9404 6.17806C5.97773 6.06608 6.06559 5.97821 6.17757 5.94089L7.93242 5.35594C8.27431 5.24198 8.27431 4.75839 7.93242 4.64442L6.17757 4.05947C6.06559 4.02215 5.97773 3.93428 5.9404 3.8223L5.35545 2.06745Z" fill="currentColor"/> <path d="M17.9632 3.23614C17.8026 2.80788 17.1968 2.80788 17.0362 3.23614L16.0787 5.78951C16.0285 5.92337 15.9229 6.02899 15.789 6.07918L13.2356 7.0367C12.8074 7.19729 12.8074 7.80307 13.2356 7.96366L15.789 8.92118C15.9229 8.97138 16.0285 9.077 16.0787 9.21085L17.0362 11.7642C17.1968 12.1925 17.8026 12.1925 17.9632 11.7642L18.9207 9.21086C18.9709 9.077 19.0765 8.97138 19.2104 8.92118L21.7637 7.96366C22.192 7.80307 22.192 7.1973 21.7637 7.0367L19.2104 6.07918C19.0765 6.02899 18.9709 5.92337 18.9207 5.78951L17.9632 3.23614Z" fill="currentColor"/> <path d="M9.30058 7.82012C9.54712 7.1791 10.454 7.1791 10.7006 7.82012L12.3809 12.189C12.4571 12.3871 12.6136 12.5436 12.8117 12.6198L17.1806 14.3001C17.8216 14.5466 17.8216 15.4536 17.1806 15.7001L12.8117 17.3804C12.6136 17.4566 12.4571 17.6131 12.3809 17.8112L10.7006 22.1801C10.454 22.8211 9.54712 22.8211 9.30058 22.1801L7.62024 17.8112C7.54406 17.6131 7.38754 17.4566 7.18947 17.3804L2.82061 15.7001C2.17959 15.4536 2.17959 14.5466 2.82061 14.3001L7.18947 12.6198C7.38754 12.5436 7.54406 12.3871 7.62024 12.189L9.30058 7.82012Z" fill="currentColor"/> </symbol> <symbol fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" id="${mt}/image" > <path d="M3 16.5V18C3 19.6569 4.34315 21 6 21H18C19.6569 21 21 19.6569 21 18V6C21 4.34315 19.6569 3 18 3L17.999 5C18.5513 5 19 5.44772 19 6V18C19 18.5523 18.5523 19 18 19H6C5.44772 19 5 18.5523 5 18V16.5H3Z" fill="currentColor"/> <path d="M13.0982 0.884877C12.9734 0.568323 12.5254 0.568322 12.4005 0.884876L11.7485 2.53819C11.7104 2.63483 11.6339 2.71134 11.5372 2.74945L9.8839 3.40151C9.56735 3.52636 9.56734 3.97436 9.8839 4.09921L11.5372 4.75126C11.6339 4.78938 11.7104 4.86588 11.7485 4.96253L12.4005 6.61584C12.5254 6.93239 12.9734 6.9324 13.0982 6.61584L13.7503 4.96253C13.7884 4.86588 13.8649 4.78938 13.9616 4.75126L15.6149 4.09921C15.9314 3.97436 15.9314 3.52636 15.6149 3.40151L13.9616 2.74945C13.8649 2.71134 13.7884 2.63483 13.7503 2.53819L13.0982 0.884877Z" fill="currentColor"/> <path d="M6.40053 5.38488C6.52538 5.06832 6.97338 5.06832 7.09823 5.38488L8.17455 8.11392C8.21267 8.21057 8.28917 8.28707 8.38582 8.32519L11.1149 9.40151C11.4314 9.52636 11.4314 9.97436 11.1149 10.0992L8.38582 11.1755C8.28917 11.2136 8.21267 11.2901 8.17455 11.3868L7.09823 14.1158C6.97338 14.4324 6.52538 14.4324 6.40053 14.1158L5.32421 11.3868C5.2861 11.2901 5.20959 11.2136 5.11295 11.1755L2.3839 10.0992C2.06735 9.97436 2.06735 9.52636 2.3839 9.40151L5.11295 8.32519C5.20959 8.28707 5.2861 8.21057 5.32421 8.11392L6.40053 5.38488Z" fill="currentColor"/> <path d="M18.9994 16.5008V18.0004C18.9994 18.5526 18.5517 19.0004 17.9994 19.0004H9.33302L14.3753 11.4369C14.6722 10.9916 15.3266 10.9916 15.6234 11.4369L18.9994 16.5008Z" fill="currentColor"/> </symbol> <symbol fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" id="${mt}/video" > <path d="M6 3C4.34315 3 3 4.34315 3 6V18C3 19.6569 4.34315 21 6 21H18C19.6569 21 21 19.6569 21 18V16.5H19V18C19 18.5523 18.5523 19 18 19H6C5.44772 19 5 18.5523 5 18V6C5 5.44772 5.44772 5 6 5V3Z" fill="currentColor"/> <path d="M10.9025 0.8839C11.0273 0.567345 11.4753 0.567346 11.6002 0.883901L12.2522 2.53721C12.2904 2.63386 12.3669 2.71036 12.4635 2.74848L14.1168 3.40053C14.4334 3.52538 14.4334 3.97338 14.1168 4.09823L12.4635 4.75029C12.3669 4.7884 12.2904 4.86491 12.2522 4.96155L11.6002 6.61486C11.4753 6.93142 11.0273 6.93142 10.9025 6.61486L10.2504 4.96155C10.2123 4.86491 10.1358 4.7884 10.0392 4.75029L8.38585 4.09823C8.0693 3.97338 8.0693 3.52538 8.38585 3.40053L10.0392 2.74848C10.1358 2.71036 10.2123 2.63386 10.2504 2.53721L10.9025 0.8839Z" fill="currentColor"/> <path d="M18.9019 3.3845C19.0267 3.06795 19.4747 3.06795 19.5996 3.3845L20.6759 6.11355C20.714 6.2102 20.7905 6.2867 20.8872 6.32482L23.6162 7.40114C23.9328 7.52598 23.9328 7.97399 23.6162 8.09883L20.8872 9.17515C20.7905 9.21327 20.714 9.28977 20.6759 9.38642L19.5996 12.1155C19.4747 12.432 19.0267 12.432 18.9019 12.1155L17.8255 9.38642C17.7874 9.28977 17.7109 9.21327 17.6143 9.17515L14.8852 8.09883C14.5687 7.97399 14.5687 7.52598 14.8852 7.40114L17.6143 6.32482C17.7109 6.2867 17.7874 6.2102 17.8255 6.11355L18.9019 3.3845Z" fill="currentColor"/> <path d="M14.9994 13.2862C15.5089 12.8859 15.5089 12.1141 14.9995 11.7137L10.618 8.27047C9.96188 7.75485 9.00011 8.22225 9.00011 9.05673L9.00011 15.9429C9.00011 16.7773 9.96185 17.2448 10.618 16.7292L14.9994 13.2862Z" fill="currentColor"/> </symbol> <symbol fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" id="${mt}/audio" > <path d="M6 3.80273C4.2066 4.84016 3 6.77919 3 9.00004V12.8153C3 15.931 5.39501 18.4873 8.44444 18.7436V20.9645C8.44444 22.2198 9.89427 22.9198 10.8773 22.1392L15.1265 18.7647H15.5C17.8285 18.7647 19.8472 17.4384 20.8417 15.5H18.4187C17.6889 16.2784 16.6512 16.7647 15.5 16.7647H14.9522C14.6134 16.7647 14.2846 16.8794 14.0193 17.0901L10.4444 19.929V18.2597C10.4444 17.4341 9.77513 16.7647 8.9495 16.7647C7.80494 16.7647 6.77409 16.2779 6.05276 15.5H6V15.4419C5.37798 14.7439 5 13.8237 5 12.8153V9.00004C5 7.98559 5.37764 7.05935 6 6.35422V3.80273Z" fill="currentColor"/> <path d="M11.6002 1.8839C11.4753 1.56735 11.0273 1.56735 10.9025 1.8839L10.2504 3.53721C10.2123 3.63386 10.1358 3.71036 10.0392 3.74848L8.38585 4.40053C8.0693 4.52538 8.0693 4.97338 8.38585 5.09823L10.0392 5.75029C10.1358 5.7884 10.2123 5.86491 10.2504 5.96155L10.9025 7.61486C11.0273 7.93142 11.4753 7.93142 11.6002 7.61486L12.2522 5.96155C12.2904 5.86491 12.3669 5.7884 12.4635 5.75029L14.1168 5.09823C14.4334 4.97338 14.4334 4.52538 14.1168 4.40053L12.4635 3.74848C12.3669 3.71036 12.2904 3.63386 12.2522 3.53721L11.6002 1.8839Z" fill="currentColor"/> <path d="M19.5996 4.3845C19.4747 4.06795 19.0267 4.06795 18.9019 4.3845L17.8255 7.11355C17.7874 7.2102 17.7109 7.2867 17.6143 7.32482L14.8852 8.40114C14.5687 8.52598 14.5687 8.97399 14.8852 9.09883L17.6143 10.1752C17.7109 10.2133 17.7874 10.2898 17.8255 10.3864L18.9019 13.1155C19.0267 13.432 19.4747 13.432 19.5996 13.1155L20.6759 10.3864C20.714 10.2898 20.7905 10.2133 20.8872 10.1752L23.6162 9.09883C23.9328 8.97399 23.9328 8.52598 23.6162 8.40114L20.8872 7.32482C20.7905 7.2867 20.714 7.2102 20.6759 7.11355L19.5996 4.3845Z" fill="currentColor"/> </symbol> <symbol fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" id="@imgly/MixingPlate" > <path d="M9.75 9C10.5784 9 11.25 8.32843 11.25 7.5C11.25 6.67157 10.5784 6 9.75 6C8.92157 6 8.25 6.67157 8.25 7.5C8.25 8.32843 8.92157 9 9.75 9Z" fill="currentColor"/> <path d="M7 13C7.82843 13 8.5 12.3284 8.5 11.5C8.5 10.6716 7.82843 10 7 10C6.17157 10 5.5 10.6716 5.5 11.5C5.5 12.3284 6.17157 13 7 13Z" fill="currentColor"/> <path d="M15.75 7.5C15.75 8.32843 15.0784 9 14.25 9C13.4216 9 12.75 8.32843 12.75 7.5C12.75 6.67157 13.4216 6 14.25 6C15.0784 6 15.75 6.67157 15.75 7.5Z" fill="currentColor"/> <path d="M17 13C17.8284 13 18.5 12.3284 18.5 11.5C18.5 10.6716 17.8284 10 17 10C16.1716 10 15.5 10.6716 15.5 11.5C15.5 12.3284 16.1716 13 17 13Z" fill="currentColor"/> <path fill-rule="evenodd" clip-rule="evenodd" d="M8.26309 2.77709C10.6681 1.77921 13.4829 1.7322 15.9209 2.64297C18.1572 3.47923 20.0876 5.09285 21.1766 7.28598C22.3395 9.62772 22.4889 13.1077 20.3864 15.2982C19.2693 16.4621 17.7657 16.9982 16.0026 16.9997C15.7897 16.9997 15.5555 16.9864 15.3497 16.9745C15.309 16.9722 15.2694 16.9699 15.2313 16.9679C14.9817 16.9542 14.761 16.9455 14.5569 16.9539C14.124 16.9718 13.9598 17.0612 13.89 17.1324C13.718 17.3081 13.6946 17.6672 13.8854 17.8895C14.2899 18.3608 14.5016 18.9277 14.5016 19.5497C14.5016 20.2206 14.3086 20.9011 13.7542 21.3896C13.2471 21.837 12.6082 21.9997 11.9635 21.9997C10.6049 21.9997 9.31155 21.7367 8.0934 21.2067C6.89058 20.6831 5.84501 19.9687 4.94363 19.0666C4.04281 18.1651 3.31836 17.107 2.79369 15.8978C1.72761 13.4409 1.72662 10.5261 2.81247 8.07034C3.88024 5.65548 5.84206 3.78161 8.26309 2.77709ZM15.2207 4.51639C13.2556 3.78239 10.9651 3.82132 9.02956 4.62439C7.06888 5.43791 5.49559 6.94785 4.64163 8.87914C3.78373 10.8194 3.78253 13.1522 4.62841 15.1017C5.05312 16.0805 5.63511 16.9291 6.35838 17.6529C7.08102 18.3761 7.91671 18.9484 8.89123 19.3728C9.8492 19.7895 10.87 19.9997 11.9635 19.9997C12.2815 19.9997 12.394 19.9225 12.431 19.8899L12.4319 19.8891C12.4367 19.8849 12.4487 19.8743 12.4631 19.8359C12.4799 19.7911 12.5016 19.7024 12.5016 19.5497C12.5016 19.4091 12.4633 19.3034 12.3677 19.192C11.5353 18.222 11.5272 16.6868 12.4611 15.7331C13.0741 15.1071 13.8844 14.98 14.4745 14.9556C14.7819 14.943 15.085 14.9568 15.3409 14.9709C15.3906 14.9736 15.4379 14.9763 15.4832 14.9788C15.6876 14.9904 15.8508 14.9997 16.0009 14.9997C17.3405 14.9986 18.2792 14.6054 18.9435 13.9133C20.2633 12.5382 20.3186 10.055 19.3853 8.1755C18.5436 6.48051 17.0293 5.19281 15.2207 4.51639Z" fill="currentColor"/> </symbol> </svg> `;var U="0.39.0";var cr=!1,F,St,Oo,Do,Bo,dr,Uo,Ue,_t,pr,At,Fe,fr;function gr(r,e={auto:!1}){if(cr)throw new Error(`you must \`import '@anthropic-ai/sdk/shims/${r.kind}'\` before importing anything else from @anthropic-ai/sdk`);if(F)throw new Error(`can't \`import '@anthropic-ai/sdk/shims/${r.kind}'\` after \`import '@anthropic-ai/sdk/shims/${F}'\``);cr=e.auto,F=r.kind,St=r.fetch,Oo=r.Request,Do=r.Response,Bo=r.Headers,dr=r.FormData,Uo=r.Blob,Ue=r.File,_t=r.ReadableStream,pr=r.getMultipartRequestOptions,At=r.getDefaultAgent,Fe=r.fileFromPath,fr=r.isFsReadStream}var ze=class{constructor(e){this.body=e}get[Symbol.toStringTag](){return"MultipartBody"}};function hr({manuallyImported:r}={}){let e=r?"You may need to use polyfills":"Add one of these imports before your first `import \u2026 from '@anthropic-ai/sdk'`:\n- `import '@anthropic-ai/sdk/shims/node'` (if you're running on Node)\n- `import '@anthropic-ai/sdk/shims/web'` (otherwise)\n",t,n,i,o;try{t=fetch,n=Request,i=Response,o=Headers}catch(s){throw new Error(`this environment is missing the following Web Fetch API type: ${s.message}. ${e}`)}return{kind:"web",fetch:t,Request:n,Response:i,Headers:o,FormData:typeof FormData<"u"?FormData:class{constructor(){throw new Error(`file uploads aren't supported in this environment yet as 'FormData' is undefined. ${e}`)}},Blob:typeof Blob<"u"?Blob:class{constructor(){throw new Error(`file uploads aren't supported in this environment yet as 'Blob' is undefined. ${e}`)}},File:typeof File<"u"?File:class{constructor(){throw new Error(`file uploads aren't supported in this environment yet as 'File' is undefined. ${e}`)}},ReadableStream:typeof ReadableStream<"u"?ReadableStream:class{constructor(){throw new Error(`streaming isn't supported in this environment yet as 'ReadableStream' is undefined. ${e}`)}},getMultipartRequestOptions:async(s,a)=>({...a,body:new ze(s)}),getDefaultAgent:s=>{},fileFromPath:()=>{throw new Error("The `fileFromPath` function is only supported in Node. See the README for more details: https://www.github.com/anthropics/anthropic-sdk-typescript#file-uploads")},isFsReadStream:s=>!1}}F||gr(hr(),{auto:!0});var l=class extends Error{},h=class r extends l{constructor(e,t,n,i){super(`${r.makeMessage(e,t,n)}`),this.status=e,this.headers=i,this.request_id=i?.["request-id"],this.error=t}static makeMessage(e,t,n){let i=t?.message?typeof t.message=="string"?t.message:JSON.stringify(t.message):t?JSON.stringify(t):n;return e&&i?`${e} ${i}`:e?`${e} status code (no body)`:i||"(no status code or body)"}static generate(e,t,n,i){if(!e||!i)return new R({message:n,cause:qe(t)});let o=t;return e===400?new me(e,o,n,i):e===401?new ye(e,o,n,i):e===403?new be(e,o,n,i):e===404?new we(e,o,n,i):e===409?new ke(e,o,n,i):e===422?new ve(e,o,n,i):e===429?new xe(e,o,n,i):e>=500?new Se(e,o,n,i):new r(e,o,n,i)}},y=class extends h{constructor({message:e}={}){super(void 0,void 0,e||"Request was aborted.",void 0)}},R=class extends h{constructor({message:e,cause:t}){super(void 0,void 0,e||"Connection error.",void 0),t&&(this.cause=t)}},te=class extends R{constructor({message:e}={}){super({message:e??"Request timed out."})}},me=class extends h{},ye=class extends h{},be=class extends h{},we=class extends h{},ke=class extends h{},ve=class extends h{},xe=class extends h{},Se=class extends h{};var Ve=function(r,e,t,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t},z=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},v,P=class{constructor(){v.set(this,void 0),this.buffer=new Uint8Array,Ve(this,v,null,"f")}decode(e){if(e==null)return[];let t=e instanceof ArrayBuffer?new Uint8Array(e):typeof e=="string"?new TextEncoder().encode(e):e,n=new Uint8Array(this.buffer.length+t.length);n.set(this.buffer),n.set(t,this.buffer.length),this.buffer=n;let i=[],o;for(;(o=qo(this.buffer,z(this,v,"f")))!=null;){if(o.carriage&&z(this,v,"f")==null){Ve(this,v,o.index,"f");continue}if(z(this,v,"f")!=null&&(o.index!==z(this,v,"f")+1||o.carriage)){i.push(this.decodeText(this.buffer.slice(0,z(this,v,"f")-1))),this.buffer=this.buffer.slice(z(this,v,"f")),Ve(this,v,null,"f");continue}let s=z(this,v,"f")!==null?o.preceding-1:o.preceding,a=this.decodeText(this.buffer.slice(0,s));i.push(a),this.buffer=this.buffer.slice(o.index),Ve(this,v,null,"f")}return i}decodeText(e){if(e==null)return"";if(typeof e=="string")return e;if(typeof Buffer<"u"){if(e instanceof Buffer)return e.toString();if(e instanceof Uint8Array)return Buffer.from(e).toString();throw new l(`Unexpected: received non-Uint8Array (${e.constructor.name}) stream chunk in an environment with a global "Buffer" defined, which this library assumes to be Node. Please report this error.`)}if(typeof TextDecoder<"u"){if(e instanceof Uint8Array||e instanceof ArrayBuffer)return this.textDecoder??(this.textDecoder=new TextDecoder("utf8")),this.textDecoder.decode(e);throw new l(`Unexpected: received non-Uint8Array/ArrayBuffer (${e.constructor.name}) in a web platform. Please report this error.`)}throw new l("Unexpected: neither Buffer nor TextDecoder are available as globals. Please report this error.")}flush(){return this.buffer.length?this.decode(` `):[]}};v=new WeakMap;P.NEWLINE_CHARS=new Set([` `,"\r"]);P.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function qo(r,e){for(let i=e??0;i<r.length;i++){if(r[i]===10)return{preceding:i,index:i+1,carriage:!1};if(r[i]===13)return{preceding:i,index:i+1,carriage:!0}}return null}function mr(r){for(let n=0;n<r.length-1;n++){if(r[n]===10&&r[n+1]===10||r[n]===13&&r[n+1]===13)return n+2;if(r[n]===13&&r[n+1]===10&&n+3<r.length&&r[n+2]===13&&r[n+3]===10)return n+4}return-1}function _e(r){if(r[Symbol.asyncIterator])return r;let e=r.getReader();return{async next(){try{let t=await e.read();return t?.done&&e.releaseLock(),t}catch(t){throw e.releaseLock(),t}},async return(){let t=e.cancel();return e.releaseLock(),await t,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}var M=class r{constructor(e,t){this.iterator=e,this.controller=t}static fromSSEResponse(e,t){let n=!1;async function*i(){if(n)throw new Error("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");n=!0;let o=!1;try{for await(let s of Vo(e,t)){if(s.event==="completion")try{yield JSON.parse(s.data)}catch(a){throw console.error("Could not parse message into JSON:",s.data),console.error("From chunk:",s.raw),a}if(s.event==="message_start"||s.event==="message_delta"||s.event==="message_stop"||s.event==="content_block_start"||s.event==="content_block_delta"||s.event==="content_block_stop")try{yield JSON.parse(s.data)}catch(a){throw console.error("Could not parse message into JSON:",s.data),console.error("From chunk:",s.raw),a}if(s.event!=="ping"&&s.event==="error")throw h.generate(void 0,`SSE Error: ${s.data}`,s.data,It(e.headers))}o=!0}catch(s){if(s instanceof Error&&s.name==="AbortError")return;throw s}finally{o||t.abort()}}return new r(i,t)}static fromReadableStream(e,t){let n=!1;async function*i(){let s=new P,a=_e(e);for await(let f of a)for(let g of s.decode(f))yield g;for(let f of s.flush())yield f}async function*o(){if(n)throw new Error("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");n=!0;let s=!1;try{for await(let a of i())s||a&&(yield JSON.parse(a));s=!0}catch(a){if(a instanceof Error&&a.name==="AbortError")return;throw a}finally{s||t.abort()}}return new r(o,t)}[Symbol.asyncIterator](){return this.iterator()}tee(){let e=[],t=[],n=this.iterator(),i=o=>({next:()=>{if(o.length===0){let s=n.next();e.push(s),t.push(s)}return o.shift()}});return[new r(()=>i(e),this.controller),new r(()=>i(t),this.controller)]}toReadableStream(){let e=this,t,n=new TextEncoder;return new _t({async start(){t=e[Symbol.asyncIterator]()},async pull(i){try{let{value:o,done:s}=await t.next();if(s)return i.close();let a=n.encode(JSON.stringify(o)+` `);i.enqueue(a)}catch(o){i.error(o)}},async cancel(){await t.return?.()}})}};async function*Vo(r,e){if(!r.body)throw e.abort(),new l("Attempted to iterate over a response with no body");let t=new Mt,n=new P,i=_e(r.body);for await(let o of Go(i))for(let s of n.decode(o)){let a=t.decode(s);a&&(yield a)}for(let o of n.flush()){let s=t.decode(o);s&&(yield s)}}async function*Go(r){let e=new Uint8Array;for await(let t of r){if(t==null)continue;let n=t instanceof ArrayBuffer?new Uint8Array(t):typeof t=="string"?new TextEncoder().encode(t):t,i=new Uint8Array(e.length+n.length);i.set(e),i.set(n,e.length),e=i;let o;for(;(o=mr(e))!==-1;)yield e.slice(0,o),e=e.slice(o)}e.length>0&&(yield e)}var Mt=class{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(e){if(e.endsWith("\r")&&(e=e.substring(0,e.length-1)),!e){if(!this.event&&!this.data.length)return null;let o={event:this.event,data:this.data.join(` `),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],o}if(this.chunks.push(e),e.startsWith(":"))return null;let[t,n,i]=Wo(e,":");return i.startsWith(" ")&&(i=i.substring(1)),t==="event"?this.event=i:t==="data"&&this.data.push(i),null}};function Wo(r,e){let t=r.indexOf(e);return t!==-1?[r.substring(0,t),e,r.substring(t+e.length)]:[r,"",""]}var Ho=r=>r!=null&&typeof r=="object"&&typeof r.url=="string"&&typeof r.blob=="function",Ko=r=>r!=null&&typeof r=="object"&&typeof r.name=="string"&&typeof r.lastModified=="number"&&Ae(r),Ae=r=>r!=null&&typeof r=="object"&&typeof r.size=="number"&&typeof r.type=="string"&&typeof r.text=="function"&&typeof r.slice=="function"&&typeof r.arrayBuffer=="function";async function yr(r,e,t){if(r=await r,Ko(r))return r;if(Ho(r)){let i=await r.blob();e||(e=new URL(r.url).pathname.split(/[\\/]/).pop()??"unknown_file");let o=Ae(i)?[await i.arrayBuffer()]:[i];return new Ue(o,e,t)}let n=await Qo(r);if(e||(e=Jo(r)??"unknown_file"),!t?.type){let i=n[0]?.type;typeof i=="string"&&(t={...t,type:i})}return new Ue(n,e,t)}async function Qo(r){let e=[];if(typeof r=="string"||ArrayBuffer.isView(r)||r instanceof ArrayBuffer)e.push(r);else if(Ae(r))e.push(await r.arrayBuffer());else if(Xo(r))for await(let t of r)e.push(t);else throw new Error(`Unexpected data type: ${typeof r}; constructor: ${r?.constructor?.name}; props: ${Yo(r)}`);return e}function Yo(r){return`[${Object.getOwnPropertyNames(r).map(t=>`"${t}"`).join(", ")}]`}function Jo(r){return Et(r.name)||Et(r.filename)||Et(r.path)?.split(/[\\/]/).pop()}var Et=r=>{if(typeof r=="string")return r;if(typeof Buffer<"u"&&r instanceof Buffer)return String(r)},Xo=r=>r!=null&&typeof r=="object"&&typeof r[Symbol.asyncIterator]=="function",Ct=r=>r&&typeof r=="object"&&r.body&&r[Symbol.toStringTag]==="MultipartBody";var es=function(r,e,t,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t},ts=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},Ge;async function xr(r){let{response:e}=r;if(r.options.stream)return re("response",e.status,e.url,e.headers,e.body),r.options.__streamClass?r.options.__streamClass.fromSSEResponse(e,r.controller):M.fromSSEResponse(e,r.controller);if(e.status===204)return null;if(r.options.__binaryResponse)return e;let t=e.headers.get("content-type");if(t?.includes("application/json")||t?.includes("application/vnd.api+json")){let o=await e.json();return re("response",e.status,e.url,e.headers,o),Sr(o,e)}let i=await e.text();return re("response",e.status,e.url,e.headers,i),i}function Sr(r,e){return!r||typeof r!="object"||Array.isArray(r)?r:Object.defineProperty(r,"_request_id",{value:e.headers.get("request-id"),enumerable:!1})}var He=class r extends Promise{constructor(e,t=xr){super(n=>{n(null)}),this.responsePromise=e,this.parseResponse=t}_thenUnwrap(e){return new r(this.responsePromise,async t=>Sr(e(await this.parseResponse(t),t),t.response))}asResponse(){return this.responsePromise.then(e=>e.response)}async withResponse(){let[e,t]=await Promise.all([this.parse(),this.asResponse()]);return{data:e,response:t,request_id:t.headers.get("request-id")}}parse(){return this.parsedPromise||(this.parsedPromise=this.responsePromise.then(this.parseResponse)),this.parsedPromise}then(e,t){return this.parse().then(e,t)}catch(e){return this.parse().catch(e)}finally(e){return this.parse().finally(e)}},Ke=class{constructor({baseURL:e,maxRetries:t=2,timeout:n=6e5,httpAgent:i,fetch:o}){this.baseURL=e,this.maxRetries=Pt("maxRetries",t),this.timeout=Pt("timeout",n),this.httpAgent=i,this.fetch=o??St}authHeaders(e){return{}}defaultHeaders(e){return{Accept:"application/json","Content-Type":"application/json","User-Agent":this.getUserAgent(),...os(),...this.authHeaders(e)}}validateHeaders(e,t){}defaultIdempotencyKey(){return`stainless-node-retry-${cs()}`}get(e,t){return this.methodRequest("get",e,t)}post(e,t){return this.methodRequest("post",e,t)}patch(e,t){return this.methodRequest("patch",e,t)}put(e,t){return this.methodRequest("put",e,t)}delete(e,t){return this.methodRequest("delete",e,t)}methodRequest(e,t,n){return this.request(Promise.resolve(n).then(async i=>{let o=i&&Ae(i?.body)?new DataView(await i.body.arrayBuffer()):i?.body instanceof DataView?i.body:i?.body instanceof ArrayBuffer?new DataView(i.body):i&&ArrayBuffer.isView(i?.body)?new DataView(i.body.buffer):i?.body;return{method:e,path:t,...i,body:o}}))}getAPIList(e,t,n){return this.requestAPIList(t,{method:"get",path:e,...n})}calculateContentLength(e){if(typeof e=="string"){if(typeof Buffer<"u")return Buffer.byteLength(e,"utf8").toString();if(typeof TextEncoder<"u")return new TextEncoder().encode(e).length.toString()}else if(ArrayBuffer.isView(e))return e.byteLength.toString();return null}buildRequest(e,{retryCount:t=0}={}){e={...e};let{method:n,path:i,query:o,headers:s={}}=e,a=ArrayBuffer.isView(e.body)||e.__binaryRequest&&typeof e.body=="string"?e.body:Ct(e.body)?e.body.body:e.body?JSON.stringify(e.body,null,2):null,f=this.calculateContentLength(a),g=this.buildURL(i,o);"timeout"in e&&Pt("timeout",e.timeout),e.timeout=e.timeout??this.timeout;let k=e.httpAgent??this.httpAgent??At(g),x=e.timeout+1e3;typeof k?.options?.timeout=="number"&&x>(k.options.timeout??0)&&(k.options.timeout=x),this.idempotencyHeader&&n!=="get"&&(e.idempotencyKey||(e.idempotencyKey=this.defaultIdempotencyKey()),s[this.idempotencyHeader]=e.idempotencyKey);let K=this.buildHeaders({options:e,headers:s,contentLength:f,retryCount:t});return{req:{method:n,...a&&{body:a},headers:K,...k&&{agent:k},signal:e.signal??null},url:g,timeout:e.timeout}}buildHeaders({options:e,headers:t,contentLength:n,retryCount:i}){let o={};n&&(o["content-length"]=n);let s=this.defaultHeaders(e);return vr(o,s),vr(o,t),Ct(e.body)&&F!=="node"&&delete o["content-type"],We(s,"x-stainless-retry-count")===void 0&&We(t,"x-stainless-retry-count")===void 0&&(o["x-stainless-retry-count"]=String(i)),We(s,"x-stainless-timeout")===void 0&&We(t,"x-stainless-timeout")===void 0&&e.timeout&&(o["x-stainless-timeout"]=String(e.timeout)),this.validateHeaders(o,t),o}_calculateNonstreamingTimeout(e){if(3600*e/128e3>600)throw new l("Streaming is strongly recommended for operations that may take longer than 10 minutes. See https://github.com/anthropics/anthropic-sdk-python#streaming-responses for more details");return 600*1e3}async prepareOptions(e){}async prepareRequest(e,{url:t,options:n}){}parseHeaders(e){return e?Symbol.iterator in e?Object.fromEntries(Array.from(e).map(t=>[...t])):{...e}:{}}makeStatusError(e,t,n,i){return h.generate(e,t,n,i)}request(e,t=null){return new He(this.makeRequest(e,t))}async makeRequest(e,t){let n=await e,i=n.maxRetries??this.maxRetries;t==null&&(t=i),await this.prepareOptions(n);let{req:o,url:s,timeout:a}=this.buildRequest(n,{retryCount:i-t});if(await this.prepareRequest(o,{url:s,options:n}),re("request",s,n,o.headers),n.signal?.aborted)throw new y;let f=new AbortController,g=await this.fetchWithTimeout(s,o,a,f).catch(qe);if(g instanceof Error){if(n.signal?.aborted)throw new y;if(t)return this.retryRequest(n,t);throw g.name==="AbortError"?new te:new R({cause:g})}let k=It(g.headers);if(!g.ok){if(t&&this.shouldRetry(g)){let ft=`retrying, ${t} attempts remaining`;return re(`response (error; ${ft})`,g.status,s,k),this.retryRequest(n,t,k)}let x=await g.text().catch(ft=>qe(ft).message),K=ss(x),pt=K?void 0:x;throw re(`response (error; ${t?"(error; no more retries left)":"(error; not retryable)"})`,g.status,s,k,pt),this.makeStatusError(g.status,K,pt,k)}return{response:g,options:n,controller:f}}requestAPIList(e,t){let n=this.makeRequest(t,null);return new Tt(this,n,e)}buildURL(e,t){let n=ls(e)?new URL(e):new URL(this.baseURL+(this.baseURL.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),i=this.defaultQuery();return Me(i)||(t={...i,...t}),typeof t=="object"&&t&&!Array.isArray(t)&&(n.search=this.stringifyQuery(t)),n.toString()}stringifyQuery(e){return Object.entries(e).filter(([t,n])=>typeof n<"u").map(([t,n])=>{if(typeof n=="string"||typeof n=="number"||typeof n=="boolean")return`${encodeURIComponent(t)}=${encodeURIComponent(n)}`;if(n===null)return`${encodeURIComponent(t)}=`;throw new l(`Cannot stringify type ${typeof n}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`)}).join("&")}async fetchWithTimeout(e,t,n,i){let{signal:o,...s}=t||{};o&&o.addEventListener("abort",()=>i.abort());let a=setTimeout(()=>i.abort(),n),f={signal:i.signal,...s};f.method&&(f.method=f.method.toUpperCase());let g=60*1e3,k=setTimeout(()=>{if(f&&f?.agent?.sockets)for(let x of Object.values(f?.agent?.sockets).flat())x?.setKeepAlive&&x.setKeepAlive(!0,g)},g);return this.fetch.call(void 0,e,f).finally(()=>{clearTimeout(a),clearTimeout(k)})}shouldRetry(e){let t=e.headers.get("x-should-retry");return t==="true"?!0:t==="false"?!1:e.status===408||e.status===409||e.status===429||e.status>=500}async retryRequest(e,t,n){let i,o=n?.["retry-after-ms"];if(o){let a=parseFloat(o);Number.isNaN(a)||(i=a)}let s=n?.["retry-after"];if(s&&!i){let a=parseFloat(s);Number.isNaN(a)?i=Date.parse(s)-Date.now():i=a*1e3}if(!(i&&0<=i&&i<60*1e3)){let a=e.maxRetries??this.maxRetries;i=this.calculateDefaultRetryTimeoutMillis(t,a)}return await us(i),this.makeRequest(e,t-1)}calculateDefaultRetryTimeoutMillis(e,t){let o=t-e,s=Math.min(.5*Math.pow(2,o),8),a=1-Math.random()*.25;return s*a*1e3}getUserAgent(){return`${this.constructor.name}/JS ${U}`}},Qe=class{constructor(e,t,n,i){Ge.set(this,void 0),es(this,Ge,e,"f"),this.options=i,this.response=t,this.body=n}hasNextPage(){return this.getPaginatedItems().length?this.nextPageInfo()!=null:!1}async getNextPage(){let e=this.nextPageInfo();if(!e)throw new l("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");let t={...this.options};if("params"in e&&typeof t.query=="object")t.query={...t.query,...e.params};else if("url"in e){let n=[...Object.entries(t.query||{}),...e.url.searchParams.entries()];for(let[i,o]of n)e.url.searchParams.set(i,o);t.query=void 0,t.path=e.url.toString()}return await ts(this,Ge,"f").requestAPIList(this.constructor,t)}async*iterPages(){let e=this;for(yield e;e.hasNextPage();)e=await e.getNextPage(),yield e}async*[(Ge=new WeakMap,Symbol.asyncIterator)](){for await(let e of this.iterPages())for(let t of e.getPaginatedItems())yield t}},Tt=class extends He{constructor(e,t,n){super(t,async i=>new n(e,i.response,await xr(i),i.options))}async*[Symbol.asyncIterator](){let e=await this;for await(let t of e)yield t}},It=r=>new Proxy(Object.fromEntries(r.entries()),{get(e,t){let n=t.toString();return e[n.toLowerCase()]||e[n]}}),rs={method:!0,path:!0,query:!0,body:!0,headers:!0,maxRetries:!0,stream:!0,timeout:!0,httpAgent:!0,signal:!0,idempotencyKey:!0,__binaryRequest:!0,__binaryResponse:!0,__streamClass:!0},S=r=>typeof r=="object"&&r!==null&&!Me(r)&&Object.keys(r).every(e=>_r(rs,e)),ns=()=>{if(typeof Deno<"u"&&Deno.build!=null)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":U,"X-Stainless-OS":wr(Deno.build.os),"X-Stainless-Arch":br(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":typeof Deno.version=="string"?Deno.version:Deno.version?.deno??"unknown"};if(typeof EdgeRuntime<"u")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":U,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":process.version};if(Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":U,"X-Stainless-OS":wr(process.platform),"X-Stainless-Arch":br(process.arch),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":process.version};let r=is();return r?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":U,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${r.browser}`,"X-Stainless-Runtime-Version":r.version}:{"X-Stainless-Lang":"js","X-Stainless-Package-Version":U,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function is(){if(typeof navigator>"u"||!navigator)return null;let r=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(let{key:e,pattern:t}of r){let n=t.exec(navigator.userAgent);if(n){let i=n[1]||0,o=n[2]||0,s=n[3]||0;return{browser:e,version:`${i}.${o}.${s}`}}}return null}var br=r=>r==="x32"?"x32":r==="x86_64"||r==="x64"?"x64":r==="arm"?"arm":r==="aarch64"||r==="arm64"?"arm64":r?`other:${r}`:"unknown",wr=r=>(r=r.toLowerCase(),r.includes("ios")?"iOS":r==="android"?"Android":r==="darwin"?"MacOS":r==="win32"?"Windows":r==="freebsd"?"FreeBSD":r==="openbsd"?"OpenBSD":r==="linux"?"Linux":r?`Other:${r}`:"Unknown"),kr,os=()=>kr??(kr=ns()),ss=r=>{try{return JSON.parse(r)}catch{return}},as=/^[a-z][a-z0-9+.-]*:/i,ls=r=>as.test(r),us=r=>new Promise(e=>setTimeout(e,r)),Pt=(r,e)=>{if(typeof e!="number"||!Number.isInteger(e))throw new l(`${r} must be an integer`);if(e<0)throw new l(`${r} must be a positive integer`);return e},qe=r=>{if(r instanceof Error)return r;if(typeof r=="object"&&r!==null)try{return new Error(JSON.stringify(r))}catch{}return new Error(String(r))};var Ye=r=>{if(typeof process<"u")return process.env?.[r]?.trim()??void 0;if(typeof Deno<"u")return Deno.env?.get?.(r)?.trim()};function Me(r){if(!r)return!0;for(let e in r)return!1;return!0}function _r(r,e){return Object.prototype.hasOwnProperty.call(r,e)}function vr(r,e){for(let t in e){if(!_r(e,t))continue;let n=t.toLowerCase();if(!n)continue;let i=e[t];i===null?delete r[n]:i!==void 0&&(r[n]=i)}}function re(r,...e){typeof process<"u"&&process?.env?.DEBUG==="true"&&console.log(`Anthropic:DEBUG:${r}`,...e)}var cs=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,r=>{let e=Math.random()*16|0;return(r==="x"?e:e&3|8).toString(16)}),Ar=()=>typeof window<"u"&&typeof window.document<"u"&&typeof navigator<"u",ds=r=>typeof r?.get=="function";var We=(r,e)=>{let t=e.toLowerCase();if(ds(r)){let n=e[0]?.toUpperCase()+e.substring(1).replace(/([^\w])(\w)/g,(i,o,s)=>o+s.toUpperCase());for(let i of[e,t,e.toUpperCase(),n]){let o=r.get(i);if(o)return o}}for(let[n,i]of Object.entries(r))if(n.toLowerCase()===t)return Array.isArray(i)?(i.length<=1||console.warn(`Received ${i.length} entries for the ${e} header, using the first entry.`),i[0]):i};var I=class extends Qe{constructor(e,t,n,i){super(e,t,n,i),this.data=n.data||[],this.has_more=n.has_more||!1,this.first_id=n.first_id||null,this.last_id=n.last_id||null}getPaginatedItems(){return this.data??[]}hasNextPage(){return this.has_more===!1?!1:super.hasNextPage()}nextPageParams(){let e=this.nextPageInfo();if(!e)return null;if("params"in e)return e.params;let t=Object.fromEntries(e.url.searchParams);return Object.keys(t).length?t:null}nextPageInfo(){if(this.options.query?.before_id){let t=this.first_id;return t?{params:{before_id:t}}:null}let e=this.last_id;return e?{params:{after_id:e}}:null}};var m=class{constructor(e){this._client=e}};var q=class extends m{retrieve(e,t){return this._client.get(`/v1/models/${e}?beta=true`,t)}list(e={},t){return S(e)?this.list({},e):this._client.getAPIList("/v1/models?beta=true",ne,{query:e,...t})}},ne=class extends I{};q.BetaModelInfosPage=ne;var ie=class r{constructor(e,t){this.iterator=e,this.controller=t}async*decoder(){let e=new P;for await(let t of this.iterator)for(let n of e.decode(t))yield JSON.parse(n);for(let t of e.flush())yield JSON.parse(t)}[Symbol.asyncIterator](){return this.decoder()}static fromResponse(e,t){if(!e.body)throw t.abort(),new l("Attempted to iterate over a response with no body");return new r(_e(e.body),t)}};var V=class extends m{create(e,t){let{betas:n,...i}=e;return this._client.post("/v1/messages/batches?beta=true",{body:i,...t,headers:{"anthropic-beta":[...n??[],"message-batches-2024-09-24"].toString(),...t?.headers}})}retrieve(e,t={},n){if(S(t))return this.retrieve(e,{},t);let{betas:i}=t;return this._client.get(`/v1/messages/batches/${e}?beta=true`,{...n,headers:{"anthropic-beta":[...i??[],"message-batches-2024-09-24"].toString(),...n?.headers}})}list(e={},t){if(S(e))return this.list({},e);let{betas:n,...i}=e;return this._client.getAPIList("/v1/messages/batches?beta=true",oe,{query:i,...t,headers:{"anthropic-beta":[...n??[],"message-batches-2024-09-24"].toString(),...t?.headers}})}delete(e,t={},n){if(S(t))return this.delete(e,{},t);let{betas:i}=t;return this._client.delete(`/v1/messages/batches/${e}?beta=true`,{...n,headers:{"anthropic-beta":[...i??[],"message-batches-2024-09-24"].toString(),...n?.headers}})}cancel(e,t={},n){if(S(t))return this.cancel(e,{},t);let{betas:i}=t;return this._client.post(`/v1/messages/batches/${e}/cancel?beta=true`,{...n,headers:{"anthropic-beta":[...i??[],"message-batches-2024-09-24"].toString(),...n?.headers}})}async results(e,t={},n){if(S(t))return this.results(e,{},t);let i=await this.retrieve(e);if(!i.results_url)throw new l(`No batch \`results_url\`; Has it finished processing? ${i.processing_status} - ${i.id}`);let{betas:o}=t;return this._client.get(i.results_url,{...n,headers:{"anthropic-beta":[...o??[],"message-batches-2024-09-24"].toString(),Accept:"application/binary",...n?.headers},__binaryResponse:!0})._thenUnwrap((s,a)=>ie.fromResponse(a.response,a.controller))}},oe=class extends I{};V.BetaMessageBatchesPage=oe;var hs=r=>{let e=0,t=[];for(;e<r.length;){let n=r[e];if(n==="\\"){e++;continue}if(n==="{"){t.push({type:"brace",value:"{"}),e++;continue}if(n==="}"){t.push({type:"brace",value:"}"}),e++;continue}if(n==="["){t.push({type:"paren",value:"["}),e++;continue}if(n==="]"){t.push({type:"paren",value:"]"}),e++;continue}if(n===":"){t.push({type:"separator",value:":"}),e++;continue}if(n===","){t.push({type:"delimiter",value:","}),e++;continue}if(n==='"'){let a="",f=!1;for(n=r[++e];n!=='"';){if(e===r.length){f=!0;break}if(n==="\\"){if(e++,e===r.length){f=!0;break}a+=n+r[e],n=r[++e]}else a+=n,n=r[++e]}n=r[++e],f||t.push({type:"string",value:a});continue}if(n&&/\s/.test(n)){e++;continue}let o=/[0-9]/;if(n&&o.test(n)||n==="-"||n==="."){let a="";for(n==="-"&&(a+=n,n=r[++e]);n&&o.test(n)||n===".";)a+=n,n=r[++e];t.push({type:"number",value:a});continue}let s=/[a-z]/i;if(n&&s.test(n)){let a="";for(;n&&s.test(n)&&e!==r.length;)a+=n,n=r[++e];if(a=="true"||a=="false"||a==="null")t.push({type:"name",value:a});else{e++;continue}continue}e++}return t},se=r=>{if(r.length===0)return r;let e=r[r.length-1];switch(e.type){case"separator":return r=r.slice(0,r.length-1),se(r);break;case"number":let t=e.value[e.value.length-1];if(t==="."||t==="-")return r=r.slice(0,r.length-1),se(r);case"string":let n=r[r.length-2];if(n?.type==="delimiter")return r=r.slice(0,r.length-1),se(r);if(n?.type==="brace"&&n.value==="{")return r=r.slice(0,r.length-1),se(r);break;case"delimiter":return r=r.slice(0,r.length-1),se(r);break}return r},ms=r=>{let e=[];return r.map(t=>{t.type==="brace"&&(t.value==="{"?e.push("}"):e.splice(e.lastIndexOf("}"),1)),t.type==="paren"&&(t.value==="["?e.push("]"):e.splice(e.lastIndexOf("]"),1))}),e.length>0&&e.reverse().map(t=>{t==="}"?r.push({type:"brace",value:"}"}):t==="]"&&r.push({type:"paren",value:"]"})}),r},ys=r=>{let e="";return r.map(t=>{switch(t.type){case"string":e+='"'+t.value+'"';break;default:e+=t.value;break}}),e},Je=r=>JSON.parse(ys(ms(se(hs(r)))));var b=function(r,e,t,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t},u=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},_,L,Ie,Xe,Ee,Ce,Ze,Pe,T,Te,et,tt,ae,rt,nt,$t,Mr,jt,Rt,Lt,Nt,Ir,Er="__json_buf",it=class r{constructor(){_.add(this),this.messages=[],this.receivedMessages=[],L.set(this,void 0),this.controller=new AbortController,Ie.set(this,void 0),Xe.set(this,()=>{}),Ee.set(this,()=>{}),Ce.set(this,void 0),Ze.set(this,()=>{}),Pe.set(this,()=>{}),T.set(this,{}),Te.set(this,!1),et.set(this,!1),tt.set(this,!1),ae.set(this,!1),rt.set(this,void 0),nt.set(this,void 0),jt.set(this,e=>{if(b(this,et,!0,"f"),e instanceof Error&&e.name==="AbortError"&&(e=new y),e instanceof y)return b(this,tt,!0,"f"),this._emit("abort",e);if(e instanceof l)return this._emit("error",e);if(e instanceof Error){let t=new l(e.message);return t.cause=e,this._emit("error",t)}return this._emit("error",new l(String(e)))}),b(this,Ie,new Promise((e,t)=>{b(this,Xe,e,"f"),b(this,Ee,t,"f")}),"f"),b(this,Ce,new Promise((e,t)=>{b(this,Ze,e,"f"),b(this,Pe,t,"f")}),"f"),u(this,Ie,"f").catch(()=>{}),u(this,Ce,"f").catch(()=>{})}get response(){return u(this,rt,"f")}get request_id(){return u(this,nt,"f")}async withResponse(){let e=await u(this,Ie,"f");if(!e)throw new Error("Could not resolve a `Response` object");return{data:this,response:e,request_id:e.headers.get("request-id")}}static fromReadableStream(e){let t=new r;return t._run(()=>t._fromReadableStream(e)),t}static createMessage(e,t,n){let i=new r;for(let o of t.messages)i._addMessageParam(o);return i._run(()=>i._createMessage(e,{...t,stream:!0},{...n,headers:{...n?.headers,"X-Stainless-Helper-Method":"stream"}})),i}_run(e){e().then(()=>{this._emitFinal(),this._emit("end")},u(this,jt,"f"))}_addMessageParam(e){this.messages.push(e)}_addMessage(e,t=!0){this.receivedMessages.push(e),t&&this._emit("message",e)}async _createMessage(e,t,n){let i=n?.signal;i&&(i.aborted&&this.controller.abort(),i.addEventListener("abort",()=>this.controller.abort())),u(this,_,"m",Rt).call(this);let{response:o,data:s}=await e.create({...t,stream:!0},{...n,signal:this.cont