1var mH=Object.create;var hp=Object.defineProperty,gH=Object.defineProperties,yH=Object.getOwnPropertyDescriptor,_H=Object.getOwnPropertyDescriptors,vH=Object.getOwnPropertyNames,dp=Object.getOwnPropertySymbols,Qk=Object.getPrototypeOf,Nb=Object.prototype.hasOwnProperty,Zk=Object.prototype.propertyIsEnumerable,bH=Reflect.get;var Yc=(n,e)=>(e=Symbol[n])?e:Symbol.for("Symbol."+n);var Xk=(n,e,t)=>e in n?hp(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,_=(n,e)=>{for(var t in e||={})Nb.call(e,t)&&Xk(n,t,e[t]);if(dp)for(var t of dp(e))Zk.call(e,t)&&Xk(n,t,e[t]);return n},D=(n,e)=>gH(n,_H(e));var Xt=(n,e)=>{var t={};for(var r in n)Nb.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&dp)for(var r of dp(n))e.indexOf(r)<0&&Zk.call(n,r)&&(t[r]=n[r]);return t};var fe=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),Jk=(n,e)=>{for(var t in e)hp(n,t,{get:e[t],enumerable:!0})},wH=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of vH(e))!Nb.call(n,i)&&i!==t&&hp(n,i,{get:()=>e[i],enumerable:!(r=yH(e,i))||r.enumerable});return n};var di=(n,e,t)=>(t=n!=null?mH(Qk(n)):{},wH(e||!n||!n.__esModule?hp(t,"default",{value:n,enumerable:!0}):t,n));var dn=(n,e,t)=>bH(Qk(n),t,e);var m=(n,e,t)=>new Promise((r,i)=>{var s=c=>{try{a(t.next(c))}catch(l){i(l)}},o=c=>{try{a(t.throw(c))}catch(l){i(l)}},a=c=>c.done?r(c.value):Promise.resolve(c.value).then(s,o);a((t=t.apply(n,e)).next())}),z=function(n,e){this[0]=n,this[1]=e},Re=(n,e,t)=>{var r=(o,a,c,l)=>{try{var u=t[o](a),d=(a=u.value)instanceof z,f=u.done;Promise.resolve(d?a[0]:a).then(p=>d?r(o==="return"?o:"next",a[1]?{done:p.done,value:p.value}:p,c,l):c({value:p,done:f})).catch(p=>r("throw",p,c,l))}catch(p){l(p)}},i=o=>s[o]=a=>new Promise((c,l)=>r(o,a,c,l)),s={};return t=t.apply(n,e),s[Yc("asyncIterator")]=()=>s,i("next"),i("throw"),i("return"),s},vn=n=>{var e=n[Yc("asyncIterator")],t=!1,r,i={};return e==null?(e=n[Yc("iterator")](),r=s=>i[s]=o=>e[s](o)):(e=e.call(n),r=s=>i[s]=o=>{if(t){if(t=!1,s==="throw")throw o;return o}return t=!0,{done:!1,value:new z(new Promise(a=>{var c=e[s](o);if(!(c instanceof Object))throw TypeError("Object expected");a(c)}),1)}}),i[Yc("iterator")]=()=>i,r("next"),"throw"in e?r("throw"):i.throw=s=>{throw s},"return"in e&&r("return"),i},Ge=(n,e,t)=>(e=n[Yc("asyncIterator")])?e.call(n):(n=n[Yc("iterator")](),e={},t=(r,i)=>(i=n[r])&&(e[r]=s=>new Promise((o,a,c)=>(s=i.call(n,s),c=s.done,Promise.resolve(s.value).then(l=>o({value:l,done:c}),a)))),t("next"),t("return"),e);var V$=fe((ATe,F$)=>{"use strict";function ti(n,e){typeof e=="boolean"&&(e={forever:e}),this._originalTimeouts=JSON.parse(JSON.stringify(n)),this._timeouts=n,this._options=e||{},this._maxRetryTime=e&&e.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._timer=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}F$.exports=ti;ti.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)};ti.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null};ti.prototype.retry=function(n){if(this._timeout&&clearTimeout(this._timeout),!n)return!1;var e=new Date().getTime();if(n&&e-this._operationStart>=this._maxRetryTime)return this._errors.push(n),this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(n);var t=this._timeouts.shift();if(t===void 0)if(this._cachedTimeouts)this._errors.splice(0,this._errors.length-1),t=this._cachedTimeouts.slice(-1);else return!1;var r=this;return this._timer=setTimeout(function(){r._attempts++,r._operationTimeoutCb&&(r._timeout=setTimeout(function(){r._operationTimeoutCb(r._attempts)},r._operationTimeout),r._options.unref&&r._timeout.unref()),r._fn(r._attempts)},t),this._options.unref&&this._timer.unref(),!0};ti.prototype.attempt=function(n,e){this._fn=n,e&&(e.timeout&&(this._operationTimeout=e.timeout),e.cb&&(this._operationTimeoutCb=e.cb));var t=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){t._operationTimeoutCb()},t._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)};ti.prototype.try=function(n){console.log("Using RetryOperation.try() is deprecated"),this.attempt(n)};ti.prototype.start=function(n){console.log("Using RetryOperation.start() is deprecated"),this.attempt(n)};ti.prototype.start=ti.prototype.try;ti.prototype.errors=function(){return this._errors};ti.prototype.attempts=function(){return this._attempts};ti.prototype.mainError=function(){if(this._errors.length===0)return null;for(var n={},e=null,t=0,r=0;r<this._errors.length;r++){var i=this._errors[r],s=i.message,o=(n[s]||0)+1;n[s]=o,o>=t&&(e=i,t=o)}return e}});var j$=fe(Dc=>{"use strict";var Jre=V$();Dc.operation=function(n){var e=Dc.timeouts(n);return new Jre(e,{forever:n&&(n.forever||n.retries===1/0),unref:n&&n.unref,maxRetryTime:n&&n.maxRetryTime})};Dc.timeouts=function(n){if(n instanceof Array)return[].concat(n);var e={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var t in n)e[t]=n[t];if(e.minTimeout>e.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var r=[],i=0;i<e.retries;i++)r.push(this.createTimeout(i,e));return n&&n.forever&&!r.length&&r.push(this.createTimeout(i,e)),r.sort(function(s,o){return s-o}),r};Dc.createTimeout=function(n,e){var t=e.randomize?Math.random()+1:1,r=Math.round(t*Math.max(e.minTimeout,1)*Math.pow(e.factor,n));return r=Math.min(r,e.maxTimeout),r};Dc.wrap=function(n,e,t){if(e instanceof Array&&(t=e,e=null),!t){t=[];for(var r in n)typeof n[r]=="function"&&t.push(r)}for(var i=0;i<t.length;i++){var s=t[i],o=n[s];n[s]=function(c){var l=Dc.operation(e),u=Array.prototype.slice.call(arguments,1
1),d=u.pop();u.push(function(f){l.retry(f)||(f&&(arguments[0]=l.mainError()),d.apply(this,arguments))}),l.attempt(function(){c.apply(n,u)})}.bind(n,o),n[s].options=e}}});var U$=fe((STe,$$)=>{"use strict";$$.exports=j$()});var ov=fe((H$,sv)=>{"use strict";var eie=U$(),tie=["Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed"],iv=class extends Error{constructor(e){super(),e instanceof Error?(this.originalError=e,{message:e}=e):(this.originalError=new Error(e),this.originalError.stack=this.stack),this.name="AbortError",this.message=e}},nie=(n,e,t)=>{let r=t.retries-(e-1);return n.attemptNumber=e,n.retriesLeft=r,n},rie=n=>tie.includes(n),B$=(n,e)=>new Promise((t,r)=>{e=_({onFailedAttempt:()=>{},retries:10},e);let i=eie.operation(e);i.attempt(s=>m(H$,null,function*(){try{t(yield n(s))}catch(o){if(!(o instanceof Error)){r(new TypeError(`Non-error was thrown: "${o}". You should only throw errors.`));return}if(o instanceof iv)i.stop(),r(o.originalError);else if(o instanceof TypeError&&!rie(o.message))i.stop(),r(o);else{nie(o,s,e);try{yield e.onFailedAttempt(o)}catch(a){r(a);return}i.retry(o)||r(i.mainError())}}}))});sv.exports=B$;
1sv.exports.default=B$;sv.exports.AbortError=iv});var W$=fe((UTe,TD)=>{"use strict";var cie=Object.prototype.hasOwnProperty,sr="~";function Af(){}Object.create&&(Af.prototype=Object.create(null),new Af().__proto__||(sr=!1));function lie(n,e,t){this.fn=n,this.context=e,this.once=t||!1}function G$(n,e,t,r,i){if(typeof t!="function")throw new TypeError("The listener must be a function");var s=new lie(t,r||n,i),o=sr?sr+e:e;return n._events[o]?n._events[o].fn?n._events[o]=[n._events[o],s]:n._events[o].push(s):(n._events[o]=s,n._eventsCount++),n}function uv(n,e){--n._eventsCount===0?n._events=new Af:delete n._events[e]}function zn(){this._events=new Af,this._eventsCount=0}zn.prototype.eventNames=function(){var e=[],t,r;if(this._eventsCount===0)return e;for(r in t=this._events)cie.call(t,r)&&e.push(sr?r.slice(1):r);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e};zn.prototype.listeners=function(e){var t=sr?sr+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var i=0,s=r.length,o=new Array(s);i<s;i++)o[i]=r[i].fn;return o};zn.prototype.listenerCount=function(e){var t=sr?sr+e:e,r=this._events[t];return r?r.fn?1:r.length:0};zn.prototype.emit=function(e,t,r,i,s,o){var a=sr?sr+e:e;if(!this._events[a])return!1;var c=this._events[a],l=arguments.length,u,d;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,r),!0;case 4:return c.fn.call(c.context,t,r,i),!0;case 5:return c.fn.call(c.context,t,r,i,s),!0;case 6:return c.fn.call(c.context,t,r,i,s,o),!0}for(d=1,u=new Array(l-1);d<l;d++)u[d-1]=arguments[d];c.fn.apply(c.context,u)}else{var f=c.length,p;for(d=0;d<f;d++)switch(c[d].once&&this.removeListener(e,c[d].fn,void 0,!0),l){case 1:c[d].fn.call(c[d].context);break;case 2:c[d].fn.call(c[d].context,t);break;case 3:c[d].fn.call(c[d].context,t,r);break;case 4:c[d].fn.call(c[d].context,t,r,i);break;default:if(!u)for(p=1,u=new Array(l-1);p<l;p++)u[p-1]=arguments[p];c[d].fn.apply(c[d].context,u)}}return!0};zn.prototype.on=function(e,t,r){return G$(this,e,t,r,!1)};zn.prototype.once=function(e,t,r){return G$(this,e,t,r,!0)};zn.prototype.removeListener=function(e,t,r,i){var s=sr?sr+e:e;if(!this._events[s])return this;if(!t)return uv(this,s),this;var o=this._events[s];if(o.fn)o.fn===t&&(!i||o.once)&&(!r||o.context===r)&&uv(this,s);else{for(var a=0,c=[],l=o.length;a<l;a++)(o[a].fn!==t||i&&!o[a].once||r&&o[a].context!==r)&&c.push(o[a]);c.length?this._events[s]=c.length===1?c[0]:c:uv(this,s)}return this};zn.prototype.removeAllListeners=function(e){var t;return e?(t=sr?sr+e:e,this._events[t]&&uv(this,t)):(this._events=new Af,this._eventsCount=0),this};zn.prototype.off=zn.prototype.removeListener;zn.prototype.addListener=zn.prototype.on;zn.prefixed=sr;zn.EventEmitter=zn;typeof TD<"u"&&(TD.exports=zn)});var Y$=fe((BTe,K$)=>{"use strict";K$.exports=(n,e)=>(e=e||(()=>{}),n.then(t=>new Promise(r=>{r(e())}).then(()=>t),t=>new Promise(r=>{r(e())}).then(()=>{throw t})))});var Q$=fe((HTe,hv)=>{"use strict";var uie=Y$(),dv=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},X$=(n,e,t)=>new Promise((r,i)=>{if(typeof e!="number"||e<0)throw new TypeError("Expected `milliseconds` to be a positive number");if(e===1/0){r(n);return}let s=setTimeout(()=>{if(typeof t=="function"){try{r(t())}catch(c){i(c)}return}let o=typeof t=="string"?t:`Promise timed out after ${e} milliseconds`,a=t instanceof Error?t:new dv(o);typeof n.cancel=="function"&&n.cancel(),i(a)},e);uie(n.then(r,i),()=>{clearTimeout(s)})});hv.exports=X$;hv.exports.default=X$;hv.exports.TimeoutError=dv});var Z$=fe(AD=>{"use strict";Object.defineProperty(AD,"__esModule",{value:!0});function die(n,e,t){let r=0,i=n.length;for(;i>0;){let s=i/2|0,o=r+s;t(n[o],e)<=0?(r=++o,i-=s+1):i=s}return r}AD.default=die});var J$=fe(SD=>{"use strict";Object.defineProperty(SD,"__esModule",{value:!0});var hie=Z$(),CD=class{constructor(){this._queue=[]}enqueue(e,t){t=Object.assign({priority:0},t);let r={priority:t.priority,run:e};if(this.size&&this._queue[this.size-1].priority>=t.priority){this._queue.push(r);return}let i=hie.default(this._queue,r,(s,o)=>o.priority-s.priority);this._queue.splice(i,0,r)}dequeue(){let e=this._queue.shift();return e?.run}filter(e){return this._queue.filter(t=>t.priority===e.priority).map(t=>t.run)}get size(){return this._queue.length}};SD.default=CD});var pv=fe(DD=>{"use strict";Object.defineProperty(DD,"__esModule",{value:!0});var fie=W$(),eU=Q$(),pie=J$(),fv=()=>{},mie=new eU.TimeoutError,xD=class extends fie{constructor(e){var t,r,i,s;if(super(),this._intervalCount=0,this._intervalEnd=0,this._pendingCount=0,this._resolveEmpty=fv,this._resolveIdle=fv,e=Object.assign({carryoverConcurrencyCount:!1,intervalCap:1/0,interval:0,concurrency:1/0,autoStart:!0,queueClass:pie.default},e),!(typeof e.intervalCap=="number"&&e.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${(r=(t=e.intervalCap)===null||t===void 0?void 0:t.toString())!==null&&r!==void 0?r:""}\` (${typeof e.intervalCap})`);
1if(e.interval===void 0||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${(s=(i=e.interval)===null||i===void 0?void 0:i.toString())!==null&&s!==void 0?s:""}\` (${typeof e.interval})`);this._carryoverConcurrencyCount=e.carryoverConcurrencyCount,this._isIntervalIgnored=e.intervalCap===1/0||e.interval===0,this._intervalCap=e.intervalCap,this._interval=e.interval,this._queue=new e.queueClass,this._queueClass=e.queueClass,this.concurrency=e.concurrency,this._timeout=e.timeout,this._throwOnTimeout=e.throwOnTimeout===!0,this._isPaused=e.autoStart===!1}get _doesIntervalAllowAnother(){return this._isIntervalIgnored||this._intervalCount<this._intervalCap}get _doesConcurrentAllowAnother(){return this._pendingCount<this._concurrency}_next(){this._pendingCount--,this._tryToStartAnother(),this.emit("next")}_resolvePromises(){this._resolveEmpty(),this._resolveEmpty=fv,this._pendingCount===0&&(this._resolveIdle(),this._resolveIdle=fv,this.emit("idle"))}_onResumeInterval(){this._onInterval(),this._initializeIntervalIfNeeded(),this._timeoutId=void 0}_isIntervalPaused(){let e=Date.now();if(this._intervalId===void 0){let t=this._intervalEnd-e;if(t<0)this._intervalCount=this._carryoverConcurrencyCount?this._pendingCount:0;else return this._timeoutId===void 0&&(this._timeoutId=setTimeout(()=>{this._onResumeInterval()},t)),!0}return!1}_tryToStartAnother(){if(this._queue.size===0)return this._intervalId&&clearInterval(this._intervalId),this._intervalId=void 0,this._resolvePromises(),!1;if(!this._isPaused){let e=!this._isIntervalPaused();if(this._doesIntervalAllowAnother&&this._doesConcurrentAllowAnother){let t=this._queue.dequeue();return t?(this.emit("active"),t(),e&&this._initializeIntervalIfNeeded(),!0):!1}}return!1}_initializeIntervalIfNeeded(){this._isIntervalIgnored||this._intervalId!==void 0||(this._intervalId=setInterval(()=>{this._onInterval()},this._interval),this._intervalEnd=Date.now()+this._interval)}_onInterval(){this._intervalCount===0&&this._pendingCount===0&&this._intervalId&&(clearInterval(this._intervalId),this._intervalId=void 0),this._intervalCount=this._carryoverConcurrencyCount?this._pendingCount:0,this._processQueue()}_processQueue(){for(;this._tryToStartAnother(););}get concurrency(){return this._concurrency}set concurrency(e){if(!(typeof e=="number"&&e>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);this._concurrency=e,this._processQueue()}add(r){return m(this,arguments,function*(e,t={}){return new Promise((i,s)=>{let o=()=>m(this,null,function*(){this._pendingCount++,this._intervalCount++;try{let a=this._timeout===void 0&&t.timeout===void 0?e():eU.default(Promise.resolve(e()),t.timeout===void 0?this._timeout:t.timeout,()=>{(t.throwOnTimeout===void 0?this._throwOnTimeout:t.throwOnTimeout)&&s(mie)});i(yield a)}catch(a){s(a)}this._next()});this._queue.enqueue(o,t),this._tryToStartAnother(),this.emit("add")})})}addAll(e,t){return m(this,null,function*(){return Promise.all(e.map(r=>m(this,null,function*(){return this.add(r,t)})))})}start(){return this._isPaused?(this._isPaused=!1,this._processQueue(),this):this}pause(){this._isPaused=!0}clear(){this._queue=new this._queueClass}onEmpty(){return m(this,null,function*(){if(this._queue.size!==0)return new Promise(e=>{let t=this._resolveEmpty;this._resolveEmpty=()=>{t(),e()}})})}onIdle(){return m(this,null,function*(){if(!(this._pendingCount===0&&this._queue.size===0))return new Promise(e=>{let t=this._resolveIdle;this._resolveIdle=()=>{t(),e()}})})}get size(){return this._queue.size}sizeBy(e){return this._queue.filter(e).length}get pending(){return this._pendingCount}get isPaused(){return this._isPaused}get timeout(){return this._timeout}set timeout(e){this._timeout=e}};DD.default=xD});var Sf=fe((nAe,rU)=>{"use strict";var bie="2.0.0",wie=Number.MAX_SAFE_INTEGER||9007199254740991,Eie=16,Iie=250,Tie=["major","premajor","minor","preminor","patch","prepatch","prerelease"];rU.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:Eie,MAX_SAFE_BUILD_LENGTH:Iie,MAX_SAFE_INTEGER:wie,RELEASE_TYPES:Tie,SEMVER_SPEC_VERSION:bie,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}});var xf=fe((rAe,iU)=>{"use strict";var Aie=typeof process=="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...n)=>console.error("SEMVER",...n):()=>{};iU.exports=Aie});var Fu=fe((bs,sU)=>{"use strict";var{MAX_SAFE_COMPONENT_LENGTH:PD,MAX_SAFE_BUILD_LENGTH:Cie,MAX_LENGTH:Sie}=Sf(),xie=xf();bs=sU.exports={};var Die=bs.re=[],Rie=bs.safeRe=[],re=bs.src=[],kie=bs.safeSrc=[],ie=bs.t={}
vendor: 5,783 bytes, line 1
1,Pie=0,MD="[a-zA-Z0-9-]",Mie=[["\\s",1],["\\d",Sie],[MD,Cie]],Nie=n=>{for(let[e,t]of Mie)n=n.split(`${e}*`).join(`${e}{0,${t}}`).split(`${e}+`).join(`${e}{1,${t}}`);return n},Ne=(n,e,t)=>{let r=Nie(e),i=Pie++;xie(n,i,e),ie[n]=i,re[i]=e,kie[i]=r,Die[i]=new RegExp(e,t?"g":void 0),Rie[i]=new RegExp(r,t?"g":void 0)};Ne("NUMERICIDENTIFIER","0|[1-9]\\d*");Ne("NUMERICIDENTIFIERLOOSE","\\d+");Ne("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${MD}*`);Ne("MAINVERSION",`(${re[ie.NUMERICIDENTIFIER]})\\.(${re[ie.NUMERICIDENTIFIER]})\\.(${re[ie.NUMERICIDENTIFIER]})`);Ne("MAINVERSIONLOOSE",`(${re[ie.NUMERICIDENTIFIERLOOSE]})\\.(${re[ie.NUMERICIDENTIFIERLOOSE]})\\.(${re[ie.NUMERICIDENTIFIERLOOSE]})`);Ne("PRERELEASEIDENTIFIER",`(?:${re[ie.NONNUMERICIDENTIFIER]}|${re[ie.NUMERICIDENTIFIER]})`);Ne("PRERELEASEIDENTIFIERLOOSE",`(?:${re[ie.NONNUMERICIDENTIFIER]}|${re[ie.NUMERICIDENTIFIERLOOSE]})`);Ne("PRERELEASE",`(?:-(${re[ie.PRERELEASEIDENTIFIER]}(?:\\.${re[ie.PRERELEASEIDENTIFIER]})*))`);Ne("PRERELEASELOOSE",`(?:-?(${re[ie.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${re[ie.PRERELEASEIDENTIFIERLOOSE]})*))`);Ne("BUILDIDENTIFIER",`${MD}+`);Ne("BUILD",`(?:\\+(${re[ie.BUILDIDENTIFIER]}(?:\\.${re[ie.BUILDIDENTIFIER]})*))`);Ne("FULLPLAIN",`v?${re[ie.MAINVERSION]}${re[ie.PRERELEASE]}?${re[ie.BUILD]}?`);Ne("FULL",`^${re[ie.FULLPLAIN]}$`);Ne("LOOSEPLAIN",`[v=\\s]*${re[ie.MAINVERSIONLOOSE]}${re[ie.PRERELEASELOOSE]}?${re[ie.BUILD]}?`);Ne("LOOSE",`^${re[ie.LOOSEPLAIN]}$`);Ne("GTLT","((?:<|>)?=?)");Ne("XRANGEIDENTIFIERLOOSE",`${re[ie.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);Ne("XRANGEIDENTIFIER",`${re[ie.NUMERICIDENTIFIER]}|x|X|\\*`);Ne("XRANGEPLAIN",`[v=\\s]*(${re[ie.XRANGEIDENTIFIER]})(?:\\.(${re[ie.XRANGEIDENTIFIER]})(?:\\.(${re[ie.XRANGEIDENTIFIER]})(?:${re[ie.PRERELEASE]})?${re[ie.BUILD]}?)?)?`);Ne("XRANGEPLAINLOOSE",`[v=\\s]*(${re[ie.XRANGEIDENTIFIERLOOSE]})(?:\\.(${re[ie.XRANGEIDENTIFIERLOOSE]})(?:\\.(${re[ie.XRANGEIDENTIFIERLOOSE]})(?:${re[ie.PRERELEASELOOSE]})?${re[ie.BUILD]}?)?)?`);Ne("XRANGE",`^${re[ie.GTLT]}\\s*${re[ie.XRANGEPLAIN]}$`);Ne("XRANGELOOSE",`^${re[ie.GTLT]}\\s*${re[ie.XRANGEPLAINLOOSE]}$`);Ne("COERCEPLAIN",`(^|[^\\d])(\\d{1,${PD}})(?:\\.(\\d{1,${PD}}))?(?:\\.(\\d{1,${PD}}))?`);Ne("COERCE",`${re[ie.COERCEPLAIN]}(?:$|[^\\d])`);Ne("COERCEFULL",re[ie.COERCEPLAIN]+`(?:${re[ie.PRERELEASE]})?(?:${re[ie.BUILD]})?(?:$|[^\\d])`);Ne("COERCERTL",re[ie.COERCE],!0);Ne("COERCERTLFULL",re[ie.COERCEFULL],!0);Ne("LONETILDE","(?:~>?)");Ne("TILDETRIM",`(\\s*)${re[ie.LONETILDE]}\\s+`,!0);bs.tildeTrimReplace="$1~";Ne("TILDE",`^${re[ie.LONETILDE]}${re[ie.XRANGEPLAIN]}$`);Ne("TILDELOOSE",`^${re[ie.LONETILDE]}${re[ie.XRANGEPLAINLOOSE]}$`);Ne("LONECARET","(?:\\^)");Ne("CARETTRIM",`(\\s*)${re[ie.LONECARET]}\\s+`,!0);bs.caretTrimReplace="$1^";Ne("CARET",`^${re[ie.LONECARET]}${re[ie.XRANGEPLAIN]}$`);Ne("CARETLOOSE",`^${re[ie.LONECARET]}${re[ie.XRANGEPLAINLOOSE]}$`);Ne("COMPARATORLOOSE",`^${re[ie.GTLT]}\\s*(${re[ie.LOOSEPLAIN]})$|^$`);Ne("COMPARATOR",`^${re[ie.GTLT]}\\s*(${re[ie.FULLPLAIN]})$|^$`);Ne("COMPARATORTRIM",`(\\s*)${re[ie.GTLT]}\\s*(${re[ie.LOOSEPLAIN]}|${re[ie.XRANGEPLAIN]})`,!0);bs.comparatorTrimReplace="$1$2$3";Ne("HYPHENRANGE",`^\\s*(${re[ie.XRANGEPLAIN]})\\s+-\\s+(${re[ie.XRANGEPLAIN]})\\s*$`);Ne("HYPHENRANGELOOSE",`^\\s*(${re[ie.XRANGEPLAINLOOSE]})\\s+-\\s+(${re[ie.XRANGEPLAINLOOSE]})\\s*$`);Ne("STAR","(<|>)?=?\\s*\\*");Ne("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$");Ne("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")});var yv=fe((iAe,oU)=>{"use strict";var Oie=Object.freeze({loose:!0}),Lie=Object.freeze({}),Fie=n=>n?typeof n!="object"?Oie:n:Lie;oU.exports=Fie});var ND=fe((sAe,lU)=>{"use strict";var aU=/^[0-9]+$/,cU=(n,e)=>{let t=aU.test(n),r=aU.test(e);return t&&r&&(n=+n,e=+e),n===e?0:t&&!r?-1:r&&!t?1:n<e?-1:1},Vie=(n,e)=>cU(e,n);lU.exports={compareIdentifiers:cU,rcompareIdentifiers:Vie}});var Gn=fe((oAe,dU)=>{"use strict";var _v=xf(),{MAX_LENGTH:uU,MAX_SAFE_INTEGER:vv}=Sf(),{safeRe:bv,t:wv}=Fu(),jie=yv(),{compareIdentifiers:Vu}=ND(),OD=class n{constructor(e,t){if(t=jie(t),e instanceof n){if(e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease)return e;e=e.version}else if(typeof e!="string")throw new TypeError(`Invalid version. Must be a string. Got type "${typeof e}".`);if(e.length>uU)throw new TypeError(`version is longer than ${uU} characters`);_v("SemVer",e,t),this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease;let r=e.trim().match(t.loose?bv[wv.LOOSE]:bv[wv.FULL]);if(!r)throw new TypeError(`Invalid Version: ${e}`);if(this.raw=e,this.major=+r[1],this.minor=+r[2],this.patch=+r[3],this.major>vv||this.major<0)throw new TypeError("Invalid major version");if(this.minor>vv||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>vv||this.patch<0)throw new TypeError("Invalid patch version");r[4]?this.prerelease=r[4].split(".").map(i=>{if(/^[0-9]+$/.test(i)){let s=+i;if(s>=0&&s<vv)return s}return i}):this.prerelease=[],this.build=r[5]?r[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(e){if(_v("SemVer.compare",this.version,this.options,e),!(e instanceof n)){if(typeof e=="string"&&e===this.version)return 0;e=new n(e,this.options)}return e.version===this.version?0:this.compareMain(e)||this.comparePre(e)}compareMain(e){return e instanceof n||(e=new n(e,this.options)),Vu(this.major,e.major)||Vu(this.minor,e.minor)||Vu(this.patch,e.patch)}comparePre(e){if(e instanceof n||(e=new n(e,this.options)),this.prerelease.length&&!e.prerelease.length)return-1;if(!this.prerelease.length&&e.prerelease.length)return 1;if(!this.prerelease.length&&!e.prerelease.length)return 0;let t=0;do{let r=this.prerelease[t],i=e.prerelease[t];
1if(_v("prerelease compare",t,r,i),r===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(r===void 0)return-1;if(r===i)continue;return Vu(r,i)}while(++t)}compareBuild(e){e instanceof n||(e=new n(e,this.options));let t=0;do{let r=this.build[t],i=e.build[t];if(_v("build compare",t,r,i),r===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(r===void 0)return-1;if(r===i)continue;return Vu(r,i)}while(++t)}inc(e,t,r){if(e.startsWith("pre")){if(!t&&r===!1)throw new Error("invalid increment argument: identifier is empty");if(t){let i=`-${t}`.match(this.options.loose?bv[wv.PRERELEASELOOSE]:bv[wv.PRERELEASE]);if(!i||i[1]!==t)throw new Error(`invalid identifier: ${t}`)}}switch(e){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",t,r);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",t,r);break;case"prepatch":this.prerelease.length=0,this.inc("patch",t,r),this.inc("pre",t,r);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",t,r),this.inc("pre",t,r);break;case"release":if(this.prerelease.length===0)throw new Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case"patch":this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case"pre":{let i=Number(r)?1:0;if(this.prerelease.length===0)this.prerelease=[i];else{let s=this.prerelease.length;for(;--s>=0;)typeof this.prerelease[s]=="number"&&(this.prerelease[s]++,s=-2);if(s===-1){if(t===this.prerelease.join(".")&&r===!1)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(i)}}if(t){let s=[t,i];r===!1&&(s=[t]),Vu(this.prerelease[0],t)===0?isNaN(this.prerelease[1])&&(this.prerelease=s):this.prerelease=s}break}default:throw new Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}};dU.exports=OD});var kc=fe((aAe,fU)=>{"use strict";var hU=Gn(),$ie=(n,e,t=!1)=>{if(n instanceof hU)return n;try{return new hU(n,e)}catch(r){if(!t)return null;throw r}};fU.exports=$ie});var mU=fe((cAe,pU)=>{"use strict";var Uie=kc(),Bie=(n,e)=>{let t=Uie(n,e);return t?t.version:null};pU.exports=Bie});var yU=fe((lAe,gU)=>{"use strict";var Hie=kc(),qie=(n,e)=>{let t=Hie(n.trim().replace(/^[=v]+/,""),e);return t?t.version:null};gU.exports=qie});var bU=fe((uAe,vU)=>{"use strict";var _U=Gn(),zie=(n,e,t,r,i)=>{typeof t=="string"&&(i=r,r=t,t=void 0);try{return new _U(n instanceof _U?n.version:n,t).inc(e,r,i).version}catch{return null}};vU.exports=zie});var IU=fe((dAe,EU)=>{"use strict";var wU=kc(),Gie=(n,e)=>{let t=wU(n,null,!0),r=wU(e,null,!0),i=t.compare(r);if(i===0)return null;let s=i>0,o=s?t:r,a=s?r:t,c=!!o.prerelease.length;if(!!a.prerelease.length&&!c){if(!a.patch&&!a.minor)return"major";if(a.compareMain(o)===0)return a.minor&&!a.patch?"minor":"patch"}let u=c?"pre":"";return t.major!==r.major?u+"major":t.minor!==r.minor?u+"minor":t.patch!==r.patch?u+"patch":"prerelease"};EU.exports=Gie});var AU=fe((hAe,TU)=>{"use strict";var Wie=Gn(),Kie=(n,e)=>new Wie(n,e).major;TU.exports=Kie});var SU=fe((fAe,CU)=>{"use strict";var Yie=Gn(),Xie=(n,e)=>new Yie(n,e).minor;CU.exports=Xie});var DU=fe((pAe,xU)=>{"use strict";var Qie=Gn(),Zie=(n,e)=>new Qie(n,e).patch;xU.exports=Zie});var kU=fe((mAe,RU)=>{"use strict";var Jie=kc(),ese=(n,e)=>{let t=Jie(n,e);return t&&t.prerelease.length?t.prerelease:null};RU.exports=ese});var ni=fe((gAe,MU)=>{"use strict";var PU=Gn(),tse=(n,e,t)=>new PU(n,t).compare(new PU(e,t));MU.exports=tse});var OU=fe((yAe,NU)=>{"use strict";var nse=ni(),rse=(n,e,t)=>nse(e,n,t);NU.exports=rse});var FU=fe((_Ae,LU)=>{"use strict";var ise=ni(),sse=(n,e)=>ise(n,e,!0);LU.exports=sse});var Ev=fe((vAe,jU)=>{"use strict";var VU=Gn(),ose=(n,e,t)=>{let r=new VU(n,t),i=new VU(e,t);return r.compare(i)||r.compareBuild(i)};jU.exports=ose});var UU=fe((bAe,$U)=>{"use strict";var ase=Ev(),cse=(n,e)=>n.sort((t,r)=>ase(t,r,e));$U.exports=cse});var HU=fe((wAe,BU)=>{"use strict";var lse=Ev(),use=(n,e)=>n.sort((t,r)=>lse(r,t,e));BU.exports=use});var Df=fe((EAe,qU)=>{"use strict";
1var dse=ni(),hse=(n,e,t)=>dse(n,e,t)>0;qU.exports=hse});var Iv=fe((IAe,zU)=>{"use strict";var fse=ni(),pse=(n,e,t)=>fse(n,e,t)<0;zU.exports=pse});var LD=fe((TAe,GU)=>{"use strict";var mse=ni(),gse=(n,e,t)=>mse(n,e,t)===0;GU.exports=gse});var FD=fe((AAe,WU)=>{"use strict";var yse=ni(),_se=(n,e,t)=>yse(n,e,t)!==0;WU.exports=_se});var Tv=fe((CAe,KU)=>{"use strict";var vse=ni(),bse=(n,e,t)=>vse(n,e,t)>=0;KU.exports=bse});var Av=fe((SAe,YU)=>{"use strict";var wse=ni(),Ese=(n,e,t)=>wse(n,e,t)<=0;YU.exports=Ese});var VD=fe((xAe,XU)=>{"use strict";var Ise=LD(),Tse=FD(),Ase=Df(),Cse=Tv(),Sse=Iv(),xse=Av(),Dse=(n,e,t,r)=>{switch(e){case"===":return typeof n=="object"&&(n=n.version),typeof t=="object"&&(t=t.version),n===t;case"!==":return typeof n=="object"&&(n=n.version),typeof t=="object"&&(t=t.version),n!==t;case"":case"=":case"==":return Ise(n,t,r);case"!=":return Tse(n,t,r);case">":return Ase(n,t,r);case">=":return Cse(n,t,r);case"<":return Sse(n,t,r);case"<=":return xse(n,t,r);default:throw new TypeError(`Invalid operator: ${e}`)}};XU.exports=Dse});var ZU=fe((DAe,QU)=>{"use strict";var Rse=Gn(),kse=kc(),{safeRe:Cv,t:Sv}=Fu(),Pse=(n,e)=>{if(n instanceof Rse)return n;if(typeof n=="number"&&(n=String(n)),typeof n!="string")return null;e=e||{};let t=null;if(!e.rtl)t=n.match(e.includePrerelease?Cv[Sv.COERCEFULL]:Cv[Sv.COERCE]);else{let c=e.includePrerelease?Cv[Sv.COERCERTLFULL]:Cv[Sv.COERCERTL],l;for(;(l=c.exec(n))&&(!t||t.index+t[0].length!==n.length);)(!t||l.index+l[0].length!==t.index+t[0].length)&&(t=l),c.lastIndex=l.index+l[1].length+l[2].length;c.lastIndex=-1}if(t===null)return null;let r=t[2],i=t[3]||"0",s=t[4]||"0",o=e.includePrerelease&&t[5]?`-${t[5]}`:"",a=e.includePrerelease&&t[6]?`+${t[6]}`:"";return kse(`${r}.${i}.${s}${o}${a}`,e)};QU.exports=Pse});var eB=fe((RAe,JU)=>{"use strict";var jD=class{constructor(){this.max=1e3,this.map=new Map}get(e){let t=this.map.get(e);if(t!==void 0)return this.map.delete(e),this.map.set(e,t),t}delete(e){return this.map.delete(e)}set(e,t){if(!this.delete(e)&&t!==void 0){if(this.map.size>=this.max){let i=this.map.keys().next().value;this.delete(i)}this.map.set(e,t)}return this}};JU.exports=jD});var ri=fe((kAe,iB)=>{"use strict";var Mse=/\s+/g,$D=class n{constructor(e,t){if(t=Ose(t),e instanceof n)return e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease?e:new n(e.raw,t);if(e instanceof UD)return this.raw=e.value,this.set=[[e]],this.formatted=void 0,this;if(this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease,this.raw=e.trim().replace(Mse," "),this.set=this.raw.split("||").map(r=>this.parseRange(r.trim())).filter(r=>r.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){let r=this.set[0];if(this.set=this.set.filter(i=>!nB(i[0])),this.set.length===0)this.set=[r];else if(this.set.length>1){for(let i of this.set)if(i.length===1&&Bse(i[0])){this.set=[i];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted="";for(let e=0;e<this.set.length;e++){e>0&&(this.formatted+="||");let t=this.set[e];for(let r=0;r<t.length;r++)r>0&&(this.formatted+=" "),this.formatted+=t[r].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(e){let r=((this.options.includePrerelease&&$se)|(this.options.loose&&Use))+":"+e,i=tB.get(r);if(i)return i;let s=this.options.loose,o=s?wr[or.HYPHENRANGELOOSE]:wr[or.HYPHENRANGE];e=e.replace(o,Zse(this.options.includePrerelease)),Pt("hyphen replace",e),e=e.replace(wr[or.COMPARATORTRIM],Fse),Pt("comparator trim",e),e=e.replace(wr[or.TILDETRIM],Vse),Pt("tilde trim",e),e=e.replace(wr[or.CARETTRIM],jse),Pt("caret trim",e);let a=e.split(" ").map(d=>Hse(d,this.options)).join(" ").split(/\s+/).map(d=>Qse(d,this.options));s&&(a=a.filter(d=>(Pt("loose invalid filter",d,this.options),!!d.match(wr[or.COMPARATORLOOSE])))),Pt("range list",a);let c=new Map,l=a.map(d=>new UD(d,this.options));for(let d of l){if(nB(d))return[d];c.set(d.value,d)}c.size>1&&c.has("")&&c.delete("");let u=[...c.values()];return tB.set(r,u),u}intersects(e,t){if(!(e instanceof n))throw new TypeError("a Range is required");return this.set.some(r=>rB(r,t)&&e.set.some(i=>rB(i,t)&&r.every(s=>i.every(o=>s.intersects(o,t)))))}test(e){if(!e)return!1;if(typeof e=="string")try{e=new Lse(e,this.options)}catch{return!1}for(let t=0;t<this.set.length;t++)if(Jse(this.set[t],e,this.options))return!0;return!1}};iB.exports=$D;var Nse=eB(),tB=new Nse,Ose=yv(),UD=Rf(),Pt=xf(),Lse=Gn(),{safeRe:wr,t:or,comparatorTrimReplace:Fse,tildeTrimReplace:Vse,caretTrimReplace:jse}=Fu(),{FLAG_INCLUDE_PRERELEASE:$se,FLAG_LOOSE:Use}=Sf(),nB=n=>n.value==="<0.0.0-0",Bse=n=>n.value==="",rB=(n,e)=>{let t=!0,r=n.slice(),i=r.pop();for(;t&&r.length;)t=r.every(s=>i.intersects(s,e)),i=r.pop();return t},Hse=(n,e)=>(Pt("comp",n,e),n=Gse(n,e),Pt("caret",n),n=qse(n,e),Pt("tildes",n),n=Kse(n,e),Pt("xrange",n),n=Xse(n,e),Pt("stars",n),n),ar=n=>!n||n.toLowerCase()==="x"||n==="*",qse=(n,e)=>n.trim().split(/\s+/).map(t=>zse(t,e)).join(" "),zse=(n,e)=>{let t=e.loose?wr[or.TILDELOOSE]:wr[or.TILDE];return n.replace(t,(r,i,s,o,a)=>{Pt("tilde",n,r,i,s,o,a);let c;return ar(i)?c="":ar(s)?c=`>=${i}.0.0 <${+i+1}.0.0-0`:ar(o)?c=`>=${i}.${s}.0 <${i}.${+s+1}.0-0`:a?(Pt("replaceTilde pr",a),c=`>=${i}.${s}.${o}-${a} <${i}.${+s+1}.0-0`):c=`>=${i}.${s}.${o} <${i}.${+s+1}.0-0`,Pt("tilde return",c),c})},Gse=(n,e)=>n.trim().split(/\s+/).map(t=>Wse(t,e)).join(" "),Wse=(n,e)=>{Pt("caret",n,e);let t=e.loose?wr[or.CARETLOOSE]:wr[or.CARET],r=e.includePrerelease?"-0":"";return n.replace(t,(i,s,o,a,c)=>{Pt("caret",n,i,s,o,a,c);let l;return ar(s)?l="":ar(o)?l=`>=${s}.0.0${r} <${+s+1}.0.0-0`:ar(a)?s==="0"?l=`>=${s}.${o}.0${r} <${s}.${+o+1}.0-0`:l=`>=${s}.${o}.0${r} <${+s+1}.0.0-0`:c?(Pt("replaceCaret pr",c),s==="0"?o==="0"?l=`>=${s}.${o}.${a}-${c} <${s}.${o}.${+a+1}-0`:l=`>=${s}.${o}.${a}-${c} <${s}.${+o+1}.0-0`:l=`>=${s}.${o}.${a}-${c} <${+s+1}.0.0-0`):(Pt("no pr"),s==="0"?o==="0"?l=`>=${s}.${o}.${a}${r} <${s}.${o}.${+a+1}-0`:l=`>=${s}.${o}.${a}${r} <${s}.${+o+1}.0-0`:l=`>=${s}.${o}.${a} <${+s+1}.0.0-0`),Pt("caret return",l),l})},Kse=(n,e)=>(Pt("replaceXRanges",n,e),n.split(/\s+/).map(t=>Yse(t,e)).join(" ")),Yse=(n,e)=>{n=n.trim();let t=e.loose?wr[or.XRANGELOOSE]:wr[or.XRANGE];return n.replace(t,(r,i,s,o,a,c)=>{Pt("xRange",n,r,i,s,o,a,c);let l=ar(s),u=l||ar(o),d=u||ar(a),f=d;return i==="="&&f&&(i=""),c=e.includePrerelease?"-0":"",l?i===">"||i==="<"?r="<0.0.0-0":r="*":i&&f?(u&&(o=0),a=0,i===">"?(i=">=",u?(s=+s+1,o=0,a=0):(o=+o+1,a=0)):i==="<="&&(i="<",u?s=+s+1:o=+o+1),i==="<"&&(c="-0"),r=`${i+s}.${o}.${a}${c}`):u?r=`>=${s}.0.0${c} <${+s+1}.0.0-0`:d&&(r=`>=${s}.${o}.0${c} <${s}.${+o+1}.0-0`),Pt("xRange return",r),r})},Xse=(n,e)=>(Pt("replaceStars",n,e),n.trim().replace(wr[or.STAR],"")),Qse=(n,e)=>(Pt("replaceGTE0",n,e),n.trim().replace(wr[e.includePrerelease?or.GTE0PRE:or.GTE0],"")),Zse=n=>(e,t,r,i,s,o,a,c,l,u,d,f)=>(ar(r)?t="":ar(i)?t=`>=${r}.0.0${n?"-0":""}`:ar(s)?t=`>=${r}.${i}.0${n?"-0":""}`:o?t=`>=${t}`:t=`>=${t}${n?"-0":""}`,ar(l)?c="":ar(u)?c=`<${+l+1}.0.0-0`:ar(d)?c=`<${l}.${+u+1}.0-0`:f?c=`<=${l}.${u}.${d}-${f}`:n?c=`<${l}.${u}.${+d+1}-0`:c=`<=${c}`,`${t} ${c}`.trim()),Jse=(n,e,t)=>{for(let r=0;r<n.length;r++)if(!n[r].test(e))return!1;if(e.prerelease.length&&!t.includePrerelease){for(let r=0;r<n.length;r++)if(Pt(n[r].semver),n[r].semver!==UD.ANY&&n[r].semver.prerelease.length>0){let i=n[r].semver;if(i.major===e.major&&i.minor===e.minor&&i.patch===e.patch)return!0}return!1}return!0}});var Rf=fe((PAe,uB)=>{"use strict";var kf=Symbol("SemVer ANY"),qD=class n{static get ANY(){return kf}constructor(e,t){if(t=sB(t),e instanceof n){if(e.loose===!!t.loose)return e;e=e.value}e=e.trim().split(/\s+/).join(" "),HD("comparator",e,t),this.options=t,this.loose=!!t.loose,this.parse(e),this.semver===kf?this.value="":this.value=this.operator+this.semver.version,HD("comp",this)}parse(e){let t=this.options.loose?oB[aB.COMPARATORLOOSE]:oB[aB.COMPARATOR],r=e.match(t);if(!r)throw new TypeError(`Invalid comparator: ${e}`);this.operator=r[1]!==void 0?r[1]:"",this.operator==="="&&(this.operator=""),r[2]?this.semver=new cB(r[2],this.options.loose):this.semver=kf}toString(){return this.value}test(e){if(HD("Comparator.test",e,this.options.loose),this.semver===kf||e===kf)return!0;
1if(typeof e=="string")try{e=new cB(e,this.options)}catch{return!1}return BD(e,this.operator,this.semver,this.options)}intersects(e,t){if(!(e instanceof n))throw new TypeError("a Comparator is required");return this.operator===""?this.value===""?!0:new lB(e.value,t).test(this.value):e.operator===""?e.value===""?!0:new lB(this.value,t).test(e.semver):(t=sB(t),t.includePrerelease&&(this.value==="<0.0.0-0"||e.value==="<0.0.0-0")||!t.includePrerelease&&(this.value.startsWith("<0.0.0")||e.value.startsWith("<0.0.0"))?!1:!!(this.operator.startsWith(">")&&e.operator.startsWith(">")||this.operator.startsWith("<")&&e.operator.startsWith("<")||this.semver.version===e.semver.version&&this.operator.includes("=")&&e.operator.includes("=")||BD(this.semver,"<",e.semver,t)&&this.operator.startsWith(">")&&e.operator.startsWith("<")||BD(this.semver,">",e.semver,t)&&this.operator.startsWith("<")&&e.operator.startsWith(">")))}};uB.exports=qD;var sB=yv(),{safeRe:oB,t:aB}=Fu(),BD=VD(),HD=xf(),cB=Gn(),lB=ri()});var Pf=fe((MAe,dB)=>{"use strict";var eoe=ri(),toe=(n,e,t)=>{try{e=new eoe(e,t)}catch{return!1}return e.test(n)};dB.exports=toe});var fB=fe((NAe,hB)=>{"use strict";var noe=ri(),roe=(n,e)=>new noe(n,e).set.map(t=>t.map(r=>r.value).join(" ").trim().split(" "));hB.exports=roe});var mB=fe((OAe,pB)=>{"use strict";var ioe=Gn(),soe=ri(),ooe=(n,e,t)=>{let r=null,i=null,s=null;try{s=new soe(e,t)}catch{return null}return n.forEach(o=>{s.test(o)&&(!r||i.compare(o)===-1)&&(r=o,i=new ioe(r,t))}),r};pB.exports=ooe});var yB=fe((LAe,gB)=>{"use strict";var aoe=Gn(),coe=ri(),loe=(n,e,t)=>{let r=null,i=null,s=null;try{s=new coe(e,t)}catch{return null}return n.forEach(o=>{s.test(o)&&(!r||i.compare(o)===1)&&(r=o,i=new aoe(r,t))}),r};gB.exports=loe});var bB=fe((FAe,vB)=>{"use strict";var zD=Gn(),uoe=ri(),_B=Df(),doe=(n,e)=>{n=new uoe(n,e);let t=new zD("0.0.0");if(n.test(t)||(t=new zD("0.0.0-0"),n.test(t)))return t;t=null;for(let r=0;r<n.set.length;++r){let i=n.set[r],s=null;i.forEach(o=>{let a=new zD(o.semver.version);switch(o.operator){case">":a.prerelease.length===0?a.patch++:a.prerelease.push(0),a.raw=a.format();case"":case">=":(!s||_B(a,s))&&(s=a);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${o.operator}`)}}),s&&(!t||_B(t,s))&&(t=s)}return t&&n.test(t)?t:null};vB.exports=doe});var EB=fe((VAe,wB)=>{"use strict";var hoe=ri(),foe=(n,e)=>{try{return new hoe(n,e).range||"*"}catch{return null}};wB.exports=foe});var xv=fe((jAe,CB)=>{"use strict";var poe=Gn(),AB=Rf(),{ANY:moe}=AB,goe=ri(),yoe=Pf(),IB=Df(),TB=Iv(),_oe=Av(),voe=Tv(),boe=(n,e,t,r)=>{n=new poe(n,r),e=new goe(e,r);let i,s,o,a,c;switch(t){case">":i=IB,s=_oe,o=TB,a=">",c=">=";break;case"<":i=TB,s=voe,o=IB,a="<",c="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(yoe(n,e,r))return!1;for(let l=0;l<e.set.length;++l){let u=e.set[l],d=null,f=null;if(u.forEach(p=>{p.semver===moe&&(p=new AB(">=0.0.0")),d=d||p,f=f||p,i(p.semver,d.semver,r)?d=p:o(p.semver,f.semver,r)&&(f=p)}),d.operator===a||d.operator===c||(!f.operator||f.operator===a)&&s(n,f.semver))return!1;if(f.operator===c&&o(n,f.semver))return!1}return!0};CB.exports=boe});var xB=fe(($Ae,SB)=>{"use strict";var woe=xv(),Eoe=(n,e,t)=>woe(n,e,">",t);SB.exports=Eoe});var RB=fe((UAe,DB)=>{"use strict";var Ioe=xv(),Toe=(n,e,t)=>Ioe(n,e,"<",t);DB.exports=Toe});var MB=fe((BAe,PB)=>{"use strict";var kB=ri(),Aoe=(n,e,t)=>(n=new kB(n,t),e=new kB(e,t),n.intersects(e,t));PB.exports=Aoe});var OB=fe((HAe,NB)=>{"use strict";var Coe=Pf(),Soe=ni();NB.exports=(n,e,t)=>{let r=[],i=null,s=null,o=n.sort((u,d)=>Soe(u,d,t));for(let u of o)Coe(u,e,t)?(s=u,i||(i=u)):(s&&r.push([i,s]),s=null,i=null);i&&r.push([i,null]);let a=[];for(let[u,d]of r)u===d?a.push(u):!d&&u===o[0]?a.push("*"):d?u===o[0]?a.push(`<=${d}`):a.push(`${u} - ${d}`):a.push(`>=${u}`);let c=a.join(" || "),l=typeof e.raw=="string"?e.raw:String(e);return c.length<l.length?c:e}});var UB=fe((qAe,$B)=>{"use strict";var LB=ri(),WD=Rf(),{ANY:GD}=WD,Mf=Pf(),KD=ni(),xoe=(n,e,t={})=>{if(n===e)return!0;n=new LB(n,t),e=new LB(e,t);let r=!1;e:for(let i of n.set){for(let s of e.set){let o=Roe(i,s,t);
1if(r=r||o!==null,o)continue e}if(r)return!1}return!0},Doe=[new WD(">=0.0.0-0")],FB=[new WD(">=0.0.0")],Roe=(n,e,t)=>{if(n===e)return!0;if(n.length===1&&n[0].semver===GD){if(e.length===1&&e[0].semver===GD)return!0;t.includePrerelease?n=Doe:n=FB}if(e.length===1&&e[0].semver===GD){if(t.includePrerelease)return!0;e=FB}let r=new Set,i,s;for(let p of n)p.operator===">"||p.operator===">="?i=VB(i,p,t):p.operator==="<"||p.operator==="<="?s=jB(s,p,t):r.add(p.semver);if(r.size>1)return null;let o;if(i&&s){if(o=KD(i.semver,s.semver,t),o>0)return null;if(o===0&&(i.operator!==">="||s.operator!=="<="))return null}for(let p of r){if(i&&!Mf(p,String(i),t)||s&&!Mf(p,String(s),t))return null;for(let y of e)if(!Mf(p,String(y),t))return!1;return!0}let a,c,l,u,d=s&&!t.includePrerelease&&s.semver.prerelease.length?s.semver:!1,f=i&&!t.includePrerelease&&i.semver.prerelease.length?i.semver:!1;d&&d.prerelease.length===1&&s.operator==="<"&&d.prerelease[0]===0&&(d=!1);for(let p of e){if(u=u||p.operator===">"||p.operator===">=",l=l||p.operator==="<"||p.operator==="<=",i){if(f&&p.semver.prerelease&&p.semver.prerelease.length&&p.semver.major===f.major&&p.semver.minor===f.minor&&p.semver.patch===f.patch&&(f=!1),p.operator===">"||p.operator===">="){if(a=VB(i,p,t),a===p&&a!==i)return!1}else if(i.operator===">="&&!Mf(i.semver,String(p),t))return!1}if(s){if(d&&p.semver.prerelease&&p.semver.prerelease.length&&p.semver.major===d.major&&p.semver.minor===d.minor&&p.semver.patch===d.patch&&(d=!1),p.operator==="<"||p.operator==="<="){if(c=jB(s,p,t),c===p&&c!==s)return!1}else if(s.operator==="<="&&!Mf(s.semver,String(p),t))return!1}if(!p.operator&&(s||i)&&o!==0)return!1}return!(i&&l&&!s&&o!==0||s&&u&&!i&&o!==0||f||d)},VB=(n,e,t)=>{if(!n)return e;let r=KD(n.semver,e.semver,t);return r>0?n:r<0||e.operator===">"&&n.operator===">="?e:n},jB=(n,e,t)=>{if(!n)return e;let r=KD(n.semver,e.semver,t);return r<0?n:r>0||e.operator==="<"&&n.operator==="<="?e:n};$B.exports=xoe});var zB=fe((zAe,qB)=>{"use strict";var YD=Fu(),BB=Sf(),koe=Gn(),HB=ND(),Poe=kc(),Moe=mU(),Noe=yU(),Ooe=bU(),Loe=IU(),Foe=AU(),Voe=SU(),joe=DU(),$oe=kU(),Uoe=ni(),Boe=OU(),Hoe=FU(),qoe=Ev(),zoe=UU(),Goe=HU(),Woe=Df(),Koe=Iv(),Yoe=LD(),Xoe=FD(),Qoe=Tv(),Zoe=Av(),Joe=VD(),eae=ZU(),tae=Rf(),nae=ri(),rae=Pf(),iae=fB(),sae=mB(),oae=yB(),aae=bB(),cae=EB(),lae=xv(),uae=xB(),dae=RB(),hae=MB(),fae=OB(),pae=UB();qB.exports={parse:Poe,valid:Moe,clean:Noe,inc:Ooe,diff:Loe,major:Foe,minor:Voe,patch:joe,prerelease:$oe,compare:Uoe,rcompare:Boe,compareLoose:Hoe,compareBuild:qoe,sort:zoe,rsort:Goe,gt:Woe,lt:Koe,eq:Yoe,neq:Xoe,gte:Qoe,lte:Zoe,cmp:Joe,coerce:eae,Comparator:tae,Range:nae,satisfies:rae,toComparators:iae,maxSatisfying:sae,minSatisfying:oae,minVersion:aae,validRange:cae,outside:lae,gtr:uae,ltr:dae,intersects:hae,simplifyRange:fae,subset:pae,SemVer:koe,re:YD.re,src:YD.src,tokens:YD.t,SEMVER_SPEC_VERSION:BB.SEMVER_SPEC_VERSION,RELEASE_TYPES:BB.RELEASE_TYPES,compareIdentifiers:HB.compareIdentifiers,rcompareIdentifiers:HB.rcompareIdentifiers}});var o4=fe((HCe,s4)=>{"use strict";s4.exports=function(n,e){if(typeof n!="string")throw new TypeError("Expected a string");return e=typeof e>"u"?"_":e,n.replace(/([a-z\d])([A-Z])/g,"$1"+e+"$2").replace(/([A-Z]+)([A-Z][a-z\d]+)/g,"$1"+e+"$2").toLowerCase()}});var f4=fe((qCe,lR)=>{"use strict";var Uae=/[\p{Lu}]/u,Bae=/[\p{Ll}]/u,a4=/^[\p{Lu}](?![\p{Lu}])/gu,u4=/([\p{Alpha}\p{N}_]|$)/u,d4=/[_.\- ]+/,Hae=new RegExp("^"+d4.source),c4=new RegExp(d4.source+u4.source,"gu"),l4=new RegExp("\\d+"+u4.source,"gu"),qae=(n,e,t)=>{let r=!1,i=!1,s=!1;for(let o=0;o<n.length;o++){let a=n[o];r&&Uae.test(a)?(n=n.slice(0,o)+"-"+n.slice(o),r=!1,s=i,i=!0,o++):i&&s&&Bae.test(a)?(n=n.slice(0,o-1)+"-"+n.slice(o-1),s=i,i=!1,r=!0):(r=e(a)===a&&t(a)!==a,s=i,i=t(a)===a&&e(a)!==a)}return n},zae=(n,e)=>(a4.lastIndex=0,n.replace(a4,t=>e(t))),Gae=(n,e)=>(c4.lastIndex=0,l4.lastIndex=0,n.replace(c4,(t,r)=>e(r)).replace(l4,t=>e(t))),h4=(n,e)=>{if(!(typeof n=="string"||Array.isArray(n)))throw new TypeError("Expected the input to be `string | string[]`");if(e=_({pascalCase:!1,preserveConsecutiveUppercase:!1},e),Array.isArray(n)?n=n.map(s=>s.trim()).filter(s=>s.length).join("-"):n=n.trim(),n.length===0)return"";let t=e.locale===!1?s=>s.toLowerCase():s=>s.toLocaleLowerCase(e.locale),r=e.locale===!1?s=>s.toUpperCase():s=>s.toLocaleUpperCase(e.locale);return n.length===1?e.pascalCase?r(n):t(n):(n!==t(n)&&(n=qae(n,t,r)),n=n.replace(Hae,""),e.preserveConsecutiveUppercase?n=zae(n,t):n=t(n),e.pascalCase&&(n=r(n.charAt(0))+n.slice(1)),Gae(n,r))};lR.exports=h4;lR.exports.default=h4});var I4=fe((oSe,E4)=>{"use strict";var b4=(n=0)=>e=>`\x1B[${38+n};5;${e}m`,w4=(n=0)=>(e,t,r)=>`\x1B[${38+n};2;${e};${t};${r}m`;function nce(){let n=new Map,e={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};e.color.gray=e.color.blackBright,e.bgColor.bgGray=e.bgColor.bgBlackBright,e.color.grey=e.color.blackBright,e.bgColor.bgGrey=e.bgColor.bgBlackBright;for(let[t,r]of Object.entries(e)){for(let[i,s]of Object.entries(r))e[i]={open:`\x1B[${s[0]}m`,close:`\x1B[${s[1]}m`},r[i]=e[i],n.set(s[0],s[1]);Object.defineProperty(e,t,{value:r,enumerable:!1})}return Object.defineProperty(e,"codes",{value:n,enumerable:!1}),e.color.close="\x1B[39m",e.bgColor.close="\x1B[49m",e.color.ansi256=b4(),e.color.ansi16m=w4(),e.bgColor.ansi256=b4(10),e.bgColor.ansi16m=w4(10),Object.defineProperties(e,{rgbToAnsi256:{value:(t,r,i)=>t===r&&r===i?t<8?16:t>
1248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(r/255*5)+Math.round(i/255*5),enumerable:!1},hexToRgb:{value:t=>{let r=/(?<colorString>[a-f\d]{6}|[a-f\d]{3})/i.exec(t.toString(16));if(!r)return[0,0,0];let{colorString:i}=r.groups;i.length===3&&(i=i.split("").map(o=>o+o).join(""));let s=Number.parseInt(i,16);return[s>>16&255,s>>8&255,s&255]},enumerable:!1},hexToAnsi256:{value:t=>e.rgbToAnsi256(...e.hexToRgb(t)),enumerable:!1}}),e}Object.defineProperty(E4,"exports",{enumerable:!0,get:nce})});var v3=fe(ib=>{"use strict";ib.byteLength=Tce;ib.toByteArray=Cce;ib.fromByteArray=Dce;var As=[],ci=[],Ice=typeof Uint8Array<"u"?Uint8Array:Array,qR="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Bc=0,y3=qR.length;Bc<y3;++Bc)As[Bc]=qR[Bc],ci[qR.charCodeAt(Bc)]=Bc;var Bc,y3;ci[45]=62;ci[95]=63;function _3(n){var e=n.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=n.indexOf("=");t===-1&&(t=e);var r=t===e?0:4-t%4;return[t,r]}function Tce(n){var e=_3(n),t=e[0],r=e[1];return(t+r)*3/4-r}function Ace(n,e,t){return(e+t)*3/4-t}function Cce(n){var e,t=_3(n),r=t[0],i=t[1],s=new Ice(Ace(n,r,i)),o=0,a=i>0?r-4:r,c;for(c=0;c<a;c+=4)e=ci[n.charCodeAt(c)]<<18|ci[n.charCodeAt(c+1)]<<12|ci[n.charCodeAt(c+2)]<<6|ci[n.charCodeAt(c+3)],s[o++]=e>>16&255,s[o++]=e>>8&255,s[o++]=e&255;return i===2&&(e=ci[n.charCodeAt(c)]<<2|ci[n.charCodeAt(c+1)]>>4,s[o++]=e&255),i===1&&(e=ci[n.charCodeAt(c)]<<10|ci[n.charCodeAt(c+1)]<<4|ci[n.charCodeAt(c+2)]>>2,s[o++]=e>>8&255,s[o++]=e&255),s}function Sce(n){return As[n>>18&63]+As[n>>12&63]+As[n>>6&63]+As[n&63]}function xce(n,e,t){for(var r,i=[],s=e;s<t;s+=3)r=(n[s]<<16&16711680)+(n[s+1]<<8&65280)+(n[s+2]&255),i.push(Sce(r));return i.join("")}function Dce(n){for(var e,t=n.length,r=t%3,i=[],s=16383,o=0,a=t-r;o<a;o+=s)i.push(xce(n,o,o+s>a?a:o+s));return r===1?(e=n[t-1],i.push(As[e>>2]+As[e<<4&63]+"==")):r===2&&(e=(n[t-2]<<8)+n[t-1],i.push(As[e>>10]+As[e>>4&63]+As[e<<2&63]+"=")),i.join("")}});var eP=null;var Ob=1,Lb=Symbol("SIGNAL");function at(n){let e=eP;return eP=n,e}var tP={version:0,lastCleanEpoch:0,dirty:!1,producerNode:void 0,producerLastReadVersion:void 0,producerIndexOfThis:void 0,nextProducerIndex:0,liveConsumerNode:void 0,liveConsumerIndexOfThis:void 0,consumerAllowSignalWrites:!1,consumerIsAlwaysLive:!1,producerMustRecompute:()=>!1,producerRecomputeValue:()=>{},consumerMarkedDirty:()=>{},consumerOnSignalRead:()=>{}};function EH(n){if(!(jb(n)&&!n.dirty)&&!(!n.dirty&&n.lastCleanEpoch===Ob)){if(!n.producerMustRecompute(n)&&!Fb(n)){n.dirty=!1,n.lastCleanEpoch=Ob;return}n.producerRecomputeValue(n),n.dirty=!1,n.lastCleanEpoch=Ob}}function nP(n){return n&&(n.nextProducerIndex=0),at(n)}function rP(n,e){if(at(e),!(!n||n.producerNode===void 0||n.producerIndexOfThis===void 0||n.producerLastReadVersion===void 0)){if(jb(n))for(let t=n.nextProducerIndex;t<n.producerNode.length;t++)Vb(n.producerNode[t],n.producerIndexOfThis[t]);for(;n.producerNode.length>n.nextProducerIndex;)n.producerNode.pop(),n.producerLastReadVersion.pop(),n.producerIndexOfThis.pop()}}function Fb(n){fp(n);for(let e=0;e<n.producerNode.length;e++){let t=n.producerNode[e],r=n.producerLastReadVersion[e];if(r!==t.version||(EH(t),r!==t.version))return!0}return!1}function iP(n){if(fp(n),jb(n))for(let e=0;e<n.producerNode.length;e++)Vb(n.producerNode[e],n.producerIndexOfThis[e]);n.producerNode.length=n.producerLastReadVersion.length=n.producerIndexOfThis.length=0,n.liveConsumerNode&&(n.liveConsumerNode.length=n.liveConsumerIndexOfThis.length=0)}function Vb(n,e){if(IH(n),fp(n),n.liveConsumerNode.length===1)for(let r=0;r<n.producerNode.length;r++)Vb(n.producerNode[r],n.producerIndexOfThis[r]);let t=n.liveConsumerNode.length-1;if(n.liveConsumerNode[e]=n.liveConsumerNode[t],n.liveConsumerIndexOfThis[e]=n.liveConsumerIndexOfThis[t],n.liveConsumerNode.length--,n.liveConsumerIndexOfThis.length--,e<n.liveConsumerNode.length){let r=n.liveConsumerIndexOfThis[e],i=n.liveConsumerNode[e];fp(i),i.producerIndexOfThis[r]=e}}function jb(n){return n.consumerIsAlwaysLive||(n?.liveConsumerNode?.length??0)>0}function fp(n){n.producerNode??=[],n.producerIndexOfThis??=[],n.producerLastReadVersion??=[]}function IH(n){n.liveConsumerNode??=[],n.liveConsumerIndexOfThis??=[]}function TH(){throw new Error}var AH=TH;function sP(n){AH=n}function Me(n){return typeof n=="function"}function Xc(n){let t=n(r=>{Error.call(r),r.stack=new Error().stack});return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var pp=Xc(n=>function(t){n(this),this.message=t?`${t.length} errors occurred during unsubscription: 2${t.map((r,i)=>`${i+1}) ${r.toString()}`).join(` 3 `)}`:"",this.name="UnsubscriptionError",this.errors=t});function Ia(n,e){if(n){let t=n.indexOf(e);0<=t&&n.splice(t,1)}}var zt=class n{constructor(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}
vendor: 10,340 bytes, line 3
3unsubscribe(){let e;if(!this.closed){this.closed=!0;let{_parentage:t}=this;if(t)if(this._parentage=null,Array.isArray(t))for(let s of t)s.remove(this);else t.remove(this);let{initialTeardown:r}=this;if(Me(r))try{r()}catch(s){e=s instanceof pp?s.errors:[s]}let{_finalizers:i}=this;if(i){this._finalizers=null;for(let s of i)try{oP(s)}catch(o){e=e??[],o instanceof pp?e=[...e,...o.errors]:e.push(o)}}if(e)throw new pp(e)}}add(e){var t;if(e&&e!==this)if(this.closed)oP(e);else{if(e instanceof n){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=(t=this._finalizers)!==null&&t!==void 0?t:[]).push(e)}}_hasParent(e){let{_parentage:t}=this;return t===e||Array.isArray(t)&&t.includes(e)}_addParent(e){let{_parentage:t}=this;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e}_removeParent(e){let{_parentage:t}=this;t===e?this._parentage=null:Array.isArray(t)&&Ia(t,e)}remove(e){let{_finalizers:t}=this;t&&Ia(t,e),e instanceof n&&e._removeParent(this)}};zt.EMPTY=(()=>{let n=new zt;return n.closed=!0,n})();var $b=zt.EMPTY;function mp(n){return n instanceof zt||n&&"closed"in n&&Me(n.remove)&&Me(n.add)&&Me(n.unsubscribe)}function oP(n){Me(n)?n():n.unsubscribe()}var hi={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1};var Qc={setTimeout(n,e,...t){let{delegate:r}=Qc;return r?.setTimeout?r.setTimeout(n,e,...t):setTimeout(n,e,...t)},clearTimeout(n){let{delegate:e}=Qc;return(e?.clearTimeout||clearTimeout)(n)},delegate:void 0};function gp(n){Qc.setTimeout(()=>{let{onUnhandledError:e}=hi;if(e)e(n);else throw n})}function od(){}var aP=Ub("C",void 0,void 0);function cP(n){return Ub("E",void 0,n)}function lP(n){return Ub("N",n,void 0)}function Ub(n,e,t){return{kind:n,value:e,error:t}}var Ta=null;function Zc(n){if(hi.useDeprecatedSynchronousErrorHandling){let e=!Ta;if(e&&(Ta={errorThrown:!1,error:null}),n(),e){let{errorThrown:t,error:r}=Ta;if(Ta=null,t)throw r}}else n()}function uP(n){hi.useDeprecatedSynchronousErrorHandling&&Ta&&(Ta.errorThrown=!0,Ta.error=n)}var Aa=class extends zt{constructor(e){super(),this.isStopped=!1,e?(this.destination=e,mp(e)&&e.add(this)):this.destination=xH}static create(e,t,r){return new Ds(e,t,r)}next(e){this.isStopped?Hb(lP(e),this):this._next(e)}error(e){this.isStopped?Hb(cP(e),this):(this.isStopped=!0,this._error(e))}complete(){this.isStopped?Hb(aP,this):(this.isStopped=!0,this._complete())}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe(),this.destination=null)}_next(e){this.destination.next(e)}_error(e){try{this.destination.error(e)}finally{this.unsubscribe()}}_complete(){try{this.destination.complete()}finally{this.unsubscribe()}}},CH=Function.prototype.bind;function Bb(n,e){return CH.call(n,e)}var qb=class{constructor(e){this.partialObserver=e}next(e){let{partialObserver:t}=this;if(t.next)try{t.next(e)}catch(r){yp(r)}}error(e){let{partialObserver:t}=this;if(t.error)try{t.error(e)}catch(r){yp(r)}else yp(e)}complete(){let{partialObserver:e}=this;if(e.complete)try{e.complete()}catch(t){yp(t)}}},Ds=class extends Aa{constructor(e,t,r){super();let i;if(Me(e)||!e)i={next:e??void 0,error:t??void 0,complete:r??void 0};else{let s;this&&hi.useDeprecatedNextContext?(s=Object.create(e),s.unsubscribe=()=>this.unsubscribe(),i={next:e.next&&Bb(e.next,s),error:e.error&&Bb(e.error,s),complete:e.complete&&Bb(e.complete,s)}):i=e}this.destination=new qb(i)}};function yp(n){hi.useDeprecatedSynchronousErrorHandling?uP(n):gp(n)}function SH(n){throw n}function Hb(n,e){let{onStoppedNotification:t}=hi;t&&Qc.setTimeout(()=>t(n,e))}var xH={closed:!0,next:od,error:SH,complete:od};var Jc=typeof Symbol=="function"&&Symbol.observable||"@@observable";function Qn(n){return n}function zb(...n){return Gb(n)}function Gb(n){return n.length===0?Qn:n.length===1?n[0]:function(t){return n.reduce((r,i)=>i(r),t)}}var Ue=(()=>{class n{constructor(t){t&&(this._subscribe=t)}lift(t){let r=new n;return r.source=this,r.operator=t,r}subscribe(t,r,i){let s=RH(t)?t:new Ds(t,r,i);return Zc(()=>{let{operator:o,source:a}=this;s.add(o?o.call(s,a):a?this._subscribe(s):this._trySubscribe(s))}),s}_trySubscribe(t){try{return this._subscribe(t)}catch(r){t.error(r)}}forEach(t,r){return r=dP(r),new r((i,s)=>{let o=new Ds({next:a=>{try{t(a)}catch(c){s(c),o.unsubscribe()}},error:s,complete:i});this.subscribe(o)})}_subscribe(t){var r;return(r=this.source)===null||r===void 0?void 0:r.subscribe(t)}[Jc](){return this}pipe(...t){return Gb(t)(this)}toPromise(t){return t=dP(t),new t((r,i)=>{let s;this.subscribe(o=>s=o,o=>i(o),()=>r(s))})}}return n.create=e=>new n(e),n})();function dP(n){var e;return(e=n??hi.Promise)!==null&&e!==void 0?e:Promise}function DH(n){return n&&Me(n.next)&&Me(n.error)&&Me(n.complete)}function RH(n){return n&&n instanceof Aa||DH(n)&&mp(n)}function Wb(n){return Me(n?.lift)}function We(n){return e=>{if(Wb(e))return e.lift(function(t){try{return n(t,this)}catch(r){this.error(r)}});throw new TypeError("Unable to lift unknown Observable type")}}function Ke(n,e,t,r,i){return new Kb(n,e,t,r,i)}var Kb=class extends Aa{constructor(e,t,r,i,s,o){super(e),this.onFinalize=s,this.shouldUnsubscribe=o,this._next=t?function(a){try{t(a)}catch(c){e.error(c)}}:super._next,this._error=i?function(a){try{i(a)}catch(c){e.error(c)}finally{this.unsubscribe()}}:super._error,this._complete=r?function(){try{r()}catch(a){e.error(a)}finally{this.unsubscribe()}}:super._complete}unsubscribe(){var e;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){let{closed:t}=this;super.unsubscribe(),!t&&((e=this.onFinalize)===null||e===void 0||e.call(this))}}};function el(){return We((n,e)=>{let t=null;n._refCount++;let r=Ke(e,void 0,void 0,void 0,()=>{if(!n||n._refCount<=0||0<--n._refCount){t=null;return}let i=n._connection,s=t;t=null,i&&(!s||i===s)&&i.unsubscribe(),e.unsubscribe()});n.subscribe(r),r.closed||(t=n.connect())})}var tl=class extends Ue{constructor(e,t){super(),this.source=e,this.subjectFactory=t,this._subject=null,this._refCount=0,this._connection=null,Wb(e)&&(this.lift=e.lift)}_subscribe(e){return this.getSubject().subscribe(e)}getSubject(){let e=this._subject;return(!e||e.isStopped)&&(this._subject=this.subjectFactory()),this._subject}_teardown(){this._refCount=0;let{_connection:e}=this;this._subject=this._connection=null,e?.unsubscribe()}connect(){let e=this._connection;if(!e){e=this._connection=new zt;let t=this.getSubject();e.add(this.source.subscribe(Ke(t,void 0,()=>{this._teardown(),t.complete()},r=>{this._teardown(),t.error(r)},()=>this._teardown()))),e.closed&&(this._connection=null,e=zt.EMPTY)}return e}refCount(){return el()(this)}};var hP=Xc(n=>function(){n(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"});var mt=(()=>{class n extends Ue{constructor(){super(),this.closed=!1,this.currentObservers=null,this.observers=[],this.isStopped=!1,this.hasError=!1,this.thrownError=null}lift(t){let r=new _p(this,this);return r.operator=t,r}_throwIfClosed(){if(this.closed)throw new hP}next(t){Zc(()=>{if(this._throwIfClosed(),!this.isStopped){this.currentObservers||(this.currentObservers=Array.from(this.observers));for(let r of this.currentObservers)r.next(t)}})}error(t){Zc(()=>{if(this._throwIfClosed(),!this.isStopped){this.hasError=this.isStopped=!0,this.thrownError=t;let{observers:r}=this;for(;r.length;)r.shift().error(t)}})}complete(){Zc(()=>{if(this._throwIfClosed(),!this.isStopped){this.isStopped=!0;let{observers:t}=this;for(;t.length;)t.shift().complete()}})}unsubscribe(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null}get observed(){var t;return((t=this.observers)===null||t===void 0?void 0:t.length)>0}_trySubscribe(t){return this._throwIfClosed(),super._trySubscribe(t)}_subscribe(t){return this._throwIfClosed(),this._checkFinalizedStatuses(t),this._innerSubscribe(t)}_innerSubscribe(t){let{hasError:r,isStopped:i,observers:s}=this;return r||i?$b:(this.currentObservers=null,s.push(t),new zt(()=>{this.currentObservers=null,Ia(s,t)}))}_checkFinalizedStatuses(t){let{hasError:r,thrownError:i,isStopped:s}=this;r?t.error(i):s&&t.complete()}asObservable(){let t=new Ue;return t.source=this,t}}return n.create=(e,t)=>new _p(e,t),n})(),_p=class extends mt{constructor(e,t){super(),this.destination=e,this.source=t}next(e){var t,r;(r=(t=this.destination)===null||t===void 0?void 0:t.next)===null||r===void 0||r.call(t,e)}error(e){var t,r;(r=(t=this.destination)===null||t===void 0?void 0:t.error)===null||r===void 0||r.call(t,e)}complete(){var e,t;(t=(e=this.destination)===null||e===void 0?void 0:e.complete)===null||t===void 0||t.call(e)}_subscribe(e){var t,r;return(r=(t=this.source)===null||t===void 0?void 0:t.subscribe(e))!==null&&r!==void 0?r:$b}};var gt=class extends mt{constructor(e){super(),this._value=e}get value(){return this.getValue()}_subscribe(e){let t=super._subscribe(e);return!t.closed&&e.next(this._value),t}getValue(){let{hasError:e,thrownError:t,_value:r}=this;if(e)throw t;return this._throwIfClosed(),r}next(e){super.next(this._value=e)}};var ad={now(){return(ad.delegate||Date).now()},delegate:void 0};var vp=class extends mt{constructor(e=1/0,t=1/0,r=ad){super(),this._bufferSize=e,this._windowTime=t,this._timestampProvider=r,this._buffer=[],this._infiniteTimeWindow=!0,this._infiniteTimeWindow=t===1/0,this._bufferSize=Math.max(1,e),this._windowTime=Math.max(1,t)}next(e){let{isStopped:t,_buffer:r,_infiniteTimeWindow:i,_timestampProvider:s,_windowTime:o}=this;t||(r.push(e),!i&&r.push(s.now()+o)),this._trimBuffer(),super.next(e)}_subscribe(e){this._throwIfClosed(),this._trimBuffer();let t=this._innerSubscribe(e),{_infiniteTimeWindow:r,_buffer:i}=this,s=i.slice();for(let o=0;o<s.length&&!e.closed;o+=r?1:2)e.next(s[o]);return this._checkFinalizedStatuses(e),t}_trimBuffer(){let{_bufferSize:e,_timestampProvider:t,_buffer:r,_infiniteTimeWindow:i}=this,s=(i?1:2)*e;if(e<1/0&&s<r.length&&r.splice(0,r.length-s),!i){let o=t.now(),a=0;for(let c=1;c<r.length&&r[c]<=o;c+=2)a=c;a&&r.splice(0,a+1)}}};var bp=class extends zt{constructor(e,t){super()}schedule(e,t=0){return this}};var cd={setInterval(n,e,...t){let{delegate:r}=cd;return r?.setInterval?r.setInterval(n,e,...t):setInterval(n,e,...t)},clearInterval(n){let{delegate:e}=cd;return(e?.clearInterval||clearInterval)(n)},delegate:void 0};var nl=class extends bp{constructor(e,t){super(e,t),this.scheduler
vendor: 4,761 bytes, line 3
3=e,this.work=t,this.pending=!1}schedule(e,t=0){var r;if(this.closed)return this;this.state=e;let i=this.id,s=this.scheduler;return i!=null&&(this.id=this.recycleAsyncId(s,i,t)),this.pending=!0,this.delay=t,this.id=(r=this.id)!==null&&r!==void 0?r:this.requestAsyncId(s,this.id,t),this}requestAsyncId(e,t,r=0){return cd.setInterval(e.flush.bind(e,this),r)}recycleAsyncId(e,t,r=0){if(r!=null&&this.delay===r&&this.pending===!1)return t;t!=null&&cd.clearInterval(t)}execute(e,t){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;let r=this._execute(e,t);if(r)return r;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))}_execute(e,t){let r=!1,i;try{this.work(e)}catch(s){r=!0,i=s||new Error("Scheduled action threw falsy error")}if(r)return this.unsubscribe(),i}unsubscribe(){if(!this.closed){let{id:e,scheduler:t}=this,{actions:r}=t;this.work=this.state=this.scheduler=null,this.pending=!1,Ia(r,this),e!=null&&(this.id=this.recycleAsyncId(t,e,null)),this.delay=null,super.unsubscribe()}}};var rl=class n{constructor(e,t=n.now){this.schedulerActionCtor=e,this.now=t}schedule(e,t=0,r){return new this.schedulerActionCtor(this,e).schedule(r,t)}};rl.now=ad.now;var il=class extends rl{constructor(e,t=rl.now){super(e,t),this.actions=[],this._active=!1}flush(e){let{actions:t}=this;if(this._active){t.push(e);return}let r;this._active=!0;do if(r=e.execute(e.state,e.delay))break;while(e=t.shift());if(this._active=!1,r){for(;e=t.shift();)e.unsubscribe();throw r}}};var wp=new il(nl),Yb=wp;var Ep=class extends nl{constructor(e,t){super(e,t),this.scheduler=e,this.work=t}schedule(e,t=0){return t>0?super.schedule(e,t):(this.delay=t,this.state=e,this.scheduler.flush(this),this)}execute(e,t){return t>0||this.closed?super.execute(e,t):this._execute(e,t)}requestAsyncId(e,t,r=0){return r!=null&&r>0||r==null&&this.delay>0?super.requestAsyncId(e,t,r):(e.flush(this),0)}};var Ip=class extends il{};var Xb=new Ip(Ep);var Zn=new Ue(n=>n.complete());function Tp(n){return n&&Me(n.schedule)}function Qb(n){return n[n.length-1]}function Ap(n){return Me(Qb(n))?n.pop():void 0}function Ui(n){return Tp(Qb(n))?n.pop():void 0}function fP(n,e){return typeof Qb(n)=="number"?n.pop():e}function Cp(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(n);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(n,r[i])&&(t[r[i]]=n[r[i]]);return t}function mP(n,e,t,r){function i(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(u){try{l(r.next(u))}catch(d){o(d)}}function c(u){try{l(r.throw(u))}catch(d){o(d)}}function l(u){u.done?s(u.value):i(u.value).then(a,c)}l((r=r.apply(n,e||[])).next())})}function pP(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],r=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&r>=n.length&&(n=void 0),{value:n&&n[r++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Ca(n){return this instanceof Ca?(this.v=n,this):new Ca(n)}function gP(n,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t.apply(n,e||[]),i,s=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",o),i[Symbol.asyncIterator]=function(){return this},i;function o(p){return function(y){return Promise.resolve(y).then(p,d)}}function a(p,y){r[p]&&(i[p]=function(v){return new Promise(function(w,E){s.push([p,v,w,E])>1||c(p,v)})},y&&(i[p]=y(i[p])))}function c(p,y){try{l(r[p](y))}catch(v){f(s[0][3],v)}}function l(p){p.value instanceof Ca?Promise.resolve(p.value.v).then(u,d):f(s[0][2],p)}function u(p){c("next",p)}function d(p){c("throw",p)}function f(p,y){p(y),s.shift(),s.length&&c(s[0][0],s[0][1])}}function yP(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=n[Symbol.asyncIterator],t;return e?e.call(n):(n=typeof pP=="function"?pP(n):n[Symbol.iterator](),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(s){t[s]=n[s]&&function(o){return new Promise(function(a,c){o=n[s](o),i(a,c,o.done,o.value)})}}function i(s,o,a,c){Promise.resolve(c).then(function(l){s({value:l,done:a})},o)}}var Sp=n=>n&&typeof n.length=="number"&&typeof n!="function";function xp(n){return Me(n?.then)}function Dp(n){return Me(n[Jc])}function Rp(n){return Symbol.asyncIterator&&Me(n?.[Symbol.asyncIterator])}function kp(n){return new TypeError(`You provided ${n!==null&&typeof n=="object"?"an invali
3d object":`'${n}'`} where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.`)}function kH(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var Pp=kH();function Mp(n){return Me(n?.[Pp])}function Np(n){return gP(this,arguments,function*(){let t=n.getReader();try{for(;;){let{value:r,done:i}=yield Ca(t.read());if(i)return yield Ca(void 0);yield yield Ca(r)}}finally{t.releaseLock()}})}function Op(n){return Me(n?.getReader)}function Dt(n){if(n instanceof Ue)return n;if(n!=null){if(Dp(n))return PH(n);if(Sp(n))return MH(n);if(xp(n))return NH(n);if(Rp(n))return _P(n);if(Mp(n))return OH(n);if(Op(n))return LH(n)}throw kp(n)}function PH(n){return new Ue(e=>{let t=n[Jc]();if(Me(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function MH(n){return new Ue(e=>{for(let t=0;t<n.length&&!e.closed;t++)e.next(n[t]);e.complete()})}function NH(n){return new Ue(e=>{n.then(t=>{e.closed||(e.next(t),e.complete())},t=>e.error(t)).then(null,gp)})}function OH(n){return new Ue(e=>{for(let t of n)if(e.next(t),e.closed)return;e.complete()})}function _P(n){return new Ue(e=>{FH(n,e).catch(t=>e.error(t))})}function LH(n){return _P(Np(n))}function FH(n,e){var t,r,i,s;return mP(this,void 0,void 0,function*(){try{for(t=yP(n);r=yield t.next(),!r.done;){let o=r.value;if(e.next(o),e.closed)return}}catch(o){i={error:o}}finally{try{r&&!r.done&&(s=t.return)&&(yield s.call(t))}finally{if(i)throw i.error}}e.complete()})}function fr(n,e,t,r=0,i=!1){let s=e.schedule(function(){t(),i?n.add(this.schedule(null,r)):this.unsubscribe()},r);if(n.add(s),!i)return s}function So(n,e=0){return We((t,r)=>{t.subscribe(Ke(r,i=>
vendor: 4,184 bytes, line 3
3fr(r,n,()=>r.next(i),e),()=>fr(r,n,()=>r.complete(),e),i=>fr(r,n,()=>r.error(i),e)))})}function xo(n,e=0){return We((t,r)=>{r.add(n.schedule(()=>t.subscribe(r),e))})}function vP(n,e){return Dt(n).pipe(xo(e),So(e))}function bP(n,e){return Dt(n).pipe(xo(e),So(e))}function wP(n,e){return new Ue(t=>{let r=0;return e.schedule(function(){r===n.length?t.complete():(t.next(n[r++]),t.closed||this.schedule())})})}function EP(n,e){return new Ue(t=>{let r;return fr(t,e,()=>{r=n[Pp](),fr(t,e,()=>{let i,s;try{({value:i,done:s}=r.next())}catch(o){t.error(o);return}s?t.complete():t.next(i)},0,!0)}),()=>Me(r?.return)&&r.return()})}function Lp(n,e){if(!n)throw new Error("Iterable cannot be null");return new Ue(t=>{fr(t,e,()=>{let r=n[Symbol.asyncIterator]();fr(t,e,()=>{r.next().then(i=>{i.done?t.complete():t.next(i.value)})},0,!0)})})}function IP(n,e){return Lp(Np(n),e)}function TP(n,e){if(n!=null){if(Dp(n))return vP(n,e);if(Sp(n))return wP(n,e);if(xp(n))return bP(n,e);if(Rp(n))return Lp(n,e);if(Mp(n))return EP(n,e);if(Op(n))return IP(n,e)}throw kp(n)}function Rt(n,e){return e?TP(n,e):Dt(n)}function Ae(...n){let e=Ui(n);return Rt(n,e)}function sl(n,e){let t=Me(n)?n:()=>n,r=i=>i.error(t());return new Ue(e?i=>e.schedule(r,0,i):r)}function Zb(n){return!!n&&(n instanceof Ue||Me(n.lift)&&Me(n.subscribe))}var Rs=Xc(n=>function(){n(this),this.name="EmptyError",this.message="no elements in sequence"});function AP(n){return n instanceof Date&&!isNaN(n)}function ke(n,e){return We((t,r)=>{let i=0;t.subscribe(Ke(r,s=>{r.next(n.call(e,s,i++))}))})}var{isArray:VH}=Array;function jH(n,e){return VH(e)?n(...e):n(e)}function Fp(n){return ke(e=>jH(n,e))}var{isArray:$H}=Array,{getPrototypeOf:UH,prototype:BH,keys:HH}=Object;function Vp(n){if(n.length===1){let e=n[0];if($H(e))return{args:e,keys:null};if(qH(e)){let t=HH(e);return{args:t.map(r=>e[r]),keys:t}}}return{args:n,keys:null}}function qH(n){return n&&typeof n=="object"&&UH(n)===BH}function jp(n,e){return n.reduce((t,r,i)=>(t[r]=e[i],t),{})}function $p(...n){let e=Ui(n),t=Ap(n),{args:r,keys:i}=Vp(n);if(r.length===0)return Rt([],e);let s=new Ue(zH(r,e,i?o=>jp(i,o):Qn));return t?s.pipe(Fp(t)):s}function zH(n,e,t=Qn){return r=>{CP(e,()=>{let{length:i}=n,s=new Array(i),o=i,a=i;for(let c=0;c<i;c++)CP(e,()=>{let l=Rt(n[c],e),u=!1;l.subscribe(Ke(r,d=>{s[c]=d,u||(u=!0,a--),a||r.next(t(s.slice()))},()=>{--o||r.complete()}))},r)},r)}}function CP(n,e,t){n?fr(t,n,e):e()}function SP(n,e,t,r,i,s,o,a){let c=[],l=0,u=0,d=!1,f=()=>{d&&!c.length&&!l&&e.complete()},p=v=>l<r?y(v):c.push(v),y=v=>{s&&e.next(v),l++;let w=!1;Dt(t(v,u++)).subscribe(Ke(e,E=>{i?.(E),s?p(E):e.next(E)},()=>{w=!0},void 0,()=>{if(w)try{for(l--;c.length&&l<r;){let E=c.shift();o?fr(e,o,()=>y(E)):y(E)}f()}catch(E){e.error(E)}}))};return n.subscribe(Ke(e,p,()=>{d=!0,f()})),()=>{a?.()}}function an(n,e,t=1/0){return Me(e)?an((r,i)=>ke((s,o)=>e(r,s,i,o))(Dt(n(r,i))),t):(typeof e=="number"&&(t=e),We((r,i)=>SP(r,i,n,t)))}function ld(n=1/0){return an(Qn,n)}function xP(){return ld(1)}function ol(...n){return xP()(Rt(n,Ui(n)))}function Up(n){return new Ue(e=>{Dt(n()).subscribe(e)})}function Jb(...n){let e=Ap(n),{args:t,keys:r}=Vp(n),i=new Ue(s=>{let{length:o}=t;if(!o){s.complete();return}let a=new Array(o),c=o,l=o;for(let u=0;u<o;u++){let d=!1;Dt(t[u]).subscribe(Ke(s,f=>{d||(d=!0,l--),a[u]=f},()=>c--,void 0,()=>{(!c||!d)&&(l||s.next(r?jp(r,a):a),s.complete())}))}});return e?i.pipe(Fp(e)):i}function ew(n=0,e,t=Yb){let r=-1;return e!=null&&(Tp(e)?t=e:r=e),new Ue(i=>{let s=AP(n)?+n-t.now():n;s<0&&(s=0);let o=0;return t.schedule(function(){i.closed||(i.next(o++),0<=r?this.schedule(void 0,r):i.complete())},s)})}function tw(...n){let e=Ui(n),t=fP(n,1/0),r=n;return r.length?r.length===1?Dt(r[0]):ld(t)(Rt(r,e)):Zn}function Tr(n,e){return We((t,r)=>{let i=0;t.subscribe(Ke(r,s=>n.call(e,s,i++)&&r.next(s)))})}function Do(n){return We((e,t)=>{let r=null,i=!1,s;r=e.subscribe(Ke(t,void 0,void 0,o=>{s=Dt(n(o,Do(n)(e))),r?(r.unsubscribe(),r=null,s.subscribe(t)):i=!0})),i&&(r.unsubscribe(),r=null,s.subscribe(t))})}function DP(n,e,t,r,i){return(s,o)=>{let a=t,c=e,l=0;s.subscribe(Ke(o,u=>{let d=l++;c=a?n(c,u,d):(a=!0,u),r&&o.next(c)},i&&(()=>{a&&o.next(c),o.complete()}
3)))}}function Ro(n,e){return Me(e)?an(n,e,1):an(n,1)}function ko(n){return We((e,t)=>{let r=!1;e.subscribe(Ke(t,i=>{r=!0,t.next(i)},()=>{r||t.next(n),t.complete()}))})}function ks(n){return n<=0?()=>Zn:We((e,t)=>{let r=0;e.subscribe(Ke(t,i=>{++r<=n&&(t.next(i),n<=r&&t.complete())}))})}function ud(n){return ke(()=>n)}function nw(n,e=Qn){return n=n??GH,We((t,r)=>{let i,s=!0;t.subscribe(Ke(r,o=>{let a=e(o);(s||!n(i,a))&&(s=!1,i=a,r.next(o))}))})}function GH(n,e){return n===e}function Bp(n=WH){return We((e,t)=>{let r=!1;e.subscribe(Ke(t,i=>{r=!0,t.next(i)},()=>r?t.complete():t.error(n())))})}function WH(){return new Rs}function Sa(n){return We((e,t)=>{try{e.subscribe(t)}finally{t.add(n)}})}function fi(n,e){let t=arguments.length>=2;return r=>r.pipe(n?Tr((i,s)=>n(i,s,r)):Qn,ks(1),t?ko(e):Bp(()=>new Rs))}function al(n){return n<=0?()=>Zn:We((e,t)=>{let r=[];e.subscribe(Ke(t,i=>{r.push(i),n<r.length&&r.shift()},()=>{for(let i of r)t.next(i);t.complete()},void 0,()=>{r=null}))})}function rw(n,e){let t=arguments.length>=2;return r=>r.pipe(n?Tr((i,s)=>n(i,s,r)):Qn,al(1),t?ko(e):Bp(()=>new Rs))}function iw(n,e){return We(DP(n,e,arguments.length>=2,!0))}function RP(n={}){let{connector:e=()=>new mt,resetOnError:t=!0,resetOnComplete:r=!0,resetOnRefCountZero:i=!0}=n;return s=>{let o,a,c,l=0,u=!1,d=!1,f=()=>{a?.unsubscribe(),a=void 0},p=()=>{f(),o=c=void 0,u=d=!1},y=()=>{let v=o;p(),v?.unsubscribe()};return We((v,w)=>{l++,!d&&!u&&f();let E=c=c??e();w.add(()=>{l--,l===0&&!d&&!u&&(a=sw(y,i))}),E.subscribe(w),!o&&l>0&&(o=new Ds({next:A=>E.next(A),error:A=>{d=!0,f(),a=sw(p,t,A),E.error(A)},complete:()=>{u=!0,f(),a=sw(p,r),E.complete()}}),Dt(v).subscribe(o))})(s)}}function sw(n,e,...t){if(e===!0){n();return}if(e===!1)return;let r=new Ds({next:()=>{r.unsubscribe(),n()}});return Dt(e(...t)).subscribe(r)}function ow(n,e,t){let r,i=!1;return n&&typeof n=="object"?{bufferSize:r=1/0,windowTime:e=1/0,refCount:i=!1,scheduler:t}=n:r=n??1/0,RP({connector:()=>new vp(r,e,t),resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:i})}function dd(...n){let e=Ui(n);return We((t,r)=>{(e?ol(n,t,e):ol(n,t)).subscribe(r)})}function Jn(n,e){return We((t,r)=>{let i=null,s=0,o=!1,a=()=>o&&!i&&r.complete();t.subscribe(Ke(r,c=>{i?.unsubscribe();let l=0,u=s++;Dt(n(c,u)).subscribe(i=Ke(r,d=>r.next(e?e(c,d,u,l++):d),()=>{i=null,a()}))},()=>{o=!0,a()}))})}function pi(n){return We((e,t)=>{Dt(n).subscribe(Ke(t,()=>t.complete(),od)),!t.closed&&e.subscribe(t)})}function Qt(n,e,t){let r=Me(n)||e||t?{next:n,error:e,complete:t}:n;return r?We((i,s)=>{var o;(o=r.subscribe)===null||o===void 0||o.call(r);let a=!0;i.subscribe(Ke(s,c=>{var l;(l=r.next)===null||l===void 0||l.call(r,c),s.next(c)},()=>{var c;a=!1,(c=r.complete)===null||c===void 0||c.call(r),s.complete()},c=>{var l;a=!1,(l=r.error)===null||l===void 0||l.call(r,c),s.error(c)},()=>{var c,l;a&&((c=r.unsubscribe)===null||c===void 0||c.call(r)),(l=r.finalize)===null||l===void 0||l.call(r)}))}):Qn}var y1="https://g.co/ng/security#xss",we=class extends Error{constructor(e,t){super(_m(e,t)),this.code=e}};function _m(n,e){return`${`NG0${Math.abs(n)}`}${e?": "+e:""}`}function Cd(n){return{toString:n}.toString()}var Hp="__parameters__";function KH(n){return function(...t){if(n){let r=n(...t);for(let i in r)this[i]=r[i]}}}function _1(n,e,t){return Cd(()=>{let r=KH(e);function i(...s){if(this instanceof i)return r.apply(this,s),this;let o=new i(...s);return a.annotation=o,a;function a(c,l,u){let d=c.hasOwnProperty(Hp)?c[Hp]:Object.defineProperty(c,Hp,{value:[]})[Hp];for(;d.length<=u;)d.push(null);return(d[u]=d[u]||[]).push(o),c}}return t&&(i.prototype=Object.create(t.prototype)),i.prototype.ngMetadataName=n,i.annotationCls=i,i})}var xa=globalThis;function Tt(n){for(let e in n)if(n[e]===Tt)return e;throw Error("Could not find renamed property on target object.")}function YH(n,e){for(let t in e)e.hasOwnProperty(t)&&!n.hasOwnProperty(t)&&(n[t]=e[t])}function tr(n){if(typeof n=="string")return n;if(Array.isArray(n))return"["+n.map(tr).join(", ")+"]";if(n==null)return""+n;if(n.overriddenName)return`${n.overriddenName}`;if(n.name)return`${n.name}`;let e=n.toString();if(e==null)return""+e;let t=e.indexOf(` 4`);return t===-1?e:e.substring(0,t)}function kP(n,e){return n==null||n===""?e===null?"":e:e==null||e===""?n:n+" "+e}var XH=Tt({__forward_ref__:Tt});function Hr(n){return n.__forward_ref__=Hr,n.toString=function(){return tr(this())},n}function er(n){return v1(n)?n():n}function v1(n){return typeof n=="function"&&n.hasOwnProperty(XH)&&n.__forward_ref__===Hr}function Q(n){return{token:n.token,providedIn:n.providedIn||null,factory:n.factory,value:void 0}}function Gi(n){return{providers:n.providers||[],imports:n.imports||[]}}function vm(n){return PP(n,w1)||PP(n,E1)}function b1(n){return vm(n)!==null}function PP(n,e){return n.hasOwnProperty(e)?n[e]:null}function QH(n){let e=n&&(n[w1]||n[E1]);return e||null}function MP(n){return n&&(n.hasOwnProperty(NP)||n.hasOwnProperty(ZH))?n[NP]:null}var w1=Tt({\u0275prov:Tt}),NP=Tt({\u0275inj:Tt}),E1=Tt({ngInjectableDef:Tt}),ZH=Tt({ngInjectorDef:Tt}),ue=class{constructor(e,t){this._desc=e,this.ngMetadataName="InjectionToken",this.\u0275prov=void 0,typeof t=="number"?this.__NG_ELEMENT_ID__=t:t!==void 0&&(this.\u0275prov=Q({token:this,providedIn:t.providedIn||"root",factory:t.factory}))}get multi(){return this}toString(){return`InjectionToken ${this._desc}`}};function I1(n){return n&&!!n.\u0275providers}var JH=Tt({\u0275cmp:Tt}),eq=Tt({\u0275dir:Tt}),tq=Tt({\u0275pipe:Tt}),nq=Tt({\u0275mod:Tt}),em=Tt({\u0275fac:Tt}),hd=Tt({__NG_ELEMENT_ID__:Tt}),OP=Tt({__NG_ENV_ID__:Tt});function gi(n){return typeof n=="string"?n:n==null?"":String(n)}function rq(n){return typeof n=="function"?n.name||n.toString():typeof n=="object"&&n!=null&&typeof n.type=="function"?n.type.name||n.type.toString():gi(n)}function iq(n,e){let t=e?`. Dependency path: ${e.join(" > ")} > ${n}`:"";throw new we(-200,n)}function E0(n,e){throw new we(-201,!1)}var Ye=function(n){return n[n.Default=0]="Default",n[n.Host=1]="Host",n[n.Self=2]="Self",n[n.SkipSelf=4]="SkipSelf",n[n.Optional=8]="Optional",n}(Ye||{}),Ew;function T1(){return Ew}function pr(n){let e=Ew;return Ew=n,e}function A1(n,e,t){let r=vm(n);if(r&&r.providedIn=="root")return r.value===void 0?r.value=r.factory():r.value;if(t&Ye.Optional)return null;if(e!==void 0)return e;E0(n,"Injector")}var sq={},fd=sq,Iw="__NG_DI_FLAG__",tm="ngTempTokenPath",oq="ngTokenPath",aq=/\n/gm,cq="\u0275",LP="__source",dl;function lq(){return dl}function Po(n){let e=dl;return dl=n,e}function uq(n,e=Ye.Default){if(dl===void 0)throw new we(-203,!1);return dl===null?A1(n,void 0,e):dl.get(n,e&Ye.Optional?null:void 0,e)}function Y(n,e=Ye.Default){return(T1()||uq)(er(n),e)}function se(n,e=Ye.Default){return Y(n,bm(e))}function bm(n){return typeof n>"u"||typeof n=="number"?n:0|(n.optional&&8)|(n.host&&1)|(n.self&&2)|(n.skipSelf&&4)}function Tw(n){let e=[];for(let t=0;t<n.length;t++){let r=er(n[t]);if(Array.isArray(r)){if(r.length===0)throw new we(900,!1);let i,s=Ye.Default;for(let o=0;o<r.length;o++){let a=r[o],c=dq(a);typeof c=="number"?c===-1?i=a.token:s|=c:i=a}e.push(Y(i,s))}else e.push(Y(r))}return e}function C1(n,e){return n[Iw]=e,n.prototype[Iw]=e,n}function dq(n){return n[Iw]}function hq(n,e,t,r){let i=n[tm];throw e[LP]&&i.unshift(e[LP]),n.message=fq(` 5`+n.message,i,t,r),n[oq]=i,n[tm]=null,n}function fq(n,e,t,r=null){n=n&&n.charAt(0)===` 6`&&n.charAt(1)==cq?n.slice(2):n;let i=tr(e);if(Array.isArray(e))i=e.map(tr).join(" -> ");else if(typeof e=="object"){let s=[];for(let o in e)if(e.hasOwnProperty(o)){let a=e[o];
6s.push(o+":"+(typeof a=="string"?JSON.stringify(a):tr(a)))}i=`{${s.join(", ")}}`}return`${t}${r?"("+r+")":""}[${i}]: ${n.replace(aq,` 7 `)}`}var kt=C1(_1("Optional"),8);var S1=C1(_1("SkipSelf"),4);function ka(n,e){let t=n.hasOwnProperty(em);return t?n[em]:null}function pq(n,e,t){if(n.length!==e.length)return!1;for(let r=0;r<n.length;r++){let i=n[r],s=e[r];if(t&&(i=t(i),s=t(s)),s!==i)return!1}return!0}function mq(n){return n.flat(Number.POSITIVE_INFINITY)}function I0(n,e){n.forEach(t=>Array.isArray(t)?I0(t,e):e(t))}function x1(n,e,t){e>=n.length?n.push(t):n.splice(e,0,t)}function nm(n,e){return e>=n.length-1?n.pop():n.splice(e,1)[0]}function gq(n,e){let t=[];for(let r=0;r<n;r++)t.push(e);return t}function yq(n,e,t,r){let i=n.length;if(i==e)n.push(t,r);else if(i===1)n.push(r,n[0]),n[0]=t;else{for(i--,n.push(n[i-1],n[i]);i>e;){let s=i-2;n[i]=n[s],i--}n[e]=t,n[e+1]=r}}function _q(n,e,t){let r=Sd(n,e);return r>=0?n[r|1]=t:(r=~r,yq(n,r,e,t)),r}function aw(n,e){let t=Sd(n,e);if(t>=0)return n[t|1]}function Sd(n,e){return vq(n,e,1)}function vq(n,e,t){let r=0,i=n.length>>t;for(;i!==r;){let s=r+(i-r>>1),o=n[s<<t];if(e===o)return s<<t;o>e?i=s:r=s+1}return~(i<<t)}var fl={},Br=[],pl=new ue(""),D1=new ue("",-1),R1=new ue(""),rm=class{get(e,t=fd){if(t===fd){let r=new Error(`NullInjectorError: No provider for ${tr(e)}!`);throw r.name="NullInjectorError",r}return t}},k1=function(n){return n[n.OnPush=0]="OnPush",n[n.Default=1]="Default",n}(k1||{}
vendor: 4,636 bytes, line 7
7),qi=function(n){return n[n.Emulated=0]="Emulated",n[n.None=2]="None",n[n.ShadowDom=3]="ShadowDom",n}(qi||{}),Cr=function(n){return n[n.None=0]="None",n[n.SignalBased=1]="SignalBased",n[n.HasDecoratorInputTransform=2]="HasDecoratorInputTransform",n}(Cr||{});function bq(n,e,t){let r=n.length;for(;;){let i=n.indexOf(e,t);if(i===-1)return i;if(i===0||n.charCodeAt(i-1)<=32){let s=e.length;if(i+s===r||n.charCodeAt(i+s)<=32)return i}t=i+1}}function Aw(n,e,t){let r=0;for(;r<t.length;){let i=t[r];if(typeof i=="number"){if(i!==0)break;r++;let s=t[r++],o=t[r++],a=t[r++];n.setAttribute(e,o,a,s)}else{let s=i,o=t[++r];Eq(s)?n.setProperty(e,s,o):n.setAttribute(e,s,o),r++}}return r}function wq(n){return n===3||n===4||n===6}function Eq(n){return n.charCodeAt(0)===64}function pd(n,e){if(!(e===null||e.length===0))if(n===null||n.length===0)n=e.slice();else{let t=-1;for(let r=0;r<e.length;r++){let i=e[r];typeof i=="number"?t=i:t===0||(t===-1||t===2?FP(n,t,i,null,e[++r]):FP(n,t,i,null,null))}}return n}function FP(n,e,t,r,i){let s=0,o=n.length;if(e===-1)o=-1;else for(;s<n.length;){let a=n[s++];if(typeof a=="number"){if(a===e){o=-1;break}else if(a>e){o=s-1;break}}}for(;s<n.length;){let a=n[s];if(typeof a=="number")break;if(a===t){if(r===null){i!==null&&(n[s+1]=i);return}else if(r===n[s+1]){n[s+2]=i;return}}s++,r!==null&&s++,i!==null&&s++}o!==-1&&(n.splice(o,0,e),s=o+1),n.splice(s++,0,t),r!==null&&n.splice(s++,0,r),i!==null&&n.splice(s++,0,i)}var P1="ng-template";function Iq(n,e,t,r){let i=0;if(r){for(;i<e.length&&typeof e[i]=="string";i+=2)if(e[i]==="class"&&bq(e[i+1].toLowerCase(),t,0)!==-1)return!0}else if(T0(n))return!1;if(i=e.indexOf(1,i),i>-1){let s;for(;++i<e.length&&typeof(s=e[i])=="string";)if(s.toLowerCase()===t)return!0}return!1}function T0(n){return n.type===4&&n.value!==P1}function Tq(n,e,t){let r=n.type===4&&!t?P1:n.value;return e===r}function Aq(n,e,t){let r=4,i=n.attrs,s=i!==null?xq(i):0,o=!1;for(let a=0;a<e.length;a++){let c=e[a];if(typeof c=="number"){if(!o&&!mi(r)&&!mi(c))return!1;if(o&&mi(c))continue;o=!1,r=c|r&1;continue}if(!o)if(r&4){if(r=2|r&1,c!==""&&!Tq(n,c,t)||c===""&&e.length===1){if(mi(r))return!1;o=!0}}else if(r&8){if(i===null||!Iq(n,i,c,t)){if(mi(r))return!1;o=!0}}else{let l=e[++a],u=Cq(c,i,T0(n),t);if(u===-1){if(mi(r))return!1;o=!0;continue}if(l!==""){let d;if(u>s?d="":d=i[u+1].toLowerCase(),r&2&&l!==d){if(mi(r))return!1;o=!0}}}}return mi(r)||o}function mi(n){return(n&1)===0}function Cq(n,e,t,r){if(e===null)return-1;let i=0;if(r||!t){let s=!1;for(;i<e.length;){let o=e[i];if(o===n)return i;if(o===3||o===6)s=!0;else if(o===1||o===2){let a=e[++i];for(;typeof a=="string";)a=e[++i];continue}else{if(o===4)break;if(o===0){i+=4;continue}}i+=s?1:2}return-1}else return Dq(e,n)}function M1(n,e,t=!1){for(let r=0;r<e.length;r++)if(Aq(n,e[r],t))return!0;return!1}function Sq(n){let e=n.attrs;if(e!=null){let t=e.indexOf(5);if(!(t&1))return e[t+1]}return null}function xq(n){for(let e=0;e<n.length;e++){let t=n[e];if(wq(t))return e}return n.length}function Dq(n,e){let t=n.indexOf(4);if(t>-1)for(t++;t<n.length;){let r=n[t];if(typeof r=="number")return-1;if(r===e)return t;t++}return-1}function Rq(n,e){e:for(let t=0;t<e.length;t++){let r=e[t];if(n.length===r.length){for(let i=0;i<n.length;i++)if(n[i]!==r[i])continue e;return!0}}return!1}function VP(n,e){return n?":not("+e.trim()+")":e}function kq(n){let e=n[0],t=1,r=2,i="",s=!1;for(;t<n.length;){let o=n[t];if(typeof o=="string")if(r&2){let a=n[++t];i+="["+o+(a.length>0?'="'+a+'"':"")+"]"}else r&8?i+="."+o:r&4&&(i+=" "+o);else i!==""&&!mi(o)&&(e+=VP(s,i),i=""),r=o,s=s||!mi(r);t++}return i!==""&&(e+=VP(s,i)),e}function Pq(n){return n.map(kq).join(",")}function Mq(n){let e=[],t=[],r=1,i=2;for(;r<n.length;){let s=n[r];if(typeof s=="string")i===2?s!==""&&e.push(s,n[++r]):i===8&&t.push(s);else{if(!mi(i))break;i=s}r++}return{attrs:e,classes:t}}function xr(n){return Cd(()=>{let e=V1(n),t=D(_({},e),{decls:n.decls,vars:n.vars,template:n.template,consts:n.consts||null,ngContentSelectors:n.ngContentSelectors,onPush:n.changeDetection===k1.OnPush,directiveDefs:null,pipeDefs:null,dependencies:e.standalone&&n.dependencies||null,getStandaloneInjector:null,signals:n.signals??!1,data:n.data||{},encapsulation:n.encapsulation||qi.Emulated,styles:n.styles||Br,_:null,schemas:n.schemas||null,tView:null,id:""});j1(t);let r=n.dependencies;return t.directiveDefs=$P(r,!1),t.pipeDefs=$P(r,!0),t.id=Lq(t),t})}function Nq(n){return Pa(n)||N1(n)}function Oq(n){return n!==null}function Wi(n){return Cd(()=>({type:n.type,bootstrap:n.bootstrap||Br,declarations:n.declarations||Br,imports:n.imports||Br,exports:n.exports||Br,transitiveCompileScopes:null,
7schemas:n.schemas||null,id:n.id||null}))}function jP(n,e){if(n==null)return fl;let t={};for(let r in n)if(n.hasOwnProperty(r)){let i=n[r],s,o,a=Cr.None;Array.isArray(i)?(a=i[0],s=i[1],o=i[2]??s):(s=i,o=i),e?(t[s]=a!==Cr.None?[r,a]:r,e[s]=o):t[s]=r}return t}function Mt(n){return Cd(()=>{let e=V1(n);return j1(e),e})}function wm(n){return{type:n.type,name:n.name,factory:null,pure:n.pure!==!1,standalone:n.standalone===!0,onDestroy:n.type.prototype.ngOnDestroy||null}}function Pa(n){return n[JH]||null}function N1(n){return n[eq]||null}function O1(n){return n[tq]||null}function L1(n){let e=Pa(n)||N1(n)||O1(n);return e!==null?e.standalone:!1}function F1(n,e){let t=n[nq]||null;if(!t&&e===!0)throw new Error(`Type ${tr(n)} does not have '\u0275mod' property.`);return t}function V1(n){let e={};return{type:n.type,providersResolver:null,factory:null,hostBindings:n.hostBindings||null,hostVars:n.hostVars||0,hostAttrs:n.hostAttrs||null,contentQueries:n.contentQueries||null,declaredInputs:e,inputTransforms:null,inputConfig:n.inputs||fl,exportAs:n.exportAs||null,standalone:n.standalone===!0,signals:n.signals===!0,selectors:n.selectors||Br,viewQuery:n.viewQuery||null,features:n.features||null,setInput:null,findHostDirectiveDefs:null,hostDirectives:null,inputs:jP(n.inputs,e),outputs:jP(n.outputs),debugInfo:null}}function j1(n){n.features?.forEach(e=>e(n))}function $P(n,e){if(!n)return null;let t=e?O1:Nq;return()=>(typeof n=="function"?n():n).map(r=>t(r)).filter(Oq)}
vendor: 1,964 bytes, line 7
7function Lq(n){let e=0,t=[n.selectors,n.ngContentSelectors,n.hostVars,n.hostAttrs,n.consts,n.vars,n.decls,n.encapsulation,n.standalone,n.signals,n.exportAs,JSON.stringify(n.inputs),JSON.stringify(n.outputs),Object.getOwnPropertyNames(n.type.prototype),!!n.contentQueries,!!n.viewQuery].join("|");for(let i of t)e=Math.imul(31,e)+i.charCodeAt(0)<<0;return e+=2147483648,"c"+e}function Nn(n){return{\u0275providers:n}}function Fq(...n){return{\u0275providers:$1(!0,n),\u0275fromNgModule:!0}}function $1(n,...e){let t=[],r=new Set,i,s=o=>{t.push(o)};return I0(e,o=>{let a=o;Cw(a,s,[],r)&&(i||=[],i.push(a))}),i!==void 0&&U1(i,s),t}function U1(n,e){for(let t=0;t<n.length;t++){let{ngModule:r,providers:i}=n[t];A0(i,s=>{e(s,r)})}}function Cw(n,e,t,r){if(n=er(n),!n)return!1;let i=null,s=MP(n),o=!s&&Pa(n);if(!s&&!o){let c=n.ngModule;if(s=MP(c),s)i=c;else return!1}else{if(o&&!o.standalone)return!1;i=n}let a=r.has(i);if(o){if(a)return!1;if(r.add(i),o.dependencies){let c=typeof o.dependencies=="function"?o.dependencies():o.dependencies;for(let l of c)Cw(l,e,t,r)}}else if(s){if(s.imports!=null&&!a){r.add(i);let l;try{I0(s.imports,u=>{Cw(u,e,t,r)&&(l||=[],l.push(u))})}finally{}l!==void 0&&U1(l,e)}if(!a){let l=ka(i)||(()=>new i);e({provide:i,useFactory:l,deps:Br},i),e({provide:R1,useValue:i,multi:!0},i),e({provide:pl,useValue:()=>Y(i),multi:!0},i)}let c=s.providers;if(c!=null&&!a){let l=n;A0(c,u=>{e(u,l)})}}else return!1;return i!==n&&n.providers!==void 0}function A0(n,e){for(let t of n)I1(t)&&(t=t.\u0275providers),Array.isArray(t)?A0(t,e):e(t)}var Vq=Tt({provide:String,useValue:Tt});function B1(n){return n!==null&&typeof n=="object"&&Vq in n}function jq(n){return!!(n&&n.useExisting)}function $q(n){return!!(n&&n.useFactory)}function ml(n){return typeof n=="function"}function Uq(n){return!!n.useClass}var Em=new ue(""),Kp={},Bq={},cw;function C0(){return cw===void 0&&(cw=new rm),cw}var mr=class{},md=class extends mr{get destroyed(){return this._destroyed}
7constructor(e,t,r,i){super(),this.parent=t,this.source=r,this.scopes=i,this.records=new Map,this._ngOnDestroyHooks=new Set,this._onDestroyHooks=[],this._destroyed=!1,xw(e,o=>this.processProvider(o)),this.records.set(D1,cl(void 0,this)),i.has("environment")&&this.records.set(mr,cl(void 0,this));let s=this.records.get(Em);s!=null&&typeof s.value=="string"&&this.scopes.add(s.value),this.injectorDefTypes=new Set(this.get(R1,Br,Ye.Self))}destroy(){this.assertNotDestroyed(),this._destroyed=!0;let e=at(null);try{for(let r of this._ngOnDestroyHooks)r.ngOnDestroy();let t=this._onDestroyHooks;this._onDestroyHooks=[];for(let r of t)r()}finally{this.records.clear(),this._ngOnDestroyHooks.clear(),this.injectorDefTypes.clear(),at(e)}}onDestroy(e){return this.assertNotDestroyed(),this._onDestroyHooks.push(e),()=>this.removeOnDestroy(e)}runInContext(e){this.assertNotDestroyed();let t=Po(this),r=pr(void 0),i;try{return e()}finally{Po(t),pr(r)}}get(e,t=fd,r=Ye.Default){if(this.assertNotDestroyed(),e.hasOwnProperty(OP))return e[OP](this);r=bm(r);let i,s=Po(this),o=pr(void 0);try{if(!(r&Ye.SkipSelf)){let c=this.records.get(e);if(c===void 0){let l=Wq(e)&&vm(e);l&&this.injectableDefInScope(l)?c=cl(Sw(e),Kp):c=null,this.records.set(e,c)}if(c!=null)return this.hydrate(e,c)}let a=r&Ye.Self?C0():this.parent;return t=r&Ye.Optional&&t===fd?null:t,a.get(e,t)}catch(a){if(a.name==="NullInjectorError"){if((a[tm]=a[tm]||[]).unshift(tr(e)),s)throw a;return hq(a,e,"R3InjectorError",this.source)}else throw a}finally{pr(o),Po(s)}}resolveInjectorInitializers(){let e=at(null),t=Po(this),r=pr(void 0),i;try{let s=this.get(pl,Br,Ye.Self);for(let o of s)o()}finally{Po(t),pr(r),at(e)}}toString(){let e=[],t=this.records;for(let r of t.keys())e.push(tr(r));return`R3Injector[${e.join(", ")}]`}assertNotDestroyed(){if(this._destroyed)throw new we(205,!1)}processProvider(e){e=er(e);let t=ml(e)?e:er(e&&e.provide),r=qq(e);if(!ml(e)&&e.multi===!0){let i=this.records.get(t);i||(i=cl(void 0,Kp,!0),i.factory=()=>Tw(i.multi),this.records.set(t,i)),t=e,i.multi.push(e)}this.records.set(t,r)}hydrate(e,t){let r=at(null);try{return t.value===Kp&&(t.value=Bq,t.value=t.factory()),typeof t.value=="object"&&t.value&&Gq(t.value)&&this._ngOnDestroyHooks.add(t.value),t.value}finally{at(r)}}injectableDefInScope(e){if(!e.providedIn)return!1;let t=er(e.providedIn);return typeof t=="string"?t==="any"||this.scopes.has(t):this.injectorDefTypes.has(t)}removeOnDestroy(e){let t=this._onDestroyHooks.indexOf(e);t!==-1&&this._onDestroyHooks.splice(t,1)}};function Sw(n){let e=vm(n),t=e!==null?e.factory:ka(n);if(t!==null)return t;if(n instanceof ue)throw new we(204,!1);if(n instanceof Function)return Hq(n);throw new we(204,!1)}function Hq(n){if(n.length>0)throw new we(204,!1);let t=QH(n);return t!==null?()=>t.factory(n):()=>new n}function qq(n){if(B1(n))return cl(void 0,n.useValue);{let e=H1(n);return cl(e,Kp)}}function H1(n,e,t){let r;if(ml(n)){let i=er(n);return ka(i)||Sw(i)}else if(B1(n))r=()=>er(n.useValue);else if($q(n))r=()=>n.useFactory(...Tw(n.deps||[]));else if(jq(n))r=()=>Y(er(n.useExisting));else{let i=er(n&&(n.useClass||n.provide));if(zq(n))r=()=>new i(...Tw(n.deps));else return ka(i)||Sw(i)}return r}function cl(n,e,t=!1){return{factory:n,value:e,multi:t?[]:void 0}}function zq(n){return!!n.deps}function Gq(n){return n!==null&&typeof n=="object"&&typeof n.ngOnDestroy=="function"}function Wq(n){return typeof n=="function"||typeof n=="object"&&n instanceof ue}function xw(n,e){for(let t of n)Array.isArray(t)?xw(t,e):t&&I1(t)?xw(t.\u0275providers,e):e(t)}function Fs(n,e){n instanceof md&&n.assertNotDestroyed();let t,r=Po(n),i=pr(void 0);try{return e()}finally{Po(r),pr(i)}}function Kq(){return T1()!==void 0||lq()!=null}function Yq(n){return typeof n=="function"}var Vs=0,Be=1,Ce=2,bn=3,yi=4,Dr=5,gd=6,yd=7,_i=8,gl=9,vi=10,Gt=11,_d=12,UP=13,bl=14,bi=15,xd=16,ll=17,Ps=18,Im=19,q1=20,Mo=21,lw=22,Ma=23,Sr=25,z1=1;var Na=7,im=8,yl=9,Ar=10,S0=function(n){return n[n.None=0]="None",n[n.HasTransplantedViews=2]="HasTransplantedViews",n}(S0||{});function Da(n){return Array.isArray(n)&&typeof n[z1]=="object"}function js(n){return Array.isArray(n)&&n[z1]===!0}function x0(n){return(n.flags&4)!==0}
7function Tm(n){return n.componentOffset>-1}function Am(n){return(n.flags&1)===1}function No(n){return!!n.template}function Xq(n){return(n[Ce]&512)!==0}var Dw=class{constructor(e,t,r){this.previousValue=e,this.currentValue=t,this.firstChange=r}isFirstChange(){return this.firstChange}};function G1(n,e,t,r){e!==null?e.applyValueToInputSignal(e,r):n[t]=r}function Ei(){return W1}function W1(n){return n.type.prototype.ngOnChanges&&(n.setInput=Zq),Qq}Ei.ngInherit=!0;function Qq(){let n=Y1(this),e=n?.current;if(e){let t=n.previous;if(t===fl)n.previous=e;else for(let r in e)t[r]=e[r];n.current=null,this.ngOnChanges(e)}}function Zq(n,e,t,r,i){let s=this.declaredInputs[r],o=Y1(n)||Jq(n,{previous:fl,current:null}),a=o.current||(o.current={}),c=o.previous,l=c[s];a[s]=new Dw(l&&l.currentValue,t,c===fl),G1(n,e,i,t)}var K1="__ngSimpleChanges__";function Y1(n){return n[K1]||null}function Jq(n,e){return n[K1]=e}var BP=null;var Bi=function(n,e,t){BP?.(n,e,t)},X1="svg",ez="math",tz=!1;function nz(){return tz}function zi(n){for(;Array.isArray(n);)n=n[Vs];return n}function Q1(n,e){return zi(e[n])}function qr(n,e){return zi(e[n.index])}function Z1(n,e){return n.data[e]}function J1(n,e){return n[e]}function Vo(n,e){let t=e[n];return Da(t)?t:t[Vs]}function rz(n){return(n[Ce]&4)===4}function D0(n){return(n[Ce]&128)===128}function iz(n){return js(n[bn])}function _l(n,e){return e==null?null:n[e]}function eM(n){n[ll]=0}function sz(n){n[Ce]&1024||(n[Ce]|=1024,D0(n)&&vd(n))}function oz(n,e){for(;n>0;)e=e[bl],n--;return e}function R0(n){return!!(n[Ce]&9216||n[Ma]?.dirty)}function Rw(n){n[vi].changeDetectionScheduler?.notify(1),R0(n)?vd(n):n[Ce]&64&&(nz()?(n[Ce]|=1024,vd(n)):n[vi].changeDetectionScheduler?.notify())}function vd(n){n[vi].changeDetectionScheduler?.notify();let e=bd(n);for(;e!==null&&!(e[Ce]&8192||(e[Ce]|=8192,!D0(e)));)e=bd(e)}function tM(n,e){if((n[Ce]&256)===256)throw new we(911,!1);n[Mo]===null&&(n[Mo]=[]),n[Mo].push(e)}function az(n,e){if(n[Mo]===null)return;let t=n[Mo].indexOf(e);t!==-1&&n[Mo].splice(t,1)}function bd(n){let e=n[bn];return js(e)?e[bn]:e}var Oe={lFrame:lM(null),bindingsEnabled:!0,skipHydrationRootTNode:null};function cz(){return Oe.lFrame.elementDepthCount}function lz(){Oe.lFrame.elementDepthCount++}function uz(){Oe.lFrame.elementDepthCount--}function nM(){return Oe.bindingsEnabled}function rM(){return Oe.skipHydrationRootTNode!==null}function dz(n){return Oe.skipHydrationRootTNode===n}function hz(){Oe.skipHydrationRootTNode=null}function He(){return Oe.lFrame.lView}function cn(){return Oe.lFrame.tView}function ge(n){return Oe.lFrame.contextLView=n,n[_i]}function ye(n){return Oe.lFrame.contextLView=null,n}function gr(){let n=iM();for(;n!==null&&n.type===64;)n=n.parent;return n}function iM(){return Oe.lFrame.currentTNode}function fz(){let n=Oe.lFrame,e=n.currentTNode;return n.isParent?e:e.parent}function $a(n,e){let t=Oe.lFrame;t.currentTNode=n,t.isParent=e}function k0(){return Oe.lFrame.isParent}function P0(){Oe.lFrame.isParent=!1}function pz(){return Oe.lFrame.contextLView}function wl(){let n=Oe.lFrame,e=n.bindingRootIndex;return e===-1&&(e=n.bindingRootIndex=n.tView.bindingStartIndex),e}function sM(){return Oe.lFrame.bindingIndex}function mz(n){return Oe.lFrame.bindingIndex=n}function Cm(){return Oe.lFrame.bindingIndex++}function M0(n){let e=Oe.lFrame,t=e.bindingIndex;return e.bindingIndex=e.bindingIndex+n,t}function gz(){return Oe.lFrame.inI18n}function yz(n,e){let t=Oe.lFrame;t.bindingIndex=t.bindingRootIndex=n,kw(e)}function _z(){return Oe.lFrame.currentDirectiveIndex}function kw(n){Oe.lFrame.currentDirectiveIndex=n}function vz(n){let e=Oe.lFrame.currentDirectiveIndex;return e===-1?null:n[e]}function oM(){return Oe.lFrame.currentQueryIndex}function N0(n){Oe.lFrame.currentQueryIndex=n}function bz(n){let e=n[Be];return e.type===2?e.declTNode:e.type===1?n[Dr]:null}function aM(n,e,t){if(t&Ye.SkipSelf){let i=e,s=n;for(;i=i.parent,i===null&&!(t&Ye.Host);)if(i=bz(s),i===null||(s=s[bl],i.type&10))break;if(i===null)return!1;e=i,n=s}let r=Oe.lFrame=cM();return r.currentTNode=e,r.lView=n,!0}function O0(n){let e=cM(),t=n[Be];Oe.lFrame=e,e.currentTNode=t.firstChild,e.lView=n,e.tView=t,e.contextLView=n,e.bindingIndex=t.bindingStartIndex,e.inI18n=!1}function cM(){let n=Oe.lFrame,e=n===null?null:n.child;return e===null?lM(n):e}function lM(n){let e={currentTNode:null,isParent:!0,lView:null,tView:null,
vendor: 4,414 bytes, line 7
7selectedIndex:-1,contextLView:null,elementDepthCount:0,currentNamespace:null,currentDirectiveIndex:-1,bindingRootIndex:-1,bindingIndex:-1,currentQueryIndex:0,parent:n,child:null,inI18n:!1};return n!==null&&(n.child=e),e}function uM(){let n=Oe.lFrame;return Oe.lFrame=n.parent,n.currentTNode=null,n.lView=null,n}var dM=uM;function L0(){let n=uM();n.isParent=!0,n.tView=null,n.selectedIndex=-1,n.contextLView=null,n.elementDepthCount=0,n.currentDirectiveIndex=-1,n.currentNamespace=null,n.bindingRootIndex=-1,n.bindingIndex=-1,n.currentQueryIndex=0}function wz(n){return(Oe.lFrame.contextLView=oz(n,Oe.lFrame.contextLView))[_i]}function jo(){return Oe.lFrame.selectedIndex}function Oa(n){Oe.lFrame.selectedIndex=n}function F0(){let n=Oe.lFrame;return Z1(n.tView,n.selectedIndex)}function V0(){Oe.lFrame.currentNamespace=X1}function j0(){Ez()}function Ez(){Oe.lFrame.currentNamespace=null}function Iz(){return Oe.lFrame.currentNamespace}var hM=!0;function Sm(){return hM}function xm(n){hM=n}function Tz(n,e,t){let{ngOnChanges:r,ngOnInit:i,ngDoCheck:s}=e.type.prototype;if(r){let o=W1(e);(t.preOrderHooks??=[]).push(n,o),(t.preOrderCheckHooks??=[]).push(n,o)}i&&(t.preOrderHooks??=[]).push(0-n,i),s&&((t.preOrderHooks??=[]).push(n,s),(t.preOrderCheckHooks??=[]).push(n,s))}function Dm(n,e){for(let t=e.directiveStart,r=e.directiveEnd;t<r;t++){let s=n.data[t].type.prototype,{ngAfterContentInit:o,ngAfterContentChecked:a,ngAfterViewInit:c,ngAfterViewChecked:l,ngOnDestroy:u}=s;o&&(n.contentHooks??=[]).push(-t,o),a&&((n.contentHooks??=[]).push(t,a),(n.contentCheckHooks??=[]).push(t,a)),c&&(n.viewHooks??=[]).push(-t,c),l&&((n.viewHooks??=[]).push(t,l),(n.viewCheckHooks??=[]).push(t,l)),u!=null&&(n.destroyHooks??=[]).push(t,u)}}function Yp(n,e,t){fM(n,e,3,t)}function Xp(n,e,t,r){(n[Ce]&3)===t&&fM(n,e,t,r)}function uw(n,e){let t=n[Ce];(t&3)===e&&(t&=16383,t+=1,n[Ce]=t)}function fM(n,e,t,r){let i=r!==void 0?n[ll]&65535:0,s=r??-1,o=e.length-1,a=0;for(let c=i;c<o;c++)if(typeof e[c+1]=="number"){if(a=e[c],r!=null&&a>=r)break}else e[c]<0&&(n[ll]+=65536),(a<s||s==-1)&&(Az(n,t,e,c),n[ll]=(n[ll]&4294901760)+c+2),c++}function HP(n,e){Bi(4,n,e);let t=at(null);try{e.call(n)}finally{at(t),Bi(5,n,e)}}function Az(n,e,t,r){let i=t[r]<0,s=t[r+1],o=i?-t[r]:t[r],a=n[o];i?n[Ce]>>14<n[ll]>>16&&(n[Ce]&3)===e&&(n[Ce]+=16384,HP(a,s)):HP(a,s)}var hl=-1,La=class{constructor(e,t,r){this.factory=e,this.resolving=!1,this.canSeeViewProviders=t,this.injectImpl=r}};function Cz(n){return n instanceof La}function Sz(n){return(n.flags&8)!==0}function xz(n){return(n.flags&16)!==0}function pM(n){return n!==hl}function sm(n){return n&32767}function Dz(n){return n>>16}function om(n,e){let t=Dz(n),r=e;for(;t>0;)r=r[bl],t--;return r}var Pw=!0;function am(n){let e=Pw;return Pw=n,e}var Rz=256,mM=Rz-1,gM=5,kz=0,Hi={};function Pz(n,e,t){let r;typeof t=="string"?r=t.charCodeAt(0)||0:t.hasOwnProperty(hd)&&(r=t[hd]),r==null&&(r=t[hd]=kz++);let i=r&mM,s=1<<i;e.data[n+(i>>gM)]|=s}function cm(n,e){let t=yM(n,e);if(t!==-1)return t;let r=e[Be];r.firstCreatePass&&(n.injectorIndex=e.length,dw(r.data,n),dw(e,null),dw(r.blueprint,null));let i=$0(n,e),s=n.injectorIndex;if(pM(i)){let o=sm(i),a=om(i,e),c=a[Be].data;for(let l=0;l<8;l++)e[s+l]=a[o+l]|c[o+l]}return e[s+8]=i,s}function dw(n,e){n.push(0,0,0,0,0,0,0,0,e)}function yM(n,e){return n.injectorIndex===-1||n.parent&&n.parent.injectorIndex===n.injectorIndex||e[n.injectorIndex+8]===null?-1:n.injectorIndex}function $0(n,e){if(n.parent&&n.parent.injectorIndex!==-1)return n.parent.injectorIndex;let t=0,r=null,i=e;for(;i!==null;){if(r=EM(i),r===null)return hl;if(t++,i=i[bl],r.injectorIndex!==-1)return r.injectorIndex|t<<16}return hl}function Mw(n,e,t){Pz(n,e,t)}function _M(n,e,t){if(t&Ye.Optional||n!==void 0)return n;E0(e,"NodeInjector")}function vM(n,e,t,r){if(t&Ye.Optional&&r===void 0&&(r=null),!(t&(Ye.Self|Ye.Host))){let i=n[gl],s=pr(void 0);try{return i?i.get(e,r,t&Ye.Optional):A1(e,r,t&Ye.Optional)}finally{pr(s)}}return _M(r,e,t)}function bM(n,e,t,r=Ye.Default,i){if(n!==null){if(e[Ce]&2048&&!(r&Ye.Self)){let o=Lz(n,e,t,r,Hi);if(o!==Hi)return o}let s=wM(n,e,t,r,Hi);if(s!==Hi)return s}return vM(e,t,r,i)}function wM(n,e,t,r,i){let s=Nz(t);if(typeof s=="function"){if(!aM(e,n,r))return r&Ye.Host?_M(i,t,r):vM(e,t,r,i);try{let o;if(o=s(r),o==null&&!(r&Ye.Optional))E0(t);else return o}finally{dM()}}else if(typeof s=="number"){let o=null,a=yM(n,e),c=hl,l=r&Ye.Host?e[bi][Dr]:null;
7for((a===-1||r&Ye.SkipSelf)&&(c=a===-1?$0(n,e):e[a+8],c===hl||!zP(r,!1)?a=-1:(o=e[Be],a=sm(c),e=om(c,e)));a!==-1;){let u=e[Be];if(qP(s,a,u.data)){let d=Mz(a,e,t,o,r,l);if(d!==Hi)return d}c=e[a+8],c!==hl&&zP(r,e[Be].data[a+8]===l)&&qP(s,a,e)?(o=u,a=sm(c),e=om(c,e)):a=-1}}return i}function Mz(n,e,t,r,i,s){let o=e[Be],a=o.data[n+8],c=r==null?Tm(a)&&Pw:r!=o&&(a.type&3)!==0,l=i&Ye.Host&&s===a,u=Qp(a,o,t,c,l);return u!==null?Fa(e,o,u,a):Hi}function Qp(n,e,t,r,i){let s=n.providerIndexes,o=e.data,a=s&1048575,c=n.directiveStart,l=n.directiveEnd,u=s>>20,d=r?a:a+u,f=i?a+u:l;for(let p=d;p<f;p++){let y=o[p];if(p<c&&t===y||p>=c&&y.type===t)return p}if(i){let p=o[c];if(p&&No(p)&&p.type===t)return c}return null}function Fa(n,e,t,r){let i=n[t],s=e.data;if(Cz(i)){let o=i;o.resolving&&iq(rq(s[t]));let a=am(o.canSeeViewProviders);o.resolving=!0;let c,l=o.injectImpl?pr(o.injectImpl):null,u=aM(n,r,Ye.Default);try{i=n[t]=o.factory(void 0,s,n,r),e.firstCreatePass&&t>=r.directiveStart&&Tz(t,s[t],e)}finally{l!==null&&pr(l),am(a),o.resolving=!1,dM()}}return i}function Nz(n){if(typeof n=="string")return n.charCodeAt(0)||0;let e=n.hasOwnProperty(hd)?n[hd]:void 0;return typeof e=="number"?e>=0?e&mM:Oz:e}function qP(n,e,t){let r=1<<n;return!!(t[e+(n>>gM)]&r)}function zP(n,e){return!(n&Ye.Self)&&!(n&Ye.Host&&e)}var Ra=class{constructor(e,t){this._tNode=e,this._lView=t}get(e,t,r){return bM(this._tNode,this._lView,e,bm(r),t)}};function Oz(){return new Ra(gr(),He())}function zr(n){return Cd(()=>{let e=n.prototype.constructor,t=e[em]||Nw(e),r=Object.prototype,i=Object.getPrototypeOf(n.prototype).constructor;for(;i&&i!==r;){let s=i[em]||Nw(i);if(s&&s!==t)return s;i=Object.getPrototypeOf(i)}return s=>new s})}function Nw(n){return v1(n)?()=>{let e=Nw(er(n));return e&&e()}:ka(n)}function Lz(n,e,t,r,i){let s=n,o=e;for(;s!==null&&o!==null&&o[Ce]&2048&&!(o[Ce]&512);){let a=wM(s,o,t,r|Ye.Self,Hi);if(a!==Hi)return a;let c=s.parent;if(!c){let l=o[q1];if(l){let u=l.get(t,Hi,r);if(u!==Hi)return u}c=EM(o),o=o[bl]}s=c}return i}function EM(n){let e=n[Be],t=e.type;return t===2?e.declTNode:t===1?n[Dr]:null}function GP(n,e=null,t=null,r){let i=IM(n,e,t,r);return i.resolveInjectorInitializers(),i}function IM(n,e=null,t=null,r,i=new Set){let s=[t||Br,Fq(n)];return r=r||(typeof n=="object"?void 0:tr(n)),new md(s,e||C0(),r||null,i)}var On=(()=>{class n{static{this.THROW_IF_NOT_FOUND=fd}static{this.NULL=new rm}static create(t,r){if(Array.isArray(t))return GP({name:""},r,t,"");{let i=t.name??"";return GP({name:i},t.parent,t.providers,i)}}static{this.\u0275prov=Q({token:n,providedIn:"any",factory:()=>Y(D1)})}static{this.__NG_ELEMENT_ID__=-1}}return n})();var Fz="ngOriginalError";function hw(n){return n[Fz]}var Ms=class{constructor(){this._console=console}handleError(e){let t=this._findOriginalError(e);this._console.error("ERROR",e),t&&this._console.error("ORIGINAL ERROR",t)}_findOriginalError(e){let t=e&&hw(e);for(;t&&hw(t);)t=hw(t);return t||null}},TM=new ue("",{providedIn:"root",factory:()=>se(Ms).handleError.bind(void 0)}),AM=(()=>{class n{static{this.__NG_ELEMENT_ID__=Vz}static{this.__NG_ENV_ID__=t=>t}}return n})(),Ow=class extends AM{constructor(e){super(),this._lView=e}onDestroy(e){return tM(this._lView,e),()=>az(this._lView,e)}};function Vz(){return new Ow(He())}function jz(){return El(gr(),He())}function El(n,e){return new nr(qr(n,e))}var nr=(()=>{class n{constructor(t){this.nativeElement=t}static{this.__NG_ELEMENT_ID__=jz}}return n})();function $z(n){return n instanceof nr?n.nativeElement:n}var Lw=class extends mt{constructor(e=!1){super(),this.destroyRef=void 0,this.__isAsync=e,Kq()&&(this.destroyRef=se(AM,{optional:!0})??void 0)}emit(e){let t=at(null);try{super.next(e)}finally{at(t)}}subscribe(e,t,r){let i=e,s=t||(()=>null),o=r;if(e&&typeof e=="object"){let c=e;i=c.next?.bind(c),s=c.error?.bind(c),o=c.complete?.bind(c)}this.__isAsync&&(s=fw(s),i&&(i=fw(i)),o&&(o=fw(o)));let a=super.subscribe({next:i,error:s,complete:o});return e instanceof zt&&e.add(a),a}};function fw(n){return e=>{setTimeout(n,void 0,e)}}var $t=Lw;function Uz(){return this._results[Symbol.iterator]()}var Fw=class n{get changes(){return this._changes??=new $t}constructor(e=!1){this._emitDistinctChangesOnly=e,this.dirty=!0,this._onDirty=void 0,this._results=[],this._changesDetected=!1,this._changes=void 0,this.length=0,this.first=void 0,this.last=void 0;let t=n.prototype;t[Symbol.iterator]||(t[Symbol.iterator]=Uz)}get(e){return this._results[e]}map(e){return this._results.map(e)}filter(e){return this._results.filter(e)}find(e){return this._results.find(e)}reduce(e,t){return this._results.reduce(e,t)}
vendor: 4,319 bytes, line 7
7forEach(e){this._results.forEach(e)}some(e){return this._results.some(e)}toArray(){return this._results.slice()}toString(){return this._results.toString()}reset(e,t){this.dirty=!1;let r=mq(e);(this._changesDetected=!pq(this._results,r,t))&&(this._results=r,this.length=r.length,this.last=r[this.length-1],this.first=r[0])}notifyOnChanges(){this._changes!==void 0&&(this._changesDetected||!this._emitDistinctChangesOnly)&&this._changes.emit(this)}onDirty(e){this._onDirty=e}setDirty(){this.dirty=!0,this._onDirty?.()}destroy(){this._changes!==void 0&&(this._changes.complete(),this._changes.unsubscribe())}};function CM(n){return(n.flags&128)===128}var SM=new Map,Bz=0;function Hz(){return Bz++}function qz(n){SM.set(n[Im],n)}function zz(n){SM.delete(n[Im])}var WP="__ngContext__";function Oo(n,e){Da(e)?(n[WP]=e[Im],qz(e)):n[WP]=e}function xM(n){return RM(n[_d])}function DM(n){return RM(n[yi])}function RM(n){for(;n!==null&&!js(n);)n=n[yi];return n}var Vw;function kM(n){Vw=n}function Gz(){if(Vw!==void 0)return Vw;if(typeof document<"u")return document;throw new we(210,!1)}var U0=new ue("",{providedIn:"root",factory:()=>Wz}),Wz="ng",B0=new ue(""),Gr=new ue("",{providedIn:"platform",factory:()=>"unknown"});var H0=new ue("",{providedIn:"root",factory:()=>Gz().body?.querySelector("[ngCspNonce]")?.getAttribute("ngCspNonce")||null});var Kz="h",Yz="b";var Xz=()=>null;function q0(n,e,t=!1){return Xz(n,e,t)}var PM=!1,Qz=new ue("",{providedIn:"root",factory:()=>PM});var qp;function Zz(){if(qp===void 0&&(qp=null,xa.trustedTypes))try{qp=xa.trustedTypes.createPolicy("angular",{createHTML:n=>n,createScript:n=>n,createScriptURL:n=>n})}catch{}return qp}function Rm(n){return Zz()?.createHTML(n)||n}var Ns=class{constructor(e){this.changingThisBreaksApplicationSecurity=e}toString(){return`SafeValue must use [property]=binding: ${this.changingThisBreaksApplicationSecurity} (see ${y1})`}},jw=class extends Ns{getTypeName(){return"HTML"}},$w=class extends Ns{getTypeName(){return"Style"}},Uw=class extends Ns{getTypeName(){return"Script"}},Bw=class extends Ns{getTypeName(){return"URL"}},Hw=class extends Ns{getTypeName(){return"ResourceURL"}};function $s(n){return n instanceof Ns?n.changingThisBreaksApplicationSecurity:n}function Ua(n,e){let t=Jz(n);if(t!=null&&t!==e){if(t==="ResourceURL"&&e==="URL")return!0;throw new Error(`Required a safe ${e}, got a ${t} (see ${y1})`)}return t===e}function Jz(n){return n instanceof Ns&&n.getTypeName()||null}function MM(n){return new jw(n)}function NM(n){return new $w(n)}function OM(n){return new Uw(n)}function LM(n){return new Bw(n)}function FM(n){return new Hw(n)}function eG(n){let e=new zw(n);return tG()?new qw(e):e}var qw=class{constructor(e){this.inertDocumentHelper=e}getInertBodyElement(e){e="<body><remove></remove>"+e;try{let t=new window.DOMParser().parseFromString(Rm(e),"text/html").body;return t===null?this.inertDocumentHelper.getInertBodyElement(e):(t.removeChild(t.firstChild),t)}catch{return null}}},zw=class{constructor(e){this.defaultDoc=e,this.inertDocument=this.defaultDoc.implementation.createHTMLDocument("sanitization-inert")}getInertBodyElement(e){let t=this.inertDocument.createElement("template");return t.innerHTML=Rm(e),t}};function tG(){try{return!!new window.DOMParser().parseFromString(Rm(""),"text/html")}catch{return!1}}var nG=/^(?!javascript:)(?:[a-z0-9+.-]+:|[^&:\/?#]*(?:[\/?#]|$))/i;function km(n){return n=String(n),n.match(nG)?n:"unsafe:"+n}function Us(n){let e={};for(let t of n.split(","))e[t]=!0;return e}function Dd(...n){let e={};for(let t of n)for(let r in t)t.hasOwnProperty(r)&&(e[r]=!0);return e}var VM=Us("area,br,col,hr,img,wbr"),jM=Us("colgroup,dd,dt,li,p,tbody,td,tfoot,th,thead,tr"),$M=Us("rp,rt"),rG=Dd($M,jM),iG=Dd(jM,Us("address,article,aside,blockquote,caption,center,del,details,dialog,dir,div,dl,figure,figcaption,footer,h1,h2,h3,h4,h5,h6,header,hgroup,hr,ins,main,map,menu,nav,ol,pre,section,summary,table,ul")),sG=Dd($M,Us("a,abbr,acronym,audio,b,bdi,bdo,big,br,cite,code,del,dfn,em,font,i,img,ins,kbd,label,map,mark,picture,q,ruby,rp,rt,s,samp,small,source,span,strike,strong,sub,sup,time,track,tt,u,var,video")),KP=Dd(VM,iG,sG,rG),UM=Us("background,cite,href,itemtype,longdesc,poster,src,xlink:href"),oG=Us("abbr,accesskey,align,alt,autoplay,axis,bgcolor,border,cellpadding,cellspacing,class,clear,color,cols,c
7olspan,compact,controls,coords,datetime,default,dir,download,face,headers,height,hidden,hreflang,hspace,ismap,itemscope,itemprop,kind,label,lang,language,loop,media,muted,nohref,nowrap,open,preload,rel,rev,role,rows,rowspan,rules,scope,scrolling,shape,size,sizes,span,srclang,srcset,start,summary,tabindex,target,title,translate,type,usemap,valign,value,vspace,width"),aG=Us("aria-activedescendant,aria-atomic,aria-autocomplete,aria-busy,aria-checked,aria-colcount,aria-colindex,aria-colspan,aria-controls,aria-current,aria-describedby,aria-details,aria-disabled,aria-dropeffect,aria-errormessage,aria-expanded,aria-flowto,aria-grabbed,aria-haspopup,aria-hidden,aria-invalid,aria-keyshortcuts,aria-label,aria-labelledby,aria-level,aria-live,aria-modal,aria-multiline,aria-multiselectable,aria-orientation,aria-owns,aria-placeholder,aria-posinset,aria-pressed,aria-readonly,aria-relevant,aria-required,aria-roledescription,aria-rowcount,aria-rowindex,aria-rowspan,aria-selected,aria-setsize,aria-sort,aria-valuemax,aria-valuemin,aria-valuenow,aria-valuetext"),cG=Dd(UM,oG,aG),lG=Us("script,style,template"),Gw=class{constructor(){this.sanitizedSomething=!1,this.buf=[]}sanitizeChildren(e){let t=e.firstChild,r=!0,i=[];for(;t;){if(t.nodeType===Node.ELEMENT_NODE?r=this.startElement(t):t.nodeType===Node.TEXT_NODE?this.chars(t.nodeValue):this.sanitizedSomething=!0,r&&t.firstChild){i.push(t),t=hG(t);continue}for(;t;){t.nodeType===Node.ELEMENT_NODE&&this.endElement(t);let s=dG(t);if(s){t=s;break}t=i.pop()}}return this.buf.join("")}startElement(e){let t=YP(e).toLowerCase();if(!KP.hasOwnProperty(t))return this.sanitizedSomething=!0,!lG.hasOwnProperty(t);this.buf.push("<"),this.buf.push(t);let r=e.attributes;for(let i=0;i<r.length;i++){let s=r.item(i),o=s.name,a=o.toLowerCase();if(!cG.hasOwnProperty(a)){this.sanitizedSomething=!0;continue}let c=s.value;UM[a]&&(c=km(c)),this.buf.push(" ",o,'="',XP(c),'"')}return this.buf.push(">"),!0}endElement(e){let t=YP(e).toLowerCase();KP.hasOwnProperty(t)&&!VM.hasOwnProperty(t)&&(this.buf.push("</"),this.buf.push(t),this.buf.push(">"))}chars(e){this.buf.push(XP(e))}};function uG(n,e){return(n.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_CONTAINED_BY)!==Node.DOCUMENT_POSITION_CONTAINED_BY}function dG(n){let e=n.nextSibling;if(e&&n!==e.previousSibling)throw BM(e);return e}function hG(n){let e=n.firstChild;if(e&&uG(n,e))throw BM(e);return e}function YP(n){let e=n.nodeName;return typeof e=="string"?e:"FORM"}function BM(n){return new Error(`Failed to sanitize html because the element is clobbered: ${n.outerHTML}`)}var fG=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,pG=/([^\#-~ |!])/g;function XP(n){return n.replace(/&/g,"&").replace(fG,function(e){let t=e.charCodeAt(0),r=e.charCodeAt(1);return"&#"+((t-55296)*1024+(r-56320)+65536)+";"}).replace(pG,function(e){return"&#"+e.charCodeAt(0)+";"}).replace(/</g,"<").replace(/>/g,">")}var zp;function HM(n,e){let t=null;try{zp=zp||eG(n);let r=e?String(e):"";t=zp.getInertBodyElement(r);let i=5,s=r;do{if(i===0)throw new Error("Failed to sanitize html because the input is unstable");i--,r=s,s=t.innerHTML,t=zp.getInertBodyElement(r)}while(r!==s);let a=new Gw().sanitizeChildren(QP(t)||t);return Rm(a)}finally{if(t){let r=QP(t)||t;for(;r.firstChild;)r.removeChild(r.firstChild)}}}function QP(n){return"content"in n&&mG(n)?n.content:null}function mG(n){return n.nodeType===Node.ELEMENT_NODE&&n.nodeName==="TEMPLATE"}var Ii=function(n){return n[n.NONE=0]="NONE",n[n.HTML=1]="HTML",n[n.STYLE=2]="STYLE",n[n.SCRIPT=3]="SCRIPT",n[n.URL=4]="URL",n[n.RESOURCE_URL=5]="RESOURCE_URL",n}(Ii||{});function z0(n){let e=gG();return e?e.sanitize(Ii.URL,n)||"":Ua(n,"URL")?$s(n):km(gi(n))}function gG(){let n=He();return n&&n[vi].sanitizer}var yG=/^>|^->|<!--|-->|--!>|<!-$/g,_G=/(<|>)/g,vG="\u200B$1\u200B";function bG(n){return n.replace(yG,e=>e.replace(_G,vG))}function qM(n){return n instanceof Function?n():n}var Os=function(n){return n[n.Important=1]="Important",n[n.DashCase=2]="DashCase",n}(Os||{}),wG;function G0(n,e){return wG(n,e)}function ul(n,e,t,r,i){if(r!=null){let s,o=!1;js(r)?s=r:Da(r)&&(o=!0,r=r[Vs]);let a=zi(r);n===0&&t!==null?i==null?XM(e,t,a):lm(e,t,a,i||null,!0):n===1&&t!==null?lm(e,t,a,i||null,!0):n===2?FG(e,a,o):n===3&&e.destroyNode(a),s!=null&&jG(e,n,s,t,i)}}function EG(n,e){return n.createText(e)}function IG(n,e,t){n.setValue(e,t)}function TG(n,e){return n.createComment(bG(e))}function zM(n,e,t){return n.createElement(e,t)}function AG(n,e){GM(n,e),e[Vs]=null,e[Dr]=null}function CG(n,e,t,r,i,s){r[Vs]=i,r[Dr]=e,Mm(n,r,t,1,i,s)}function GM(n,e){e[vi].changeDetectionScheduler?.notify(1),Mm(n,e,e[Gt],2,null,null)}function SG(n){let e=n[_d];if(!e)return pw(n[Be],n);for(;e;){let t=null;if(Da(e))t=e[_d];else{let r=e[Ar];r&&(t=r)}if(!t){for(;e&&!e[yi]&&e!==n;)Da(e)&&pw(e[Be],e),e=e[bn];e===null&&(e=n),Da(e)&&pw(e[Be],e),t=e&&e[yi]}e=t}}function xG(n,e,t,r){let i=Ar+r,s=t.length;r>0&&(t[i-1][yi]=e),r<s-Ar?(e[yi]=t[i],x1(t,Ar+r,e)):(t.push(e),e[yi]=null),e[bn]=t;let o=e[xd];o!==null&&t!==o&&DG(o,e);let a=e[Ps];a!==null&&a.insertView(n),Rw(e),e[Ce]|=128}function DG(n,e){let t=n[yl],i=e[bn][bn][bi];e[bi]!==i&&(n[Ce]|=S0.HasTransplantedViews),t===null?n[yl]=[e]:t.push(e)}function WM(n,e){let t=n[yl],r=t.indexOf(e);t.splice(r,1)}function Ww(n,e){if(n.length<=Ar)return;let t=Ar+e,r=n[t];if(r){let i=r[xd];i!==null&&i!==n&&WM(i,r),e>0&&(n[t-1][yi]=r[yi]);let s=nm(n,Ar+e);AG(r[Be],r);let o=s[Ps];o!==null&&o.detachView(s[Be]),r[bn]=null,r[yi]=null,r[Ce]&=-129}return r}function KM(n,e){if(!(e[Ce]&256)){let t=e[Gt];t.destroyNode&&Mm(n,e,t,3,null,null),SG(e)}}function pw(n,e){if(e[Ce]&256)return;let t=at(null);try{e[Ce]&=-129,e[Ce]|=256,e[Ma]&&iP(e[Ma]),kG(n,e),RG(n,e),e[Be].type===1&&e[Gt].destroy();let r=e[xd];if(r!==null&&js(e[bn])){r!==e[bn]&&WM(r,e);let i=e[Ps];i!==null&&i.detachView(n)}zz(e)}finally{at(t)}}function RG(n,e){let t=n.cleanup,r=e[yd];if(t!==null)for(let s=0;s<t.length-1;s+=2)if(typeof t[s]=="string"){let o=t[s+3];o>=0?r[o]():r[-o].unsubscribe(),s+=2}else{let o=r[t[s+1]];t[s].call(o)}r!==null&&(e[yd]=null);let i=e[Mo];if(i!==null){e[Mo]=null;for(let s=0;s<i.length;s++){let o=i[s];o()}}}function kG(n,e){let t;if(n!=null&&(t=n.destroyHooks)!=null)for(let r=0;r<t.length;r+=2){let i=e[t[r]];if(!(i instanceof La)){let s=t[r+1];if(Array.isArray(s))for(let o=0;o<s.length;o+=2){let a=i[s[o]],c=s[o+1];Bi(4,a,c);try{c.call(a)}
7finally{Bi(5,a,c)}}else{Bi(4,i,s);try{s.call(i)}finally{Bi(5,i,s)}}}}}function YM(n,e,t){return PG(n,e.parent,t)}function PG(n,e,t){let r=e;for(;r!==null&&r.type&40;)e=r,r=e.parent;if(r===null)return t[Vs];{let{componentOffset:i}=r;if(i>-1){let{encapsulation:s}=n.data[r.directiveStart+i];if(s===qi.None||s===qi.Emulated)return null}return qr(r,t)}}function lm(n,e,t,r,i){n.insertBefore(e,t,r,i)}function XM(n,e,t){n.appendChild(e,t)}function ZP(n,e,t,r,i){r!==null?lm(n,e,t,r,i):XM(n,e,t)}function MG(n,e,t,r){n.removeChild(e,t,r)}function W0(n,e){return n.parentNode(e)}function NG(n,e){return n.nextSibling(e)}function QM(n,e,t){return LG(n,e,t)}function OG(n,e,t){return n.type&40?qr(n,t):null}var LG=OG,JP;function Pm(n,e,t,r){let i=YM(n,r,e),s=e[Gt],o=r.parent||e[Dr],a=QM(o,r,e);if(i!=null)if(Array.isArray(t))for(let c=0;c<t.length;c++)ZP(s,i,t[c],a,!1);else ZP(s,i,t,a,!1);JP!==void 0&&JP(s,r,e,t,i)}function Zp(n,e){if(e!==null){let t=e.type;if(t&3)return qr(e,n);if(t&4)return Kw(-1,n[e.index]);if(t&8){let r=e.child;if(r!==null)return Zp(n,r);{let i=n[e.index];return js(i)?Kw(-1,i):zi(i)}}else{if(t&32)return G0(e,n)()||zi(n[e.index]);{let r=ZM(n,e);if(r!==null){if(Array.isArray(r))return r[0];let i=bd(n[bi]);return Zp(i,r)}else return Zp(n,e.next)}}}return null}function ZM(n,e){if(e!==null){let r=n[bi][Dr],i=e.projection;return r.projection[i]}return null}function Kw(n,e){let t=Ar+n+1;if(t<e.length){let r=e[t],i=r[Be].firstChild;if(i!==null)return Zp(r,i)}return e[Na]}function FG(n,e,t){let r=W0(n,e);r&&MG(n,r,e,t)}function K0(n,e,t,r,i,s,o){for(;t!=null;){let a=r[t.index],c=t.type;if(o&&e===0&&(a&&Oo(zi(a),r),t.flags|=2),(t.flags&32)!==32)if(c&8)K0(n,e,t.child,r,i,s,!1),ul(e,n,i,a,s);else if(c&32){let l=G0(t,r),u;for(;u=l();)ul(e,n,i,u,s);ul(e,n,i,a,s)}else c&16?JM(n,e,r,t,i,s):ul(e,n,i,a,s);t=o?t.projectionNext:t.next}}function Mm(n,e,t,r,i,s){K0(t,r,n.firstChild,e,i,s,!1)}function VG(n,e,t){let r=e[Gt],i=YM(n,t,e),s=t.parent||e[Dr],o=QM(s,t,e);JM(r,0,e,t,i,o)}function JM(n,e,t,r,i,s){let o=t[bi],c=o[Dr].projection[r.projection];if(Array.isArray(c))for(let l=0;l<c.length;l++){let u=c[l];ul(e,n,i,u,s)}else{let l=c,u=o[bn];CM(r)&&(l.flags|=128),K0(n,e,l,u,i,s,!0)}}function jG(n,e,t,r,i){let s=t[Na],o=zi(t);s!==o&&ul(e,n,r,s,i);for(let a=Ar;a<t.length;a++){let c=t[a];Mm(c[Be],c,n,e,r,s)}}function $G(n,e,t,r,i){if(e)i?n.addClass(t,r):n.removeClass(t,r);else{let s=r.indexOf("-")===-1?void 0:Os.DashCase;i==null?n.removeStyle(t,r,s):(typeof i=="string"&&i.endsWith("!important")&&(i=i.slice(0,-10),s|=Os.Important),n.setStyle(t,r,i,s))}}function UG(n,e,t){n.setAttribute(e,"style",t)}function eN(n,e,t){t===""?n.removeAttribute(e,"class"):n.setAttribute(e,"class",t)}function tN(n,e,t){let{mergedAttrs:r,classes:i,styles:s}=t;r!==null&&Aw(n,e,r),i!==null&&eN(n,e,i),s!==null&&UG(n,e,s)}var Wr={};function j(n=1){nN(cn(),He(),jo()+n,!1)}function nN(n,e,t,r){if(!r)if((e[Ce]&3)===3){let s=n.preOrderCheckHooks;s!==null&&Yp(e,s,t)}else{let s=n.preOrderHooks;s!==null&&Xp(e,s,0,t)}Oa(t)}function oe(n,e=Ye.Default){let t=He();if(t===null)return Y(n,e);let r=gr();return bM(r,t,er(n),e)}function rN(n,e,t,r,i,s){let o=at(null);try{let a=null;i&Cr.SignalBased&&(a=e[r][Lb]),a!==null&&a.transformFn!==void 0&&(s=a.transformFn(s)),i&Cr.HasDecoratorInputTransform&&(s=n.inputTransforms[r].call(e,s)),n.setInput!==null?n.setInput(e,a,s,t,r):G1(e,a,r,s)}finally{at(o)}}function BG(n,e){let t=n.hostBindingOpCodes;if(t!==null)try{for(let r=0;r<t.length;r++){let i=t[r];if(i<0)Oa(~i);else{let s=i,o=t[++r],a=t[++r];yz(o,s);let c=e[s];a(2,c)}}}finally{Oa(-1)}}function Nm(n,e,t,r,i,s,o,a,c,l,u){let d=e.blueprint.slice();return d[Vs]=i,d[Ce]=r|4|128|8|64,(l!==null||n&&n[Ce]&2048)&&(d[Ce]|=2048),eM(d),d[bn]=d[bl]=n,d[_i]=t,d[vi]=o||n&&n[vi],d[Gt]=a||n&&n[Gt],d[gl]=c||n&&n[gl]||null,d[Dr]=s,d[Im]=Hz(),d[gd]=u,d[q1]=l,d[bi]=e.type==2?n[bi]:d,d}function Il(n,e,t,r,i){let s=n.data[e];if(s===null)s=HG(n,e,t,r,i),gz()&&(s.flags|=32);else if(s.type&64){s.type=t,s.value=r,s.attrs=i;let o=fz();s.injectorIndex=o===null?-1:o.injectorIndex}return $a(s,!0),s}function HG(n,e,t,r,i){let s=iM(),o=k0(),a=o?s:s&&s.parent,c=n.data[e]=YG(n,a,t,e,r,i);return n.firstChild===null&&(n.firstChild=c),s!==null&&(o?s.child==null&&c.parent!==null&&(s.child=c):s.next===null&&(s.next=c,c.prev=s)),c}function iN(n,e,t,r){if(t===0)return-1;let i=e.length;for(let s=0;s<t;s++)e.push(r),n.blueprint.push(r),n.data.push(null);return i}function sN(n,e,t,r,i){let s=jo(),o=r&2;try{Oa(-1),o&&e.length>Sr&&nN(n,e,Sr,!1),Bi(o?2:0,i),t(r,i)}finally{Oa(s),Bi(o?3:1,i)}}function Y0(n,e,t){if(x0(e)){let r=at(null);try{let i=e.directiveStart,s=e.directiveEnd;for(let o=i;o<s;o++){let a=n.data[o];if(a.contentQueries){let c=t[o];a.contentQueries(1,c,o)}}}finally{at(r)}}}function X0(n,e,t){nM()&&(t5(n,e,t,qr(t,e)),(t.flags&64)===64&&lN(n,e,t))}function Q0(n,e,t=qr){let r=e.localNames;if(r!==null){let i=e.index+1;for(let s=0;s<r.length;s+=2){let o=r[s+1],a=o===-1?t(e,n):n[o];n[i++]=a}}}function oN(n){let e=n.tView;
7return e===null||e.incompleteFirstPass?n.tView=Z0(1,null,n.template,n.decls,n.vars,n.directiveDefs,n.pipeDefs,n.viewQuery,n.schemas,n.consts,n.id):e}function Z0(n,e,t,r,i,s,o,a,c,l,u){let d=Sr+r,f=d+i,p=qG(d,f),y=typeof l=="function"?l():l;return p[Be]={type:n,blueprint:p,template:t,queries:null,viewQuery:a,declTNode:e,data:p.slice().fill(null,d),bindingStartIndex:d,expandoStartIndex:f,hostBindingOpCodes:null,firstCreatePass:!0,firstUpdatePass:!0,staticViewQueries:!1,staticContentQueries:!1,preOrderHooks:null,preOrderCheckHooks:null,contentHooks:null,contentCheckHooks:null,viewHooks:null,viewCheckHooks:null,destroyHooks:null,cleanup:null,contentQueries:null,components:null,directiveRegistry:typeof s=="function"?s():s,pipeRegistry:typeof o=="function"?o():o,firstChild:null,schemas:c,consts:y,incompleteFirstPass:!1,ssrId:u}}function qG(n,e){let t=[];for(let r=0;r<e;r++)t.push(r<n?null:Wr);return t}function zG(n,e,t,r){let s=r.get(Qz,PM)||t===qi.ShadowDom,o=n.selectRootElement(e,s);return GG(o),o}function GG(n){WG(n)}var WG=()=>null;function KG(n,e,t,r){let i=hN(e);i.push(t),n.firstCreatePass&&fN(n).push(r,i.length-1)}function YG(n,e,t,r,i,s){let o=e?e.injectorIndex:-1,a=0;return rM()&&(a|=128),{type:t,index:r,insertBeforeIndex:null,injectorIndex:o,directiveStart:-1,directiveEnd:-1,directiveStylingLast:-1,componentOffset:-1,propertyBindings:null,flags:a,providerIndexes:0,value:i,attrs:s,mergedAttrs:null,localNames:null,initialInputs:void 0,inputs:null,outputs:null,tView:null,next:null,prev:null,projectionNext:null,child:null,parent:e,projection:null,styles:null,stylesWithoutHost:null,residualStyles:void 0,classes:null,classesWithoutHost:null,residualClasses:void 0,classBindings:0,styleBindings:0}}function e1(n,e,t,r,i){for(let s in e){if(!e.hasOwnProperty(s))continue;let o=e[s];if(o===void 0)continue;r??={};let a,c=Cr.None;Array.isArray(o)?(a=o[0],c=o[1]):a=o;let l=s;if(i!==null){if(!i.hasOwnProperty(s))continue;l=i[s]}n===0?t1(r,t,l,a,c):t1(r,t,l,a)}return r}function t1(n,e,t,r,i){let s;n.hasOwnProperty(t)?(s=n[t]).push(e,r):s=n[t]=[e,r],i!==void 0&&s.push(i)}function XG(n,e,t){let r=e.directiveStart,i=e.directiveEnd,s=n.data,o=e.attrs,a=[],c=null,l=null;for(let u=r;u<i;u++){let d=s[u],f=t?t.get(d):null,p=f?f.inputs:null,y=f?f.outputs:null;c=e1(0,d.inputs,u,c,p),l=e1(1,d.outputs,u,l,y);let v=c!==null&&o!==null&&!T0(e)?h5(c,u,o):null;a.push(v)}c!==null&&(c.hasOwnProperty("class")&&(e.flags|=8),c.hasOwnProperty("style")&&(e.flags|=16)),e.initialInputs=a,e.inputs=c,e.outputs=l}function QG(n){return n==="class"?"className":n==="for"?"htmlFor":n==="formaction"?"formAction":n==="innerHtml"?"innerHTML":n==="readonly"?"readOnly":n==="tabindex"?"tabIndex":n}function aN(n,e,t,r,i,s,o,a){let c=qr(e,t),l=e.inputs,u;!a&&l!=null&&(u=l[r])?(eE(n,t,u,r,i),Tm(e)&&ZG(t,e.index)):e.type&3?(r=QG(r),i=o!=null?o(i,e.value||"",r):i,s.setProperty(c,r,i)):e.type&12}function ZG(n,e){let t=Vo(e,n);t[Ce]&16||(t[Ce]|=64)}function J0(n,e,t,r){if(nM()){let i=r===null?null:{"":-1},s=r5(n,t),o,a;s===null?o=a=null:[o,a]=s,o!==null&&cN(n,e,t,o,i,a),i&&i5(t,r,i)}t.mergedAttrs=pd(t.mergedAttrs,t.attrs)}function cN(n,e,t,r,i,s){for(let l=0;l<r.length;l++)Mw(cm(t,e),n,r[l].type);o5(t,n.data.length,r.length);for(let l=0;l<r.length;l++){let u=r[l];u.providersResolver&&u.providersResolver(u)}let o=!1,a=!1,c=iN(n,e,r.length,null);for(let l=0;l<r.length;l++){let u=r[l];t.mergedAttrs=pd(t.mergedAttrs,u.hostAttrs),a5(n,t,e,c,u),s5(c,u,i),u.contentQueries!==null&&(t.flags|=4),(u.hostBindings!==null||u.hostAttrs!==null||u.hostVars!==0)&&(t.flags|=64);let d=u.type.prototype;!o&&(d.ngOnChanges||d.ngOnInit||d.ngDoCheck)&&((n.preOrderHooks??=[]).push(t.index),o=!0),!a&&(d.ngOnChanges||d.ngDoCheck)&&((n.preOrderCheckHooks??=[]).push(t.index),a=!0),c++}XG(n,t,s)}function JG(n,e,t,r,i){let s=i.hostBindings;if(s){let o=n.hostBindingOpCodes;o===null&&(o=n.hostBindingOpCodes=[]);let a=~e.index;e5(o)!=a&&o.push(a),o.push(t,r,s)}}function e5(n){let e=n.length;for(;e>0;){let t=n[--e];if(typeof t=="number"&&t<0)return t}return 0}function t5(n,e,t,r){let i=t.directiveStart,s=t.directiveEnd;
7Tm(t)&&c5(e,t,n.data[i+t.componentOffset]),n.firstCreatePass||cm(t,e),Oo(r,e);let o=t.initialInputs;for(let a=i;a<s;a++){let c=n.data[a],l=Fa(e,n,a,t);if(Oo(l,e),o!==null&&d5(e,a-i,l,c,t,o),No(c)){let u=Vo(t.index,e);u[_i]=Fa(e,n,a,t)}}}function lN(n,e,t){let r=t.directiveStart,i=t.directiveEnd,s=t.index,o=_z();try{Oa(s);for(let a=r;a<i;a++){let c=n.data[a],l=e[a];kw(a),(c.hostBindings!==null||c.hostVars!==0||c.hostAttrs!==null)&&n5(c,l)}}finally{Oa(-1),kw(o)}}function n5(n,e){n.hostBindings!==null&&n.hostBindings(1,e)}function r5(n,e){let t=n.directiveRegistry,r=null,i=null;if(t)for(let s=0;s<t.length;s++){let o=t[s];if(M1(e,o.selectors,!1))if(r||(r=[]),No(o))if(o.findHostDirectiveDefs!==null){let a=[];i=i||new Map,o.findHostDirectiveDefs(o,a,i),r.unshift(...a,o);let c=a.length;Yw(n,e,c)}else r.unshift(o),Yw(n,e,0);else i=i||new Map,o.findHostDirectiveDefs?.(o,r,i),r.push(o)}return r===null?null:[r,i]}function Yw(n,e,t){e.componentOffset=t,(n.components??=[]).push(e.index)}function i5(n,e,t){if(e){let r=n.localNames=[];for(let i=0;i<e.length;i+=2){let s=t[e[i+1]];if(s==null)throw new we(-301,!1);r.push(e[i],s)}}}function s5(n,e,t){if(t){if(e.exportAs)for(let r=0;r<e.exportAs.length;r++)t[e.exportAs[r]]=n;No(e)&&(t[""]=n)}}function o5(n,e,t){n.flags|=1,n.directiveStart=e,n.directiveEnd=e+t,n.providerIndexes=e}function a5(n,e,t,r,i){n.data[r]=i;let s=i.factory||(i.factory=ka(i.type,!0)),o=new La(s,No(i),oe);n.blueprint[r]=o,t[r]=o,JG(n,e,r,iN(n,t,i.hostVars,Wr),i)}function c5(n,e,t){let r=qr(e,n),i=oN(t),s=n[vi].rendererFactory,o=16;t.signals?o=4096:t.onPush&&(o=64);let a=Om(n,Nm(n,i,null,o,r,e,null,s.createRenderer(r,t),null,null,null));n[e.index]=a}function l5(n,e,t,r,i,s){let o=qr(n,e);u5(e[Gt],o,s,n.value,t,r,i)}function u5(n,e,t,r,i,s,o){if(s==null)n.removeAttribute(e,i,t);else{let a=o==null?gi(s):o(s,r||"",i);n.setAttribute(e,i,a,t)}}function d5(n,e,t,r,i,s){let o=s[e];if(o!==null)for(let a=0;a<o.length;){let c=o[a++],l=o[a++],u=o[a++],d=o[a++];rN(r,t,c,l,u,d)}}function h5(n,e,t){let r=null,i=0;for(;i<t.length;){let s=t[i];if(s===0){i+=4;continue}else if(s===5){i+=2;continue}if(typeof s=="number")break;if(n.hasOwnProperty(s)){r===null&&(r=[]);let o=n[s];for(let a=0;a<o.length;a+=3)if(o[a]===e){r.push(s,o[a+1],o[a+2],t[i+1]);break}}i+=2}return r}function uN(n,e,t,r){return[n,!0,0,e,null,r,null,t,null,null]}function dN(n,e){let t=n.contentQueries;if(t!==null){let r=at(null);try{for(let i=0;i<t.length;i+=2){let s=t[i],o=t[i+1];if(o!==-1){let a=n.data[o];N0(s),a.contentQueries(2,e[o],o)}}}finally{at(r)}}}function Om(n,e){return n[_d]?n[UP][yi]=e:n[_d]=e,n[UP]=e,e}function Xw(n,e,t){N0(0);let r=at(null);try{e(n,t)}finally{at(r)}}function hN(n){return n[yd]||(n[yd]=[])}function fN(n){return n.cleanup||(n.cleanup=[])}function pN(n,e){let t=n[gl],r=t?t.get(Ms,null):null;r&&r.handleError(e)}function eE(n,e,t,r,i){for(let s=0;s<t.length;){let o=t[s++],a=t[s++],c=t[s++],l=e[o],u=n.data[o];rN(u,l,r,a,c,i)}}function tE(n,e,t){let r=Q1(e,n);IG(n[Gt],r,t)}function f5(n,e){let t=Vo(e,n),r=t[Be];p5(r,t);let i=t[Vs];i!==null&&t[gd]===null&&(t[gd]=q0(i,t[gl])),nE(r,t,t[_i])}function p5(n,e){for(let t=e.length;t<n.blueprint.length;t++)e.push(n.blueprint[t])}function nE(n,e,t){O0(e);try{let r=n.viewQuery;r!==null&&Xw(1,r,t);let i=n.template;i!==null&&sN(n,e,i,1,t),n.firstCreatePass&&(n.firstCreatePass=!1),e[Ps]?.finishViewCreation(n),n.staticContentQueries&&dN(n,e),n.staticViewQueries&&Xw(2,n.viewQuery,t);let s=n.components;s!==null&&m5(e,s)}catch(r){throw n.firstCreatePass&&(n.incompleteFirstPass=!0,n.firstCreatePass=!1),r}finally{e[Ce]&=-5,L0()}}function m5(n,e){for(let t=0;t<e.length;t++)f5(n,e[t])}function g5(n,e,t,r){let i=at(null);try{let s=e.tView,a=n[Ce]&4096?4096:16,c=Nm(n,s,t,a,null,e,null,null,r?.injector??null,r?.embeddedViewInjector??null,r?.dehydratedView??null),l=n[e.index];c[xd]=l;let u=n[Ps];return u!==null&&(c[Ps]=u.createEmbeddedView(s)),nE(s,c,t),c}finally{at(i)}}function n1(n,e){return!e||e.firstChild===null||CM(n)}function y5(n,e,t,r=!0){let i=e[Be];if(xG(i,e,n,t),r){let o=Kw(t,n),a=e[Gt],c=W0(a,n[Na]);c!==null&&CG(i,n[Dr],a,e,c,o)}let s=e[gd];s!==null&&s.firstChild!==null&&(s.firstChild=null)}function um(n,e,t,r,i=!1){for(;t!==null;){let s=e[t.index];s!==null&&r.push(zi(s)),js(s)&&_5(s,r);let o=t.type;if(o&8)um(n,e,t.child,r);else if(o&32){let a=G0(t,e),c;for(;c=a();)r.push(c)}else if(o&16){let a=ZM(e,t);if(Array.isArray(a))r.push(...a);else{let c=bd(e[bi]);um(c[Be],c,a,r,!0)}}t=i?t.projectionNext:t.next}return r}function _5(n,e){for(let t=Ar;t<n.length;t++){let r=n[t],i=r[Be].firstChild;i!==null&&um(r[Be],r,i,e)}n[Na]!==n[Vs]&&e.push(n[Na])}var mN=[];function v5(n){return n[Ma]??b5(n)}function b5(n){let e=mN.pop()??Object.create(E5);return e.lView=n,e}function w5(n){n.lView[Ma]!==n&&(n.lView=null,mN.push(n))}var E5=D(_({},tP),{consumerIsAlwaysLive:!0,consumerMarkedDirty:n=>{vd(n.lView)},consumerOnSignalRead(){this.lView[Ma]=this}}),gN=100;function yN(n,e=!0,t=0){let r=n[vi],i=r.rendererFactory,s=!1;s||i.begin?.();try{I5(n,t)}catch(o){throw e&&pN(n,o),o}finally{s||(i.end?.(),r.inlineEffectRunner?.flush())}}function I5(n,e){Qw(n,e);let t=0;for(;R0(n);){if(t===gN)throw new we(103,!1);t++,Qw(n,1)}}function T5(n,e,t,r){let i=e[Ce];if((i&256)===256)return;let s=!1;!s&&e[vi].inlineEffectRunner?.flush(),O0(e);let o=null,a=null;!s&&A5(n)&&(a=v5(e),o=nP(a));try{eM(e),mz(n.bindingStartIndex),t!==null&&sN(n,e,t,2,r);let c=(i&3)===3;if(!s)if(c){let d=n.preOrderCheckHooks;d!==null&&Yp(e,d,null)}else{let d=n.preOrderHooks;d!==null&&Xp(e,d,0,null),uw(e,0)}if(C5(e),_N(e,0),n.contentQueries!==null&&dN(n,e),!s)if(c){let d=n.contentCheckHooks;d!==null&&Yp(e,d)}else{let d=n.contentHooks;d!==null&&Xp(e,d,1),uw(e,1)}BG(n,e);let l=n.components;l!==null&&bN(e,l,0);let u=n.viewQuery;if(u!==null&&Xw(2,u,r),!s)if(c){let d=n.viewCheckHooks;d!==null&&Yp(e,d)}else{let d=n.viewHooks;d!==null&&Xp(e,d,2),uw(e,2)}if(n.firstUpdatePass===!0&&(n.firstUpdatePass=!1),e[lw]){for(let d of e[lw])d();e[lw]=null}s||(e[Ce]&=-73)}catch(c){throw vd(e),c}finally{a!==null&&(rP(a,o),w5(a)),L0()}}function A5(n){return n.type!==2}function _N(n,e){for(let t=xM(n);t!==null;t=DM(t))for(let r=Ar;r<t.length;r++){let i=t[r];vN(i,e)}}function C5(n){for(let e=xM(n);e!==null;e=DM(e)){if(!(e[Ce]&S0.HasTransplantedViews))continue;let t=e[yl];for(let r=0;r<t.length;r++){let i=t[r],s=i[bn];sz(i)}}}
7function S5(n,e,t){let r=Vo(e,n);vN(r,t)}function vN(n,e){D0(n)&&Qw(n,e)}function Qw(n,e){let r=n[Be],i=n[Ce],s=n[Ma],o=!!(e===0&&i&16);if(o||=!!(i&64&&e===0),o||=!!(i&1024),o||=!!(s?.dirty&&Fb(s)),s&&(s.dirty=!1),n[Ce]&=-9217,o)T5(r,n,r.template,n[_i]);else if(i&8192){_N(n,1);let a=r.components;a!==null&&bN(n,a,1)}}function bN(n,e,t){for(let r=0;r<e.length;r++)S5(n,e[r],t)}function rE(n){for(n[vi].changeDetectionScheduler?.notify();n;){n[Ce]|=64;let e=bd(n);if(Xq(n)&&!e)return n;n=e}return null}var Va=class{get rootNodes(){let e=this._lView,t=e[Be];return um(t,e,t.firstChild,[])}constructor(e,t,r=!0){this._lView=e,this._cdRefInjectingView=t,this.notifyErrorHandler=r,this._appRef=null,this._attachedToViewContainer=!1}get context(){return this._lView[_i]}set context(e){this._lView[_i]=e}get destroyed(){return(this._lView[Ce]&256)===256}destroy(){if(this._appRef)this._appRef.detachView(this);else if(this._attachedToViewContainer){let e=this._lView[bn];if(js(e)){let t=e[im],r=t?t.indexOf(this):-1;r>-1&&(Ww(e,r),nm(t,r))}this._attachedToViewContainer=!1}KM(this._lView[Be],this._lView)}onDestroy(e){tM(this._lView,e)}markForCheck(){rE(this._cdRefInjectingView||this._lView)}detach(){this._lView[Ce]&=-129}reattach(){Rw(this._lView),this._lView[Ce]|=128}detectChanges(){this._lView[Ce]|=1024,yN(this._lView,this.notifyErrorHandler)}checkNoChanges(){}attachToViewContainerRef(){if(this._appRef)throw new we(902,!1);this._attachedToViewContainer=!0}detachFromAppRef(){this._appRef=null,GM(this._lView[Be],this._lView)}attachToAppRef(e){if(this._attachedToViewContainer)throw new we(902,!1);this._appRef=e,Rw(this._lView)}},Lo=(()=>{class n{static{this.__NG_ELEMENT_ID__=R5}}return n})(),x5=Lo,D5=class extends x5{constructor(e,t,r){super(),this._declarationLView=e,this._declarationTContainer=t,this.elementRef=r}get ssrId(){return this._declarationTContainer.tView?.ssrId||null}createEmbeddedView(e,t){return this.createEmbeddedViewImpl(e,t)}createEmbeddedViewImpl(e,t,r){let i=g5(this._declarationLView,this._declarationTContainer,e,{embeddedViewInjector:t,dehydratedView:r});return new Va(i)}};function R5(){return Lm(gr(),He())}function Lm(n,e){return n.type&4?new D5(e,n,El(n,e)):null}var jye=new RegExp(`^(\\d+)*(${Yz}|${Kz})*(.*)`);var k5=()=>null;function r1(n,e){return k5(n,e)}var Zw=class{},Jw=class{},dm=class{};function P5(n){let e=Error(`No component factory found for ${tr(n)}.`);return e[M5]=n,e}var M5="ngComponent";var e0=class{resolveComponentFactory(e){throw P5(e)}},Fm=(()=>{class n{static{this.NULL=new e0}}return n})(),wd=class{},Bs=(()=>{class n{constructor(){this.destroyNode=null}static{this.__NG_ELEMENT_ID__=()=>N5()}}return n})();function N5(){let n=He(),e=gr(),t=Vo(e.index,n);return(Da(t)?t:n)[Gt]}var O5=(()=>{class n{static{this.\u0275prov=Q({token:n,providedIn:"root",factory:()=>null})}}return n})(),mw={};var i1=new Set;function iE(n){i1.has(n)||(i1.add(n),performance?.mark?.("mark_feature_usage",{detail:{feature:n}}))}function s1(...n){}function L5(){let n=typeof xa.requestAnimationFrame=="function",e=xa[n?"requestAnimationFrame":"setTimeout"],t=xa[n?"cancelAnimationFrame":"clearTimeout"];if(typeof Zone<"u"&&e&&t){let r=e[Zone.__symbol__("OriginalDelegate")];r&&(e=r);let i=t[Zone.__symbol__("OriginalDelegate")];i&&(t=i)}return{nativeRequestAnimationFrame:e,nativeCancelAnimationFrame:t}}var st=class n{constructor({enableLongStackTrace:e=!1,shouldCoalesceEventChangeDetection:t=!1,shouldCoalesceRunChangeDetection:r=!1}){if(this.hasPendingMacrotasks=!1,this.hasPendingMicrotasks=!1,this.isStable=!0,this.onUnstable=new $t(!1),this.onMicrotaskEmpty=new $t(!1),this.onStable=new $t(!1),this.onError=new $t(!1),typeof Zone>"u")throw new we(908,!1);Zone.assertZonePatched();let i=this;i._nesting=0,i._outer=i._inner=Zone.current,Zone.TaskTrackingZoneSpec&&(i._inner=i._inner.fork(new Zone.TaskTrackingZoneSpec)),e&&Zone.longStackTraceZoneSpec&&(i._inner=i._inner.fork(Zone.longStackTraceZoneSpec)),i.shouldCoalesceEventChangeDetection=!r&&t,i.shouldCoalesceRunChangeDetection=r,i.lastRequestAnimationFrameId=-1,i.nativeRequestAnimationFrame=L5().nativeRequestAnimationFrame,j5(i)}
7static isInAngularZone(){return typeof Zone<"u"&&Zone.current.get("isAngularZone")===!0}static assertInAngularZone(){if(!n.isInAngularZone())throw new we(909,!1)}static assertNotInAngularZone(){if(n.isInAngularZone())throw new we(909,!1)}run(e,t,r){return this._inner.run(e,t,r)}runTask(e,t,r,i){let s=this._inner,o=s.scheduleEventTask("NgZoneEvent: "+i,e,F5,s1,s1);try{return s.runTask(o,t,r)}finally{s.cancelTask(o)}}runGuarded(e,t,r){return this._inner.runGuarded(e,t,r)}runOutsideAngular(e){return this._outer.run(e)}},F5={};function sE(n){if(n._nesting==0&&!n.hasPendingMicrotasks&&!n.isStable)try{n._nesting++,n.onMicrotaskEmpty.emit(null)}finally{if(n._nesting--,!n.hasPendingMicrotasks)try{n.runOutsideAngular(()=>n.onStable.emit(null))}finally{n.isStable=!0}}}function V5(n){n.isCheckStableRunning||n.lastRequestAnimationFrameId!==-1||(n.lastRequestAnimationFrameId=n.nativeRequestAnimationFrame.call(xa,()=>{n.fakeTopEventTask||(n.fakeTopEventTask=Zone.root.scheduleEventTask("fakeTopEventTask",()=>{n.lastRequestAnimationFrameId=-1,t0(n),n.isCheckStableRunning=!0,sE(n),n.isCheckStableRunning=!1},void 0,()=>{},()=>{})),n.fakeTopEventTask.invoke()}),t0(n))}function j5(n){let e=()=>{V5(n)};n._inner=n._inner.fork({name:"angular",properties:{isAngularZone:!0},onInvokeTask:(t,r,i,s,o,a)=>{if($5(a))return t.invokeTask(i,s,o,a);try{return o1(n),t.invokeTask(i,s,o,a)}finally{(n.shouldCoalesceEventChangeDetection&&s.type==="eventTask"||n.shouldCoalesceRunChangeDetection)&&e(),a1(n)}},onInvoke:(t,r,i,s,o,a,c)=>{try{return o1(n),t.invoke(i,s,o,a,c)}finally{n.shouldCoalesceRunChangeDetection&&e(),a1(n)}},onHasTask:(t,r,i,s)=>{t.hasTask(i,s),r===i&&(s.change=="microTask"?(n._hasPendingMicrotasks=s.microTask,t0(n),sE(n)):s.change=="macroTask"&&(n.hasPendingMacrotasks=s.macroTask))},onHandleError:(t,r,i,s)=>(t.handleError(i,s),n.runOutsideAngular(()=>n.onError.emit(s)),!1)})}function t0(n){n._hasPendingMicrotasks||(n.shouldCoalesceEventChangeDetection||n.shouldCoalesceRunChangeDetection)&&n.lastRequestAnimationFrameId!==-1?n.hasPendingMicrotasks=!0:n.hasPendingMicrotasks=!1}function o1(n){n._nesting++,n.isStable&&(n.isStable=!1,n.onUnstable.emit(null))}function a1(n){n._nesting--,sE(n)}function $5(n){return!Array.isArray(n)||n.length!==1?!1:n[0].data?.__ignore_ng_zone__===!0}var wN=(()=>{class n{constructor(){this.handler=null,this.internalCallbacks=[]}execute(){this.executeInternalCallbacks(),this.handler?.execute()}executeInternalCallbacks(){let t=[...this.internalCallbacks];this.internalCallbacks.length=0;for(let r of t)r()}ngOnDestroy(){this.handler?.destroy(),this.handler=null,this.internalCallbacks.length=0}static{this.\u0275prov=Q({token:n,providedIn:"root",factory:()=>new n})}}return n})();function hm(n,e,t){let r=t?n.styles:null,i=t?n.classes:null,s=0;if(e!==null)for(let o=0;o<e.length;o++){let a=e[o];if(typeof a=="number")s=a;else if(s==1)i=kP(i,a);else if(s==2){let c=a,l=e[++o];r=kP(r,c+": "+l+";")}}t?n.styles=r:n.stylesWithoutHost=r,t?n.classes=i:n.classesWithoutHost=i}var fm=class extends Fm{constructor(e){super(),this.ngModule=e}resolveComponentFactory(e){let t=Pa(e);return new Ed(t,this.ngModule)}};function c1(n){let e=[];for(let t in n){if(!n.hasOwnProperty(t))continue;let r=n[t];r!==void 0&&e.push({propName:Array.isArray(r)?r[0]:r,templateName:t})}return e}function U5(n){let e=n.toLowerCase();return e==="svg"?X1:e==="math"?ez:null}var n0=class{constructor(e,t){this.injector=e,this.parentInjector=t}get(e,t,r){r=bm(r);let i=this.injector.get(e,mw,r);return i!==mw||t===mw?i:this.parentInjector.get(e,t,r)}},Ed=class extends dm{get inputs(){let e=this.componentDef,t=e.inputTransforms,r=c1(e.inputs);if(t!==null)for(let i of r)t.hasOwnProperty(i.propName)&&(i.transform=t[i.propName]);return r}get outputs(){return c1(this.componentDef.outputs)}constructor(e,t){super(),this.componentDef=e,this.ngModule=t,this.componentType=e.type,this.selector=Pq(e.selectors),this.ngContentSelectors=e.ngContentSelectors?e.ngContentSelectors:[],this.isBoundToModule=!!t}create(e,t,r,i){let s=at(null);try{i=i||this.ngModule;let o=i instanceof mr?i:i?.injector;o&&this.componentDef.getStandaloneInjector!==null&&(o=this.componentDef.getStandaloneInjector(o)||o);let a=o?new n0(e,o):e,c=a.get(wd,null);if(c===null)throw new we(407,!1);let l=a.get(O5,null),u=a.get(wN,null),d=a.get(Zw,null),f={rendererFactory:c,sanitizer:l,inlineEffectRunner:null,afterRe
7nderEventManager:u,changeDetectionScheduler:d},p=c.createRenderer(null,this.componentDef),y=this.componentDef.selectors[0][0]||"div",v=r?zG(p,r,this.componentDef.encapsulation,a):zM(p,y,U5(y)),w=512;this.componentDef.signals?w|=4096:this.componentDef.onPush||(w|=16);let E=null;v!==null&&(E=q0(v,a,!0));let A=Z0(0,null,null,1,0,null,null,null,null,null,null),x=Nm(null,A,null,w,null,null,f,p,a,null,E);O0(x);let M,O;try{let $=this.componentDef,C,T=null;$.findHostDirectiveDefs?(C=[],T=new Map,$.findHostDirectiveDefs($,C,T),C.push($)):C=[$];let S=B5(x,v),k=H5(S,v,$,C,x,f,p);O=Z1(A,Sr),v&&G5(p,$,v,r),t!==void 0&&W5(O,this.ngContentSelectors,t),M=z5(k,$,C,T,x,[K5]),nE(A,x,null)}finally{L0()}return new r0(this.componentType,M,El(O,x),x,O)}finally{at(s)}}},r0=class extends Jw{constructor(e,t,r,i,s){super(),this.location=r,this._rootLView=i,this._tNode=s,this.previousInputValues=null,this.instance=t,this.hostView=this.changeDetectorRef=new Va(i,void 0,!1),this.componentType=e}setInput(e,t){let r=this._tNode.inputs,i;if(r!==null&&(i=r[e])){if(this.previousInputValues??=new Map,this.previousInputValues.has(e)&&Object.is(this.previousInputValues.get(e),t))return;let s=this._rootLView;eE(s[Be],s,i,e,t),this.previousInputValues.set(e,t);let o=Vo(this._tNode.index,s);rE(o)}}get injector(){return new Ra(this._tNode,this._rootLView)}destroy(){this.hostView.destroy()}onDestroy(e){this.hostView.onDestroy(e)}};function B5(n,e){let t=n[Be],r=Sr;return n[r]=e,Il(t,r,2,"#host",null)}function H5(n,e,t,r,i,s,o){let a=i[Be];q5(r,n,e,o);let c=null;e!==null&&(c=q0(e,i[gl]));let l=s.rendererFactory.createRenderer(e,t),u=16;t.signals?u=4096:t.onPush&&(u=64);let d=Nm(i,oN(t),null,u,i[n.index],n,s,l,null,null,c);return a.firstCreatePass&&Yw(a,n,r.length-1),Om(i,d),i[n.index]=d}function q5(n,e,t,r){for(let i of n)e.mergedAttrs=pd(e.mergedAttrs,i.hostAttrs);e.mergedAttrs!==null&&(hm(e,e.mergedAttrs,!0),t!==null&&tN(r,t,e))}function z5(n,e,t,r,i,s){let o=gr(),a=i[Be],c=qr(o,i);cN(a,i,o,t,null,r);for(let u=0;u<t.length;u++){let d=o.directiveStart+u,f=Fa(i,a,d,o);Oo(f,i)}lN(a,i,o),c&&Oo(c,i);let l=Fa(i,a,o.directiveStart+o.componentOffset,o);if(n[_i]=i[_i]=l,s!==null)for(let u of s)u(l,e);return Y0(a,o,i),l}function G5(n,e,t,r){if(r)Aw(n,t,["ng-version","17.3.12"]);else{let{attrs:i,classes:s}=Mq(e.selectors[0]);i&&Aw(n,t,i),s&&s.length>0&&eN(n,t,s.join(" "))}}function W5(n,e,t){let r=n.projection=[];for(let i=0;i<e.length;i++){let s=t[i];r.push(s!=null?Array.from(s):null)}}function K5(){let n=gr();Dm(He()[Be],n)}var Ti=(()=>{class n{static{this.__NG_ELEMENT_ID__=Y5}}return n})();function Y5(){let n=gr();return IN(n,He())}var X5=Ti,EN=class extends X5{constructor(e,t,r){super(),this._lContainer=e,this._hostTNode=t,this._hostLView=r}get element(){return El(this._hostTNode,this._hostLView)}get injector(){return new Ra(this._hostTNode,this._hostLView)}get parentInjector(){let e=$0(this._hostTNode,this._hostLView);if(pM(e)){let t=om(e,this._hostLView),r=sm(e),i=t[Be].data[r+8];return new Ra(i,t)}else return new Ra(null,this._hostLView)}clear(){for(;this.length>0;)this.remove(this.length-1)}get(e){let t=l1(this._lContainer);return t!==null&&t[e]||null}get length(){return this._lContainer.length-Ar}createEmbeddedView(e,t,r){let i,s;typeof r=="number"?i=r:r!=null&&(i=r.index,s=r.injector);let o=r1(this._lContainer,e.ssrId),a=e.createEmbeddedViewImpl(t||{},s,o);return this.insertImpl(a,i,n1(this._hostTNode,o)),a}createComponent(e,t,r,i,s){let o=e&&!Yq(e),a;if(o)a=t;else{let y=t||{};a=y.index,r=y.injector,i=y.projectableNodes,s=y.environmentInjector||y.ngModuleRef}let c=o?e:new Ed(Pa(e)),l=r||this.parentInjector;if(!s&&c.ngModule==null){let v=(o?l:this.parentInjector).get(mr,null);v&&(s=v)}let u=Pa(c.componentType??{}),d=r1(this._lContainer,u?.id??null),f=d?.firstChild??null,p=c.create(l,i,f,s);return this.insertImpl(p.hostView,a,n1(this._hostTNode,d)),p}insert(e,t){return this.insertImpl(e,t,!0)}insertImpl(e,t,r){let i=e._lView;if(iz(i)){let a=this.indexOf(e);if(a!==-1)this.detach(a);else{let c=i[bn],l=new EN(c,c[Dr],c[bn]);l.detach(l.indexOf(e))}}let s=this._adjustIndex(t),o=this._lContainer;return y5(o,i,s,r),e.attachToViewContainerRef(),x1(gw(o),s,e),e}move(e,t){return this.insert(e,t)}indexOf(e){let t=l1(this._lContainer);return t!==null?t.indexOf(e):-1}remove(e){let t=this._adjustIndex(e,-1),r=Ww(this._lContainer,t);r&&(nm(gw(this._lContainer),t),KM(r[Be],r))}detach(e){let t=this._adjustIndex(e,-1),r=Ww(this._lContainer,t);return r&&nm(gw(this._lContainer),t)!=null?new Va(r):null}_adjustIndex(e,t=0){return e??this.length+t}};function l1(n){return n[im]}function gw(n){return n[im]||(n[im]=[])}function IN(n,e){let t,r=e[n.index];return js(r)?t=r:(t=uN(r,e,null,n),e[n.index]=t,Om(e,t)),Z5(t,e,n,r),new EN(t,n,e)}function Q5(n,e){let t=n[Gt],r=t.createComment(""),i=qr(e,n),s=W0(t,i);return lm(t,s,r,NG(t,i),!1),r}var Z5=t6,J5=()=>!1;function e6(n,e,t){return J5(n,e,t)}function t6(n,e,t,r){if(n[Na])return;let i;t.type&8?i=zi(r):i=Q5(e,t),n[Na]=i}var i0=class n{constructor(e){this.queryList=e,this.matches=null}clone(){return new n(this.queryList)}setDirty(){this.queryList.setDirty()}},s0=class n{constructor(e=[]){this.queries=e}createEmbeddedView(e){let t=e.queries;if(t!==null){let r=e.contentQueries!==null?e.contentQueries[0]:t.length,i=[];for(let s=0;s<r;s++){let o=t.getByIndex(s),a=this.queries[o.indexInDeclarationView];i.push(a.clone())}return new n(i)}return null}insertView(e){this.dirtyQueriesWithMatches(e)}detachView(e){this.dirtyQueriesWithMatches(e)}finishViewCreation(e){this.dirtyQueriesWithMatches(e)}dirtyQueriesWithMatches(e){for(let t=0;t<this.queries.length;t++)oE(e,t).matches!==null&&this.queries[t].setDirty()}},o0=class{constructor(e,t,r=null){this.flags=t,this.read=r,typeof e=="string"?this.predicate=l6(e):this.predicate=e}},a0=class n{constructor(e=[]){this.queries=e}elementStart(e,t){for(let r=0;r<this.queries.length;r++)this.queries[r].elementStart(e,t)}elementEnd(e){for(let t=0;t<this.queries.length;t++)this.queries[t].elementEnd(e)}embeddedTView(e){let t=null;for(let r=0;r<this.length;r++){let i=t!==null?t.length:0,s=this.getByIndex(r).embeddedTView(e,i);s&&(s.indexInDeclarationView=r,t!==null?t.push(s):t=[s])}return t!==null?new n(t):null}template(e,t){for(let r=0;r<this.queries.length;r++)this.queries[r].template(e,t)}getByIndex(e){return this.queries[e]}get length(){return this.queries.length}track(e){this.queries.push(e)}},c0=class n{constructor(e,t=-1){this.metadata=e,this.matches=null,this.indexInDeclarationView=-1,this.crossesNgTemplate=!1,this._appliesToNextNode=!0,this._declarationNodeIndex=t}elementStart(e,t){this.isApplyingToNode(t)&&this.matchTNode(e,t)}elementEnd(e){this._declarationNodeIndex===e.index&&(this._appliesToNextNode=!1)}template(e,t){this.elementStart(e,t)}embeddedTView(e,t){return this.isApplyingToNode(e)?(this.crossesNgTemplate=!0,this.addMatch(-e.index,t),new n(this.metadata)):null}isApplyingToNode(e){if(this._appliesToNextNode&&(this.metadata.flags&1)!==1){let t=this._declarationNodeIndex,r=e.parent;for(;r!==null&&r.type&8&&r.index!==t;)r=r.parent;return t===(r!==null?r.index:-1)}return this._appliesToNextNode}
vendor: 9,997 bytes, line 7
7matchTNode(e,t){let r=this.metadata.predicate;if(Array.isArray(r))for(let i=0;i<r.length;i++){let s=r[i];this.matchTNodeWithReadOption(e,t,n6(t,s)),this.matchTNodeWithReadOption(e,t,Qp(t,e,s,!1,!1))}else r===Lo?t.type&4&&this.matchTNodeWithReadOption(e,t,-1):this.matchTNodeWithReadOption(e,t,Qp(t,e,r,!1,!1))}matchTNodeWithReadOption(e,t,r){if(r!==null){let i=this.metadata.read;if(i!==null)if(i===nr||i===Ti||i===Lo&&t.type&4)this.addMatch(t.index,-2);else{let s=Qp(t,e,i,!1,!1);s!==null&&this.addMatch(t.index,s)}else this.addMatch(t.index,r)}}addMatch(e,t){this.matches===null?this.matches=[e,t]:this.matches.push(e,t)}};function n6(n,e){let t=n.localNames;if(t!==null){for(let r=0;r<t.length;r+=2)if(t[r]===e)return t[r+1]}return null}function r6(n,e){return n.type&11?El(n,e):n.type&4?Lm(n,e):null}function i6(n,e,t,r){return t===-1?r6(e,n):t===-2?s6(n,e,r):Fa(n,n[Be],t,e)}function s6(n,e,t){if(t===nr)return El(e,n);if(t===Lo)return Lm(e,n);if(t===Ti)return IN(e,n)}function TN(n,e,t,r){let i=e[Ps].queries[r];if(i.matches===null){let s=n.data,o=t.matches,a=[];for(let c=0;o!==null&&c<o.length;c+=2){let l=o[c];if(l<0)a.push(null);else{let u=s[l];a.push(i6(e,u,o[c+1],t.metadata.read))}}i.matches=a}return i.matches}function l0(n,e,t,r){let i=n.queries.getByIndex(t),s=i.matches;if(s!==null){let o=TN(n,e,i,t);for(let a=0;a<s.length;a+=2){let c=s[a];if(c>0)r.push(o[a/2]);else{let l=s[a+1],u=e[-c];for(let d=Ar;d<u.length;d++){let f=u[d];f[xd]===f[bn]&&l0(f[Be],f,l,r)}if(u[yl]!==null){let d=u[yl];for(let f=0;f<d.length;f++){let p=d[f];l0(p[Be],p,l,r)}}}}}return r}function o6(n,e){return n[Ps].queries[e].queryList}function a6(n,e,t){let r=new Fw((t&4)===4);return KG(n,e,r,r.destroy),(e[Ps]??=new s0).queries.push(new i0(r))-1}function c6(n,e,t){let r=cn();return r.firstCreatePass&&(u6(r,new o0(n,e,t),-1),(e&2)===2&&(r.staticViewQueries=!0)),a6(r,He(),e)}function l6(n){return n.split(",").map(e=>e.trim())}function u6(n,e,t){n.queries===null&&(n.queries=new a0),n.queries.track(new c0(e,t))}function oE(n,e){return n.queries.getByIndex(e)}function d6(n,e){let t=n[Be],r=oE(t,e);return r.crossesNgTemplate?l0(t,n,e,[]):TN(t,n,r,e)}function h6(n){return typeof n=="function"&&n[Lb]!==void 0}function AN(n){return h6(n)&&typeof n.set=="function"}function f6(n){return Object.getPrototypeOf(n.prototype).constructor}function Rr(n){let e=f6(n.type),t=!0,r=[n];for(;e;){let i;if(No(n))i=e.\u0275cmp||e.\u0275dir;else{if(e.\u0275cmp)throw new we(903,!1);i=e.\u0275dir}if(i){if(t){r.push(i);let o=n;o.inputs=Gp(n.inputs),o.inputTransforms=Gp(n.inputTransforms),o.declaredInputs=Gp(n.declaredInputs),o.outputs=Gp(n.outputs);let a=i.hostBindings;a&&_6(n,a);let c=i.viewQuery,l=i.contentQueries;if(c&&g6(n,c),l&&y6(n,l),p6(n,i),YH(n.outputs,i.outputs),No(i)&&i.data.animation){let u=n.data;u.animation=(u.animation||[]).concat(i.data.animation)}}let s=i.features;if(s)for(let o=0;o<s.length;o++){let a=s[o];a&&a.ngInherit&&a(n),a===Rr&&(t=!1)}}e=Object.getPrototypeOf(e)}m6(r)}function p6(n,e){for(let t in e.inputs){if(!e.inputs.hasOwnProperty(t)||n.inputs.hasOwnProperty(t))continue;let r=e.inputs[t];if(r!==void 0&&(n.inputs[t]=r,n.declaredInputs[t]=e.declaredInputs[t],e.inputTransforms!==null)){let i=Array.isArray(r)?r[0]:r;if(!e.inputTransforms.hasOwnProperty(i))continue;n.inputTransforms??={},n.inputTransforms[i]=e.inputTransforms[i]}}}function m6(n){let e=0,t=null;for(let r=n.length-1;r>=0;r--){let i=n[r];i.hostVars=e+=i.hostVars,i.hostAttrs=pd(i.hostAttrs,t=pd(t,i.hostAttrs))}}function Gp(n){return n===fl?{}:n===Br?[]:n}function g6(n,e){let t=n.viewQuery;t?n.viewQuery=(r,i)=>{e(r,i),t(r,i)}:n.viewQuery=e}function y6(n,e){let t=n.contentQueries;t?n.contentQueries=(r,i,s)=>{e(r,i,s),t(r,i,s)}:n.contentQueries=e}function _6(n,e){let t=n.hostBindings;t?n.hostBindings=(r,i)=>{e(r,i),t(r,i)}:n.hostBindings=e}var Fo=class{},Id=class{};var u0=class extends Fo{constructor(e,t,r){super(),this._parent=t,this._bootstrapComponents=[],this.destroyCbs=[],this.componentFactoryResolver=new fm(this);let i=F1(e);this._bootstrapComponents=qM(i.bootstrap),this._r3Injector=IM(e,t,[{provide:Fo,useValue:this},{provide:Fm,useValue:this.componentFactoryResolver},...r],tr(e),new Set(["environment"])),this._r3Injector.resolveInjectorInitializers(),this.instance=this._r3Injector.get(e)}get injector(){return this._r3Injector}destroy(){let e=this._r3Injector;!e.destroyed&&e.destroy(),this.destroyCbs.forEach(t=>t()),this.destroyCbs=null}onDestroy(e){this.destroyCbs.push(e)}},d0=class extends Id{constructor(e){super(),this.moduleType=e}create(e){return new u0(this.moduleType,e,[])}};var pm=class extends Fo{constructor(e){super(),this.componentFactoryResolver=new fm(this),this.instance=null;let t=new md([...e.providers,{provide:Fo,useValue:this},{provide:Fm,useValue:this.componentFactoryResolver}],e.parent||C0(),e.debugName,new Set(["environment"]));this.injector=t,e.runEnvironmentInitializers&&t.resolveInjectorInitializers()}destroy(){this.injector.destroy()}onDestroy(e){this.injector.onDestroy(e)}};function aE(n,e,t=null){return new pm({providers:n,parent:e,debugName:t,runEnvironmentInitializers:!0}).injector}var Tl=(()=>{class n{constructor(){this.taskId=0,this.pendingTasks=new Set,this.hasPendingTasks=new gt(!1)}get _hasPendingTasks(){return this.hasPendingTasks.value}add(){this._hasPendingTasks||this.hasPendingTasks.next(!0);let t=this.taskId++;return this.pendingTasks.add(t),t}remove(t){this.pendingTasks.delete(t),this.pendingTasks.size===0&&this._hasPendingTasks&&this.hasPendingTasks.next(!1)}ngOnDestroy(){this.pendingTasks.clear(),this._hasPendingTasks&&this.hasPendingTasks.next(!1)}static{this.\u0275fac=function(r){return new(r||n)}}static{this.\u0275prov=Q({token:n,factory:n.\u0275fac,providedIn:"root"})}}return n})();function CN(n){return b6(n)?Array.isArray(n)||!(n instanceof Map)&&Symbol.iterator in n:!1}function v6(n,e){if(Array.isArray(n))for(let t=0;t<n.length;t++)e(n[t]);else{let t=n[Symbol.iterator](),r;for(;!(r=t.next()).done;)e(r.value)}}function b6(n){return n!==null&&(typeof n=="function"||typeof n=="object")}function Rd(n,e,t){return n[e]=t}function SN(n,e){return n[e]}function wi(n,e,t){let r=n[e];return Object.is(r,t)?!1:(n[e]=t,!0)}function Td(n,e,t,r){let i=wi(n,e,t);return wi(n,e+1,r)||i}function w6(n,e,t,r,i){let s=Td(n,e,t,r);return wi(n,e+2,i)||s}function xN(n,e,t,r,i,s){let o=Td(n,e,t,r);return Td(n,e+2,i,s)||o}function E6(n){return(n.flags&32)===32}function I6(n,e,t,r,i,s,o,a,c){let l=e.consts,u=Il(e,n,4,o||null,_l(l,a));J0(e,t,u,_l(l,c)),Dm(e,u);let d=u.tView=Z0(2,u,r,i,s,e.directiveRegistry,e.pipeRegistry,null,e.schemas,l,null);return e.queries!==null&&(e.queries.template(e,u),d.queries=e.queries.embeddedTView(u)),u}function me(n,e,t,r,i,s,o,a){let c=He(),l=cn(),u=n+Sr,d=l.firstCreatePass?I6(u,l,c,e,t,r,i,s,o):l.data[u];$a(d,!1);let f=T6(l,c,d,n);Sm()&&Pm(l,c,f,d),Oo(f,c);let p=uN(f,c,f,d);return c[u]=p,Om(c,p),e6(p,d,c),Am(d)&&X0(l,c,d),o!=null&&Q0(c,d,a),me}var T6=A6;function A6(n,e,t,r){return xm(!0),e[Gt].createComment("")}function kd(n,e,t,r){let i=He(),s=Cm();if(wi(i,s,e)){let o=cn(),a=F0();l5(a,i,n,e,t,r)}return kd}function C6(n,e,t,r){return wi(n,Cm(),t)?e+gi(t)+r:Wr}function S6(n,e,t,r,i,s){let o=sM(),a=Td(n,o,t,i);return M0(2),a?e+gi(t)+r+gi(i)+s:Wr}function x6(n,e,t,r,i,s,o,a,c,l,u,d){let f=sM(),p=xN(n,f,t,i,o,c);return p=wi(n,f+4,u)||p,M0(5),p?e+gi(t)+r+gi(i)+s+gi(o)+a+gi(c)+l+gi(u)+d:Wr}function Wp(n,e){return n<<17|e<<2}function ja(n){return n>>17&32767}function D6(n){return(n&2)==2}function R6(n,e){return n&131071|e<<17}function h0(n){return n|2}function vl(n){return(n&131068)>>2}function yw(n,e){return n&-131069|e<<2}function k6(n){return(n&1)===1}function f0(n){return n|1}function P6(n,e,t,r,i,s){let o=s?e.classBindings:e.styleBindings,a=ja(o),c=vl(o);n[r]=t;let l=!1,u;if(Array.isArray(t)){let d=t;u=d[1],(u===null||Sd(d,u)>0)&&(l=!0)}else u=t;if(i)if(c!==0){let f=ja(n[a+1]);n[r+1]=Wp(f,a),f!==0&&(n[f+1]=yw(n[f+1],r)),n[a+1]=R6(n[a+1],r)}else n[r+1]=Wp(a,0),a!==0&&(n[a+1]=yw(n[a+1],r)),a=r;else n[r+1]=Wp(c,0),a===0?a=r:n[c+1]=yw(n[c+1],r),c=r;l&&(n[r+1]=h0(n[r+1])),u1(n,u,r,!0),u1(n,u,r,!1),M6(e,u,n,r,s),o=Wp(a,c),s?e.classBindings=o:e.styleBindings=o}function M6(n,e,t,r,i){let s=i?n.residualClasses:n.residualStyles;s!=null&&typeof e=="string"&&Sd(s,e)>=0&&(t[r+1]=f0(t[r+1]))}function u1(n,e,t,r){let i=n[t+1],s=e===null,o=r?ja(i):vl(i),a=!1;for(;o!==0&&(a===!1||s);){let c=n[o],l=n[o+1];N6(c,e)&&(a=!0,n[o+1]=r?f0(l):h0(l)),o=r?ja(l):vl(l)}a&&(n[t+1]=r?h0(i):f0(i))}function N6(n,e){return n===null||e==null||(Array.isArray(n)?n[1]:n)===e?!0:Array.isArray(n)&&typeof e=="string"?Sd(n,e)>=0:!1}function B(n,e,t){let r=He(),i=Cm();if(wi(r,i,e)){let s=cn(),o=F0();aN(s,o,r,n,e,r[Gt],t,!1)}return B}function d1(n,e,t,r,i){let s=e.inputs,o=i?"class":"style";eE(n,t,s[o],o,r)}function kr(n,e){return O6(n,e,null,!0),kr}function O6(n,e,t,r){let i=He(),s=cn(),o=M0(2);if(s.firstUpdatePass&&F6(s,n,o,r),e!==Wr&&wi(i,o,e)){let a=s.data[jo()];B6(s,a,i,i[Gt],n,i[o+1]=H6(e,t),r,o)}}function L6(n,e){return e>=n.expandoStartIndex}function F6(n,e,t,r){let i=n.data;if(i[t+1]===null){let s=i[jo()],o=L6(n,t);q6(s,r)&&e===null&&!o&&(e=!1),e=V6(i,s,e,r),P6(i,s,e,t,o,r)}}function V6(n,e,t,r){let i=vz(n),s=r?e.residualClasses:e.residualStyles;if(i===null)(r?e.classBindings:e.styleBindings)===0&&(t=_w(null,n,e,t,r),t=Ad(t,e.attrs,r),s=null);else{let o=e.directiveStylingLast;if(o===-1||n[o]!==i)if(t=_w(i,n,e,t,r),s===null){let c=j6(n,e,r);c!==void 0&&Array.isArray(c)&&(c=_w(null,n,e,c[1],r),c=Ad(c,e.attrs,r),$6(n,e,r,c))}else s=U6(n,e,r)}return s!==void 0&&(r?e.residualClasses=s:e.residualStyles=s),t}function j6(n,e,t){let r=t?e.classBindings:e.styleBindings;if(vl(r)!==0)return n[ja(r)]}function $6(n,e,t,r){let i=t?e.classBindings:e.styleBindings;n[ja(i)]=r}function U6(n,e,t){let r,i=e.directiveEnd;for(let s=1+e.directiveStylingLast;s<i;s++){let o=n[s].hostAttrs;r=Ad(r,o,t)}return Ad(r,e.attrs,t)}function _w(n,e,t,r,i){let s=null,o=t.directiveEnd,a=t.directiveStylingLast;
7for(a===-1?a=t.directiveStart:a++;a<o&&(s=e[a],r=Ad(r,s.hostAttrs,i),s!==n);)a++;return n!==null&&(t.directiveStylingLast=a),r}function Ad(n,e,t){let r=t?1:2,i=-1;if(e!==null)for(let s=0;s<e.length;s++){let o=e[s];typeof o=="number"?i=o:i===r&&(Array.isArray(n)||(n=n===void 0?[]:["",n]),_q(n,o,t?!0:e[++s]))}return n===void 0?null:n}function B6(n,e,t,r,i,s,o,a){if(!(e.type&3))return;let c=n.data,l=c[a+1],u=k6(l)?h1(c,e,t,i,vl(l),o):void 0;if(!mm(u)){mm(s)||D6(l)&&(s=h1(c,null,t,i,a,o));let d=Q1(jo(),t);$G(r,o,d,i,s)}}function h1(n,e,t,r,i,s){let o=e===null,a;for(;i>0;){let c=n[i],l=Array.isArray(c),u=l?c[1]:c,d=u===null,f=t[i+1];f===Wr&&(f=d?Br:void 0);let p=d?aw(f,r):u===r?f:void 0;if(l&&!mm(p)&&(p=aw(c,r)),mm(p)&&(a=p,o))return a;let y=n[i+1];i=o?ja(y):vl(y)}if(e!==null){let c=s?e.residualClasses:e.residualStyles;c!=null&&(a=aw(c,r))}return a}function mm(n){return n!==void 0}function H6(n,e){return n==null||n===""||(typeof e=="string"?n=n+e:typeof n=="object"&&(n=tr($s(n)))),n}function q6(n,e){return(n.flags&(e?8:16))!==0}function z6(n,e,t,r,i,s){let o=e.consts,a=_l(o,i),c=Il(e,n,2,r,a);return J0(e,t,c,_l(o,s)),c.attrs!==null&&hm(c,c.attrs,!1),c.mergedAttrs!==null&&hm(c,c.mergedAttrs,!0),e.queries!==null&&e.queries.elementStart(e,c),c}function F(n,e,t,r){let i=He(),s=cn(),o=Sr+n,a=i[Gt],c=s.firstCreatePass?z6(o,s,i,e,t,r):s.data[o],l=G6(s,i,c,a,e,n);i[o]=l;let u=Am(c);return $a(c,!0),tN(a,l,c),!E6(c)&&Sm()&&Pm(s,i,l,c),cz()===0&&Oo(l,i),lz(),u&&(X0(s,i,c),Y0(s,c,i)),r!==null&&Q0(i,c),F}function L(){let n=gr();k0()?P0():(n=n.parent,$a(n,!1));let e=n;dz(e)&&hz(),uz();let t=cn();return t.firstCreatePass&&(Dm(t,n),x0(n)&&t.queries.elementEnd(n)),e.classesWithoutHost!=null&&Sz(e)&&d1(t,e,He(),e.classesWithoutHost,!0),e.stylesWithoutHost!=null&&xz(e)&&d1(t,e,He(),e.stylesWithoutHost,!1),L}function yt(n,e,t,r){return F(n,e,t,r),L(),yt}var G6=(n,e,t,r,i,s)=>(xm(!0),zM(r,i,Iz()));function W6(n,e,t,r,i){let s=e.consts,o=_l(s,r),a=Il(e,n,8,"ng-container",o);o!==null&&hm(a,o,!0);let c=_l(s,i);return J0(e,t,a,c),e.queries!==null&&e.queries.elementStart(e,a),a}function Ba(n,e,t){let r=He(),i=cn(),s=n+Sr,o=i.firstCreatePass?W6(s,i,r,e,t):i.data[s];$a(o,!0);let a=K6(i,r,o,n);return r[s]=a,Sm()&&Pm(i,r,a,o),Oo(a,r),Am(o)&&(X0(i,r,o),Y0(i,o,r)),t!=null&&Q0(r,o),Ba}function Ha(){let n=gr(),e=cn();return k0()?P0():(n=n.parent,$a(n,!1)),e.firstCreatePass&&(Dm(e,n),x0(n)&&e.queries.elementEnd(n)),Ha}var K6=(n,e,t,r)=>(xm(!0),TG(e[Gt],""));function St(){return He()}var gm="en-US";var Y6=gm;function X6(n){typeof n=="string"&&(Y6=n.toLowerCase().replace(/_/g,"-"))}function _e(n,e,t,r){let i=He(),s=cn(),o=gr();return DN(s,i,i[Gt],o,n,e,r),_e}function Q6(n,e,t,r){let i=n.cleanup;if(i!=null)for(let s=0;s<i.length-1;s+=2){let o=i[s];if(o===t&&i[s+1]===r){let a=e[yd],c=i[s+2];return a.length>c?a[c]:null}typeof o=="string"&&(s+=2)}return null}function DN(n,e,t,r,i,s,o){let a=Am(r),l=n.firstCreatePass&&fN(n),u=e[_i],d=hN(e),f=!0;if(r.type&3||o){let v=qr(r,e),w=o?o(v):v,E=d.length,A=o?M=>o(zi(M[r.index])):r.index,x=null;if(!o&&a&&(x=Q6(n,e,i,r.index)),x!==null){let M=x.__ngLastListenerFn__||x;M.__ngNextListenerFn__=s,x.__ngLastListenerFn__=s,f=!1}else{s=p1(r,e,u,s,!1);let M=t.listen(w,i,s);d.push(s,M),l&&l.push(i,A,E,E+1)}}else s=p1(r,e,u,s,!1);let p=r.outputs,y;if(f&&p!==null&&(y=p[i])){let v=y.length;if(v)for(let w=0;w<v;w+=2){let E=y[w],A=y[w+1],O=e[E][A].subscribe(s),$=d.length;d.push(s,O),l&&l.push(i,r.index,$,-($+1))}}}function f1(n,e,t,r){let i=at(null);try{return Bi(6,e,t),t(r)!==!1}catch(s){return pN(n,s),!1}finally{Bi(7,e,t),at(i)}}function p1(n,e,t,r,i){return function s(o){if(o===Function)return r;let a=n.componentOffset>-1?Vo(n.index,e):e;rE(a);let c=f1(e,t,r,o),l=s.__ngNextListenerFn__;for(;l;)c=f1(e,t,l,o)&&c,l=l.__ngNextListenerFn__;return i&&c===!1&&o.preventDefault(),c}}function G(n=1){return wz(n)}function Z6(n,e){let t=null,r=Sq(n);for(let i=0;i<e.length;i++){let s=e[i];if(s==="*"){t=i;continue}if(r===null?M1(n,s,!0):Rq(r,s))return i}return t}function RN(n){let e=He()[bi][Dr];if(!e.projection){let t=n?n.length:1,r=e.projection=gq(t,null),i=r.slice(),s=e.child;for(;s!==null;){let o=n?Z6(s,n):0;o!==null&&(i[o]?i[o].projectionNext=s:r[o]=s,i[o]=s),s=s.next}}}function kN(n,e=0,t){let r=He(),i=cn(),s=Il(i,Sr+n,16,null,t||null);s.projection===null&&(s.projection=e),P0(),(!r[gd]||rM())&&(s.flags&32)!==32&&VG(i,r,s)}function Vm(n,e,t){c6(n,e,t)}function Pd(n){let e=He(),t=cn(),r=oM();N0(r+1);let i=oE(t,r);if(n.dirty&&rz(e)===((i.metadata.flags&2)===2)){if(i.matches===null)n.reset([]);else{let s=d6(e,r);n.reset(s,$z),n.notifyOnChanges()}return!0}return!1}function Md(){return o6(He(),oM())}function J6(n,e,t,r){t>=n.data.length&&(n.data[t]=null,n.blueprint[t]=null),e[t]=r}function Al(n){let e=pz();return J1(e,Sr+n)}
vendor: 5,221 bytes, line 7
7function H(n,e=""){let t=He(),r=cn(),i=n+Sr,s=r.firstCreatePass?Il(r,i,1,e,null):r.data[i],o=eW(r,t,s,e,n);t[i]=o,Sm()&&Pm(r,t,o,s),$a(s,!1)}var eW=(n,e,t,r,i)=>(xm(!0),EG(e[Gt],r));function Zt(n){return Ut("",n,""),Zt}function Ut(n,e,t){let r=He(),i=C6(r,n,e,t);return i!==Wr&&tE(r,jo(),i),Ut}function jm(n,e,t,r,i){let s=He(),o=S6(s,n,e,t,r,i);return o!==Wr&&tE(s,jo(),o),jm}function cE(n,e,t,r,i,s,o,a,c,l,u){let d=He(),f=x6(d,n,e,t,r,i,s,o,a,c,l,u);return f!==Wr&&tE(d,jo(),f),cE}function hn(n,e,t){AN(e)&&(e=e());let r=He(),i=Cm();if(wi(r,i,e)){let s=cn(),o=F0();aN(s,o,r,n,e,r[Gt],t,!1)}return hn}function wn(n,e){let t=AN(n);return t&&n.set(e),t}function fn(n,e){let t=He(),r=cn(),i=gr();return DN(r,t,t[Gt],i,n,e),fn}function tW(n,e,t){let r=cn();if(r.firstCreatePass){let i=No(n);p0(t,r.data,r.blueprint,i,!0),p0(e,r.data,r.blueprint,i,!1)}}function p0(n,e,t,r,i){if(n=er(n),Array.isArray(n))for(let s=0;s<n.length;s++)p0(n[s],e,t,r,i);else{let s=cn(),o=He(),a=gr(),c=ml(n)?n:er(n.provide),l=H1(n),u=a.providerIndexes&1048575,d=a.directiveStart,f=a.providerIndexes>>20;if(ml(n)||!n.multi){let p=new La(l,i,oe),y=bw(c,e,i?u:u+f,d);y===-1?(Mw(cm(a,o),s,c),vw(s,n,e.length),e.push(c),a.directiveStart++,a.directiveEnd++,i&&(a.providerIndexes+=1048576),t.push(p),o.push(p)):(t[y]=p,o[y]=p)}else{let p=bw(c,e,u+f,d),y=bw(c,e,u,u+f),v=p>=0&&t[p],w=y>=0&&t[y];if(i&&!w||!i&&!v){Mw(cm(a,o),s,c);let E=iW(i?rW:nW,t.length,i,r,l);!i&&w&&(t[y].providerFactory=E),vw(s,n,e.length,0),e.push(c),a.directiveStart++,a.directiveEnd++,i&&(a.providerIndexes+=1048576),t.push(E),o.push(E)}else{let E=PN(t[i?y:p],l,!i&&r);vw(s,n,p>-1?p:y,E)}!i&&r&&w&&t[y].componentProviders++}}}function vw(n,e,t,r){let i=ml(e),s=Uq(e);if(i||s){let c=(s?er(e.useClass):e).prototype.ngOnDestroy;if(c){let l=n.destroyHooks||(n.destroyHooks=[]);if(!i&&e.multi){let u=l.indexOf(t);u===-1?l.push(t,[r,c]):l[u+1].push(r,c)}else l.push(t,c)}}}function PN(n,e,t){return t&&n.componentProviders++,n.multi.push(e)-1}function bw(n,e,t,r){for(let i=t;i<r;i++)if(e[i]===n)return i;return-1}function nW(n,e,t,r){return m0(this.multi,[])}function rW(n,e,t,r){let i=this.multi,s;if(this.providerFactory){let o=this.providerFactory.componentProviders,a=Fa(t,t[Be],this.providerFactory.index,r);s=a.slice(0,o),m0(i,s);for(let c=o;c<a.length;c++)s.push(a[c])}else s=[],m0(i,s);return s}function m0(n,e){for(let t=0;t<n.length;t++){let r=n[t];e.push(r())}return e}function iW(n,e,t,r,i){let s=new La(n,t,oe);return s.multi=[],s.index=e,s.componentProviders=0,PN(s,i,r&&!t),s}function Ki(n,e=[]){return t=>{t.providersResolver=(r,i)=>tW(r,i?i(n):n,e)}}var sW=(()=>{class n{constructor(t){this._injector=t,this.cachedInjectors=new Map}getOrCreateStandaloneInjector(t){if(!t.standalone)return null;if(!this.cachedInjectors.has(t)){let r=$1(!1,t.type),i=r.length>0?aE([r],this._injector,`Standalone[${t.type.name}]`):null;this.cachedInjectors.set(t,i)}return this.cachedInjectors.get(t)}ngOnDestroy(){try{for(let t of this.cachedInjectors.values())t!==null&&t.destroy()}finally{this.cachedInjectors.clear()}}static{this.\u0275prov=Q({token:n,providedIn:"environment",factory:()=>new n(Y(mr))})}}return n})();function Pr(n){iE("NgStandalone"),n.getStandaloneInjector=e=>e.get(sW).getOrCreateStandaloneInjector(n)}function lE(n,e,t){let r=wl()+n,i=He();return i[r]===Wr?Rd(i,r,t?e.call(t):e()):SN(i,r)}function MN(n,e,t,r){return LN(He(),wl(),n,e,t,r)}function NN(n,e,t,r,i){return oW(He(),wl(),n,e,t,r,i)}function uE(n,e,t,r,i,s){return aW(He(),wl(),n,e,t,r,i,s)}function ON(n,e,t,r,i,s,o,a){let c=wl()+n,l=He(),u=xN(l,c,t,r,i,s);return wi(l,c+4,o)||u?Rd(l,c+5,a?e.call(a,t,r,i,s,o):e(t,r,i,s,o)):SN(l,c+5)}function dE(n,e){let t=n[e];return t===Wr?void 0:t}function LN(n,e,t,r,i,s){let o=e+t;return wi(n,o,i)?Rd(n,o+1,s?r.call(s,i):r(i)):dE(n,o+1)}function oW(n,e,t,r,i,s,o){let a=e+t;return Td(n,a,i,s)?Rd(n,a+2,o?r.call(o,i,s):r(i,s)):dE(n,a+2)}function aW(n,e,t,r,i,s,o,a){let c=e+t;return w6(n,c,i,s,o)?Rd(n,c+3,a?r.call(a,i,s,o):r(i,s,o)):dE(n,c+3)}function Yi(n,e){let t=cn(),r,i=n+Sr;t.firstCreatePass?(r=cW(e,t.pipeRegistry),t.data[i]=r,r.onDestroy&&(t.destroyHooks??=[]).push(i,r.onDestroy)):r=t.data[i];let s=r.factory||(r.factory=ka(r.type,!0)),o,a=pr(oe);try{let c=am(!1),l=s();return am(c),J6(t,He(),i,l),l}finally{pr(a)}}function cW(n,e){if(e)for(let t=e.length-1;t>=0;t--){let r=e[t];if(n===r.name)return r}}function Xi(n,e,t){let r=n+Sr,i=He(),s=J1(i,r);return lW(i,r)?LN(i,wl(),e,s.transform,t,s):s.transform(t)}function lW(n,e){return n[Be].data[e].pure}function hE(n,e){return Lm(n,e)}var Ls=class{constructor(e){this.full=e;let t=e.split(".");this.major=t[0],this.minor=t[1],this.patch=t.slice(2).join(".")}},FN=new Ls("17.3.12"),$m=(()=>{class n{log(t){console.log(t)}warn(t){console.warn(t)}static{this.\u0275fac=function(r){return new(r||n)}}static{this.\u0275prov=Q({token:n,factory:n.\u0275fac,providedIn:"platform"})}}return n})();var VN=new ue("");function $o(n){return!!n&&typeof n.then=="function"}function fE(n){return!!n&&typeof n.subscribe=="function"}var jN=new ue(""),$N=(()=>{class n{constructor(){this.initialized=!1,this.done=!1,this.donePromise=new Promise((t,r)=>{this.resolve=t,this.reject=r}),this.appInits=se(jN,{optional:!0})??[]}
7runInitializers(){if(this.initialized)return;let t=[];for(let i of this.appInits){let s=i();if($o(s))t.push(s);else if(fE(s)){let o=new Promise((a,c)=>{s.subscribe({complete:a,error:c})});t.push(o)}}let r=()=>{this.done=!0,this.resolve()};Promise.all(t).then(()=>{r()}).catch(i=>{this.reject(i)}),t.length===0&&r(),this.initialized=!0}static{this.\u0275fac=function(r){return new(r||n)}}static{this.\u0275prov=Q({token:n,factory:n.\u0275fac,providedIn:"root"})}}return n})(),Um=new ue("");function uW(){sP(()=>{throw new we(600,!1)})}function dW(n){return n.isBoundToModule}function hW(n,e,t){try{let r=t();return $o(r)?r.catch(i=>{throw e.runOutsideAngular(()=>n.handleError(i)),i}):r}catch(r){throw e.runOutsideAngular(()=>n.handleError(r)),r}}var Cl=(()=>{class n{constructor(){this._bootstrapListeners=[],this._runningTick=!1,this._destroyed=!1,this._destroyListeners=[],this._views=[],this.internalErrorHandler=se(TM),this.afterRenderEffectManager=se(wN),this.externalTestViews=new Set,this.beforeRender=new mt,this.afterTick=new mt,this.componentTypes=[],this.components=[],this.isStable=se(Tl).hasPendingTasks.pipe(ke(t=>!t)),this._injector=se(mr)}get destroyed(){return this._destroyed}get injector(){return this._injector}bootstrap(t,r){let i=t instanceof dm;if(!this._injector.get($N).done){let f=!i&&L1(t),p=!1;throw new we(405,p)}let o;i?o=t:o=this._injector.get(Fm).resolveComponentFactory(t),this.componentTypes.push(o.componentType);let a=dW(o)?void 0:this._injector.get(Fo),c=r||o.selector,l=o.create(On.NULL,[],c,a),u=l.location.nativeElement,d=l.injector.get(VN,null);return d?.registerApplication(u),l.onDestroy(()=>{this.detachView(l.hostView),ww(this.components,l),d?.unregisterApplication(u)}),this._loadComponent(l),l}tick(){this._tick(!0)}_tick(t){if(this._runningTick)throw new we(101,!1);let r=at(null);try{this._runningTick=!0,this.detectChangesInAttachedViews(t)}catch(i){this.internalErrorHandler(i)}finally{this.afterTick.next(),this._runningTick=!1,at(r)}}detectChangesInAttachedViews(t){let r=0,i=this.afterRenderEffectManager;for(;;){if(r===gN)throw new we(103,!1);if(t){let s=r===0;this.beforeRender.next(s);for(let{_lView:o,notifyErrorHandler:a}of this._views)fW(o,s,a)}if(r++,i.executeInternalCallbacks(),![...this.externalTestViews.keys(),...this._views].some(({_lView:s})=>g0(s))&&(i.execute(),![...this.externalTestViews.keys(),...this._views].some(({_lView:s})=>g0(s))))break}}attachView(t){let r=t;this._views.push(r),r.attachToAppRef(this)}detachView(t){let r=t;ww(this._views,r),r.detachFromAppRef()}_loadComponent(t){this.attachView(t.hostView),this.tick(),this.components.push(t);let r=this._injector.get(Um,[]);[...this._bootstrapListeners,...r].forEach(i=>i(t))}ngOnDestroy(){if(!this._destroyed)try{this._destroyListeners.forEach(t=>t()),this._views.slice().forEach(t=>t.destroy())}finally{this._destroyed=!0,this._views=[],this._bootstrapListeners=[],this._destroyListeners=[]}}onDestroy(t){return this._destroyListeners.push(t),()=>ww(this._destroyListeners,t)}destroy(){if(this._destroyed)throw new we(406,!1);let t=this._injector;t.destroy&&!t.destroyed&&t.destroy()}get viewCount(){return this._views.length}warnIfDestroyed(){}static{this.\u0275fac=function(r){return new(r||n)}}static{this.\u0275prov=Q({token:n,factory:n.\u0275fac,providedIn:"root"})}}return n})();function ww(n,e){let t=n.indexOf(e);t>-1&&n.splice(t,1)}function fW(n,e,t){!e&&!g0(n)||pW(n,t,e)}function g0(n){return R0(n)}function pW(n,e,t){let r;t?(r=0,n[Ce]|=1024):n[Ce]&64?r=0:r=1,yN(n,e,r)}var y0=class{constructor(e,t){this.ngModuleFactory=e,this.componentFactories=t}},pE=(()=>{class n{compileModuleSync(t){return new d0(t)}compileModuleAsync(t){return Promise.resolve(this.compileModuleSync(t))}compileModuleAndAllComponentsSync(t){let r=this.compileModuleSync(t),i=F1(t),s=qM(i.declarations).reduce((o,a)=>{let c=Pa(a);return c&&o.push(new Ed(c)),o},[]);return new y0(r,s)}compileModuleAndAllComponentsAsync(t){return Promise.resolve(this.compileModuleAndAllComponentsSync(t))}clearCache(){}clearCacheFor(t){}getModuleId(t){}static{this.\u0275fac=function(r){return new(r||n)}}static{this.\u0275prov=Q({token:n,factory:n.\u0275fac,providedIn:"root"})}}return n})();var mW=(()=>{class n{constructor(){this.zone=se(st),this.applicationRef=se(Cl)}initialize(){this._onMicrotaskEmptySubscription||(this._onMicrotaskEmptySubscription=this.zone.onMicrotaskEmpty.subscribe({next:()=>{this.zone.run(()=>{this.applicationRef.tick()})}}))}ngOnDestroy(){this._onMicrotaskEmptySubscription?.unsubscribe()}static{this.\u0275fac=function(r){return new(r||n)}}static{this.\u0275prov=Q({token:n,factory:n.\u0275fac,providedIn:"root"})}}return n})();function gW(n){return[{provide:st,useFactory:n},{provide:pl,multi:!0,useFactory:()=>{let e=se(mW,{optional:!0});return()=>e.initialize()}},{provide:pl,multi:!0,useFactory:()=>{let e=se(bW);return()=>{e.initialize()}}},{provide:TM,useFactory:yW}]}function yW(){let n=se(st),e=se(Ms);return t=>n.runOutsideAngular(()=>e.handleError(t))}function _W(n){let e=gW(()=>new st(vW(n)));return Nn([[],e])}function vW(n){return{enableLongStackTrace:!1,shouldCoalesceEventChangeDetection:n?.eventCoalescing??!1,shouldCoalesceRunChangeDetection:n?.runCoalescing??!1}}var bW=(()=>{class n{constructor(){this.subscription=new zt,this.initialized=!1,this.zone=se(st),this.pendingTasks=se(Tl)}initialize(){if(this.initialized)return;this.initialized=!0;let t=null;!this.zone.isStable&&!this.zone.hasPendingMacrotasks&&!this.zone.hasPendingMicrotasks&&(t=this.pendingTasks.add()),this.zone.runOutsideAngular(()=>{this.subscription.add(this.zone.onStable.subscribe(()=>{st.assertNotInAngularZone(),queueMicrotask(()=>{t!==null&&!this.zone.hasPendingMacrotasks&&!this.zone.hasPendingMicrotasks&&(this.pendingTasks.remove(t),t=null)})}
7))}),this.subscription.add(this.zone.onUnstable.subscribe(()=>{st.assertInAngularZone(),t??=this.pendingTasks.add()}))}ngOnDestroy(){this.subscription.unsubscribe()}static{this.\u0275fac=function(r){return new(r||n)}}static{this.\u0275prov=Q({token:n,factory:n.\u0275fac,providedIn:"root"})}}return n})();function wW(){return typeof $localize<"u"&&$localize.locale||gm}var mE=new ue("",{providedIn:"root",factory:()=>se(mE,Ye.Optional|Ye.SkipSelf)||wW()});var UN=new ue("");var Jp=null;function EW(n=[],e){return On.create({name:e,providers:[{provide:Em,useValue:"platform"},{provide:UN,useValue:new Set([()=>Jp=null])},...n]})}function IW(n=[]){if(Jp)return Jp;let e=EW(n);return Jp=e,uW(),TW(e),e}function TW(n){n.get(B0,null)?.forEach(t=>t())}var Uo=(()=>{class n{static{this.__NG_ELEMENT_ID__=AW}}return n})();function AW(n){return CW(gr(),He(),(n&16)===16)}function CW(n,e,t){if(Tm(n)&&!t){let r=Vo(n.index,e);return new Va(r,r)}else if(n.type&47){let r=e[bi];return new Va(r,e)}return null}var _0=class{constructor(){}supports(e){return CN(e)}create(e){return new v0(e)}},SW=(n,e)=>e,v0=class{constructor(e){this.length=0,this._linkedRecords=null,this._unlinkedRecords=null,this._previousItHead=null,this._itHead=null,this._itTail=null,this._additionsHead=null,this._additionsTail=null,this._movesHead=null,this._movesTail=null,this._removalsHead=null,this._removalsTail=null,this._identityChangesHead=null,this._identityChangesTail=null,this._trackByFn=e||SW}forEachItem(e){let t;for(t=this._itHead;t!==null;t=t._next)e(t)}forEachOperation(e){let t=this._itHead,r=this._removalsHead,i=0,s=null;for(;t||r;){let o=!r||t&&t.currentIndex<m1(r,i,s)?t:r,a=m1(o,i,s),c=o.currentIndex;if(o===r)i--,r=r._nextRemoved;else if(t=t._next,o.previousIndex==null)i++;else{s||(s=[]);let l=a-i,u=c-i;if(l!=u){for(let f=0;f<l;f++){let p=f<s.length?s[f]:s[f]=0,y=p+f;u<=y&&y<l&&(s[f]=p+1)}let d=o.previousIndex;s[d]=u-l}}a!==c&&e(o,a,c)}}forEachPreviousItem(e){let t;for(t=this._previousItHead;t!==null;t=t._nextPrevious)e(t)}forEachAddedItem(e){let t;for(t=this._additionsHead;t!==null;t=t._nextAdded)e(t)}forEachMovedItem(e){let t;for(t=this._movesHead;t!==null;t=t._nextMoved)e(t)}forEachRemovedItem(e){let t;for(t=this._removalsHead;t!==null;t=t._nextRemoved)e(t)}forEachIdentityChange(e){let t;for(t=this._identityChangesHead;t!==null;t=t._nextIdentityChange)e(t)}diff(e){if(e==null&&(e=[]),!CN(e))throw new we(900,!1);return this.check(e)?this:null}onDestroy(){}check(e){this._reset();let t=this._itHead,r=!1,i,s,o;if(Array.isArray(e)){this.length=e.length;for(let a=0;a<this.length;a++)s=e[a],o=this._trackByFn(a,s),t===null||!Object.is(t.trackById,o)?(t=this._mismatch(t,s,o,a),r=!0):(r&&(t=this._verifyReinsertion(t,s,o,a)),Object.is(t.item,s)||this._addIdentityChange(t,s)),t=t._next}else i=0,v6(e,a=>{o=this._trackByFn(i,a),t===null||!Object.is(t.trackById,o)?(t=this._mismatch(t,a,o,i),r=!0):(r&&(t=this._verifyReinsertion(t,a,o,i)),Object.is(t.item,a)||this._addIdentityChange(t,a)),t=t._next,i++}),this.length=i;return this._truncate(t),this.collection=e,this.isDirty}get isDirty(){return this._additionsHead!==null||this._movesHead!==null||this._removalsHead!==null||this._identityChangesHead!==null}_reset(){if(this.isDirty){let e;for(e=this._previousItHead=this._itHead;e!==null;e=e._next)e._nextPrevious=e._next;for(e=this._additionsHead;e!==null;e=e._nextAdded)e.previousIndex=e.currentIndex;for(this._additionsHead=this._additionsTail=null,e=this._movesHead;e!==null;e=e._nextMoved)e.previousIndex=e.currentIndex;this._movesHead=this._movesTail=null,this._removalsHead=this._removalsTail=null,this._identityChangesHead=this._identityChangesTail=null}}_mismatch(e,t,r,i){let s;return e===null?s=this._itTail:(s=e._prev,this._remove(e)),e=this._unlinkedRecords===null?null:this._unlinkedRecords.get(r,null),e!==null?(Object.is(e.item,t)||this._addIdentityChange(e,t),this._reinsertAfter(e,s,i)):(e=this._linkedRecords===null?null:this._linkedRecords.get(r,i),e!==null?(Object.is(e.item,t)||this._addIdentityChange(e,t),this._moveAfter(e,s,i)):e=this._addAfter(new b0(t,r),s,i)),e}_verifyReinsertion(e,t,r,i){let s=this._unlinkedRecords===null?null:this._unlinkedRecords.get(r,null);return s!==null?e=this._reinsertAfter(s,e._prev,i):e.currentIndex!=i&&(e.currentIndex=i,this._addToMoves(e,i)),e}_truncate(e){for(;e!==null;){let t=e._next;this._addToRemovals(this._unlink(e)),e=t}this._unlinkedRecords!==null&&this._unlinkedRecords.clear(),this._additionsTail!==null&&(this._additionsTail._nextAdded=null),this._movesTail!==null&&(this._movesTail._nextMoved=null),this._itTail!==null&&(this._itTail._next=null),this._removalsTail!==null&&(this._removalsTail._nextRemoved=null),this._identityChangesTail!==null&&(this._identityChangesTail._nextIdentityChange=null)}_reinsertAfter(e,t,r){this._unlinkedRecords!==null&&this._unlinkedRecords.remove(e);let i=e._prevRemoved,s=e._nextRemoved;return i===null?this._removalsHead=s:i._nextRemoved=s,s===null?this._removalsTail=i:s._prevRemoved=i,this._insertAfter(e,t,r),this._addToMoves(e,r),e}_moveAfter(e,t,r){return this._unlink(e),this._insertAfter(e,t,r),this._addToMoves(e,r),e}_addAfter(e,t,r){return this._insertAfter(e,t,r),this._additionsTail===null?this._additionsTail=this._additionsHead=e:this._additionsTail=this._additionsTail._nextAdded=e,e}_insertAfter(e,t,r){let i=t===null?this._itHead:t._next;return e._next=i,e._prev=t,i===null?this._itTail=e:i._prev=e,t===null?this._itHead=e:t._next=e,this._linkedRecords===null&&(this._linkedRecords=new ym),this._linkedRecords.put(e),e.currentIndex=r,e}_remove(e){return this._addToRemovals(this._unlink(e))}_unlink(e){this._linkedRecords!==null&&this._linkedRecords.remove(e);let t=e._prev,r=e._next;return t===null?this._itHead=r:t._next=r,r===null?this._itTail=t:r._prev=t,e}_addToMoves(e,t){return e.previousIndex===t||(this._movesTail===null?this._movesTail=this._movesHead=e:this._movesTail=this._movesTail._nextMoved=e),e}_addToRemovals(e){return this._unlinkedRecords===null&&(this._unlinkedRecords=new ym),this._unlinkedRecords.put(e),e.currentIndex=null,e._nextRemoved=null,this._removalsTail===null?(this._removalsTail=this._removalsHead=e,e._prevRemoved=null):(e._prevRemoved=this._removalsTail,this._removalsTail=this._removalsTail._nextRemoved=e),e}_addIdentityChange(e,t){return e.item=t,this._identityChangesTail===null?this._identityChangesTail=this._identityChangesHead=e:this._identityChangesTail=this._identityChangesTail._nextIdentityChange=e,e}},b0=class{constructor(e,t){this.item=e,this.trackById=t,this.currentIndex=null,this.previousIndex=null,this._nextPrevious=null,this._prev=null,this._next=null,this._prevDup=null,this._nextDup=null,this._prevRemoved=null,this._nextRemoved=null,this._nextAdded=null,this._nextMoved=null,this._nextIdentityChange=null}},w0=class{constructor(){this._head=null,this._tail=null}add(e){this._head===null?(this._head=this._tail=e,e._nextDup=null,e._prevDup=null):(this._tail._nextDup=e,e._prevDup=this._tail,e._nextDup=null,this._tail=e)}get(e,t){let r;for(r=this._head;r!==null;r=r._nextDup)if((t===null||t<=r.currentIndex)&&Object.is(r.trackById,e))return r;return null}remove(e){let t=e._prevDup,r=e._nextDup;return t===null?this._head=r:t._nextDup=r,r===null?this._tail=t:r._prevDup=t,this._head===null}},ym=class{constructor(){this.map=new Map}put(e){let t=e.trackById,r=this.map.get(t);r||(r=new w0,this.map.set(t,r)),r.add(e)}get(e,t){let r=e,i=this.map.get(r);return i?i.get(e,t):null}remove(e){let t=e.trackById;return this.map.get(t).remove(e)&&this.map.delete(t),e}get isEmpty(){return this.map.size===0}clear(){this.map.clear()}};function m1(n,e,t){let r=n.previousIndex;if(r===null)return r;let i=0;return t&&r<t.length&&(i=t[r]),r+e+i}function g1(){return new gE([new _0])}var gE=(()=>{class n{static{this.\u0275prov=Q({token:n,providedIn:"root",factory:g1})}constructor(t){this.factories=t}static create(t,r){if(r!=null){let i=r.factories.slice();t=t.concat(i)}return new n(t)}static extend(t){return{provide:n,useFactory:r=>n.create(t,r||g1()),deps:[[n,new S1,new kt]]}}find(t){let r=this.factories.find(i=>i.supports(t));if(r!=null)return r;throw new we(901,!1)}}return n})();function BN(n){try{let{rootComponent:e,appProviders:t,platformProviders:r}=n,i=IW(r),s=[_W(),...t||[]],a=new pm({providers:s,parent:i,debugName:"",runEnvironmentInitializer
7s:!1}).injector,c=a.get(st);return c.run(()=>{a.resolveInjectorInitializers();let l=a.get(Ms,null),u;c.runOutsideAngular(()=>{u=c.onError.subscribe({next:p=>{l.handleError(p)}})});let d=()=>a.destroy(),f=i.get(UN);return f.add(d),a.onDestroy(()=>{u.unsubscribe(),f.delete(d)}),hW(l,c,()=>{let p=a.get($N);return p.runInitializers(),p.donePromise.then(()=>{let y=a.get(mE,gm);X6(y||gm);let v=a.get(Cl);return e!==void 0&&v.bootstrap(e),v})})})}catch(e){return Promise.reject(e)}}function Bm(n){return typeof n=="boolean"?n:n!=null&&n!=="false"}function yE(n){let e=at(null);try{return n()}finally{at(e)}}var KN=null;function Hs(){return KN}function YN(n){KN??=n}var Hm=class{};var rr=new ue(""),XN=(()=>{class n{historyGo(t){throw new Error("")}static{this.\u0275fac=function(r){return new(r||n)}}static{this.\u0275prov=Q({token:n,factory:()=>se(RW),providedIn:"platform"})}}return n})();var RW=(()=>{class n extends XN{constructor(){super(),this._doc=se(rr),this._location=window.location,this._history=window.history}getBaseHrefFromDOM(){return Hs().getBaseHref(this._doc)}onPopState(t){let r=Hs().getGlobalEventTarget(this._doc,"window");return r.addEventListener("popstate",t,!1),()=>r.removeEventListener("popstate",t)}onHashChange(t){let r=Hs().getGlobalEventTarget(this._doc,"window");return r.addEventListener("hashchange",t,!1),()=>r.removeEventListener("hashchange",t)}get href(){return this._location.href}get protocol(){return this._location.protocol}get hostname(){return this._location.hostname}get port(){return this._location.port}get pathname(){return this._location.pathname}get search(){return this._location.search}get hash(){return this._location.hash}set pathname(t){this._location.pathname=t}pushState(t,r,i){this._history.pushState(t,r,i)}replaceState(t,r,i){this._history.replaceState(t,r,i)}forward(){this._history.forward()}back(){this._history.back()}historyGo(t=0){this._history.go(t)}getState(){return this._history.state}static{this.\u0275fac=function(r){return new(r||n)}}static{this.\u0275prov=Q({token:n,factory:()=>new n,providedIn:"platform"})}}return n})();function QN(n,e){if(n.length==0)return e;if(e.length==0)return n;let t=0;return n.endsWith("/")&&t++,e.startsWith("/")&&t++,t==2?n+e.substring(1):t==1?n+e:n+"/"+e}function HN(n){let e=n.match(/#|\?|$/),t=e&&e.index||n.length,r=t-(n[t-1]==="/"?1:0);return n.slice(0,r)+n.slice(t)}function qa(n){return n&&n[0]!=="?"?"?"+n:n}var qm=(()=>{class n{historyGo(t){throw new Error("")}static{this.\u0275fac=function(r){return new(r||n)}}static{this.\u0275prov=Q({token:n,factory:()=>se(ZN),providedIn:"root"})}}return n})(),kW=new ue(""),ZN=(()=>{class n extends qm{constructor(t,r){super(),this._platformLocation=t,this._removeListenerFns=[],this._baseHref=r??this._platformLocation.getBaseHrefFromDOM()??se(rr).location?.origin??""}ngOnDestroy(){for(;this._removeListenerFns.length;)this._removeListenerFns.pop()()}onPopState(t){this._removeListenerFns.push(this._platformLocation.onPopState(t),this._platformLocation.onHashChange(t))}getBaseHref(){return this._baseHref}prepareExternalUrl(t){return QN(this._baseHref,t)}path(t=!1){let r=this._platformLocation.pathname+qa(this._platformLocation.search),i=this._platformLocation.hash;return i&&t?`${r}${i}`:r}pushState(t,r,i,s){let o=this.prepareExternalUrl(i+qa(s));this._platformLocation.pushState(t,r,o)}replaceState(t,r,i,s){let o=this.prepareExternalUrl(i+qa(s));this._platformLocation.replaceState(t,r,o)}forward(){this._platformLocation.forward()}back(){this._platformLocation.back()}getState(){return this._platformLocation.getState()}historyGo(t=0){this._platformLocation.historyGo?.(t)}static{this.\u0275fac=function(r){return new(r||n)(Y(XN),Y(kW,8))}}static{this.\u0275prov=Q({token:n,factory:n.\u0275fac,providedIn:"root"})}}return n})();var Nd=(()=>{class n{constructor(t){this._subject=new $t,this._urlChangeListeners=[],this._urlChangeSubscription=null,this._locationStrategy=t;let r=this._locationStrategy.getBaseHref();this._basePath=NW(HN(qN(r))),this._locationStrategy.onPopState(i=>{this._subject.emit({url:this.path(!0),pop:!0,state:i.state,type:i.type})})}ngOnDestroy(){this._urlChangeSubscription?.unsubscribe(),this._urlChangeListeners=[]}path(t=!1){return this.normalize(this._locationStrategy.path(t))}getState(){return this._locationStrategy.getState()}isCurrentPathEqualTo(t,r=""){return this.path()==this.normalize(t+qa(r))}normalize(t){return n.stripTrailingSlash(MW(this._basePath,qN(t)))}prepareExternalUrl(t){return t&&t[0]!=="/"&&(t="/"+t),this._locationStrategy.prepareExternalUrl(t)}
7go(t,r="",i=null){this._locationStrategy.pushState(i,"",t,r),this._notifyUrlChangeListeners(this.prepareExternalUrl(t+qa(r)),i)}replaceState(t,r="",i=null){this._locationStrategy.replaceState(i,"",t,r),this._notifyUrlChangeListeners(this.prepareExternalUrl(t+qa(r)),i)}forward(){this._locationStrategy.forward()}back(){this._locationStrategy.back()}historyGo(t=0){this._locationStrategy.historyGo?.(t)}onUrlChange(t){return this._urlChangeListeners.push(t),this._urlChangeSubscription??=this.subscribe(r=>{this._notifyUrlChangeListeners(r.url,r.state)}),()=>{let r=this._urlChangeListeners.indexOf(t);this._urlChangeListeners.splice(r,1),this._urlChangeListeners.length===0&&(this._urlChangeSubscription?.unsubscribe(),this._urlChangeSubscription=null)}}_notifyUrlChangeListeners(t="",r){this._urlChangeListeners.forEach(i=>i(t,r))}subscribe(t,r,i){return this._subject.subscribe({next:t,error:r,complete:i})}static{this.normalizeQueryParams=qa}static{this.joinWithSlash=QN}static{this.stripTrailingSlash=HN}static{this.\u0275fac=function(r){return new(r||n)(Y(qm))}}static{this.\u0275prov=Q({token:n,factory:()=>PW(),providedIn:"root"})}}return n})();function PW(){return new Nd(Y(qm))}function MW(n,e){if(!n||!e.startsWith(n))return e;let t=e.substring(n.length);return t===""||["/",";","?","#"].includes(t[0])?t:e}function qN(n){return n.replace(/\/index.html$/,"")}function NW(n){if(new RegExp("^(https?:)?//").test(n)){let[,t]=n.split(/\/\/[^\/]+/);return t}return n}function zm(n,e){e=encodeURIComponent(e);for(let t of n.split(";")){let r=t.indexOf("="),[i,s]=r==-1?[t,""]:[t.slice(0,r),t.slice(r+1)];if(i.trim()===e)return decodeURIComponent(s)}return null}var _E=/\s+/,zN=[],Gm=(()=>{class n{constructor(t,r){this._ngEl=t,this._renderer=r,this.initialClasses=zN,this.stateMap=new Map}set klass(t){this.initialClasses=t!=null?t.trim().split(_E):zN}set ngClass(t){this.rawClass=typeof t=="string"?t.trim().split(_E):t}ngDoCheck(){for(let r of this.initialClasses)this._updateState(r,!0);let t=this.rawClass;if(Array.isArray(t)||t instanceof Set)for(let r of t)this._updateState(r,!0);else if(t!=null)for(let r of Object.keys(t))this._updateState(r,!!t[r]);this._applyStateDiff()}_updateState(t,r){let i=this.stateMap.get(t);i!==void 0?(i.enabled!==r&&(i.changed=!0,i.enabled=r),i.touched=!0):this.stateMap.set(t,{enabled:r,changed:!0,touched:!0})}_applyStateDiff(){for(let t of this.stateMap){let r=t[0],i=t[1];i.changed?(this._toggleClass(r,i.enabled),i.changed=!1):i.touched||(i.enabled&&this._toggleClass(r,!1),this.stateMap.delete(r)),i.touched=!1}}_toggleClass(t,r){t=t.trim(),t.length>0&&t.split(_E).forEach(i=>{r?this._renderer.addClass(this._ngEl.nativeElement,i):this._renderer.removeClass(this._ngEl.nativeElement,i)})}static{this.\u0275fac=function(r){return new(r||n)(oe(nr),oe(Bs))}}static{this.\u0275dir=Mt({type:n,selectors:[["","ngClass",""]],inputs:{klass:[Cr.None,"class","klass"],ngClass:"ngClass"},standalone:!0})}}return n})();
7var vE=class{constructor(e,t,r,i){this.$implicit=e,this.ngForOf=t,this.index=r,this.count=i}get first(){return this.index===0}get last(){return this.index===this.count-1}get even(){return this.index%2===0}get odd(){return!this.even}},Wm=(()=>{class n{set ngForOf(t){this._ngForOf=t,this._ngForOfDirty=!0}set ngForTrackBy(t){this._trackByFn=t}get ngForTrackBy(){return this._trackByFn}constructor(t,r,i){this._viewContainer=t,this._template=r,this._differs=i,this._ngForOf=null,this._ngForOfDirty=!0,this._differ=null}set ngForTemplate(t){t&&(this._template=t)}ngDoCheck(){if(this._ngForOfDirty){this._ngForOfDirty=!1;let t=this._ngForOf;if(!this._differ&&t)if(0)try{}catch{}else this._differ=this._differs.find(t).create(this.ngForTrackBy)}if(this._differ){let t=this._differ.diff(this._ngForOf);t&&this._applyChanges(t)}}_applyChanges(t){let r=this._viewContainer;t.forEachOperation((i,s,o)=>{if(i.previousIndex==null)r.createEmbeddedView(this._template,new vE(i.item,this._ngForOf,-1,-1),o===null?void 0:o);else if(o==null)r.remove(s===null?void 0:s);else if(s!==null){let a=r.get(s);r.move(a,o),GN(a,i)}});for(let i=0,s=r.length;i<s;i++){let a=r.get(i).context;a.index=i,a.count=s,a.ngForOf=this._ngForOf}t.forEachIdentityChange(i=>{let s=r.get(i.currentIndex);GN(s,i)})}static ngTemplateContextGuard(t,r){return!0}static{this.\u0275fac=function(r){return new(r||n)(oe(Ti),oe(Lo),oe(gE))}}static{this.\u0275dir=Mt({type:n,selectors:[["","ngFor","","ngForOf",""]],inputs:{ngForOf:"ngForOf",ngForTrackBy:"ngForTrackBy",ngForTemplate:"ngForTemplate"},standalone:!0})}}return n})();function GN(n,e){n.context.$implicit=e.item}var xl=(()=>{class n{constructor(t,r){this._viewContainer=t,this._context=new bE,this._thenTemplateRef=null,this._elseTemplateRef=null,this._thenViewRef=null,this._elseViewRef=null,this._thenTemplateRef=r}set ngIf(t){this._context.$implicit=this._context.ngIf=t,this._updateView()}set ngIfThen(t){WN("ngIfThen",t),this._thenTemplateRef=t,this._thenViewRef=null,this._updateView()}set ngIfElse(t){WN("ngIfElse",t),this._elseTemplateRef=t,this._elseViewRef=null,this._updateView()}_updateView(){this._context.$implicit?this._thenViewRef||(this._viewContainer.clear(),this._elseViewRef=null,this._thenTemplateRef&&(this._thenViewRef=this._viewContainer.createEmbeddedView(this._thenTemplateRef,this._context))):this._elseViewRef||(this._viewContainer.clear(),this._thenViewRef=null,this._elseTemplateRef&&(this._elseViewRef=this._viewContainer.createEmbeddedView(this._elseTemplateRef,this._context)))}static ngTemplateContextGuard(t,r){return!0}static{this.\u0275fac=function(r){return new(r||n)(oe(Ti),oe(Lo))}}static{this.\u0275dir=Mt({type:n,selectors:[["","ngIf",""]],inputs:{ngIf:"ngIf",ngIfThen:"ngIfThen",ngIfElse:"ngIfElse"},standalone:!0})}}return n})(),bE=class{constructor(){this.$implicit=null,this.ngIf=null}};function WN(n,e){if(!!!(!e||e.createEmbeddedView))throw new Error(`${n} must be a TemplateRef, but received '${tr(e)}'.`)}var OW=!0,wE=class{constructor(e,t){this._viewContainerRef=e,this._templateRef=t,this._created=!1}create(){this._created=!0,this._viewContainerRef.createEmbeddedView(this._templateRef)}destroy(){this._created=!1,this._viewContainerRef.clear()}enforceState(e){e&&!this._created?this.create():!e&&this._created&&this.destroy()}},TE=(()=>{class n{constructor(){this._defaultViews=[],this._defaultUsed=!1,this._caseCount=0,this._lastCaseCheckIndex=0,this._lastCasesMatched=!1}set ngSwitch(t){this._ngSwitch=t,this._caseCount===0&&this._updateDefaultCases(!0)}_addCase(){return this._caseCount++}_addDefault(t){this._defaultViews.push(t)}_matchCase(t){let r=OW?t===this._ngSwitch:t==this._ngSwitch;return this._lastCasesMatched||=r,this._lastCaseCheckIndex++,this._lastCaseCheckIndex===this._caseCount&&(this._updateDefaultCases(!this._lastCasesMatched),this._lastCaseCheckIndex=0,this._lastCasesMatched=!1),r}_updateDefaultCases(t){if(this._defaultViews.length>0&&t!==this._defaultUsed){this._defaultUsed=t;for(let r of this._defaultViews)r.enforceState(t)}}static{this.\u0275fac=function(r){return new(r||n)}}static{this.\u0275dir=Mt({type:n,selectors:[["","ngSwitch",""]],inputs:{ngSwitch:"ngSwitch"},standalone:!0})}}return n})(),JN=(()=>{class n{constructor(t,r,i){this.ngSwitch=i,i._addCase(),this._view=new wE(t,r)}ngDoCheck(){this._view.enforceState(this.ngSwitch._matchCase(this.ngSwitchCase))}static{this.\u0275fac=function(r){return new(r||n)(oe(Ti),oe(Lo),oe(TE,9))}}static{this.\u0275dir=Mt({type:n,selectors:[["","ngSwitchCase",""]],inputs:{ngSwitchCase:"ngSwitchCase"},standalone:!0})}}return n})();function eO(n,e){return new we(2100,!1)}var EE=class{createSubscription(e,t){return yE(()=>e.subscribe({next:t,error:r=>{throw r}}))}dispose(e){yE(()=>e.unsubscribe())}},IE=class{createSubscription(e,t){return e.then(t,r=>{throw r})}dispose(e){}},LW=new IE,FW=new EE,Km=(()=>{class n{constructor(t){this._latestValue=null,this.markForCheckOnValueUpdate=!0,this._subscription=null,this._obj=null,this._strategy=null,this._ref=t}ngOnDestroy(){this._subscription&&this._dispose(),this._ref=null}transform(t){if(!this._obj){if(t)try{this.markForCheckOnValueUpdate=!1,this._subscribe(t)}finally{this.markForCheckOnValueUpdate=!0}return this._latestValue}return t!==this._obj?(this._dispose(),this.transform(t)):this._latestValue}_subscribe(t){this._obj=t,this._strategy=this._selectStrategy(t),this._subscription=this._strategy.createSubscription(t,r=>this._updateLatestValue(t,r))}_selectStrategy(t){if($o(t))return LW;if(fE(t))return FW;throw eO(n,t)}_dispose(){this._strategy.dispose(this._subscription),this._latestValue=null,this._subscription=null,this._obj=null}_updateLatestValue(t,r){t===this._obj&&(this._latestValue=r,this.markForCheckOnValueUpdate&&this._ref?.markForCheck())}static{this.\u0275fac=function(r){return new(r||n)(oe(Uo,16))}}static{this.\u0275pipe=wm({name:"async",type:n,pure:!1,standalone:!0})}}return n})();var VW=/(?:[0-9A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u
70EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF38\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])\S*/g,tO=(()=>{class n{transform(t){if(t==null)return null;if(typeof t!="string")throw eO(n,t);return t.replace(VW,r=>r[0].toUpperCase()+r.slice(1).toLowerCase())}static{this.\u0275fac=function(r){return new(r||n)}}static{this.\u0275pipe=wm({name:"titlecase",type:n,pure:!0,standalone:!0})}}return n})();var Ai=(()=>{class n{static{this.\u0275fac=function(r){return new(r||n)}}static{this.\u0275mod=Wi({type:n})}static{this.\u0275inj=Gi({})}}return n})(),AE="browser",jW="server";function za(n){return n===AE}function Ym(n){return n===jW}var Sl=class{};var Fd=class{},Qm=class{},Ga=class n{constructor(e){this.normalizedNames=new Map,this.lazyUpdate=null,e?typeof e=="string"?this.lazyInit=()=>{this.headers=new Map,e.split(` 8`).forEach(t=>{let r=t.indexOf(":");if(r>0){let i=t.slice(0,r),s=i.toLowerCase(),o=t.slice(r+1).trim();this.maybeSetNormalizedName(i,s),this.headers.has(s)?this.headers.get(s).push(o):this.headers.set(s,[o])}})}:typeof Headers<"u"&&e instanceof Headers?(this.headers=new Map,e.forEach((t,r)=>{this.setHeaderEntries(r,t)})):this.lazyInit=()=>{this.headers=new Map,Object.entries(e).forEach(([t,r])=>{this.setHeaderEntries(t,r)}
vendor: 4,532 bytes, line 8
8)}:this.headers=new Map}has(e){return this.init(),this.headers.has(e.toLowerCase())}get(e){this.init();let t=this.headers.get(e.toLowerCase());return t&&t.length>0?t[0]:null}keys(){return this.init(),Array.from(this.normalizedNames.values())}getAll(e){return this.init(),this.headers.get(e.toLowerCase())||null}append(e,t){return this.clone({name:e,value:t,op:"a"})}set(e,t){return this.clone({name:e,value:t,op:"s"})}delete(e,t){return this.clone({name:e,value:t,op:"d"})}maybeSetNormalizedName(e,t){this.normalizedNames.has(t)||this.normalizedNames.set(t,e)}init(){this.lazyInit&&(this.lazyInit instanceof n?this.copyFrom(this.lazyInit):this.lazyInit(),this.lazyInit=null,this.lazyUpdate&&(this.lazyUpdate.forEach(e=>this.applyUpdate(e)),this.lazyUpdate=null))}copyFrom(e){e.init(),Array.from(e.headers.keys()).forEach(t=>{this.headers.set(t,e.headers.get(t)),this.normalizedNames.set(t,e.normalizedNames.get(t))})}clone(e){let t=new n;return t.lazyInit=this.lazyInit&&this.lazyInit instanceof n?this.lazyInit:this,t.lazyUpdate=(this.lazyUpdate||[]).concat([e]),t}applyUpdate(e){let t=e.name.toLowerCase();switch(e.op){case"a":case"s":let r=e.value;if(typeof r=="string"&&(r=[r]),r.length===0)return;this.maybeSetNormalizedName(e.name,t);let i=(e.op==="a"?this.headers.get(t):void 0)||[];i.push(...r),this.headers.set(t,i);break;case"d":let s=e.value;if(!s)this.headers.delete(t),this.normalizedNames.delete(t);else{let o=this.headers.get(t);if(!o)return;o=o.filter(a=>s.indexOf(a)===-1),o.length===0?(this.headers.delete(t),this.normalizedNames.delete(t)):this.headers.set(t,o)}break}}setHeaderEntries(e,t){let r=(Array.isArray(t)?t:[t]).map(s=>s.toString()),i=e.toLowerCase();this.headers.set(i,r),this.maybeSetNormalizedName(e,i)}forEach(e){this.init(),Array.from(this.normalizedNames.keys()).forEach(t=>e(this.normalizedNames.get(t),this.headers.get(t)))}};var SE=class{encodeKey(e){return nO(e)}encodeValue(e){return nO(e)}decodeKey(e){return decodeURIComponent(e)}decodeValue(e){return decodeURIComponent(e)}};function BW(n,e){let t=new Map;return n.length>0&&n.replace(/^\?/,"").split("&").forEach(i=>{let s=i.indexOf("="),[o,a]=s==-1?[e.decodeKey(i),""]:[e.decodeKey(i.slice(0,s)),e.decodeValue(i.slice(s+1))],c=t.get(o)||[];c.push(a),t.set(o,c)}),t}var HW=/%(\d[a-f0-9])/gi,qW={40:"@","3A":":",24:"$","2C":",","3B":";","3D":"=","3F":"?","2F":"/"};function nO(n){return encodeURIComponent(n).replace(HW,(e,t)=>qW[t]??e)}function Xm(n){return`${n}`}var Bo=class n{constructor(e={}){if(this.updates=null,this.cloneFrom=null,this.encoder=e.encoder||new SE,e.fromString){if(e.fromObject)throw new Error("Cannot specify both fromString and fromObject.");this.map=BW(e.fromString,this.encoder)}else e.fromObject?(this.map=new Map,Object.keys(e.fromObject).forEach(t=>{let r=e.fromObject[t],i=Array.isArray(r)?r.map(Xm):[Xm(r)];this.map.set(t,i)})):this.map=null}has(e){return this.init(),this.map.has(e)}get(e){this.init();let t=this.map.get(e);return t?t[0]:null}getAll(e){return this.init(),this.map.get(e)||null}keys(){return this.init(),Array.from(this.map.keys())}append(e,t){return this.clone({param:e,value:t,op:"a"})}appendAll(e){let t=[];return Object.keys(e).forEach(r=>{let i=e[r];Array.isArray(i)?i.forEach(s=>{t.push({param:r,value:s,op:"a"})}):t.push({param:r,value:i,op:"a"})}),this.clone(t)}set(e,t){return this.clone({param:e,value:t,op:"s"})}delete(e,t){return this.clone({param:e,value:t,op:"d"})}toString(){return this.init(),this.keys().map(e=>{let t=this.encoder.encodeKey(e);return this.map.get(e).map(r=>t+"="+this.encoder.encodeValue(r)).join("&")}).filter(e=>e!=="").join("&")}clone(e){let t=new n({encoder:this.encoder});return t.cloneFrom=this.cloneFrom||this,t.updates=(this.updates||[]).concat(e),t}init(){this.map===null&&(this.map=new Map),this.cloneFrom!==null&&(this.cloneFrom.init(),this.cloneFrom.keys().forEach(e=>this.map.set(e,this.cloneFrom.map.get(e))),this.updates.forEach(e=>{switch(e.op){case"a":case"s":let t=(e.op==="a"?this.map.get(e.param):void 0)||[];t.push(Xm(e.value)),this.map.set(e.param,t);break;case"d":if(e.value!==void 0){let r=this.map.get(e.param)||[],i=r.indexOf(Xm(e.value));i!==-1&&r.splice(i,1),r.length>0?this.map.set(e.param,r):this.map.delete(e.param)}else{this.map.delete(e.param);break}}}),this.cloneFrom=this.updates=null)}};var xE=class{constructor(){this.map=new Map}set(e,t){return this.map.set(e,t),this}get(e){return this.map.has(e)||this.map.set(e,e.defaultValue()),this.map.get(e)}delete(e){return this.map.delete(e),this}has(e){return this.map.has(e)}
8keys(){return this.map.keys()}};function zW(n){switch(n){case"DELETE":case"GET":case"HEAD":case"OPTIONS":case"JSONP":return!1;default:return!0}}function rO(n){return typeof ArrayBuffer<"u"&&n instanceof ArrayBuffer}function iO(n){return typeof Blob<"u"&&n instanceof Blob}function sO(n){return typeof FormData<"u"&&n instanceof FormData}function GW(n){return typeof URLSearchParams<"u"&&n instanceof URLSearchParams}var Ld=class n{constructor(e,t,r,i){this.url=t,this.body=null,this.reportProgress=!1,this.withCredentials=!1,this.responseType="json",this.method=e.toUpperCase();let s;if(zW(this.method)||i?(this.body=r!==void 0?r:null,s=i):s=r,s&&(this.reportProgress=!!s.reportProgress,this.withCredentials=!!s.withCredentials,s.responseType&&(this.responseType=s.responseType),s.headers&&(this.headers=s.headers),s.context&&(this.context=s.context),s.params&&(this.params=s.params),this.transferCache=s.transferCache),this.headers??=new Ga,this.context??=new xE,!this.params)this.params=new Bo,this.urlWithParams=t;else{let o=this.params.toString();if(o.length===0)this.urlWithParams=t;else{let a=t.indexOf("?"),c=a===-1?"?":a<t.length-1?"&":"";this.urlWithParams=t+c+o}}}serializeBody(){return this.body===null?null:typeof this.body=="string"||rO(this.body)||iO(this.body)||sO(this.body)||GW(this.body)?this.body:this.body instanceof Bo?this.body.toString():typeof this.body=="object"||typeof this.body=="boolean"||Array.isArray(this.body)?JSON.stringify(this.body):this.body.toString()}detectContentTypeHeader(){return this.body===null||sO(this.body)?null:iO(this.body)?this.body.type||null:rO(this.body)?null:typeof this.body=="string"?"text/plain":this.body instanceof Bo?"application/x-www-form-urlencoded;charset=UTF-8":typeof this.body=="object"||typeof this.body=="number"||typeof this.body=="boolean"?"application/json":null}clone(e={}){let t=e.method||this.method,r=e.url||this.url,i=e.responseType||this.responseType,s=e.transferCache??this.transferCache,o=e.body!==void 0?e.body:this.body,a=e.withCredentials??this.withCredentials,c=e.reportProgress??this.reportProgress,l=e.headers||this.headers,u=e.params||this.params,d=e.context??this.context;return e.setHeaders!==void 0&&(l=Object.keys(e.setHeaders).reduce((f,p)=>f.set(p,e.setHeaders[p]),l)),e.setParams&&(u=Object.keys(e.setParams).reduce((f,p)=>f.set(p,e.setParams[p]),u)),new n(t,r,o,{params:u,headers:l,context:d,reportProgress:c,responseType:i,withCredentials:a,transferCache:s})}},Dl=function(n){return n[n.Sent=0]="Sent",n[n.UploadProgress=1]="UploadProgress",n[n.ResponseHeader=2]="ResponseHeader",n[n.DownloadProgress=3]="DownloadProgress",n[n.Response=4]="Response",n[n.User=5]="User",n}(Dl||{}),Vd=class{constructor(e,t=eg.Ok,r="OK"){this.headers=e.headers||new Ga,this.status=e.status!==void 0?e.status:t,this.statusText=e.statusText||r,this.url=e.url||null,this.ok=this.status>=200&&this.status<300}},DE=class n extends Vd{constructor(e={}){super(e),this.type=Dl.ResponseHeader}clone(e={}){return new n({headers:e.headers||this.headers,status:e.status!==void 0?e.status:this.status,statusText:e.statusText||this.statusText,url:e.url||this.url||void 0})}},Zm=class n extends Vd{constructor(e={}){super(e),this.type=Dl.Response,this.body=e.body!==void 0?e.body:null}clone(e={}){return new n({body:e.body!==void 0?e.body:this.body,headers:e.headers||this.headers,status:e.status!==void 0?e.status:this.status,statusText:e.statusText||this.statusText,url:e.url||this.url||void 0})}},Jm=class extends Vd{constructor(e){super(e,0,"Unknown Error"),this.name="HttpErrorResponse",this.ok=!1,this.status>=200&&this.status<300?this.message=`Http failure during parsing for ${e.url||"(unknown url)"}`:this.message=`Http failure response for ${e.url||"(unknown url)"}: ${e.status} ${e.statusText}`,this.error=e.error||null}},eg=function(n){return n[n.Continue=100]="Continue",n[n.SwitchingProtocols=101]="SwitchingProtocols",n[n.Processing=102]="Processing",n[n.EarlyHints=103]="EarlyHints",n[n.Ok=200]="Ok",n[n.Created=201]="Created",n[n.Accepted=202]="Accepted",n[n.NonAuthoritativeInformation=203]="NonAuthoritativeInformation",n[n.NoContent=204]="NoContent",n[n.ResetContent=205]="ResetContent",n[n.PartialContent=206]="PartialContent",n[n.MultiStatus=207]="MultiStatus",n[n.AlreadyReported=208]="AlreadyReported",n[n.ImUsed=226]="ImUsed",n[n.MultipleChoices=300]="MultipleChoices",n[n.MovedPermanently=301]="MovedPermanently",n[n.Found=302]="Found",n[n.SeeOther=303]="SeeOther",n[n.NotModified=304]="NotModified",n[n.UseProxy=305]="UseProxy",n[n.Unused=306]="Unused",n[n.TemporaryRedirect=307]="TemporaryRedirect",n[n.PermanentRedirect=308]="PermanentRedirect",n[n.BadRequest=400]="BadRequest",n[n.Unauthorized=401]="Unauthorized",n[n.PaymentRequired=402]="PaymentRequired",n[n.Forbidden=403]="Forbidden",n[n.NotFound=404]="NotFound",n[n.MethodNotAllowed=405]="MethodNotAllowed",n[n.NotAcceptable=406]="NotAcceptable",n[n.ProxyAuthenticationRequired=407]="ProxyAuthenticationRequired",n[n.RequestTimeout=408]="RequestTimeout",n[n.Conflict=409]="Conflict",n[n.Gone=410]="Gone",n[n.LengthRequired=411]="LengthRequired",n[n.PreconditionFailed=412]="PreconditionFailed",n[n.PayloadTooLarge=413]="PayloadTooLarge",n[n.UriTooLong=414]="UriTooLong",n[n.UnsupportedMediaType=415]="UnsupportedMediaType",n[n.RangeNotSatisfiable=416]="RangeNotSatisfiable",n[n.ExpectationFailed=417]="ExpectationFailed",n[n.ImATeapot=418]="ImATeapot",n[n.MisdirectedRequest=421]="MisdirectedRequest",n[n.UnprocessableEntity=422]="UnprocessableEntity",n[n.Locked=423]="Locked",n[n.FailedDependency=424]="FailedDependency",n[n.TooEarly=425]="TooEarly",n[n.UpgradeRequired=426]="UpgradeRequired",n[n.PreconditionRequired=428]="PreconditionRequired",n[n.TooManyRequests=429]="TooManyRequests",n[n.RequestHeaderFieldsTooLarge=431]="RequestHeaderFieldsTooLarge",n[n.UnavailableForLegalReasons=451]="UnavailableForLegalReasons",n[n.InternalServerError=500]="InternalServerError",n[n.NotImplemented=501]="NotImplemented",n[n.BadGateway=502]="BadGateway",n[n.ServiceUnavailable=503]="ServiceUnavailable",n[n.GatewayTimeout=504]="GatewayTimeout",n[n.HttpVersionNotSupported=505]="HttpVersionNotSupported",n[n.VariantAlsoNegotiates=506]="VariantAlsoNegotiates",n[n.InsufficientStorage=507]="InsufficientStorage",n[n.LoopDetected=508]="LoopDetected",n[n.NotExtended=510]="NotExtended",n[n.NetworkAuthenticationRequired=511]="NetworkAuthenticationRequired",n}(eg||{});function CE(n,e){return{body:e,headers:n.headers,context:n.context,observe:n.observe,params:n.params,reportProgress:n.reportProgress,responseType:n.responseType,withCredentials:n.withCredentials,transferCache:n.transferCache}}var RE=(()=>{class n{constructor(t){this.handler=t}request(t,r,i={}){let s;if(t instanceof Ld)s=t;else{let c;i.headers instanceof Ga?c=i.headers:c=new Ga(i.headers);let l;i.params&&(i.params instanceof Bo?l=i.params:l=new Bo({fromObject:i.params})),s=new Ld(t,r,i.body!==void 0?i.body:null,{headers:c,context:i.context,params:l,reportProgress:i.reportProgress,responseType:i.responseType||"json",withCredentials:i.withCredentials,transferCache:i.transferCache})}let o=Ae(s).pipe(Ro(c=>this.handler.handle(c)));if(t instanceof Ld||i.observe==="events")return o;let a=o.pipe(Tr(c=>c instanceof Zm));switch(i.observe||"body"){case"body":switch(s.responseType){case"arraybuffer":return a.pipe(ke(c=>{if(c.body!==null&&!(c.body instanceof ArrayBuffer))throw new Error("Response is not an ArrayBuffer.");return c.body}));case"blob":return a.pipe(ke(c=>{if(c.body!==null&&!(c.body instanceof Blob))throw new Error("Response is not a Blob.");return c.body}));case"text":return a.pipe(ke(c=>{if(c.body!==null&&typeof c.body!="string")throw new Error("Response is not a string.");return c.body}));case"json":default:return a.pipe(ke(c=>c.body))}case"response":return a;default:throw new Error(`Unreachable: unhandled observe type ${i.observe}}`)}}delete(t,r={}){return this.request("DELETE",t,r)}get(t,r={}){return this.request("GET",t,r)}head(t,r={}){return this.request("HEAD",t,r)}jsonp(t,r){return this.request("JSONP",t,{params:new Bo().append(r,"JSONP_CALLBACK"),observe:"body",responseType:"json"})}options(t,r={}){return this.request("OPTIONS",t,r)}patch(t,r,i={}){return this.request("PATCH",t,CE(i,r))}post(t,r,i={}){return this.request("POST",t,CE(i,r))}put(t,r,i={}){return this.request("PUT",t,CE(i,r))}static{this.\u0275fac=function(r){return new(r||n)(Y(Fd))}}static{this.\u0275prov=Q({token:n,factory:n.\u0275fac})}}return n})();function WW(n,e){return e(n)}function KW(n,e,t){return(r,i)=>Fs(t,()=>e(r,s=>n(s,i)))}var cO=new ue(""),YW=new ue(""),XW=new ue("");var oO=(()=>{class n extends Fd{constructor(t,r){super(),this.backend=t,this.injector=r,this.chain=null,this.pendingTasks=se(Tl);let i=se(XW,{optional:!0});this.backend=i??t}handle(t){if(this.chain===null){let i=Array.from(new Set([...this.injector.get(cO),...this.injector.get(YW,[])]));this.chain=i.reduceRight((s,o)=>KW(s,o,this.injector),WW)}let r=this.pendingTasks.add();return this.chain(t,i=>this.backend.handle(i)).pipe(Sa(()=>this.pendingTasks.remove(r)))}static{this.\u0275fac=function(r){return new(r||n)(Y(Qm),Y(mr))}}static{this.\u0275prov=Q({token:n,factory:n.\u0275fac})}}return n})();var QW=/^\)\]\}',?\n/;function ZW(n){return"responseURL"in n&&n.responseURL?n.responseURL:/^X-Request-URL:/m.test(n.getAllResponseHeaders())?n.getResponseHeader("X-Request-URL"):null}var aO=(()=>{class n{constructor(t){this.xhrFactory=t}handle(t){if(t.method==="JSONP")throw new we(-2800,!1);let r=this.xhrFactory;return(r.\u0275loadImpl?Rt(r.\u0275loadImpl()):Ae(null)).pipe(Jn(()=>new Ue(s=>{let o=r.build();if(o.open(t.method,t.urlWithParams),t.withCredentials&&(o.withCredentials=!0),t.headers.forEac
8h((v,w)=>o.setRequestHeader(v,w.join(","))),t.headers.has("Accept")||o.setRequestHeader("Accept","application/json, text/plain, */*"),!t.headers.has("Content-Type")){let v=t.detectContentTypeHeader();v!==null&&o.setRequestHeader("Content-Type",v)}if(t.responseType){let v=t.responseType.toLowerCase();o.responseType=v!=="json"?v:"text"}let a=t.serializeBody(),c=null,l=()=>{if(c!==null)return c;let v=o.statusText||"OK",w=new Ga(o.getAllResponseHeaders()),E=ZW(o)||t.url;return c=new DE({headers:w,status:o.status,statusText:v,url:E}),c},u=()=>{let{headers:v,status:w,statusText:E,url:A}=l(),x=null;w!==eg.NoContent&&(x=typeof o.response>"u"?o.responseText:o.response),w===0&&(w=x?eg.Ok:0);let M=w>=200&&w<300;if(t.responseType==="json"&&typeof x=="string"){let O=x;x=x.replace(QW,"");try{x=x!==""?JSON.parse(x):null}catch($){x=O,M&&(M=!1,x={error:$,text:x})}}M?(s.next(new Zm({body:x,headers:v,status:w,statusText:E,url:A||void 0})),s.complete()):s.error(new Jm({error:x,headers:v,status:w,statusText:E,url:A||void 0}))},d=v=>{let{url:w}=l(),E=new Jm({error:v,status:o.status||0,statusText:o.statusText||"Unknown Error",url:w||void 0});s.error(E)},f=!1,p=v=>{f||(s.next(l()),f=!0);let w={type:Dl.DownloadProgress,loaded:v.loaded};v.lengthComputable&&(w.total=v.total),t.responseType==="text"&&o.responseText&&(w.partialText=o.responseText),s.next(w)},y=v=>{let w={type:Dl.UploadProgress,loaded:v.loaded};v.lengthComputable&&(w.total=v.total),s.next(w)};return o.addEventListener("load",u),o.addEventListener("error",d),o.addEventListener("timeout",d),o.addEventListener("abort",d),t.reportProgress&&(o.addEventListener("progress",p),a!==null&&o.upload&&o.upload.addEventListener("progress",y)),o.send(a),s.next({type:Dl.Sent}),()=>{o.removeEventListener("error",d),o.removeEventListener("abort",d),o.removeEventListener("load",u),o.removeEventListener("timeout",d),t.reportProgress&&(o.removeEventListener("progress",p),a!==null&&o.upload&&o.upload.removeEventListener("progress",y)),o.readyState!==o.DONE&&o.abort()}})))}static{this.\u0275fac=function(r){return new(r||n)(Y(Sl))}}static{this.\u0275prov=Q({token:n,factory:n.\u0275fac})}}return n})(),lO=new ue(""),JW="XSRF-TOKEN",e9=new ue("",{providedIn:"root",factory:()=>JW}),t9="X-XSRF-TOKEN",n9=new ue("",{providedIn:"root",factory:()=>t9}),tg=class{},r9=(()=>{class n{constructor(t,r,i){this.doc=t,this.platform=r,this.cookieName=i,this.lastCookieString="",this.lastToken=null,this.parseCount=0}getToken(){if(this.platform==="server")return null;let t=this.doc.cookie||"";return t!==this.lastCookieString&&(this.parseCount++,this.lastToken=zm(t,this.cookieName),this.lastCookieString=t),this.lastToken}static{this.\u0275fac=function(r){return new(r||n)(Y(rr),Y(Gr),Y(e9))}}static{this.\u0275prov=Q({token:n,factory:n.\u0275fac})}}return n})();function i9(n,e){let t=n.url.toLowerCase();if(!se(lO)||n.method==="GET"||n.method==="HEAD"||t.startsWith("http://")||t.startsWith("https://"))return e(n);let r=se(tg).getToken(),i=se(n9);return r!=null&&!n.headers.has(i)&&(n=n.clone({headers:n.headers.set(i,r)})),e(n)}function uO(...n){let e=[RE,aO,oO,{provide:Fd,useExisting:oO},{provide:Qm,useExisting:aO},{provide:cO,useValue:i9,multi:!0},{provide:lO,useValue:!0},{provide:tg,useClass:r9}];for(let t of n)e.push(...t.\u0275providers);return Nn(e)}var ME=class extends Hm{constructor(){super(...arguments),this.supportsDOMEvents=!0}},NE=class n extends ME{static makeCurrent(){YN(new n)}onAndCancel(e,t,r){return e.addEventListener(t,r),()=>{e.removeEventListener(t,r)}}dispatchEvent(e,t){e.dispatchEvent(t)}remove(e){e.parentNode&&e.parentNode.removeChild(e)}createElement(e,t){return t=t||this.getDefaultDocument(),t.createElement(e)}createHtmlDocument(){return document.implementation.createHTMLDocument("fakeTitle")}getDefaultDocument(){return document}isElementNode(e){return e.nodeType===Node.ELEMENT_NODE}isShadowRoot(e){return e instanceof DocumentFragment}getGlobalEventTarget(e,t){return t==="window"?window:t==="document"?e:t==="body"?e.body:null}getBaseHref(e){let t=o9();return t==null?null:a9(t)}resetBaseElement(){jd=null}getUserAgent(){return window.navigator.userAgent}getCookie(e){return zm(document.cookie,e)}},jd=null;function o9(){return jd=jd||document.querySelector("base"),jd?jd.getAttribute("href"):null}function a9(n){return new URL(n,document.baseURI).pathname}var c9=(()=>{class n{build(){return new XMLHttpRequest}static{this.\u0275fac=function(r){return new(r||n)}}static{this.\u0275prov=Q({token:n,factory:n.\u0275fac})}}return n})(),OE=new ue(""),pO=(()=>{class n{constructor(t,r){this._zone=r,this._eventNameToPlugin=new Map,t.forEach(i=>
8{i.manager=this}),this._plugins=t.slice().reverse()}addEventListener(t,r,i){return this._findPluginFor(r).addEventListener(t,r,i)}getZone(){return this._zone}_findPluginFor(t){let r=this._eventNameToPlugin.get(t);if(r)return r;if(r=this._plugins.find(s=>s.supports(t)),!r)throw new we(5101,!1);return this._eventNameToPlugin.set(t,r),r}static{this.\u0275fac=function(r){return new(r||n)(Y(OE),Y(st))}}static{this.\u0275prov=Q({token:n,factory:n.\u0275fac})}}return n})(),ng=class{constructor(e){this._doc=e}},kE="ng-app-id",mO=(()=>{class n{constructor(t,r,i,s={}){this.doc=t,this.appId=r,this.nonce=i,this.platformId=s,this.styleRef=new Map,this.hostNodes=new Set,this.styleNodesInDOM=this.collectServerRenderedStyles(),this.platformIsServer=Ym(s),this.resetHostNodes()}addStyles(t){for(let r of t)this.changeUsageCount(r,1)===1&&this.onStyleAdded(r)}removeStyles(t){for(let r of t)this.changeUsageCount(r,-1)<=0&&this.onStyleRemoved(r)}ngOnDestroy(){let t=this.styleNodesInDOM;t&&(t.forEach(r=>r.remove()),t.clear());for(let r of this.getAllStyles())this.onStyleRemoved(r);this.resetHostNodes()}addHost(t){this.hostNodes.add(t);for(let r of this.getAllStyles())this.addStyleToHost(t,r)}removeHost(t){this.hostNodes.delete(t)}getAllStyles(){return this.styleRef.keys()}onStyleAdded(t){for(let r of this.hostNodes)this.addStyleToHost(r,t)}onStyleRemoved(t){let r=this.styleRef;r.get(t)?.elements?.forEach(i=>i.remove()),r.delete(t)}collectServerRenderedStyles(){let t=this.doc.head?.querySelectorAll(`style[${kE}="${this.appId}"]`);if(t?.length){let r=new Map;return t.forEach(i=>{i.textContent!=null&&r.set(i.textContent,i)}),r}return null}changeUsageCount(t,r){let i=this.styleRef;if(i.has(t)){let s=i.get(t);return s.usage+=r,s.usage}return i.set(t,{usage:r,elements:[]}),r}getStyleElement(t,r){let i=this.styleNodesInDOM,s=i?.get(r);if(s?.parentNode===t)return i.delete(r),s.removeAttribute(kE),s;{let o=this.doc.createElement("style");return this.nonce&&o.setAttribute("nonce",this.nonce),o.textContent=r,this.platformIsServer&&o.setAttribute(kE,this.appId),t.appendChild(o),o}}addStyleToHost(t,r){let i=this.getStyleElement(t,r),s=this.styleRef,o=s.get(r)?.elements;o?o.push(i):s.set(r,{elements:[i],usage:1})}resetHostNodes(){let t=this.hostNodes;t.clear(),t.add(this.doc.head)}static{this.\u0275fac=function(r){return new(r||n)(Y(rr),Y(U0),Y(H0,8),Y(Gr))}}static{this.\u0275prov=Q({token:n,factory:n.\u0275fac})}}return n})(),PE={svg:"http://www.w3.org/2000/svg",xhtml:"http://www.w3.org/1999/xhtml",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/",math:"http://www.w3.org/1998/MathML/"},FE=/%COMP%/g,gO="%COMP%",l9=`_nghost-${gO}`,u9=`_ngcontent-${gO}`,d9=!0,h9=new ue("",{providedIn:"root",factory:()=>d9});function f9(n){return u9.replace(FE,n)}function p9(n){return l9.replace(FE,n)}function yO(n,e){return e.map(t=>t.replace(FE,n))}var dO=(()=>{class n{constructor(t,r,i,s,o,a,c,l=null){this.eventManager=t,this.sharedStylesHost=r,this.appId=i,this.removeStylesOnCompDestroy=s,this.doc=o,this.platformId=a,this.ngZone=c,this.nonce=l,this.rendererByCompId=new Map,this.platformIsServer=Ym(a),this.defaultRenderer=new $d(t,o,c,this.platformIsServer)}createRenderer(t,r){if(!t||!r)return this.defaultRenderer;this.platformIsServer&&r.encapsulation===qi.ShadowDom&&(r=D(_({},r),{encapsulation:qi.Emulated}));let i=this.getOrCreateRenderer(t,r);return i instanceof rg?i.applyToHost(t):i instanceof Ud&&i.applyStyles(),i}getOrCreateRenderer(t,r){let i=this.rendererByCompId,s=i.get(r.id);if(!s){let o=this.doc,a=this.ngZone,c=this.eventManager,l=this.sharedStylesHost,u=this.removeStylesOnCompDestroy,d=this.platformIsServer;switch(r.encapsulation){case qi.Emulated:s=new rg(c,l,r,this.appId,u,o,a,d);break;case qi.ShadowDom:return new LE(c,l,t,r,o,a,this.nonce,d);default:s=new Ud(c,l,r,u,o,a,d);break}i.set(r.id,s)}return s}ngOnDestroy(){this.rendererByCompId.clear()}static{this.\u0275fac=function(r){return new(r||n)(Y(pO),Y(mO),Y(U0),Y(h9),Y(rr),Y(Gr),Y(st),Y(H0))}}static{this.\u0275prov=Q({token:n,factory:n.\u0275fac})}}return n}
8)(),$d=class{constructor(e,t,r,i){this.eventManager=e,this.doc=t,this.ngZone=r,this.platformIsServer=i,this.data=Object.create(null),this.throwOnSyntheticProps=!0,this.destroyNode=null}destroy(){}createElement(e,t){return t?this.doc.createElementNS(PE[t]||t,e):this.doc.createElement(e)}createComment(e){return this.doc.createComment(e)}createText(e){return this.doc.createTextNode(e)}appendChild(e,t){(hO(e)?e.content:e).appendChild(t)}insertBefore(e,t,r){e&&(hO(e)?e.content:e).insertBefore(t,r)}removeChild(e,t){e&&e.removeChild(t)}selectRootElement(e,t){let r=typeof e=="string"?this.doc.querySelector(e):e;if(!r)throw new we(-5104,!1);return t||(r.textContent=""),r}parentNode(e){return e.parentNode}nextSibling(e){return e.nextSibling}setAttribute(e,t,r,i){if(i){t=i+":"+t;let s=PE[i];s?e.setAttributeNS(s,t,r):e.setAttribute(t,r)}else e.setAttribute(t,r)}removeAttribute(e,t,r){if(r){let i=PE[r];i?e.removeAttributeNS(i,t):e.removeAttribute(`${r}:${t}`)}else e.removeAttribute(t)}addClass(e,t){e.classList.add(t)}removeClass(e,t){e.classList.remove(t)}
8setStyle(e,t,r,i){i&(Os.DashCase|Os.Important)?e.style.setProperty(t,r,i&Os.Important?"important":""):e.style[t]=r}removeStyle(e,t,r){r&Os.DashCase?e.style.removeProperty(t):e.style[t]=""}setProperty(e,t,r){e!=null&&(e[t]=r)}setValue(e,t){e.nodeValue=t}listen(e,t,r){if(typeof e=="string"&&(e=Hs().getGlobalEventTarget(this.doc,e),!e))throw new Error(`Unsupported event target ${e} for event ${t}`);return this.eventManager.addEventListener(e,t,this.decoratePreventDefault(r))}decoratePreventDefault(e){return t=>{if(t==="__ngUnwrap__")return e;(this.platformIsServer?this.ngZone.runGuarded(()=>e(t)):e(t))===!1&&t.preventDefault()}}};function hO(n){return n.tagName==="TEMPLATE"&&n.content!==void 0}var LE=class extends $d{constructor(e,t,r,i,s,o,a,c){super(e,s,o,c),this.sharedStylesHost=t,this.hostEl=r,this.shadowRoot=r.attachShadow({mode:"open"}),this.sharedStylesHost.addHost(this.shadowRoot);let l=yO(i.id,i.styles);for(let u of l){let d=document.createElement("style");a&&d.setAttribute("nonce",a),d.textContent=u,this.shadowRoot.appendChild(d)}}nodeOrShadowRoot(e){return e===this.hostEl?this.shadowRoot:e}appendChild(e,t){return super.appendChild(this.nodeOrShadowRoot(e),t)}insertBefore(e,t,r){return super.insertBefore(this.nodeOrShadowRoot(e),t,r)}removeChild(e,t){return super.removeChild(this.nodeOrShadowRoot(e),t)}parentNode(e){return this.nodeOrShadowRoot(super.parentNode(this.nodeOrShadowRoot(e)))}destroy(){this.sharedStylesHost.removeHost(this.shadowRoot)}},Ud=class extends $d{constructor(e,t,r,i,s,o,a,c){super(e,s,o,a),this.sharedStylesHost=t,this.removeStylesOnCompDestroy=i,this.styles=c?yO(c,r.styles):r.styles}applyStyles(){this.sharedStylesHost.addStyles(this.styles)}destroy(){this.removeStylesOnCompDestroy&&this.sharedStylesHost.removeStyles(this.styles)}},rg=class extends Ud{constructor(e,t,r,i,s,o,a,c){let l=i+"-"+r.id;super(e,t,r,s,o,a,c,l),this.contentAttr=f9(l),this.hostAttr=p9(l)}applyToHost(e){this.applyStyles(),this.setAttribute(e,this.hostAttr,"")}createElement(e,t){let r=super.createElement(e,t);return super.setAttribute(r,this.contentAttr,""),r}},m9=(()=>{class n extends ng{constructor(t){super(t)}supports(t){return!0}addEventListener(t,r,i){return t.addEventListener(r,i,!1),()=>this.removeEventListener(t,r,i)}removeEventListener(t,r,i){return t.removeEventListener(r,i)}static{this.\u0275fac=function(r){return new(r||n)(Y(rr))}}static{this.\u0275prov=Q({token:n,factory:n.\u0275fac})}}return n})(),fO=["alt","control","meta","shift"],g9={"\b":"Backspace"," ":"Tab","\x7F":"Delete","\x1B":"Escape",Del:"Delete",Esc:"Escape",Left:"ArrowLeft",Right:"ArrowRight",Up:"ArrowUp",Down:"ArrowDown",Menu:"ContextMenu",Scroll:"ScrollLock",Win:"OS"},y9={alt:n=>n.altKey,control:n=>n.ctrlKey,meta:n=>n.metaKey,shift:n=>n.shiftKey},_9=(()=>{class n extends ng{constructor(t){super(t)}supports(t){return n.parseEventName(t)!=null}addEventListener(t,r,i){let s=n.parseEventName(r),o=n.eventCallback(s.fullKey,i,this.manager.getZone());return this.manager.getZone().runOutsideAngular(()=>Hs().onAndCancel(t,s.domEventName,o))}static parseEventName(t){let r=t.toLowerCase().split("."),i=r.shift();if(r.length===0||!(i==="keydown"||i==="keyup"))return null;let s=n._normalizeKey(r.pop()),o="",a=r.indexOf("code");if(a>-1&&(r.splice(a,1),o="code."),fO.forEach(l=>{let u=r.indexOf(l);u>-1&&(r.splice(u,1),o+=l+".")}),o+=s,r.length!=0||s.length===0)return null;let c={};return c.domEventName=i,c.fullKey=o,c}
8static matchEventFullKeyCode(t,r){let i=g9[t.key]||t.key,s="";return r.indexOf("code.")>-1&&(i=t.code,s="code."),i==null||!i?!1:(i=i.toLowerCase(),i===" "?i="space":i==="."&&(i="dot"),fO.forEach(o=>{if(o!==i){let a=y9[o];a(t)&&(s+=o+".")}}),s+=i,s===r)}static eventCallback(t,r,i){return s=>{n.matchEventFullKeyCode(s,t)&&i.runGuarded(()=>r(s))}}static _normalizeKey(t){return t==="esc"?"escape":t}static{this.\u0275fac=function(r){return new(r||n)(Y(rr))}}static{this.\u0275prov=Q({token:n,factory:n.\u0275fac})}}return n})();function _O(n,e){return BN(_({rootComponent:n},v9(e)))}function v9(n){return{appProviders:[...T9,...n?.providers??[]],platformProviders:I9}}function b9(){NE.makeCurrent()}function w9(){return new Ms}function E9(){return kM(document),document}var I9=[{provide:Gr,useValue:AE},{provide:B0,useValue:b9,multi:!0},{provide:rr,useFactory:E9,deps:[]}];var T9=[{provide:Em,useValue:"root"},{provide:Ms,useFactory:w9,deps:[]},{provide:OE,useClass:m9,multi:!0,deps:[rr,st,Gr]},{provide:OE,useClass:_9,multi:!0,deps:[rr]},dO,mO,pO,{provide:wd,useExisting:dO},{provide:Sl,useClass:c9,deps:[]},[]];var vO=(()=>{class n{constructor(t){this._doc=t}getTitle(){return this._doc.title}setTitle(t){this._doc.title=t||""}static{this.\u0275fac=function(r){return new(r||n)(Y(rr))}}static{this.\u0275prov=Q({token:n,factory:n.\u0275fac,providedIn:"root"})}}return n})();var VE=(()=>{class n{static{this.\u0275fac=function(r){return new(r||n)}}static{this.\u0275prov=Q({token:n,factory:function(r){let i=null;return r?i=new(r||n):i=Y(A9),i},providedIn:"root"})}}return n})(),A9=(()=>{class n extends VE{constructor(t){super(),this._doc=t}sanitize(t,r){if(r==null)return null;switch(t){case Ii.NONE:return r;case Ii.HTML:return Ua(r,"HTML")?$s(r):HM(this._doc,String(r)).toString();case Ii.STYLE:return Ua(r,"Style")?$s(r):r;case Ii.SCRIPT:if(Ua(r,"Script"))return $s(r);throw new we(5200,!1);case Ii.URL:return Ua(r,"URL")?$s(r):km(String(r));case Ii.RESOURCE_URL:if(Ua(r,"ResourceURL"))return $s(r);throw new we(5201,!1);default:throw new we(5202,!1)}}bypassSecurityTrustHtml(t){return MM(t)}bypassSecurityTrustStyle(t){return NM(t)}bypassSecurityTrustScript(t){return OM(t)}bypassSecurityTrustUrl(t){return LM(t)}bypassSecurityTrustResourceUrl(t){return FM(t)}static{this.\u0275fac=function(r){return new(r||n)(Y(rr))}}static{this.\u0275prov=Q({token:n,factory:n.\u0275fac,providedIn:"root"})}}return n})();var Ve="primary",nh=Symbol("RouteTitle"),HE=class{constructor(e){this.params=e||{}}has(e){return Object.prototype.hasOwnProperty.call(this.params,e)}get(e){if(this.has(e)){let t=this.params[e];return Array.isArray(t)?t[0]:t}return null}getAll(e){if(this.has(e)){let t=this.params[e];return Array.isArray(t)?t:[t]}return[]}get keys(){return Object.keys(this.params)}};function Nl(n){return new HE(n)}function C9(n,e,t){let r=t.path.split("/");if(r.length>n.length||t.pathMatch==="full"&&(e.hasChildren()||r.length<n.length))return null;let i={};for(let s=0;s<r.length;s++){let o=r[s],a=n[s];if(o.startsWith(":"))i[o.substring(1)]=a;else if(o!==a.path)return null}return{consumed:n.slice(0,r.length),posParams:i}}function S9(n,e){if(n.length!==e.length)return!1;for(let t=0;t<n.length;++t)if(!Qi(n[t],e[t]))return!1;return!0}function Qi(n,e){let t=n?qE(n):void 0,r=e?qE(e):void 0;if(!t||!r||t.length!=r.length)return!1;let i;for(let s=0;s<t.length;s++)if(i=t[s],!CO(n[i],e[i]))return!1;return!0}function qE(n){return[...Object.keys(n),...Object.getOwnPropertySymbols(n)]}function CO(n,e){if(Array.isArray(n)&&Array.isArray(e)){if(n.length!==e.length)return!1;let t=[...n].sort(),r=[...e].sort();return t.every((i,s)=>r[s]===i)}else return n===e}function SO(n){return n.length>0?n[n.length-1]:null}function zo(n){return Zb(n)?n:$o(n)?Rt(Promise.resolve(n)):Ae(n)}var x9={exact:DO,subset:RO},xO={exact:D9,subset:R9,ignored:()=>!0};function wO(n,e,t){return x9[t.paths](n.root,e.root,t.matrixParams)&&xO[t.queryParams](n.queryParams,e.queryParams)&&!(t.fragment==="exact"&&n.fragment!==e.fragment)}function D9(n,e){return Qi(n,e)}function DO(n,e,t){if(!Ka(n.segments,e.segments)||!og(n.segments,e.segments,t)||n.numberOfChildren!==e.numberOfChildren)return!1;for(let r in e.children)if(!n.children[r]||!DO(n.children[r],e.children[r],t))return!1;return!0}function R9(n,e){return Object.keys(e).length<=Object.keys(n).length&&Object.keys(e).every(t=>CO(n[t],e[t]))}function RO(n,e,t){return kO(n,e,e.segments,t)}function kO(n,e,t,r){if(n.segments.length>t.length){let i=n.segments.slice(0,t.length);
vendor: 10,069 bytes, line 8
8return!(!Ka(i,t)||e.hasChildren()||!og(i,t,r))}else if(n.segments.length===t.length){if(!Ka(n.segments,t)||!og(n.segments,t,r))return!1;for(let i in e.children)if(!n.children[i]||!RO(n.children[i],e.children[i],r))return!1;return!0}else{let i=t.slice(0,n.segments.length),s=t.slice(n.segments.length);return!Ka(n.segments,i)||!og(n.segments,i,r)||!n.children[Ve]?!1:kO(n.children[Ve],e,s,r)}}function og(n,e,t){return e.every((r,i)=>xO[t](n[i].parameters,r.parameters))}var Ho=class{constructor(e=new ht([],{}),t={},r=null){this.root=e,this.queryParams=t,this.fragment=r}get queryParamMap(){return this._queryParamMap??=Nl(this.queryParams),this._queryParamMap}toString(){return M9.serialize(this)}},ht=class{constructor(e,t){this.segments=e,this.children=t,this.parent=null,Object.values(t).forEach(r=>r.parent=this)}hasChildren(){return this.numberOfChildren>0}get numberOfChildren(){return Object.keys(this.children).length}toString(){return ag(this)}},Wa=class{constructor(e,t){this.path=e,this.parameters=t}get parameterMap(){return this._parameterMap??=Nl(this.parameters),this._parameterMap}toString(){return MO(this)}};function k9(n,e){return Ka(n,e)&&n.every((t,r)=>Qi(t.parameters,e[r].parameters))}function Ka(n,e){return n.length!==e.length?!1:n.every((t,r)=>t.path===e[r].path)}function P9(n,e){let t=[];return Object.entries(n.children).forEach(([r,i])=>{r===Ve&&(t=t.concat(e(i,r)))}),Object.entries(n.children).forEach(([r,i])=>{r!==Ve&&(t=t.concat(e(i,r)))}),t}var gI=(()=>{class n{static{this.\u0275fac=function(r){return new(r||n)}}static{this.\u0275prov=Q({token:n,factory:()=>new lg,providedIn:"root"})}}return n})(),lg=class{parse(e){let t=new GE(e);return new Ho(t.parseRootSegment(),t.parseQueryParams(),t.parseFragment())}serialize(e){let t=`/${Bd(e.root,!0)}`,r=L9(e.queryParams),i=typeof e.fragment=="string"?`#${N9(e.fragment)}`:"";return`${t}${r}${i}`}},M9=new lg;function ag(n){return n.segments.map(e=>MO(e)).join("/")}function Bd(n,e){if(!n.hasChildren())return ag(n);if(e){let t=n.children[Ve]?Bd(n.children[Ve],!1):"",r=[];return Object.entries(n.children).forEach(([i,s])=>{i!==Ve&&r.push(`${i}:${Bd(s,!1)}`)}),r.length>0?`${t}(${r.join("//")})`:t}else{let t=P9(n,(r,i)=>i===Ve?[Bd(n.children[Ve],!1)]:[`${i}:${Bd(r,!1)}`]);return Object.keys(n.children).length===1&&n.children[Ve]!=null?`${ag(n)}/${t[0]}`:`${ag(n)}/(${t.join("//")})`}}function PO(n){return encodeURIComponent(n).replace(/%40/g,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",")}function ig(n){return PO(n).replace(/%3B/gi,";")}function N9(n){return encodeURI(n)}function zE(n){return PO(n).replace(/\(/g,"%28").replace(/\)/g,"%29").replace(/%26/gi,"&")}function cg(n){return decodeURIComponent(n)}function EO(n){return cg(n.replace(/\+/g,"%20"))}function MO(n){return`${zE(n.path)}${O9(n.parameters)}`}function O9(n){return Object.entries(n).map(([e,t])=>`;${zE(e)}=${zE(t)}`).join("")}function L9(n){let e=Object.entries(n).map(([t,r])=>Array.isArray(r)?r.map(i=>`${ig(t)}=${ig(i)}`).join("&"):`${ig(t)}=${ig(r)}`).filter(t=>t);return e.length?`?${e.join("&")}`:""}var F9=/^[^\/()?;#]+/;function jE(n){let e=n.match(F9);return e?e[0]:""}var V9=/^[^\/()?;=#]+/;function j9(n){let e=n.match(V9);return e?e[0]:""}var $9=/^[^=?&#]+/;function U9(n){let e=n.match($9);return e?e[0]:""}var B9=/^[^&#]+/;function H9(n){let e=n.match(B9);return e?e[0]:""}var GE=class{constructor(e){this.url=e,this.remaining=e}parseRootSegment(){return this.consumeOptional("/"),this.remaining===""||this.peekStartsWith("?")||this.peekStartsWith("#")?new ht([],{}):new ht([],this.parseChildren())}parseQueryParams(){let e={};if(this.consumeOptional("?"))do this.parseQueryParam(e);while(this.consumeOptional("&"));return e}parseFragment(){return this.consumeOptional("#")?decodeURIComponent(this.remaining):null}parseChildren(){if(this.remaining==="")return{};this.consumeOptional("/");let e=[];for(this.peekStartsWith("(")||e.push(this.parseSegment());this.peekStartsWith("/")&&!this.peekStartsWith("//")&&!this.peekStartsWith("/(");)this.capture("/"),e.push(this.parseSegment());let t={};this.peekStartsWith("/(")&&(this.capture("/"),t=this.parseParens(!0));let r={};return this.peekStartsWith("(")&&(r=this.parseParens(!1)),(e.length>0||Object.keys(t).length>0)&&(r[Ve]=new ht(e,t)),r}parseSegment(){let e=jE(this.remaining);if(e===""&&this.peekStartsWith(";"))throw new we(4009,!1);return this.capture(e),new Wa(cg(e),this.parseMatrixParams())}parseMatrixParams(){let e={};for(;this.consumeOptional(";");)this.parseParam(e);return e}parseParam(e){let t=j9(this.remaining);if(!t)return;this.capture(t);let r="";if(this.consumeOptional("=")){let i=jE(this.remaining);i&&(r=i,this.capture(r))}e[cg(t)]=cg(r)}parseQueryParam(e){let t=U9(this.remaining);if(!t)return;this.capture(t);let r="";if(this.consumeOptional("=")){let o=H9(this.remaining);o&&(r=o,this.capture(r))}let i=EO(t),s=EO(r);if(e.hasOwnProperty(i)){let o=e[i];Array.isArray(o)||(o=[o],e[i]=o),o.push(s)}else e[i]=s}parseParens(e){let t={};for(this.capture("(");!this.consumeOptional(")")&&this.remaining.length>0;){let r=jE(this.remaining),i=this.remaining[r.length];if(i!=="/"&&i!==")"&&i!==";")throw new we(4010,!1);let s;r.indexOf(":")>-1?(s=r.slice(0,r.indexOf(":")),this.capture(s),this.capture(":")):e&&(s=Ve);let o=this.parseChildren();t[s]=Object.keys(o).length===1?o[Ve]:new ht([],o),this.consumeOptional("//")}return t}peekStartsWith(e){return this.remaining.startsWith(e)}consumeOptional(e){return this.peekStartsWith(e)?(this.remaining=this.remaining.substring(e.length),!0):!1}capture(e){if(!this.consumeOptional(e))throw new we(4011,!1)}};function NO(n){return n.segments.length>0?new ht([],{[Ve]:n}):n}function OO(n){let e={};for(let[r,i]of Object.entries(n.children)){let s=OO(i);if(r===Ve&&s.segments.length===0&&s.hasChildren())for(let[o,a]of Object.entries(s.children))e[o]=a;else(s.segments.length>0||s.hasChildren())&&(e[r]=s)}let t=new ht(n.segments,e);return q9(t)}function q9(n){if(n.numberOfChildren===1&&n.children[Ve]){let e=n.children[Ve];return new ht(n.segments.concat(e.segments),e.children)}return n}function Ol(n){return n instanceof Ho}function z9(n,e,t=null,r=null){let i=LO(n);return FO(i,e,t,r)}function LO(n){let e;function t(s){let o={};for(let c of s.children){let l=t(c);o[c.outlet]=l}let a=new ht(s.url,o);return s===n&&(e=a),a}let r=t(n.root),i=NO(r);return e??i}function FO(n,e,t,r){let i=n;for(;i.parent;)i=i.parent;if(e.length===0)return $E(i,i,i,t,r);let s=G9(e);if(s.toRoot())return $E(i,i,new ht([],{}),t,r);let o=W9(s,i,n),a=o.processChildren?zd(o.segmentGroup,o.index,s.commands):jO(o.segmentGroup,o.index,s.commands);return $E(i,o.segmentGroup,a,t,r)}function ug(n){return typeof n=="object"&&n!=null&&!n.outlets&&!n.segmentPath}function Kd(n){return typeof n=="object"&&n!=null&&n.outlets}function $E(n,e,t,r,i){let s={};r&&Object.entries(r).forEach(([c,l])=>{s[c]=Array.isArray(l)?l.map(u=>`${u}`):`${l}`});let o;n===e?o=t:o=VO(n,e,t);let a=NO(OO(o));return new Ho(a,s,i)}function VO(n,e,t){let r={};return Object.entries(n.children).forEach(([i,s])=>{s===e?r[i]=t:r[i]=VO(s,e,t)}),new ht(n.segments,r)}var dg=class{constructor(e,t,r){if(this.isAbsolute=e,this.numberOfDoubleDots=t,this.commands=r,e&&r.length>0&&ug(r[0]))throw new we(4003,!1);let i=r.find(Kd);if(i&&i!==SO(r))throw new we(4004,!1)}toRoot(){return this.isAbsolute&&this.commands.length===1&&this.commands[0]=="/"}};function G9(n){if(typeof n[0]=="string"&&n.length===1&&n[0]==="/")return new dg(!0,0,n);let e=0,t=!1,r=n.reduce((i,s,o)=>{if(typeof s=="object"&&s!=null){if(s.outlets){let a={};return Object.entries(s.outlets).forEach(([c,l])=>{a[c]=typeof l=="string"?l.split("/"):l}),[...i,{outlets:a}]}if(s.segmentPath)return[...i,s.segmentPath]}return typeof s!="string"?[...i,s]:o===0?(s.split("/").forEach((a,c)=>{c==0&&a==="."||(c==0&&a===""?t=!0:a===".."?e++:a!=""&&i.push(a))}),i):[...i,s]},[]);return new dg(t,e,r)}var Pl=class{constructor(e,t,r){this.segmentGroup=e,this.processChildren=t,this.index=r}};function W9(n,e,t){if(n.isAbsolute)return new Pl(e,!0,0);if(!t)return new Pl(e,!1,NaN);if(t.parent===null)return new Pl(t,!0,0);let r=ug(n.commands[0])?0:1,i=t.segments.length-1+r;return K9(t,i,n.numberOfDoubleDots)}function K9(n,e,t){let r=n,i=e,s=t;for(;s>i;){if(s-=i,r=r.parent,!r)throw new we(4005,!1);i=r.segments.length}return new Pl(r,!1,i-s)}function Y9(n){return Kd(n[0])?n[0].outlets:{[Ve]:n}}function jO(n,e,t){if(n??=new ht([],{}),n.segments.length===0&&n.hasChildren())return zd(n,e,t);let r=X9(n,e,t),i=t.slice(r.commandIndex);if(r.match&&r.pathIndex<n.segments.length){let s=new ht(n.segments.slice(0,r.pathIndex),{});return s.children[Ve]=new ht(n.segments.slice(r.pathIndex),n.children),zd(s,0,i)}else return r.match&&i.length===0?new ht(n.segments,{}):r.match&&!n.hasChildren()?WE(n,e,t):r.match?zd(n,0,i):WE(n,e,t)}function zd(n,e,t){if(t.length===0)return new ht(n.segments,{});{let r=Y9(t),i={};if(Object.keys(r).some(s=>s!==Ve)&&n.children[Ve]&&n.numberOfChildren===1&&n.children[Ve].segments.length===0){let s=zd(n.children[Ve],e,t);return new ht(n.segments,s.children)}return Object.entries(r).forEach(([s,o])=>{typeof o=="string"&&(o=[o]),o!==null&&(i[s]=jO(n.children[s],e,o))}),Object.entries(n.children).forEach(([s,o])=>{r[s]===void 0&&(i[s]=o)}),new ht(n.segments,i)}}function X9(n,e,t){let r=0,i=e,s={match:!1,pathIndex:0,commandIndex:0};for(;i<n.segments.length;){if(r>=t.length)return s;let o=n.segments[i],a=t[r];if(Kd(a))break;let c=`${a}`,l=r<t.length-1?t[r+1]:null;if(i>0&&c===void 0)break;if(c&&l&&typeof l=="object"&&l.outlets===void 0){if(!TO(c,l,o))return s;r+=2}else{if(!TO(c,{},o))return s;r++}i++}return{match:!0,pathIndex:i,commandIndex:r}}function WE(n,e,t){let r=n.segments.slice(0,e),i=0;for(;i<t.length;){let s=t[i];if(Kd(s)){let c=Q9(s.outlets);return new ht(r,c)}if(i===0&&ug(t[0])){let c=n.segments[e];r.push(new Wa(c.path,IO(t[0]))),i++;continue}let o=Kd(s)?s.outlets[Ve]:`${s}`,a=i<t.length-1?t[i+1]:null;o&&a&&ug(a)?(r.push(new Wa(o,IO(a))),i+=2):(r.push(new Wa(o,{})),i++)}return new ht(r,{})}function Q9(n){let e={};
8return Object.entries(n).forEach(([t,r])=>{typeof r=="string"&&(r=[r]),r!==null&&(e[t]=WE(new ht([],{}),0,r))}),e}function IO(n){let e={};return Object.entries(n).forEach(([t,r])=>e[t]=`${r}`),e}function TO(n,e,t){return n==t.path&&Qi(e,t.parameters)}var Gd="imperative",En=function(n){return n[n.NavigationStart=0]="NavigationStart",n[n.NavigationEnd=1]="NavigationEnd",n[n.NavigationCancel=2]="NavigationCancel",n[n.NavigationError=3]="NavigationError",n[n.RoutesRecognized=4]="RoutesRecognized",n[n.ResolveStart=5]="ResolveStart",n[n.ResolveEnd=6]="ResolveEnd",n[n.GuardsCheckStart=7]="GuardsCheckStart",n[n.GuardsCheckEnd=8]="GuardsCheckEnd",n[n.RouteConfigLoadStart=9]="RouteConfigLoadStart",n[n.RouteConfigLoadEnd=10]="RouteConfigLoadEnd",n[n.ChildActivationStart=11]="ChildActivationStart",n[n.ChildActivationEnd=12]="ChildActivationEnd",n[n.ActivationStart=13]="ActivationStart",n[n.ActivationEnd=14]="ActivationEnd",n[n.Scroll=15]="Scroll",n[n.NavigationSkipped=16]="NavigationSkipped",n}(En||{}),Kr=class{constructor(e,t){this.id=e,this.url=t}},Yd=class extends Kr{constructor(e,t,r="imperative",i=null){super(e,t),this.type=En.NavigationStart,this.navigationTrigger=r,this.restoredState=i}toString(){return`NavigationStart(id: ${this.id}, url: '${this.url}')`}},Ya=class extends Kr{constructor(e,t,r){super(e,t),this.urlAfterRedirects=r,this.type=En.NavigationEnd}toString(){return`NavigationEnd(id: ${this.id}, url: '${this.url}', urlAfterRedirects: '${this.urlAfterRedirects}')`}},Nr=function(n){return n[n.Redirect=0]="Redirect",n[n.SupersededByNewNavigation=1]="SupersededByNewNavigation",n[n.NoDataFromResolver=2]="NoDataFromResolver",n[n.GuardRejected=3]="GuardRejected",n}(Nr||{}),KE=function(n){return n[n.IgnoredSameUrlNavigation=0]="IgnoredSameUrlNavigation",n[n.IgnoredByUrlHandlingStrategy=1]="IgnoredByUrlHandlingStrategy",n}(KE||{}
8),qo=class extends Kr{constructor(e,t,r,i){super(e,t),this.reason=r,this.code=i,this.type=En.NavigationCancel}toString(){return`NavigationCancel(id: ${this.id}, url: '${this.url}')`}},Xa=class extends Kr{constructor(e,t,r,i){super(e,t),this.reason=r,this.code=i,this.type=En.NavigationSkipped}},Xd=class extends Kr{constructor(e,t,r,i){super(e,t),this.error=r,this.target=i,this.type=En.NavigationError}toString(){return`NavigationError(id: ${this.id}, url: '${this.url}', error: ${this.error})`}},hg=class extends Kr{constructor(e,t,r,i){super(e,t),this.urlAfterRedirects=r,this.state=i,this.type=En.RoutesRecognized}toString(){return`RoutesRecognized(id: ${this.id}, url: '${this.url}', urlAfterRedirects: '${this.urlAfterRedirects}', state: ${this.state})`}},YE=class extends Kr{constructor(e,t,r,i){super(e,t),this.urlAfterRedirects=r,this.state=i,this.type=En.GuardsCheckStart}toString(){return`GuardsCheckStart(id: ${this.id}, url: '${this.url}', urlAfterRedirects: '${this.urlAfterRedirects}', state: ${this.state})`}},XE=class extends Kr{constructor(e,t,r,i,s){super(e,t),this.urlAfterRedirects=r,this.state=i,this.shouldActivate=s,this.type=En.GuardsCheckEnd}toString(){return`GuardsCheckEnd(id: ${this.id}, url: '${this.url}', urlAfterRedirects: '${this.urlAfterRedirects}', state: ${this.state}, shouldActivate: ${this.shouldActivate})`}}
8,QE=class extends Kr{constructor(e,t,r,i){super(e,t),this.urlAfterRedirects=r,this.state=i,this.type=En.ResolveStart}toString(){return`ResolveStart(id: ${this.id}, url: '${this.url}', urlAfterRedirects: '${this.urlAfterRedirects}', state: ${this.state})`}},ZE=class extends Kr{constructor(e,t,r,i){super(e,t),this.urlAfterRedirects=r,this.state=i,this.type=En.ResolveEnd}toString(){return`ResolveEnd(id: ${this.id}, url: '${this.url}', urlAfterRedirects: '${this.urlAfterRedirects}', state: ${this.state})`}},JE=class{constructor(e){this.route=e,this.type=En.RouteConfigLoadStart}toString(){return`RouteConfigLoadStart(path: ${this.route.path})`}},eI=class{constructor(e){this.route=e,this.type=En.RouteConfigLoadEnd}toString(){return`RouteConfigLoadEnd(path: ${this.route.path})`}},tI=class{constructor(e){this.snapshot=e,this.type=En.ChildActivationStart}toString(){return`ChildActivationStart(path: '${this.snapshot.routeConfig&&this.snapshot.routeConfig.path||""}')`}},nI=class{constructor(e){this.snapshot=e,this.type=En.ChildActivationEnd}toString(){return`ChildActivationEnd(path: '${this.snapshot.routeConfig&&this.snapshot.routeConfig.path||""}')`}},rI=class{constructor(e){this.snapshot=e,this.type=En.ActivationStart}toString(){return`ActivationStart(path: '${this.snapshot.routeConfig&&this.snapshot.routeConfig.path||""}')`}},iI=class{constructor(e){this.snapshot=e,this.type=En.ActivationEnd}toString(){return`ActivationEnd(path: '${this.snapshot.routeConfig&&this.snapshot.routeConfig.path||""}')`}};var Qd=class{},Zd=class{constructor(e){this.url=e}};var sI=class{constructor(){this.outlet=null,this.route=null,this.injector=null,this.children=new _g,this.attachRef=null}},_g=(()=>{class n{constructor(){this.contexts=new Map}onChildOutletCreated(t,r){let i=this.getOrCreateContext(t);i.outlet=r,this.contexts.set(t,i)}onChildOutletDestroyed(t){let r=this.getContext(t);r&&(r.outlet=null,r.attachRef=null)}onOutletDeactivated(){let t=this.contexts;return this.contexts=new Map,t}onOutletReAttached(t){this.contexts=t}getOrCreateContext(t){let r=this.getContext(t);return r||(r=new sI,this.contexts.set(t,r)),r}getContext(t){return this.contexts.get(t)||null}static{this.\u0275fac=function(r){return new(r||n)}}static{this.\u0275prov=Q({token:n,factory:n.\u0275fac,providedIn:"root"})}}return n})(),fg=class{constructor(e){this._root=e}get root(){return this._root.value}parent(e){let t=this.pathFromRoot(e);return t.length>1?t[t.length-2]:null}children(e){let t=oI(e,this._root);return t?t.children.map(r=>r.value):[]}firstChild(e){let t=oI(e,this._root);return t&&t.children.length>0?t.children[0].value:null}siblings(e){let t=aI(e,this._root);return t.length<2?[]:t[t.length-2].children.map(i=>i.value).filter(i=>i!==e)}pathFromRoot(e){return aI(e,this._root).map(t=>t.value)}};function oI(n,e){if(n===e.value)return e;for(let t of e.children){let r=oI(n,t);if(r)return r}return null}function aI(n,e){if(n===e.value)return[e];for(let t of e.children){let r=aI(n,t);if(r.length)return r.unshift(e),r}return[]}var Mr=class{constructor(e,t){this.value=e,this.children=t}toString(){return`TreeNode(${this.value})`}};function kl(n){let e={};return n&&n.children.forEach(t=>e[t.value.outlet]=t),e}var pg=class extends fg{constructor(e,t){super(e),this.snapshot=t,_I(this,e)}toString(){return this.snapshot.toString()}};function $O(n){let e=Z9(n),t=new gt([new Wa("",{})]),r=new gt({}),i=new gt({}),s=new gt({}),o=new gt(""),a=new Ll(t,r,s,o,i,Ve,n,e.root);return a.snapshot=e.root,new pg(new Mr(a,[]),e)}function Z9(n){let e={},t={},r={},i="",s=new Jd([],e,r,i,t,Ve,n,null,{});return new mg("",new Mr(s,[]))}var Ll=class{constructor(e,t,r,i,s,o,a,c){this.urlSubject=e,this.paramsSubject=t,this.queryParamsSubject=r,this.fragmentSubject=i,this.dataSubject=s,this.outlet=o,this.component=a,this._futureSnapshot=c,this.title=this.dataSubject?.pipe(ke(l=>l[nh]))??Ae(void 0),this.url=e,this.params=t,this.queryParams=r,this.fragment=i,this.data=s}get routeConfig(){return this._futureSnapshot.routeConfig}get root(){return this._routerState.root}get parent(){return this._routerState.parent(this)}get firstChild(){return this._routerState.firstChild(this)}get children(){return this._routerState.children(this)}get pathFromRoot(){return this._routerState.pathFromRoot(this)}get paramMap(){return this._paramMap??=this.params.pipe(ke(e=>Nl(e))),this._paramMap}get queryParamMap(){return this._queryParamMap??=this.queryParams.pipe(ke(e=>Nl(e))),this._queryParamMap}toString(){return this.snapshot?this.snapshot.toString():`Future(${this._futureSnapshot})`}};
8function yI(n,e,t="emptyOnly"){let r,{routeConfig:i}=n;return e!==null&&(t==="always"||i?.path===""||!e.component&&!e.routeConfig?.loadComponent)?r={params:_(_({},e.params),n.params),data:_(_({},e.data),n.data),resolve:_(_(_(_({},n.data),e.data),i?.data),n._resolvedData)}:r={params:_({},n.params),data:_({},n.data),resolve:_(_({},n.data),n._resolvedData??{})},i&&BO(i)&&(r.resolve[nh]=i.title),r}var Jd=class{get title(){return this.data?.[nh]}constructor(e,t,r,i,s,o,a,c,l){this.url=e,this.params=t,this.queryParams=r,this.fragment=i,this.data=s,this.outlet=o,this.component=a,this.routeConfig=c,this._resolve=l}get root(){return this._routerState.root}get parent(){return this._routerState.parent(this)}get firstChild(){return this._routerState.firstChild(this)}get children(){return this._routerState.children(this)}get pathFromRoot(){return this._routerState.pathFromRoot(this)}get paramMap(){return this._paramMap??=Nl(this.params),this._paramMap}get queryParamMap(){return this._queryParamMap??=Nl(this.queryParams),this._queryParamMap}toString(){let e=this.url.map(r=>r.toString()).join("/"),t=this.routeConfig?this.routeConfig.path:"";return`Route(url:'${e}', path:'${t}')`}},mg=class extends fg{constructor(e,t){super(t),this.url=e,_I(this,t)}toString(){return UO(this._root)}};function _I(n,e){e.value._routerState=n,e.children.forEach(t=>_I(n,t))}function UO(n){let e=n.children.length>0?` { ${n.children.map(UO).join(", ")} } `:"";return`${n.value}${e}`}function UE(n){if(n.snapshot){let e=n.snapshot,t=n._futureSnapshot;n.snapshot=t,Qi(e.queryParams,t.queryParams)||n.queryParamsSubject.next(t.queryParams),e.fragment!==t.fragment&&n.fragmentSubject.next(t.fragment),Qi(e.params,t.params)||n.paramsSubject.next(t.params),S9(e.url,t.url)||n.urlSubject.next(t.url),Qi(e.data,t.data)||n.dataSubject.next(t.data)}else n.snapshot=n._futureSnapshot,n.dataSubject.next(n._futureSnapshot.data)}function cI(n,e){let t=Qi(n.params,e.params)&&k9(n.url,e.url),r=!n.parent!=!e.parent;return t&&!r&&(!n.parent||cI(n.parent,e.parent))}function BO(n){return typeof n.title=="string"||n.title===null}var vI=(()=>{class n{constructor(){this.activated=null,this._activatedRoute=null,this.name=Ve,this.activateEvents=new $t,this.deactivateEvents=new $t,this.attachEvents=new $t,this.detachEvents=new $t,this.parentContexts=se(_g),this.location=se(Ti),this.changeDetector=se(Uo),this.environmentInjector=se(mr),this.inputBinder=se(bI,{optional:!0}),this.supportsBindingToComponentInputs=!0}get activatedComponentRef(){return this.activated}ngOnChanges(t){if(t.name){let{firstChange:r,previousValue:i}=t.name;if(r)return;this.isTrackedInParentContexts(i)&&(this.deactivate(),this.parentContexts.onChildOutletDestroyed(i)),this.initializeOutletWithName()}}ngOnDestroy(){this.isTrackedInParentContexts(this.name)&&this.parentContexts.onChildOutletDestroyed(this.name),this.inputBinder?.unsubscribeFromRouteData(this)}isTrackedInParentContexts(t){return this.parentContexts.getContext(t)?.outlet===this}ngOnInit(){this.initializeOutletWithName()}initializeOutletWithName(){if(this.parentContexts.onChildOutletCreated(this.name,this),this.activated)return;let t=this.parentContexts.getContext(this.name);t?.route&&(t.attachRef?this.attach(t.attachRef,t.route):this.activateWith(t.route,t.injector))}get isActivated(){return!!this.activated}get component(){if(!this.activated)throw new we(4012,!1);return this.activated.instance}get activatedRoute(){if(!this.activated)throw new we(4012,!1);return this._activatedRoute}get activatedRouteData(){return this._activatedRoute?this._activatedRoute.snapshot.data:{}}detach(){if(!this.activated)throw new we(4012,!1);this.location.detach();let t=this.activated;return this.activated=null,this._activatedRoute=null,this.detachEvents.emit(t.instance),t}attach(t,r){this.activated=t,this._activatedRoute=r,this.location.insert(t.hostView),this.inputBinder?.bindActivatedRouteToOutletComponent(this),this.attachEvents.emit(t.instance)}deactivate(){if(this.activated){let t=this.component;this.activated.destroy(),this.activated=null,this._activatedRoute=null,this.deactivateEvents.emit(t)}}activateWith(t,r){if(this.isActivated)throw new we(4013,!1);this._activatedRoute=t;let i=this.location,o=t.snapshot.component,a=this.parentContexts.getOrCreateContext(this.name).children,c=new lI(t,a,i.injector);this.activated=i.createComponent(o,{index:i.length,injector:c,environmentInjector:r??this.environmentInjector}),this.changeDetector.markForCheck(),this.inputBinder?.bindActivatedRouteToOutletComponent(this),this.activateEvents.emit(this.activated.instance)}static{this.\u0275fac=function(r){return new(r||n)}}static{this.\u0275dir=Mt({type:n,selectors:[["router-outlet"]],inputs:{name:"name"},outputs:{activateEvents:"activate",deactivateEvents:"deactivate",attachEvents:"attach",detachEvents:"detach"},exportAs:["outlet"],standalone:!0,features:[Ei]})}}return n})(),lI=class n{__ngOutletInjector(e){return new n(this.route,this.childContexts,e)}constructor(e,t,r){this.route=e,this.childContexts=t,this.parent=r}get(e,t){return e===Ll?this.route:e===_g?this.childContexts:this.parent.get(e,t)}},bI=new ue("");function J9(n,e,t){let r=eh(n,e._root,t?t._root:void 0);return new pg(r,e)}function eh(n,e,t){if(t&&n.shouldReuseRoute(e.value,t.value.snapshot)){let r=t.value;r._futureSnapshot=e.value;let i=e8(n,e,t);return new Mr(r,i)}else{if(n.shouldAttach(e.value)){let s=n.retrieve(e.value);if(s!==null){let o=s.route;return o.value._futureSnapshot=e.value,o.children=e.children.map(a=>eh(n,a)),o}}let r=t8(e.value),i=e.children.map(s=>eh(n,s));return new Mr(r,i)}}function e8(n,e,t){return e.children.map(r=>{for(let i of t.children)if(n.shouldReuseRoute(r.value,i.value.snapshot))return eh(n,r,i);return eh(n,r)})}
8function t8(n){return new Ll(new gt(n.url),new gt(n.params),new gt(n.queryParams),new gt(n.fragment),new gt(n.data),n.outlet,n.component,n)}var HO="ngNavigationCancelingError";function qO(n,e){let{redirectTo:t,navigationBehaviorOptions:r}=Ol(e)?{redirectTo:e,navigationBehaviorOptions:void 0}:e,i=zO(!1,Nr.Redirect);return i.url=t,i.navigationBehaviorOptions=r,i}function zO(n,e){let t=new Error(`NavigationCancelingError: ${n||""}`);return t[HO]=!0,t.cancellationCode=e,t}function n8(n){return GO(n)&&Ol(n.url)}function GO(n){return!!n&&n[HO]}var r8=(()=>{class n{static{this.\u0275fac=function(r){return new(r||n)}}static{this.\u0275cmp=xr({type:n,selectors:[["ng-component"]],standalone:!0,features:[Pr],decls:1,vars:0,template:function(r,i){r&1&&yt(0,"router-outlet")},dependencies:[vI],encapsulation:2})}}return n})();function i8(n,e){return n.providers&&!n._injector&&(n._injector=aE(n.providers,e,`Route: ${n.path}`)),n._injector??e}function wI(n){let e=n.children&&n.children.map(wI),t=e?D(_({},n),{children:e}):_({},n);return!t.component&&!t.loadComponent&&(e||t.loadChildren)&&t.outlet&&t.outlet!==Ve&&(t.component=r8),t}function Zi(n){return n.outlet||Ve}function s8(n,e){let t=n.filter(r=>Zi(r)===e);return t.push(...n.filter(r=>Zi(r)!==e)),t}function rh(n){if(!n)return null;if(n.routeConfig?._injector)return n.routeConfig._injector;for(let e=n.parent;e;e=e.parent){let t=e.routeConfig;if(t?._loadedInjector)return t._loadedInjector;if(t?._injector)return t._injector}return null}var o8=(n,e,t,r)=>ke(i=>(new uI(e,i.targetRouterState,i.currentRouterState,t,r).activate(n),i)),uI=class{constructor(e,t,r,i,s){this.routeReuseStrategy=e,this.futureState=t,this.currState=r,this.forwardEvent=i,this.inputBindingEnabled=s}activate(e){let t=this.futureState._root,r=this.currState?this.currState._root:null;this.deactivateChildRoutes(t,r,e),UE(this.futureState.root),this.activateChildRoutes(t,r,e)}deactivateChildRoutes(e,t,r){let i=kl(t);e.children.forEach(s=>{let o=s.value.outlet;this.deactivateRoutes(s,i[o],r),delete i[o]}),Object.values(i).forEach(s=>{this.deactivateRouteAndItsChildren(s,r)})}deactivateRoutes(e,t,r){let i=e.value,s=t?t.value:null;if(i===s)if(i.component){let o=r.getContext(i.outlet);o&&this.deactivateChildRoutes(e,t,o.children)}else this.deactivateChildRoutes(e,t,r);else s&&this.deactivateRouteAndItsChildren(t,r)}deactivateRouteAndItsChildren(e,t){e.value.component&&this.routeReuseStrategy.shouldDetach(e.value.snapshot)?this.detachAndStoreRouteSubtree(e,t):this.deactivateRouteAndOutlet(e,t)}detachAndStoreRouteSubtree(e,t){let r=t.getContext(e.value.outlet),i=r&&e.value.component?r.children:t,s=kl(e);for(let o of Object.values(s))this.deactivateRouteAndItsChildren(o,i);if(r&&r.outlet){let o=r.outlet.detach(),a=r.children.onOutletDeactivated();this.routeReuseStrategy.store(e.value.snapshot,{componentRef:o,route:e,contexts:a})}}deactivateRouteAndOutlet(e,t){let r=t.getContext(e.value.outlet),i=r&&e.value.component?r.children:t,s=kl(e);for(let o of Object.values(s))this.deactivateRouteAndItsChildren(o,i);r&&(r.outlet&&(r.outlet.deactivate(),r.children.onOutletDeactivated()),r.attachRef=null,r.route=null)}activateChildRoutes(e,t,r){let i=kl(t);e.children.forEach(s=>{this.activateRoutes(s,i[s.value.outlet],r),this.forwardEvent(new iI(s.value.snapshot))}),e.children.length&&this.forwardEvent(new nI(e.value.snapshot))}activateRoutes(e,t,r){let i=e.value,s=t?t.value:null;if(UE(i),i===s)if(i.component){let o=r.getOrCreateContext(i.outlet);this.activateChildRoutes(e,t,o.children)}else this.activateChildRoutes(e,t,r);else if(i.component){let o=r.getOrCreateContext(i.outlet);if(this.routeReuseStrategy.shouldAttach(i.snapshot)){let a=this.routeReuseStrategy.retrieve(i.snapshot);this.routeReuseStrategy.store(i.snapshot,null),o.children.onOutletReAttached(a.contexts),o.attachRef=a.componentRef,o.route=a.route.value,o.outlet&&o.outlet.attach(a.componentRef,a.route.value),UE(a.route.value),this.activateChildRoutes(e,null,o.children)}else{let a=rh(i.snapshot);o.attachRef=null,o.route=i,o.injector=a,o.outlet&&o.outlet.activateWith(i,o.injector),this.activateChildRoutes(e,null,o.children)}}else this.activateChildRoutes(e,null,r)}},gg=class{constructor(e){this.path=e,this.route=this.path[this.path.length-1]}},Ml=class{constructor(e,t){this.component=e,this.route=t}};function a8(n,e,t){let r=n._root,i=e?e._root:null;return Hd(r,i,t,[r.value])}
vendor: 4,261 bytes, line 8
8function c8(n){let e=n.routeConfig?n.routeConfig.canActivateChild:null;return!e||e.length===0?null:{node:n,guards:e}}function Vl(n,e){let t=Symbol(),r=e.get(n,t);return r===t?typeof n=="function"&&!b1(n)?n:e.get(n):r}function Hd(n,e,t,r,i={canDeactivateChecks:[],canActivateChecks:[]}){let s=kl(e);return n.children.forEach(o=>{l8(o,s[o.value.outlet],t,r.concat([o.value]),i),delete s[o.value.outlet]}),Object.entries(s).forEach(([o,a])=>Wd(a,t.getContext(o),i)),i}function l8(n,e,t,r,i={canDeactivateChecks:[],canActivateChecks:[]}){let s=n.value,o=e?e.value:null,a=t?t.getContext(n.value.outlet):null;if(o&&s.routeConfig===o.routeConfig){let c=u8(o,s,s.routeConfig.runGuardsAndResolvers);c?i.canActivateChecks.push(new gg(r)):(s.data=o.data,s._resolvedData=o._resolvedData),s.component?Hd(n,e,a?a.children:null,r,i):Hd(n,e,t,r,i),c&&a&&a.outlet&&a.outlet.isActivated&&i.canDeactivateChecks.push(new Ml(a.outlet.component,o))}else o&&Wd(e,a,i),i.canActivateChecks.push(new gg(r)),s.component?Hd(n,null,a?a.children:null,r,i):Hd(n,null,t,r,i);return i}function u8(n,e,t){if(typeof t=="function")return t(n,e);switch(t){case"pathParamsChange":return!Ka(n.url,e.url);case"pathParamsOrQueryParamsChange":return!Ka(n.url,e.url)||!Qi(n.queryParams,e.queryParams);case"always":return!0;case"paramsOrQueryParamsChange":return!cI(n,e)||!Qi(n.queryParams,e.queryParams);case"paramsChange":default:return!cI(n,e)}}function Wd(n,e,t){let r=kl(n),i=n.value;Object.entries(r).forEach(([s,o])=>{i.component?e?Wd(o,e.children.getContext(s),t):Wd(o,null,t):Wd(o,e,t)}),i.component?e&&e.outlet&&e.outlet.isActivated?t.canDeactivateChecks.push(new Ml(e.outlet.component,i)):t.canDeactivateChecks.push(new Ml(null,i)):t.canDeactivateChecks.push(new Ml(null,i))}function ih(n){return typeof n=="function"}function d8(n){return typeof n=="boolean"}function h8(n){return n&&ih(n.canLoad)}function f8(n){return n&&ih(n.canActivate)}function p8(n){return n&&ih(n.canActivateChild)}function m8(n){return n&&ih(n.canDeactivate)}function g8(n){return n&&ih(n.canMatch)}function WO(n){return n instanceof Rs||n?.name==="EmptyError"}var sg=Symbol("INITIAL_VALUE");function Fl(){return Jn(n=>$p(n.map(e=>e.pipe(ks(1),dd(sg)))).pipe(ke(e=>{for(let t of e)if(t!==!0){if(t===sg)return sg;if(t===!1||t instanceof Ho)return t}return!0}),Tr(e=>e!==sg),ks(1)))}function y8(n,e){return an(t=>{let{targetSnapshot:r,currentSnapshot:i,guards:{canActivateChecks:s,canDeactivateChecks:o}}=t;return o.length===0&&s.length===0?Ae(D(_({},t),{guardsResult:!0})):_8(o,r,i,n).pipe(an(a=>a&&d8(a)?v8(r,s,n,e):Ae(a)),ke(a=>D(_({},t),{guardsResult:a})))})}function _8(n,e,t,r){return Rt(n).pipe(an(i=>T8(i.component,i.route,t,e,r)),fi(i=>i!==!0,!0))}function v8(n,e,t,r){return Rt(e).pipe(Ro(i=>ol(w8(i.route.parent,r),b8(i.route,r),I8(n,i.path,t),E8(n,i.route,t))),fi(i=>i!==!0,!0))}function b8(n,e){return n!==null&&e&&e(new rI(n)),Ae(!0)}function w8(n,e){return n!==null&&e&&e(new tI(n)),Ae(!0)}function E8(n,e,t){let r=e.routeConfig?e.routeConfig.canActivate:null;if(!r||r.length===0)return Ae(!0);let i=r.map(s=>Up(()=>{let o=rh(e)??t,a=Vl(s,o),c=f8(a)?a.canActivate(e,n):Fs(o,()=>a(e,n));return zo(c).pipe(fi())}));return Ae(i).pipe(Fl())}function I8(n,e,t){let r=e[e.length-1],s=e.slice(0,e.length-1).reverse().map(o=>c8(o)).filter(o=>o!==null).map(o=>Up(()=>{let a=o.guards.map(c=>{let l=rh(o.node)??t,u=Vl(c,l),d=p8(u)?u.canActivateChild(r,n):Fs(l,()=>u(r,n));return zo(d).pipe(fi())});return Ae(a).pipe(Fl())}));return Ae(s).pipe(Fl())}function T8(n,e,t,r,i){let s=e&&e.routeConfig?e.routeConfig.canDeactivate:null;if(!s||s.length===0)return Ae(!0);let o=s.map(a=>{let c=rh(e)??i,l=Vl(a,c),u=m8(l)?l.canDeactivate(n,e,t,r):Fs(c,()=>l(n,e,t,r));return zo(u).pipe(fi())});return Ae(o).pipe(Fl())}function A8(n,e,t,r){let i=e.canLoad;if(i===void 0||i.length===0)return Ae(!0);let s=i.map(o=>{let a=Vl(o,n),c=h8(a)?a.canLoad(e,t):Fs(n,()=>a(e,t));return zo(c)});return Ae(s).pipe(Fl(),KO(r))}function KO(n){return zb(Qt(e=>{if(Ol(e))throw qO(n,e)}),ke(e=>e===!0))}function C8(n,e,t,r){let i=e.canMatch;if(!i||i.length===0)return Ae(!0);let s=i.map(o=>{let a=Vl(o,n),c=g8(a)?a.canMatch(e,t):Fs(n,()=>a(e,t));return zo(c)});return Ae(s).pipe(Fl(),KO(r))}var th=class{constructor(e){this.segmentGroup=e||null}}
8,yg=class extends Error{constructor(e){super(),this.urlTree=e}};function Rl(n){return sl(new th(n))}function S8(n){return sl(new we(4e3,!1))}function x8(n){return sl(zO(!1,Nr.GuardRejected))}var dI=class{constructor(e,t){this.urlSerializer=e,this.urlTree=t}lineralizeSegments(e,t){let r=[],i=t.root;for(;;){if(r=r.concat(i.segments),i.numberOfChildren===0)return Ae(r);if(i.numberOfChildren>1||!i.children[Ve])return S8(e.redirectTo);i=i.children[Ve]}}applyRedirectCommands(e,t,r){let i=this.applyRedirectCreateUrlTree(t,this.urlSerializer.parse(t),e,r);if(t.startsWith("/"))throw new yg(i);return i}applyRedirectCreateUrlTree(e,t,r,i){let s=this.createSegmentGroup(e,t.root,r,i);return new Ho(s,this.createQueryParams(t.queryParams,this.urlTree.queryParams),t.fragment)}createQueryParams(e,t){let r={};return Object.entries(e).forEach(([i,s])=>{if(typeof s=="string"&&s.startsWith(":")){let a=s.substring(1);r[i]=t[a]}else r[i]=s}),r}createSegmentGroup(e,t,r,i){let s=this.createSegments(e,t.segments,r,i),o={};return Object.entries(t.children).forEach(([a,c])=>{o[a]=this.createSegmentGroup(e,c,r,i)}),new ht(s,o)}createSegments(e,t,r,i){return t.map(s=>s.path.startsWith(":")?this.findPosParam(e,s,i):this.findOrReturn(s,r))}findPosParam(e,t,r){let i=r[t.path.substring(1)];if(!i)throw new we(4001,!1);return i}findOrReturn(e,t){let r=0;for(let i of t){if(i.path===e.path)return t.splice(r),i;r++}return e}},hI={matched:!1,consumedSegments:[],remainingSegments:[],parameters:{},positionalParamSegments:{}};function D8(n,e,t,r,i){let s=EI(n,e,t);return s.matched?(r=i8(e,r),C8(r,e,t,i).pipe(ke(o=>o===!0?s:_({},hI)))):Ae(s)}function EI(n,e,t){if(e.path==="**")return R8(t);if(e.path==="")return e.pathMatch==="full"&&(n.hasChildren()||t.length>0)?_({},hI):{matched:!0,consumedSegments:[],remainingSegments:t,parameters:{},positionalParamSegments:{}};let i=(e.matcher||C9)(t,n,e);if(!i)return _({},hI);let s={};Object.entries(i.posParams??{}).forEach(([a,c])=>{s[a]=c.path});let o=i.consumed.length>0?_(_({},s),i.consumed[i.consumed.length-1].parameters):s;return{matched:!0,consumedSegments:i.consumed,remainingSegments:t.slice(i.consumed.length),parameters:o,positionalParamSegments:i.posParams??{}}}function R8(n){return{matched:!0,parameters:n.length>0?SO(n).parameters:{},consumedSegments:n,remainingSegments:[],positionalParamSegments:{}}}function AO(n,e,t,r){return t.length>0&&M8(n,t,r)?{segmentGroup:new ht(e,P8(r,new ht(t,n.children))),slicedSegments:[]}:t.length===0&&N8(n,t,r)?{segmentGroup:new ht(n.segments,k8(n,t,r,n.children)),slicedSegments:t}:{segmentGroup:new ht(n.segments,n.children),slicedSegments:t}}function k8(n,e,t,r){let i={};for(let s of t)if(vg(n,e,s)&&!r[Zi(s)]){let o=new ht([],{});i[Zi(s)]=o}return _(_({},r),i)}function P8(n,e){let t={};t[Ve]=e;for(let r of n)if(r.path===""&&Zi(r)!==Ve){let i=new ht([],{});t[Zi(r)]=i}return t}function M8(n,e,t){return t.some(r=>vg(n,e,r)&&Zi(r)!==Ve)}function N8(n,e,t){return t.some(r=>vg(n,e,r))}function vg(n,e,t){return(n.hasChildren()||e.length>0)&&t.pathMatch==="full"?!1:t.path===""}function O8(n,e,t,r){return Zi(n)!==r&&(r===Ve||!vg(e,t,n))?!1:EI(e,n,t).matched}function L8(n,e,t){return e.length===0&&!n.children[t]}var fI=class{};function F8(n,e,t,r,i,s,o="emptyOnly"){return new pI(n,e,t,r,i,o,s).recognize()}var V8=31,pI=class{constructor(e,t,r,i,s,o,a){this.injector=e,this.configLoader=t,this.rootComponentType=r,this.config=i,this.urlTree=s,this.paramsInheritanceStrategy=o,this.urlSerializer=a,this.applyRedirects=new dI(this.urlSerializer,this.urlTree),this.absoluteRedirectCount=0,this.allowRedirects=!0}noMatchError(e){return new we(4002,`'${e.segmentGroup}'`)}recognize(){let e=AO(this.urlTree.root,[],[],this.config).segmentGroup;return this.match(e).pipe(ke(t=>{let r=new Jd([],Object.freeze({}),Object.freeze(_({},this.urlTree.queryParams)),this.urlTree.fragment,{},Ve,this.rootComponentType,null,{}),i=new Mr(r,t),s=new mg("",i),o=z9(r,[],this.urlTree.queryParams,this.urlTree.fragment);return o.queryParams=this.urlTree.queryParams,s.url=this.urlSerializer.serialize(o),this.inheritParamsAndData(s._root,null),{state:s,tree:o}}))}match(e){return this.processSegmentGroup(this.injector,this.config,e,Ve).pipe(Do(r=>{if(r instanceof yg)return this.urlTree=r.urlTree,this.match(r.urlTree.root);throw r instanceof th?this.noMatchError(r):r}))}inheritParamsAndData(e,t){let r=e.value,i=yI(r,t,this.paramsInheritanceStrategy);r.params=Object.freeze(i.params),r.data=Object.freeze(i.data),e.children.forEac
8h(s=>this.inheritParamsAndData(s,r))}processSegmentGroup(e,t,r,i){return r.segments.length===0&&r.hasChildren()?this.processChildren(e,t,r):this.processSegment(e,t,r,r.segments,i,!0).pipe(ke(s=>s instanceof Mr?[s]:[]))}processChildren(e,t,r){let i=[];for(let s of Object.keys(r.children))s==="primary"?i.unshift(s):i.push(s);return Rt(i).pipe(Ro(s=>{let o=r.children[s],a=s8(t,s);return this.processSegmentGroup(e,a,o,s)}),iw((s,o)=>(s.push(...o),s)),ko(null),rw(),an(s=>{if(s===null)return Rl(r);let o=YO(s);return j8(o),Ae(o)}))}processSegment(e,t,r,i,s,o){return Rt(t).pipe(Ro(a=>this.processSegmentAgainstRoute(a._injector??e,t,a,r,i,s,o).pipe(Do(c=>{if(c instanceof th)return Ae(null);throw c}))),fi(a=>!!a),Do(a=>{if(WO(a))return L8(r,i,s)?Ae(new fI):Rl(r);throw a}))}processSegmentAgainstRoute(e,t,r,i,s,o,a){return O8(r,i,s,o)?r.redirectTo===void 0?this.matchSegmentAgainstRoute(e,i,r,s,o):this.allowRedirects&&a?this.expandSegmentAgainstRouteUsingRedirect(e,i,t,r,s,o):Rl(i):Rl(i)}expandSegmentAgainstRouteUsingRedirect(e,t,r,i,s,o){let{matched:a,consumedSegments:c,positionalParamSegments:l,remainingSegments:u}=EI(t,i,s);if(!a)return Rl(t);i.redirectTo.startsWith("/")&&(this.absoluteRedirectCount++,this.absoluteRedirectCount>V8&&(this.allowRedirects=!1));let d=this.applyRedirects.applyRedirectCommands(c,i.redirectTo,l);return this.applyRedirects.lineralizeSegments(i,d).pipe(an(f=>this.processSegment(e,r,t,f.concat(u),o,!1)))}matchSegmentAgainstRoute(e,t,r,i,s){let o=D8(t,r,i,e,this.urlSerializer);return r.path==="**"&&(t.children={}),o.pipe(Jn(a=>a.matched?(e=r._injector??e,this.getChildConfig(e,r,i).pipe(Jn(({routes:c})=>{let l=r._loadedInjector??e,{consumedSegments:u,remainingSegments:d,parameters:f}=a,p=new Jd(u,f,Object.freeze(_({},this.urlTree.queryParams)),this.urlTree.fragment,U8(r),Zi(r),r.component??r._loadedComponent??null,r,B8(r)),{segmentGroup:y,slicedSegments:v}=AO(t,u,d,c);if(v.length===0&&y.hasChildren())return this.processChildren(l,c,y).pipe(ke(E=>E===null?null:new Mr(p,E)));if(c.length===0&&v.length===0)return Ae(new Mr(p,[]));let w=Zi(r)===s;return this.processSegment(l,c,y,v,w?Ve:s,!0).pipe(ke(E=>new Mr(p,E instanceof Mr?[E]:[])))}))):Rl(t)))}getChildConfig(e,t,r){return t.children?Ae({routes:t.children,injector:e}):t.loadChildren?t._loadedRoutes!==void 0?Ae({routes:t._loadedRoutes,injector:t._loadedInjector}):A8(e,t,r,this.urlSerializer).pipe(an(i=>i?this.configLoader.loadChildren(e,t).pipe(Qt(s=>{t._loadedRoutes=s.routes,t._loadedInjector=s.injector})):x8(t))):Ae({routes:[],injector:e})}};function j8(n){n.sort((e,t)=>e.value.outlet===Ve?-1:t.value.outlet===Ve?1:e.value.outlet.localeCompare(t.value.outlet))}function $8(n){let e=n.value.routeConfig;return e&&e.path===""}function YO(n){let e=[],t=new Set;for(let r of n){if(!$8(r)){e.push(r);continue}let i=e.find(s=>r.value.routeConfig===s.value.routeConfig);i!==void 0?(i.children.push(...r.children),t.add(i)):e.push(r)}for(let r of t){let i=YO(r.children);e.push(new Mr(r.value,i))}return e.filter(r=>!t.has(r))}function U8(n){return n.data||{}}function B8(n){return n.resolve||{}}function H8(n,e,t,r,i,s){return an(o=>F8(n,e,t,r,o.extractedUrl,i,s).pipe(ke(({state:a,tree:c})=>D(_({},o),{targetSnapshot:a,urlAfterRedirects:c}))))}function q8(n,e){return an(t=>{let{targetSnapshot:r,guards:{canActivateChecks:i}}=t;if(!i.length)return Ae(t);let s=new Set(i.map(c=>c.route)),o=new Set;for(let c of s)if(!o.has(c))for(let l of XO(c))o.add(l);let a=0;return Rt(o).pipe(Ro(c=>s.has(c)?z8(c,r,n,e):(c.data=yI(c,c.parent,n).resolve,Ae(void 0))),Qt(()=>a++),al(1),an(c=>a===o.size?Ae(t):Zn))})}function XO(n){let e=n.children.map(t=>XO(t)).flat();return[n,...e]}function z8(n,e,t,r){let i=n.routeConfig,s=n._resolve;return i?.title!==void 0&&!BO(i)&&(s[nh]=i.title),G8(s,n,e,r).pipe(ke(o=>(n._resolvedData=o,n.data=yI(n,n.parent,t).resolve,null)))}function G8(n,e,t,r){let i=qE(n);if(i.length===0)return Ae({});let s={};return Rt(i).pipe(an(o=>W8(n[o],e,t,r).pipe(fi(),Qt(a=>{s[o]=a}))),al(1),ud(s),Do(o=>WO(o)?Zn:sl(o)))}function W8(n,e,t,r){let i=rh(e)??r,s=Vl(n,i),o=s.resolve?s.resolve(e,t):Fs(i,()=>s(e,t));return zo(o)}function BE(n){return Jn(e=>{let t=n(e);return t?Rt(t).pipe(ke(()=>e)):Ae(e)})}var QO=(()=>{class n{buildTitle(t){let r,i=t.root;for(;i!==void 0;)r=this.getResolvedTitleForRoute(i)??r,i=i.children.find(s=>s.outlet===Ve);return r}getResolvedTitleForRoute(t){return t.data[nh]}static{this.\u0275fac=function(r){return new(r||n)}}static{this.\u0275prov=Q({token:n,factory:()=>se(K8),providedIn:"root"})}}return n})(),K8=(()=>{class n extends QO{constructor(t){super(),this.title=t}updateTitle(t){let r=this.buildTitle(t);r!==void 0&&this.title.setTitle(r)}static{this.\u0275fac=function(r){return new(r||n)(Y(vO))}}static{this.\u0275prov=Q({token:n,factory:n.\u0275fac,providedIn:"root"})}}return n})(),II=new ue("",{providedIn:"root",factory:()=>({})}),TI=new ue(""),Y8=(()=>{class n{constructor(){this.componentLoaders=new WeakMap,this.childrenLoaders=new WeakMap,this.compiler=se(pE)}loadComponent(t){if(this.componentLoaders.get(t))return this.componentLoaders.get(t);if(t._loadedComponent)return Ae(t._loadedComponent);this.onLoadStartListener&&this.onLoadStartListener(t);let r=zo(t.loadComponent()).pipe(ke(ZO),Qt(s=>{this.onLoadEndListener&&this.onLoadEndListener(t),t._loadedComponent=s}),Sa(()=>{this.componentLoaders.delete(t)})),i=new tl(r,()=>new mt).pipe(el());return this.componentLoaders.set(t,i),i}loadChildren(t,r){if(this.childrenLoaders.get(r))return this.childrenLoaders.get(r);if(r._loadedRoutes)return Ae({routes:r._loadedRoutes,injector:r._loadedInjector});this.onLoadStartListener&&this.onLoadStartListener(r);let s=X8(r,this.compiler,t,this.onLoadEndListener).pipe(Sa(()=>{this.childrenLoaders.delete(r)}
8)),o=new tl(s,()=>new mt).pipe(el());return this.childrenLoaders.set(r,o),o}static{this.\u0275fac=function(r){return new(r||n)}}static{this.\u0275prov=Q({token:n,factory:n.\u0275fac,providedIn:"root"})}}return n})();function X8(n,e,t,r){return zo(n.loadChildren()).pipe(ke(ZO),an(i=>i instanceof Id||Array.isArray(i)?Ae(i):Rt(e.compileModuleAsync(i))),ke(i=>{r&&r(n);let s,o,a=!1;return Array.isArray(i)?(o=i,a=!0):(s=i.create(t).injector,o=s.get(TI,[],{optional:!0,self:!0}).flat()),{routes:o.map(wI),injector:s}}))}function Q8(n){return n&&typeof n=="object"&&"default"in n}function ZO(n){return Q8(n)?n.default:n}var AI=(()=>{class n{static{this.\u0275fac=function(r){return new(r||n)}}static{this.\u0275prov=Q({token:n,factory:()=>se(Z8),providedIn:"root"})}}return n})(),Z8=(()=>{class n{shouldProcessUrl(t){return!0}extract(t){return t}merge(t,r){return t}static{this.\u0275fac=function(r){return new(r||n)}}static{this.\u0275prov=Q({token:n,factory:n.\u0275fac,providedIn:"root"})}}return n})(),J8=new ue("");var eK=(()=>{class n{get hasRequestedNavigation(){return this.navigationId!==0}constructor(){this.currentNavigation=null,this.currentTransition=null,this.lastSuccessfulNavigation=null,this.events=new mt,this.transitionAbortSubject=new mt,this.configLoader=se(Y8),this.environmentInjector=se(mr),this.urlSerializer=se(gI),this.rootContexts=se(_g),this.location=se(Nd),this.inputBindingEnabled=se(bI,{optional:!0})!==null,this.titleStrategy=se(QO),this.options=se(II,{optional:!0})||{},this.paramsInheritanceStrategy=this.options.paramsInheritanceStrategy||"emptyOnly",this.urlHandlingStrategy=se(AI),this.createViewTransition=se(J8,{optional:!0}),this.navigationId=0,this.afterPreactivation=()=>Ae(void 0),this.rootComponentType=null;let t=i=>this.events.next(new JE(i)),r=i=>this.events.next(new eI(i));this.configLoader.onLoadEndListener=r,this.configLoader.onLoadStartListener=t}complete(){this.transitions?.complete()}handleNavigationRequest(t){let r=++this.navigationId;this.transitions?.next(D(_(_({},this.transitions.value),t),{id:r}))}setupNavigations(t,r,i){return this.transitions=new gt({id:0,currentUrlTree:r,currentRawUrl:r,extractedUrl:this.urlHandlingStrategy.extract(r),urlAfterRedirects:this.urlHandlingStrategy.extract(r),rawUrl:r,extras:{},resolve:null,reject:null,promise:Promise.resolve(!0),source:Gd,restoredState:null,currentSnapshot:i.snapshot,targetSnapshot:null,currentRouterState:i,targetRouterState:null,guards:{canActivateChecks:[],canDeactivateChecks:[]},guardsResult:null}),this.transitions.pipe(Tr(s=>s.id!==0),ke(s=>D(_({},s),{extractedUrl:this.urlHandlingStrategy.extract(s.rawUrl)})),Jn(s=>{let o=!1,a=!1;return Ae(s).pipe(Jn(c=>{if(this.navigationId>s.id)return this.cancelNavigationTransition(s,"",Nr.SupersededByNewNavigation),Zn;this.currentTransition=s,this.currentNavigation={id:c.id,initialUrl:c.rawUrl,extractedUrl:c.extractedUrl,trigger:c.source,extras:c.extras,previousNavigation:this.lastSuccessfulNavigation?D(_({},this.lastSuccessfulNavigation),{previousNavigation:null}):null};let l=!t.navigated||this.isUpdatingInternalState()||this.isUpdatedBrowserUrl(),u=c.extras.onSameUrlNavigation??t.onSameUrlNavigation;if(!l&&u!=="reload"){let d="";return this.events.next(new Xa(c.id,this.urlSerializer.serialize(c.rawUrl),d,KE.IgnoredSameUrlNavigation)),c.resolve(null),Zn}if(this.urlHandlingStrategy.shouldProcessUrl(c.rawUrl))return Ae(c).pipe(Jn(d=>{let f=this.transitions?.getValue();return this.events.next(new Yd(d.id,this.urlSerializer.serialize(d.extractedUrl),d.source,d.restoredState)),f!==this.transitions?.getValue()?Zn:Promise.resolve(d)}),H8(this.environmentInjector,this.configLoader,this.rootComponentType,t.config,this.urlSerializer,this.paramsInheritanceStrategy),Qt(d=>{s.targetSnapshot=d.targetSnapshot,s.urlAfterRedirects=d.urlAfterRedirects,this.currentNavigation=D(_({},this.currentNavigation),{finalUrl:d.urlAfterRedirects});let f=new hg(d.id,this.urlSerializer.serialize(d.extractedUrl),this.urlSerializer.serialize(d.urlAfterRedirects),d.targetSnapshot);this.events.next(f)}));if(l&&this.urlHandlingStrategy.shouldProcessUrl(c.currentRawUrl)){let{id:d,extractedUrl:f,source:p,restoredState:y,extras:v}=c,w=new Yd(d,this.urlSerializer.serialize(f),p,y);this.events.next(w);let E=$O(this.rootComponentType).snapshot;return this.currentTransition=s=D(_({},c),{targetSnapshot:E,urlAfterRedirects:f,extras:D(_({},v),{skipLocationChange:!1,replaceUrl:!1})}),this.currentNavigation.finalUrl=f,Ae(s)}else{let d="";return this.events.next(new Xa(c.id,this.urlSerializer.serialize(c.extractedUrl),d,KE.IgnoredByUrlHandlingStrategy)),c.resolve(null),Zn}}),Qt(c=>{let l=new YE(c.id,this.urlSerializer.serialize(c.extractedUrl),this.urlSerializer.serialize(c.urlAfterRedirects),c.targetSnapshot);this.events.next(l)}
8),ke(c=>(this.currentTransition=s=D(_({},c),{guards:a8(c.targetSnapshot,c.currentSnapshot,this.rootContexts)}),s)),y8(this.environmentInjector,c=>this.events.next(c)),Qt(c=>{if(s.guardsResult=c.guardsResult,Ol(c.guardsResult))throw qO(this.urlSerializer,c.guardsResult);let l=new XE(c.id,this.urlSerializer.serialize(c.extractedUrl),this.urlSerializer.serialize(c.urlAfterRedirects),c.targetSnapshot,!!c.guardsResult);this.events.next(l)}),Tr(c=>c.guardsResult?!0:(this.cancelNavigationTransition(c,"",Nr.GuardRejected),!1)),BE(c=>{if(c.guards.canActivateChecks.length)return Ae(c).pipe(Qt(l=>{let u=new QE(l.id,this.urlSerializer.serialize(l.extractedUrl),this.urlSerializer.serialize(l.urlAfterRedirects),l.targetSnapshot);this.events.next(u)}),Jn(l=>{let u=!1;return Ae(l).pipe(q8(this.paramsInheritanceStrategy,this.environmentInjector),Qt({next:()=>u=!0,complete:()=>{u||this.cancelNavigationTransition(l,"",Nr.NoDataFromResolver)}}))}),Qt(l=>{let u=new ZE(l.id,this.urlSerializer.serialize(l.extractedUrl),this.urlSerializer.serialize(l.urlAfterRedirects),l.targetSnapshot);this.events.next(u)}))}),BE(c=>{let l=u=>{let d=[];u.routeConfig?.loadComponent&&!u.routeConfig._loadedComponent&&d.push(this.configLoader.loadComponent(u.routeConfig).pipe(Qt(f=>{u.component=f}),ke(()=>{})));for(let f of u.children)d.push(...l(f));return d};return $p(l(c.targetSnapshot.root)).pipe(ko(null),ks(1))}),BE(()=>this.afterPreactivation()),Jn(()=>{let{currentSnapshot:c,targetSnapshot:l}=s,u=this.createViewTransition?.(this.environmentInjector,c.root,l.root);return u?Rt(u).pipe(ke(()=>s)):Ae(s)}),ke(c=>{let l=J9(t.routeReuseStrategy,c.targetSnapshot,c.currentRouterState);return this.currentTransition=s=D(_({},c),{targetRouterState:l}),this.currentNavigation.targetRouterState=l,s}),Qt(()=>{this.events.next(new Qd)}),o8(this.rootContexts,t.routeReuseStrategy,c=>this.events.next(c),this.inputBindingEnabled),ks(1),Qt({next:c=>{o=!0,this.lastSuccessfulNavigation=this.currentNavigation,this.events.next(new Ya(c.id,this.urlSerializer.serialize(c.extractedUrl),this.urlSerializer.serialize(c.urlAfterRedirects))),this.titleStrategy?.updateTitle(c.targetRouterState.snapshot),c.resolve(!0)},complete:()=>{o=!0}}),pi(this.transitionAbortSubject.pipe(Qt(c=>{throw c}))),Sa(()=>{!o&&!a&&this.cancelNavigationTransition(s,"",Nr.SupersededByNewNavigation),this.currentTransition?.id===s.id&&(this.currentNavigation=null,this.currentTransition=null)}),Do(c=>{if(a=!0,GO(c))this.events.next(new qo(s.id,this.urlSerializer.serialize(s.extractedUrl),c.message,c.cancellationCode)),n8(c)?this.events.next(new Zd(c.url)):s.resolve(!1);else{this.events.next(new Xd(s.id,this.urlSerializer.serialize(s.extractedUrl),c,s.targetSnapshot??void 0));try{s.resolve(t.errorHandler(c))}catch(l){this.options.resolveNavigationPromiseOnError?s.resolve(!1):s.reject(l)}}return Zn}))}))}cancelNavigationTransition(t,r,i){let s=new qo(t.id,this.urlSerializer.serialize(t.extractedUrl),r,i);this.events.next(s),t.resolve(!1)}isUpdatingInternalState(){return this.currentTransition?.extractedUrl.toString()!==this.currentTransition?.currentUrlTree.toString()}isUpdatedBrowserUrl(){return this.urlHandlingStrategy.extract(this.urlSerializer.parse(this.location.path(!0))).toString()!==this.currentTransition?.extractedUrl.toString()&&!this.currentTransition?.extras.skipLocationChange}static{this.\u0275fac=function(r){return new(r||n)}}static{this.\u0275prov=Q({token:n,factory:n.\u0275fac,providedIn:"root"})}}return n})();function tK(n){return n!==Gd}var nK=(()=>{class n{static{this.\u0275fac=function(r){return new(r||n)}}static{this.\u0275prov=Q({token:n,factory:()=>se(rK),providedIn:"root"})}}return n})(),mI=class{shouldDetach(e){return!1}store(e,t){}shouldAttach(e){return!1}retrieve(e){return null}shouldReuseRoute(e,t){return e.routeConfig===t.routeConfig}},rK=(()=>{class n extends mI{static{this.\u0275fac=(()=>{let t;return function(i){return(t||(t=zr(n)))(i||n)}})()}static{this.\u0275prov=Q({token:n,factory:n.\u0275fac,providedIn:"root"})}}return n})(),JO=(()=>{class n{static{this.\u0275fac=function(r){return new(r||n)}}static{this.\u0275prov=Q({token:n,factory:()=>se(iK),providedIn:"root"})}}return n})(),iK=(()=>{class n extends JO{constructor(){super(...arguments),this.location=se(Nd),this.urlSerializer
8=se(gI),this.options=se(II,{optional:!0})||{},this.canceledNavigationResolution=this.options.canceledNavigationResolution||"replace",this.urlHandlingStrategy=se(AI),this.urlUpdateStrategy=this.options.urlUpdateStrategy||"deferred",this.currentUrlTree=new Ho,this.rawUrlTree=this.currentUrlTree,this.currentPageId=0,this.lastSuccessfulId=-1,this.routerState=$O(null),this.stateMemento=this.createStateMemento()}getCurrentUrlTree(){return this.currentUrlTree}getRawUrlTree(){return this.rawUrlTree}restoredState(){return this.location.getState()}get browserPageId(){return this.canceledNavigationResolution!=="computed"?this.currentPageId:this.restoredState()?.\u0275routerPageId??this.currentPageId}getRouterState(){return this.routerState}createStateMemento(){return{rawUrlTree:this.rawUrlTree,currentUrlTree:this.currentUrlTree,routerState:this.routerState}}registerNonRouterCurrentEntryChangeListener(t){return this.location.subscribe(r=>{r.type==="popstate"&&t(r.url,r.state)})}handleRouterEvent(t,r){if(t instanceof Yd)this.stateMemento=this.createStateMemento();else if(t instanceof Xa)this.rawUrlTree=r.initialUrl;else if(t instanceof hg){if(this.urlUpdateStrategy==="eager"&&!r.extras.skipLocationChange){let i=this.urlHandlingStrategy.merge(r.finalUrl,r.initialUrl);this.setBrowserUrl(i,r)}}else t instanceof Qd?(this.currentUrlTree=r.finalUrl,this.rawUrlTree=this.urlHandlingStrategy.merge(r.finalUrl,r.initialUrl),this.routerState=r.targetRouterState,this.urlUpdateStrategy==="deferred"&&(r.extras.skipLocationChange||this.setBrowserUrl(this.rawUrlTree,r))):t instanceof qo&&(t.code===Nr.GuardRejected||t.code===Nr.NoDataFromResolver)?this.restoreHistory(r):t instanceof Xd?this.restoreHistory(r,!0):t instanceof Ya&&(this.lastSuccessfulId=t.id,this.currentPageId=this.browserPageId)}setBrowserUrl(t,r){let i=this.urlSerializer.serialize(t);if(this.location.isCurrentPathEqualTo(i)||r.extras.replaceUrl){let s=this.browserPageId,o=_(_({},r.extras.state),this.generateNgRouterState(r.id,s));this.location.replaceState(i,"",o)}else{let s=_(_({},r.extras.state),this.generateNgRouterState(r.id,this.browserPageId+1));this.location.go(i,"",s)}}restoreHistory(t,r=!1){if(this.canceledNavigationResolution==="computed"){let i=this.browserPageId,s=this.currentPageId-i;s!==0?this.location.historyGo(s):this.currentUrlTree===t.finalUrl&&s===0&&(this.resetState(t),this.resetUrlToCurrentUrlTree())}else this.canceledNavigationResolution==="replace"&&(r&&this.resetState(t),this.resetUrlToCurrentUrlTree())}resetState(t){this.routerState=this.stateMemento.routerState,this.currentUrlTree=this.stateMemento.currentUrlTree,this.rawUrlTree=this.urlHandlingStrategy.merge(this.currentUrlTree,t.finalUrl??this.rawUrlTree)}resetUrlToCurrentUrlTree(){this.location.replaceState(this.urlSerializer.serialize(this.rawUrlTree),"",this.generateNgRouterState(this.lastSuccessfulId,this.currentPageId))}generateNgRouterState(t,r){return this.canceledNavigationResolution==="computed"?{navigationId:t,\u0275routerPageId:r}:{navigationId:t}}static{this.\u0275fac=(()=>{let t;return function(i){return(t||(t=zr(n)))(i||n)}})()}static{this.\u0275prov=Q({token:n,factory:n.\u0275fac,providedIn:"root"})}}return n})(),qd=function(n){return n[n.COMPLETE=0]="COMPLETE",n[n.FAILED=1]="FAILED",n[n.REDIRECTING=2]="REDIRECTING",n}(qd||{});function sK(n,e){n.events.pipe(Tr(t=>t instanceof Ya||t instanceof qo||t instanceof Xd||t instanceof Xa),ke(t=>t instanceof Ya||t instanceof Xa?qd.COMPLETE:(t instanceof qo?t.code===Nr.Redirect||t.code===Nr.SupersededByNewNavigation:!1)?qd.REDIRECTING:qd.FAILED),Tr(t=>t!==qd.REDIRECTING),ks(1)).subscribe(()=>{e()})}function oK(n){throw n}var aK={paths:"exact",fragment:"ignored",matrixParams:"ignored",queryParams:"exact"},cK={paths:"subset",fragment:"ignored",matrixParams:"ignored",queryParams:"subset"},bg=(()=>{class n{get currentUrlTree(){return this.stateManager.getCurrentUrlTree()}get rawUrlTree(){return this.stateManager.getRawUrlTree()}get events(){return this._events}get routerState(){return this.stateManager.getRouterState()}constructor(){this.disposed=!1,this.isNgZoneEnabled=!1,this.console=se($m),this.stateManager=se(JO),this.options=se(II,{optional:!0})||{},this.pendingTasks=se(Tl),this.urlUpdateStrategy=this.options.urlUpdateStrategy||"deferred",this.navigationTransitions=se(eK),this.urlSerializer
8=se(gI),this.location=se(Nd),this.urlHandlingStrategy=se(AI),this._events=new mt,this.errorHandler=this.options.errorHandler||oK,this.navigated=!1,this.routeReuseStrategy=se(nK),this.onSameUrlNavigation=this.options.onSameUrlNavigation||"ignore",this.config=se(TI,{optional:!0})?.flat()??[],this.componentInputBindingEnabled=!!se(bI,{optional:!0}),this.eventsSubscription=new zt,this.isNgZoneEnabled=se(st)instanceof st&&st.isInAngularZone(),this.resetConfig(this.config),this.navigationTransitions.setupNavigations(this,this.currentUrlTree,this.routerState).subscribe({error:t=>{this.console.warn(t)}}),this.subscribeToNavigationEvents()}subscribeToNavigationEvents(){let t=this.navigationTransitions.events.subscribe(r=>{try{let i=this.navigationTransitions.currentTransition,s=this.navigationTransitions.currentNavigation;if(i!==null&&s!==null){if(this.stateManager.handleRouterEvent(r,s),r instanceof qo&&r.code!==Nr.Redirect&&r.code!==Nr.SupersededByNewNavigation)this.navigated=!0;else if(r instanceof Ya)this.navigated=!0;else if(r instanceof Zd){let o=this.urlHandlingStrategy.merge(r.url,i.currentRawUrl),a={info:i.extras.info,skipLocationChange:i.extras.skipLocationChange,replaceUrl:this.urlUpdateStrategy==="eager"||tK(i.source)};this.scheduleNavigation(o,Gd,null,a,{resolve:i.resolve,reject:i.reject,promise:i.promise})}}uK(r)&&this._events.next(r)}catch(i){this.navigationTransitions.transitionAbortSubject.next(i)}});this.eventsSubscription.add(t)}resetRootComponentType(t){this.routerState.root.component=t,this.navigationTransitions.rootComponentType=t}initialNavigation(){this.setUpLocationChangeListener(),this.navigationTransitions.hasRequestedNavigation||this.navigateToSyncWithBrowser(this.location.path(!0),Gd,this.stateManager.restoredState())}setUpLocationChangeListener(){this.nonRouterCurrentEntryChangeSubscription??=this.stateManager.registerNonRouterCurrentEntryChangeListener((t,r)=>{setTimeout(()=>{this.navigateToSyncWithBrowser(t,"popstate",r)},0)})}navigateToSyncWithBrowser(t,r,i){let s={replaceUrl:!0},o=i?.navigationId?i:null;if(i){let c=_({},i);delete c.navigationId,delete c.\u0275routerPageId,Object.keys(c).length!==0&&(s.state=c)}let a=this.parseUrl(t);this.scheduleNavigation(a,r,o,s)}get url(){return this.serializeUrl(this.currentUrlTree)}getCurrentNavigation(){return this.navigationTransitions.currentNavigation}get lastSuccessfulNavigation(){return this.navigationTransitions.lastSuccessfulNavigation}resetConfig(t){this.config=t.map(wI),this.navigated=!1}ngOnDestroy(){this.dispose()}dispose(){this.navigationTransitions.complete(),this.nonRouterCurrentEntryChangeSubscription&&(this.nonRouterCurrentEntryChangeSubscription.unsubscribe(),this.nonRouterCurrentEntryChangeSubscription=void 0),this.disposed=!0,this.eventsSubscription.unsubscribe()}createUrlTree(t,r={}){let{relativeTo:i,queryParams:s,fragment:o,queryParamsHandling:a,preserveFragment:c}=r,l=c?this.currentUrlTree.fragment:o,u=null;switch(a){case"merge":u=_(_({},this.currentUrlTree.queryParams),s);break;case"preserve":u=this.currentUrlTree.queryParams;break;default:u=s||null}u!==null&&(u=this.removeEmptyProps(u));let d;try{let f=i?i.snapshot:this.routerState.snapshot.root;d=LO(f)}catch{(typeof t[0]!="string"||!t[0].startsWith("/"))&&(t=[]),d=this.currentUrlTree.root}return FO(d,t,u,l??null)}navigateByUrl(t,r={skipLocationChange:!1}){let i=Ol(t)?t:this.parseUrl(t),s=this.urlHandlingStrategy.merge(i,this.rawUrlTree);return this.scheduleNavigation(s,Gd,null,r)}navigate(t,r={skipLocationChange:!1}){return lK(t),this.navigateByUrl(this.createUrlTree(t,r),r)}serializeUrl(t){return this.urlSerializer.serialize(t)}parseUrl(t){try{return this.urlSerializer.parse(t)}catch{return this.urlSerializer.parse("/")}}isActive(t,r){let i;if(r===!0?i=_({},aK):r===!1?i=_({},cK):i=r,Ol(t))return wO(this.currentUrlTree,t,i);let s=this.parseUrl(t);return wO(this.currentUrlTree,s,i)}removeEmptyProps(t){return Object.entries(t).reduce((r,[i,s])=>(s!=null&&(r[i]=s),r),{})}scheduleNavigation(t,r,i,s,o){if(this.disposed)return Promise.resolve(!1);let a,c,l;o?(a=o.resolve,c=o.reject,l=o.promise):l=new Promise((d,f)=>{a=d,c=f});let u=this.pendingTasks.add();return sK(this,()=>{queueMicrotask(()=>this.pendingTasks.remove(u))}),this.navigationTransitions.handleNavigationRequest({source:r,restoredState:i,currentUrlTree:this.currentUrlTree,currentRawUrl:this.currentUrlTree,rawUrl:t,extras:s,resolve:a,reject:c,promise:l,currentSnapshot:this.routerState.snapshot,currentRouterState:this.routerState}),l.catch(d=>Promise.reject(d))}static{this.\u0275fac=function(r){return new(r||n)}}static{this.\u0275prov=Q({token:n,factory:n.\u0275fac,providedIn:"root"})}}return n})();function lK(n){for(let e=0;e<n.length;e++)if(n[e]==null)throw new we(4008,!1)}function uK(n){return!(n instanceof Qd)&&!(n instanceof Zd)}var dK=new ue("");function eL(n,...e){return Nn([{provide:TI,multi:!0,useValue:n},[],{provide:Ll,useFactory:hK,deps:[bg]},{provide:Um,multi:!0,useFactory:fK},e.map(t=>t.\u0275providers)])}function hK(n){return n.routerState.root}function fK(){let n=se(On);return e=>{let t=n.get(Cl);if(e!==t.components[0])return;let r=n.get(bg),i=n.get(pK);n.get(mK)===1&&r.initialNavigation(),n.get(gK,null,Ye.Optional)?.setUpPreloading(),n.get(dK,null,Ye.Optional)?.init(),r.resetRootComponentType(t.componentTypes[0]),i.closed||(i.next(),i.complete(),i.unsubscribe())}}var pK=new ue("",{factory:()=>new mt}),mK=new ue("",{providedIn:"root",factory:()=>1});var gK=new ue("");var nL=function(n){let e=[],t=0;for(let r=0;r<n.length;r++){let i=n.charCodeAt(r);i<128?e[t++]=i:i<2048?(e[t++]=i>>6|192,e[t++]=i&63|128):(i&64512)===55296&&r+1<n.length&&(n.charCodeAt(r+1)&64512)===56320?(i=65536+((i&1023)<<10)+(n.charCodeAt(++r)&1023),e[t++]=i>>18|240,e[t++]=i>>12&63|128,e[t++]=i>>6&63|128,e[t++]=i&63|128):(e[t++]=i>>12|224,e[t++]=i>>6&63|128,e[t++]=i&63|128)}return e},_K=function(n){let e=[],t=0,r=0;for(;t<n.length;){let i=n[t++];if(i<128)e[r++]=String.fromCharCode(i);else if(i>191&&i<224){let s=n[t++];e[r++]=String.fromCharCode((i&31)<<6|s&63)}else if(i>239&&i<365){let s=n[t++],o=n[t++],a=n[t++],c=((i&7)<<18|(s&63)<<12|(o&63)<<6|a&63)-65536;e[r++]=String.fromCharCode(55296+(c>>10)),e[r++]=String.fromCharCode(56320+(c&1023))}else{let s=n[t++],o=n[t++];e[r++]=String.fromCharCode((i&15)<<12|(s&63)<<6|o&63)}}return e.join("")},rL={byteToCharMap_:null,charToByteMap_:null,byteToCharMapWebSafe_:null,charToByteMapWebSafe_:null,ENCODED_VALS_BASE:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",get ENCODED_VALS(){return this.ENCODED_VALS_BASE+"+/="},get ENCODED_VALS_WEBSAFE(){return this.ENCODED_VALS_BASE+"-_."},HAS_NATIVE_SUPPORT:typeof atob=="function",encodeByteArray(n,e){if(!Array.isArray(n))throw Error("encodeByteArray takes an array as a parameter");this.init_();let t=e?this.byteToCharMapWebSafe_:this.byteToCharMap_,r=[];for(let i=0;i<n.length;i+=3){let s=n[i],o=i+1<n.length,a=o?n[i+1]:0,c=i+2<n.length,l=c?n[i+2]:0,u=s>>2,d=(s&3)<<4|a>>4,f=(a&15)<<2|l>>6,p=l&63;c||(p=64,o||(f=64)),r.push(t[u],t[d],t[f],t[p])}return r.join("")},encodeString(n,e){return this.HAS_NATIVE_SUPPORT&&!e?btoa(n):this.encodeByteArray(nL(n),e)},decodeString(n,e){return this.HAS_NATIVE_SUPPORT&&!e?atob(n):_K(this.decodeStringToByteArray(n,e))},decodeStringToByteArray(n,e){this.init_();let t=e?this.charToByteMapWebSafe_:this.charToByteMap_,r=[];for(let i=0;i<n.length;){let s=t[n.charAt(i++)],a=i<n.length?t[n.charAt(i)]:0;++i;let l=i<n.length?t[n.charAt(i)]:64;++i;let d=i<n.length?t[n.charAt(i)]:64;if(++i,s==null||a==null||l==null||d==null)throw new SI;let f=s<<2|a>>4;if(r.push(f),l!==64){let p=a<<4&240|l>>2;if(r.push(p),d!==64){let y=l<<6&192|d;r.push(y)}}}return r},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let n=0;n<this.ENCODED_VALS.length;n++)this.byteToCharMap_[n]=this.ENCODED_VALS.charAt(n),this.charToByteMap_[this.byteToCharMap_[n]]=n,this.byteToCharMapWebSafe_[n]=this.ENCODED_VALS_WEBSAFE.charAt(n),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[n]]=n,n>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(n)]=n,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(n)]=n)}}}
vendor: 16,186 bytes, line 8
8,SI=class extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}},vK=function(n){let e=nL(n);return rL.encodeByteArray(e,!0)},sh=function(n){return vK(n).replace(/\./g,"")},DI=function(n){try{return rL.decodeString(n,!0)}catch(e){console.error("base64Decode failed: ",e)}return null};function bK(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("Unable to locate global object.")}var wK=()=>bK().__FIREBASE_DEFAULTS__,EK=()=>{if(typeof process>"u"||typeof process.env>"u")return;let n=process.env.__FIREBASE_DEFAULTS__;if(n)return JSON.parse(n)},IK=()=>{if(typeof document>"u")return;let n;try{n=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch{return}let e=n&&DI(n[1]);return e&&JSON.parse(e)},Eg=()=>{try{return wK()||EK()||IK()}catch(n){console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${n}`);return}},RI=n=>{var e,t;return(t=(e=Eg())===null||e===void 0?void 0:e.emulatorHosts)===null||t===void 0?void 0:t[n]},jl=n=>{let e=RI(n);if(!e)return;let t=e.lastIndexOf(":");if(t<=0||t+1===e.length)throw new Error(`Invalid host ${e} with no separate hostname and port!`);let r=parseInt(e.substring(t+1),10);return e[0]==="["?[e.substring(1,t-1),r]:[e.substring(0,t),r]},kI=()=>{var n;return(n=Eg())===null||n===void 0?void 0:n.config},PI=n=>{var e;return(e=Eg())===null||e===void 0?void 0:e[`_${n}`]};var wg=class{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}wrapCallback(e){return(t,r)=>{t?this.reject(t):this.resolve(r),typeof e=="function"&&(this.promise.catch(()=>{}),e.length===1?e(t):e(t,r))}}};function Ig(n,e){if(n.uid)throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.');let t={alg:"none",type:"JWT"},r=e||"demo-project",i=n.iat||0,s=n.sub||n.user_id;if(!s)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");let o=Object.assign({iss:`https://securetoken.google.com/${r}`,aud:r,iat:i,exp:i+3600,auth_time:i,sub:s,user_id:s,firebase:{sign_in_provider:"custom",identities:{}}},n);return[sh(JSON.stringify(t)),sh(JSON.stringify(o)),""].join(".")}function pn(){return typeof navigator<"u"&&typeof navigator.userAgent=="string"?navigator.userAgent:""}function iL(){return typeof window<"u"&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(pn())}function TK(){var n;let e=(n=Eg())===null||n===void 0?void 0:n.forceEnvironment;if(e==="node")return!0;if(e==="browser")return!1;try{return Object.prototype.toString.call(global.process)==="[object process]"}catch{return!1}}function sL(){return typeof navigator<"u"&&navigator.userAgent==="Cloudflare-Workers"}function oL(){let n=typeof chrome=="object"?chrome.runtime:typeof browser=="object"?browser.runtime:void 0;return typeof n=="object"&&n.id!==void 0}function aL(){return typeof navigator=="object"&&navigator.product==="ReactNative"}function cL(){let n=pn();return n.indexOf("MSIE ")>=0||n.indexOf("Trident/")>=0}function lL(){return!TK()&&!!navigator.userAgent&&navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")}function MI(){try{return typeof indexedDB=="object"}catch{return!1}}function uL(){return new Promise((n,e)=>{try{let t=!0,r="validate-browser-context-for-indexeddb-analytics-module",i=self.indexedDB.open(r);i.onsuccess=()=>{i.result.close(),t||self.indexedDB.deleteDatabase(r),n(!0)},i.onupgradeneeded=()=>{t=!1},i.onerror=()=>{var s;e(((s=i.error)===null||s===void 0?void 0:s.message)||"")}}catch(t){e(t)}})}var AK="FirebaseError",In=class n extends Error{constructor(e,t,r){super(t),this.code=e,this.customData=r,this.name=AK,Object.setPrototypeOf(this,n.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,qs.prototype.create)}},qs=class{constructor(e,t,r){this.service=e,this.serviceName=t,this.errors=r}create(e,...t){let r=t[0]||{},i=`${this.service}/${e}`,s=this.errors[e],o=s?CK(s,r):"Error",a=`${this.serviceName}: ${o} (${i}).`;return new In(i,a,r)}};function CK(n,e){return n.replace(SK,(t,r)=>{let i=e[r];return i!=null?String(i):`<${r}?>`})}var SK=/\{\$([^}]+)}/g;function dL(n){for(let e in n)if(Object.prototype.hasOwnProperty.call(n,e))return!1;return!0}function Qa(n,e){if(n===e)return!0;let t=Object.keys(n),r=Object.keys(e);for(let i of t){if(!r.includes(i))return!1;let s=n[i],o=e[i];if(tL(s)&&tL(o)){if(!Qa(s,o))return!1}else if(s!==o)return!1}for(let i of r)if(!t.includes(i))return!1;return!0}function tL(n){return n!==null&&typeof n=="object"}function $l(n){let e=[];for(let[t,r]of Object.entries(n))Array.isArray(r)?r.forEach(i=>{e.push(encodeURIComponent(t)+"="+encodeURIComponent(i))}):e.push(encodeURIComponent(t)+"="+encodeURIComponent(r));return e.length?"&"+e.join("&"):""}function hL(n,e){let t=new xI(n,e);return t.subscribe.bind(t)}var xI=class{constructor(e,t){this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Promise.resolve(),this.finalized=!1,this.onNoObservers=t,this.task.then(()=>{e(this)}).catch(r=>{this.error(r)})}next(e){this.forEachObserver(t=>{t.next(e)})}error(e){this.forEachObserver(t=>{t.error(e)}),this.close(e)}complete(){this.forEachObserver(e=>{e.complete()}),this.close()}subscribe(e,t,r){let i;if(e===void 0&&t===void 0&&r===void 0)throw new Error("Missing Observer.");xK(e,["next","error","complete"])?i=e:i={next:e,error:t,complete:r},i.next===void 0&&(i.next=CI),i.error===void 0&&(i.error=CI),i.complete===void 0&&(i.complete=CI);let s=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then(()=>{try{this.finalError?i.error(this.finalError):i.complete()}catch{}}),this.observers.push(i),s}unsubscribeOne(e){this.observers===void 0||this.observers[e]===void 0||(delete this.observers[e],this.observerCount-=1,this.observerCount===0&&this.onNoObservers!==void 0&&this.onNoObservers(this))}forEachObserver(e){if(!this.finalized)for(let t=0;t<this.observers.length;t++)this.sendOne(t,e)}sendOne(e,t){this.task.then(()=>{if(this.observers!==void 0&&this.observers[e]!==void 0)try{t(this.observers[e])}catch(r){typeof console<"u"&&console.error&&console.error(r)}})}close(e){this.finalized||(this.finalized=!0,e!==void 0&&(this.finalError=e),this.task.then(()=>{this.observers=void 0,this.onNoObservers=void 0}))}};function xK(n,e){if(typeof n!="object"||n===null)return!1;for(let t of e)if(t in n&&typeof n[t]=="function")return!0;return!1}function CI(){}var lve=4*60*60*1e3;function _t(n){return n&&n._delegate?n._delegate:n}var Ln=class{constructor(e,t,r){this.name=e,this.instanceFactory=t,this.type=r,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(e){return this.instantiationMode=e,this}setMultipleInstances(e){return this.multipleInstances=e,this}setServiceProps(e){return this.serviceProps=e,this}setInstanceCreatedCallback(e){return this.onInstanceCreated=e,this}};var Za="[DEFAULT]";var NI=class{constructor(e,t){this.name=e,this.container=t,this.component=null,this.instances=new Map,this.instancesDeferred=new Map,this.instancesOptions=new Map,this.onInitCallbacks=new Map}get(e){let t=this.normalizeInstanceIdentifier(e);if(!this.instancesDeferred.has(t)){let r=new wg;if(this.instancesDeferred.set(t,r),this.isInitialized(t)||this.shouldAutoInitialize())try{let i=this.getOrInitializeService({instanceIdentifier:t});i&&r.resolve(i)}catch{}}return this.instancesDeferred.get(t).promise}getImmediate(e){var t;let r=this.normalizeInstanceIdentifier(e?.identifier),i=(t=e?.optional)!==null&&t!==void 0?t:!1;if(this.isInitialized(r)||this.shouldAutoInitialize())try{return this.getOrInitializeService({instanceIdentifier:r})}catch(s){if(i)return null;throw s}else{if(i)return null;throw Error(`Service ${this.name} is not available`)}}getComponent(){return this.component}setComponent(e){if(e.name!==this.name)throw Error(`Mismatching Component ${e.name} for Provider ${this.name}.`);if(this.component)throw Error(`Component for ${this.name} has already been provided`);if(this.component=e,!!this.shouldAutoInitialize()){if(RK(e))try{this.getOrInitializeService({instanceIdentifier:Za})}catch{}for(let[t,r]of this.instancesDeferred.entries()){let i=this.normalizeInstanceIdentifier(t);try{let s=this.getOrInitializeService({instanceIdentifier:i});r.resolve(s)}catch{}}}}clearInstance(e=Za){this.instancesDeferred.delete(e),this.instancesOptions.delete(e),this.instances.delete(e)}delete(){return m(this,null,function*(){let e=Array.from(this.instances.values());yield Promise.all([...e.filter(t=>"INTERNAL"in t).map(t=>t.INTERNAL.delete()),...e.filter(t=>"_delete"in t).map(t=>t._delete())])})}isComponentSet(){return this.component!=null}isInitialized(e=Za){return this.instances.has(e)}getOptions(e=Za){return this.instancesOptions.get(e)||{}}initialize(e={}){let{options:t={}}=e,r=this.normalizeInstanceIdentifier(e.instanceIdentifier);if(this.isInitialized(r))throw Error(`${this.name}(${r}) has already been initialized`);if(!this.isComponentSet())throw Error(`Component ${this.name} has not been registered yet`);let i=this.getOrInitializeService({instanceIdentifier:r,options:t});for(let[s,o]of this.instancesDeferred.entries()){let a=this.normalizeInstanceIdentifier(s);r===a&&o.resolve(i)}return i}onInit(e,t){var r;let i=this.normalizeInstanceIdentifier(t),s=(r=this.onInitCallbacks.get(i))!==null&&r!==void 0?r:new Set;s.add(e),this.onInitCallbacks.set(i,s);let o=this.instances.get(i);return o&&e(o,i),()=>{s.delete(e)}}invokeOnInitCallbacks(e,t){let r=this.onInitCallbacks.get(t);if(r)for(let i of r)try{i(e,t)}catch{}}getOrInitializeService({instanceIdentifier:e,options:t={}}){let r=this.instances.get(e);if(!r&&this.component&&(r=this.component.instanceFactory(this.container,{instanceIdentifier:DK(e),options:t}),this.instances.set(e,r),this.instancesOptions.set(e,t),this.invokeOnInitCallbacks(r,e),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,e,r)}catch{}return r||null}normalizeInstanceIdentifier(e=Za){return this.component?this.component.multipleInstances?e:Za:e}shouldAutoInitialize(){return!!this.component&&this.component.instantiationMode!=="EXPLICIT"}};function DK(n){return n===Za?void 0:n}function RK(n){return n.instantiationMode==="EAGER"}var Tg=class{constructor(e){this.name=e,this.providers=new Map}addComponent(e){let t=this.getProvider(e.name);if(t.isComponentSet())throw new Error(`Component ${e.name} has already been registered with ${this.name}`);t.setComponent(e)}addOrOverwriteComponent(e){this.getProvider(e.name).isComponentSet()&&this.providers.delete(e.name),this.addComponent(e)}getProvider(e){if(this.providers.has(e))return this.providers.get(e);let t=new NI(e,this);return this.providers.set(e,t),t}getProviders(){return Array.from(this.providers.values())}};var kK=[],tt=function(n){return n[n.DEBUG=0]="DEBUG",n[n.VERBOSE=1]="VERBOSE",n[n.INFO=2]="INFO",n[n.WARN=3]="WARN",n[n.ERROR=4]="ERROR",n[n.SILENT=5]="SILENT",n}(tt||{}),PK={debug:tt.DEBUG,verbose:tt.VERBOSE,info:tt.INFO,warn:tt.WARN,error:tt.ERROR,silent:tt.SILENT},MK=tt.INFO,NK={[tt.DEBUG]:"log",[tt.VERBOSE]:"log",[tt.INFO]:"info",[tt.WARN]:"warn",[tt.ERROR]:"error"},OK=(n,e,...t)=>{if(e<n.logLevel)return;let r=new Date().toISOString(),i=NK[e];if(i)console[i](`[${r}] ${n.name}:`,...t);else throw new Error(`Attempted to log a message with an invalid logType (value: ${e})`)},Go=class{constructor(e){this.name=e,this._logLevel=MK,this._logHandler=OK,this._userLogHandler=null,kK.push(this)}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in tt))throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel=typeof e=="string"?PK[e]:e}get logHandler(){return this._logHandler}set logHandler(e){if(typeof e!="function")throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=e}get userLogHandler(){return this._userLogHandler}set userLogHandler(e){this._userLogHandler=e}debug(...e){this._userLogHandler&&this._userLogHandler(this,tt.DEBUG,...e),this._logHandler(this,tt.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,tt.VERBOSE,...e),this._logHandler(this,tt.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,tt.INFO,...e),this._logHandler(this,tt.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,tt.WARN,...e),this._logHandler(this,tt.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,tt.ERROR,...e),this._logHandler(this,tt.ERROR,...e)}};var LK=(n,e)=>e.some(t=>n instanceof t),fL,pL;function FK(){return fL||(fL=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function VK(){return pL||(pL=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var mL=new WeakMap,LI=new WeakMap,gL=new WeakMap,OI=new WeakMap,VI=new WeakMap;function jK(n){let e=new Promise((t,r)=>{let i=()=>{n.removeEventListener("success",s),n.removeEventListener("error",o)},s=()=>{t(Ji(n.result)),i()},o=()=>{r(n.error),i()};n.addEventListener("success",s),n.addEventListener("error",o)});return e.then(t=>{t instanceof IDBCursor&&mL.set(t,n)}).catch(()=>{}),VI.set(e,n),e}function $K(n){if(LI.has(n))return;let e=new Promise((t,r)=>{let i=()=>{n.removeEventListener("complete",s),n.removeEventListener("error",o),n.removeEventListener("abort",o)},s=()=>{t(),i()},o=()=>{r(n.error||new DOMException("AbortError","AbortError")),i()};n.addEventListener("complete",s),n.addEventListener("error",o),n.addEventListener("abort",o)});LI.set(n,e)}var FI={get(n,e,t){if(n instanceof IDBTransaction){if(e==="done")return LI.get(n);if(e==="objectStoreNames")return n.objectStoreNames||gL.get(n);if(e==="store")return t.objectStoreNames[1]?void 0:t.objectStore(t.objectStoreNames[0])}return Ji(n[e])},set(n,e,t){return n[e]=t,!0},has(n,e){return n instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in n}};function yL(n){FI=n(FI)}function UK(n){return n===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...t){let r=n.call(Ag(this),e,...t);return gL.set(r,e.sort?e.sort():[e]),Ji(r)}:VK().includes(n)?function(...e){return n.apply(Ag(this),e),Ji(mL.get(this))}:function(...e){return Ji(n.apply(Ag(this),e))}}function BK(n){return typeof n=="function"?UK(n):(n instanceof IDBTransaction&&$K(n),LK(n,FK())?new Proxy(n,FI):n)}function Ji(n){if(n instanceof IDBRequest)return jK(n);if(OI.has(n))return OI.get(n);let e=BK(n);return e!==n&&(OI.set(n,e),VI.set(e,n)),e}var Ag=n=>VI.get(n);function vL(n,e,{blocked:t,upgrade:r,blocking:i,terminated:s}={}){let o=indexedDB.open(n,e),a=Ji(o);return r&&o.addEventListener("upgradeneeded",c=>{r(Ji(o.result),c.oldVersion,c.newVersion,Ji(o.transaction),c)}),t&&o.addEventListener("blocked",c=>t(c.oldVersion,c.newVersion,c)),a.then(c=>{s&&c.addEventListener("close",()=>s()),i&&c.addEventListener("versionchange",l=>i(l.oldVersion,l.newVersion,l))}).catch(()=>{}),a}var HK=["get","getKey","getAll","getAllKeys","count"],qK=["put","add","delete","clear"],jI=new Map;function _L(n,e){if(!(n instanceof IDBDatabase&&!(e in n)&&typeof e=="string"))return;if(jI.get(e))return jI.get(e);let t=e.replace(/FromIndex$/,""),r=e!==t,i=qK.includes(t);if(!(t in(r?IDBIndex:IDBObjectStore).prototype)||!(i||HK.includes(t)))return;let s=function(o,...a){return m(this,null,function*(){let c=this.transaction(o,i?"readwrite":"readonly"),l=c.store;return r&&(l=l.index(a.shift())),(yield Promise.all([l[t](...a),i&&c.done]))[0]})};return jI.set(e,s),s}yL(n=>D(_({},n),{get:(e,t,r)=>_L(e,t)||n.get(e,t,r),has:(e,t)=>!!_L(e,t)||n.has(e,t)}));var UI=class{constructor(e){this.container=e}getPlatformInfoString(){return this.container.getProviders().map(t=>{if(zK(t)){let r=t.getImmediate();return`${r.library}/${r.version}`}else return null}).filter(t=>t).join(" ")}};function zK(n){let e=n.getComponent();return e?.type==="VERSION"}var BI="@firebase/app",bL="0.10.13";var zs=new Go("@firebase/app"),GK="@firebase/app-compat",WK="@firebase/analytics-compat",KK="@firebase/analytics",YK="@f
8irebase/app-check-compat",XK="@firebase/app-check",QK="@firebase/auth",ZK="@firebase/auth-compat",JK="@firebase/database",e7="@firebase/data-connect",t7="@firebase/database-compat",n7="@firebase/functions",r7="@firebase/functions-compat",i7="@firebase/installations",s7="@firebase/installations-compat",o7="@firebase/messaging",a7="@firebase/messaging-compat",c7="@firebase/performance",l7="@firebase/performance-compat",u7="@firebase/remote-config",d7="@firebase/remote-config-compat",h7="@firebase/storage",f7="@firebase/storage-compat",p7="@firebase/firestore",m7="@firebase/vertexai-preview",g7="@firebase/firestore-compat",y7="firebase",_7="10.14.1";var HI="[DEFAULT]",v7={[BI]:"fire-core",[GK]:"fire-core-compat",[KK]:"fire-analytics",[WK]:"fire-analytics-compat",[XK]:"fire-app-check",[YK]:"fire-app-check-compat",[QK]:"fire-auth",[ZK]:"fire-auth-compat",[JK]:"fire-rtdb",[e7]:"fire-data-connect",[t7]:"fire-rtdb-compat",[n7]:"fire-fn",[r7]:"fire-fn-compat",[i7]:"fire-iid",[s7]:"fire-iid-compat",[o7]:"fire-fcm",[a7]:"fire-fcm-compat",[c7]:"fire-perf",[l7]:"fire-perf-compat",[u7]:"fire-rc",[d7]:"fire-rc-compat",[h7]:"fire-gcs",[f7]:"fire-gcs-compat",[p7]:"fire-fst",[g7]:"fire-fst-compat",[m7]:"fire-vertex","fire-js":"fire-js",[y7]:"fire-js-all"};var oh=new Map,b7=new Map,qI=new Map;function wL(n,e){try{n.container.addComponent(e)}catch(t){zs.debug(`Component ${e.name} failed to register with FirebaseApp ${n.name}`,t)}}function Yr(n){let e=n.name;if(qI.has(e))return zs.debug(`There were multiple attempts to register component ${e}.`),!1;qI.set(e,n);for(let t of oh.values())wL(t,n);for(let t of b7.values())wL(t,n);return!0}function Gs(n,e){let t=n.container.getProvider("heartbeat").getImmediate({optional:!0});return t&&t.triggerHeartbeat(),n.container.getProvider(e)}function es(n){return n.settings!==void 0}var w7={"no-app":"No Firebase App '{$appName}' has been created - call initializeApp() first","bad-app-name":"Illegal App name: '{$appName}'","duplicate-app":"Firebase App named '{$appName}' already exists with different options or config","app-deleted":"Firebase App named '{$appName}' already deleted","server-app-deleted":"Firebase Server App has been deleted","no-options":"Need to provide options, when not being deployed to hosting via source.","invalid-app-argument":"firebase.{$appName}() takes either no argument or a Firebase App instance.","invali
8d-log-argument":"First argument to `onLog` must be null or a function.","idb-open":"Error thrown when opening IndexedDB. Original error: {$originalErrorMessage}.","idb-get":"Error thrown when reading from IndexedDB. Original error: {$originalErrorMessage}.","idb-set":"Error thrown when writing to IndexedDB. Original error: {$originalErrorMessage}.","idb-delete":"Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}.","finalization-registry-not-supported":"FirebaseServerApp deleteOnDeref field defined but the JS runtime does not support FinalizationRegistry.","invalid-server-app-environment":"FirebaseServerApp is not for use in browser environments."},Wo=new qs("app","Firebase",w7);var zI=class{constructor(e,t,r){this._isDeleted=!1,this._options=Object.assign({},e),this._config=Object.assign({},t),this._name=t.name,this._automaticDataCollectionEnabled=t.automaticDataCollectionEnabled,this._container=r,this.container.addComponent(new Ln("app",()=>this,"PUBLIC"))}get automaticDataCollectionEnabled(){return this.checkDestroyed(),this._automaticDataCollectionEnabled}set automaticDataCollectionEnabled(e){this.checkDestroyed(),this._automaticDataCollectionEnabled=e}get name(){return this.checkDestroyed(),this._name}get options(){return this.checkDestroyed(),this._options}get config(){return this.checkDestroyed(),this._config}get container(){return this._container}get isDeleted(){return this._isDeleted}set isDeleted(e){this._isDeleted=e}checkDestroyed(){if(this.isDeleted)throw Wo.create("app-deleted",{appName:this._name})}};var ts=_7;function KI(n,e={}){let t=n;typeof e!="object"&&(e={name:e});let r=Object.assign({name:HI,automaticDataCollectionEnabled:!1},e),i=r.name;if(typeof i!="string"||!i)throw Wo.create("bad-app-name",{appName:String(i)});if(t||(t=kI()),!t)throw Wo.create("no-options");let s=oh.get(i);if(s){if(Qa(t,s.options)&&Qa(r,s.config))return s;throw Wo.create("duplicate-app",{appName:i})}let o=new Tg(i);for(let c of qI.values())o.addComponent(c);let a=new zI(t,r,o);return oh.set(i,a),a}function ns(n=HI){let e=oh.get(n);if(!e&&n===HI&&kI())return KI();if(!e)throw Wo.create("no-app",{appName:n});return e}function Cg(){return Array.from(oh.values())}function vt(n,e,t){var r;let i=(r=v7[n])!==null&&r!==void 0?r:n;t&&(i+=`-${t}`);let s=i.match(/\s|\//),o=e.match(/\s|\//);if(s||o){let a=[`Unable to register library "${i}" with version "${e}":`];s&&a.push(`library name "${i}" contains illegal characters (whitespace or "/")`),s&&o&&a.push("and"),o&&a.push(`version name "${e}" contains illegal characters (whitespace or "/")`),zs.warn(a.join(" "));return}Yr(new Ln(`${i}-version`,()=>({library:i,version:e}),"VERSION"))}var E7="firebase-heartbeat-database",I7=1,ah="firebase-heartbeat-store",$I=null;function AL(){return $I||($I=vL(E7,I7,{upgrade:(n,e)=>{switch(e){case 0:try{n.createObjectStore(ah)}catch(t){console.warn(t)}}}}).catch(n=>{throw Wo.create("idb-open",{originalErrorMessage:n.message})})),$I}function T7(n){return m(this,null,function*(){try{let t=(yield AL()).transaction(ah),r=yield t.objectStore(ah).get(CL(n));return yield t.done,r}catch(e){if(e instanceof In)zs.warn(e.message);else{let t=Wo.create("idb-get",{originalErrorMessage:e?.message});zs.warn(t.message)}}})}function EL(n,e){return m(this,null,function*(){try{let r=(yield AL()).transaction(ah,"readwrite");yield r.objectStore(ah).put(e,CL(n)),yield r.done}catch(t){if(t instanceof In)zs.warn(t.message);else{let r=Wo.create("idb-set",{originalErrorMessage:t?.message});zs.warn(r.message)}}})}function CL(n){return`${n.name}!${n.options.appId}`}var A7=1024,C7=30*24*60*60*1e3,GI=class{constructor(e){this.container=e,this._heartbeatsCache=null;let t=this.container.getProvider("app").getImmediate();this._storage=new WI(t),this._heartbeatsCachePromise=this._storage.read().then(r=>(this._heartbeatsCache=r,r))}triggerHeartbeat(){return m(this,null,function*(){var e,t;try{let i=this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(),s=IL();return((e=this._heartbeatsCache)===null||e===void 0?void 0:e.heartbeats)==null&&(this._heartbeatsCache=yield this._heartbeatsCachePromise,((t=this._heartbeatsCache)===null||t===void 0?void 0:t.heartbeats)==null)||this._heartbeatsCache.lastSentHeartbeatDate===s||this._heartbeatsCache.heartbeats.some(o=>o.date===s)?void 0:(this._heartbeatsCache.heartbeats.push({date:s,agent:i}),this._heartbeatsCache.heartbeats=this._heartbeatsCache.heartbeats.filter(o=>{let a=new Date(o.date).valueOf();return Date.now()-a<=C7}),this._storage.overwrite(this._heartbeatsCache))}catch(r){zs.warn(r)}})}getHeartbeatsHeader(){return m(this,null,function*(){var e;try{if(this._heartbeatsCache===null&&(yield this._heartbeatsCachePromise),((e=this._heartbeatsCache)===null||e===void 0?void 0:e.heartbeats)==null||this._heartbeatsCache.heartbeats.length===0)return"";let t=IL(),{heartbeatsToSend:r,unsentEntries:i}=S7(this._heartbeatsCache.heartbeats),s=sh(JSON.stringify({version:2,heartbeats:r}));return this._heartbeatsCache.lastSentHeartbeatDate=t,i.length>0?(this._heartbeatsCache.heartbeats=i,yield this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),s}catch(t){return zs.warn(t),""}})}};function IL(){return new Date().toISOString().substring(0,10)}function S7(n,e=A7){let t=[],r=n.slice();for(let i of n){let s=t.find(o=>o.agent===i.agent);if(s){if(s.dates.push(i.date),TL(t)>e){s.dates.pop();break}}else if(t.push({agent:i.agent,dates:[i.date]}),TL(t)>e){t.pop();break}r=r.slice(1)}return{heartbeatsToSend:t,unsentEntries:r}}var WI=class{constructor(e){this.app=e,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}runIndexedDBEnvironmentCheck(){return m(this,null,function*(){return MI()?uL().then(()=>!0).catch(()=>!1):!1})}read(){return m(this,null,function*(){if(yield this._canUseIndexedDBPromise){let t=yield T7(this.app);return t?.heartbeats?t:{heartbeats:[]}}else return{heartbeats:[]}})}overwrite(e){return m(this,null,function*(){var t;if(yield this._canUseIndexedDBPromise){let i=yield this.read();return EL(this.app,{lastSentHeartbeatDate:(t=e.lastSentHeartbeatDate)!==null&&t!==void 0?t:i.lastSentHeartbeatDate,heartbeats:e.heartbeats})}else return})}add(e){return m(this,null,function*(){var t;if(yield this._canUseIndexedDBPromise){let i=yield this.read();return EL(this.app,{lastSentHeartbeatDate:(t=e.lastSentHeartbeatDate)!==null&&t!==void 0?t:i.lastSentHeartbeatDate,heartbeats:[...i.heartbeats,...e.heartbeats]})}else return})}};function TL(n){return sh(JSON.stringify({version:2,heartbeats:n})).length}function x7(n){Yr(new Ln("platform-logger",e=>new UI(e),"PRIVATE")),Yr(new Ln("heartbeat",e=>new GI(e),"PRIVATE")),vt(BI,bL,n),vt(BI,bL,"esm2017"),vt("fire-js","")}x7("");var D7="firebase",R7="10.14.1";vt(D7,R7,"app");var Ci=new Ls("ANGULARFIRE2_VERSION");function Ko(n,e,t){if(e){if(e.length===1)return e[0];let s=e.filter(o=>o.app===t);if(s.length===1)return s[0]}return t.container.getProvider(n).getImmediate({optional:!0})}var Ws=(n,e)=>{let t=e?[e]:Cg(),r=[];return t.forEach(i=>
8{i.container.getProvider(n).instances.forEach(o=>{r.includes(o)||r.push(o)})}),r},rs=class{constructor(){return Ws(k7)}},k7="app-check";function Ul(){}var Sg=class{zone;delegate;constructor(e,t=Xb){this.zone=e,this.delegate=t}now(){return this.delegate.now()}schedule(e,t,r){let i=this.zone,s=function(o){i.runGuarded(()=>{e.apply(this,[o])})};return this.delegate.schedule(s,t,r)}},YI=class{zone;task=null;constructor(e){this.zone=e}call(e,t){let r=this.unscheduleTask.bind(this);return this.task=this.zone.run(()=>Zone.current.scheduleMacroTask("firebaseZoneBlock",Ul,{},Ul,Ul)),t.pipe(Qt({next:r,complete:r,error:r})).subscribe(e).add(r)}unscheduleTask(){setTimeout(()=>{this.task!=null&&this.task.state==="scheduled"&&(this.task.invoke(),this.task=null)},10)}},is=(()=>{class n{ngZone;outsideAngular;insideAngular;constructor(t){this.ngZone=t,this.outsideAngular=t.runOutsideAngular(()=>new Sg(Zone.current)),this.insideAngular=t.run(()=>new Sg(Zone.current,wp)),globalThis.\u0275AngularFireScheduler||=this}static \u0275fac=function(r){return new(r||n)(Y(st))};static \u0275prov=Q({token:n,factory:n.\u0275fac,providedIn:"root"})}return n})();function xg(){let n=globalThis.\u0275AngularFireScheduler;if(!n)throw new Error(`Either AngularFireModule has not been provided in your Ap
8pModule (this can be done manually or implictly using 9provideFirebaseApp) or you're calling an AngularFire method outside of an NgModule (which is not supported).`);return n}function P7(n){return xg().ngZone.runOutsideAngular(()=>n())}function Ja(n){return xg().ngZone.run(()=>n())}function M7(n){return N7(xg())(n)}function N7(n){return function(t){return t=t.lift(new YI(n.ngZone)),t.pipe(xo(n.outsideAngular),So(n.insideAngular))}}var O7=(n,e)=>function(){let r=arguments;return e&&setTimeout(()=>{e.state==="scheduled"&&e.invoke()},10),Ja(()=>n.apply(void 0,r))},ft=(n,e)=>function(){let t,r=arguments;for(let s=0;s<arguments.length;s++)typeof r[s]=="function"&&(e&&(t||=Ja(()=>Zone.current.scheduleMacroTask("firebaseZoneBlock",Ul,{},Ul,Ul))),r[s]=O7(r[s],t));let i=P7(()=>n.apply(this,r));if(!e)if(i instanceof Ue){let s=xg();return i.pipe(xo(s.outsideAngular),So(s.insideAngular))}else return Ja(()=>i);return i instanceof Ue?i.pipe(M7):i instanceof Promise?Ja(()=>new Promise((s,o)=>i.then(a=>Ja(()=>s(a)),a=>Ja(()=>o(a))))):typeof i=="function"&&t?function(){return setTimeout(()=>{t&&t.state==="scheduled"&&t.invoke()},10),i.apply(this,arguments)}:Ja(()=>i)};var Or=class{constructor(e){return e}},Si=class{constructor(){return Cg()}};function L7(n){return n&&n.length===1?n[0]:new Or(ns())}var XI=new ue("angularfire2._apps"),F7={provide:Or,useFactory:L7,deps:[[new kt,XI]]},V7={provide:Si,deps:[[new kt,XI]]};function j7(n){return(e,t)=>{let r=t.get(Gr);vt("angularfire",Ci.full,"core"),vt("angularfire",Ci.full,"app"),vt("angular",FN.full,r.toString());let i=e.runOutsideAngular(()=>n(t));return new Or(i)}}function SL(n,...e){return Nn([F7,V7,{provide:XI,useFactory:j7(n),multi:!0,deps:[st,On,is,...e]}])}var xL=ft(KI,!0);function HL(){return{"dependent-sdk-initialized-before-auth":"Another Firebase SDK was initialized and is trying to use Auth before Auth is initialized. Please be sure to call `initializeAuth` or `getAuth` before starting any other Firebase SDK."}}var qL=HL,zL=new qs("auth","Firebase",HL());var Ng=new Go("@firebase/auth");function $7(n,...e){Ng.logLevel<=tt.WARN&&Ng.warn(`Auth (${ts}): ${n}`,...e)}function Rg(n,...e){Ng.logLevel<=tt.ERROR&&Ng.error(`Auth (${ts}): ${n}`,...e)}function os(n,...e){throw pT(n,...e)}function xi(n,...e){return pT(n,...e)}function fT(n,e,t){let r=Object.assign(Object.assign({},qL()),{[e]:t});return new qs("auth","Firebase",r).create(e,{appName:n.name})}function ec(n){return fT(n,"operation-not-supported-in-this-environment","Operations that alter the current user are not supported in conjunction with FirebaseServerApp")}function U7(n,e,t){let r=t;if(!(e instanceof r))throw r.name!==e.constructor.name&&os(n,"argument-error"),fT(n,"argument-error",`Type of ${e.constructor.name} does not match expected instance.Did you pass a reference from a different Auth SDK?`)}function pT(n,...e){if(typeof n!="string"){let t=e[0],r=[...e.slice(1)];return r[0]&&(r[0].appName=n.name),n._errorFactory.create(t,...r)}return zL.create(n,...e)}function xe(n,e,...t){if(!n)throw pT(e,...t)}function Ks(n){let e="INTERNAL ASSERTION FAILED: "+n;throw Rg(e),new Error(e)}function Xs(n,e){n||Ks(e)}function JI(){var n;return typeof self<"u"&&((n=self.location)===null||n===void 0?void 0:n.href)||""}function B7(){return DL()==="http:"||DL()==="https:"}function DL(){var n;return typeof self<"u"&&((n=self.location)===null||n===void 0?void 0:n.protocol)||null}function H7(){return typeof navigator<"u"&&navigator&&"onLine"in navigator&&typeof navigator.onLine=="boolean"&&(B7()||oL()||"connection"in navigator)?navigator.onLine:!0}function q7(){if(typeof navigator>"u")return null;let n=navigator;return n.languages&&n.languages[0]||n.language||null}var tc=class{constructor(e,t){this.shortDelay=e,this.longDelay=t,Xs(t>e,"Short delay should be less than long delay!"),this.isMobile=iL()||aL()}get(){return H7()?this.isMobile?this.longDelay:this.shortDelay:Math.min(5e3,this.shortDelay)}};function mT(n,e){Xs(n.emulator,"Emulator should always be set here");let{url:t}=n.emulator;return e?`${t}${e.startsWith("/")?e.slice(1):e}`:t}var Og=class{static initialize(e,t,r){this.fetchImpl=e,t&&(this.headersImpl=t),r&&(this.responseImpl=r)}static fetch(){if(this.fetchImpl)return this.fetchImpl;if(typeof self<"u"&&"fetch"in self)return self.fetch;if(typeof globalThis<"u"&&globalThis.fetch)return globalThis.fetch;if(typeof fetch<"u")return fetch;Ks("Could not find fetch implementation, make sure you call FetchProvi
9der.initialize() with an appropriate polyfill")}static headers(){if(this.headersImpl)return this.headersImpl;if(typeof self<"u"&&"Headers"in self)return self.Headers;if(typeof globalThis<"u"&&globalThis.Headers)return globalThis.Headers;if(typeof Headers<"u")return Headers;Ks("Could not find Headers implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}static response(){if(this.responseImpl)return this.responseImpl;if(typeof self<"u"&&"Response"in self)return self.Response;if(typeof globalThis<"u"&&globalThis.Response)return globalThis.Response;if(typeof Response<"u")return Response;Ks("Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}};var z7={CREDENTIAL_MISMATCH:"custom-token-mismatch",MISSING_CUSTOM_TOKEN:"internal-error",INVALID_IDENTIFIER:"invalid-email",MISSING_CONTINUE_URI:"internal-error",INVALID_PASSWORD:"wrong-password",MISSING_PASSWORD:"missing-password",INVALID_LOGIN_CREDENTIALS:"invalid-credential",EMAIL_EXISTS:"email-already-in-use",PASSWORD_LOGIN_DISABLED:"operation-not-allowed",INVALID_IDP_RESPONSE:"invalid-credential",INVALID_PENDING_TOKEN:"invalid-credential",FEDERATED_USER_ID_ALREADY_LINKED:"credential-already-in-use",MISSING_REQ_TYPE:"internal-error",EMAIL_NOT_FOUND:"user-not-found",RESET_PASSWORD_EXCEED_LIMIT:"too-many-requests",EXPIRED_OOB_CODE:"expired-action-code",INVALID_OOB_CODE:"invalid-action-code",MISSING_OOB_CODE:"internal-error",CREDENTIAL_TOO_OLD_LOGIN_AGAIN:"requires-recent-login",INVALID_ID_TOKEN:"invalid-user-token",TOKEN_EXPIRED:"user-token-expired",USER_NOT_FOUND:"user-token-expired",TOO_MANY_ATTEMPTS_TRY_LATER:"too-many-requests",PASSWORD_DOES_NOT_MEET_REQUIREMENTS:"password-does-not-meet-requirements",INVALID_CODE:"invalid-verification-code",INVALID_SESSION_INFO:"invalid-verification-id",INVALID_TEMPORARY_PROOF:"invalid-credential",MISSING_SESSION_INFO:"missing-verification-id",SESSION_EXPIRED:"code-expired",MISSING_ANDROID_PACKAGE_NAME:"missing-android-pkg-name",UNAUTHORIZED_DOMAIN:"unauthorized-continue-uri",INVALID_OAUTH_CLIENT_ID:"invalid-oauth-client-id",ADMIN_ONLY_OPERATION:"admin-restricted-operation",INVALID_MFA_PENDING_CREDENTIAL:"invalid-multi-factor-session",MFA_ENROLLMENT_NOT_FOUND:"multi-factor-info-not-found",MISSING_MFA_ENROLLMENT_ID:"missing-multi-factor-info",MISSING_MFA_PENDING_CREDENTIAL:"missing-multi-factor-session",SECOND_FACTOR_EXISTS:"second-factor-already-in-use",SECOND_FACTOR_LIMIT_EXCEEDED:"maximum-second-factor-count-exceeded",BLOCKING_FUNCTION_ERROR_RESPONSE:"internal-error",RECAPTCHA_NOT_ENABLED:"recaptcha-not-enabled",MISSING_RECAPTCHA_TOKEN:"missing-recaptcha-token",INVALID_RECAPTCHA_TOKEN:"invalid-recaptcha-token",INVALID_RECAPTCHA_ACTION:"invalid-recaptcha-action",MISSING_CLIENT_TYPE:"missing-client-type",MISSING_RECAPTCHA_VERSION:"missing-recaptcha-version",INVALID_RECAPTCHA_VERSION:"invalid-recaptcha-version",INVALID_REQ_TYPE:"invalid-req-type"};var G7=new tc(3e4,6e4);function gT(n,e){return n.tenantId&&!e.tenantId?Object.assign(Object.assign({},e),{tenantId:n.tenantId}):e}function ql(s,o,a,c){return m(this,arguments,function*(n,e,t,r,i={}){return GL(n,i,()=>m(this,null,function*(){let l={},u={};r&&(e==="GET"?u=r:l={body:JSON.stringify(r)});let d=$l(Object.assign({key:n.config.apiKey},u)).slice(1),f=yield n._getAdditionalHeaders();f["Content-Type"]="application/json",n.languageCode&&(f["X-Firebase-Locale"]=n.languageCode);let p=Object.assign({method:e,headers:f},l);return sL()||(p.referrerPolicy="no-referrer"),Og.fetch()(WL(n,n.config.apiHost,t,d),p)}))})}function GL(n,e,t){return m(this,null,function*(){n._canInitEmulator=!1;let r=Object.assign(Object.assign({},z7),e);try{let i=new eT(n),s=yield Promise.race([t(),i.promise]);i.clearNetworkTimeout();let o=yield s.json();if("needConfirmation"in o)throw Dg(n,"account-exists-with-different-credential",o);if(s.ok&&!("errorMessage"in o))return o;{let a=s.ok?o.errorMessage:o.error.message,[c,l]=a.split(" : ");if(c==="FEDERATED_USER_ID_ALREADY_LINKED")throw Dg(n,"credential-already-in-use",o);if(c==="EMAIL_EXISTS")throw Dg(n,"email-already-in-use",o);if(c==="USER_DISABLED")throw Dg(n,"user-disabled",o);let u=r[c]||c.toLowerCase().replace(/[_\s]+/g,"-");if(l)throw fT(n,u,l);os(n,u)}}catch(i){if(i instanceof In)throw i;os(n,"network-request-failed",{message:String(i)})}})}function W7(s,o,a,c){return m(this,arguments,function*(n,e,t,r,i={}){let l=yield ql(n,e,t,r,i);return"mfaPendingCredential"in l&&os(n,"multi-factor-auth-required",{_serverResponse:l}),l})}function WL(n,e,t,r){let i=`${e}${t}?${r}`;return n.config.emulator?mT(n.config,i):`${n.config.apiScheme}://${i}`}var eT=class{constructor(e){this.auth=e,this.timer=null,this.promise=new Promise((t,r)=>{this.timer=setTimeout(()=>r(xi(this.auth,"network-request-failed")),G7.get())})}clearNetworkTimeout(){clearTimeout(this.timer)}};function Dg(n,e,t){let r={appName:n.name};t.email&&(r.email=t.email),t.phoneNumber&&(r.phoneNumber=t.phoneNumber);let i=xi(n,e,r);return i.customData._tokenResponse=t,i}function K7(n,e){return m(this,null,function*(){return ql(n,"POST","/v1/accounts:delete",e)}
vendor: 29,354 bytes, line 9
9)}function KL(n,e){return m(this,null,function*(){return ql(n,"POST","/v1/accounts:lookup",e)})}function ch(n){if(n)try{let e=new Date(Number(n));if(!isNaN(e.getTime()))return e.toUTCString()}catch{}}function yT(n,e=!1){return m(this,null,function*(){let t=_t(n),r=yield t.getIdToken(e),i=_T(r);xe(i&&i.exp&&i.auth_time&&i.iat,t.auth,"internal-error");let s=typeof i.firebase=="object"?i.firebase:void 0,o=s?.sign_in_provider;return{claims:i,token:r,authTime:ch(QI(i.auth_time)),issuedAtTime:ch(QI(i.iat)),expirationTime:ch(QI(i.exp)),signInProvider:o||null,signInSecondFactor:s?.sign_in_second_factor||null}})}function QI(n){return Number(n)*1e3}function _T(n){let[e,t,r]=n.split(".");if(e===void 0||t===void 0||r===void 0)return Rg("JWT malformed, contained fewer than 3 sections"),null;try{let i=DI(t);return i?JSON.parse(i):(Rg("Failed to decode base64 JWT payload"),null)}catch(i){return Rg("Caught error parsing JWT payload as JSON",i?.toString()),null}}function RL(n){let e=_T(n);return xe(e,"internal-error"),xe(typeof e.exp<"u","internal-error"),xe(typeof e.iat<"u","internal-error"),Number(e.exp)-Number(e.iat)}function uh(n,e,t=!1){return m(this,null,function*(){if(t)return e;try{return yield e}catch(r){throw r instanceof In&&Y7(r)&&n.auth.currentUser===n&&(yield n.auth.signOut()),r}})}function Y7({code:n}){return n==="auth/user-disabled"||n==="auth/user-token-expired"}var tT=class{constructor(e){this.user=e,this.isRunning=!1,this.timerId=null,this.errorBackoff=3e4}_start(){this.isRunning||(this.isRunning=!0,this.schedule())}_stop(){this.isRunning&&(this.isRunning=!1,this.timerId!==null&&clearTimeout(this.timerId))}getInterval(e){var t;if(e){let r=this.errorBackoff;return this.errorBackoff=Math.min(this.errorBackoff*2,96e4),r}else{this.errorBackoff=3e4;let i=((t=this.user.stsTokenManager.expirationTime)!==null&&t!==void 0?t:0)-Date.now()-3e5;return Math.max(0,i)}}schedule(e=!1){if(!this.isRunning)return;let t=this.getInterval(e);this.timerId=setTimeout(()=>m(this,null,function*(){yield this.iteration()}),t)}iteration(){return m(this,null,function*(){try{yield this.user.getIdToken(!0)}catch(e){e?.code==="auth/network-request-failed"&&this.schedule(!0);return}this.schedule()})}};var dh=class{constructor(e,t){this.createdAt=e,this.lastLoginAt=t,this._initializeTime()}_initializeTime(){this.lastSignInTime=ch(this.lastLoginAt),this.creationTime=ch(this.createdAt)}_copy(e){this.createdAt=e.createdAt,this.lastLoginAt=e.lastLoginAt,this._initializeTime()}toJSON(){return{createdAt:this.createdAt,lastLoginAt:this.lastLoginAt}}};function Lg(n){return m(this,null,function*(){var e;let t=n.auth,r=yield n.getIdToken(),i=yield uh(n,KL(t,{idToken:r}));xe(i?.users.length,t,"internal-error");let s=i.users[0];n._notifyReloadListener(s);let o=!((e=s.providerUserInfo)===null||e===void 0)&&e.length?YL(s.providerUserInfo):[],a=X7(n.providerData,o),c=n.isAnonymous,l=!(n.email&&s.passwordHash)&&!a?.length,u=c?l:!1,d={uid:s.localId,displayName:s.displayName||null,photoURL:s.photoUrl||null,email:s.email||null,emailVerified:s.emailVerified||!1,phoneNumber:s.phoneNumber||null,tenantId:s.tenantId||null,providerData:a,metadata:new dh(s.createdAt,s.lastLoginAt),isAnonymous:u};Object.assign(n,d)})}function vT(n){return m(this,null,function*(){let e=_t(n);yield Lg(e),yield e.auth._persistUserIfCurrent(e),e.auth._notifyListenersIfCurrent(e)})}function X7(n,e){return[...n.filter(r=>!e.some(i=>i.providerId===r.providerId)),...e]}function YL(n){return n.map(e=>{var{providerId:t}=e,r=Cp(e,["providerId"]);return{providerId:t,uid:r.rawId||"",displayName:r.displayName||null,email:r.email||null,phoneNumber:r.phoneNumber||null,photoURL:r.photoUrl||null}})}function Q7(n,e){return m(this,null,function*(){let t=yield GL(n,{},()=>m(this,null,function*(){let r=$l({grant_type:"refresh_token",refresh_token:e}).slice(1),{tokenApiHost:i,apiKey:s}=n.config,o=WL(n,i,"/v1/token",`key=${s}`),a=yield n._getAdditionalHeaders();return a["Content-Type"]="application/x-www-form-urlencoded",Og.fetch()(o,{method:"POST",headers:a,body:r})}));return{accessToken:t.access_token,expiresIn:t.expires_in,refreshToken:t.refresh_token}})}function Z7(n,e){return m(this,null,function*(){return ql(n,"POST","/v2/accounts:revokeToken",gT(n,e))})}var lh=class n{constructor(){this.refreshToken=null,this.accessToken=null,this.expirationTime=null}get isExpired(){return!this.expirationTime||Date.now()>this.expirationTime-3e4}updateFromServerResponse(e){xe(e.idToken,"internal-error"),xe(typeof e.idToken<"u","internal-error"),xe(typeof e.refreshToken<"u","internal-error");let t="expiresIn"in e&&typeof e.expiresIn<"u"?Number(e.expiresIn):RL(e.idToken);this.updateTokensAndExpiration(e.idToken,e.refreshToken,t)}updateFromIdToken(e){xe(e.length!==0,"internal-error");let t=RL(e);this.updateTokensAndExpiration(e,null,t)}getToken(e,t=!1){return m(this,null,function*(){return!t&&this.accessToken&&!this.isExpired?this.accessToken:(xe(this.refreshToken,e,"user-token-expired"),this.refreshToken?(yield this.refresh(e,this.refreshToken),this.accessToken):null)})}clearRefreshToken(){this.refreshToken=null}refresh(e,t){return m(this,null,function*(){let{accessToken:r,refreshToken:i,expiresIn:s}=yield Q7(e,t);this.updateTokensAndExpiration(r,i,Number(s))})}updateTokensAndExpiration(e,t,r){this.refreshToken=t||null,this.accessToken=e||null,this.expirationTime=Date.now()+r*1e3}static fromJSON(e,t){let{refreshToken:r,accessToken:i,expirationTime:s}=t,o=new n;return r&&(xe(typeof r=="string","internal-error",{appName:e}),o.refreshToken=r),i&&(xe(typeof i=="string","internal-error",{appName:e}),o.accessToken=i),s&&(xe(typeof s=="number","internal-error",{appName:e}),o.expirationTime=s),o}toJSON(){return{refreshToken:this.refreshToken,accessToken:this.accessToken,expirationTime:this.expirationTime}}_assign(e){this.accessToken=e.accessToken,this.refreshToken=e.refreshToken,this.expirationTime=e.expirationTime}_clone(){return Object.assign(new n,this.toJSON())}_performRefresh(){return Ks("not implemented")}};function Yo(n,e){xe(typeof n=="string"||typeof n>"u","internal-error",{appName:e})}var Hl=class n{constructor(e){var{uid:t,auth:r,stsTokenManager:i}=e,s=Cp(e,["uid","auth","stsTokenManager"]);this.providerId="firebase",this.proactiveRefresh=new tT(this),this.reloadUserInfo=null,this.reloadListener=null,this.uid=t,this.auth=r,this.stsTokenManager=i,this.accessToken=i.accessToken,this.displayName=s.displayName||null,this.email=s.email||null,this.emailVerified=s.emailVerified||!1,this.phoneNumber=s.phoneNumber||null,this.photoURL=s.photoURL||null,this.isAnonymous=s.isAnonymous||!1,this.tenantId=s.tenantId||null,this.providerData=s.providerData?[...s.providerData]:[],this.metadata=new dh(s.createdAt||void 0,s.lastLoginAt||void 0)}getIdToken(e){return m(this,null,function*(){let t=yield uh(this,this.stsTokenManager.getToken(this.auth,e));return xe(t,this.auth,"internal-error"),this.accessToken!==t&&(this.accessToken=t,yield this.auth._persistUserIfCurrent(this),this.auth._notifyListenersIfCurrent(this)),t})}getIdTokenResult(e){return yT(this,e)}reload(){return vT(this)}_assign(e){this!==e&&(xe(this.uid===e.uid,this.auth,"internal-error"),this.displayName=e.displayName,this.photoURL=e.photoURL,this.email=e.email,this.emailVerified=e.emailVerified,this.phoneNumber=e.phoneNumber,this.isAnonymous=e.isAnonymous,this.tenantId=e.tenantId,this.providerData=e.providerData.map(t=>Object.assign({},t)),this.metadata._copy(e.metadata),this.stsTokenManager._assign(e.stsTokenManager))}_clone(e){let t=new n(Object.assign(Object.assign({},this),{auth:e,stsTokenManager:this.stsTokenManager._clone()}));return t.metadata._copy(this.metadata),t}_onReload(e){xe(!this.reloadListener,this.auth,"internal-error"),this.reloadListener=e,this.reloadUserInfo&&(this._notifyReloadListener(this.reloadUserInfo),this.reloadUserInfo=null)}_notifyReloadListener(e){this.reloadListener?this.reloadListener(e):this.reloadUserInfo=e}_startProactiveRefresh(){this.proactiveRefresh._start()}_stopProactiveRefresh(){this.proactiveRefresh._stop()}_updateTokensIfNecessary(e,t=!1){return m(this,null,function*(){let r=!1;e.idToken&&e.idToken!==this.stsTokenManager.accessToken&&(this.stsTokenManager.updateFromServerResponse(e),r=!0),t&&(yield Lg(this)),yield this.auth._persistUserIfCurrent(this),r&&this.auth._notifyListenersIfCurrent(this)})}delete(){return m(this,null,function*(){if(es(this.auth.app))return Promise.reject(ec(this.auth));let e=yield this.getIdToken();return yield uh(this,K7(this.auth,{idToken:e})),this.stsTokenManager.clearRefreshToken(),this.auth.signOut()})}toJSON(){return Object.assign(Object.assign({uid:this.uid,email:this.email||void 0,emailVerified:this.emailVerified,displayName:this.displayName||void 0,isAnonymous:this.isAnonymous,photoURL:this.photoURL||void 0,phoneNumber:this.phoneNumber||void 0,tenantId:this.tenantId||void 0,providerData:this.providerData.map(e=>Object.assign({},e)),stsTokenManager:this.stsTokenManager.toJSON(),_redirectEventId:this._redirectEventId},this.metadata.toJSON()),{apiKey:this.auth.config.apiKey,appName:this.auth.name})}get refreshToken(){return this.stsTokenManager.refreshToken||""}static _fromJSON(e,t){var r,i,s,o,a,c,l,u;let d=(r=t.displayName)!==null&&r!==void 0?r:void 0,f=(i=t.email)!==null&&i!==void 0?i:void 0,p=(s=t.phoneNumber)!==null&&s!==void 0?s:void 0,y=(o=t.photoURL)!==null&&o!==void 0?o:void 0,v=(a=t.tenantId)!==null&&a!==void 0?a:void 0,w=(c=t._redirectEventId)!==null&&c!==void 0?c:void 0,E=(l=t.createdAt)!==null&&l!==void 0?l:void 0,A=(u=t.lastLoginAt)!==null&&u!==void 0?u:void 0,{uid:x,emailVerified:M,isAnonymous:O,providerData:$,stsTokenManager:C}=t;xe(x&&C,e,"internal-error");let T=lh.fromJSON(this.name,C);xe(typeof x=="string",e,"internal-error"),Yo(d,e.name),Yo(f,e.name),xe(typeof M=="boolean",e,"internal-error"),xe(typeof O=="boolean",e,"internal-error"),Yo(p,e.name),Yo(y,e.name),Yo(v,e.name),Yo(w,e.name),Yo(E,e.name),Yo(A,e.name);let S=new n({uid:x,auth:e,email:f,emailVerified:M,displayName:d,isAnonymous:O,photoURL:y,phoneNumber:p,tenantId:v,stsTokenManager:T,createdAt:E,lastLoginAt:A});return $&&Array.isArray($)&&(S.providerData=$.map(k=>Object.assign({},k))),w&&(S._redirectEventId=w),S}static _fromIdTokenResponse(e,t,r=!1){return m(this,null,function*(){let i=new lh;i.updateFromServerResponse(t);let s=new n({uid:t.localId,auth:e,stsTokenManager:i,isAnonymous:r});return yield Lg(s),s})}static _fromGetAccountInfoResponse(e,t,r){return m(this,null,function*(){let i=t.users[0];xe(i.localId!==void 0,"internal-error");let s=i.providerUserInfo!==void 0?YL(i.providerUserInfo):[],o=!(i.email&&i.passwordHash)&&!s?.length,a=new lh;a.updateFromIdToken(r);let c=new n({uid:i.localId,auth:e,stsTokenManager:a,isAnonymous:o}),l={uid:i.localId,displayName:i.displayName||null,photoURL:i.photoUrl||null,email:i.email||null,emailVerified:i.emailVerified||!1,phoneNumber:i.phoneNumber||null,tenantId:i.tenantId||null,providerData:s,metadata:new dh(i.createdAt,i.lastLoginAt),isAnonymous:!(i.email&&i.passwordHash)&&!s?.length};return Object.assign(c,l),c})}};var kL=new Map;function Ys(n){Xs(n instanceof Function,"Expected a class definition");let e=kL.get(n);return e?(Xs(e instanceof n,"Instance stored in cache mismatched with class"),e):(e=new n,kL.set(n,e),e)}var J7=(()=>{class n{constructor(){this.type="NONE",this.storage={}}_isAvailable(){return m(this,null,function*(){return!0})}_set(t,r){return m(this,null,function*(){this.storage[t]=r})}_get(t){return m(this,null,function*(){let r=this.storage[t];return r===void 0?null:r})}_remove(t){return m(this,null,function*(){delete this.storage[t]})}_addListener(t,r){}_removeListener(t,r){}}return n.type="NONE",n})(),nT=J7;function kg(n,e,t){return`firebase:${n}:${e}:${t}`}var Fg=class n{constructor(e,t,r){this.persistence=e,this.auth=t,this.userKey=r;let{config:i,name:s}=this.auth;this.fullUserKey=kg(this.userKey,i.apiKey,s),this.fullPersistenceKey=kg("persistence",i.apiKey,s),this.boundEventHandler=t._onStorageEvent.bind(t),this.persistence._addListener(this.fullUserKey,this.boundEventHandler)}setCurrentUser(e){return this.persistence._set(this.fullUserKey,e.toJSON())}getCurrentUser(){return m(this,null,function*(){let e=yield this.persistence._get(this.fullUserKey);return e?Hl._fromJSON(this.auth,e):null})}removeCurrentUser(){return this.persistence._remove(this.fullUserKey)}savePersistenceForRedirect(){return this.persistence._set(this.fullPersistenceKey,this.persistence.type)}setPersistence(e){return m(this,null,function*(){if(this.persistence===e)return;let t=yield this.getCurrentUser();if(yield this.removeCurrentUser(),this.persistence=e,t)return this.setCurrentUser(t)})}delete(){this.persistence._removeListener(this.fullUserKey,this.boundEventHandler)}static create(e,t,r="authUser"){return m(this,null,function*(){if(!t.length)return new n(Ys(nT),e,r);let i=(yield Promise.all(t.map(l=>m(this,null,function*(){if(yield l._isAvailable())return l})))).filter(l=>l),s=i[0]||Ys(nT),o=kg(r,e.config.apiKey,e.name),a=null;for(let l of t)try{let u=yield l._get(o);if(u){let d=Hl._fromJSON(e,u);l!==s&&(a=d),s=l;break}}catch{}let c=i.filter(l=>l._shouldAllowMigration);return!s._shouldAllowMigration||!c.length?new n(s,e,r):(s=c[0],a&&(yield s._set(o,a.toJSON())),yield Promise.all(t.map(l=>m(this,null,function*(){if(l!==s)try{yield l._remove(o)}catch{}}))),new n(s,e,r))})}};function PL(n){let e=n.toLowerCase();if(e.includes("opera/")||e.includes("opr/")||e.includes("opios/"))return"Opera";if(JL(e))return"IEMobile";if(e.includes("msie")||e.includes("trident/"))return"IE";if(e.includes("edge/"))return"Edge";if(XL(e))return"Firefox";if(e.includes("silk/"))return"Silk";if(tF(e))return"Blackberry";if(nF(e))return"Webos";if(QL(e))return"Safari";if((e.includes("chrome/")||ZL(e))&&!e.includes("edge/"))return"Chrome";if(eF(e))return"Android";{let t=/([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/,r=n.match(t);if(r?.length===2)return r[1]}return"Other"}function XL(n=pn()){return/firefox\//i.test(n)}function QL(n=pn()){let e=n.toLowerCase();return e.includes("safari/")&&!e.includes("chrome/")&&!e.includes("crios/")&&!e.includes("android")}function ZL(n=pn()){return/crios\//i.test(n)}function JL(n=pn()){return/iemobile/i.test(n)}function eF(n=pn()){return/android/i.test(n)}function tF(n=pn()){return/blackberry/i.test(n)}function nF(n=pn()){return/webos/i.test(n)}function bT(n=pn()){return/iphone|ipad|ipod/i.test(n)||/macintosh/i.test(n)&&/mobile/i.test(n)}function eY(n=pn()){var e;return bT(n)&&!!(!((e=window.navigator)===null||e===void 0)&&e.standalone)}function tY(){return cL()&&document.documentMode===10}function rF(n=pn()){return bT(n)||eF(n)||nF(n)||tF(n)||/windows phone/i.test(n)||JL(n)}function iF(n,e=[]){let t;switch(n){case"Browser":t=PL(pn());break;case"Worker":t=`${PL(pn())}-${n}`;break;default:t=n}let r=e.length?e.join(","):"FirebaseCore-web";return`${t}/JsCore/${ts}/${r}`}var rT=class{constructor(e){this.auth=e,this.queue=[]}pushCallback(e,t){let r=s=>new Promise((o,a)=>{try{let c=e(s);o(c)}catch(c){a(c)}});r.onAbort=t,this.queue.push(r);let i=this.queue.length-1;return()=>{this.queue[i]=()=>Promise.resolve()}}runMiddleware(e){return m(this,null,function*(){if(this.auth.currentUser===e)return;let t=[];try{for(let r of this.queue)yield r(e),r.onAbort&&t.push(r.onAbort)}catch(r){t.reverse();for(let i of t)try{i()}catch{}throw this.auth._errorFactory.create("login-blocked",{originalMessage:r?.message})}})}};function nY(t){return m(this,arguments,function*(n,e={}){return ql(n,"GET","/v2/passwordPolicy",gT(n,e))})}var rY=6,iT=class{constructor(e){var t,r,i,s;let o=e.customStrengthOptions;this.customStrengthOptions={},this.customStrengthOptions.minPasswordLength=(t=o.minPasswordLength)!==null&&t!==void 0?t:rY,o.maxPasswordLength&&(this.customStrengthOptions.maxPasswordLength=o.maxPasswordLength),o.containsLowercaseCharacter!==void 0&&(this.customStrengthOptions.containsLowercaseLetter=o.containsLowercaseCharacter),o.containsUppercaseCharacter!==void 0&&(this.customStrengthOptions.containsUppercaseLetter=o.containsUppercaseCharacter),o.containsNumericCharacter!==void 0&&(this.customStrengthOptions.containsNumericCharacter=o.containsNumericCharacter),o.containsNonAlphanumericCharacter!==void 0&&(this.customStrengthOptions.containsNonAlphanumericCharacter=o.containsNonAlphanumericCharacter),this.enforcementState=e.enforcementState,this.enforcementState==="ENFORCEMENT_STATE_UNSPECIFIED"&&(this.enforcementState="OFF"),this.allowedNonAlphanumericCharacters=(i=(r=e.allowedNonAlphanumericCharacters)===null||r===void 0?void 0:r.join(""))!==null&&i!==void 0?i:"",this.forceUpgradeOnSignin=(s=e.forceUpgradeOnSignin)!==null&&s!==void 0?s:!1,this.schemaVersion=e.schemaVersion}validatePassword(e){var t,r,i,s,o,a;let c={isValid:!0,passwordPolicy:this};return this.validatePasswordLengthOptions(e,c),this.validatePasswordCharacterOptions(e,c),c.isValid&&(c.isValid=(t=c.meetsMinPasswordLength)!==null&&t!==void 0?t:!0),c.isValid&&(c.isValid=(r=c.meetsMaxPasswordLength)!==null&&r!==void 0?r:!0),c.isValid&&(c.isValid=(i=c.containsLowercaseLetter)!==null&&i!==void 0?i:!0),c.isValid&&(c.isValid=(s=c.containsUppercaseLetter)!==null&&s!==void 0?s:!0),c.isValid&&(c.isValid=(o=c.containsNumericCharacter)!==null&&o!==void 0?o:!0),c.isValid&&(c.isValid=(a=c.containsNonAlphanumericCharacter)!==null&&a!==void 0?a:!0),c}validatePasswordLengthOptions(e,t){let r=this.customStrengthOptions.minPasswordLength,i=this.customStrengthOptions.maxPasswordLength;r&&(t.meetsMinPasswordLength=e.length>=r),i&&(t.meetsMaxPasswordLength=e.length<=i)}validatePasswordCharacterOptions(e,t){this.updatePasswordCharacterOptionsStatuses(t,!1,!1,!1,!1);let r;for(let i=0;i<e.length;i++)r=e.charAt(i),this.updatePasswordCharacterOptionsStatuses(t,r>="a"&&r<="z",r>="A"&&r<="Z",r>="0"&&r<="9",this.allowedNonAlphanumericCharacters.includes(r))}updatePasswordCharacterOptionsStatuses(e,t,r,i,s){this.customStrengthOptions.containsLowercaseLetter&&(e.containsLowercaseLetter||(e.containsLowercaseLetter=t)),this.customStrengthOptions.containsUppercaseLetter&&(e.containsUppercaseLetter||(e.containsUppercaseLetter=r)),this.customStrengthOptions.containsNumericCharacter&&(e.containsNumericCharacter||(e.containsNumericCharacter=i)),this.customStrengthOptions.containsNonAlphanumericCharacter&&(e.containsNonAlphanumericCharacter||(e.containsNonAlphanumericCharacter=s))}};var sT=class{constructor(e,t,r,i){this.app=e,this.heartbeatServiceProvider=t,this.appCheckServiceProvider=r,this.config=i,this.currentUser=null,this.emulatorConfig=null,this.operations=Promise.resolve(),this.authStateSubscription=new Vg(this),this.idTokenSubscription=new Vg(this),this.beforeStateQueue=new rT(this),this.redirectUser=null,this.isProactiveRefreshEnabled=!1,this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION=1,this._canInitEmulator=!0,this._isInitialized=!1,this._deleted=!1,this._initializationPromise=null,this._popupRedirectResolver=null,this._errorFactory=zL,this._agentRecaptchaConfig=null,this._tenantRecaptchaConfigs={},this._projectPasswordPolicy=null,this._tenantPasswordPolicies={},this.lastNotifiedUid=void 0,this.languageCode=null,this.tenantId=null,this.settings={appVerificationDisabledForTesting:!1},this.frameworks=[],this.name=e.name,this.clientVersion=i.sdkClientVersion}_initializeWithPersistence(e,t){return t&&(this._popupRedirectResolver=Ys(t)),this._initializationPromise=this.queue(()=>m(this,null,function*(){var r,i;if(!this._deleted&&(this.persistenceManager=yield Fg.create(this,e),!this._deleted)){if(!((r=this._popupRedirectResolver)===null||r===void 0)&&r._shouldInitProactively)try{yield this._popupRedirectResolver._initialize(this)}catch{}yield this.initializeCurrentUser(t),this.lastNotifiedUid=((i=this.currentUser)===null||i===void 0?void 0:i.uid)||null,!this._deleted&&(this._isInitialized=!0)}})),this._initializationPromise}_onStorageEvent(){return m(this,null,function*(){if(this._deleted)return;let e=yield this.assertedPersistence.getCurrentUser();if(!(!this.currentUser&&!e)){if(this.currentUser&&e&&this.currentUser.uid===e.uid){this._currentUser._assign(e),yield this.currentUser.getIdToken();return}yield this._updateCurrentUser(e,!0)}})}initializeCurrentUserFromIdToken(e){return m(this,null,function*(){try{let t=yield KL(this,{idToken:e}),r=yield Hl._fromGetAccountInfoResponse(this,t,e);yield this.directlySetCurrentUser(r)}catch(t){console.warn("FirebaseServerApp could not login user with provided authIdToken: ",t),yield this.directlySetCurrentUser(null)}})}initializeCurrentUser(e){return m(this,null,function*(){var t;if(es(this.app)){let o=this.app.settings.authIdToken;return o?new Promise(a=>{setTimeout(()=>this.initializeCurrentUserFromIdToken(o).then(a,a))}):this.directlySetCurrentUser(null)}let r=yield this.assertedPersistence.getCurrentUser(),i=r,s=!1;if(e&&this.config.authDomain){yield this.getOrInitRedirectPersistenceManager();let o=(t=this.redirectUser)===null||t===void 0?void 0:t._redirectEventId,a=i?._redirectEventId,c=yield this.tryRedirectSignIn(e);(!o||o===a)&&c?.user&&(i=c.user,s=!0)}if(!i)return this.directlySetCurrentUser(null);if(!i._redirectEventId){if(s)try{yield this.beforeStateQueue.runMiddleware(i)}catch(o){i=r,this._popupRedirectResolver._overrideRedirectResult(this,()=>Promise.reject(o))}return i?this.reloadAndSetCurrentUserOrClear(i):this.directlySetCurrentUser(null)}return xe(this._popupRedirectResolver,this,"argument-error"),yield this.getOrInitRedirectPersistenceManager(),this.redirectUser&&this.redirectUser._redirectEventId===i._redirectEventId?this.directlySetCurrentUser(i):this.reloadAndSetCurrentUserOrClear(i)})}tryRedirectSignIn(e){return m(this,null,function*(){let t=null;try{t=yield this._popupRedirectResolver._completeRedirectFn(this,e,!0)}catch{yield this._setRedirectUser(null)}return t})}reloadAndSetCurrentUserOrClear(e){return m(this,null,function*(){try{yield Lg(e)}catch(t){if(t?.code!=="auth/network-request-failed")return this.directlySetCurrentUser(null)}return this.directlySetCurrentUser(e)})}useDeviceLanguage(){this.languageCode=q7()}_delete(){return m(this,null,function*(){this._deleted=!0})}updateCurrentUser(e){return m(this,null,function*(){if(es(this.app))return Promise.reject(ec(this));let t=e?_t(e):null;return t&&xe(t.auth.config.apiKey===this.config.apiKey,this,"invalid-user-token"),this._updateCurrentUser(t&&t._clone(this))})}_updateCurrentUser(e,t=!1){return m(this,null,function*(){if(!this._deleted)return e&&xe(this.tenantId===e.tenantId,this,"tenant-id-mismatch"),t||(yield this.beforeStateQueue.runMiddleware(e)),this.queue(()=>m(this,null,function*(){yield this.directlySetCurrentUser(e),this.notifyAuthListeners()}))})}signOut(){return m(this,null,function*(){return es(this.app)?Promise.reject(ec(this)):(yield this.beforeStateQueue.runMiddleware(null),(this.redirectPersistenceManager||this._popupRedirectResolver)&&(yield this._setRedirectUser(null)),this._updateCurrentUser(null,!0))})}setPersistence(e){return es(this.app)?Promise.reject(ec(this)):this.queue(()=>m(this,null,function*(){yield this.assertedPersistence.setPersistence(Ys(e))}))}_getRecaptchaConfig(){return this.tenantId==null?this._agentRecaptchaConfig:this._tenantRecaptchaConfigs[this.tenantId]}validatePassword(e){return m(this,null,function*(){this._getPasswordPolicyInternal()||(yield this._updatePasswordPolicy());let t=this._getPasswordPolicyInternal();return t.schemaVersion!==this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION?Promise.reject(this._errorFactory.create("unsupported-password-policy-schema-version",{})):t.validatePassword(e)})}_getPasswordPolicyInternal(){return this.tenantId===null?this._projectPasswordPolicy:this._tenantPasswordPolicies[this.tenantId]}_updatePasswordPolicy(){return m(this,null,function*(){let e=yield nY(this),t=new iT(e);this.tenantId===null?this._projectPasswordPolicy=t:this._tenantPasswordPolicies[this.tenantId]=t})}_getPersistence(){return this.assertedPersistence.persistence.type}_updateErrorMap(e){this._errorFactory=new qs("auth","Firebase",e())}onAuthStateChanged(e,t,r){return this.registerStateListener(this.authStateSubscription,e,t,r)}beforeAuthStateChanged(e,t){return this.beforeStateQueue.pushCallback(e,t)}onIdTokenChanged(e,t,r){return this.registerStateListener(this.idTokenSubscription,e,t,r)}authStateReady(){return new Promise((e,t)=>{if(this.currentUser)e();else{let r=this.onAuthStateChanged(()=>{r(),e()},t)}})}revokeAccessToken(e){return m(this,null,function*(){if(this.currentUser){let t=yield this.currentUser.getIdToken(),r={providerId:"apple.com",tokenType:"ACCESS_TOKEN",token:e,idToken:t};this.tenantId!=null&&(r.tenantId=this.tenantId),yield Z7(this,r)}})}toJSON(){var e;return{apiKey:this.config.apiKey,authDomain:this.config.authDomain,appName:this.name,currentUser:(e=this._currentUser)===null||e===void 0?void 0:e.toJSON()}}_setRedirectUser(e,t){return m(this,null,function*(){let r=yield this.getOrInitRedirectPersistenceManager(t);return e===null?r.removeCurrentUser():r.setCurrentUser(e)})}getOrInitRedirectPersistenceManager(e){return m(this,null,function*(){if(!this.redirectPersistenceManager){let t=e&&Ys(e)||this._popupRedirectResolver;xe(t,this,"argument-error"),this.redirectPersistenceManager=yield Fg.create(this,[Ys(t._redirectPersistence)],"redirectUser"),this.redirectUser=yield this.redirectPersistenceManager.getCurrentUser()}return this.redirectPersistenceManager})}_redirectUserForId(e){return m(this,null,function*(){var t,r;return this._isInitialized&&(yield this.queue(()=>m(this,null,function*(){}))),((t=this._currentUser)===null||t===void 0?void 0:t._redirectEventId)===e?this._currentUser:((r=this.redirectUser)===null||r===void 0?void 0:r._redirectEventId)===e?this.redirectUser:null})}_persistUserIfCurrent(e){return m(this,null,function*(){if(e===this.currentUser)return this.queue(()=>m(this,null,function*(){return this.directlySetCurrentUser(e)}))})}_notifyListenersIfCurrent(e){e===this.currentUser&&this.notifyAuthListeners()}_key(){return`${this.config.authDomain}:${this.config.apiKey}:${this.name}`}_startProactiveRefresh(){this.isProactiveRefreshEnabled=!0,this.currentUser&&this._currentUser._startProactiveRefresh()}_stopProactiveRefresh(){this.isProactiveRefreshEnabled=!1,this.currentUser&&this._currentUser._stopProactiveRefresh()}get _currentUser(){return this.currentUser}notifyAuthListeners(){var e,t;if(!this._isInitialized)return;this.idTokenSubscription.next(this.currentUser);let r=(t=(e=this.currentUser)===null||e===void 0?void 0:e.uid)!==null&&t!==void 0?t:null;this.lastNotifiedUid!==r&&(this.lastNotifiedUid=r,this.authStateSubscription.next(this.currentUser))}registerStateListener(e,t,r,i){if(this._deleted)return()=>{};let s=typeof t=="function"?t:t.next.bind(t),o=!1,a=this._isInitialized?Promise.resolve():this._initializationPromise;if(xe(a,this,"internal-error"),a.then(()=>{o||s(this.currentUser)}),typeof t=="function"){let c=e.addObserver(t,r,i);return()=>{o=!0,c()}}else{let c=e.addObserver(t);return()=>{o=!0,c()}}}directlySetCurrentUser(e){return m(this,null,function*(){this.currentUser&&this.currentUser!==e&&this._currentUser._stopProactiveRefresh(),e&&this.isProactiveRefreshEnabled&&e._startProactiveRefresh(),this.currentUser=e,e?yield this.assertedPersistence.setCurrentUser(e):yield this.assertedPersistence.removeCurrentUser()})}queue(e){return this.operations=this.operations.then(e,e),this.operations}get assertedPersistence(){return xe(this.persistenceManager,this,"internal-error"),this.persistenceManager}_logFramework(e){!e||this.frameworks.includes(e)||(this.frameworks.push(e),this.frameworks.sort(),this.clientVersion=iF(this.config.clientPlatform,this._getFrameworks()))}_getFrameworks(){return this.frameworks}_getAdditionalHeaders(){return m(this,null,function*(){var e;let t={"X-Client-Version":this.clientVersion};this.app.options.appId&&(t["X-Firebase-gmpid"]=this.app.options.appId);let r=yield(e=this.heartbeatServiceProvider.getImmediate({optional:!0}))===null||e===void 0?void 0:e.getHeartbeatsHeader();r&&(t["X-Firebase-Client"]=r);let i=yield this._getAppCheckToken();return i&&(t["X-Firebase-AppCheck"]=i),t})}_getAppCheckToken(){return m(this,null,function*(){var e;let t=yield(e=this.appCheckServiceProvider.getImmediate({optional:!0}))===null||e===void 0?void 0:e.getToken();return t?.error&&$7(`Error while retrieving App Check token: ${t.error}`),t?.token})}};function Gg(n){return _t(n)}var Vg=class{constructor(e){this.auth=e,this.observer=null,this.addObserver=hL(t=>this.observer=t)}get next(){return xe(this.observer,this.auth,"internal-error"),this.observer.next.bind(this.observer)}};var wT={loadJS(){return m(this,null,function*(){throw new Error("Unable to load external scripts")})},recaptchaV2Script:"",recaptchaEnterpriseScript:"",gapiScript:""};function iY(n){wT=n}function sY(n){return wT.loadJS(n)}function oY(){return wT.gapiScript}function sF(n){return`__${n}${Math.floor(Math.random()*1e6)}`}function ET(n,e){let t=Gs(n,"auth");if(t.isInitialized()){let i=t.getImmediate(),s=t.getOptions();if(Qa(s,e??{}))return i;os(i,"already-initialized")}return t.initialize({options:e})}function aY(n,e){let t=e?.persistence||[],r=(Array.isArray(t)?t:[t]).map(Ys);e?.errorMap&&n._updateErrorMap(e.errorMap),n._initializeWithPersistence(r,e?.popupRedirectResolver)}function Wg(n,e,t){let r=Gg(n);xe(r._canInitEmulator,r,"emulator-config-failed"),xe(/^https?:\/\//.test(e),r,"invali
9d-emulator-scheme");let i=!!t?.disableWarnings,s=oF(e),{host:o,port:a}=cY(e),c=a===null?"":`:${a}`;r.config.emulator={url:`${s}//${o}${c}/`},r.settings.appVerificationDisabledForTesting=!0,r.emulatorConfig=Object.freeze({host:o,port:a,protocol:s.replace(":",""),options:Object.freeze({disableWarnings:i})}),i||lY()}function oF(n){let e=n.indexOf(":");return e<0?"":n.substr(0,e+1)}function cY(n){let e=oF(n),t=/(\/\/)?([^?#/]+)/.exec(n.substr(e.length));if(!t)return{host:"",port:null};let r=t[2].split("@").pop()||"",i=/^(\[[^\]]+\])(:|$)/.exec(r);if(i){let s=i[1];return{host:s,port:ML(r.substr(s.length+1))}}else{let[s,o]=r.split(":");return{host:s,port:ML(o)}}}function ML(n){if(!n)return null;let e=Number(n);return isNaN(e)?null:e}function lY(){function n(){let e=document.createElement("p"),t=e.style;e.innerText="Running in emulator mode. Do not use with production credentials.",t.position="fixed",t.width="100%",t.backgroundColor="#ffffff",t.border=".1em solid #000000",t.color="#b50000",t.bottom="0px",t.left="0px",t.margin="0px",t.zIndex="10000",t.textAlign="center",e.classList.add("firebase-emulator-warning"),document.body.appendChild(e)}typeof console<"u"&&typeof console.info=="function"&&console.info("WARNING: You are using the Auth Emulator, which is intended for local testing only. Do not use with production credentials."),typeof window<"u"&&typeof document<"u"&&(document.readyState==="loading"?window.addEventListener("DOMContentLoaded",n):n())}var hh=class{constructor(e,t){this.providerId=e,this.signInMethod=t}toJSON(){return Ks("not implemented")}_getIdTokenResponse(e){return Ks("not implemented")}_linkToIdToken(e,t){return Ks("not implemented")}_getReauthenticationResolver(e){return Ks("not implemented")}};function Bl(n,e){return m(this,null,function*(){return W7(n,"POST","/v1/accounts:signInWithIdp",gT(n,e))})}var uY="http://localhost",jg=class n extends hh{constructor(){super(...arguments),this.pendingToken=null}static _fromParams(e){let t=new n(e.providerId,e.signInMethod);return e.idToken||e.accessToken?(e.idToken&&(t.idToken=e.idToken),e.accessToken&&(t.accessToken=e.accessToken),e.nonce&&!e.pendingToken&&(t.nonce=e.nonce),e.pendingToken&&(t.pendingToken=e.pendingToken)):e.oauthToken&&e.oauthTokenSecret?(t.accessToken=e.oauthToken,t.secret=e.oauthTokenSecret):os("argument-error"),t}toJSON(){return{idToken:this.idToken,accessToken:this.accessToken,secret:this.secret,n
9once:this.nonce,pendingToken:this.pendingToken,providerId:this.providerId,signInMethod:this.signInMethod}}static fromJSON(e){let t=typeof e=="string"?JSON.parse(e):e,{providerId:r,signInMethod:i}=t,s=Cp(t,["providerId","signInMethod"]);if(!r||!i)return null;let o=new n(r,i);return o.idToken=s.idToken||void 0,o.accessToken=s.accessToken||void 0,o.secret=s.secret,o.nonce=s.nonce,o.pendingToken=s.pendingToken||null,o}_getIdTokenResponse(e){let t=this.buildRequest();return Bl(e,t)}_linkToIdToken(e,t){let r=this.buildRequest();return r.idToken=t,Bl(e,r)}_getReauthenticationResolver(e){let t=this.buildRequest();return t.autoCreate=!1,Bl(e,t)}buildRequest(){let e={requestUri:uY,returnSecureToken:!0};if(this.pendingToken)e.pendingToken=this.pendingToken;else{let t={};this.idToken&&(t.id_token=this.idToken),this.accessToken&&(t.access_token=this.accessToken),this.secret&&(t.oauth_token_secret=this.secret),t.providerId=this.providerId,this.nonce&&!this.pendingToken&&(t.nonce=this.nonce),e.postBody=$l(t)}return e}};var fh=class{constructor(e){this.providerId=e,this.defaultLanguageCode=null,this.customParameters={}}setDefaultLanguage(e){this.defaultLanguageCode=e}setCustomParameters(e){return this.customParameters=e,this}getCustomParameters(){return this.customParameters}};var $g=class extends fh{constructor(){super(...arguments),this.scopes=[]}addScope(e){return this.scopes.includes(e)||this.scopes.push(e),this}getScopes(){return[...this.scopes]}};var IT=(()=>{class n extends $g{constructor(){super("google.com"),this.addScope("profile")}static credential(t,r){return jg._fromParams({providerId:n.PROVIDER_ID,signInMethod:n.GOOGLE_SIGN_IN_METHOD,idToken:t,accessToken:r})}static credentialFromResult(t){return n.credentialFromTaggedObject(t)}static credentialFromError(t){return n.credentialFromTaggedObject(t.customData||{})}static credentialFromTaggedObject({_tokenResponse:t}){if(!t)return null;let{oauthIdToken:r,oauthAccessToken:i}=t;if(!r&&!i)return null;try{return n.credential(r,i)}catch{return null}}}n.GOOGLE_SIGN_IN_METHOD="google.com",n.PROVIDER_ID="google.com";return n})();var ph=class n{constructor(e){this.user=e.user,this.providerId=e.providerId,this._tokenResponse=e._tokenResponse,this.operationType=e.operationType}static _fromIdTokenResponse(e,t,r,i=!1){return m(this,null,function*(){let s=yield Hl._fromIdTokenResponse(e,r,i),o=NL(r);return new n({user:s,providerId:o,_tokenResponse:r,operationType:t})})}static _forOperation(e,t,r){return m(this,null,function*(){yield e._updateTokensIfNecessary(r,!0);let i=NL(r);return new n({user:e,providerId:i,_tokenResponse:r,operationType:t})})}};function NL(n){return n.providerId?n.providerId:"phoneNumber"in n?"phone":null}
9var oT=class n extends In{constructor(e,t,r,i){var s;super(t.code,t.message),this.operationType=r,this.user=i,Object.setPrototypeOf(this,n.prototype),this.customData={appName:e.name,tenantId:(s=e.tenantId)!==null&&s!==void 0?s:void 0,_serverResponse:t.customData._serverResponse,operationType:r}}static _fromErrorAndOperation(e,t,r,i){return new n(e,t,r,i)}};function aF(n,e,t,r){return(e==="reauthenticate"?t._getReauthenticationResolver(n):t._getIdTokenResponse(n)).catch(s=>{throw s.code==="auth/multi-factor-auth-required"?oT._fromErrorAndOperation(n,s,e,r):s})}function dY(n,e,t=!1){return m(this,null,function*(){let r=yield uh(n,e._linkToIdToken(n.auth,yield n.getIdToken()),t);return ph._forOperation(n,"link",r)})}function hY(n,e,t=!1){return m(this,null,function*(){let{auth:r}=n;if(es(r.app))return Promise.reject(ec(r));let i="reauthenticate";try{let s=yield uh(n,aF(r,i,e,n),t);xe(s.idToken,r,"internal-error");let o=_T(s.idToken);xe(o,r,"internal-error");let{sub:a}=o;return xe(n.uid===a,r,"user-mismatch"),ph._forOperation(n,i,s)}catch(s){throw s?.code==="auth/user-not-found"&&os(r,"user-mismatch"),s}})}function fY(n,e,t=!1){return m(this,null,function*(){if(es(n.app))return Promise.reject(ec(n));let r="signIn",i=yield aF(n,r,e),s=yield ph._fromIdTokenResponse(n,r,i);return t||(yield n._updateCurrentUser(s.user)),s})}function TT(n,e,t,r){return _t(n).onIdTokenChanged(e,t,r)}function AT(n,e,t){return _t(n).beforeAuthStateChanged(e,t)}function CT(n,e,t,r){return _t(n).onAuthStateChanged(e,t,r)}function ST(n){return _t(n).signOut()}var Ug="__sak";var Bg=class{constructor(e,t){this.storageRetriever=e,this.type=t}_isAvailable(){try{return this.storage?(this.storage.setItem(Ug,"1"),this.storage.removeItem(Ug),Promise.resolve(!0)):Promise.resolve(!1)}catch{return Promise.resolve(!1)}}_set(e,t){return this.storage.setItem(e,JSON.stringify(t)),Promise.resolve()}_get(e){let t=this.storage.getItem(e);return Promise.resolve(t?JSON.parse(t):null)}_remove(e){return this.storage.removeItem(e),Promise.resolve()}get storage(){return this.storageRetriever()}};var pY=1e3,mY=10,gY=(()=>{class n extends Bg{constructor(){super(()=>window.localStorage,"LOCAL"),this.boundEventHandler=(t,r)=>this.onStorageEvent(t,r),this.listeners={},this.localCache={},this.pollTimer=null,this.fallbackToPolling=rF(),this._shouldAllowMigration=!0}forAllChangedKeys(t){for(let r of Object.keys(this.listeners)){let i=this.storage.getItem(r),s=this.localCache[r];i!==s&&t(r,s,i)}}onStorageEvent(t,r=!1){if(!t.key){this.forAllChangedKeys((a,c,l)=>{this.notifyListeners(a,l)});return}let i=t.key;r?this.detachListener():this.stopPolling();let s=()=>{let a=this.storage.getItem(i);!r&&this.localCache[i]===a||this.notifyListeners(i,a)},o=this.storage.getItem(i);tY()&&o!==t.newValue&&t.newValue!==t.oldValue?setTimeout(s,mY):s()}notifyListeners(t,r){this.localCache[t]=r;let i=this.listeners[t];if(i)for(let s of Array.from(i))s(r&&JSON.parse(r))}startPolling(){this.stopPolling(),this.pollTimer=setInterval(()=>{this.forAllChangedKeys((t,r,i)=>{this.onStorageEvent(new StorageEvent("storage",{key:t,oldValue:r,newValue:i}),!0)})},pY)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}attachListener(){window.addEventListener("storage",this.boundEventHandler)}detachListener(){window.removeEventListener("storage",this.boundEventHandler)}_addListener(t,r){Object.keys(this.listeners).length===0&&(this.fallbackToPolling?this.startPolling():this.attachListener()),this.listeners[t]||(this.listeners[t]=new Set,this.localCache[t]=this.storage.getItem(t)),this.listeners[t].add(r)}_removeListener(t,r){this.listeners[t]&&(this.listeners[t].delete(r),this.listeners[t].size===0&&delete this.listeners[t]),Object.keys(this.listeners).length===0&&(this.detachListener(),this.stopPolling())}_set(t,r){return m(this,null,function*(){yield dn(n.prototype,this,"_set").call(this,t,r),this.localCache[t]=JSON.stringify(r)})}_get(t){return m(this,null,function*(){let r=yield dn(n.prototype,this,"_get").call(this,t);return this.localCache[t]=JSON.stringify(r),r})}_remove(t){return m(this,null,function*(){yield dn(n.prototype,this,"_remove").call(this,t),delete this.localCache[t]})}}return n.type="LOCAL",n})(),cF=gY;var yY=(()=>{class n extends Bg{constructor(){super(()=>window.sessionStorage,"SESSION")}_addListener(t,r){}_removeListener(t,r){}}return n.type="SESSION",n})(),xT=yY;function _Y(n){return Promise.all(n.map(e=>m(this,null,function*(){try{return{fulfilled:!0,value:yield e}}catch(t){return{fulfilled:!1,reason:t}}})))}var vY=(()=>{class n{constructor(t){this.eventTarget=t,this.handlersMap={},this.boundEventHandler=this.handleEvent.bind(this)}static _getInstance(t){let r=this.receivers.find(s=>s.isListeningto(t));if(r)return r;let i=new n(t);return this.receivers.push(i),i}isListeningto(t){return this.eventTarget===t}handleEvent(t){return m(this,null,function*(){let r=t,{eventId:i,eventType:s,data:o}=r.data,a=this.handlersMap[s];if(!a?.size)return;r.ports[0].postMessage({status:"ack",eventId:i,eventType:s});let c=Array.from(a).map(u=>m(this,null,function*(){return u(r.origin,o)})),l=yield _Y(c);r.ports[0].postMessage({status:"done",eventId:i,eventType:s,response:l})})}_subscribe(t,r){Object.keys(this.handlersMap).length===0&&this.eventTarget.addEventListener("message",this.boundEventHandler),this.handlersMap[t]||(this.handlersMap[t]=new Set),this.handlersMap[t].add(r)}_unsubscribe(t,r){this.handlersMap[t]&&r&&this.handlersMap[t].delete(r),(!r||this.handlersMap[t].size===0)&&delete this.handlersMap[t],Object.keys(this.handlersMap).length===0&&this.eventTarget.removeEventListener("message",this.boundEventHandler)}}n.receivers=[];return n})();function DT(n="",e=10){let t="";for(let r=0;r<e;r++)t+=Math.floor(Math.random()*10);return n+t}var aT=class{constructor(e){this.target=e,this.handlers=new Set}removeMessageHandler(e){e.messageChannel&&(e.messageChannel.port1.removeEventListener("message",e.onMessage),e.messageChannel.port1.close()),this.handlers.delete(e)}_send(e,t,r=50){return m(this,null,function*(){let i=typeof MessageChannel<"u"?new MessageChannel:null;if(!i)throw new Error("connection_unavailable");let s,o;return new Promise((a,c)=>{let l=DT("",20);i.port1.start();let u=setTimeout(()=>{c(new Error("unsupported_event"))},r);o={messageChannel:i,onMessage(d){let f=d;if(f.data.eventId===l)switch(f.data.status){case"ack":clearTimeout(u),s=setTimeout(()=>{c(new Error("timeout"))},3e3);break;case"done":clearTimeout(s),a(f.data.response);break;default:clearTimeout(u),clearTimeout(s),c(new Error("invalid_response"));break}}},this.handlers.add(o),i.port1.addEventListener("message",o.onMessage),this.target.postMessage({eventType:e,eventId:l,data:t},[i.port2])}).finally(()=>{o&&this.removeMessageHandler(o)})})}};function ss(){return window}
vendor: 6,419 bytes, line 9
9function bY(n){ss().location.href=n}function lF(){return typeof ss().WorkerGlobalScope<"u"&&typeof ss().importScripts=="function"}function wY(){return m(this,null,function*(){if(!navigator?.serviceWorker)return null;try{return(yield navigator.serviceWorker.ready).active}catch{return null}})}function EY(){var n;return((n=navigator?.serviceWorker)===null||n===void 0?void 0:n.controller)||null}function IY(){return lF()?self:null}var uF="firebaseLocalStorageDb",TY=1,Hg="firebaseLocalStorage",dF="fbase_key",nc=class{constructor(e){this.request=e}toPromise(){return new Promise((e,t)=>{this.request.addEventListener("success",()=>{e(this.request.result)}),this.request.addEventListener("error",()=>{t(this.request.error)})})}};function Kg(n,e){return n.transaction([Hg],e?"readwrite":"readonly").objectStore(Hg)}function AY(){let n=indexedDB.deleteDatabase(uF);return new nc(n).toPromise()}function cT(){let n=indexedDB.open(uF,TY);return new Promise((e,t)=>{n.addEventListener("error",()=>{t(n.error)}),n.addEventListener("upgradeneeded",()=>{let r=n.result;try{r.createObjectStore(Hg,{keyPath:dF})}catch(i){t(i)}}),n.addEventListener("success",()=>m(this,null,function*(){let r=n.result;r.objectStoreNames.contains(Hg)?e(r):(r.close(),yield AY(),e(yield cT()))}))})}function OL(n,e,t){return m(this,null,function*(){let r=Kg(n,!0).put({[dF]:e,value:t});return new nc(r).toPromise()})}function CY(n,e){return m(this,null,function*(){let t=Kg(n,!1).get(e),r=yield new nc(t).toPromise();return r===void 0?null:r.value})}function LL(n,e){let t=Kg(n,!0).delete(e);return new nc(t).toPromise()}var SY=800,xY=3,DY=(()=>{class n{constructor(){this.type="LOCAL",this._shouldAllowMigration=!0,this.listeners={},this.localCache={},this.pollTimer=null,this.pendingWrites=0,this.receiver=null,this.sender=null,this.serviceWorkerReceiverAvailable=!1,this.activeServiceWorker=null,this._workerInitializationPromise=this.initializeServiceWorkerMessaging().then(()=>{},()=>{})}_openDb(){return m(this,null,function*(){return this.db?this.db:(this.db=yield cT(),this.db)})}_withRetries(t){return m(this,null,function*(){let r=0;for(;;)try{let i=yield this._openDb();return yield t(i)}catch(i){if(r++>xY)throw i;this.db&&(this.db.close(),this.db=void 0)}})}initializeServiceWorkerMessaging(){return m(this,null,function*(){return lF()?this.initializeReceiver():this.initializeSender()})}initializeReceiver(){return m(this,null,function*(){this.receiver=vY._getInstance(IY()),this.receiver._subscribe("keyChanged",(t,r)=>m(this,null,function*(){return{keyProcessed:(yield this._poll()).includes(r.key)}})),this.receiver._subscribe("ping",(t,r)=>m(this,null,function*(){return["keyChanged"]}))})}initializeSender(){return m(this,null,function*(){var t,r;if(this.activeServiceWorker=yield wY(),!this.activeServiceWorker)return;this.sender=new aT(this.activeServiceWorker);let i=yield this.sender._send("ping",{},800);i&&!((t=i[0])===null||t===void 0)&&t.fulfilled&&!((r=i[0])===null||r===void 0)&&r.value.includes("keyChanged")&&(this.serviceWorkerReceiverAvailable=!0)})}notifyServiceWorker(t){return m(this,null,function*(){if(!(!this.sender||!this.activeServiceWorker||EY()!==this.activeServiceWorker))try{yield this.sender._send("keyChanged",{key:t},this.serviceWorkerReceiverAvailable?800:50)}catch{}})}_isAvailable(){return m(this,null,function*(){try{if(!indexedDB)return!1;let t=yield cT();return yield OL(t,Ug,"1"),yield LL(t,Ug),!0}catch{}return!1})}_withPendingWrite(t){return m(this,null,function*(){this.pendingWrites++;try{yield t()}finally{this.pendingWrites--}})}_set(t,r){return m(this,null,function*(){return this._withPendingWrite(()=>m(this,null,function*(){return yield this._withRetries(i=>OL(i,t,r)),this.localCache[t]=r,this.notifyServiceWorker(t)}))})}_get(t){return m(this,null,function*(){let r=yield this._withRetries(i=>CY(i,t));return this.localCache[t]=r,r})}_remove(t){return m(this,null,function*(){return this._withPendingWrite(()=>m(this,null,function*(){return yield this._withRetries(r=>LL(r,t)),delete this.localCache[t],this.notifyServiceWorker(t)}))})}_poll(){return m(this,null,function*(){let t=yield this._withRetries(s=>{let o=Kg(s,!1).getAll();return new nc(o).toPromise()});if(!t)return[];if(this.pendingWrites!==0)return[];let r=[],i=new Set;if(t.length!==0)for(let{fbase_key:s,value:o}of t)i.add(s),JSON.stringify(this.localCache[s])!==JSON.stringify(o)&&(this.notifyListeners(s,o),r.push(s));for(let s of Object.keys(this.localCache))this.localCache[s]&&!i.has(s)&&(this.notifyListeners(s,null),r.push(s));return r})}notifyListeners(t,r){this.localCache[t]=r;let i=this.listeners[t];if(i)for(let s of Array.from(i))s(r)}startPolling(){this.stopPolling(),this.pollTimer=setInterval(()=>m(this,null,function*(){return this._poll()}),SY)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}_addListener(t,r){Object.keys(this.listeners).length===0&&this.startPolling(),this.listeners[t]||(this.listeners[t]=new Set,this._get(t)),this.listeners[t].add(r)}_removeListener(t,r){this.listeners[t]&&(this.listeners[t].delete(r),this.listeners[t].size===0&&delete this.listeners[t]),Object.keys(this.listeners).length===0&&this.stopPolling()}}return n.type="LOCAL",n})(),hF=DY;var ibe=sF("rcb"),sbe=new tc(3e4,6e4);function fF(n,e){return e?Ys(e):(xe(n._popupRedirectResolver,n,"argument-error"),n._popupRedirectResolver)}var mh=class extends hh{constructor(e){super("custom","custom"),this.params=e}_getIdTokenResponse(e){return Bl(e,this._buildIdpRequest())}_linkToIdToken(e,t){return Bl(e,this._buildIdpRequest(t))}_getReauthenticationResolver(e){return Bl(e,this._buildIdpRequest())}_buildIdpRequest(e){let t={requestUri:this.params.requestUri,sessionId:this.params.sessionId,postBody:this.params.postBody,tenantId:this.params.tenantId,pendingToken:this.params.pendingToken,returnSecureToken:!0,returnIdpCredential:!0};return e&&(t.idToken=e),t}};function RY(n){return fY(n.auth,new mh(n),n.bypassAuthState)}function kY(n){let{auth:e,user:t}=n;return xe(t,e,"internal-error"),hY(t,new mh(n),n.bypassAuthState)}function PY(n){return m(this,null,function*(){let{auth:e,user:t}=n;return xe(t,e,"internal-error"),dY(t,new mh(n),n.bypassAuthState)})}var qg=class{constructor(e,t,r,i,s=!1){this.auth=e,this.resolver=r,this.user=i,this.bypassAuthState=s,this.pendingPromise=null,this.eventManager=null,this.filter=Array.isArray(t)?t:[t]}execute(){return new Promise((e,t)=>
9m(this,null,function*(){this.pendingPromise={resolve:e,reject:t};try{this.eventManager=yield this.resolver._initialize(this.auth),yield this.onExecution(),this.eventManager.registerConsumer(this)}catch(r){this.reject(r)}}))}onAuthEvent(e){return m(this,null,function*(){let{urlResponse:t,sessionId:r,postBody:i,tenantId:s,error:o,type:a}=e;if(o){this.reject(o);return}let c={auth:this.auth,requestUri:t,sessionId:r,tenantId:s||void 0,postBody:i||void 0,user:this.user,bypassAuthState:this.bypassAuthState};try{this.resolve(yield this.getIdpTask(a)(c))}catch(l){this.reject(l)}})}onError(e){this.reject(e)}getIdpTask(e){switch(e){case"signInViaPopup":case"signInViaRedirect":return RY;case"linkViaPopup":case"linkViaRedirect":return PY;case"reauthViaPopup":case"reauthViaRedirect":return kY;default:os(this.auth,"internal-error")}}resolve(e){Xs(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.resolve(e),this.unregisterAndCleanUp()}reject(e){Xs(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.reject(e),this.unregisterAndCleanUp()}unregisterAndCleanUp(){this.eventManager&&this.eventManager.unregisterConsumer(this),this.pendingPromise=null,this.cleanUp()}};var MY=new tc(2e3,1e4);function RT(n,e,t){return m(this,null,function*(){if(es(n.app))return Promise.reject(xi(n,"operation-not-supported-in-this-environment"));let r=Gg(n);U7(n,e,fh);let i=fF(r,t);return new NY(r,"signInViaPopup",e,i).executeNotNull()})}
9var NY=(()=>{class n extends qg{constructor(t,r,i,s,o){super(t,r,s,o),this.provider=i,this.authWindow=null,this.pollId=null,n.currentPopupAction&&n.currentPopupAction.cancel(),n.currentPopupAction=this}executeNotNull(){return m(this,null,function*(){let t=yield this.execute();return xe(t,this.auth,"internal-error"),t})}onExecution(){return m(this,null,function*(){Xs(this.filter.length===1,"Popup operations only handle one event");let t=DT();this.authWindow=yield this.resolver._openPopup(this.auth,this.provider,this.filter[0],t),this.authWindow.associatedEvent=t,this.resolver._originValidation(this.auth).catch(r=>{this.reject(r)}),this.resolver._isIframeWebStorageSupported(this.auth,r=>{r||this.reject(xi(this.auth,"web-storage-unsupported"))}),this.pollUserCancellation()})}get eventId(){var t;return((t=this.authWindow)===null||t===void 0?void 0:t.associatedEvent)||null}cancel(){this.reject(xi(this.auth,"cancelled-popup-request"))}cleanUp(){this.authWindow&&this.authWindow.close(),this.pollId&&window.clearTimeout(this.pollId),this.authWindow=null,this.pollId=null,n.currentPopupAction=null}pollUserCancellation(){let t=()=>{var r,i;if(!((i=(r=this.authWindow)===null||r===void 0?void 0:r.window)===null||i===void 0)&&i.closed){this.pollId=window.setTimeout(()=>{this.pollId=null,this.reject(xi(this.auth,"popup-closed-by-user"))},8e3);return}this.pollId=window.setTimeout(t,MY.get())};t()}}n.currentPopupAction=null;return n})(),OY="pendingRedirect",Pg=new Map,lT=class n extends qg{constructor(e,t,r=!1){super(e,["signInViaRedirect","linkViaRedirect","reauthViaRedirect","unknown"],t,void 0,r),this.eventId=null}execute(){return m(this,null,function*(){let e=Pg.get(this.auth._key());if(!e){try{let r=(yield LY(this.resolver,this.auth))?yield dn(n.prototype,this,"execute").call(this):null;e=()=>Promise.resolve(r)}catch(t){e=()=>Promise.reject(t)}Pg.set(this.auth._key(),e)}return this.bypassAuthState||Pg.set(this.auth._key(),()=>Promise.resolve(null)),e()})}onAuthEvent(e){return m(this,null,function*(){if(e.type==="signInViaRedirect")return dn(n.prototype,this,"onAuthEvent").call(this,e);if(e.type==="unknown"){this.resolve(null);return}if(e.eventId){let t=yield this.auth._redirectUserForId(e.eventId);if(t)return this.user=t,dn(n.prototype,this,"onAuthEvent").call(this,e);this.resolve(null)}})}onExecution(){return m(this,null,function*(){})}cleanUp(){}};function LY(n,e){return m(this,null,function*(){let t=jY(e),r=VY(n);if(!(yield r._isAvailable()))return!1;let i=(yield r._get(t))==="true";return yield r._remove(t),i})}function FY(n,e){Pg.set(n._key(),e)}function VY(n){return Ys(n._redirectPersistence)}function jY(n){return kg(OY,n.config.apiKey,n.name)}function $Y(n,e,t=!1){return m(this,null,function*(){if(es(n.app))return Promise.reject(ec(n));let r=Gg(n),i=fF(r,e),o=yield new lT(r,i,t).execute();return o&&!t&&(delete o.user._redirectEventId,yield r._persistUserIfCurrent(o.user),yield r._setRedirectUser(null,e)),o})}var UY=10*60*1e3,uT=class{constructor(e){this.auth=e,this.cachedEventUids=new Set,this.consumers=new Set,this.queuedRedirectEvent=null,this.hasHandledPotentialRedirect=!1,this.lastProcessedEventTime=Date.now()}registerConsumer(e){this.consumers.add(e),this.queuedRedirectEvent&&this.isEventForConsumer(this.queuedRedirectEvent,e)&&(this.sendToConsumer(this.queuedRedirectEvent,e),this.saveEventToCache(this.queuedRedirectEvent),this.queuedRedirectEvent=null)}unregisterConsumer(e){this.consumers.delete(e)}onEvent(e){if(this.hasEventBeenHandled(e))return!1;let t=!1;return this.consumers.forEach(r=>{this.isEventForConsumer(e,r)&&(t=!0,this.sendToConsumer(e,r),this.saveEventToCache(e))}),this.hasHandledPotentialRedirect||!BY(e)||(this.hasHandledPotentialRedirect=!0,t||(this.queuedRedirectEvent=e,t=!0)),t}sendToConsumer(e,t){var r;if(e.error&&!pF(e)){let i=((r=e.error.code)===null||r===void 0?void 0:r.split("auth/")[1])||"internal-error";t.onError(xi(this.auth,i))}else t.onAuthEvent(e)}isEventForConsumer(e,t){let r=t.eventId===null||!!e.eventId&&e.eventId===t.eventId;return t.filter.includes(e.type)&&r}hasEventBeenHandled(e){return Date.now()-this.lastProcessedEventTime>=UY&&this.cachedEventUids.clear(),this.cachedEventUids.has(FL(e))}saveEventToCache(e){this.cachedEventUids.add(FL(e)),this.lastProcessedEventTime=
9Date.now()}};function FL(n){return[n.type,n.eventId,n.sessionId,n.tenantId].filter(e=>e).join("-")}function pF({type:n,error:e}){return n==="unknown"&&e?.code==="auth/no-auth-event"}function BY(n){switch(n.type){case"signInViaRedirect":case"linkViaRedirect":case"reauthViaRedirect":return!0;case"unknown":return pF(n);default:return!1}}function HY(t){return m(this,arguments,function*(n,e={}){return ql(n,"GET","/v1/projects",e)})}var qY=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,zY=/^https?/;function GY(n){return m(this,null,function*(){if(n.config.emulator)return;let{authorizedDomains:e}=yield HY(n);for(let t of e)try{if(WY(t))return}catch{}os(n,"unauthorized-domain")})}function WY(n){let e=JI(),{protocol:t,hostname:r}=new URL(e);if(n.startsWith("chrome-extension://")){let o=new URL(n);return o.hostname===""&&r===""?t==="chrome-extension:"&&n.replace("chrome-extension://","")===e.replace("chrome-extension://",""):t==="chrome-extension:"&&o.hostname===r}if(!zY.test(t))return!1;if(qY.test(n))return r===n;let i=n.replace(/\./g,"\\.");return new RegExp("^(.+\\."+i+"|"+i+")$","i").test(r)}var KY=new tc(3e4,6e4);function VL(){let n=ss().___jsl;if(n?.H){for(let e of Object.keys(n.H))if(n.H[e].r=n.H[e].r||[],n.H[e].L=n.H[e].L||[],n.H[e].r=[...n.H[e].L],n.CP)for(let t=0;t<n.CP.length;t++)n.CP[t]=null}}function YY(n){return new Promise((e,t)=>{var r,i,s;function o(){VL(),gapi.load("gapi.iframes",{callback:()=>{e(gapi.iframes.getContext())},ontimeout:()=>{VL(),t(xi(n,"network-request-failed"))},timeout:KY.get()})}if(!((i=(r=ss().gapi)===null||r===void 0?void 0:r.iframes)===null||i===void 0)&&i.Iframe)e(gapi.iframes.getContext());else if(!((s=ss().gapi)===null||s===void 0)&&s.load)o();else{let a=sF("iframefcb");return ss()[a]=()=>{gapi.load?o():t(xi(n,"network-request-failed"))},sY(`${oY()}?onload=${a}`).catch(c=>t(c))}}).catch(e=>{throw Mg=null,e})}var Mg=null;function XY(n){return Mg=Mg||YY(n),Mg}var QY=new tc(5e3,15e3),ZY="__/auth/iframe",JY="emulator/auth/iframe",eX={style:{position:"absolute",top:"-100px",width:"1px",height:"1px"},"aria-hidden":"true",tabindex:"-1"},tX=new Map([["identitytoolkit.googleapis.com","p"],["staging-identitytoolkit.sandbox.googleapis.com","s"],["test-identitytoolkit.sandbox.googleapis.com","t"]]);function nX(n){let e=n.config;xe(e.authDomain,n,"auth-domain-config-required");let t=e.emulator?mT(e,JY):`https://${n.config.authDomain}/${ZY}`,r={apiKey:e.apiKey,appName:n.name,v:ts},i=tX.get(n.config.apiHost);i&&(r.eid=i);let s=n._getFrameworks();return s.length&&(r.fw=s.join(",")),`${t}?${$l(r).slice(1)}`}function rX(n){return m(this,null,function*(){let e=yield XY(n),t=ss().gapi;return xe(t,n,"internal-error"),e.open({where:document.body,url:nX(n),messageHandlersFilter:t.iframes.CROSS_ORIGIN_IFRAMES_FILTER,attributes:eX,dontclear:!0},r=>new Promise((i,s)=>m(this,null,function*(){yield r.restyle({setHideOnLeave:!1});let o=xi(n,"network-request-failed"),a=ss().setTimeout(()=>{s(o)},QY.get());function c(){ss().clearTimeout(a),i(r)}r.ping(c).then(c,()=>{s(o)})})))})}var iX={location:"yes",resizable:"yes",statusbar:"yes",toolbar:"no"},sX=500,oX=600,aX="_blank",cX="http://localhost",zg=class{constructor(e){this.window=e,this.associatedEvent=null}close(){if(this.window)try{this.window.close()}catch{}}};function lX(n,e,t,r=sX,i=oX){let s=Math.max((window.screen.availHeight-i)/2,0).toString(),o=Math.max((window.screen.availWidth-r)/2,0).toString(),a="",c=Object.assign(Object.assign({},iX),{width:r.toString(),height:i.toString(),top:s,left:o}),l=pn().toLowerCase();t&&(a=ZL(l)?aX:t),XL(l)&&(e=e||cX,c.scrollbars="yes");let u=Object.entries(c).reduce((f,[p,y])=>`${f}${p}=${y},`,"");if(eY(l)&&a!=="_self")return uX(e||"",a),new zg(null);let d=window.open(e||"",a,u);xe(d,n,"popup-blocked");try{d.focus()}catch{}return new zg(d)}function uX(n,e){let t=document.createElement("a");t.href=n,t.target=e;let r=document.createEvent("MouseEvent");r.initMouseEvent("click",!0,!0,window,1,0,0,0,0,!1,!1,!1,!1,1,null),t.dispatchEvent(r)}var dX="__/auth/handler",hX="emulator/auth/handler",fX=encodeURIComponent("fac");function jL(n,e,t,r,i,s){return m(this,null,function*(){xe(n.config.authDomain,n,"auth-domain-config-required"),xe(n.config.apiKey,n,"invalid-api-key");let o={apiKey:n.config.apiKey,appName:n.name,authType:t,redirectUrl:r,v:ts,eventId:i};if(e instanceof fh){e.setDefaultLanguage(n.languageCode),o.providerId=e.providerId||"",dL(e.getCustomParameters())||(o.customParameters=JSON.stringify(e.getCustomParameters()));for(let[u,d]of Object.entries(s||{}))o[u]=d}if(e instanceof $g){let u=e.getScopes().filter(d=>d!=="");u.length>0&&(o.scopes=u.join(","))}n.tenantId&&(o.tid=n.tenantId);let a=o;for(let u of Object.keys(a))a[u]===void 0&&delete a[u];let c=yield n._getAppCheckToken(),l=c?`#${fX}=${encodeURIComponent(c)}`:"";return`${pX(n)}?${$l(a).slice(1)}${l}`})}function pX({config:n}){return n.emulator?mT(n,hX):`https://${n.authDomain}/${dX}`}var ZI="webStorageSupport",dT=class{constructor(){this.eventManagers={},this.iframes={},this.originValidationPromises={},this._redirectPersistence=xT,this._completeRedirectFn=$Y,this._overrideRedirectResult=FY}_openPopup(e,t,r,i){return m(this,null,function*(){var s;Xs((s=this.eventManagers[e._key()])===null||s===void 0?void 0:s.manager,"_initialize() not called before _openPopup()");let o=yield jL(e,t,r,JI(),i);return lX(e,o,DT())})}
9_openRedirect(e,t,r,i){return m(this,null,function*(){yield this._originValidation(e);let s=yield jL(e,t,r,JI(),i);return bY(s),new Promise(()=>{})})}_initialize(e){let t=e._key();if(this.eventManagers[t]){let{manager:i,promise:s}=this.eventManagers[t];return i?Promise.resolve(i):(Xs(s,"If manager is not set, promise should be"),s)}let r=this.initAndGetManager(e);return this.eventManagers[t]={promise:r},r.catch(()=>{delete this.eventManagers[t]}),r}initAndGetManager(e){return m(this,null,function*(){let t=yield rX(e),r=new uT(e);return t.register("authEvent",i=>(xe(i?.authEvent,e,"invalid-auth-event"),{status:r.onEvent(i.authEvent)?"ACK":"ERROR"}),gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER),this.eventManagers[e._key()]={manager:r},this.iframes[e._key()]=t,r})}_isIframeWebStorageSupported(e,t){this.iframes[e._key()].send(ZI,{type:ZI},i=>{var s;let o=(s=i?.[0])===null||s===void 0?void 0:s[ZI];o!==void 0&&t(!!o),os(e,"internal-error")},gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER)}_originValidation(e){let t=e._key();return this.originValidationPromises[t]||(this.originValidationPromises[t]=GY(e)),this.originValidationPromises[t]}get _shouldInitProactively(){return rF()||QL()||bT()}},mF=dT;var $L="@firebase/auth",UL="1.7.9";var hT=class{constructor(e){this.auth=e,this.internalListeners=new Map}getUid(){var e;return this.assertAuthConfigured(),((e=this.auth.currentUser)===null||e===void 0?void 0:e.uid)||null}getToken(e){return m(this,null,function*(){return this.assertAuthConfigured(),yield this.auth._initializationPromise,this.auth.currentUser?{accessToken:yield this.auth.currentUser.getIdToken(e)}:null})}addAuthTokenListener(e){if(this.assertAuthConfigured(),this.internalListeners.has(e))return;let t=this.auth.onIdTokenChanged(r=>{e(r?.stsTokenManager.accessToken||null)});this.internalListeners.set(e,t),this.updateProactiveRefresh()}removeAuthTokenListener(e){this.assertAuthConfigured();let t=this.internalListeners.get(e);t&&(this.internalListeners.delete(e),t(),this.updateProactiveRefresh())}assertAuthConfigured(){xe(this.auth._initializationPromise,"dependent-sdk-initialized-before-auth")}updateProactiveRefresh(){this.internalListeners.size>0?this.auth._startProactiveRefresh():this.auth._stopProactiveRefresh()}};function mX(n){switch(n){case"Node":return"node";case"ReactNative":return"rn";case"Worker":return"webworker";case"Cordova":return"cordova";case"WebExtension":return"web-extension";default:return}}function gX(n){Yr(new Ln("auth",(e,{options:t})=>{let r=e.getProvider("app").getImmediate(),i=e.getProvider("heartbeat"),s=e.getProvider("app-check-internal"),{apiKey:o,authDomain:a}=r.options;xe(o&&!o.includes(":"),"invalid-api-key",{appName:r.name});let c={apiKey:o,authDomain:a,clientPlatform:n,apiHost:"identitytoolkit.googleapis.com",tokenApiHost:"securetoken.googleapis.com",apiScheme:"https",sdkClientVersion:iF(n)},l=new sT(r,i,s,c);return aY(l,t),l},"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback((e,t,r)=>{e.getProvider("auth-internal").initialize()})),Yr(new Ln("auth-internal",e=>{let t=Gg(e.getProvider("auth").getImmediate());return(r=>new hT(r))(t)},"PRIVATE").setInstantiationMode("EXPLICIT")),vt($L,UL,mX(n)),vt($L,UL,"esm2017")}var yX=5*60,_X=PI("authIdTokenMaxAge")||yX,BL=null,vX=n=>e=>m(void 0,null,function*(){let t=e&&(yield e.getIdTokenResult()),r=t&&(new Date().getTime()-Date.parse(t.issuedAtTime))/1e3;if(r&&r>_X)return;let i=t?.token;BL!==i&&(BL=i,yield fetch(n,{method:i?"POST":"DELETE",headers:i?{Authorization:`Bearer ${i}`}:{}}))});function kT(n=ns()){let e=Gs(n,"auth");if(e.isInitialized())return e.getImmediate();let t=ET(n,{popupRedirectResolver:mF,persistence:[hF,cF,xT]}),r=PI("authTokenSyncURL");if(r&&typeof isSecureContext=="boolean"&&isSecureContext){let s=new URL(r,location.origin);if(location.origin===s.origin){let o=vX(s.toString());AT(t,o,()=>o(t.currentUser)),TT(t,a=>o(a))}}let i=RI("auth");return i&&Wg(t,`http://${i}`),t}function bX(){var n,e;return(e=(n=document.getElementsByTagName("head"))===null||n===void 0?void 0:n[0])!==null&&e!==void 0?e:document}iY({loadJS(n){return new Promise((e,t)=>
vendor: 57,733 bytes, lines 9-17
9{let r=document.createElement("script");r.setAttribute("src",n),r.onload=e,r.onerror=i=>{let s=xi("internal-error");s.customData=i,t(s)},r.type="text/javascript",r.charset="UTF-8",bX().appendChild(r)})},gapiScript:"https://apis.google.com/js/api.js",recaptchaV2Script:"https://www.google.com/recaptcha/api.js",recaptchaEnterpriseScript:"https://www.google.com/recaptcha/enterprise.js?render="});gX("Browser");var gF="auth",Di=class{constructor(e){return e}},Qs=class{constructor(){return Ws(gF)}};var PT=new ue("angularfire2.auth-instances");function dQ(n,e){let t=Ko(gF,n,e);return t&&new Di(t)}function hQ(n){return(e,t)=>{let r=e.runOutsideAngular(()=>n(t));return new Di(r)}}var fQ={provide:Qs,deps:[[new kt,PT]]},pQ={provide:Di,useFactory:dQ,deps:[[new kt,PT],Or]};function yF(n,...e){return vt("angularfire",Ci.full,"auth"),Nn([pQ,fQ,{provide:PT,useFactory:hQ(n),multi:!0,deps:[st,On,is,Si,[new kt,rs],...e]}])}var _F=ft(Wg,!0);var vF=ft(kT,!0);var bF=ft(CT,!0);var wF=ft(RT,!0);var EF=ft(ST,!0);var IF=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},TF={};var Xo,NT;(function(){var n;function e(C,T){function S(){}S.prototype=T.prototype,C.D=T.prototype,C.prototype=new S,C.prototype.constructor=C,C.C=function(k,P,N){for(var R=Array(arguments.length-2),ze=2;ze<arguments.length;ze++)R[ze-2]=arguments[ze];return T.prototype[P].apply(k,R)}}function t(){this.blockSize=-1}function r(){this.blockSize=-1,this.blockSize=64,this.g=Array(4),this.B=Array(this.blockSize),this.o=this.h=0,this.s()}e(r,t),r.prototype.s=function(){this.g[0]=1732584193,this.g[1]=4023233417,this.g[2]=2562383102,this.g[3]=271733878,this.o=this.h=0};function i(C,T,S){S||(S=0);var k=Array(16);if(typeof T=="string")for(var P=0;16>P;++P)k[P]=T.charCodeAt(S++)|T.charCodeAt(S++)<<8|T.charCodeAt(S++)<<16|T.charCodeAt(S++)<<24;else for(P=0;16>P;++P)k[P]=T[S++]|T[S++]<<8|T[S++]<<16|T[S++]<<24;T=C.g[0],S=C.g[1],P=C.g[2];var N=C.g[3],R=T+(N^S&(P^N))+k[0]+3614090360&4294967295;T=S+(R<<7&4294967295|R>>>25),R=N+(P^T&(S^P))+k[1]+3905402710&4294967295,N=T+(R<<12&4294967295|R>>>20),R=P+(S^N&(T^S))+k[2]+606105819&4294967295,P=N+(R<<17&4294967295|R>>>15),R=S+(T^P&(N^T))+k[3]+3250441966&4294967295,S=P+(R<<22&4294967295|R>>>10),R=T+(N^S&(P^N))+k[4]+4118548399&4294967295,T=S+(R<<7&4294967295|R>>>25),R=N+(P^T&(S^P))+k[5]+1200080426&4294967295,N=T+(R<<12&4294967295|R>>>20),R=P+(S^N&(T^S))+k[6]+2821735955&4294967295,P=N+(R<<17&4294967295|R>>>15),R=S+(T^P&(N^T))+k[7]+4249261313&4294967295,S=P+(R<<22&4294967295|R>>>10),R=T+(N^S&(P^N))+k[8]+1770035416&4294967295,T=S+(R<<7&4294967295|R>>>25),R=N+(P^T&(S^P))+k[9]+2336552879&4294967295,N=T+(R<<12&4294967295|R>>>20),R=P+(S^N&(T^S))+k[10]+4294925233&4294967295,P=N+(R<<17&4294967295|R>>>15),R=S+(T^P&(N^T))+k[11]+2304563134&4294967295,S=P+(R<<22&4294967295|R>>>10),R=T+(N^S&(P^N))+k[12]+1804603682&4294967295,T=S+(R<<7&4294967295|R>>>25),R=N+(P^T&(S^P))+k[13]+4254626195&4294967295,N=T+(R<<12&4294967295|R>>>20),R=P+(S^N&(T^S))+k[14]+2792965006&4294967295,P=N+(R<<17&4294967295|R>>>15),R=S+(T^P&(N^T))+k[15]+1236535329&4294967295,S=P+(R<<22&4294967295|R>>>10),R=T+(P^N&(S^P))+k[1]+4129170786&4294967295,T=S+(R<<5&4294967295|R>>>27),R=N+(S^P&(T^S))+k[6]+3225465664&4294967295,N=T+(R<<9&4294967295|R>>>23),R=P+(T^S&(N^T))+k[11]+643717713&4294967295,P=N+(R<<14&4294967295|R>>>18),R=S+(N^T&(P^N))+k[0]+3921069994&4294967295,S=P+(R<<20&4294967295|R>>>12),R=T+(P^N&(S^P))+k[5]+3593408605&4294967295,T=S+(R<<5&4294967295|R>>>27),R=N+(S^P&(T^S))+k[10]+38016083&4294967295,N=T+(R<<9&4294967295|R>>>23),R=P+(T^S&(N^T))+k[15]+3634488961&4294967295,P=N+(R<<14&4294967295|R>>>18),R=S+(N^T&(P^N))+k[4]+3889429448&4294967295,S=P+(R<<20&4294967295|R>>>12),R=T+(P^N&(S^P))+k[9]+568446438&4294967295,T=S+(R<<5&4294967295|R>>>27),R=N+(S^P&(T^S))+k[14]+3275163606&4294967295,N=T+(R<<9&4294967295|R>>>23),R=P+(T^S&(N^T))+k[3]+4107603335&4294967295,P=N+(R<<14&4294967295|R>>>18),R=S+(N^T&(P^N))+k[8]+1163531501&4294967295,S=P+(R<<20&4294967295|R>>>12),R=T+(P^N&(S^P))+k[13]+2850285829&4294967295,T=S+(R<<5&4294967295|R>>>27),R=N+(S^P&(T^S))+k[2]+4243563512&4294967295,N=T+(R<<9&4294967295|R>>>23),R=P+(T^S&(N^T))+k[7]+1735328473&4294967295,P=N+(R<<14&4294967295|R>>>18),R=S+(N^T&(P^N))+k[12]+2368359562&4294967295,S=P+(R<<20&4294967295|R>>>12),R=T+(S^P^N)+k[5]+4294588738&4294967295,T=S+(R<<4&4294967295|R>>>28),R=N+(T^S^P)+k[8]+2272392833&4294967295,N=T+(R<<11&4294967295|R>>>21),R=P+(N^T^S)+k[11]+1839030562&4294967295,P=N+(R<<16&4294967295|R>>>16),R=S+(P^N^T)+k[14]+4259657740&4294967295,S=P+(R<<23&4294967295|R>>>9),R=T+(S^P^N)+k[1]+2763975236&4294967295,T=S+(R<<4&4294967295|R>>>28),R=N+(T^S^P)+k[4]+1272893353&4294967295,N=T+(R<<11&4294967295|R>>>21),R=P+(N^T^S)+k[7]+4139469664&4294967295,P=N+(R<<16&4294967295|R>>>16),R=S+(P^N^T)+k[10]+3200236656&4294967295,S=P+(R<<23&4294967295|R>>>9),R=T+(S^P^N)+k[13]+681279174&4294967295,T=S+(R<<4&4294967295|R>>>28),R=N+(T^S^P)+k[0]+3936430074&4294967295,N=T+(R<<11&4294967295|R>>>21),R=P+(N^T^S)+k[3]+3572445317&4294967295,P=N+(R<<16&4294967295|R>>>16),R=S+(P^N^T)+k[6]+76029189&4294967295,S=P+(R<<23&4294967295|R>>>9),R=T+(S^P^N)+k[9]+3654602809&4294967295,T=S+(R<<4&4294967295|R>>>28),R=N+(T^S^P)+k[12]+3873151461&4294967295,N=T+(R<<11&4294967295|R>>>21),R=P+(N^T^S)+k[15]+530742520&4294967295,P=N+(R<<16&4294967295|R>>>16),R=S+(P^N^T)+k[2]+3299628645&4294967295,S=P+(R<<23&4294967295|R>>>9),R=T+(P^(S|~N))+k[0]+4096336452&4294967295,T=S+(R<<6&4294967295|R>>>26),R=N+(S^(T|~P))+k[7]+1126891415&4294967295,N=T+(R<<10&4294967295|R>>>22),R=P+(T^(N|~S))+k[14]+2878612391&4294967295,P=N+(R<<15&4294967295|R>>>17),R=S+(N^(P|~T))+k[5]+4237533241&4294967295,S=P+(R<<21&4294967295|R>>>11),R=T+(P^(S|~N))+k[12]+1700485571&4294967295,T=S+(R<<6&4294967295|R>>>26),R=N+(S^(T|~P))+k[3]+2399980690&4294967295,N=T+(R<<10&4294967295|R>>>22),R=P+(T^(N|~S))+k[10]+4293915773&4294967295,P=N+(R<<15&4294967295|R>>>17),R=S+(N^(P|~T))+k[1]+2240044497&4294967295,S=P+(R<<21&4294967295|R>>>11),R=T+(P^(S|~N))+k[8]+1873313359&4294967295,T=S+(R<<6&4294967295|R>>>26),R=N+(S^(T|~P))+k[15]+4264355552&4294967295,N=T+(R<<10&4294967295|R>>>22),R=P+(T^(N|~S))+k[6]+2734768916&4294967295,P=N+(R<<15&4294967295|R>>>17),R=S+(N^(P|~T))+k[13]+1309151649&4294967295,S=P+(R<<21&4294967295|R>>>11),R=T+(P^(S|~N))+k[4]+4149444226&4294967295,T=S+(R<<6&4294967295|R>>>26),R=N+(S^(T|~P))+k[11]+3174756917&4294967295,N=T+(R<<10&4294967295|R>>>22),R=P+(T^(N|~S))+k[2]+718787259&4294967295,P=N+(R<<15&4294967295|R>>>17),R=S+(N^(P|~T))+k[9]+3951481745&4294967295,C.g[0]=C.g[0]+T&4294967295,C.g[1]=C.g[1]+(P+(R<<21&4294967295|R>>>11))&4294967295,C.g[2]=C.g[2]+P&4294967295,C.g[3]=C.g[3]+N&4294967295}r.prototype.u=function(C,T){T===void 0&&(T=C.length);for(var S=T-this.blockSize,k=this.B,P=this.h,N=0;N<T;){if(P==0)for(;N<=S;)i(this,C,N),N+=this.blockSize;if(typeof C=="string"){for(;N<T;)if(k[P++]=C.charCodeAt(N++),P==this.blockSize){i(this,k),P=0;break}}else for(;N<T;)if(k[P++]=C[N++],P==this.blockSize){i(this,k),P=0;break}}this.h=P,this.o+=T},r.prototype.v=function(){var C=Array((56>this.h?this.blockSize:2*this.blockSize)-this.h);C[0]=128;for(var T=1;T<C.length-8;++T)C[T]=0;var S=8*this.o;for(T=C.length-8;T<C.length;++T)C[T]=S&255,S/=256;for(this.u(C),C=Array(16),T=S=0;4>T;++T)for(var k=0;32>k;k+=8)C[S++]=this.g[T]>>>k&255;return C};function s(C,T){var S=a;return Object.prototype.hasOwnProperty.call(S,C)?S[C]:S[C]=T(C)}function o(C,T){this.h=T;for(var S=[],k=!0,P=C.length-1;0<=P;P--){var N=C[P]|0;k&&N==T||(S[P]=N,k=!1)}this.g=S}var a={};function c(C){return-128<=C&&128>C?s(C,function(T){return new o([T|0],0>T?-1:0)}):new o([C|0],0>C?-1:0)}function l(C){if(isNaN(C)||!isFinite(C))return d;if(0>C)return w(l(-C));for(var T=[],S=1,k=0;C>=S;k++)T[k]=C/S|0,S*=4294967296;return new o(T,0)}function u(C,T){if(C.length==0)throw Error("number format error: empty string");if(T=T||10,2>T||36<T)throw Error("radix out of range: "+T);if(C.charAt(0)=="-")return w(u(C.substring(1),T));if(0<=C.indexOf("-"))throw Error('number format error: interior "-" character');for(var S=l(Math.pow(T,8)),k=d,P=0;P<C.length;P+=8){var N=Math.min(8,C.length-P),R=parseInt(C.substring(P,P+N),T);8>N?(N=l(Math.pow(T,N)),k=k.j(N).add(l(R))):(k=k.j(S),k=k.add(l(R)))}return k}var d=c(0),f=c(1),p=c(16777216);n=o.prototype,n.m=function(){if(v(this))return-w(this).m();for(var C=0,T=1,S=0;S<this.g.length;S++){var k=this.i(S);C+=(0<=k?k:4294967296+k)*T,T*=4294967296}return C},n.toString=function(C){if(C=C||10,2>C||36<C)throw Error("radix out of range: "+C);if(y(this))return"0";if(v(this))return"-"+w(this).toString(C);for(var T=l(Math.pow(C,6)),S=this,k="";;){var P=M(S,T).g;S=E(S,P.j(T));var N=((0<S.g.length?S.g[0]:S.h)>>>0).toString(C);if(S=P,y(S))return N+k;for(;6>N.length;)N="0"+N;k=N+k}},n.i=function(C){return 0>C?0:C<this.g.length?this.g[C]:this.h};function y(C){if(C.h!=0)return!1;for(var T=0;T<C.g.length;T++)if(C.g[T]!=0)return!1;return!0}function v(C){return C.h==-1}n.l=function(C){return C=E(this,C),v(C)?-1:y(C)?0:1};function w(C){for(var T=C.g.length,S=[],k=0;k<T;k++)S[k]=~C.g[k];return new o(S,~C.h).add(f)}n.abs=function(){return v(this)?w(this):this},n.add=function(C){for(var T=Math.max(this.g.length,C.g.length),S=[],k=0,P=0;P<=T;P++){var N=k+(this.i(P)&65535)+(C.i(P)&65535),R=(N>>>16)+(this.i(P)>>>16)+(C.i(P)>>>16);k=R>>>16,N&=65535,R&=65535,S[P]=R<<16|N}return new o(S,S[S.length-1]&-2147483648?-1:0)};function E(C,T){return C.add(w(T))}n.j=function(C){if(y(this)||y(C))return d;if(v(this))return v(C)?w(this).j(w(C)):w(w(this).j(C));if(v(C))return w(this.j(w(C)));if(0>this.l(p)&&0>C.l(p))return l(this.m()*C.m());for(var T=this.g.length+C.g.length,S=[],k=0;k<2*T;k++)S[k]=0;for(k=0;k<this.g.length;k++)for(var P=0;P<C.g.length;P++){var N=this.i(k)>>>16,R=this.i(k)&65535,ze=C.i(P)>>>16,Yt=C.i(P)&65535;S[2*k+2*P]+=R*Yt,A(S,2*k+2*P),S[2*k+2*P+1]+=N*Yt,A(S,2*k+2*P+1),S[2*k+2*P+1]+=R*ze,A(S,2*k+2*P+1),S[2*k+2*P+2]+=N*ze,A(S,2*k+2*P+2)}for(k=0;k<T;k++)S[k]=S[2*k+1]<<16|S[2*k];for(k=T;k<2*T;k++)S[k]=0;return new o(S,0)};function A(C,T){for(;(C[T]&65535)!=C[T];)C[T+1]+=C[T]>>>16,C[T]&=65535,T++}function x(C,T){this.g=C,this.h=T}function M(C,T){if(y(T))throw Error("division by zero");if(y(C))return new x(d,d);if(v(C))return T=M(w(C),T),new x(w(T.g),w(T.h));if(v(T))return T=M(C,w(T)),new x(w(T.g),T.h);if(30<C.g.length){if(v(C)||v(T))throw Error("slowDivide_ only works with positive integers.");for(var S=f,k=T;0>=k.l(C);)S=O(S),k=O(k);var P=$(S,1),N=$(k,1);for(k=$(k,2),S=$(S,2);!y(k);){var R=N.add(k);0>=R.l(C)&&(P=P.add(S),N=R),k=$(k,1),S=$(S,1)}return T=E(C,P.j(T)),new x(P,T)}for(P=d;0<=C.l(T);){for(S=Math.max(1,Math.floor(C.m()/T.m())),k=Math.ceil(Math.log(S)/Math.LN2),k=48>=k?1:Math.pow(2,k-48),N=l(S),R=N.j(T);v(R)||0<R.l(C);)S-=k,N=l(S),R=N.j(T);y(N)&&(N=f),P=P.add(N),C=E(C,R)}return new x(P,C)}n.A=function(C){return M(this,C).h},n.and=function(C){for(var T=Math.max(this.g.length,C.g.length),S=[],k=0;k<T;k++)S[k]=this.i(k)&C.i(k);return new o(S,this.h&C.h)},n.or=function(C){for(var T=Math.max(this.g.length,C.g.length),S=[],k=0;k<T;k++)S[k]=this.i(k)|C.i(k);return new o(S,this.h|C.h)},n.xor=function(C){for(var T=Math.max(this.g.length,C.g.length),S=[],k=0;k<T;k++)S[k]=this.i(k)^C.i(k);return new o(S,this.h^C.h)};function O(C){for(var T=C.g.length+1,S=[],k=0;k<T;k++)S[k]=C.i(k)<<1|C.i(k-1)>>>31;return new o(S,C.h)}function $(C,T){var S=T>>5;T%=32;for(var k=C.g.length-S,P=[],N=0;N<k;N++)P[N]=0<T?C.i(N+S)>>>T|C.i(N+S+1)<<32-T:C.i(N+S);return new o(P,C.h)}r.prototype.digest=r.prototype.v,r.prototype.reset=r.prototype.s,r.prototype.update=r.prototype.u,NT=TF.Md5=r,o.prototype.add=o.prototype.add,o.prototype.multiply=o.prototype.j,o.prototype.modulo=o.prototype.A,o.prototype.compare=o.prototype.l,o.prototype.toNumber=o.prototype.m,o.prototype.toString=o.prototype.toString,o.prototype.getBits=o.prototype.i,o.fromNumber=l,o.fromString=u,Xo=TF.Integer=o}).apply(typeof IF<"u"?IF:typeof self<"u"?self:typeof window<"u"?window:{});var Yg=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Zs={};var OT,mQ,zl,LT,gh,Xg,FT,VT,jT;(function(){var n,e=typeof Object.defineProperties=="function"?Object.defineProperty:function(h,g,b){return h==Array.prototype||h==Object.prototype||(h[g]=b.value),h};function t(h){h=[typeof globalThis=="object"&&globalThis,h,typeof window=="object"&&window,typeof self=="object"&&self,typeof Yg=="object"&&Yg];for(var g=0;g<h.length;++g){var b=h[g];if(b&&b.Math==Math)return b}throw Error("Cannot find global object")}var r=t(this);function i(h,g){if(g)e:{var b=r;h=h.split(".");for(var I=0;I<h.length-1;I++){var V=h[I];if(!(V in b))break e;b=b[V]}h=h[h.length-1],I=b[h],g=g(I),g!=I&&g!=null&&e(b,h,{configurable:!0,writable:!0,value:g})}}function s(h,g){h instanceof String&&(h+="");var b=0,I=!1,V={next:function(){if(!I&&b<h.length){var U=b++;return{value:g(U,h[U]),done:!1}}return I=!0,{done:!0,value:void 0}}};return V[Symbol.iterator]=function(){return V},V}i("Array.prototype.values",function(h){return h||function(){return s(this,function(g,b){return b})}});var o=o||{},a=this||self;function c(h){var g=typeof h;return g=g!="object"?g:h?Array.isArray(h)?"array":g:"null",g=="array"||g=="object"&&typeof h.length=="number"}function l(h){var g=typeof h;return g=="object"&&h!=null||g=="function"}function u(h,g,b){return h.call.apply(h.bind,arguments)}function d(h,g,b){if(!h)throw Error();if(2<arguments.length){var I=Array.prototype.slice.call(arguments,2);return function(){var V=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(V,I),h.apply(g,V)}}return function(){return h.apply(g,arguments)}}function f(h,g,b){return f=Function.prototype.bind&&Function.prototype.bind.toString().indexOf("native code")!=-1?u:d,f.apply(null,arguments)}function p(h,g){var b=Array.prototype.slice.call(arguments,1);return function(){var I=b.slice();return I.push.apply(I,arguments),h.apply(this,I)}}function y(h,g){function b(){}b.prototype=g.prototype,h.aa=g.prototype,h.prototype=new b,h.prototype.constructor=h,h.Qb=function(I,V,U){for(var Z=Array(arguments.length-2),It=2;It<arguments.length;It++)Z[It-2]=arguments[It];return g.prototype[V].apply(I,Z)}}function v(h){let g=h.length;if(0<g){let b=Array(g);for(let I=0;I<g;I++)b[I]=h[I];return b}return[]}function w(h,g){for(let b=1;b<arguments.length;b++){let I=arguments[b];if(c(I)){let V=h.length||0,U=I.length||0;h.length=V+U;for(let Z=0;Z<U;Z++)h[V+Z]=I[Z]}else h.push(I)}}class E{constructor(g,b){this.i=g,this.j=b,this.h=0,this.g=null}get(){let g;return 0<this.h?(this.h--,g=this.g,this.g=g.next,g.next=null):g=this.i(),g}}function A(h){return/^[\s\xa0]*$/.test(h)}function x(){var h=a.navigator;return h&&(h=h.userAgent)?h:""}function M(h){return M[" "](h),h}M[" "]=function(){};var O=x().indexOf("Gecko")!=-1&&!(x().toLowerCase().indexOf("webkit")!=-1&&x().indexOf("Edge")==-1)&&!(x().indexOf("Trident")!=-1||x().indexOf("MSIE")!=-1)&&x().indexOf("Edge")==-1;function $(h,g,b){for(let I in h)g.call(b,h[I],I,h)}function C(h,g){for(let b in h)g.call(void 0,h[b],b,h)}function T(h){let g={};for(let b in h)g[b]=h[b];return g}let S="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function k(h,g){let b,I;for(let V=1;V<arguments.length;V++){I=arguments[V];for(b in I)h[b]=I[b];for(let U=0;U<S.length;U++)b=S[U],Object.prototype.hasOwnProperty.call(I,b)&&(h[b]=I[b])}}function P(h){var g=1;h=h.split(":");let b=[];for(;0<g&&h.length;)b.push(h.shift()),g--;return h.length&&b.push(h.join(":")),b}function N(h){a.setTimeout(()=>{throw h},0)}function R(){var h=ur;let g=null;return h.g&&(g=h.g,h.g=h.g.next,h.g||(h.h=null),g.next=null),g}class ze{constructor(){this.h=this.g=null}add(g,b){let I=Yt.get();I.set(g,b),this.h?this.h.next=I:this.g=I,this.h=I}}var Yt=new E(()=>new le,h=>h.reset());class le{constructor(){this.next=this.g=this.h=null}set(g,b){this.h=g,this.g=b,this.next=null}reset(){this.next=this.g=this.h=null}}let ce,un=!1,ur=new ze,$i=()=>{let h=a.Promise.resolve(void 0);ce=()=>{h.then(dr)}};var dr=()=>{for(var h;h=R();){try{h.h.call(h.g)}catch(b){N(b)}var g=Yt;g.j(h),100>g.h&&(g.h++,h.next=g.g,g.g=h)}un=!1};function Et(){this.s=this.s,this.C=this.C}Et.prototype.s=!1,Et.prototype.ma=function(){this.s||(this.s=!0,this.N())},Et.prototype.N=function(){if(this.C)for(;this.C.length;)this.C.shift()()};function Ze(h,g){this.type=h,this.g=this.target=g,this.defaultPrevented=!1}Ze.prototype.h=function(){this.defaultPrevented=!0};var Io=function(){if(!a.addEventListener||!Object.defineProperty)return!1;var h=!1,g=Object.defineProperty({},"passive",{get:function(){h=!0}});try{let b=()=>{};a.addEventListener("test",b,g),a.removeEventListener("test",b,g)}catch{}return h}();function li(h,g){if(Ze.call(this,h?h.type:""),this.relatedTarget=this.g=this.target=null,this.button=this.screenY=this.screenX=this.clientY=this.clientX=0,this.key="",this.metaKey=this.shiftKey=this.altKey=this.ctrlKey=!1,this.state=null,this.pointerId=0,this.pointerType="",this.i=null,h){var b=this.type=h.type,I=h.changedTouches&&h.changedTouches.length?h.changedTouches[0]:null;if(this.target=h.target||h.srcElement,this.g=g,g=h.relatedTarget){if(O){e:{try{M(g.nodeName);var V=!0;break e}catch{}V=!1}V||(g=null)}}else b=="mouseover"?g=h.fromElement:b=="mouseout"&&(g=h.toElement);this.relatedTarget=g,I?(this.clientX=I.clientX!==void 0?I.clientX:I.pageX,this.clientY=I.clientY!==void 0?I.clientY:I.pageY,this.screenX=I.screenX||0,this.screenY=I.screenY||0):(this.clientX=h.clientX!==void 0?h.clientX:h.pageX,this.clientY=h.clientY!==void 0?h.clientY:h.pageY,this.screenX=h.screenX||0,this.screenY=h.screenY||0),this.button=h.button,this.key=h.key||"",this.ctrlKey=h.ctrlKey,this.altKey=h.altKey,this.shiftKey=h.shiftKey,this.metaKey=h.metaKey,this.pointerId=h.pointerId||0,this.pointerType=typeof h.pointerType=="string"?h.pointerType:hr[h.pointerType]||"",this.state=h.state,this.i=h,h.defaultPrevented&&li.aa.h.call(this)}}y(li,Ze);var hr={2:"touch",3:"pen",4:"mouse"};li.prototype.h=function(){li.aa.h.call(this);var h=this.i;h.preventDefault?h.preventDefault():h.returnValue=!1};var dt="closure_listenable_"+(1e6*Math.random()|0),Ur=0;function Kf(h,g,b,I,V){this.listener=h,this.proxy=null,this.src=g,this.type=b,this.capture=!!I,this.ha=V,this.key=++Ur,this.da=this.fa=!1}function qc(h){h.da=!0,h.listener=null,h.proxy=null,h.src=null,h.ha=null}function Yf(h){this.src=h,this.g={},this.h=0}Yf.prototype.add=function(h,g,b,I,V){var U=h.toString();h=this.g[U],h||(h=this.g[U]=[],this.h++);var Z=db(h,g,I,V);return-1<Z?(g=h[Z],b||(g.fa=!1)):(g=new Kf(g,this.src,U,!!I,V),g.fa=b,h.push(g)),g};function ub(h,g){var b=g.type;if(b in h.g){var I=h.g[b],V=Array.prototype.indexOf.call(I,g,void 0),U;(U=0<=V)&&Array.prototype.splice.call(I,V,1),U&&(qc(g),h.g[b].length==0&&(delete h.g[b],h.h--))}}function db(h,g,b,I){for(var V=0;V<h.length;++V){var U=h[V];if(!U.da&&U.listener==g&&U.capture==!!b&&U.ha==I)return V}return-1}var hb="closure_lm_"+(1e6*Math.random()|0),fb={};function XR(h,g,b,I,V){if(I&&I.once)return ZR(h,g,b,I,V);if(Array.isArray(g)){for(var U=0;U<g.length;U++)XR(h,g[U],b,I,V);return null}return b=yb(b),h&&h[dt]?h.K(g,b,l(I)?!!I.capture:!!I,V):QR(h,g,b,!1,I,V)}function QR(h,g,b,I,V,U){if(!g)throw Error("Invalid event type");var Z=l(V)?!!V.capture:!!V,It=mb(h);if(It||(h[hb]=It=new Yf(h)),b=It.add(g,b,I,Z,U),b.proxy)return b;if(I=U3(),b.proxy=I,I.src=h,I.listener=b,h.addEventListener)Io||(V=Z),V===void 0&&(V=!1),h.addEventListener(g.toString(),I,V);else if(h.attachEvent)h.attachEvent(ek(g.toString()),I);else if(h.addListener&&h.removeListener)h.addListener(I);else throw Error("addEventListener and attachEvent are unavailable.");return b}function U3(){function h(b){return g.call(h.src,h.listener,b)}let g=B3;return h}function ZR(h,g,b,I,V){if(Array.isArray(g)){for(var U=0;U<g.length;U++)ZR(h,g[U],b,I,V);return null}return b=yb(b),h&&h[dt]?h.L(g,b,l(I)?!!I.capture:!!I,V):QR(h,g,b,!0,I,V)}function JR(h,g,b,I,V){if(Array.isArray(g))for(var U=0;U<g.length;U++)JR(h,g[U],b,I,V);else I=l(I)?!!I.capture:!!I,b=yb(b),h&&h[dt]?(h=h.i,g=String(g).toString(),g in h.g&&(U=h.g[g],b=db(U,b,I,V),-1<b&&(qc(U[b]),Array.prototype.splice.call(U,b,1),U.length==0&&(delete h.g[g],h.h--)))):h&&(h=mb(h))&&(g=h.g[g.toString()],h=-1,g&&(h=db(g,b,I,V)),(b=-1<h?g[h]:null)&&pb(b))}function pb(h){if(typeof h!="number"&&h&&!h.da){var g=h.src;if(g&&g[dt])ub(g.i,h);else{var b=h.type,I=h.proxy;g.removeEventListener?g.removeEventListener(b,I,h.capture):g.detachEvent?g.detachEvent(ek(b),I):g.addListener&&g.removeListener&&g.removeListener(I),(b=mb(g))?(ub(b,h),b.h==0&&(b.src=null,g[hb]=null)):qc(h)}}}function ek(h){return h in fb?fb[h]:fb[h]="on"+h}function B3(h,g){if(h.da)h=!0;else{g=new li(g,this);var b=h.listener,I=h.ha||h.src;h.fa&&pb(h),h=b.call(I,g)}return h}function mb(h){return h=h[hb],h instanceof Yf?h:null}var gb="__closure_events_fn_"+(1e9*Math.random()>>>0);function yb(h){return typeof h=="function"?h:(h[gb]||(h[gb]=function(g){return h.handleEvent(g)}),h[gb])}function kn(){Et.call(this),this.i=new Yf(this),this.M=this,this.F=null}y(kn,Et),kn.prototype[dt]=!0,kn.prototype.removeEventListener=function(h,g,b,I){JR(this,h,g,b,I)};function Yn(h,g){var b,I=h.F;if(I)for(b=[];I;I=I.F)b.push(I);if(h=h.M,I=g.type||g,typeof g=="string")g=new Ze(g,h);else if(g instanceof Ze)g.target=g.target||h;else{var V=g;g=new Ze(I,h),k(g,V)}if(V=!0,b)for(var U=b.length-1;0<=U;U--){var Z=g.g=b[U];V=Xf(Z,I,!0,g)&&V}if(Z=g.g=h,V=Xf(Z,I,!0,g)&&V,V=Xf(Z,I,!1,g)&&V,b)for(U=0;U<b.length;U++)Z=g.g=b[U],V=Xf(Z,I,!1,g)&&V}kn.prototype.N=function(){if(kn.aa.N.call(this),this.i){var h=this.i,g;for(g in h.g){for(var b=h.g[g],I=0;I<b.length;I++)qc(b[I]);delete h.g[g],h.h--}}this.F=null},kn.prototype.K=function(h,g,b,I){return this.i.add(String(h),g,!1,b,I)},kn.prototype.L=function(h,g,b,I){return this.i.add(String(h),g,!0,b,I)};function Xf(h,g,b,I){if(g=h.i.g[String(g)],!g)return!0;g=g.concat();for(var V=!0,U=0;U<g.length;++U){var Z=g[U];if(Z&&!Z.da&&Z.capture==b){var It=Z.listener,_n=Z.ha||Z.src;Z.fa&&ub(h.i,Z),V=It.call(_n,I)!==!1&&V}}return V&&!I.defaultPrevented}function tk(h,g,b){if(typeof h=="function")b&&(h=f(h,b));else if(h&&typeof h.handleEvent=="function")h=f(h.handleEvent,h);else throw Error("Invalid listener argument");return 2147483647<Number(g)?-1:a.setTimeout(h,g||0)}function nk(h){h.g=tk(()=>{h.g=null,h.i&&(h.i=!1,nk(h))},h.l);let g=h.h;h.h=null,h.m.apply(null,g)}class H3 extends Et{constructor(g,b){super(),this.m=g,this.l=b,this.h=null,this.i=!1,this.g=null}j(g){this.h=arguments,this.g?this.i=!0:nk(this)}N(){super.N(),this.g&&(a.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}function Gu(h){Et.call(this),this.h=h,this.g={}}y(Gu,Et);var rk=[];function ik(h){$(h.g,function(g,b){this.g.hasOwnProperty(b)&&pb(g)},h),h.g={}}Gu.prototype.N=function(){Gu.aa.N.call(this),ik(this)},Gu.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")};var _b=a.JSON.stringify,q3=a.JSON.parse,z3=class{stringify(h){return a.JSON.stringify(h,void 0)}parse(h){return a.JSON.parse(h,void 0)}};function vb(){}vb.prototype.h=null;function sk(h){return h.h||(h.h=h.i())}function ok(){}var Wu={OPEN:"a",kb:"b",Ja:"c",wb:"d"};function bb(){Ze.call(this,"d")}y(bb,Ze);function wb(){Ze.call(this,"c")}y(wb,Ze);var va={},ak=null;function Qf(){return ak=ak||new kn}va.La="serverreachability";function ck(h){Ze.call(this,va.La,h)}y(ck,Ze);function Ku(h){let g=Qf();Yn(g,new ck(g))}va.STAT_EVENT="statevent";function lk(h,g){Ze.call(this,va.STAT_EVENT,h),this.stat=g}y(lk,Ze);function Xn(h){let g=Qf();Yn(g,new lk(g,h))}va.Ma="timingevent";function uk(h,g){Ze.call(this,va.Ma,h),this.size=g}y(uk,Ze);function Yu(h,g){if(typeof h!="function")throw Error("Fn must not be null and must be a function");return a.setTimeout(function(){h()},g)}function Xu(){this.g=!0}Xu.prototype.xa=function(){this.g=!1};function G3(h,g,b,I,V,U){h.info(function(){if(h.g)if(U)for(var Z="",It=U.split("&"),_n=0;_n<It.length;_n++){var lt=It[_n].split("=");if(1<lt.length){var Pn=lt[0];lt=lt[1];var Mn=Pn.split("_");Z=2<=Mn.length&&Mn[1]=="type"?Z+(Pn+"="+lt+"&"):Z+(Pn+"=redacted&")}}else Z=null;else Z=U;return"XMLHTTP REQ ("+I+") [attempt "+V+"]: "+g+` 10`+b+` 11`+Z})}function W3(h,g,b,I,V,U,Z){h.info(function(){return"XMLHTTP RESP ("+I+") [ attempt "+V+"]: "+g+` 12`+b+` 13`+U+" "+Z})}function zc(h,g,b,I){h.info(function(){return"XMLHTTP TEXT ("+g+"): "+Y3(h,b)+(I?" "+I:"")})}function K3(h,g){h.info(function(){return"TIMEOUT: "+g})}Xu.prototype.info=function(){};function Y3(h,g){if(!h.g)return g;if(!g)return null;try{var b=JSON.parse(g);if(b){for(h=0;h<b.length;h++)if(Array.isArray(b[h])){var I=b[h];if(!(2>I.length)){var V=I[1];if(Array.isArray(V)&&!(1>V.length)){var U=V[0];if(U!="noop"&&U!="stop"&&U!="close")for(var Z=1;Z<V.length;Z++)V[Z]=""}}}}return _b(b)}catch{return g}}var Zf={NO_ERROR:0,gb:1,tb:2,sb:3,nb:4,rb:5,ub:6,Ia:7,TIMEOUT:8,xb:9},dk={lb:"complete",Hb:"success",Ja:"error",Ia:"abort",zb:"ready",Ab:"readystatechange",TIMEOUT:"timeout",vb:"incrementaldata",yb:"progress",ob:"downloadprogress",Pb:"uploadprogress"},Eb;function Jf(){}y(Jf,vb),Jf.prototype.g=function(){return new XMLHttpRequest},Jf.prototype.i=function(){return{}},Eb=new Jf;function To(h,g,b,I){this.j=h,this.i=g,this.l=b,this.R=I||1,this.U=new Gu(this),this.I=45e3,this.H=null,this.o=!1,this.m=this.A=this.v=this.L=this.F=this.S=this.B=null,this.D=[],this.g=null,this.C=0,this.s=this.u=null,this.X=-1,this.J=!1,this.O=0,this.M=null,this.W=this.K=this.T=this.P=!1,this.h=new hk}function hk(){this.i=null,this.g="",this.h=!1}var fk={},Ib={};function Tb(h,g,b){h.L=1,h.v=rp(Ss(g)),h.m=b,h.P=!0,pk(h,null)}function pk(h,g){h.F=Date.now(),ep(h),h.A=Ss(h.v);var b=h.A,I=h.R;Array.isArray(I)||(I=[String(I)]),xk(b.i,"t",I),h.C=0,b=h.j.J,h.h=new hk,h.g=Gk(h.j,b?g:null,!h.m),0<h.O&&(h.M=new H3(f(h.Y,h,h.g),h.O)),g=h.U,b=h.g,I=h.ca;var V="readystatechange";Array.isArray(V)||(V&&(rk[0]=V.toString()),V=rk);for(var U=0;U<V.length;U++){var Z=XR(b,V[U],I||g.handleEvent,!1,g.h||g);if(!Z)break;g.g[Z.key]=Z}g=h.H?T(h.H):{},h.m?(h.u||(h.u="POST"),g["Content-Type"]="application/x-www-form-urlencoded",h.g.ea(h.A,h.u,h.m,g)):(h.u="GET",h.g.ea(h.A,h.u,null,g)),Ku(),G3(h.i,h.u,h.A,h.l,h.R,h.m)}To.prototype.ca=function(h){h=h.target;let g=this.M;g&&xs(h)==3?g.j():this.Y(h)},To.prototype.Y=function(h){try{if(h==this.g)e:{let Mn=xs(this.g);var g=this.g.Ba();let Kc=this.g.Z();if(!(3>Mn)&&(Mn!=3||this.g&&(this.h.h||this.g.oa()||Ok(this.g)))){this.J||Mn!=4||g==7||(g==8||0>=Kc?Ku(3):Ku(2)),Ab(this);var b=this.g.Z();this.X=b;t:if(mk(this)){var I=Ok(this.g);h="";var V=I.length,U=xs(this.g)==4;if(!this.h.i){if(typeof TextDecoder>"u"){ba(this),Qu(this);var Z="";break t}this.h.i=new a.TextDecoder}for(g=0;g<V;g++)this.h.h=!0,h+=this.h.i.decode(I[g],{stream:!(U&&g==V-1)});I.length=0,this.h.g+=h,this.C=0,Z=this.h.g}else Z=this.g.oa();if(this.o=b==200,W3(this.i,this.u,this.A,this.l,this.R,Mn,b),this.o){if(this.T&&!this.K){t:{if(this.g){var It,_n=this.g;if((It=_n.g?_n.g.getResponseHeader("X-HTTP-Initial-Response"):null)&&!A(It)){var lt=It;break t}}lt=null}if(b=lt)zc(this.i,this.l,b,"Initial handshake response via X-HTTP-Initial-Response"),this.K=!0,Cb(this,b);else{this.o=!1,this.s=3,Xn(12),ba(this),Qu(this);break e}}if(this.P){b=!0;let ui;for(;!this.J&&this.C<Z.length;)if(ui=X3(this,Z),ui==Ib){Mn==4&&(this.s=4,Xn(14),b=!1),zc(this.i,this.l,null,"[Incomplete Response]");break}else if(ui==fk){this.s=4,Xn(15),zc(this.i,this.l,Z,"[Invalid Chunk]"),b=!1;break}else zc(this.i,this.l,ui,null),Cb(this,ui);if(mk(this)&&this.C!=0&&(this.h.g=this.h.g.slice(this.C),this.C=0),Mn!=4||Z.length!=0||this.h.h||(this.s=1,Xn(16),b=!1),this.o=this.o&&b,!b)zc(this.i,this.l,Z,"[Invalid Chunked Response]"),ba(this),Qu(this);else if(0<Z.length&&!this.W){this.W=!0;var Pn=this.j;Pn.g==this&&Pn.ba&&!Pn.M&&(Pn.j.info("Great, no buffering proxy detected. Bytes received: "+Z.length),Pb(Pn),Pn.M=!0,Xn(11))}}else zc(this.i,this.l,Z,null),Cb(this,Z);Mn==4&&ba(this),this.o&&!this.J&&(Mn==4?Bk(this.j,this):(this.o=!1,ep(this)))}else fH(this.g),b==400&&0<Z.indexOf("Unknown SID")?(this.s=3,Xn(12)):(this.s=0,Xn(13)),ba(this),Qu(this)}}}catch{}finally{}};function mk(h){return h.g?h.u=="GET"&&h.L!=2&&h.j.Ca:!1}function X3(h,g){var b=h.C,I=g.indexOf(` 14`,b);return I==-1?Ib:(b=Number(g.substring(b,I)),isNaN(b)?fk:(I+=1,I+b>g.length?Ib:(g=g.slice(I,I+b),h.C=I+b,g)))}To.prototype.cancel=function(){this.J=!0,ba(this)};function ep(h){h.S=Date.now()+h.I,gk(h,h.I)}function gk(h,g){if(h.B!=null)throw Error("WatchDog timer not null");h.B=Yu(f(h.ba,h),g)}function Ab(h){h.B&&(a.clearTimeout(h.B),h.B=null)}To.prototype.ba=function(){this.B=null;let h=Date.now();0<=h-this.S?(K3(this.i,this.A),this.L!=2&&(Ku(),Xn(17)),ba(this),this.s=2,Qu(this)):gk(this,this.S-h)};function Qu(h){h.j.G==0||h.J||Bk(h.j,h)}function ba(h){Ab(h);var g=h.M;g&&typeof g.ma=="function"&&g.ma(),h.M=null,ik(h.U),h.g&&(g=h.g,h.g=null,g.abort(),g.ma())}function Cb(h,g){try{var b=h.j;if(b.G!=0&&(b.g==h||Sb(b.h,h))){if(!h.K&&Sb(b.h,h)&&b.G==3){try{var I=b.Da.g.parse(g)}catch{I=null}if(Array.isArray(I)&&I.length==3){var V=I;if(V[0]==0){e:if(!b.u){if(b.g)if(b.g.F+3e3<h.F)cp(b),op(b);else break e;kb(b),Xn(18)}}else b.za=V[1],0<b.za-b.T&&37500>V[2]&&b.F&&b.v==0&&!b.C&&(b.C=Yu(f(b.Za,b),6e3));if(1>=vk(b.h)&&b.ca){try{b.ca()}catch{}b.ca=void 0}}else Ea(b,11)}else if((h.K||b.g==h)&&cp(b),!A(g))for(V=b.Da.g.parse(g),g=0;g<V.length;g++){let lt=V[g];if(b.T=lt[0],lt=lt[1],b.G==2)if(lt[0]=="c"){b.K=lt[1],b.ia=lt[2];let Pn=lt[3];Pn!=null&&(b.la=Pn,b.j.info("VER="+b.la));let Mn=lt[4];Mn!=null&&(b.Aa=Mn,b.j.info("SVER="+b.Aa));let Kc=lt[5];Kc!=null&&typeof Kc=="number"&&0<Kc&&(I=1.5*Kc,b.L=I,b.j.info("backChannelRequestTimeoutMs_="+I)),I=b;let ui=h.g;if(ui){let up=ui.g?ui.g.getResponseHeader("X-Client-Wire-Protocol"):null;if(up){var U=I.h;U.g||up.indexOf("spdy")==-1&&up.indexOf("quic")==-1&&up.indexOf("h2")==-1||(U.j=U.l,U.g=new Set,U.h&&(xb(U,U.h),U.h=null))}if(I.D){let Mb=ui.g?ui.g.getResponseHeader("X-HTTP-Session-Id"):null;Mb&&(I.ya=Mb,xt(I.I,I.D,Mb))}}b.G=3,b.l&&b.l.ua(),b.ba&&(b.R=Date.now()-h.F,b.j.info("Handshake RTT: "+b.R+"ms")),I=b;var Z=h;if(I.qa=zk(I,I.J?I.ia:null,I.W),Z.K){bk(I.h,Z);var It=Z,_n=I.L;_n&&(It.I=_n),It.B&&(Ab(It),ep(It)),I.g=Z}else $k(I);0<b.i.length&&ap(b)}else lt[0]!="stop"&<[0]!="close"||Ea(b,7);else b.G==3&&(lt[0]=="stop"||lt[0]=="close"?lt[0]=="stop"?Ea(b,7):Rb(b):lt[0]!="noop"&&b.l&&b.l.ta(lt),b.v=0)}}Ku(4)}catch{}}var Q3=class{constructor(h,g){this.g=h,this.map=g}};function yk(h){this.l=h||10,a.PerformanceNavigationTiming?(h=a.performance.getEntriesByType("navigation"),h=0<h.length&&(h[0].nextHopProtocol=="hq"||h[0].nextHopProtocol=="h2")):h=!!(a.chrome&&a.chrome.loadTimes&&a.chrome.loadTimes()&&a.chrome.loadTimes().wasFetchedViaSpdy),this.j=h?this.l:1,this.g=null,1<this.j&&(this.g=new Set),this.h=null,this.i=[]}function _k(h){return h.h?!0:h.g?h.g.size>=h.j:!1}function vk(h){return h.h?1:h.g?h.g.size:0}function Sb(h,g){return h.h?h.h==g:h.g?h.g.has(g):!1}function xb(h,g){h.g?h.g.add(g):h.h=g}function bk(h,g){h.h&&h.h==g?h.h=null:h.g&&h.g.has(g)&&h.g.delete(g)}yk.prototype.cancel=function(){if(this.i=wk(this),this.h)this.h.cancel(),this.h=null;else if(this.g&&this.g.size!==0){for(let h of this.g.values())h.cancel();this.g.clear()}};function wk(h){if(h.h!=null)return h.i.concat(h.h.D);if(h.g!=null&&h.g.size!==0){let g=h.i;for(let b of h.g.values())g=g.concat(b.D);return g}return v(h.i)}function Z3(h){if(h.V&&typeof h.V=="function")return h.V();if(typeof Map<"u"&&h instanceof Map||typeof Set<"u"&&h instanceof Set)return Array.from(h.values());if(typeof h=="string")return h.split("");if(c(h)){for(var g=[],b=h.length,I=0;I<b;I++)g.push(h[I]);return g}g=[],b=0;for(I in h)g[b++]=h[I];return g}function J3(h){if(h.na&&typeof h.na=="function")return h.na();if(!h.V||typeof h.V!="function"){if(typeof Map<"u"&&h instanceof Map)return Array.from(h.keys());if(!(typeof Set<"u"&&h instanceof Set)){if(c(h)||typeof h=="string"){var g=[];h=h.length;for(var b=0;b<h;b++)g.push(b);return g}g=[],b=0;for(let I in h)g[b++]=I;return g}}}function Ek(h,g){if(h.forEach&&typeof h.forEach=="function")h.forEach(g,void 0);else if(c(h)||typeof h=="string")Array.prototype.forEach.call(h,g,void 0);else for(var b=J3(h),I=Z3(h),V=I.length,U=0;U<V;U++)g.call(void 0,I[U],b&&b[U],h)}var Ik=RegExp("^(?:([^:/?#.]+):)?(?://(?:([^\\\\/?#]*)@)?([^\\\\/?#]*?)(?::([0-9]+))?(?=[\\\\/?#]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#([\\s\\S]*))?$");function eH(h,g){if(h){h=h.split("&");for(var b=0;b<h.length;b++){var I=h[b].indexOf("="),V=null;if(0<=I){var U=h[b].substring(0,I);V=h[b].substring(I+1)}else U=h[b];g(U,V?decodeURIComponent(V.replace(/\+/g," ")):"")}}}function wa(h){if(this.g=this.o=this.j="",this.s=null,this.m=this.l="",this.h=!1,h instanceof wa){this.h=h.h,tp(this,h.j),this.o=h.o,this.g=h.g,np(this,h.s),this.l=h.l;var g=h.i,b=new ed;b.i=g.i,g.g&&(b.g=new Map(g.g),b.h=g.h),Tk(this,b),this.m=h.m}else h&&(g=String(h).match(Ik))?(this.h=!1,tp(this,g[1]||"",!0),this.o=Zu(g[2]||""),this.g=Zu(g[3]||"",!0),np(this,g[4]),this.l=Zu(g[5]||"",!0),Tk(this,g[6]||"",!0),this.m=Zu(g[7]||"")):(this.h=!1,this.i=new ed(null,this.h))}wa.prototype.toString=function(){var h=[],g=this.j;g&&h.push(Ju(g,Ak,!0),":");var b=this.g;return(b||g=="file")&&(h.push("//"),(g=this.o)&&h.push(Ju(g,Ak,!0),"@"),h.push(encodeURIComponent(String(b)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),b=this.s,b!=null&&h.push(":",String(b))),(b=this.l)&&(this.g&&b.charAt(0)!="/"&&h.push("/"),h.push(Ju(b,b.charAt(0)=="/"?rH:nH,!0))),(b=this.i.toString())&&h.push("?",b),(b=this.m)&&h.push("#",Ju(b,sH)),h.join("")};function Ss(h){return new wa(h)}function tp(h,g,b){h.j=b?Zu(g,!0):g,h.j&&(h.j=h.j.replace(/:$/,""))}function np(h,g){if(g){if(g=Number(g),isNaN(g)||0>g)throw Error("Bad port number "+g);h.s=g}else h.s=null}function Tk(h,g,b){g instanceof ed?(h.i=g,oH(h.i,h.h)):(b||(g=Ju(g,iH)),h.i=new ed(g,h.h))}function xt(h,g,b){h.i.set(g,b)}function rp(h){return xt(h,"zx",Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^Date.now()).toString(36)),h}function Zu(h,g){return h?g?decodeURI(h.replace(/%25/g,"%2525")):decodeURIComponent(h):""}function Ju(h,g,b){return typeof h=="string"?(h=encodeURI(h).replace(g,tH),b&&(h=h.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),h):null}function tH(h){return h=h.charCodeAt(0),"%"+(h>>4&15).toString(16)+(h&15).toString(16)}var Ak=/[#\/\?@]/g,nH=/[#\?:]/g,rH=/[#\?]/g,iH=/[#\?@]/g,sH=/#/g;function ed(h,g){this.h=this.g=null,this.i=h||null,this.j=!!g}function Ao(h){h.g||(h.g=new Map,h.h=0,h.i&&eH(h.i,function(g,b){h.add(decodeURIComponent(g.replace(/\+/g," ")),b)}))}n=ed.prototype,n.add=function(h,g){Ao(this),this.i=null,h=Gc(this,h);var b=this.g.get(h);return b||this.g.set(h,b=[]),b.push(g),this.h+=1,this};function Ck(h,g){Ao(h),g=Gc(h,g),h.g.has(g)&&(h.i=null,h.h-=h.g.get(g).length,h.g.delete(g))}function Sk(h,g){return Ao(h),g=Gc(h,g),h.g.has(g)}n.forEach=function(h,g){Ao(this),this.g.forEach(function(b,I){b.forEach(function(V){h.call(g,V,I,this)},this)},this)},n.na=function(){Ao(this);let h=Array.from(this.g.values()),g=Array.from(this.g.keys()),b=[];for(let I=0;I<g.length;I++){let V=h[I];for(let U=0;U<V.length;U++)b.push(g[I])}return b},n.V=function(h){Ao(this);let g=[];if(typeof h=="string")Sk(this,h)&&(g=g.concat(this.g.get(Gc(this,h))));else{h=Array.from(this.g.values());for(let b=0;b<h.length;b++)g=g.concat(h[b])}return g},n.set=function(h,g){return Ao(this),this.i=null,h=Gc(this,h),Sk(this,h)&&(this.h-=this.g.get(h).length),this.g.set(h,[g]),this.h+=1,this},n.get=function(h,g){return h?(h=this.V(h),0<h.length?String(h[0]):g):g};function xk(h,g,b){Ck(h,g),0<b.length&&(h.i=null,h.g.set(Gc(h,g),v(b)),h.h+=b.length)}n.toString=function(){if(this.i)return this.i;if(!this.g)return"";let h=[],g=Array.from(this.g.keys());for(var b=0;b<g.length;b++){var I=g[b];let U=encodeURIComponent(String(I)),Z=this.V(I);for(I=0;I<Z.length;I++){var V=U;Z[I]!==""&&(V+="="+encodeURIComponent(String(Z[I]))),h.push(V)}}return this.i=h.join("&")};function Gc(h,g){return g=String(g),h.j&&(g=g.toLowerCase()),g}function oH(h,g){g&&!h.j&&(Ao(h),h.i=null,h.g.forEach(function(b,I){var V=I.toLowerCase();I!=V&&(Ck(this,I),xk(this,V,b))},h)),h.j=g}function aH(h,g){let b=new Xu;if(a.Image){let I=new Image;I.onload=p(Co,b,"TestLoadImage: loaded",!0,g,I),I.onerror=p(Co,b,"TestLoadImage: error",!1,g,I),I.onabort=p(Co,b,"TestLoadImage: abort",!1,g,I),I.ontimeout=p(Co,b,"TestLoadImage: timeout",!1,g,I),a.setTimeout(function(){I.ontimeout&&I.ontimeout()},1e4),I.src=h}else g(!1)}function cH(h,g){let b=new Xu,I=new AbortController,V=setTimeout(()=>{I.abort(),Co(b,"TestPingServer: timeout",!1,g)},1e4);fetch(h,{signal:I.signal}).then(U=>{clearTimeout(V),U.ok?Co(b,"TestPingServer: ok",!0,g):Co(b,"TestPingServer: server error",!1,g)}).catch(()=>{clearTimeout(V),Co(b,"TestPingServer: error",!1,g)})}function Co(h,g,b,I,V){try{V&&(V.onload=null,V.onerror=null,V.onabort=null,V.ontimeout=null),I(b)}catch{}}function lH(){this.g=new z3}function uH(h,g,b){let I=b||"";try{Ek(h,function(V,U){let Z=V;l(V)&&(Z=_b(V)),g.push(I+U+"="+encodeURIComponent(Z))})}catch(V){throw g.push(I+"type="+encodeURIComponent("_badmap")),V}}function td(h){this.l=h.Ub||null,this.j=h.eb||!1}y(td,vb),td.prototype.g=function(){return new ip(this.l,this.j)},td.prototype.i=function(h){return function(){return h}}({});function ip(h,g){kn.call(this),this.D=h,this.o=g,this.m=void 0,this.status=this.readyState=0,this.responseType=this.responseText=this.response=this.statusText="",this.onreadystatechange=null,this.u=new Headers,this.h=null,this.B="GET",this.A="",this.g=!1,this.v=this.j=this.l=null}y(ip,kn),n=ip.prototype,n.open=function(h,g){if(this.readyState!=0)throw this.abort(),Error("Error reopening a connection");this.B=h,this.A=g,this.readyState=1,rd(this)},n.send=function(h){if(this.readyState!=1)throw this.abort(),Error("need to call open() first. ");this.g=!0;let g={headers:this.u,method:this.B,credentials:this.m,cache:void 0};h&&(g.body=h),(this.D||a).fetch(new Request(this.A,g)).then(this.Sa.bind(this),this.ga.bind(this))},n.abort=function(){this.response=this.responseText="",this.u=new Headers,this.status=0,this.j&&this.j.cancel("Request was aborted.").catch(()=>{}),1<=this.readyState&&this.g&&this.readyState!=4&&(this.g=!1,nd(this)),this.readyState=0},n.Sa=function(h){if(this.g&&(this.l=h,this.h||(this.status=this.l.status,this.statusText=this.l.statusText,this.h=h.headers,this.readyState=2,rd(this)),this.g&&(this.readyState=3,rd(this),this.g)))if(this.responseType==="arraybuffer")h.arrayBuffer().then(this.Qa.bind(this),this.ga.bind(this));else if(typeof a.ReadableStream<"u"&&"body"in h){if(this.j=h.body.getReader(),this.o){if(this.responseType)throw Error('responseType must be empty for "streamBinaryChunks" mode responses.');this.response=[]}else this.response=this.responseText="",this.v=new TextDecoder;Dk(this)}else h.text().then(this.Ra.bind(this),this.ga.bind(this))};function Dk(h){h.j.read().then(h.Pa.bind(h)).catch(h.ga.bind(h))}n.Pa=function(h){if(this.g){if(this.o&&h.value)this.response.push(h.value);else if(!this.o){var g=h.value?h.value:new Uint8Array(0);(g=this.v.decode(g,{stream:!h.done}))&&(this.response=this.responseText+=g)}h.done?nd(this):rd(this),this.readyState==3&&Dk(this)}},n.Ra=function(h){this.g&&(this.response=this.responseText=h,nd(this))},n.Qa=function(h){this.g&&(this.response=h,nd(this))},n.ga=function(){this.g&&nd(this)};function nd(h){h.readyState=4,h.l=null,h.j=null,h.v=null,rd(h)}n.setRequestHeader=function(h,g){this.u.append(h,g)},n.getResponseHeader=function(h){return this.h&&this.h.get(h.toLowerCase())||""},n.getAllResponseHeaders=function(){if(!this.h)return"";let h=[],g=this.h.entries();for(var b=g.next();!b.done;)b=b.value,h.push(b[0]+": "+b[1]),b=g.next();return h.join(`\r 15`)};function rd(h){h.onreadystatechange&&h.onreadystatechange.call(h)}Object.defineProperty(ip.prototype,"withCredentials",{get:function(){return this.m==="include"},set:function(h){this.m=h?"include":"same-origin"}});function Rk(h){let g="";return $(h,function(b,I){g+=I,g+=":",g+=b,g+=`\r 16`}),g}function Db(h,g,b){e:{for(I in b){var I=!1;break e}I=!0}I||(b=Rk(b),typeof h=="string"?b!=null&&encodeURIComponent(String(b)):xt(h,g,b))}function jt(h){kn.call(this),this.headers=new Map,this.o=h||null,this.h=!1,this.v=this.g=null,this.D="",this.m=0,this.l="",this.j=this.B=this.u=this.A=!1,this.I=null,this.H="",this.J=!1}y(jt,kn);var dH=/^https?$/i,hH=["POST","PUT"];n=jt.prototype,n.Ha=function(h){this.J=h},n.ea=function(h,g,b,I){if(this.g)throw Error("[goog.net.XhrIo] Object is active with another request="+this.D+"; newUri="+h);g=g?g.toUpperCase():"GET",this.D=h,this.l="",this.m=0,this.A=!1,this.h=!0,this.g=this.o?this.o.g():Eb.g(),this.v=this.o?sk(this.o):sk(Eb),this.g.onreadystatechange=f(this.Ea,this);try{this.B=!0,this.g.open(g,String(h),!0),this.B=!1}catch(U){kk(this,U);return}if(h=b||"",b=new Map(this.headers),I)if(Object.getPrototypeOf(I)===Object.prototype)for(var V in I)b.set(V,I[V]);else if(typeof I.keys=="function"&&typeof I.get=="function")for(let U of I.keys())b.set(U,I.get(U));else throw Error("Unknown input type for opt_headers: "+String(I));I=Array.from(b.keys()).find(U=>U.toLowerCase()=="content-type"),V=a.FormData&&h instanceof a.FormData,!(0<=Array.prototype.indexOf.call(hH,g,void 0))||I||V||b.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8");for(let[U,Z]of b)this.g.setRequestHeader(U,Z);this.H&&(this.g.responseType=this.H),"withCredentials"in this.g&&this.g.withCredentials!==this.J&&(this.g.withCredentials=this.J);try{Nk(this),this.u=!0,this.g.send(h),this.u=!1}catch(U){kk(this,U)}};function kk(h,g){h.h=!1,h.g&&(h.j=!0,h.g.abort(),h.j=!1),h.l=g,h.m=5,Pk(h),sp(h)}function Pk(h){h.A||(h.A=!0,Yn(h,"complete"),Yn(h,"error"))}n.abort=function(h){this.g&&this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1,this.m=h||7,Yn(this,"complete"),Yn(this,"abort"),sp(this))},n.N=function(){this.g&&(this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1),sp(this,!0)),jt.aa.N.call(this)},n.Ea=function(){this.s||(this.B||this.u||this.j?Mk(this):this.bb())},n.bb=function(){Mk(this)};function Mk(h){if(h.h&&typeof o<"u"&&(!h.v[1]||xs(h)!=4||h.Z()!=2)){if(h.u&&xs(h)==4)tk(h.Ea,0,h);else if(Yn(h,"readystatechange"),xs(h)==4){h.h=!1;try{let Z=h.Z();e:switch(Z){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var g=!0;break e;default:g=!1}var b;if(!(b=g)){var I;if(I=Z===0){var V=String(h.D).match(Ik)[1]||null;!V&&a.self&&a.self.location&&(V=a.self.location.protocol.slice(0,-1)),I=!dH.test(V?V.toLowerCase():"")}b=I}if(b)Yn(h,"complete"),Yn(h,"success");else{h.m=6;try{var U=2<xs(h)?h.g.statusText:""}catch{U=""}h.l=U+" ["+h.Z()+"]",Pk(h)}}finally{sp(h)}}}}function sp(h,g){if(h.g){Nk(h);let b=h.g,I=h.v[0]?()=>{}:null;h.g=null,h.v=null,g||Yn(h,"ready");try{b.onreadystatechange=I}catch{}}}function Nk(h){h.I&&(a.clearTimeout(h.I),h.I=null)}n.isActive=function(){return!!this.g};function xs(h){return h.g?h.g.readyState:0}n.Z=function(){try{return 2<xs(this)?this.g.status:-1}catch{return-1}},n.oa=function(){try{return this.g?this.g.responseText:""}catch{return""}},n.Oa=function(h){if(this.g){var g=this.g.responseText;return h&&g.indexOf(h)==0&&(g=g.substring(h.length)),q3(g)}};function Ok(h){try{if(!h.g)return null;if("response"in h.g)return h.g.response;switch(h.H){case"":case"text":return h.g.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in h.g)return h.g.mozResponseArrayBuffer}return null}catch{return null}}function fH(h){let g={};h=(h.g&&2<=xs(h)&&h.g.getAllResponseHeaders()||"").split(`\r 17`);for(let I=0;I<h.length;I++){if(A(h[I]))continue;var b=P(h[I]);let V=b[0];if(b=b[1],typeof b!="string")continue;b=b.trim();let U=g[V]||[];g[V]=U,U.push(b)}C(g,function(I){return I.join(", ")})}n.Ba=function(){return this.m},n.Ka=function(){return typeof this.l=="string"?this.l:String(this.l)};function id(h,g,b){return b&&b.internalChannelParams&&b.internalChannelParams[h]||g}function Lk(h){this.Aa=0,this.i=[],this.j=new Xu,this.ia=this.qa=this.I=this.W=this.g=this.ya=this.D=this.H=this.m=this.S=this.o=null,this.Ya=this.U=0,this.Va=id("failFast",!1,h),this.F=this.C=this.u=this.s=this.l=null,this.X=!0,this.za=this.T=-1,this.Y=this.v=this.B=0,this.Ta=id("baseRetryDelayMs",5e3,h),this.cb=id("retryDelaySeedMs",1e4,h),this.Wa=id("forwardChannelMaxRetries",2,h),this.wa=id("forwardChannelRequestTimeoutMs",2e4,h),this.pa=h&&h.xmlHttpFactory||void 0,this.Xa=h&&h.Tb||void 0,this.Ca=h&&h.useFetchStreams||!1,this.L=void 0,this.J=h&&h.supportsCrossDomainXhr||!1,this.K="",this.h=new yk(h&&h.concurrentRequestLimit),this.Da=new lH,this.P=h&&h.fastHandshake||!1,this.O=h&&h.encodeInitMessageHeaders||!1,this.P&&this.O&&(this.O=!1),this.Ua=h&&h.Rb||!1,h&&h.xa&&this.j.xa(),h&&h.forceLongPolling&&(this.X=!1),this.ba=!this.P&&this.X&&h&&h.detectBufferingProxy||!1,this.ja=void 0,h&&h.longPollingTimeout&&0<h.longPollingTimeout&&(this.ja=h.longPollingTimeout),this.ca=void 0,this.R=0,this.M=!1,this.ka=this.A=null}n=Lk.prototype,n.la=8,n.G=1,n.connect=function(h,g,b,I){Xn(0),this.W=h,this.H=g||{},b&&I!==void 0&&(this.H.OSID=b,this.H.OAID=I),this.F=this.X,this.I=zk(this,null,this.W),ap(this)};function Rb(h){if(Fk(h),h.G==3){var g=h.U++,b=Ss(h.I);if(xt(b,"SID",h.K),xt(b,"RID",g),xt(b,"TYPE","terminate"),sd(h,b),g=new To(h,h.j,g),g.L=2,g.v=rp(Ss(b)),b=!1,a.navigator&&a.navigator.sendBeacon)try{b=a.navigator.sendBeacon(g.v.toString(),"")}catch{}!b&&a.Image&&(new Image().src=g.v,b=!0),b||(g.g=Gk(g.j,null),g.g.ea(g.v)),g.F=Date.now(),ep(g)}qk(h)}function op(h){h.g&&(Pb(h),h.g.cancel(),h.g=null)}function Fk(h){op(h),h.u&&(a.clearTimeout(h.u),h.u=null),cp(h),h.h.cancel(),h.s&&(typeof h.s=="number"&&a.clearTimeout(h.s),h.s=null)}function ap(h){if(!_k(h.h)&&!h.s){h.s=!0;var g=h.Ga;ce||$i(),un||(ce(),un=!0),ur.add(g,h),h.B=0}}function pH(h,g){return vk(h.h)>=h.h.j-(h.s?1:0)?!1:h.s?(h.i=g.D.concat(h.i),!0):h.G==1||h.G==2||h.B>=(h.Va?0:h.Wa)?!1:(h.s=Yu(f(h.Ga,h,g),Hk(h,h.B)),h.B++,!0)}n.Ga=function(h){if(this.s)if(this.s=null,this.G==1){if(!h){this.U=Math.floor(1e5*Math.random()),h=this.U++;let V=new To(this,this.j,h),U=this.o;if(this.S&&(U?(U=T(U),k(U,this.S)):U=this.S),this.m!==null||this.O||(V.H=U,U=null),this.P)e:{for(var g=0,b=0;b<this.i.length;b++){t:{var I=this.i[b];if("__data__"in I.map&&(I=I.map.__data__,typeof I=="string")){I=I.length;break t}I=void 0}if(I===void 0)break;if(g+=I,4096<g){g=b;break e}if(g===4096||b===this.i.length-1){g=b+1;break e}}g=1e3}else g=1e3;g=jk(this,V,g),b=Ss(this.I),xt(b,"RID",h),xt(b,"CVER",22),this.D&&xt(b,"X-HTTP-Session-Id",this.D),sd(this,b),U&&(this.O?g="headers="+encodeURIComponent(String(Rk(U)))+"&"+g:this.m&&Db(b,this.m,U)),xb(this.h,V),this.Ua&&xt(b,"TYPE","init"),this.P?(xt(b,"$req",g),xt(b,"SID","null"),V.T=!0,Tb(V,b,null)):Tb(V,b,g),this.G=2}}else this.G==3&&(h?Vk(this,h):this.i.length==0||_k(this.h)||Vk(this))};function Vk(h,g){var b;g?b=g.l:b=h.U++;let I=Ss(h.I);xt(I,"SID",h.K),xt(I,"RID",b),xt(I,"AID",h.T),sd(h,I),h.m&&h.o&&Db(I,h.m,h.o),b=new To(h,h.j,b,h.B+1),h.m===null&&(b.H=h.o),g&&(h.i=g.D.concat(h.i)),g=jk(h,b,1e3),b.I=Math.round(.5*h.wa)+Math.round(.5*h.wa*Math.random()),xb(h.h,b),Tb(b,I,g)}function sd(h,g){h.H&&$(h.H,function(b,I){xt(g,I,b)}),h.l&&Ek({},function(b,I){xt(g,I,b)})}function jk(h,g,b){b=Math.min(h.i.length,b);var I=h.l?f(h.l.Na,h.l,h):null;e:{var V=h.i;let U=-1;for(;;){let Z=["count="+b];U==-1?0<b?(U=V[0].g,Z.push("ofs="+U)):U=0:Z.push("ofs="+U);let It=!0;for(let _n=0;_n<b;_n++){let lt=V[_n].g,Pn=V[_n].map;if(lt-=U,0>lt)U=Math.max(0,V[_n].g-100),It=!1;else try{uH(Pn,Z,"req"+lt+"_")}catch{I&&I(Pn)}}if(It){I=Z.join("&");break e}}}return h=h.i.splice(0,b),g.D=h,I}function $k(h){if(!h.g&&!h.u){h.Y=1;var g=h.Fa;ce||$i(),un||(ce(),un=!0),ur.add(g,h),h.v=0}}function kb(h){return h.g||h.u||3<=h.v?!1:(h.Y++,h.u=Yu(f(h.Fa,h),Hk(h,h.v)),h.v++,!0)}n.Fa=function(){if(this.u=null,Uk(this),this.ba&&!(this.M||this.g==null||0>=this.R)){var h=2*this.R;this.j.info("BP detection timer enabled: "+h),this.A=Yu(f(this.ab,this),h)}},n.ab=function(){this.A&&(this.A=null,this.j.info("BP detection timeout reached."),this.j.info("Buffering proxy detected and switch to long-polling!"),this.F=!1,this.M=!0,Xn(10),op(this),Uk(this))};function Pb(h){h.A!=null&&(a.clearTimeout(h.A),h.A=null)}function Uk(h){h.g=new To(h,h.j,"rpc",h.Y),h.m===null&&(h.g.H=h.o),h.g.O=0;var g=Ss(h.qa);xt(g,"RID","rpc"),xt(g,"SID",h.K),xt(g,"AID",h.T),xt(g,"CI",h.F?"0":"1"),!h.F&&h.ja&&xt(g,"TO",h.ja),xt(g,"TYPE","xmlhttp"),sd(h,g),h.m&&h.o&&Db(g,h.m,h.o),h.L&&(h.g.I=h.L);var b=h.g;h=h.ia,b.L=1,b.v=rp(Ss(g)),b.m=null,b.P=!0,pk(b,h)}n.Za=function(){this.C!=null&&(this.C=null,op(this),kb(this),Xn(19))};function cp(h){h.C!=null&&(a.clearTimeout(h.C),h.C=null)}function Bk(h,g){var b=null;if(h.g==g){cp(h),Pb(h),h.g=null;var I=2}else if(Sb(h.h,g))b=g.D,bk(h.h,g),I=1;else return;if(h.G!=0){if(g.o)if(I==1){b=g.m?g.m.length:0,g=Date.now()-g.F;var V=h.B;I=Qf(),Yn(I,new uk(I,b)),ap(h)}else $k(h);else if(V=g.s,V==3||V==0&&0<g.X||!(I==1&&pH(h,g)||I==2&&kb(h)))switch(b&&0<b.length&&(g=h.h,g.i=g.i.concat(b)),V){case 1:Ea(h,5);break;case 4:Ea(h,10);break;case 3:Ea(h,6);break;default:Ea(h,2)}}}function Hk(h,g){let b=h.Ta+Math.floor(Math.random()*h.cb);return h.isActive()||(b*=2),b*g}function Ea(h,g){if(h.j.info("Error code "+g),g==2){var b=f(h.fb,h),I=h.Xa;let V=!I;I=new wa(I||"//www.google.com/images/cleardot.gif"),a.location&&a.location.protocol=="http"||tp(I,"https"),rp(I),V?aH(I.toString(),b):cH(I.toString(),b)}else Xn(2);h.G=0,h.l&&h.l.sa(g),qk(h),Fk(h)}n.fb=function(h){h?(this.j.info("Successfully pinged google.com"),Xn(2)):(this.j.info("Failed to ping google.com"),Xn(1))};function qk(h){if(h.G=0,h.ka=[],h.l){let g=wk(h.h);(g.length!=0||h.i.length!=0)&&(w(h.ka,g),w(h.ka,h.i),h.h.i.length=0,v(h.i),h.i.length=0),h.l.ra()}}function zk(h,g,b){var I=b instanceof wa?Ss(b):new wa(b);if(I.g!="")g&&(I.g=g+"."+I.g),np(I,I.s);else{var V=a.location;I=V.protocol,g=g?g+"."+V.hostname:V.hostname,V=+V.port;var U=new wa(null);I&&tp(U,I),g&&(U.g=g),V&&np(U,V),b&&(U.l=b),I=U}return b=h.D,g=h.ya,b&&g&&xt(I,b,g),xt(I,"VER",h.la),sd(h,I),I}function Gk(h,g,b){if(g&&!h.J)throw Error("Can't create secondary domain capable XhrIo object.");return g=h.Ca&&!h.pa?new jt(new td({eb:b})):new jt(h.pa),g.Ha(h.J),g}n.isActive=function(){return!!this.l&&this.l.isActive(this)};function Wk(){}n=Wk.prototype,n.ua=function(){},n.ta=function(){},n.sa=function(){},n.ra=function(){},n.isActive=function(){return!0},n.Na=function(){};function lp(){}lp.prototype.g=function(h,g){return new Ir(h,g)};function Ir(h,g){kn.call(this),this.g=new Lk(g),this.l=h,this.h=g&&g.messageUrlParams||null,h=g&&g.messageHeaders||null,g&&g.clientProtocolHeaderRequired&&(h?h["X-Client-Protocol"]="webchannel":h={"X-Client-Protocol":"webchannel"}),this.g.o=h,h=g&&g.initMessageHeaders||null,g&&g.messageContentType&&(h?h["X-WebChannel-Content-Type"]=g.messageContentType:h={"X-WebChannel-Content-Type":g.messageContentType}),g&&g.va&&(h?h["X-WebChannel-Client-Profile"]=g.va:h={"X-WebChannel-Client-Profile":g.va}),this.g.S=h,(h=g&&g.Sb)&&!A(h)&&(this.g.m=h),this.v=g&&g.supportsCrossDomainXhr||!1,this.u=g&&g.sendRawJson||!1,(g=g&&g.httpSessionIdParam)&&!A(g)&&(this.g.D=g,h=this.h,h!==null&&g in h&&(h=this.h,g in h&&delete h[g])),this.j=new Wc(this)}y(Ir,kn),Ir.prototype.m=function(){this.g.l=this.j,this.v&&(this.g.J=!0),this.g.connect(this.l,this.h||void 0)},Ir.prototype.close=function(){Rb(this.g)},Ir.prototype.o=function(h){var g=this.g;if(typeof h=="string"){var b={};b.__data__=h,h=b}else this.u&&(b={},b.__data__=_b(h),h=b);g.i.push(new Q3(g.Ya++,h)),g.G==3&&ap(g)},Ir.prototype.N=function(){this.g.l=null,delete this.j,Rb(this.g),delete this.g,Ir.aa.N.call(this)};function Kk(h){bb.call(this),h.__headers__&&(this.headers=h.__headers__,this.statusCode=h.__status__,delete h.__headers__,delete h.__status__);var g=h.__sm__;if(g){e:{for(let b in g){h=b;break e}h=void 0}(this.i=h)&&(h=this.i,g=g!==null&&h in g?g[h]:void 0),this.data=g}else this.data=h}y(Kk,bb);function Yk(){wb.call(this),this.status=1}y(Yk,wb);function Wc(h){this.g=h}y(Wc,Wk),Wc.prototype.ua=function(){Yn(this.g,"a")},Wc.prototype.ta=function(h){Yn(this.g,new Kk(h))},Wc.prototype.sa=function(h){Yn(this.g,new Yk)},Wc.prototype.ra=function(){Yn(this.g,"b")},lp.prototype.createWebChannel=lp.prototype.g,Ir.prototype.send=Ir.prototype.o,Ir.prototype.open=Ir.prototype.m,Ir.prototype.close=Ir.prototype.close,jT=Zs.createWebChannelTransport=function(){return new lp},VT=Zs.getStatEventTarget=function(){return Qf()},FT=Zs.Event=va,Xg=Zs.Stat={mb:0,pb:1,qb:2,Jb:3,Ob:4,Lb:5,Mb:6,Kb:7,Ib:8,Nb:9,PROXY:10,NOPROXY:11,Gb:12,Cb:13,Db:14,Bb:15,Eb:16,Fb:17,ib:18,hb:19,jb:20},Zf.NO_ERROR=0,Zf.TIMEOUT=8,Zf.HTTP_ERROR=6,gh=Zs.ErrorCode=Zf,dk.COMPLETE="complete",LT=Zs.EventType=dk,ok.EventType=Wu,Wu.OPEN="a",Wu.CLOSE="b",Wu.ERROR="c",Wu.MESSAGE="d",kn.prototype.listen=kn.prototype.K,zl=Zs.WebChannel=ok,mQ=Zs.FetchXmlHttpFactory=td,jt.prototype.listenOnce=jt.prototype.L,jt.prototype.getLastError=jt.prototype.Ka,jt.prototype.getLastErrorCode=jt.prototype.Ba,jt.prototype.getStatus=jt.prototype.Z,jt.prototype.getResponseJson=jt.prototype.Oa,jt.prototype.getResponseText=jt.prototype.oa,jt.prototype.send=jt.prototype.ea,jt.prototype.setWithCredentials=jt.prototype.Ha,OT=Zs.XhrIo=jt}).apply(typeof Yg<"u"?Yg:typeof self<"u"?self:typeof window<"u"?window:{});var AF="@firebase/firestore";var mn=class{constructor(e){this.uid=e}isAuthenticated(){return this.uid!=null}toKey(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"}isEqual(e){return e.uid===this.uid}};mn.UNAUTHENTICATED=new mn(null),mn.GOOGLE_CREDENTIALS=new mn("google-credentials-uid"),mn.FIRST_PARTY=new mn("first-party-uid"),mn.MOCK_USER=new mn("mock-user");var uu="10.14.0";var oc=new Go("@firebase/firestore");function yh(){return oc.logLevel}function de(n,...e){if(oc.logLevel<=tt.DEBUG){let t=e.map(EC);oc.debug(`Firestore (${uu}): ${n}`,...t)}}function eo(n,...e){if(oc.logLevel<=tt.ERROR){let t=e.map(EC);oc.error(`Firestore (${uu}): ${n}`,...t)}}function Zl(n,...e){if(oc.logLevel<=tt.WARN){let t=e.map(EC);oc.warn(`Firestore (${uu}): ${n}`,...t)}}function EC(n){if(typeof n=="string")return n;try{return function(t){return JSON.stringify(t)}(n)}catch{return n}}function Se(n="Unexpected state"){let e=`FIRESTORE (${uu}) INTERNAL ASSERTION FAILED: `+n;throw eo(e),new Error(e)}function bt(n,e){n||Se()}function Pe(n,e){return n}var q={OK:"ok",CANCELLED:"cancelled",UNKNOWN:"unknown",INVALID_ARGUMENT:"invalid-argument",DEADLINE_EXCEEDED:"deadline-exceeded",NOT_FOUND:"not-found",ALREADY_EXISTS:"already-exists",PERMISSION_DENIED:"permission-denied",UNAUTHENTICATED:"unauthenticated",RESOURCE_EXHAUSTED:"resource-exhausted",FAILED_PRECONDITION:"failed-precondition",ABORTED:"aborted",OUT_OF_RANGE:"out-of-range",UNIMPLEMENTED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"},ne=class extends In{constructor(e,t){super(e,t),this.code=e,this.message=t,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}};var cs=class{constructor(){this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}};var ty=class{constructor(e,t){this.user=t,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${e}`)}},qT=class{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,t){e.enqueueRetryable(()=>t(mn.UNAUTHENTICATED))}shutdown(){}},zT=class{constructor(e){this.token=e,this.changeListener=null}getToken(){return Promise.resolve(this.token)}invalidateToken(){}start(e,t){this.changeListener=t,e.enqueueRetryable(()=>t(this.token.user))}shutdown(){this.changeListener=null}},GT=class{constructor(e){this.t=e,this.currentUser=mn.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(e,t){bt(this.o===void 0);let r=this.i,i=c=>this.i!==r?(r=this.i,t(c)):Promise.resolve(),s=new cs;this.o=()=>{this.i++,this.currentUser=this.u(),s.resolve(),s=new cs,e.enqueueRetryable(()=>i(this.currentUser))};let o=()=>{let c=s;e.enqueueRetryable(()=>m(this,null,function*(){yield c.promise,yield i(this.currentUser)}))},a=c=>{de("FirebaseAuthCredentialsProvider","Auth detected"),this.auth=c,this.o&&(this.auth.addAuthTokenListener(this.o),o())};this.t.onInit(c=>a(c)),setTimeout(()=>{if(!this.auth){let c=this.t.getImmediate({optional:!0});c?a(c):(de("FirebaseAuthCredentialsProvider","Auth not yet detected"),s.resolve(),s=new cs)}},0),o()}getToken(){let e=this.i,t=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(t).then(r=>this.i!==e?(de("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):r?(bt(typeof r.accessToken=="string"),new ty(r.accessToken,this.currentUser)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.auth&&this.o&&this.auth.removeAuthTokenListener(this.o),this.o=void 0}u(){let e=this.auth&&this.auth.getUid();return bt(e===null||typeof e=="string"),new mn(e)}},WT=class{constructor(e,t,r){this.l=e,this.h=t,this.P=r,this.type="FirstParty",this.user=mn.FIRST_PARTY,this.I=new Map}T(){return this.P?this.P():null}get headers(){this.I.set("X-Goog-AuthUser",this.l);let e=this.T();return e&&this.I.set("Authorization",e),this.h&&this.I.set("X-Goog-Iam-Authorization-Token",this.h),this.I}},KT=class{constructor(e,t,r){this.l=e,this.h=t,this.P=r}getToken(){return Promise.resolve(new WT(this.l,this.h,this.P))}start(e,t){e.enqueueRetryable(()=>t(mn.FIRST_PARTY))}shutdown(){}invalidateToken(){}},YT=class{constructor(e){this.value=e,this.type="AppCheck",this.headers=new Map,e&&e.length>0&&this.headers.set("x-firebase-appcheck",this.value)}},XT=class{constructor(e){this.A=e,this.forceRefresh=!1,this.appCheck=null,this.R=null}start(e,t){bt(this.o===void 0);let r=s=>
17{s.error!=null&&de("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${s.error.message}`);let o=s.token!==this.R;return this.R=s.token,de("FirebaseAppCheckTokenProvider",`Received ${o?"new":"existing"} token.`),o?t(s.token):Promise.resolve()};this.o=s=>{e.enqueueRetryable(()=>r(s))};let i=s=>{de("FirebaseAppCheckTokenProvider","AppCheck detected"),this.appCheck=s,this.o&&this.appCheck.addTokenListener(this.o)};this.A.onInit(s=>i(s)),setTimeout(()=>{if(!this.appCheck){let s=this.A.getImmediate({optional:!0});s?i(s):de("FirebaseAppCheckTokenProvider","AppCheck not yet detected")}},0)}getToken(){let e=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(e).then(t=>t?(bt(typeof t.token=="string"),this.R=t.token,new YT(t.token)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.o&&this.appCheck.removeTokenListener(this.o),this.o=void 0}};function gQ(n){let e=typeof self<"u"&&(self.crypto||self.msCrypto),t=new Uint8Array(n);if(e&&typeof e.getRandomValues=="function")e.getRandomValues(t);else for(let r=0;r<n;r++)t[r]=Math.floor(256*Math.random());return t}var ny=class{static newId(){let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",t=Math.floor(256/e.length)*e.length,r="";for(;r.length<20;){let i=gQ(40);for(let s=0;s<i.length;++s)r.length<20&&i[s]<t&&(r+=e.charAt(i[s]%e.length))}return r}};function ut(n,e){return n<e?-1:n>e?1:0}function Jl(n,e,t){return n.length===e.length&&n.every((r,i)=>t(r,e[i]))}var Tn=class n{constructor(e,t){if(this.seconds=e,this.nanoseconds=t,t<0)throw new ne(q.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(t>=1e9)throw new ne(q.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(e<-62135596800)throw new ne(q.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e);if(e>=253402300800)throw new ne(q.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e)}static now(){return n.fromMillis(Date.now())}static fromDate(e){return n.fromMillis(e.getTime())}static fromMillis(e){let t=Math.floor(e/1e3),r=Math.floor(1e6*(e-1e3*t));return new n(t,r)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/1e6}_compareTo(e){return this.seconds===e.seconds?ut(this.nanoseconds,e.nanoseconds):ut(this.seconds,e.seconds)}isEqual(e){return e.seconds===this.seconds&&e.nanoseconds===this.nanoseconds}toString(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"}toJSON(){return{seconds:this.seconds,nanoseconds:this.nanoseconds}}valueOf(){let e=this.seconds- -62135596800;return String(e).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}};var Le=class n{constructor(e){this.timestamp=e}static fromTimestamp(e){return new n(e)}static min(){return new n(new Tn(0,0))}static max(){return new n(new Tn(253402300799,999999999))}compareTo(e){return this.timestamp._compareTo(e.timestamp)}isEqual(e){return this.timestamp.isEqual(e.timestamp)}toMicroseconds(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3}toString(){return"SnapshotVersion("+this.timestamp.toString()+")"}toTimestamp(){return this.timestamp}};var ry=class n{constructor(e,t,r){t===void 0?t=0:t>e.length&&Se(),r===void 0?r=e.length-t:r>e.length-t&&Se(),this.segments=e,this.offset=t,this.len=r}get length(){return this.len}isEqual(e){return n.comparator(this,e)===0}child(e){let t=this.segments.slice(this.offset,this.limit());return e instanceof n?e.forEach(r=>{t.push(r)}):t.push(e),this.construct(t)}limit(){return this.offset+this.length}popFirst(e){return e=e===void 0?1:e,this.construct(this.segments,this.offset+e,this.length-e)}popLast(){return this.construct(this.segments,this.offset,this.length-1)}firstSegment(){return this.segments[this.offset]}lastSegment(){return this.get(this.length-1)}get(e){return this.segments[this.offset+e]}isEmpty(){return this.length===0}isPrefixOf(e){if(e.length<this.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}isImmediateParentOf(e){if(this.length+1!==e.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}forEach(e){for(let t=this.offset,r=this.limit();t<r;t++)e(this.segments[t])}toArray(){return this.segments.slice(this.offset,this.limit())}static comparator(e,t){let r=Math.min(e.length,t.length);for(let i=0;i<r;i++){let s=e.get(i),o=t.get(i);if(s<o)return-1;if(s>o)return 1}return e.length<t.length?-1:e.length>t.length?1:0}},Ft=class n extends ry{construct(e,t,r){return new n(e,t,r)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}
vendor: 2,152 bytes, line 17
17toUriEncodedString(){return this.toArray().map(encodeURIComponent).join("/")}static fromString(...e){let t=[];for(let r of e){if(r.indexOf("//")>=0)throw new ne(q.INVALID_ARGUMENT,`Invalid segment (${r}). Paths must not contain // in them.`);t.push(...r.split("/").filter(i=>i.length>0))}return new n(t)}static emptyPath(){return new n([])}},yQ=/^[_a-zA-Z][_a-zA-Z0-9]*$/,Fr=class n extends ry{construct(e,t,r){return new n(e,t,r)}static isValidIdentifier(e){return yQ.test(e)}canonicalString(){return this.toArray().map(e=>(e=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),n.isValidIdentifier(e)||(e="`"+e+"`"),e)).join(".")}toString(){return this.canonicalString()}isKeyField(){return this.length===1&&this.get(0)==="__name__"}static keyField(){return new n(["__name__"])}static fromServerFormat(e){let t=[],r="",i=0,s=()=>{if(r.length===0)throw new ne(q.INVALID_ARGUMENT,`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);t.push(r),r=""},o=!1;for(;i<e.length;){let a=e[i];if(a==="\\"){if(i+1===e.length)throw new ne(q.INVALID_ARGUMENT,"Path has trailing escape character: "+e);let c=e[i+1];if(c!=="\\"&&c!=="."&&c!=="`")throw new ne(q.INVALID_ARGUMENT,"Path has invalid escape sequence: "+e);r+=c,i+=2}else a==="`"?(o=!o,i++):a!=="."||o?(r+=a,i++):(s(),i++)}if(s(),o)throw new ne(q.INVALID_ARGUMENT,"Unterminated ` in path: "+e);return new n(t)}static emptyPath(){return new n([])}};var Ee=class n{constructor(e){this.path=e}static fromPath(e){return new n(Ft.fromString(e))}static fromName(e){return new n(Ft.fromString(e).popFirst(5))}static empty(){return new n(Ft.emptyPath())}get collectionGroup(){return this.path.popLast().lastSegment()}hasCollectionId(e){return this.path.length>=2&&this.path.get(this.path.length-2)===e}getCollectionGroup(){return this.path.get(this.path.length-2)}getCollectionPath(){return this.path.popLast()}isEqual(e){return e!==null&&Ft.comparator(this.path,e.path)===0}toString(){return this.path.toString()}static comparator(e,t){return Ft.comparator(e.path,t.path)}static isDocumentKey(e){return e.length%2==0}static fromSegments(e){return new n(new Ft(e.slice()))}};
17var QT=class{constructor(e,t,r,i){this.indexId=e,this.collectionGroup=t,this.fields=r,this.indexState=i}};QT.UNKNOWN_ID=-1;function _Q(n,e){let t=n.toTimestamp().seconds,r=n.toTimestamp().nanoseconds+1,i=Le.fromTimestamp(r===1e9?new Tn(t+1,0):new Tn(t,r));return new ac(i,Ee.empty(),e)}function vQ(n){return new ac(n.readTime,n.key,-1)}var ac=class n{constructor(e,t,r){this.readTime=e,this.documentKey=t,this.largestBatchId=r}static min(){return new n(Le.min(),Ee.empty(),-1)}static max(){return new n(Le.max(),Ee.empty(),-1)}};function bQ(n,e){let t=n.readTime.compareTo(e.readTime);return t!==0?t:(t=Ee.comparator(n.documentKey,e.documentKey),t!==0?t:ut(n.largestBatchId,e.largestBatchId))}var wQ="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.",ZT=class{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(e){this.onCommittedListeners.push(e)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach(e=>e())}};function Lh(n){return m(this,null,function*(){if(n.code!==q.FAILED_PRECONDITION||n.message!==wQ)throw n;de("LocalStore","Unexpectedly lost primary lease")})}var X=class n{constructor(e){this.nextCallback=null,this.catchCallback=null,this.result=void 0,this.error=void 0,this.isDone=!1,this.callbackAttached=!1,e(t=>{this.isDone=!0,this.result=t,this.nextCallback&&this.nextCallback(t)},t=>{this.isDone=!0,this.error=t,this.catchCallback&&this.catchCallback(t)})}catch(e){return this.next(void 0,e)}next(e,t){return this.callbackAttached&&Se(),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(t,this.error):this.wrapSuccess(e,this.result):new n((r,i)=>{this.nextCallback=s=>{this.wrapSuccess(e,s).next(r,i)},this.catchCallback=s=>{this.wrapFailure(t,s).next(r,i)}})}toPromise(){return new Promise((e,t)=>{this.next(e,t)})}wrapUserFunction(e){try{let t=e();return t instanceof n?t:n.resolve(t)}catch(t){return n.reject(t)}}wrapSuccess(e,t){return e?this.wrapUserFunction(()=>e(t)):n.resolve(t)}wrapFailure(e,t){return e?this.wrapUserFunction(()=>e(t)):n.reject(t)}static resolve(e){return new n((t,r)=>{t(e)})}static reject(e){return new n((t,r)=>{r(e)})}static waitFor(e){return new n((t,r)=>{let i=0,s=0,o=!1;e.forEach(a=>{++i,a.next(()=>{++s,o&&s===i&&t()},c=>r(c))}),o=!0,s===i&&t()})}static or(e){let t=n.resolve(!1);for(let r of e)t=t.next(i=>i?n.resolve(i):r());return t}static forEach(e,t){let r=[];return e.forEach((i,s)=>{r.push(t.call(this,i,s))}),this.waitFor(r)}static mapArray(e,t){return new n((r,i)=>{let s=e.length,o=new Array(s),a=0;for(let c=0;c<s;c++){let l=c;t(e[l]).next(u=>{o[l]=u,++a,a===s&&r(o)},u=>i(u))}})}static doWhile(e,t){return new n((r,i)=>{let s=()=>{e()===!0?t().next(()=>{s()},i):r()};s()})}};function EQ(n){let e=n.match(/Android ([\d.]+)/i),t=e?e[1].split(".").slice(0,2).join("."):"-1";return Number(t)}function Fh(n){return n.name==="IndexedDbTransactionError"}var o2=(()=>{class n{constructor(t,r){this.previousValue=t,r&&(r.sequenceNumberHandler=i=>this.ie(i),this.se=i=>r.writeSequenceNumber(i))}ie(t){return this.previousValue=Math.max(t,this.previousValue),this.previousValue}next(){let t=++this.previousValue;return this.se&&this.se(t),t}}return n.oe=-1,n})();function Ly(n){return n==null}function Ih(n){return n===0&&1/n==-1/0}function IQ(n){return typeof n=="number"&&Number.isInteger(n)&&!Ih(n)&&n<=Number.MAX_SAFE_INTEGER&&n>=Number.MIN_SAFE_INTEGER}var TQ=["mutationQueues","mutations","documentMutations","remoteDocuments","targets","owner","targetGlobal","targetDocuments","clientMetadata","remoteDocumentGlobal","collectionParents","bundles","namedQueries"],twe=[...TQ,"documentOverlays"],AQ=["mutationQueues","mutations","documentMutations","remoteDocumentsV14","targets","owner","targetGlobal","targetDocuments","clientMetadata","remoteDocumentGlobal","collectionParents","bundles","namedQueries","documentOverlays"],CQ=AQ,SQ=[...CQ,"indexConfiguration","indexState","indexEntries"];var nwe=[...SQ,"globals"];function CF(n){let e=0;for(let t in n)Object.prototype.hasOwnProperty.call(n,t)&&e++;return e}function fc(n,e){for(let t in n)Object.prototype.hasOwnProperty.call(n,t)&&e(t,n[t])}function a2(n){for(let e in n)if(Object.prototype.hasOwnProperty.call(n,e))return!1;return!0}var Bt=class n{constructor(e,t){this.comparator=e,this.root=t||ls.EMPTY}insert(e,t){return new n(this.comparator,this.root.insert(e,t,this.comparator).copy(null,null,ls.BLACK,null,
vendor: 6,314 bytes, line 17
17null))}remove(e){return new n(this.comparator,this.root.remove(e,this.comparator).copy(null,null,ls.BLACK,null,null))}get(e){let t=this.root;for(;!t.isEmpty();){let r=this.comparator(e,t.key);if(r===0)return t.value;r<0?t=t.left:r>0&&(t=t.right)}return null}indexOf(e){let t=0,r=this.root;for(;!r.isEmpty();){let i=this.comparator(e,r.key);if(i===0)return t+r.left.size;i<0?r=r.left:(t+=r.left.size+1,r=r.right)}return-1}isEmpty(){return this.root.isEmpty()}get size(){return this.root.size}minKey(){return this.root.minKey()}maxKey(){return this.root.maxKey()}inorderTraversal(e){return this.root.inorderTraversal(e)}forEach(e){this.inorderTraversal((t,r)=>(e(t,r),!1))}toString(){let e=[];return this.inorderTraversal((t,r)=>(e.push(`${t}:${r}`),!1)),`{${e.join(", ")}}`}reverseTraversal(e){return this.root.reverseTraversal(e)}getIterator(){return new Yl(this.root,null,this.comparator,!1)}getIteratorFrom(e){return new Yl(this.root,e,this.comparator,!1)}getReverseIterator(){return new Yl(this.root,null,this.comparator,!0)}getReverseIteratorFrom(e){return new Yl(this.root,e,this.comparator,!0)}},Yl=class{constructor(e,t,r,i){this.isReverse=i,this.nodeStack=[];let s=1;for(;!e.isEmpty();)if(s=t?r(e.key,t):1,t&&i&&(s*=-1),s<0)e=this.isReverse?e.left:e.right;else{if(s===0){this.nodeStack.push(e);break}this.nodeStack.push(e),e=this.isReverse?e.right:e.left}}getNext(){let e=this.nodeStack.pop(),t={key:e.key,value:e.value};if(this.isReverse)for(e=e.left;!e.isEmpty();)this.nodeStack.push(e),e=e.right;else for(e=e.right;!e.isEmpty();)this.nodeStack.push(e),e=e.left;return t}hasNext(){return this.nodeStack.length>0}peek(){if(this.nodeStack.length===0)return null;let e=this.nodeStack[this.nodeStack.length-1];return{key:e.key,value:e.value}}},ls=class n{constructor(e,t,r,i,s){this.key=e,this.value=t,this.color=r??n.RED,this.left=i??n.EMPTY,this.right=s??n.EMPTY,this.size=this.left.size+1+this.right.size}copy(e,t,r,i,s){return new n(e??this.key,t??this.value,r??this.color,i??this.left,s??this.right)}isEmpty(){return!1}inorderTraversal(e){return this.left.inorderTraversal(e)||e(this.key,this.value)||this.right.inorderTraversal(e)}reverseTraversal(e){return this.right.reverseTraversal(e)||e(this.key,this.value)||this.left.reverseTraversal(e)}min(){return this.left.isEmpty()?this:this.left.min()}minKey(){return this.min().key}maxKey(){return this.right.isEmpty()?this.key:this.right.maxKey()}insert(e,t,r){let i=this,s=r(e,i.key);return i=s<0?i.copy(null,null,null,i.left.insert(e,t,r),null):s===0?i.copy(null,t,null,null,null):i.copy(null,null,null,null,i.right.insert(e,t,r)),i.fixUp()}removeMin(){if(this.left.isEmpty())return n.EMPTY;let e=this;return e.left.isRed()||e.left.left.isRed()||(e=e.moveRedLeft()),e=e.copy(null,null,null,e.left.removeMin(),null),e.fixUp()}remove(e,t){let r,i=this;if(t(e,i.key)<0)i.left.isEmpty()||i.left.isRed()||i.left.left.isRed()||(i=i.moveRedLeft()),i=i.copy(null,null,null,i.left.remove(e,t),null);else{if(i.left.isRed()&&(i=i.rotateRight()),i.right.isEmpty()||i.right.isRed()||i.right.left.isRed()||(i=i.moveRedRight()),t(e,i.key)===0){if(i.right.isEmpty())return n.EMPTY;r=i.right.min(),i=i.copy(r.key,r.value,null,null,i.right.removeMin())}i=i.copy(null,null,null,null,i.right.remove(e,t))}return i.fixUp()}isRed(){return this.color}fixUp(){let e=this;return e.right.isRed()&&!e.left.isRed()&&(e=e.rotateLeft()),e.left.isRed()&&e.left.left.isRed()&&(e=e.rotateRight()),e.left.isRed()&&e.right.isRed()&&(e=e.colorFlip()),e}moveRedLeft(){let e=this.colorFlip();return e.right.left.isRed()&&(e=e.copy(null,null,null,null,e.right.rotateRight()),e=e.rotateLeft(),e=e.colorFlip()),e}moveRedRight(){let e=this.colorFlip();return e.left.left.isRed()&&(e=e.rotateRight(),e=e.colorFlip()),e}rotateLeft(){let e=this.copy(null,null,n.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight(){let e=this.copy(null,null,n.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)}colorFlip(){let e=this.left.copy(null,null,!this.left.color,null,null),t=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,e,t)}checkMaxDepth(){let e=this.check();return Math.pow(2,e)<=this.size+1}check(){if(this.isRed()&&this.left.isRed()||this.right.isRed())throw Se();let e=this.left.check();if(e!==this.right.check())throw Se();return e+(this.isRed()?0:1)}};ls.EMPTY=null,ls.RED=!0,ls.BLACK=!1;ls.EMPTY=new class{constructor(){this.size=0}get key(){throw Se()}get value(){throw Se()}get color(){throw Se()}get left(){throw Se()}get right(){throw Se()}copy(e,t,r,i,s){return this}insert(e,t,r){return new ls(e,t)}remove(e,t){return this}isEmpty(){return!0}inorderTraversal(e){return!1}reverseTraversal(e){return!1}minKey(){return null}maxKey(){return null}isRed(){return!1}checkMaxDepth(){return!0}check(){return 0}};var Vn=class n{constructor(e){this.comparator=e,this.data=new Bt(this.comparator)}has(e){return this.data.get(e)!==null}first(){return this.data.minKey()}last(){return this.data.maxKey()}get size(){return this.data.size}indexOf(e){return this.data.indexOf(e)}forEach(e){this.data.inorderTraversal((t,r)=>(e(t),!1))}forEachInRange(e,t){let r=this.data.getIteratorFrom(e[0]);for(;r.hasNext();){let i=r.getNext();if(this.comparator(i.key,e[1])>=0)return;t(i.key)}}forEachWhile(e,t){let r;for(r=t!==void 0?this.data.getIteratorFrom(t):this.data.getIterator();r.hasNext();)if(!e(r.getNext().key))return}firstAfterOrEqual(e){let t=this.data.getIteratorFrom(e);return t.hasNext()?t.getNext().key:null}getIterator(){return new iy(this.data.getIterator())}getIteratorFrom(e){return new iy(this.data.getIteratorFrom(e))}add(e){return this.copy(this.data.remove(e).insert(e,!0))}delete(e){return this.has(e)?this.copy(this.data.remove(e)):this}isEmpty(){return this.data.isEmpty()}unionWith(e){let t=this;return t.size<e.size&&(t=e,e=this),e.forEach(r=>{t=t.add(r)}),t}isEqual(e){if(!(e instanceof n)||this.size!==e.size)return!1;let t=this.data.getIterator(),r=e.data.getIterator();for(;t.hasNext();){let i=t.getNext().key,s=r.getNext().key;if(this.comparator(i,s)!==0)return!1}return!0}toArray(){let e=[];return this.forEach(t=>{e.push(t)}),e}toString(){let e=[];return this.forEach(t=>e.push(t)),"SortedSet("+e.toString()+")"}copy(e){let t=new n(this.comparator);return t.data=e,t}}
17,iy=class{constructor(e){this.iter=e}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}};var Xr=class n{constructor(e){this.fields=e,e.sort(Fr.comparator)}static empty(){return new n([])}unionWith(e){let t=new Vn(Fr.comparator);for(let r of this.fields)t=t.add(r);for(let r of e)t=t.add(r);return new n(t.toArray())}covers(e){for(let t of this.fields)if(t.isPrefixOf(e))return!0;return!1}isEqual(e){return Jl(this.fields,e.fields,(t,r)=>t.isEqual(r))}};var sy=class extends Error{constructor(){super(...arguments),this.name="Base64DecodeError"}};var jn=class n{constructor(e){this.binaryString=e}static fromBase64String(e){let t=function(i){try{return atob(i)}catch(s){throw typeof DOMException<"u"&&s instanceof DOMException?new sy("Invalid base64 string: "+s):s}}(e);return new n(t)}static fromUint8Array(e){let t=function(i){let s="";for(let o=0;o<i.length;++o)s+=String.fromCharCode(i[o]);return s}(e);return new n(t)}[Symbol.iterator](){let e=0;return{next:()=>e<this.binaryString.length?{value:this.binaryString.charCodeAt(e++),done:!1}:{value:void 0,done:!0}}}toBase64(){return function(t){return btoa(t)}(this.binaryString)}toUint8Array(){return function(t){let r=new Uint8Array(t.length);for(let i=0;i<t.length;i++)r[i]=t.charCodeAt(i);return r}(this.binaryString)}approximateByteSize(){return 2*this.binaryString.length}compareTo(e){return ut(this.binaryString,e.binaryString)}isEqual(e){return this.binaryString===e.binaryString}};jn.EMPTY_BYTE_STRING=new jn("");var xQ=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function to(n){if(bt(!!n),typeof n=="string"){let e=0,t=xQ.exec(n);if(bt(!!t),t[1]){let i=t[1];i=(i+"000000000").substr(0,9),e=Number(i)}let r=new Date(n);return{seconds:Math.floor(r.getTime()/1e3),nanos:e}}return{seconds:Nt(n.seconds),nanos:Nt(n.nanos)}}function Nt(n){return typeof n=="number"?n:typeof n=="string"?Number(n):0}function Jo(n){return typeof n=="string"?jn.fromBase64String(n):jn.fromUint8Array(n)}function IC(n){var e,t;return((t=(((e=n?.mapValue)===null||e===void 0?void 0:e.fields)||{}).__type__)===null||t===void 0?void 0:t.stringValue)==="server_timestamp"}function TC(n){let e=n.mapValue.fields.__previous_value__;return IC(e)?TC(e):e}function Th(n){let e=to(n.mapValue.fields.__local_write_time__.timestampValue);return new Tn(e.seconds,e.nanos)}var JT=class{constructor(e,t,r,i,s,o,a,c,l){this.databaseId=e,this.appId=t,this.persistenceKey=r,this.host=i,this.ssl=s,this.forceLongPolling=o,this.autoDetectLongPolling=a,this.longPollingOptions=c,this.useFetchStreams=l}},oy=class n{constructor(e,t){this.projectId=e,this.database=t||"(default)"}static empty(){return new n("","")}get isDefaultDatabase(){return this.database==="(default)"}isEqual(e){return e instanceof n&&e.projectId===this.projectId&&e.database===this.database}};var Qg={mapValue:{fields:{__type__:{stringValue:"__max__"}}}};function cc(n){return"nullValue"in n?0:"booleanValue"in n?1:"integerValue"in n||"doubleValue"in n?2:"timestampValue"in n?3:"stringValue"in n?5:"bytesValue"in n?6:"referenceValue"in n?7:"geoPointValue"in n?8:"arrayValue"in n?9:"mapValue"in n?IC(n)?4:l2(n)?9007199254740991:c2(n)?10:11:Se()}function hs(n,e){if(n===e)return!0;let t=cc(n);if(t!==cc(e))return!1;switch(t){case 0:case 9007199254740991:return!0;case 1:return n.booleanValue===e.booleanValue;case 4:return Th(n).isEqual(Th(e));case 3:return function(i,s){if(typeof i.timestampValue=="string"&&typeof s.timestampValue=="string"&&i.timestampValue.length===s.timestampValue.length)return i.timestampValue===s.timestampValue;let o=to(i.timestampValue),a=to(s.timestampValue);return o.seconds===a.seconds&&o.nanos===a.nanos}(n,e);case 5:return n.stringValue===e.stringValue;case 6:return function(i,s){return Jo(i.bytesValue).isEqual(Jo(s.bytesValue))}(n,e);case 7:return n.referenceValue===e.referenceValue;case 8:return function(i,s){return Nt(i.geoPointValue.latitude)===Nt(s.geoPointValue.latitude)&&Nt(i.geoPointValue.longitude)===Nt(s.geoPointValue.longitude)}(n,e);case 2:return function(i,s){if("integerValue"in i&&"integerValue"in s)return Nt(i.integerValue)===Nt(s.integerValue);if("doubleValue"in i&&"doubleValue"in s){let o=Nt(i.doubleValue),a=Nt(s.doubleValue);return o===a?Ih(o)===Ih(a):isNaN(o)&&isNaN(a)}return!1}(n,e);case 9:return Jl(n.arrayValue.values||[],e.arrayValue.values||[],hs);case 10:case 11:return function(i,s){let o=i.mapValue.fields||{},a=s.mapValue.fields||{};if(CF(o)!==CF(a))return!1;for(let c in o)if(o.hasOwnProperty(c)&&(a[c]===void 0||!hs(o[c],a[c])))return!1;return!0}(n,e);default:return Se()}}function Ah(n,e){return(n.values||[]).find(t=>hs(t,e))!==void 0}function eu(n,e){if(n===e)return 0;let t=cc(n),r=cc(e);if(t!==r)return ut(t,r);switch(t){case 0:case 9007199254740991:return 0;case 1:return ut(n.booleanValue,e.booleanValue);case 2:return function(s,o){let a=Nt(s.integerValue||s.doubleValue),c=Nt(o.integerValue||o.doubleValue);return a<c?-1:a>c?1:a===c?0:isNaN(a)?isNaN(c)?0:-1:1}(n,e);case 3:return SF(n.timestampValue,e.timestampValue);case 4:return SF(Th(n),Th(e));case 5:return ut(n.stringValue,e.stringValue);case 6:return function(s,o){let a=Jo(s),c=Jo(o);return a.compareTo(c)}(n.bytesValue,e.bytesValue);case 7:return function(s,o){let a=s.split("/"),c=o.split("/");for(let l=0;l<a.length&&l<c.length;l++){let u=ut(a[l],c[l]);if(u!==0)return u}return ut(a.length,c.length)}(n.referenceValue,e.referenceValue);case 8:return function(s,o){let a=ut(Nt(s.latitude),Nt(o.latitude));return a!==0?a:ut(Nt(s.longitude),Nt(o.longitude))}(n.geoPointValue,e.geoPointValue);case 9:return xF(n.arrayValue,e.arrayValue);case 10:return function(s,o){var a,c,l,u;let d=s.fields||{},f=o.fields||{},p=(a=d.value)===null||a===void 0?void 0:a.arrayValue,y=(c=f.value)===null||c===void 0?void 0:c.arrayValue,v=ut(((l=p?.values)===null||l===void 0?void 0:l.length)||0,((u=y?.values)===null||u===void 0?void 0:u.length)||0);return v!==0?v:xF(p,y)}(n.mapValue,e.mapValue);case 11:return function(s,o){if(s===Qg.mapValue&&o===Qg.mapValue)return 0;if(s===Qg.mapValue)return 1;if(o===Qg.mapValue)return-1;let a=s.fields||{},c=Object.keys(a),l=o.fields||{},u=Object.keys(l);c.sort(),u.sort();for(let d=0;d<c.length&&d<u.length;++d){let f=ut(c[d],u[d]);if(f!==0)return f;let p=eu(a[c[d]],l[u[d]]);if(p!==0)return p}return ut(c.length,u.length)}(n.mapValue,e.mapValue);default:throw Se()}}function SF(n,e){if(typeof n=="string"&&typeof e=="string"&&n.length===e.length)return ut(n,e);let t=to(n),r=to(e),i=ut(t.seconds,r.seconds);return i!==0?i:ut(t.nanos,r.nanos)}function xF(n,e){let t=n.values||[],r=e.values||[];for(let i=0;i<t.length&&i<r.length;++i){let s=eu(t[i],r[i]);if(s)return s}return ut(t.length,r.length)}function tu(n){return eA(n)}function eA(n){return"nullValue"in n?"null":"booleanValue"in n?""+n.booleanValue:"integerValue"in n?""+n.integerValue:"doubleValue"in n?""+n.doubleValue:"timestampValue"in n?function(t){let r=to(t);return`time(${r.seconds},${r.nanos})`}(n.timestampValue):"stringValue"in n?n.stringValue:"bytesValue"in n?function(t){return Jo(t).toBase64()}(n.bytesValue):"referenceValue"in n?function(t){return Ee.fromName(t).toString()}(n.referenceValue):"geoPointValue"in n?function(t){return`geo(${t.latitude},${t.longitude})`}(n.geoPointValue):"arrayValue"in n?function(t){let r="[",i=!0;for(let s of t.values||[])i?i=!1:r+=",",r+=eA(s);return r+"]"}(n.arrayValue):"mapValue"in n?function(t){let r=Object.keys(t.fields||{}).sort(),i="{",s=!0;for(let o of r)s?s=!1:i+=",",i+=`${o}:${eA(t.fields[o])}`;return i+"}"}(n.mapValue):Se()}function DF(n,e){return{referenceValue:`projects/${n.projectId}/databases/${n.database}/documents/${e.path.canonicalString()}`}}function tA(n){return!!n&&"integerValue"in n}function AC(n){return!!n&&"arrayValue"in n}function RF(n){return!!n&&"nullValue"in n}function kF(n){return!!n&&"doubleValue"in n&&isNaN(Number(n.doubleValue))}function Jg(n){return!!n&&"mapValue"in n}function c2(n){var e,t;return((t=(((e=n?.mapValue)===null||e===void 0?void 0:e.fields)||{}).__type__)===null||t===void 0?void 0:t.stringValue)==="__vector__"}function vh(n){if(n.geoPointValue)return{geoPointValue:Object.assign({},n.geoPointValue)};if(n.timestampValue&&typeof n.timestampValue=="object")return{timestampValue:Object.assign({},n.timestampValue)};if(n.mapValue){let e={mapValue:{fields:{}}};return fc(n.mapValue.fields,(t,r)=>e.mapValue.fields[t]=vh(r)),e}if(n.arrayValue){let e={arrayValue:{values:[]}};for(let t=0;t<(n.arrayValue.values||[]).length;++t)e.arrayValue.values[t]=vh(n.arrayValue.values[t]);return e}return Object.assign({},n)}function l2(n){return(((n.mapValue||{}).fields||{}).__type__||{}).stringValue==="__max__"}var Lr=class n{constructor(e){this.value=e}static empty(){return new n({mapValue:{}})}field(e){if(e.isEmpty())return this.value;{let t=this.value;for(let r=0;r<e.length-1;++r)if(t=(t.mapValue.fields||{})[e.get(r)],!Jg(t))return null;return t=(t.mapValue.fields||{})[e.lastSegment()],t||null}}set(e,t){this.getFieldsMap(e.popLast())[e.lastSegment()]=vh(t)}setAll(e){let t=Fr.emptyPath(),r={},i=[];e.forEach((o,a)=>
vendor: 9,276 bytes, line 17
17{if(!t.isImmediateParentOf(a)){let c=this.getFieldsMap(t);this.applyChanges(c,r,i),r={},i=[],t=a.popLast()}o?r[a.lastSegment()]=vh(o):i.push(a.lastSegment())});let s=this.getFieldsMap(t);this.applyChanges(s,r,i)}delete(e){let t=this.field(e.popLast());Jg(t)&&t.mapValue.fields&&delete t.mapValue.fields[e.lastSegment()]}isEqual(e){return hs(this.value,e.value)}getFieldsMap(e){let t=this.value;t.mapValue.fields||(t.mapValue={fields:{}});for(let r=0;r<e.length;++r){let i=t.mapValue.fields[e.get(r)];Jg(i)&&i.mapValue.fields||(i={mapValue:{fields:{}}},t.mapValue.fields[e.get(r)]=i),t=i}return t.mapValue.fields}applyChanges(e,t,r){fc(t,(i,s)=>e[i]=s);for(let i of r)delete e[i]}clone(){return new n(vh(this.value))}};function u2(n){let e=[];return fc(n.fields,(t,r)=>{let i=new Fr([t]);if(Jg(r)){let s=u2(r.mapValue).fields;if(s.length===0)e.push(i);else for(let o of s)e.push(i.child(o))}else e.push(i)}),new Xr(e)}var Ri=class n{constructor(e,t,r,i,s,o,a){this.key=e,this.documentType=t,this.version=r,this.readTime=i,this.createTime=s,this.data=o,this.documentState=a}static newInvalidDocument(e){return new n(e,0,Le.min(),Le.min(),Le.min(),Lr.empty(),0)}static newFoundDocument(e,t,r,i){return new n(e,1,t,Le.min(),r,i,0)}static newNoDocument(e,t){return new n(e,2,t,Le.min(),Le.min(),Lr.empty(),0)}static newUnknownDocument(e,t){return new n(e,3,t,Le.min(),Le.min(),Lr.empty(),2)}convertToFoundDocument(e,t){return!this.createTime.isEqual(Le.min())||this.documentType!==2&&this.documentType!==0||(this.createTime=e),this.version=e,this.documentType=1,this.data=t,this.documentState=0,this}convertToNoDocument(e){return this.version=e,this.documentType=2,this.data=Lr.empty(),this.documentState=0,this}convertToUnknownDocument(e){return this.version=e,this.documentType=3,this.data=Lr.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=Le.min(),this}setReadTime(e){return this.readTime=e,this}get hasLocalMutations(){return this.documentState===1}get hasCommittedMutations(){return this.documentState===2}get hasPendingWrites(){return this.hasLocalMutations||this.hasCommittedMutations}isValidDocument(){return this.documentType!==0}isFoundDocument(){return this.documentType===1}isNoDocument(){return this.documentType===2}isUnknownDocument(){return this.documentType===3}isEqual(e){return e instanceof n&&this.key.isEqual(e.key)&&this.version.isEqual(e.version)&&this.documentType===e.documentType&&this.documentState===e.documentState&&this.data.isEqual(e.data)}mutableCopy(){return new n(this.key,this.documentType,this.version,this.readTime,this.createTime,this.data.clone(),this.documentState)}toString(){return`Document(${this.key}, ${this.version}, ${JSON.stringify(this.data.value)}, {createTime: ${this.createTime}}), {documentType: ${this.documentType}}), {documentState: ${this.documentState}})`}};var nu=class{constructor(e,t){this.position=e,this.inclusive=t}};function PF(n,e,t){let r=0;for(let i=0;i<n.position.length;i++){let s=e[i],o=n.position[i];if(s.field.isKeyField()?r=Ee.comparator(Ee.fromName(o.referenceValue),t.key):r=eu(o,t.data.field(s.field)),s.dir==="desc"&&(r*=-1),r!==0)break}return r}function MF(n,e){if(n===null)return e===null;if(e===null||n.inclusive!==e.inclusive||n.position.length!==e.position.length)return!1;for(let t=0;t<n.position.length;t++)if(!hs(n.position[t],e.position[t]))return!1;return!0}var lc=class{constructor(e,t="asc"){this.field=e,this.dir=t}};function DQ(n,e){return n.dir===e.dir&&n.field.isEqual(e.field)}var ay=class{},tn=class n extends ay{constructor(e,t,r){super(),this.field=e,this.op=t,this.value=r}static create(e,t,r){return e.isKeyField()?t==="in"||t==="not-in"?this.createKeyFieldInFilter(e,t,r):new rA(e,t,r):t==="array-contains"?new oA(e,r):t==="in"?new aA(e,r):t==="not-in"?new cA(e,r):t==="array-contains-any"?new lA(e,r):new n(e,t,r)}static createKeyFieldInFilter(e,t,r){return t==="in"?new iA(e,r):new sA(e,r)}matches(e){let t=e.data.field(this.field);return this.op==="!="?t!==null&&this.matchesComparison(eu(t,this.value)):t!==null&&cc(this.value)===cc(t)&&this.matchesComparison(eu(t,this.value))}matchesComparison(e){switch(this.op){case"<":return e<0;case"<=":return e<=0;case"==":return e===0;case"!=":return e!==0;case">":return e>0;case">=":return e>=0;default:return Se()}}isInequality(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}},ki=class n extends ay{constructor(e,t){super(),this.filters=e,this.op=t,this.ae=null}static create(e,t){return new n(e,t)}matches(e){return d2(this)?this.filters.find(t=>!t.matches(e))===void 0:this.filters.find(t=>t.matches(e))!==void 0}getFlattenedFilters(){return this.ae!==null||(this.ae=this.filters.reduce((e,t)=>e.concat(t.getFlattenedFilters()),[])),this.ae}getFilters(){return Object.assign([],this.filters)}};function d2(n){return n.op==="and"}function h2(n){return RQ(n)&&d2(n)}function RQ(n){for(let e of n.filters)if(e instanceof ki)return!1;return!0}function nA(n){if(n instanceof tn)return n.field.canonicalString()+n.op.toString()+tu(n.value);if(h2(n))return n.filters.map(e=>nA(e)).join(",");{let e=n.filters.map(t=>nA(t)).join(",");return`${n.op}(${e})`}}function f2(n,e){return n instanceof tn?function(r,i){return i instanceof tn&&r.op===i.op&&r.field.isEqual(i.field)&&hs(r.value,i.value)}(n,e):n instanceof ki?function(r,i){return i instanceof ki&&r.op===i.op&&r.filters.length===i.filters.length?r.filters.reduce((s,o,a)=>s&&f2(o,i.filters[a]),!0):!1}(n,e):void Se()}function p2(n){return n instanceof tn?function(t){return`${t.field.canonicalString()} ${t.op} ${tu(t.value)}`}(n):n instanceof ki?function(t){return t.op.toString()+" {"+t.getFilters().map(p2).join(" ,")+"}"}(n):"Filter"}var rA=class extends tn{constructor(e,t,r){super(e,t,r),this.key=Ee.fromName(r.referenceValue)}matches(e){let t=Ee.comparator(e.key,this.key);return this.matchesComparison(t)}},iA=class extends tn{constructor(e,t){super(e,"in",t),this.keys=m2("in",t)}matches(e){return this.keys.some(t=>t.isEqual(e.key))}},sA=class extends tn{constructor(e,t){super(e,"not-in",t),this.keys=m2("not-in",t)}matches(e){return!this.keys.some(t=>t.isEqual(e.key))}};function m2(n,e){var t;return(((t=e.arrayValue)===null||t===void 0?void 0:t.values)||[]).map(r=>Ee.fromName(r.referenceValue))}var oA=class extends tn{constructor(e,t){super(e,"array-contains",t)}matches(e){let t=e.data.field(this.field);return AC(t)&&Ah(t.arrayValue,this.value)}},aA=class extends tn{constructor(e,t){super(e,"in",t)}matches(e){let t=e.data.field(this.field);return t!==null&&Ah(this.value.arrayValue,t)}},cA=class extends tn{constructor(e,t){super(e,"not-in",t)}matches(e){if(Ah(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;let t=e.data.field(this.field);return t!==null&&!Ah(this.value.arrayValue,t)}},lA=class extends tn{constructor(e,t){super(e,"array-contains-any",t)}matches(e){let t=e.data.field(this.field);return!(!AC(t)||!t.arrayValue.values)&&t.arrayValue.values.some(r=>Ah(this.value.arrayValue,r))}};var uA=class{constructor(e,t=null,r=[],i=[],s=null,o=null,a=null){this.path=e,this.collectionGroup=t,this.orderBy=r,this.filters=i,this.limit=s,this.startAt=o,this.endAt=a,this.ue=null}};function NF(n,e=null,t=[],r=[],i=null,s=null,o=null){return new uA(n,e,t,r,i,s,o)}function CC(n){let e=Pe(n);if(e.ue===null){let t=e.path.canonicalString();e.collectionGroup!==null&&(t+="|cg:"+e.collectionGroup),t+="|f:",t+=e.filters.map(r=>nA(r)).join(","),t+="|ob:",t+=e.orderBy.map(r=>function(s){return s.field.canonicalString()+s.dir}(r)).join(","),Ly(e.limit)||(t+="|l:",t+=e.limit),e.startAt&&(t+="|lb:",t+=e.startAt.inclusive?"b:":"a:",t+=e.startAt.position.map(r=>tu(r)).join(",")),e.endAt&&(t+="|ub:",t+=e.endAt.inclusive?"a:":"b:",t+=e.endAt.position.map(r=>tu(r)).join(",")),e.ue=t}return e.ue}function SC(n,e){if(n.limit!==e.limit||n.orderBy.length!==e.orderBy.length)return!1;for(let t=0;t<n.orderBy.length;t++)if(!DQ(n.orderBy[t],e.orderBy[t]))return!1;if(n.filters.length!==e.filters.length)return!1;for(let t=0;t<n.filters.length;t++)if(!f2(n.filters[t],e.filters[t]))return!1;return n.collectionGroup===e.collectionGroup&&!!n.path.isEqual(e.path)&&!!MF(n.startAt,e.startAt)&&MF(n.endAt,e.endAt)}function dA(n){return Ee.isDocumentKey(n.path)&&n.collectionGroup===null&&n.filters.length===0}var ea=class{constructor(e,t=null,r=[],i=[],s=null,o="F",a=null,c=null){this.path=e,this.collectionGroup=t,this.explicitOrderBy=r,this.filters=i,this.limit=s,this.limitType=o,this.startAt=a,this.endAt=c,this.ce=null,this.le=null,this.he=null,this.startAt,this.endAt}};function kQ(n,e,t,r,i,s,o,a){return new ea(n,e,t,r,i,s,o,a)}function xC(n){return new ea(n)}function OF(n){return n.filters.length===0&&n.limit===null&&n.startAt==null&&n.endAt==null&&(n.explicitOrderBy.length===0||n.explicitOrderBy.length===1&&n.explicitOrderBy[0].field.isKeyField())}function g2(n){return n.collectionGroup!==null}function bh(n){let e=Pe(n);if(e.ce===null){e.ce=[];let t=new Set;for(let s of e.explicitOrderBy)e.ce.push(s),t.add(s.field.canonicalString());let r=e.explicitOrderBy.length>0?e.explicitOrderBy[e.explicitOrderBy.length-1].dir:"asc";(function(o){let a=new Vn(Fr.comparator);
17return o.filters.forEach(c=>{c.getFlattenedFilters().forEach(l=>{l.isInequality()&&(a=a.add(l.field))})}),a})(e).forEach(s=>{t.has(s.canonicalString())||s.isKeyField()||e.ce.push(new lc(s,r))}),t.has(Fr.keyField().canonicalString())||e.ce.push(new lc(Fr.keyField(),r))}return e.ce}function us(n){let e=Pe(n);return e.le||(e.le=PQ(e,bh(n))),e.le}function PQ(n,e){if(n.limitType==="F")return NF(n.path,n.collectionGroup,e,n.filters,n.limit,n.startAt,n.endAt);{e=e.map(i=>{let s=i.dir==="desc"?"asc":"desc";return new lc(i.field,s)});let t=n.endAt?new nu(n.endAt.position,n.endAt.inclusive):null,r=n.startAt?new nu(n.startAt.position,n.startAt.inclusive):null;return NF(n.path,n.collectionGroup,e,n.filters,n.limit,t,r)}}function hA(n,e){let t=n.filters.concat([e]);return new ea(n.path,n.collectionGroup,n.explicitOrderBy.slice(),t,n.limit,n.limitType,n.startAt,n.endAt)}function fA(n,e,t){return new ea(n.path,n.collectionGroup,n.explicitOrderBy.slice(),n.filters.slice(),e,t,n.startAt,n.endAt)}function Fy(n,e){return SC(us(n),us(e))&&n.limitType===e.limitType}function y2(n){return`${CC(us(n))}|lt:${n.limitType}`}function Gl(n){return`Query(target=${function(t){let r=t.path.canonicalString();return t.collectionGroup!==null&&(r+=" collectionGroup="+t.collectionGroup),t.filters.length>0&&(r+=`, filters: [${t.filters.map(i=>p2(i)).join(", ")}]`),Ly(t.limit)||(r+=", limit: "+t.limit),t.orderBy.length>0&&(r+=`, orderBy: [${t.orderBy.map(i=>function(o){return`${o.field.canonicalString()} (${o.dir})`}(i)).join(", ")}]`),t.startAt&&(r+=", startAt: ",r+=t.startAt.inclusive?"b:":"a:",r+=t.startAt.position.map(i=>tu(i)).join(",")),t.endAt&&(r+=", endAt: ",r+=t.endAt.inclusive?"a:":"b:",r+=t.endAt.position.map(i=>tu(i)).join(",")),`Target(${r})`}(us(n))}; limitType=${n.limitType})`}function Vy(n,e){return e.isFoundDocument()&&function(r,i){let s=i.key.path;return r.collectionGroup!==null?i.key.hasCollectionId(r.collectionGroup)&&r.path.isPrefixOf(s):Ee.isDocumentKey(r.path)?r.path.isEqual(s):r.path.isImmediateParentOf(s)}(n,e)&&function(r,i){for(let s of bh(r))if(!s.field.isKeyField()&&i.data.field(s.field)===null)return!1;return!0}(n,e)&&function(r,i){for(let s of r.filters)if(!s.matches(i))return!1;return!0}(n,e)&&function(r,i){return!(r.startAt&&!function(o,a,c){let l=PF(o,a,c);return o.inclusive?l<=0:l<0}(r.startAt,bh(r),i)||r.endAt&&!function(o,a,c){let l=PF(o,a,c);return o.inclusive?l>=0:l>0}(r.endAt,bh(r),i))}(n,e)}function MQ(n){return n.collectionGroup||(n.path.length%2==1?n.path.lastSegment():n.path.get(n.path.length-2))}function _2(n){return(e,t)=>{let r=!1;for(let i of bh(n)){let s=NQ(i,e,t);if(s!==0)return s;r=r||i.field.isKeyField()}return 0}}function NQ(n,e,t){let r=n.field.isKeyField()?Ee.comparator(e.key,t.key):function(s,o,a){let c=o.data.field(s),l=a.data.field(s);return c!==null&&l!==null?eu(c,l):Se()}(n.field,e,t);switch(n.dir){case"asc":return r;case"desc":return-1*r;default:return Se()}}var ta=class{constructor(e,t){this.mapKeyFn=e,this.equalsFn=t,this.inner={},this.innerSize=0}get(e){let t=this.mapKeyFn(e),r=this.inner[t];if(r!==void 0){for(let[i,s]of r)if(this.equalsFn(i,e))return s}}has(e){return this.get(e)!==void 0}set(e,t){let r=this.mapKeyFn(e),i=this.inner[r];if(i===void 0)return this.inner[r]=[[e,t]],void this.innerSize++;for(let s=0;s<i.length;s++)if(this.equalsFn(i[s][0],e))return void(i[s]=[e,t]);i.push([e,t]),this.innerSize++}delete(e){let t=this.mapKeyFn(e),r=this.inner[t];if(r===void 0)return!1;for(let i=0;i<r.length;i++)if(this.equalsFn(r[i][0],e))return r.length===1?delete this.inner[t]:r.splice(i,1),this.innerSize--,!0;return!1}forEach(e){fc(this.inner,(t,r)=>{for(let[i,s]of r)e(i,s)})}isEmpty(){return a2(this.inner)}size(){return this.innerSize}};var OQ=new Bt(Ee.comparator);function no(){return OQ}var v2=new Bt(Ee.comparator);function _h(...n){let e=v2;for(let t of n)e=e.insert(t.key,t);return e}function b2(n){let e=v2;return n.forEach((t,r)=>e=e.insert(t,r.overlayedDocument)),e}function rc(){return wh()}function w2(){return wh()}function wh(){return new ta(n=>n.toString(),(n,e)=>n.isEqual(e))}var LQ=new Bt(Ee.comparator),FQ=new Vn(Ee.comparator);function nt(...n){let e=FQ;for(let t of n)e=e.add(t);return e}var VQ=new Vn(ut);function jQ(){return VQ}function DC(n,e){if(n.useProto3Json){if(isNaN(e))return{doubleValue:"NaN"};if(e===1/0)return{doubleValue:"Infinity"};if(e===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:Ih(e)?"-0":e}}function E2(n){return{integerValue:""+n}}function $Q(n,e){return IQ(e)?E2(e):DC(n,e)}var ru=class{constructor(){this._=void 0}};function UQ(n,e,t){return n instanceof iu?function(i,s){let o={f
17ields:{__type__:{stringValue:"server_timestamp"},__local_write_time__:{timestampValue:{seconds:i.seconds,nanos:i.nanoseconds}}}};return s&&IC(s)&&(s=TC(s)),s&&(o.fields.__previous_value__=s),{mapValue:o}}(t,e):n instanceof uc?T2(n,e):n instanceof dc?A2(n,e):function(i,s){let o=I2(i,s),a=LF(o)+LF(i.Pe);return tA(o)&&tA(i.Pe)?E2(a):DC(i.serializer,a)}(n,e)}function BQ(n,e,t){return n instanceof uc?T2(n,e):n instanceof dc?A2(n,e):t}function I2(n,e){return n instanceof su?function(r){return tA(r)||function(s){return!!s&&"doubleValue"in s}(r)}(e)?e:{integerValue:0}:null}var iu=class extends ru{},uc=class extends ru{constructor(e){super(),this.elements=e}};function T2(n,e){let t=C2(e);for(let r of n.elements)t.some(i=>hs(i,r))||t.push(r);return{arrayValue:{values:t}}}var dc=class extends ru{constructor(e){super(),this.elements=e}};function A2(n,e){let t=C2(e);for(let r of n.elements)t=t.filter(i=>!hs(i,r));return{arrayValue:{values:t}}}var su=class extends ru{constructor(e,t){super(),this.serializer=e,this.Pe=t}};function LF(n){return Nt(n.integerValue||n.doubleValue)}function C2(n){return AC(n)&&n.arrayValue.values?n.arrayValue.values.slice():[]}function HQ(n,e){return n.field.isEqual(e.field)&&function(r,i){return r instanceof uc&&i instanceof uc||r instanceof dc&&i instanceof dc?Jl(r.elements,i.elements,hs):r instanceof su&&i instanceof su?hs(r.Pe,i.Pe):r instanceof iu&&i instanceof iu}(n.transform,e.transform)}var pA=class{constructor(e,t){this.version=e,this.transformResults=t}},Qo=class n{constructor(e,t){this.updateTime=e,this.exists=t}static none(){return new n}static exists(e){return new n(void 0,e)}static updateTime(e){return new n(e)}get isNone(){return this.updateTime===void 0&&this.exists===void 0}isEqual(e){return this.exists===e.exists&&(this.updateTime?!!e.updateTime&&this.updateTime.isEqual(e.updateTime):!e.updateTime)}};function ey(n,e){return n.updateTime!==void 0?e.isFoundDocument()&&e.version.isEqual(n.updateTime):n.exists===void 0||n.exists===e.isFoundDocument()}var ou=class{};function S2(n,e){if(!n.hasLocalMutations||e&&e.fields.length===0)return null;if(e===null)return n.isNoDocument()?new cy(n.key,Qo.none()):new hc(n.key,n.data,Qo.none());{let t=n.data,r=Lr.empty(),i=new Vn(Fr.comparator);for(let s of e.fields)if(!i.has(s)){let o=t.field(s);o===null&&s.length>1&&(s=s.popLast(),o=t.field(s)),o===null?r.delete(s):r.set(s,o),i=i.add(s)}return new fs(n.key,r,new Xr(i.toArray()),Qo.none())}}function qQ(n,e,t){n instanceof hc?function(i,s,o){let a=i.value.clone(),c=VF(i.fieldTransforms,s,o.transformResults);a.setAll(c),s.convertToFoundDocument(o.version,a).setHasCommittedMutations()}(n,e,t):n instanceof fs?function(i,s,o){if(!ey(i.precondition,s))return void s.convertToUnknownDocument(o.version);let a=VF(i.fieldTransforms,s,o.transformResults),c=s.data;c.setAll(x2(i)),c.setAll(a),s.convertToFoundDocument(o.version,c).setHasCommittedMutations()}(n,e,t):function(i,s,o){s.convertToNoDocument(o.version).setHasCommittedMutations()}(0,e,t)}function Eh(n,e,t,r){return n instanceof hc?function(s,o,a,c){if(!ey(s.precondition,o))return a;let l=s.value.clone(),u=jF(s.fieldTransforms,c,o);return l.setAll(u),o.convertToFoundDocument(o.version,l).setHasLocalMutations(),null}(n,e,t,r):n instanceof fs?function(s,o,a,c){if(!ey(s.precondition,o))return a;let l=jF(s.fieldTransforms,c,o),u=o.data;return u.setAll(x2(s)),u.setAll(l),o.convertToFoundDocument(o.version,u).setHasLocalMutations(),a===null?null:a.unionWith(s.fieldMask.fields).unionWith(s.fieldTransforms.map(d=>d.field))}(n,e,t,r):function(s,o,a){return ey(s.precondition,o)?(o.convertToNoDocument(o.version).setHasLocalMutations(),null):a}(n,e,t)}function zQ(n,e){let t=null;for(let r of n.fieldTransforms){let i=e.data.field(r.field),s=I2(r.transform,i||null);s!=null&&(t===null&&(t=Lr.empty()),t.set(r.field,s))}return t||null}function FF(n,e){return n.type===e.type&&!!n.key.isEqual(e.key)&&!!n.precondition.isEqual(e.precondition)&&!!function(r,i){return r===void 0&&i===void 0||!(!r||!i)&&Jl(r,i,(s,o)=>HQ(s,o))}(n.fieldTransforms,e.fieldTransforms)&&(n.type===0?n.value.isEqual(e.value):n.type!==1||n.data.isEqual(e.data)&&n.fieldMask.isEqual(e.fieldMask))}var hc=class extends ou{constructor(e,t,r,i=[]){super(),this.key=e,this.value=t,this.prec
vendor: 1,915 bytes, line 17
17ondition=r,this.fieldTransforms=i,this.type=0}getFieldMask(){return null}},fs=class extends ou{constructor(e,t,r,i,s=[]){super(),this.key=e,this.data=t,this.fieldMask=r,this.precondition=i,this.fieldTransforms=s,this.type=1}getFieldMask(){return this.fieldMask}};function x2(n){let e=new Map;return n.fieldMask.fields.forEach(t=>{if(!t.isEmpty()){let r=n.data.field(t);e.set(t,r)}}),e}function VF(n,e,t){let r=new Map;bt(n.length===t.length);for(let i=0;i<t.length;i++){let s=n[i],o=s.transform,a=e.data.field(s.field);r.set(s.field,BQ(o,a,t[i]))}return r}function jF(n,e,t){let r=new Map;for(let i of n){let s=i.transform,o=t.data.field(i.field);r.set(i.field,UQ(s,o,e))}return r}var cy=class extends ou{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=2,this.fieldTransforms=[]}getFieldMask(){return null}},mA=class extends ou{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=3,this.fieldTransforms=[]}getFieldMask(){return null}};var gA=class{constructor(e,t,r,i){this.batchId=e,this.localWriteTime=t,this.baseMutations=r,this.mutations=i}applyToRemoteDocument(e,t){let r=t.mutationResults;for(let i=0;i<this.mutations.length;i++){let s=this.mutations[i];s.key.isEqual(e.key)&&qQ(s,e,r[i])}}applyToLocalView(e,t){for(let r of this.baseMutations)r.key.isEqual(e.key)&&(t=Eh(r,e,t,this.localWriteTime));for(let r of this.mutations)r.key.isEqual(e.key)&&(t=Eh(r,e,t,this.localWriteTime));return t}applyToLocalDocumentSet(e,t){let r=w2();return this.mutations.forEach(i=>{let s=e.get(i.key),o=s.overlayedDocument,a=this.applyToLocalView(o,s.mutatedFields);a=t.has(i.key)?null:a;let c=S2(o,a);c!==null&&r.set(i.key,c),o.isValidDocument()||o.convertToNoDocument(Le.min())}),r}keys(){return this.mutations.reduce((e,t)=>e.add(t.key),nt())}isEqual(e){return this.batchId===e.batchId&&Jl(this.mutations,e.mutations,(t,r)=>FF(t,r))&&Jl(this.baseMutations,e.baseMutations,(t,r)=>FF(t,r))}}
17,yA=class n{constructor(e,t,r,i){this.batch=e,this.commitVersion=t,this.mutationResults=r,this.docVersions=i}static from(e,t,r){bt(e.mutations.length===r.length);let i=function(){return LQ}(),s=e.mutations;for(let o=0;o<s.length;o++)i=i.insert(s[o].key,r[o].version);return new n(e,t,r,i)}};var _A=class{constructor(e,t){this.largestBatchId=e,this.mutation=t}getKey(){return this.mutation.key}isEqual(e){return e!==null&&this.mutation===e.mutation}toString(){return`Overlay{ 18 largestBatchId: ${this.largestBatchId}, 19 mutation: ${this.mutation.toString()} 20 }`}};var vA=class{constructor(e,t){this.count=e,this.unchangedNames=t}};var Jt,ot;function GQ(n){switch(n){default:return Se();case q.CANCELLED:case q.UNKNOWN:case q.DEADLINE_EXCEEDED:case q.RESOURCE_EXHAUSTED:case q.INTERNAL:case q.UNAVAILABLE:case q.UNAUTHENTICATED:return!1;case q.INVALID_ARGUMENT:case q.NOT_FOUND:case q.ALREADY_EXISTS:case q.PERMISSION_DENIED:case q.FAILED_PRECONDITION:case q.ABORTED:case q.OUT_OF_RANGE:case q.UNIMPLEMENTED:case q.DATA_LOSS:return!0}}function D2(n){if(n===void 0)return eo("GRPC error has no .code"),q.UNKNOWN;switch(n){case Jt.OK:return q.OK;case Jt.CANCELLED:return q.CANCELLED;case Jt.UNKNOWN:return q.UNKNOWN;case Jt.DEADLINE_EXCEEDED:return q.DEADLINE_EXCEEDED;case Jt.RESOURCE_EXHAUSTED:return q.RESOURCE_EXHAUSTED;case Jt.INTERNAL:return q.INTERNAL;case Jt.UNAVAILABLE:return q.UNAVAILABLE;case Jt.UNAUTHENTICATED:return q.UNAUTHENTICATED;case Jt.INVALID_ARGUMENT:return q.INVALID_ARGUMENT;case Jt.NOT_FOUND:return q.NOT_FOUND;case Jt.ALREADY_EXISTS:return q.ALREADY_EXISTS;case Jt.PERMISSION_DENIED:return q.PERMISSION_DENIED;case Jt.FAILED_PRECONDITION:return q.FAILED_PRECONDITION;case Jt.ABORTED:return q.ABORTED;case Jt.OUT_OF_RANGE:return q.OUT_OF_RANGE;case Jt.UNIMPLEMENTED:return q.UNIMPLEMENTED;case Jt.DATA_LOSS:return q.DATA_LOSS;default:return Se()}}(ot=Jt||(Jt={}))[ot.OK=0]="OK",ot[ot.CANCELLED=1]="CANCELLED",ot[ot.UNKNOWN=2]="UNKNOWN",ot[ot.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",ot[ot.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",ot[ot.NOT_FOUND=5]="NOT_FOUND",ot[ot.ALREADY_EXISTS=6]="ALREADY_EXISTS",ot[ot.PERMISSION_DENIED=7]="PERMISSION_DENIED",ot[ot.UNAUTHENTICATED=16]="UNAUTHENTICATED",ot[ot.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",ot[ot.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",ot[ot.ABORTED=10]="ABORTED",ot[ot.OUT_OF_RANGE=11]="OUT_OF_RANGE",ot[ot.UNIMPLEMENTED=12]="UNIMPLEMENTED",ot[ot.INTERNAL=13]="INTERNAL",ot[ot.UNAVAILABLE=14]="UNAVAILABLE",ot[ot.DATA_LOSS=15]="DATA_LOSS";var $F=null;function WQ(){return new TextEncoder}var KQ=new Xo([4294967295,4294967295],0);function UF(n){let e=WQ().encode(n),t=new NT;return t.update(e),new Uint8Array(t.digest())}function BF(n){let e=new DataView(n.buffer),t=e.getUint32(0,!0),r=e.getUint32(4,!0),i=e.getUint32(8,!0),s=e.getUint32(12,!0);return[new Xo([t,r],0),new Xo([i,s],0)]}var bA=class n{constructor(e,t,r){if(this.bitmap=e,this.padding=t,this.hashCount=r,t<0||t>=8)throw new ic(`Invalid padding: ${t}`);if(r<0)throw new ic(`Invalid hash count: ${r}`);if(e.length>0&&this.hashCount===0)throw new ic(`Invalid hash count: ${r}`);if(e.length===0&&t!==0)throw new ic(`Invalid padding when bitmap length is 0: ${t}`);this.Ie=8*e.length-t,this.Te=Xo.fromNumber(this.Ie)}Ee(e,t,r){let i=e.add(t.multiply(Xo.fromNumber(r)));return i.compare(KQ)===1&&(i=new Xo([i.getBits(0),i.getBits(1)],0)),i.modulo(this.Te).toNumber()}de(e){return(this.bitmap[Math.floor(e/8)]&1<<e%8)!=0}mightContain(e){if(this.Ie===0)return!1;let t=UF(e),[r,i]=BF(t);for(let s=0;s<this.hashCount;s++){let o=this.Ee(r,i,s);if(!this.de(o))return!1}return!0}static create(e,t,r){let i=e%8==0?0:8-e%8,s=new Uint8Array(Math.ceil(e/8)),o=new n(s,i,t);return r.forEach(a=>o.insert(a)),o}insert(e){if(this.Ie===0)return;let t=UF(e),[r,i]=BF(t);for(let s=0;s<this.hashCount;s++){let o=this.Ee(r,i,s);this.Ae(o)}}Ae(e){let t=Math.floor(e/8),r=e%8;this.bitmap[t]|=1<<r}},ic=class extends Error{constructor(){super(...arguments),this.name="BloomFilterError"}};var ly=class n{constructor(e,t,r,i,s){this.snapshotVersion=e,this.targetChanges=t,this.targetMismatches=r,this.documentUpdates=i,this.resolvedLimboDocuments=s}static createSynthesizedRemoteEventForCurrentChange(e,t,r){let i=new Map;return i.set(e,Ch.createSynthesizedTargetChangeForCurrentChange(e,t,r)),new n(Le.min(),i,new Bt(ut),no(),nt())}},Ch=class n{constructor(e,t,r,i,s){this.resumeToken=e,this.current=t,this.addedDocuments=r,this.modifiedDocuments=i,this.removedDocuments=s}static createSynthesizedTargetChangeForCurrentChange(e,t,r){return new n(r,t,nt(),nt(),nt())}};
vendor: 8,217 bytes, line 20
20var Xl=class{constructor(e,t,r,i){this.Re=e,this.removedTargetIds=t,this.key=r,this.Ve=i}},uy=class{constructor(e,t){this.targetId=e,this.me=t}},dy=class{constructor(e,t,r=jn.EMPTY_BYTE_STRING,i=null){this.state=e,this.targetIds=t,this.resumeToken=r,this.cause=i}},hy=class{constructor(){this.fe=0,this.ge=qF(),this.pe=jn.EMPTY_BYTE_STRING,this.ye=!1,this.we=!0}get current(){return this.ye}get resumeToken(){return this.pe}get Se(){return this.fe!==0}get be(){return this.we}De(e){e.approximateByteSize()>0&&(this.we=!0,this.pe=e)}ve(){let e=nt(),t=nt(),r=nt();return this.ge.forEach((i,s)=>{switch(s){case 0:e=e.add(i);break;case 2:t=t.add(i);break;case 1:r=r.add(i);break;default:Se()}}),new Ch(this.pe,this.ye,e,t,r)}Ce(){this.we=!1,this.ge=qF()}Fe(e,t){this.we=!0,this.ge=this.ge.insert(e,t)}Me(e){this.we=!0,this.ge=this.ge.remove(e)}xe(){this.fe+=1}Oe(){this.fe-=1,bt(this.fe>=0)}Ne(){this.we=!0,this.ye=!0}},wA=class{constructor(e){this.Le=e,this.Be=new Map,this.ke=no(),this.qe=HF(),this.Qe=new Bt(ut)}Ke(e){for(let t of e.Re)e.Ve&&e.Ve.isFoundDocument()?this.$e(t,e.Ve):this.Ue(t,e.key,e.Ve);for(let t of e.removedTargetIds)this.Ue(t,e.key,e.Ve)}We(e){this.forEachTarget(e,t=>{let r=this.Ge(t);switch(e.state){case 0:this.ze(t)&&r.De(e.resumeToken);break;case 1:r.Oe(),r.Se||r.Ce(),r.De(e.resumeToken);break;case 2:r.Oe(),r.Se||this.removeTarget(t);break;case 3:this.ze(t)&&(r.Ne(),r.De(e.resumeToken));break;case 4:this.ze(t)&&(this.je(t),r.De(e.resumeToken));break;default:Se()}})}forEachTarget(e,t){e.targetIds.length>0?e.targetIds.forEach(t):this.Be.forEach((r,i)=>{this.ze(i)&&t(i)})}He(e){let t=e.targetId,r=e.me.count,i=this.Je(t);if(i){let s=i.target;if(dA(s))if(r===0){let o=new Ee(s.path);this.Ue(t,o,Ri.newNoDocument(o,Le.min()))}else bt(r===1);else{let o=this.Ye(t);if(o!==r){let a=this.Ze(e),c=a?this.Xe(a,e,o):1;if(c!==0){this.je(t);let l=c===2?"TargetPurposeExistenceFilterMismatchBloom":"TargetPurposeExistenceFilterMismatch";this.Qe=this.Qe.insert(t,l)}$F?.et(function(u,d,f,p,y){var v,w,E,A,x,M;let O={localCacheCount:u,existenceFilterCount:d.count,databaseId:f.database,projectId:f.projectId},$=d.unchangedNames;return $&&(O.bloomFilter={applied:y===0,hashCount:(v=$?.hashCount)!==null&&v!==void 0?v:0,bitmapLength:(A=(E=(w=$?.bits)===null||w===void 0?void 0:w.bitmap)===null||E===void 0?void 0:E.length)!==null&&A!==void 0?A:0,padding:(M=(x=$?.bits)===null||x===void 0?void 0:x.padding)!==null&&M!==void 0?M:0,mightContain:C=>{var T;return(T=p?.mightContain(C))!==null&&T!==void 0&&T}}),O}(o,e.me,this.Le.tt(),a,c))}}}}Ze(e){let t=e.me.unchangedNames;if(!t||!t.bits)return null;let{bits:{bitmap:r="",padding:i=0},hashCount:s=0}=t,o,a;try{o=Jo(r).toUint8Array()}catch(c){if(c instanceof sy)return Zl("Decoding the base64 bloom filter in existence filter failed ("+c.message+"); ignoring the bloom filter and falling back to full re-query."),null;throw c}try{a=new bA(o,i,s)}catch(c){return Zl(c instanceof ic?"BloomFilter error: ":"Applying bloom filter failed: ",c),null}return a.Ie===0?null:a}Xe(e,t,r){return t.me.count===r-this.nt(e,t.targetId)?0:2}nt(e,t){let r=this.Le.getRemoteKeysForTarget(t),i=0;return r.forEach(s=>{let o=this.Le.tt(),a=`projects/${o.projectId}/databases/${o.database}/documents/${s.path.canonicalString()}`;e.mightContain(a)||(this.Ue(t,s,null),i++)}),i}rt(e){let t=new Map;this.Be.forEach((s,o)=>{let a=this.Je(o);if(a){if(s.current&&dA(a.target)){let c=new Ee(a.target.path);this.ke.get(c)!==null||this.it(o,c)||this.Ue(o,c,Ri.newNoDocument(c,e))}s.be&&(t.set(o,s.ve()),s.Ce())}});let r=nt();this.qe.forEach((s,o)=>{let a=!0;o.forEachWhile(c=>{let l=this.Je(c);return!l||l.purpose==="TargetPurposeLimboResolution"||(a=!1,!1)}),a&&(r=r.add(s))}),this.ke.forEach((s,o)=>o.setReadTime(e));let i=new ly(e,t,this.Qe,this.ke,r);return this.ke=no(),this.qe=HF(),this.Qe=new Bt(ut),i}$e(e,t){if(!this.ze(e))return;let r=this.it(e,t.key)?2:0;this.Ge(e).Fe(t.key,r),this.ke=this.ke.insert(t.key,t),this.qe=this.qe.insert(t.key,this.st(t.key).add(e))}Ue(e,t,r){if(!this.ze(e))return;let i=this.Ge(e);this.it(e,t)?i.Fe(t,1):i.Me(t),this.qe=this.qe.insert(t,this.st(t).delete(e)),r&&(this.ke=this.ke.insert(t,r))}removeTarget(e){this.Be.delete(e)}Ye(e){let t=this.Ge(e).ve();return this.Le.getRemoteKeysForTarget(e).size+t.addedDocuments.size-t.removedDocuments.size}xe(e){this.Ge(e).xe()}Ge(e){let t=this.Be.get(e);return t||(t=new hy,this.Be.set(e,t)),t}st(e){let t=this.qe.get(e);return t||(t=new Vn(ut),this.qe=this.qe.insert(e,t)),t}ze(e){let t=this.Je(e)!==null;return t||de("WatchChangeAggregator","Detected inactive target",e),t}Je(e){let t=this.Be.get(e);return t&&t.Se?null:this.Le.ot(e)}je(e){this.Be.set(e,new hy),this.Le.getRemoteKeysForTarget(e).forEach(t=>{this.Ue(e,t,null)})}it(e,t){return this.Le.getRemoteKeysForTarget(e).has(t)}};function HF(){return new Bt(Ee.comparator)}function qF(){return new Bt(Ee.comparator)}var YQ={asc:"ASCENDING",desc:"DESCENDING"},XQ={"<":"LESS_THAN","<=":"LESS_THAN_OR_EQUAL",">":"GREATER_THAN",">=":"GREATER_THAN_OR_EQUAL","==":"EQUAL","!=":"NOT_EQUAL","array-contains":"ARRAY_CONTAINS",in:"IN","not-in":"NOT_IN","array-contains-any":"ARRAY_CONTAINS_ANY"},QQ={and:"AND",or:"OR"},EA=class{constructor(e,t){this.databaseId=e,this.useProto3Json=t}};function IA(n,e){return n.useProto3Json||Ly(e)?e:{value:e}}function fy(n,e){return n.useProto3Json?`${new Date(1e3*e.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")}.${("000000000"+e.nanoseconds).slice(-9)}Z`:{seconds:""+e.seconds,nanos:e.nanoseconds}}function R2(n,e){return n.useProto3Json?e.toBase64():e.toUint8Array()}function ZQ(n,e){return fy(n,e.toTimestamp())}function ds(n){return bt(!!n),Le.fromTimestamp(function(t){let r=to(t);return new Tn(r.seconds,r.nanos)}(n))}function RC(n,e){return TA(n,e).canonicalString()}function TA(n,e){let t=function(i){return new Ft(["projects",i.projectId,"databases",i.database])}(n).child("documents");return e===void 0?t:t.child(e)}function k2(n){let e=Ft.fromString(n);return bt(L2(e)),e}function AA(n,e){return RC(n.databaseId,e.path)}function $T(n,e){let t=k2(e);if(t.get(1)!==n.databaseId.projectId)throw new ne(q.INVALID_ARGUMENT,"Tried to deserialize key from different project: "+t.get(1)+" vs "+n.databaseId.projectId);if(t.get(3)!==n.databaseId.database)throw new ne(q.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+t.get(3)+" vs "+n.databaseId.database);return new Ee(M2(t))}function P2(n,e){return RC(n.databaseId,e)}function JQ(n){let e=k2(n);return e.length===4?Ft.emptyPath():M2(e)}function CA(n){return new Ft(["projects",n.databaseId.projectId,"databases",n.databaseId.database]).canonicalString()}function M2(n){return bt(n.length>4&&n.get(4)==="documents"),n.popFirst(5)}function zF(n,e,t){return{name:AA(n,e),fields:t.value.mapValue.fields}}function eZ(n,e){let t;if("targetChange"in e){e.targetChange;let r=function(l){return l==="NO_CHANGE"?0:l==="ADD"?1:l==="REMOVE"?2:l==="CURRENT"?3:l==="RESET"?4:Se()}(e.targetChange.targetChangeType||"NO_CHANGE"),i=e.targetChange.targetIds||[],s=function(l,u){return l.useProto3Json?(bt(u===void 0||typeof u=="string"),jn.fromBase64String(u||"")):(bt(u===void 0||u instanceof Buffer||u instanceof Uint8Array),jn.fromUint8Array(u||new Uint8Array))}(n,e.targetChange.resumeToken),o=e.targetChange.cause,a=o&&function(l){let u=l.code===void 0?q.UNKNOWN:D2(l.code);return new ne(u,l.message||"")}(o);t=new dy(r,i,s,a||null)}else if("documentChange"in e){e.documentChange;let r=e.documentChange;r.document,r.document.name,r.document.updateTime;let i=$T(n,r.document.name),s=ds(r.document.updateTime),o=r.document.createTime?ds(r.document.createTime):Le.min(),a=new Lr({mapValue:{fields:r.document.fields}}),c=Ri.newFoundDocument(i,s,o,a),l=r.targetIds||[],u=r.removedTargetIds||[];t=new Xl(l,u,c.key,c)}else if("documentDelete"in e){e.documentDelete;let r=e.documentDelete;r.document;let i=$T(n,r.document),s=r.readTime?ds(r.readTime):Le.min(),o=Ri.newNoDocument(i,s),a=r.removedTargetIds||[];t=new Xl([],a,o.key,o)}else if("documentRemove"in e){e.documentRemove;let r=e.documentRemove;r.document;let i=$T(n,r.document),s=r.removedTargetIds||[];t=new Xl([],s,i,null)}else{if(!("filter"in e))return Se();{e.filter;let r=e.filter;r.targetId;
20let{count:i=0,unchangedNames:s}=r,o=new vA(i,s),a=r.targetId;t=new uy(a,o)}}return t}function tZ(n,e){let t;if(e instanceof hc)t={update:zF(n,e.key,e.value)};else if(e instanceof cy)t={delete:AA(n,e.key)};else if(e instanceof fs)t={update:zF(n,e.key,e.data),updateMask:uZ(e.fieldMask)};else{if(!(e instanceof mA))return Se();t={verify:AA(n,e.key)}}return e.fieldTransforms.length>0&&(t.updateTransforms=e.fieldTransforms.map(r=>function(s,o){let a=o.transform;if(a instanceof iu)return{fieldPath:o.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(a instanceof uc)return{fieldPath:o.field.canonicalString(),appendMissingElements:{values:a.elements}};if(a instanceof dc)return{fieldPath:o.field.canonicalString(),removeAllFromArray:{values:a.elements}};if(a instanceof su)return{fieldPath:o.field.canonicalString(),increment:a.Pe};throw Se()}(0,r))),e.precondition.isNone||(t.currentDocument=function(i,s){return s.updateTime!==void 0?{updateTime:ZQ(i,s.updateTime)}:s.exists!==void 0?{exists:s.exists}:Se()}(n,e.precondition)),t}function nZ(n,e){return n&&n.length>0?(bt(e!==void 0),n.map(t=>function(i,s){let o=i.updateTime?ds(i.updateTime):ds(s);return o.isEqual(Le.min())&&(o=ds(s)),new pA(o,i.transformResults||[])}(t,e))):[]}function rZ(n,e){return{documents:[P2(n,e.path)]}}function iZ(n,e){let t={structuredQuery:{}},r=e.path,i;e.collectionGroup!==null?(i=r,t.structuredQuery.from=[{collectionId:e.collectionGroup,allDescendants:!0}]):(i=r.popLast(),t.structuredQuery.from=[{collectionId:r.lastSegment()}]),t.parent=P2(n,i);let s=function(l){if(l.length!==0)return O2(ki.create(l,"and"))}(e.filters);s&&(t.structuredQuery.where=s);let o=function(l){if(l.length!==0)return l.map(u=>function(f){return{field:Wl(f.field),direction:aZ(f.dir)}}(u))}(e.orderBy);o&&(t.structuredQuery.orderBy=o);let a=IA(n,e.limit);return a!==null&&(t.structuredQuery.limit=a),e.startAt&&(t.structuredQuery.startAt=function(l){return{before:l.inclusive,values:l.position}}(e.startAt)),e.endAt&&(t.structuredQuery.endAt=function(l){return{before:!l.inclusive,values:l.position}}(e.endAt)),{_t:t,parent:i}}function sZ(n){let e=JQ(n.parent),t=n.structuredQuery,r=t.from?t.from.length:0,i=null;if(r>0){bt(r===1);let u=t.from[0];u.allDescendants?i=u.collectionId:e=e.child(u.collectionId)}let s=[];t.where&&(s=function(d){let f=N2(d);return f instanceof ki&&h2(f)?f.getFilters():[f]}(t.where));let o=[];t.orderBy&&(o=function(d){return d.map(f=>function(y){return new lc(Kl(y.field),function(w){switch(w){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}}(y.direction))}(f))}(t.orderBy));let a=null;t.limit&&(a=function(d){let f;return f=typeof d=="object"?d.value:d,Ly(f)?null:f}(t.limit));let c=null;t.startAt&&(c=function(d){let f=!!d.before,p=d.values||[];return new nu(p,f)}(t.startAt));let l=null;return t.endAt&&(l=function(d){let f=!d.before,p=d.values||[];return new nu(p,f)}(t.endAt)),kQ(e,i,o,s,a,"F",c,l)}function oZ(n,e){let t=function(i){switch(i){case"TargetPurposeListen":return null;case"TargetPurposeExistenceFilterMismatch":return"existence-filter-mismatch";case"TargetPurposeExistenceFilterMismatchBloom":return"existence-filter-mismatch-bloom";case"TargetPurposeLimboResolution":return"limbo-document";default:return Se()}}(e.purpose);return t==null?null:{"goog-listen-tags":t}}function N2(n){return n.unaryFilter!==void 0?function(t){switch(t.unaryFilter.op){case"IS_NAN":let r=Kl(t.unaryFilter.field);return tn.create(r,"==",{doubleValue:NaN});case"IS_NULL":let i=Kl(t.unaryFilter.field);return tn.create(i,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":let s=Kl(t.unaryFilter.field);return tn.create(s,"!=",{doubleValue:NaN});case"IS_NOT_NULL":let o=Kl(t.unaryFilter.field);return tn.create(o,"!=",{nullValue:"NULL_VALUE"});default:return Se()}}(n):n.fieldFilter!==void 0?function(t){return tn.create(Kl(t.fieldFilter.field),function(i){switch(i){case"EQUAL":return"==";case"NOT_EQUAL":return"!=";case"GREATER_THAN":return">";case"GREATER_THAN_OR_EQUAL":return">=";case"LESS_THAN":return"<";case"LESS_THAN_OR_EQUAL":return"<=";case"ARRAY_CONTAINS":return"array-contains";case"IN":return"in";case"NOT_IN":return"not-in";case"ARRAY_CONTAINS_ANY":return"array-contains-any";default:return Se()}}(t.fieldFilter.op),t.fieldFilter.value)}(n):n.compositeFilter!==void 0?function(t){return ki.create(t.compositeFilter.filters.map(r=>N2(r)),function(i){switch(i){case"AND":return"and";case"OR":return"or";default:return Se()}}(t.compositeFilter.op))}(n):Se()}function aZ(n){return YQ[n]}function cZ(n){return XQ[n]}function lZ(n){return QQ[n]}function Wl(n){return{fieldPath:n.canonicalString()}}function Kl(n){return Fr.fromServerFormat(n.fieldPath)}function O2(n){return n instanceof tn?function(t){if(t.op==="=="){if(kF(t.value))return{unaryFilter:{field:Wl(t.field),op:"IS_NAN"}};if(RF(t.value))return{unaryFilter:{field:Wl(t.field),op:"IS_NULL"}}}else if(t.op==="!="){if(kF(t.value))return{unaryFilter:{field:Wl(t.field),op:"IS_NOT_NA
20N"}};if(RF(t.value))return{unaryFilter:{field:Wl(t.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:Wl(t.field),op:cZ(t.op),value:t.value}}}(n):n instanceof ki?function(t){let r=t.getFilters().map(i=>O2(i));return r.length===1?r[0]:{compositeFilter:{op:lZ(t.op),filters:r}}}(n):Se()}function uZ(n){let e=[];return n.fields.forEach(t=>e.push(t.canonicalString())),{fieldPaths:e}}function L2(n){return n.length>=4&&n.get(0)==="projects"&&n.get(2)==="databases"}var Sh=class n{constructor(e,t,r,i,s=Le.min(),o=Le.min(),a=jn.EMPTY_BYTE_STRING,c=null){this.target=e,this.targetId=t,this.purpose=r,this.sequenceNumber=i,this.snapshotVersion=s,this.lastLimboFreeSnapshotVersion=o,this.resumeToken=a,this.expectedCount=c}withSequenceNumber(e){return new n(this.target,this.targetId,this.purpose,e,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,this.expectedCount)}withResumeToken(e,t){return new n(this.target,this.targetId,this.purpose,this.sequenceNumber,t,this.lastLimboFreeSnapshotVersion,e,null)}withExpectedCount(e){return new n(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,e)}withLastLimboFreeSnapshotVersion(e){return new n(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,e,this.resumeToken,this.expectedCount)}};var SA=class{constructor(e){this.ct=e}};function dZ(n){let e=sZ({parent:n.parent,structuredQuery:n.structuredQuery});return n.limitType==="LAST"?fA(e,e.limit,"L"):e}var py=class{constructor(){}It(e,t){this.Tt(e,t),t.Et()}Tt(e,t){if("nullValue"in e)this.dt(t,5);else if("booleanValue"in e)this.dt(t,10),t.At(e.booleanValue?1:0);else if("integerValue"in e)this.dt(t,15),t.At(Nt(e.integerValue));else if("doubleValue"in e){let r=Nt(e.doubleValue);isNaN(r)?this.dt(t,13):(this.dt(t,15),Ih(r)?t.At(0):t.At(r))}else if("timestampValue"in e){let r=e.timestampValue;this.dt(t,20),typeof r=="string"&&(r=to(r)),t.Rt(`${r.seconds||""}`),t.At(r.nanos||0)}else if("stringValue"in e)this.Vt(e.stringValue,t),this.ft(t);else if("bytesValue"in e)this.dt(t,30),t.gt(Jo(e.bytesValue)),this.ft(t);else if("referenceValue"in e)this.yt(e.referenceValue,t);else if("geoPointValue"in e){let r=e.geoPointValue;this.dt(t,45),t.At(r.latitude||0),t.At(r.longitude||0)}else"mapValue"in e?l2(e)?this.dt(t,Number.MAX_SAFE_INTEGER):c2(e)?this.wt(e.mapValue,t):(this.St(e.mapValue,t),this.ft(t)):"arrayValue"in e?(this.bt(e.arrayValue,t),this.ft(t)):Se()}Vt(e,t){this.dt(t,25),this.Dt(e,t)}Dt(e,t){t.Rt(e)}St(e,t){let r=e.fields||{};this.dt(t,55);for(let i of Object.keys(r))this.Vt(i,t),this.Tt(r[i],t)}wt(e,t){var r,i;let s=e.fields||{};this.dt(t,53);let o="value",a=((i=(r=s[o].arrayValue)===null||r===void 0?void 0:r.values)===null||i===void 0?void 0:i.length)||0;this.dt(t,15),t.At(Nt(a)),this.Vt(o,t),this.Tt(s[o],t)}bt(e,t){let r=e.values||[];this.dt(t,50);for(let i of r)this.Tt(i,t)}yt(e,t){this.dt(t,37),Ee.fromName(e).path.forEach(r=>{this.dt(t,60),this.Dt(r,t)})}dt(e,t){e.At(t)}ft(e){e.At(2)}};py.vt=new py;var xA=class{constructor(){this.un=new DA}addToCollectionParentIndex(e,t){return this.un.add(t),X.resolve()}getCollectionParents(e,t){return X.resolve(this.un.getEntries(t))}addFieldIndex(e,t){return X.resolve()}deleteFieldIndex(e,t){return X.resolve()}deleteAllFieldIndexes(e){return X.resolve()}createTargetIndexes(e,t){return X.resolve()}getDocumentsMatchingTarget(e,t){return X.resolve(null)}getIndexType(e,t){return X.resolve(0)}getFieldIndexes(e,t){return X.resolve([])}getNextCollectionGroupToUpdate(e){return X.resolve(null)}getMinOffset(e,t){return X.resolve(ac.min())}getMinOffsetFromCollectionGroup(e,t){return X.resolve(ac.min())}updateCollectionGroup(e,t,r){return X.resolve()}updateIndexEntries(e,t){return X.resolve()}},DA=class{constructor(){this.index={}}add(e){let t=e.lastSegment(),r=e.popLast(),i=this.index[t]||new Vn(Ft.comparator),s=!i.has(r);return this.index[t]=i.add(r),s}has(e){let t=e.lastSegment(),r=e.popLast(),i=this.index[t];return i&&i.has(r)}getEntries(e){return(this.index[e]||new Vn(Ft.comparator)).toArray()}};var iwe=new Uint8Array(0);var as=class n{constructor(e,t,r){this.cacheSizeCollectionThreshold=e,this.percentileToCollect=t,this.maximumSequenceNumbersToCollect=r}
vendor: 19,002 bytes, line 20
20static withCacheSize(e){return new n(e,n.DEFAULT_COLLECTION_PERCENTILE,n.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)}};as.DEFAULT_COLLECTION_PERCENTILE=10,as.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,as.DEFAULT=new as(41943040,as.DEFAULT_COLLECTION_PERCENTILE,as.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),as.DISABLED=new as(-1,0,0);var xh=class n{constructor(e){this.Ln=e}next(){return this.Ln+=2,this.Ln}static Bn(){return new n(0)}static kn(){return new n(-1)}};var RA=class{constructor(){this.changes=new ta(e=>e.toString(),(e,t)=>e.isEqual(t)),this.changesApplied=!1}addEntry(e){this.assertNotApplied(),this.changes.set(e.key,e)}removeEntry(e,t){this.assertNotApplied(),this.changes.set(e,Ri.newInvalidDocument(e).setReadTime(t))}getEntry(e,t){this.assertNotApplied();let r=this.changes.get(t);return r!==void 0?X.resolve(r):this.getFromCache(e,t)}getEntries(e,t){return this.getAllFromCache(e,t)}apply(e){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(e)}assertNotApplied(){}};var kA=class{constructor(e,t){this.overlayedDocument=e,this.mutatedFields=t}};var PA=class{constructor(e,t,r,i){this.remoteDocumentCache=e,this.mutationQueue=t,this.documentOverlayCache=r,this.indexManager=i}getDocument(e,t){let r=null;return this.documentOverlayCache.getOverlay(e,t).next(i=>(r=i,this.remoteDocumentCache.getEntry(e,t))).next(i=>(r!==null&&Eh(r.mutation,i,Xr.empty(),Tn.now()),i))}getDocuments(e,t){return this.remoteDocumentCache.getEntries(e,t).next(r=>this.getLocalViewOfDocuments(e,r,nt()).next(()=>r))}getLocalViewOfDocuments(e,t,r=nt()){let i=rc();return this.populateOverlays(e,i,t).next(()=>this.computeViews(e,t,i,r).next(s=>{let o=_h();return s.forEach((a,c)=>{o=o.insert(a,c.overlayedDocument)}),o}))}getOverlayedDocuments(e,t){let r=rc();return this.populateOverlays(e,r,t).next(()=>this.computeViews(e,t,r,nt()))}populateOverlays(e,t,r){let i=[];return r.forEach(s=>{t.has(s)||i.push(s)}),this.documentOverlayCache.getOverlays(e,i).next(s=>{s.forEach((o,a)=>{t.set(o,a)})})}computeViews(e,t,r,i){let s=no(),o=wh(),a=function(){return wh()}();return t.forEach((c,l)=>{let u=r.get(l.key);i.has(l.key)&&(u===void 0||u.mutation instanceof fs)?s=s.insert(l.key,l):u!==void 0?(o.set(l.key,u.mutation.getFieldMask()),Eh(u.mutation,l,u.mutation.getFieldMask(),Tn.now())):o.set(l.key,Xr.empty())}),this.recalculateAndSaveOverlays(e,s).next(c=>(c.forEach((l,u)=>o.set(l,u)),t.forEach((l,u)=>{var d;return a.set(l,new kA(u,(d=o.get(l))!==null&&d!==void 0?d:null))}),a))}recalculateAndSaveOverlays(e,t){let r=wh(),i=new Bt((o,a)=>o-a),s=nt();return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(e,t).next(o=>{for(let a of o)a.keys().forEach(c=>{let l=t.get(c);if(l===null)return;let u=r.get(c)||Xr.empty();u=a.applyToLocalView(l,u),r.set(c,u);let d=(i.get(a.batchId)||nt()).add(c);i=i.insert(a.batchId,d)})}).next(()=>{let o=[],a=i.getReverseIterator();for(;a.hasNext();){let c=a.getNext(),l=c.key,u=c.value,d=w2();u.forEach(f=>{if(!s.has(f)){let p=S2(t.get(f),r.get(f));p!==null&&d.set(f,p),s=s.add(f)}}),o.push(this.documentOverlayCache.saveOverlays(e,l,d))}return X.waitFor(o)}).next(()=>r)}recalculateAndSaveOverlaysForDocumentKeys(e,t){return this.remoteDocumentCache.getEntries(e,t).next(r=>this.recalculateAndSaveOverlays(e,r))}getDocumentsMatchingQuery(e,t,r,i){return function(o){return Ee.isDocumentKey(o.path)&&o.collectionGroup===null&&o.filters.length===0}(t)?this.getDocumentsMatchingDocumentQuery(e,t.path):g2(t)?this.getDocumentsMatchingCollectionGroupQuery(e,t,r,i):this.getDocumentsMatchingCollectionQuery(e,t,r,i)}getNextDocuments(e,t,r,i){return this.remoteDocumentCache.getAllFromCollectionGroup(e,t,r,i).next(s=>{let o=i-s.size>0?this.documentOverlayCache.getOverlaysForCollectionGroup(e,t,r.largestBatchId,i-s.size):X.resolve(rc()),a=-1,c=s;return o.next(l=>X.forEach(l,(u,d)=>(a<d.largestBatchId&&(a=d.largestBatchId),s.get(u)?X.resolve():this.remoteDocumentCache.getEntry(e,u).next(f=>{c=c.insert(u,f)}))).next(()=>this.populateOverlays(e,l,s)).next(()=>this.computeViews(e,c,l,nt())).next(u=>({batchId:a,changes:b2(u)})))})}getDocumentsMatchingDocumentQuery(e,t){return this.getDocument(e,new Ee(t)).next(r=>{let i=_h();return r.isFoundDocument()&&(i=i.insert(r.key,r)),i})}getDocumentsMatchingCollectionGroupQuery(e,t,r,i){let s=t.collectionGroup,o=_h();return this.indexManager.getCollectionParents(e,s).next(a=>X.forEach(a,c=>{let l=function(d,f){return new ea(f,null,d.explicitOrderBy.slice(),d.filters.slice(),d.limit,d.limitType,d.startAt,d.endAt)}(t,c.child(s));return this.getDocumentsMatchingCollectionQuery(e,l,r,i).next(u=>{u.forEach((d,f)=>{o=o.insert(d,f)})})}).next(()=>o))}getDocumentsMatchingCollectionQuery(e,t,r,i){let s;return this.documentOverlayCache.getOverlaysForCollection(e,t.path,r.largestBatchId).next(o=>(s=o,this.remoteDocumentCache.getDocumentsMatchingQuery(e,t,r,s,i))).next(o=>{s.forEach((c,l)=>{let u=l.getKey();o.get(u)===null&&(o=o.insert(u,Ri.newInvalidDocument(u)))});let a=_h();return o.forEach((c,l)=>{let u=s.get(c);u!==void 0&&Eh(u.mutation,l,Xr.empty(),Tn.now()),Vy(t,l)&&(a=a.insert(c,l))}),a})}};var MA=class{constructor(e){this.serializer=e,this.hr=new Map,this.Pr=new Map}getBundleMetadata(e,t){return X.resolve(this.hr.get(t))}saveBundleMetadata(e,t){return this.hr.set(t.id,function(i){return{id:i.id,version:i.version,createTime:ds(i.createTime)}}(t)),X.resolve()}getNamedQuery(e,t){return X.resolve(this.Pr.get(t))}saveNamedQuery(e,t){return this.Pr.set(t.name,function(i){return{name:i.name,query:dZ(i.bundledQuery),readTime:ds(i.readTime)}}(t)),X.resolve()}};var NA=class{constructor(){this.overlays=new Bt(Ee.comparator),this.Ir=new Map}getOverlay(e,t){return X.resolve(this.overlays.get(t))}getOverlays(e,t){let r=rc();return X.forEach(t,i=>this.getOverlay(e,i).next(s=>{s!==null&&r.set(i,s)})).next(()=>r)}saveOverlays(e,t,r){return r.forEach((i,s)=>{this.ht(e,t,s)}),X.resolve()}removeOverlaysForBatchId(e,t,r){let i=this.Ir.get(r);return i!==void 0&&(i.forEach(s=>this.overlays=this.overlays.remove(s)),this.Ir.delete(r)),X.resolve()}getOverlaysForCollection(e,t,r){let i=rc(),s=t.length+1,o=new Ee(t.child("")),a=this.overlays.getIteratorFrom(o);for(;a.hasNext();){let c=a.getNext().value,l=c.getKey();if(!t.isPrefixOf(l.path))break;l.path.length===s&&c.largestBatchId>r&&i.set(c.getKey(),c)}return X.resolve(i)}getOverlaysForCollectionGroup(e,t,r,i){let s=new Bt((l,u)=>l-u),o=this.overlays.getIterator();for(;o.hasNext();){let l=o.getNext().value;if(l.getKey().getCollectionGroup()===t&&l.largestBatchId>r){let u=s.get(l.largestBatchId);u===null&&(u=rc(),s=s.insert(l.largestBatchId,u)),u.set(l.getKey(),l)}}let a=rc(),c=s.getIterator();for(;c.hasNext()&&(c.getNext().value.forEach((l,u)=>a.set(l,u)),!(a.size()>=i)););return X.resolve(a)}ht(e,t,r){let i=this.overlays.get(r.key);if(i!==null){let o=this.Ir.get(i.largestBatchId).delete(r.key);this.Ir.set(i.largestBatchId,o)}this.overlays=this.overlays.insert(r.key,new _A(t,r));let s=this.Ir.get(t);s===void 0&&(s=nt(),this.Ir.set(t,s)),this.Ir.set(t,s.add(r.key))}};var OA=class{constructor(){this.sessionToken=jn.EMPTY_BYTE_STRING}getSessionToken(e){return X.resolve(this.sessionToken)}setSessionToken(e,t){return this.sessionToken=t,X.resolve()}};var Dh=class{constructor(){this.Tr=new Vn(en.Er),this.dr=new Vn(en.Ar)}isEmpty(){return this.Tr.isEmpty()}addReference(e,t){let r=new en(e,t);this.Tr=this.Tr.add(r),this.dr=this.dr.add(r)}Rr(e,t){e.forEach(r=>this.addReference(r,t))}removeReference(e,t){this.Vr(new en(e,t))}mr(e,t){e.forEach(r=>this.removeReference(r,t))}gr(e){let t=new Ee(new Ft([])),r=new en(t,e),i=new en(t,e+1),s=[];return this.dr.forEachInRange([r,i],o=>{this.Vr(o),s.push(o.key)}),s}pr(){this.Tr.forEach(e=>this.Vr(e))}Vr(e){this.Tr=this.Tr.delete(e),this.dr=this.dr.delete(e)}yr(e){let t=new Ee(new Ft([])),r=new en(t,e),i=new en(t,e+1),s=nt();return this.dr.forEachInRange([r,i],o=>{s=s.add(o.key)}),s}containsKey(e){let t=new en(e,0),r=this.Tr.firstAfterOrEqual(t);return r!==null&&e.isEqual(r.key)}},en=class{constructor(e,t){this.key=e,this.wr=t}static Er(e,t){return Ee.comparator(e.key,t.key)||ut(e.wr,t.wr)}static Ar(e,t){return ut(e.wr,t.wr)||Ee.comparator(e.key,t.key)}};var LA=class{constructor(e,t){this.indexManager=e,this.referenceDelegate=t,this.mutationQueue=[],this.Sr=1,this.br=new Vn(en.Er)}checkEmpty(e){return X.resolve(this.mutationQueue.length===0)}addMutationBatch(e,t,r,i){let s=this.Sr;this.Sr++,this.mutationQueue.length>0&&this.mutationQueue[this.mutationQueue.length-1];let o=new gA(s,t,r,i);this.mutationQueue.push(o);for(let a of i)this.br=this.br.add(new en(a.key,s)),this.indexManager.addToCollectionParentIndex(e,a.key.path.popLast());return X.resolve(o)}lookupMutationBatch(e,t){return X.resolve(this.Dr(t))}getNextMutationBatchAfterBatchId(e,t){let r=t+1,i=this.vr(r),s=i<0?0:i;return X.resolve(this.mutationQueue.length>s?this.mutationQueue[s]:null)}getHighestUnacknowledgedBatchId(){return X.resolve(this.mutationQueue.length===0?-1:this.Sr-1)}getAllMutationBatches(e){return X.resolve(this.mutationQueue.slice())}getAllMutationBatchesAffectingDocumentKey(e,t){let r=new en(t,0),i=new en(t,Number.POSITIVE_INFINITY),s=[];return this.br.forEachInRange([r,i],o=>{let a=this.Dr(o.wr);s.push(a)}),X.resolve(s)}getAllMutationBatchesAffectingDocumentKeys(e,t){let r=new Vn(ut);return t.forEach(i=>{let s=new en(i,0),o=new en(i,Number.POSITIVE_INFINITY);this.br.forEachInRange([s,o],a=>{r=r.add(a.wr)})}),X.resolve(this.Cr(r))}getAllMutationBatchesAffectingQuery(e,t){let r=t.path,i=r.length+1,s=r;Ee.isDocumentKey(s)||(s=s.child(""));let o=new en(new Ee(s),0),a=new Vn(ut);return this.br.forEachWhile(c=>{let l=c.key.path;return!!r.isPrefixOf(l)&&(l.length===i&&(a=a.add(c.wr)),!0)},o),X.resolve(this.Cr(a))}Cr(e){let t=[];return e.forEach(r=>{let i=this.Dr(r);i!==null&&t.push(i)}),t}removeMutationBatch(e,t){bt(this.Fr(t.batchId,"removed")===0),this.mutationQueue.shift();let r=this.br;return X.forEach(t.mutations,i=>{let s=new en(i.key,t.batchId);return r=r.delete(s),this.referenceDelegate.markPotentiallyOrphaned(e,i.key)}).next(()=>{this.br=r})}On(e){}containsKey(e,t){let r=new en(t,0),i=this.br.firstAfterOrEqual(r);return X.resolve(t.isEqual(i&&i.key))}performConsistencyCheck(e){return this.mutationQueue.length,X.resolve()}Fr(e,t){return this.vr(e)}vr(e){return this.mutationQueue.length===0?0:e-this.mutationQueue[0].batchId}Dr(e){let t=this.vr(e);return t<0||t>=this.mutationQueue.length?null:this.mutationQueue[t]}};var FA=class{constructor(e){this.Mr=e,this.docs=function(){return new Bt(Ee.comparator)}(),this.size=0}setIndexManager(e){this.indexManager=e}addEntry(e,t){let r=t.key,i=this.docs.get(r),s=i?i.size:0,o=this.Mr(t);return this.docs=this.docs.insert(r,{document:t.mutableCopy(),size:o}),this.size+=o-s,this.indexManager.addToCollectionParentIndex(e,r.path.popLast())}removeEntry(e){let t=this.docs.get(e);t&&(this.docs=this.docs.remove(e),this.size-=t.size)}getEntry(e,t){let r=this.docs.get(t);return X.resolve(r?r.document.mutableCopy():Ri.newInvalidDocument(t))}getEntries(e,t){let r=no();return t.forEach(i=>{let s=this.docs.get(i);r=r.insert(i,s?s.document.mutableCopy():Ri.newInvalidDocument(i))}),X.resolve(r)}getDocumentsMatchingQuery(e,t,r,i){let s=no(),o=t.path,a=new Ee(o.child("")),c=this.docs.getIteratorFrom(a);for(;c.hasNext();){let{key:l,value:{document:u}}=c.getNext();if(!o.isPrefixOf(l.path))break;l.path.length>o.length+1||bQ(vQ(u),r)<=0||(i.has(u.key)||Vy(t,u))&&(s=s.insert(u.key,u.mutableCopy()))}return X.resolve(s)}getAllFromCollectionGroup(e,t,r,i){Se()}Or(e,t){return X.forEach(this.docs,r=>t(r))}newChangeBuffer(e){return new VA(this)}getSize(e){return X.resolve(this.size)}},VA=class extends RA{constructor(e){super(),this.cr=e}applyChanges(e){let t=[];return this.changes.forEach((r,i)=>{i.isValidDocument()?t.push(this.cr.addEntry(e,i)):this.cr.removeEntry(r)}),X.waitFor(t)}getFromCache(e,t){return this.cr.getEntry(e,t)}getAllFromCache(e,t){return this.cr.getEntries(e,t)}};var jA=class{constructor(e){this.persistence=e,this.Nr=new ta(t=>CC(t),SC),this.lastRemoteSnapshotVersion=Le.min(),this.highestTargetId=0,this.Lr=0,this.Br=new Dh,this.targetCount=0,this.kr=xh.Bn()}forEachTarget(e,t){return this.Nr.forEach((r,i)=>t(i)),X.resolve()}getLastRemoteSnapshotVersion(e){return X.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(e){return X.resolve(this.Lr)}allocateTargetId(e){return this.highestTargetId=this.kr.next(),X.resolve(this.highestTargetId)}setTargetsMetadata(e,t,r){return r&&(this.lastRemoteSnapshotVersion=r),t>this.Lr&&(this.Lr=t),X.resolve()}Kn(e){this.Nr.set(e.target,e);let t=e.targetId;t>this.highestTargetId&&(this.kr=new xh(t),this.highestTargetId=t),e.sequenceNumber>this.Lr&&(this.Lr=e.sequenceNumber)}addTargetData(e,t){return this.Kn(t),this.targetCount+=1,X.resolve()}updateTargetData(e,t){return this.Kn(t),X.resolve()}removeTargetData(e,t){return this.Nr.delete(t.target),this.Br.gr(t.targetId),this.targetCount-=1,X.resolve()}removeTargets(e,t,r){let i=0,s=[];return this.Nr.forEach((o,a)=>{a.sequenceNumber<=t&&r.get(a.targetId)===null&&(this.Nr.delete(o),s.push(this.removeMatchingKeysForTargetId(e,a.targetId)),i++)}),X.waitFor(s).next(()=>i)}getTargetCount(e){return X.resolve(this.targetCount)}getTargetData(e,t){let r=this.Nr.get(t)||null;return X.resolve(r)}addMatchingKeys(e,t,r){return this.Br.Rr(t,r),X.resolve()}removeMatchingKeys(e,t,r){this.Br.mr(t,r);let i=this.persistence.referenceDelegate,s=[];return i&&t.forEach(o=>{s.push(i.markPotentiallyOrphaned(e,o))}),X.waitFor(s)}removeMatchingKeysForTargetId(e,t){return this.Br.gr(t),X.resolve()}getMatchingKeysForTargetId(e,t){let r=this.Br.yr(t);return X.resolve(r)}containsKey(e,t){return X.resolve(this.Br.containsKey(t))}};var $A=class{constructor(e,t){this.qr={},this.overlays={},this.Qr=new o2(0),this.Kr=!1,this.Kr=!0,this.$r=new OA,this.referenceDelegate=e(this),this.Ur=new jA(this),this.indexManager=new xA,this.remoteDocumentCache=function(i){return new FA(i)}(r=>this.referenceDelegate.Wr(r)),this.serializer=new SA(t),this.Gr=new MA(this.serializer)}start(){return Promise.resolve()}shutdown(){return this.Kr=!1,Promise.resolve()}get started(){return this.Kr}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(e){return this.indexManager}getDocumentOverlayCache(e){let t=this.overlays[e.toKey()];return t||(t=new NA,this.overlays[e.toKey()]=t),t}getMutationQueue(e,t){let r=this.qr[e.toKey()];return r||(r=new LA(t,this.referenceDelegate),this.qr[e.toKey()]=r),r}getGlobalsCache(){return this.$r}getTargetCache(){return this.Ur}getRemoteDocumentCache(){return this.remoteDocumentCache}getBundleCache(){return this.Gr}runTransaction(e,t,r){de("MemoryPersistence","Starting transaction:",e);let i=new UA(this.Qr.next());return this.referenceDelegate.zr(),r(i).next(s=>this.referenceDelegate.jr(i).next(()=>s)).toPromise().then(s=>(i.raiseOnCommittedEvent(),s))}Hr(e,t){return X.or(Object.values(this.qr).map(r=>()=>r.containsKey(e,t)))}},UA=class extends ZT{constructor(e){super(),this.currentSequenceNumber=e}},BA=class n{constructor(e){this.persistence=e,this.Jr=new Dh,this.Yr=null}static Zr(e){return new n(e)}get Xr(){if(this.Yr)return this.Yr;throw Se()}addReference(e,t,r){return this.Jr.addReference(r,t),this.Xr.delete(r.toString()),X.resolve()}removeReference(e,t,r){return this.Jr.removeReference(r,t),this.Xr.add(r.toString()),X.resolve()}markPotentiallyOrphaned(e,t){return this.Xr.add(t.toString()),X.resolve()}removeTarget(e,t){this.Jr.gr(t.targetId).forEach(i=>this.Xr.add(i.toString()));let r=this.persistence.getTargetCache();return r.getMatchingKeysForTargetId(e,t.targetId).next(i=>{i.forEach(s=>this.Xr.add(s.toString()))}).next(()=>r.removeTargetData(e,t))}zr(){this.Yr=new Set}jr(e){let t=this.persistence.getRemoteDocumentCache().newChangeBuffer();return X.forEach(this.Xr,r=>{let i=Ee.fromPath(r);return this.ei(e,i).next(s=>{s||t.removeEntry(i,Le.min())})}).next(()=>(this.Yr=null,t.apply(e)))}updateLimboDocument(e,t){return this.ei(e,t).next(r=>{r?this.Xr.delete(t.toString()):this.Xr.add(t.toString())})}Wr(e){return 0}ei(e,t){return X.or([()=>X.resolve(this.Jr.containsKey(t)),()=>this.persistence.getTargetCache().containsKey(e,t),()=>this.persistence.Hr(e,t)])}};var HA=class n{constructor(e,t,r,i){this.targetId=e,this.fromCache=t,this.$i=r,this.Ui=i}static Wi(e,t){let r=nt(),i=nt();for(let s of t.docChanges)switch(s.type){case 0:r=r.add(s.doc.key);break;case 1:i=i.add(s.doc.key)}return new n(e,t.fromCache,r,i)}};var qA=class{constructor(){this._documentReadCount=0}get documentReadCount(){return this._documentReadCount}incrementDocumentReadCount(e){this._documentReadCount+=e}};var zA=class{constructor(){this.Gi=!1,this.zi=!1,this.ji=100,this.Hi=function(){return lL()?8:EQ(pn())>0?6:4}()}initialize(e,t){this.Ji=e,this.indexManager=t,this.Gi=!0}getDocumentsMatchingQuery(e,t,r,i){let s={result:null};return this.Yi(e,t).next(o=>{s.result=o}).next(()=>{if(!s.result)return this.Zi(e,t,i,r).next(o=>{s.result=o})}).next(()=>{if(s.result)return;let o=new qA;return this.Xi(e,t,o).next(a=>{if(s.result=a,this.zi)return this.es(e,t,o,a.size)})}).next(()=>s.result)}es(e,t,r,i){return r.documentReadCount<this.ji?(yh()<=tt.DEBUG&&de("QueryEngine","SDK will not create cache indexes for query:",Gl(t),"since it only creates cache indexes for collection contains","more than or equal to",this.ji,"documents"),X.resolve()):(yh()<=tt.DEBUG&&de("QueryEngine","Query:",Gl(t),"scans",r.documentReadCount,"local documents and returns",i,"documents as results."),r.documentReadCount>this.Hi*i?(yh()<=tt.DEBUG&&de("QueryEngine","The SDK decides to create cache indexes for query:",Gl(t),"as using cache indexes may help improve performance."),this.indexManager.createTargetIndexes(e,us(t))):X.resolve())}Yi(e,t){if(OF(t))return X.resolve(null);let r=us(t);return this.indexManager.getIndexType(e,r).next(i=>i===0?null:(t.limit!==null&&i===1&&(t=fA(t,null,"F"),r=us(t)),this.indexManager.getDocumentsMatchingTarget(e,r).next(s=>{let o=nt(...s);return this.Ji.getDocuments(e,o).next(a=>this.indexManager.getMinOffset(e,r).next(c=>{let l=this.ts(t,a);return this.ns(t,l,o,c.readTime)?this.Yi(e,fA(t,null,"F")):this.rs(e,l,t,c)}))})))}Zi(e,t,r,i){return OF(t)||i.isEqual(Le.min())?X.resolve(null):this.Ji.getDocuments(e,r).next(s=>{let o=this.ts(t,s);return this.ns(t,o,r,i)?X.resolve(null):(yh()<=tt.DEBUG&&de("QueryEngine","Re-using previous result from %s to execute query: %s",i.toString(),Gl(t)),this.rs(e,o,t,_Q(i,-1)).next(a=>a))})}ts(e,t){let r=new Vn(_2(e));return t.forEach((i,s)=>{Vy(e,s)&&(r=r.add(s))}),r}ns(e,t,r,i){if(e.limit===null)return!1;if(r.size!==t.size)return!0;let s=e.limitType==="F"?t.last():t.first();return!!s&&(s.hasPendingWrites||s.version.compareTo(i)>0)}Xi(e,t,r){return yh()<=tt.DEBUG&&de("QueryEngine","Using full collection scan to execute query:",Gl(t)),this.Ji.getDocumentsMatchingQuery(e,t,ac.min(),r)}rs(e,t,r,i){return this.Ji.getDocumentsMatchingQuery(e,r,i).next(s=>(t.forEach(o=>{s=s.insert(o.key,o)}),s))}};
20var GA=class{constructor(e,t,r,i){this.persistence=e,this.ss=t,this.serializer=i,this.os=new Bt(ut),this._s=new ta(s=>CC(s),SC),this.us=new Map,this.cs=e.getRemoteDocumentCache(),this.Ur=e.getTargetCache(),this.Gr=e.getBundleCache(),this.ls(r)}ls(e){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(e),this.indexManager=this.persistence.getIndexManager(e),this.mutationQueue=this.persistence.getMutationQueue(e,this.indexManager),this.localDocuments=new PA(this.cs,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.cs.setIndexManager(this.indexManager),this.ss.initialize(this.localDocuments,this.indexManager)}collectGarbage(e){return this.persistence.runTransaction("Collect garbage","readwrite-primary",t=>e.collect(t,this.os))}};function hZ(n,e,t,r){return new GA(n,e,t,r)}function F2(n,e){return m(this,null,function*(){let t=Pe(n);return yield t.persistence.runTransaction("Handle user change","readonly",r=>{let i;return t.mutationQueue.getAllMutationBatches(r).next(s=>(i=s,t.ls(e),t.mutationQueue.getAllMutationBatches(r))).next(s=>{let o=[],a=[],c=nt();for(let l of i){o.push(l.batchId);for(let u of l.mutations)c=c.add(u.key)}for(let l of s){a.push(l.batchId);for(let u of l.mutations)c=c.add(u.key)}return t.localDocuments.getDocuments(r,c).next(l=>({hs:l,removedBatchIds:o,addedBatchIds:a}))})})})}function fZ(n,e){let t=Pe(n);return t.persistence.runTransaction("Acknowledge batch","readwrite-primary",r=>{let i=e.batch.keys(),s=t.cs.newChangeBuffer({trackRemovals:!0});return function(a,c,l,u){let d=l.batch,f=d.keys(),p=X.resolve();return f.forEach(y=>{p=p.next(()=>u.getEntry(c,y)).next(v=>{let w=l.docVersions.get(y);bt(w!==null),v.version.compareTo(w)<0&&(d.applyToRemoteDocument(v,l),v.isValidDocument()&&(v.setReadTime(l.commitVersion),u.addEntry(v)))})}),p.next(()=>a.mutationQueue.removeMutationBatch(c,d))}(t,r,e,s).next(()=>s.apply(r)).next(()=>t.mutationQueue.performConsistencyCheck(r)).next(()=>t.documentOverlayCache.removeOverlaysForBatchId(r,i,e.batch.batchId)).next(()=>t.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(r,function(a){let c=nt();for(let l=0;l<a.mutationResults.length;++l)a.mutationResults[l].transformResults.length>0&&(c=c.add(a.batch.mutations[l].key));return c}(e))).next(()=>t.localDocuments.getDocuments(r,i))})}function V2(n){let e=Pe(n);return e.persistence.runTransaction("Get last remote snapshot version","readonly",t=>e.Ur.getLastRemoteSnapshotVersion(t))}function pZ(n,e){let t=Pe(n),r=e.snapshotVersion,i=t.os;return t.persistence.runTransaction("Apply remote event","readwrite-primary",s=>{let o=t.cs.newChangeBuffer({trackRemovals:!0});i=t.os;let a=[];
20e.targetChanges.forEach((u,d)=>{let f=i.get(d);if(!f)return;a.push(t.Ur.removeMatchingKeys(s,u.removedDocuments,d).next(()=>t.Ur.addMatchingKeys(s,u.addedDocuments,d)));let p=f.withSequenceNumber(s.currentSequenceNumber);e.targetMismatches.get(d)!==null?p=p.withResumeToken(jn.EMPTY_BYTE_STRING,Le.min()).withLastLimboFreeSnapshotVersion(Le.min()):u.resumeToken.approximateByteSize()>0&&(p=p.withResumeToken(u.resumeToken,r)),i=i.insert(d,p),function(v,w,E){return v.resumeToken.approximateByteSize()===0||w.snapshotVersion.toMicroseconds()-v.snapshotVersion.toMicroseconds()>=3e8?!0:E.addedDocuments.size+E.modifiedDocuments.size+E.removedDocuments.size>0}(f,p,u)&&a.push(t.Ur.updateTargetData(s,p))});let c=no(),l=nt();if(e.documentUpdates.forEach(u=>{e.resolvedLimboDocuments.has(u)&&a.push(t.persistence.referenceDelegate.updateLimboDocument(s,u))}),a.push(mZ(s,o,e.documentUpdates).next(u=>{c=u.Ps,l=u.Is})),!r.isEqual(Le.min())){let u=t.Ur.getLastRemoteSnapshotVersion(s).next(d=>t.Ur.setTargetsMetadata(s,s.currentSequenceNumber,r));a.push(u)}return X.waitFor(a).next(()=>o.apply(s)).next(()=>t.localDocuments.getLocalViewOfDocuments(s,c,l)).next(()=>c)}).then(s=>(t.os=i,s))}function mZ(n,e,t){let r=nt(),i=nt();return t.forEach(s=>r=r.add(s)),e.getEntries(n,r).next(s=>{let o=no();return t.forEach((a,c)=>{let l=s.get(a);c.isFoundDocument()!==l.isFoundDocument()&&(i=i.add(a)),c.isNoDocument()&&c.version.isEqual(Le.min())?(e.removeEntry(a,c.readTime),o=o.insert(a,c)):!l.isValidDocument()||c.version.compareTo(l.version)>0||c.version.compareTo(l.version)===0&&l.hasPendingWrites?(e.addEntry(c),o=o.insert(a,c)):de("LocalStore","Ignoring outdated watch update for ",a,". Current version:",l.version," Watch version:",c.version)}),{Ps:o,Is:i}})}function gZ(n,e){let t=Pe(n);return t.persistence.runTransaction("Get next mutation batch","readonly",r=>(e===void 0&&(e=-1),t.mutationQueue.getNextMutationBatchAfterBatchId(r,e)))}function yZ(n,e){let t=Pe(n);return t.persistence.runTransaction("Allocate target","readwrite",r=>{let i;return t.Ur.getTargetData(r,e).next(s=>s?(i=s,X.resolve(i)):t.Ur.allocateTargetId(r).next(o=>(i=new Sh(e,o,"TargetPurposeListen",r.currentSequenceNumber),t.Ur.addTargetData(r,i).next(()=>i))))}).then(r=>{let i=t.os.get(r.targetId);return(i===null||r.snapshotVersion.compareTo(i.snapshotVersion)>0)&&(t.os=t.os.insert(r.targetId,r),t._s.set(e,r.targetId)),r})}function WA(n,e,t){return m(this,null,function*(){let r=Pe(n),i=r.os.get(e),s=t?"readwrite":"readwrite-primary";try{t||(yield r.persistence.runTransaction("Release target",s,o=>r.persistence.referenceDelegate.removeTarget(o,i)))}catch(o){if(!Fh(o))throw o;de("LocalStore",`Failed to update sequence numbers for target ${e}: ${o}`)}r.os=r.os.remove(e),r._s.delete(i.target)})}function GF(n,e,t){let r=Pe(n),i=Le.min(),s=nt();return r.persistence.runTransaction("Execute query","readwrite",o=>function(c,l,u){let d=Pe(c),f=d._s.get(u);return f!==void 0?X.resolve(d.os.get(f)):d.Ur.getTargetData(l,u)}(r,o,us(e)).next(a=>{if(a)return i=a.lastLimboFreeSnapshotVersion,r.Ur.getMatchingKeysForTargetId(o,a.targetId).next(c=>{s=c})}).next(()=>r.ss.getDocumentsMatchingQuery(o,e,t?i:Le.min(),t?s:nt())).next(a=>(_Z(r,MQ(e),a),{documents:a,Ts:s})))}function _Z(n,e,t){let r=n.us.get(e)||Le.min();t.forEach((i,s)=>{s.readTime.compareTo(r)>0&&(r=s.readTime)}),n.us.set(e,r)}var my=class{constructor(){this.activeTargetIds=jQ()}fs(e){this.activeTargetIds=this.activeTargetIds.add(e)}gs(e){this.activeTargetIds=this.activeTargetIds.delete(e)}Vs(){let e={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(e)}};var KA=class{constructor(){this.so=new my,this.oo={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(e){}updateMutationState(e,t,r){}addLocalQueryTarget(e,t=!0){return t&&this.so.fs(e),this.oo[e]||"not-current"}updateQueryState(e,t,r){this.oo[e]=t}removeLocalQueryTarget(e){this.so.gs(e)}isLocalQueryTarget(e){return this.so.activeTargetIds.has(e)}clearQueryState(e){delete this.oo[e]}getAllActiveQueryTargets(){return this.so.activeTargetIds}isActiveQueryTarget(e){return this.so.activeTargetIds.has(e)}start(){return this.so=new my,Promise.resolve()}handleUserChange(e,t,r){}setOnlineState(e){}shutdown(){}writeSequenceNumber(e){}notifyBundleLoaded(e){}};var YA=class{_o(e){}shutdown(){}};var gy=class{constructor(){this.ao=()=>this.uo(),this.co=()=>this.lo(),this.ho=[],this.Po()}_o(e){this.ho.push(e)}shutdown(){window.removeEventListener("online",this.ao),window.removeEventListener("offline",this.co)}Po(){window.addEventListener("online",this.ao),window.addEventListener("offline",this.co)}uo(){de("ConnectivityMonitor","Network connectivity changed: AVAILABLE");for(let e of this.ho)e(0)}lo(){de("ConnectivityMonitor","Network connectivity changed: UNAVAILABLE");for(let e of this.ho)e(1)}static D(){return typeof window<"u"&&window.addEventListener!==void 0&&window.removeEventListener!==void 0}};var Zg=null;function UT(){return Zg===null?Zg=function(){return 268435456+Math.round(2147483648*Math.random())}():Zg++,"0x"+Zg.toString(16)}var vZ={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregation
20Query:"runAggregationQuery"};var XA=class{constructor(e){this.Io=e.Io,this.To=e.To}Eo(e){this.Ao=e}Ro(e){this.Vo=e}mo(e){this.fo=e}onMessage(e){this.po=e}close(){this.To()}send(e){this.Io(e)}yo(){this.Ao()}wo(){this.Vo()}So(e){this.fo(e)}bo(e){this.po(e)}};var Fn="WebChannelConnection",QA=class extends class{constructor(t){this.databaseInfo=t,this.databaseId=t.databaseId;let r=t.ssl?"https":"http",i=encodeURIComponent(this.databaseId.projectId),s=encodeURIComponent(this.databaseId.database);this.Do=r+"://"+t.host,this.vo=`projects/${i}/databases/${s}`,this.Co=this.databaseId.database==="(default)"?`project_id=${i}`:`project_id=${i}&database_id=${s}`}get Fo(){return!1}Mo(t,r,i,s,o){let a=UT(),c=this.xo(t,r.toUriEncodedString());de("RestConnection",`Sending RPC '${t}' ${a}:`,c,i);let l={"google-cloud-resource-prefix":this.vo,"x-goog-request-params":this.Co};return this.Oo(l,s,o),this.No(t,c,l,i).then(u=>(de("RestConnection",`Received RPC '${t}' ${a}: `,u),u),u=>{throw Zl("RestConnection",`RPC '${t}' ${a} failed with error: `,u,"url: ",c,"request:",i),u})}Lo(t,r,i,s,o,a){return this.Mo(t,r,i,s,o)}Oo(t,r,i){t["X-Goog-Api-Client"]=function(){return"gl-js/ fire/"+uu}(),t["Content-Type"]="text/plain",this.databaseInfo.appId&&(t["X-Firebase-GMPID"]=this.databaseInfo.appId),r&&r.headers.forEach((s,o)=>t[o]=s),i&&i.headers.forEach((s,o)=>t[o]=s)}xo(t,r){let i=vZ[t];return`${this.Do}/v1/${r}:${i}`}terminate(){}}{constructor(e){super(e),this.forceLongPolling=e.forceLongPolling,this.autoDetectLongPolling=e.autoDetectLongPolling,this.useFetchStreams=e.useFetchStreams,this.longPollingOptions=e.longPollingOptions}No(e,t,r,i){let s=UT();return new Promise((o,a)=>{let c=new OT;c.setWithCredentials(!0),c.listenOnce(LT.COMPLETE,()=>{try{switch(c.getLastErrorCode()){case gh.NO_ERROR:let u=c.getResponseJson();de(Fn,`XHR for RPC '${e}' ${s} received:`,JSON.stringify(u)),o(u);break;case gh.TIMEOUT:de(Fn,`RPC '${e}' ${s} timed out`),a(new ne(q.DEADLINE_EXCEEDED,"Request time out"));break;case gh.HTTP_ERROR:let d=c.getStatus();if(de(Fn,`RPC '${e}' ${s} failed with status:`,d,"response text:",c.getResponseText()),d>0){let f=c.getResponseJson();Array.isArray(f)&&(f=f[0]);let p=f?.error;if(p&&p.status&&p.message){let y=function(w){let E=w.toLowerCase().replace(/_/g,"-");return Object.values(q).indexOf(E)>=0?E:q.UNKNOWN}(p.status);a(new ne(y,p.message))}else a(new ne(q.UNKNOWN,"Server responded with status "+c.getStatus()))}else a(new ne(q.UNAVAILABLE,"Connection failed."));break;default:Se()}}finally{de(Fn,`RPC '${e}' ${s} completed.`)}});let l=JSON.stringify(i);de(Fn,`RPC '${e}' ${s} sending request:`,i),c.send(t,"POST",l,r,15)})}Bo(e,t,r){let i=UT(),s=[this.Do,"/","google.firestore.v1.Firestore","/",e,"/channel"],o=jT(),a=VT(),c={httpSessionIdParam:"gsessionid",initMessageHeaders:{},messageUrlParams:{database:`projects/${this.databaseId.projectId}/databases/${this.databaseId.database}`},sendRawJson:!0,supportsCrossDomainXhr:!0,internalChannelParams:{forwardChannelRequestTimeoutMs:6e5},forceLongPolling:this.forceLongPolling,detectBufferingProxy:this.autoDetectLongPolling},l=this.longPollingOptions.timeoutSeconds;l!==void 0&&(c.longPollingTimeout=Math.round(1e3*l)),this.useFetchStreams&&(c.useFetchStreams=!0),this.Oo(c.initMessageHeaders,t,r),c.encodeInitMessageHeaders=!0;let u=s.join("");de(Fn,`Creating RPC '${e}' stream ${i}: ${u}`,c);let d=o.createWebChannel(u,c),f=!1,p=!1,y=new XA({Io:w=>{p?de(Fn,`Not sending because RPC '${e}' stream ${i} is closed:`,w):(f||(de(Fn,`Opening RPC '${e}' stream ${i} transport.`),d.open(),f=!0),de(Fn,`RPC '${e}' stream ${i} sending:`,w),d.send(w))},To:()=>d.close()}),v=(w,E,A)=>{w.listen(E,x=>{try{A(x)}catch(M){setTimeout(()=>{throw M},0)}})};return v(d,zl.EventType.OPEN,()=>{p||(de(Fn,`RPC '${e}' stream ${i} transport opened.`),y.yo())}),v(d,zl.EventType.CLOSE,()=>{p||(p=!0,de(Fn,`RPC '${e}' stream ${i} transport closed`),y.So())}),v(d,zl.EventType.ERROR,w=>{p||(p=!0,Zl(Fn,`RPC '${e}' stream ${i} transport errored:`,w),y.So(new ne(q.UNAVAILABLE,"The operation could not be completed")))}),v(d,zl.EventType.MESSAGE,w=>{var E;if(!p){let A=w.data[0];bt(!!A);let x=A,M=x.error||((E=x[0])===null||E===void 0?void 0:E.error);if(M){de(Fn,`RPC '${e}' stream ${i} received error:`,M);let O=M.status,$=function(S){let k=Jt[S];if(k!==void 0)return D2(k)}(O),C=M.message;$===void 0&&($=q.INTERNAL,C="Unknown error status: "+O+" with message "+M.message),p=!0,y.So(new ne($,C)),d.close()}else de(Fn,`RPC '${e}' stream ${i} received:`,A),y.bo(A)}}),v(a,FT.STAT_EVENT,w=>{w.stat===Xg.PROXY?de(Fn,`RPC '${e}' stream ${i} detected buffering proxy`):w.stat===Xg.NOPROXY&&de(Fn,`RPC '${e}' stream ${i} detected no buffering proxy`)}),setTimeout(()=>{y.wo()},0),y}};function BT(){return typeof document<"u"?document:null}function jy(n){return new EA(n,!0)}var yy=class{constructor(e,t,r=1e3,i=1.5,s=6e4){this.ui=e,this.timerId=t,this.ko=r,this.qo=i,this.Qo=s,this.Ko=0,this.$o=null,this.Uo=Date.now(),this.reset()}reset(){this.Ko=0}Wo(){this.Ko=this.Qo}Go(e){this.cancel();let t=Math.floor(this.Ko+this.zo()),r=Math.max(0,Date.now()-this.Uo),i=Math.max(0,t-r);i>0&&de("ExponentialBackoff",`Backing off for ${i} ms (base delay: ${this.Ko}
20 ms, delay with jitter: ${t} ms, last attempt: ${r} ms ago)`),this.$o=this.ui.enqueueAfterDelay(this.timerId,i,()=>(this.Uo=Date.now(),e())),this.Ko*=this.qo,this.Ko<this.ko&&(this.Ko=this.ko),this.Ko>this.Qo&&(this.Ko=this.Qo)}jo(){this.$o!==null&&(this.$o.skipDelay(),this.$o=null)}cancel(){this.$o!==null&&(this.$o.cancel(),this.$o=null)}zo(){return(Math.random()-.5)*this.Ko}};var _y=class{constructor(e,t,r,i,s,o,a,c){this.ui=e,this.Ho=r,this.Jo=i,this.connection=s,this.authCredentialsProvider=o,this.appCheckCredentialsProvider=a,this.listener=c,this.state=0,this.Yo=0,this.Zo=null,this.Xo=null,this.stream=null,this.e_=0,this.t_=new yy(e,t)}n_(){return this.state===1||this.state===5||this.r_()}r_(){return this.state===2||this.state===3}start(){this.e_=0,this.state!==4?this.auth():this.i_()}stop(){return m(this,null,function*(){this.n_()&&(yield this.close(0))})}s_(){this.state=0,this.t_.reset()}o_(){this.r_()&&this.Zo===null&&(this.Zo=this.ui.enqueueAfterDelay(this.Ho,6e4,()=>this.__()))}a_(e){this.u_(),this.stream.send(e)}__(){return m(this,null,function*(){if(this.r_())return this.close(0)})}u_(){this.Zo&&(this.Zo.cancel(),this.Zo=null)}c_(){this.Xo&&(this.Xo.cancel(),this.Xo=null)}close(e,t){return m(this,null,function*(){this.u_(),this.c_(),this.t_.cancel(),this.Yo++,e!==4?this.t_.reset():t&&t.code===q.RESOURCE_EXHAUSTED?(eo(t.toString()),eo("Using maximum backoff delay to prevent overloading the backend."),this.t_.Wo()):t&&t.code===q.UNAUTHENTICATED&&this.state!==3&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),this.stream!==null&&(this.l_(),this.stream.close(),this.stream=null),this.state=e,yield this.listener.mo(t)})}l_(){}auth(){this.state=1;let e=this.h_(this.Yo),t=this.Yo;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then(([r,i])=>{this.Yo===t&&this.P_(r,i)},r=>{e(()=>{let i=new ne(q.UNKNOWN,"Fetching auth token failed: "+r.message);return this.I_(i)})})}P_(e,t){let r=this.h_(this.Yo);this.stream=this.T_(e,t),this.stream.Eo(()=>{r(()=>this.listener.Eo())}),this.stream.Ro(()=>{r(()=>(this.state=2,this.Xo=this.ui.enqueueAfterDelay(this.Jo,1e4,()=>(this.r_()&&(this.state=3),Promise.resolve())),this.listener.Ro()))}),this.stream.mo(i=>{r(()=>this.I_(i))}),this.stream.onMessage(i=>{r(()=>++this.e_==1?this.E_(i):this.onNext(i))})}i_(){this.state=5,this.t_.Go(()=>m(this,null,function*(){this.state=0,this.start()}))}I_(e){return de("PersistentStream",`close with error: ${e}`),this.stream=null,this.close(4,e)}h_(e){return t=>{this.ui.enqueueAndForget(()=>this.Yo===e?t():(de("PersistentStream","stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve()))}}},ZA=class extends _y{constructor(e,t,r,i,s,o){super(e,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",t,r,i,o),this.serializer=s}T_(e,t){return this.connection.Bo("Listen",e,t)}E_(e){return this.onNext(e)}onNext(e){this.t_.reset();let t=eZ(this.serializer,e),r=function(s){if(!("targetChange"in s))return Le.min();let o=s.targetChange;return o.targetIds&&o.targetIds.length?Le.min():o.readTime?ds(o.readTime):Le.min()}(e);return this.listener.d_(t,r)}A_(e){let t={};t.database=CA(this.serializer),t.addTarget=function(s,o){let a,c=o.target;if(a=dA(c)?{documents:rZ(s,c)}:{query:iZ(s,c)._t},a.targetId=o.targetId,o.resumeToken.approximateByteSize()>0){a.resumeToken=R2(s,o.resumeToken);let l=IA(s,o.expectedCount);l!==null&&(a.expectedCount=l)}else if(o.snapshotVersion.compareTo(Le.min())>0){a.readTime=fy(s,o.snapshotVersion.toTimestamp());let l=IA(s,o.expectedCount);l!==null&&(a.expectedCount=l)}return a}(this.serializer,e);let r=oZ(this.serializer,e);r&&(t.labels=r),this.a_(t)}R_(e){let t={};t.database=CA(this.serializer),t.removeTarget=e,this.a_(t)}},JA=class extends _y{constructor(e,t,r,i,s,o){super(e,"write_stream_connection_backoff","write_stream_idle","health_check_timeout",t,r,i,o),this.serializer=s}get V_(){return this.e_>0}start(){this.lastStreamToken=void 0,super.start()}l_(){this.V_&&this.m_([])}T_(e,t){return this.connection.Bo("Write",e,t)}E_(e){return bt(!!e.streamToken),this.lastStreamToken=e.streamToken,bt(!e.writeResults||e.writeResults.length===0),this.listener.f_()}onNext(e){bt(!!e.streamToken),this.lastStreamToken=e.streamToken,this.t_.reset();let t=nZ(e.writeResults,e.commitTime),r=ds(e.commitTime);return this.listener.g_(r,t)}p_(){let e={};e.database=CA(this.serializer),this.a_(e)}m_(e){let t={streamToken:this.lastStreamToken,writes:e.map(r=>tZ(this.serializer,r))};this.a_(t)}};var eC=class extends class{}
vendor: 20,234 bytes, lines 20-24
20{constructor(e,t,r,i){super(),this.authCredentials=e,this.appCheckCredentials=t,this.connection=r,this.serializer=i,this.y_=!1}w_(){if(this.y_)throw new ne(q.FAILED_PRECONDITION,"The client has already been terminated.")}Mo(e,t,r,i){return this.w_(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([s,o])=>this.connection.Mo(e,TA(t,r),i,s,o)).catch(s=>{throw s.name==="FirebaseError"?(s.code===q.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),s):new ne(q.UNKNOWN,s.toString())})}Lo(e,t,r,i,s){return this.w_(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([o,a])=>this.connection.Lo(e,TA(t,r),i,o,a,s)).catch(o=>{throw o.name==="FirebaseError"?(o.code===q.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),o):new ne(q.UNKNOWN,o.toString())})}terminate(){this.y_=!0,this.connection.terminate()}},tC=class{constructor(e,t){this.asyncQueue=e,this.onlineStateHandler=t,this.state="Unknown",this.S_=0,this.b_=null,this.D_=!0}v_(){this.S_===0&&(this.C_("Unknown"),this.b_=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,()=>(this.b_=null,this.F_("Backend didn't respond within 10 seconds."),this.C_("Offline"),Promise.resolve())))}M_(e){this.state==="Online"?this.C_("Unknown"):(this.S_++,this.S_>=1&&(this.x_(),this.F_(`Connection failed 1 times. Most recent error: ${e.toString()}`),this.C_("Offline")))}set(e){this.x_(),this.S_=0,e==="Online"&&(this.D_=!1),this.C_(e)}C_(e){e!==this.state&&(this.state=e,this.onlineStateHandler(e))}F_(e){let t=`Could not reach Cloud Firestore backend. ${e} 21This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.`;this.D_?(eo(t),this.D_=!1):de("OnlineStateTracker",t)}x_(){this.b_!==null&&(this.b_.cancel(),this.b_=null)}};var nC=class{constructor(e,t,r,i,s){this.localStore=e,this.datastore=t,this.asyncQueue=r,this.remoteSyncer={},this.O_=[],this.N_=new Map,this.L_=new Set,this.B_=[],this.k_=s,this.k_._o(o=>{r.enqueueAndForget(()=>m(this,null,function*(){pc(this)&&(de("RemoteStore","Restarting streams for network reachability change."),yield function(c){return m(this,null,function*(){let l=Pe(c);l.L_.add(4),yield Vh(l),l.q_.set("Unknown"),l.L_.delete(4),yield $y(l)})}(this))}))}),this.q_=new tC(r,i)}};function $y(n){return m(this,null,function*(){if(pc(n))for(let e of n.B_)yield e(!0)})}function Vh(n){return m(this,null,function*(){for(let e of n.B_)yield e(!1)})}function j2(n,e){let t=Pe(n);t.N_.has(e.targetId)||(t.N_.set(e.targetId,e),NC(t)?MC(t):du(t).r_()&&PC(t,e))}function kC(n,e){let t=Pe(n),r=du(t);t.N_.delete(e),r.r_()&&$2(t,e),t.N_.size===0&&(r.r_()?r.o_():pc(t)&&t.q_.set("Unknown"))}function PC(n,e){if(n.Q_.xe(e.targetId),e.resumeToken.approximateByteSize()>0||e.snapshotVersion.compareTo(Le.min())>0){let t=n.remoteSyncer.getRemoteKeysForTarget(e.targetId).size;e=e.withExpectedCount(t)}du(n).A_(e)}function $2(n,e){n.Q_.xe(e),du(n).R_(e)}function MC(n){n.Q_=new wA({getRemoteKeysForTarget:e=>n.remoteSyncer.getRemoteKeysForTarget(e),ot:e=>n.N_.get(e)||null,tt:()=>n.datastore.serializer.databaseId}),du(n).start(),n.q_.v_()}function NC(n){return pc(n)&&!du(n).n_()&&n.N_.size>0}function pc(n){return Pe(n).L_.size===0}function U2(n){n.Q_=void 0}function bZ(n){return m(this,null,function*(){n.q_.set("Online")})}function wZ(n){return m(this,null,function*(){n.N_.forEach((e,t)=>{PC(n,e)})})}function EZ(n,e){return m(this,null,function*(){U2(n),NC(n)?(n.q_.M_(e),MC(n)):n.q_.set("Unknown")})}function IZ(n,e,t){return m(this,null,function*(){if(n.q_.set("Online"),e instanceof dy&&e.state===2&&e.cause)try{yield function(i,s){return m(this,null,function*(){let o=s.cause;for(let a of s.targetIds)i.N_.has(a)&&(yield i.remoteSyncer.rejectListen(a,o),i.N_.delete(a),i.Q_.removeTarget(a))})}(n,e)}catch(r){de("RemoteStore","Failed to remove targets %s: %s ",e.targetIds.join(","),r),yield vy(n,r)}else if(e instanceof Xl?n.Q_.Ke(e):e instanceof uy?n.Q_.He(e):n.Q_.We(e),!t.isEqual(Le.min()))try{let r=yield V2(n.localStore);t.compareTo(r)>=0&&(yield function(s,o){let a=s.Q_.rt(o);return a.targetChanges.forEach((c,l)=>{if(c.resumeToken.approximateByteSize()>0){let u=s.N_.get(l);u&&s.N_.set(l,u.withResumeToken(c.resumeToken,o))}}),a.targetMismatches.forEach((c,l)=>{let u=s.N_.get(c);if(!u)return;s.N_.set(c,u.withResumeToken(jn.EMPTY_BYTE_STRING,u.snapshotVersion)),$2(s,c);let d=new Sh(u.target,c,l,u.sequenceNumber);PC(s,d)}),s.remoteSyncer.applyRemoteEvent(a)}(n,t))}catch(r){de("RemoteStore","Failed to raise snapshot:",r),yield vy(n,r)}})}function vy(n,e,t){return m(this,null,function*(){if(!Fh(e))throw e;n.L_.add(1),yield Vh(n),n.q_.set("Offline"),t||(t=()=>V2(n.localStore)),n.asyncQueue.enqueueRetryable(()=>m(this,null,function*(){de("RemoteStore","Retrying IndexedDB access"),yield t(),n.L_.delete(1),yield $y(n)}))})}function B2(n,e){return e().catch(t=>vy(n,t,e))}function Uy(n){return m(this,null,function*(){let e=Pe(n),t=na(e),r=e.O_.length>0?e.O_[e.O_.length-1].batchId:-1;for(;TZ(e);)try{let i=yield gZ(e.localStore,r);if(i===null){e.O_.length===0&&t.o_();break}r=i.batchId,AZ(e,i)}catch(i){yield vy(e,i)}H2(e)&&q2(e)})}function TZ(n){return pc(n)&&n.O_.length<10}function AZ(n,e){n.O_.push(e);let t=na(n);t.r_()&&t.V_&&t.m_(e.mutations)}function H2(n){return pc(n)&&!na(n).n_()&&n.O_.length>0}function q2(n){na(n).start()}function CZ(n){return m(this,null,function*(){na(n).p_()})}function SZ(n){return m(this,null,function*(){let e=na(n);for(let t of n.O_)e.m_(t.mutations)})}function xZ(n,e,t){return m(this,null,function*(){let r=n.O_.shift(),i=yA.from(r,e,t);yield B2(n,()=>n.remoteSyncer.applySuccessfulWrite(i)),yield Uy(n)})}function DZ(n,e){return m(this,null,function*(){e&&na(n).V_&&(yield function(r,i){return m(this,null,function*(){if(function(o){return GQ(o)&&o!==q.ABORTED}(i.code)){let s=r.O_.shift();na(r).s_(),yield B2(r,()=>r.remoteSyncer.rejectFailedWrite(s.batchId,i)),yield Uy(r)}})}(n,e)),H2(n)&&q2(n)})}function WF(n,e){return m(this,null,function*(){let t=Pe(n);t.asyncQueue.verifyOperationInProgress(),de("RemoteStore","RemoteStore received new credentials");let r=pc(t);t.L_.add(3),yield Vh(t),r&&t.q_.set("Unknown"),yield t.remoteSyncer.handleCredentialChange(e),t.L_.delete(3),yield $y(t)})}function RZ(n,e){return m(this,null,function*(){let t=Pe(n);e?(t.L_.delete(2),yield $y(t)):e||(t.L_.add(2),yield Vh(t),t.q_.set("Unknown"))})}function du(n){return n.K_||(n.K_=function(t,r,i){let s=Pe(t);return s.w_(),new ZA(r,s.connection,s.authCredentials,s.appCheckCredentials,s.serializer,i)}(n.datastore,n.asyncQueue,{Eo:bZ.bind(null,n),Ro:wZ.bind(null,n),mo:EZ.bind(null,n),d_:IZ.bind(null,n)}),n.B_.push(e=>m(this,null,function*(){e?(n.K_.s_(),NC(n)?MC(n):n.q_.set("Unknown")):(yield n.K_.stop(),U2(n))}))),n.K_}function na(n){return n.U_||(n.U_=function(t,r,i){let s=Pe(t);return s.w_(),new JA(r,s.connection,s.authCredentials,s.appCheckCredentials,s.serializer,i)}(n.datastore,n.asyncQueue,{Eo:()=>Promise.resolve(),Ro:CZ.bind(null,n),mo:DZ.bind(null,n),f_:SZ.bind(null,n),g_:xZ.bind(null,n)}),n.B_.push(e=>m(this,null,function*(){e?(n.U_.s_(),yield Uy(n)):(yield n.U_.stop(),n.O_.length>0&&(de("RemoteStore",`Stopping write stream with ${n.O_.length} pending writes`),n.O_=[]))}))),n.U_}var rC=class n{constructor(e,t,r,i,s){this.asyncQueue=e,this.timerId=t,this.targetTimeMs=r,this.op=i,this.removalCallback=s,this.deferred=new cs,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch(o=>{})}get promise(){return this.deferred.promise}static createAndSchedule(e,t,r,i,s){let o=Date.now()+r,a=new n(e,t,o,i,s);return a.start(r),a}start(e){this.timerHandle=setTimeout(()=>this.handleDelayElapsed(),e)}skipDelay(){return this.handleDelayElapsed()}cancel(e){this.timerHandle!==null&&(this.clearTimeout(),this.deferred.reject(new ne(q.CANCELLED,"Operation cancelled"+(e?": "+e:""))))}handleDelayElapsed(){this.asyncQueue.enqueueAndForget(()=>this.timerHandle!==null?(this.clearTimeout(),this.op().then(e=>this.deferred.resolve(e))):Promise.resolve())}clearTimeout(){this.timerHandle!==null&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)}};function OC(n,e){if(eo("AsyncQueue",`${e}: ${n}`),Fh(n))return new ne(q.UNAVAILABLE,`${e}: ${n}`);throw n}var by=class n{constructor(e){this.comparator=e?(t,r)=>e(t,r)||Ee.comparator(t.key,r.key):(t,r)=>Ee.comparator(t.key,r.key),this.keyedMap=_h(),this.sortedSet=new Bt(this.comparator)}static emptySet(e){return new n(e.comparator)}has(e){return this.keyedMap.get(e)!=null}get(e){return this.keyedMap.get(e)}first(){return this.sortedSet.minKey()}last(){return this.sortedSet.maxKey()}isEmpty(){return this.sortedSet.isEmpty()}indexOf(e){let t=this.keyedMap.get(e);return t?this.sortedSet.indexOf(t):-1}get size(){return this.sortedSet.size}forEach(e){this.sortedSet.inorderTraversal((t,r)=>(e(t),!1))}add(e){let t=this.delete(e.key);return t.copy(t.keyedMap.insert(e.key,e),t.sortedSet.insert(e,null))}delete(e){let t=this.get(e);return t?this.copy(this.keyedMap.remove(e),this.sortedSet.remove(t)):this}isEqual(e){if(!(e instanceof n)||this.size!==e.size)return!1;let t=this.sortedSet.getIterator(),r=e.sortedSet.getIterator();for(;t.hasNext();){let i=t.getNext().key,s=r.getNext().key;if(!i.isEqual(s))return!1}return!0}toString(){let e=[];return this.forEach(t=>{e.push(t.toString())}),e.length===0?"DocumentSet ()":`DocumentSet ( 22 `+e.join(` 23`)+` 24)`}copy(e,t){let r=new n;return r.comparator=this.comparator,r.keyedMap=e,r.sortedSet=t,r}};var wy=class{constructor(){this.W_=new Bt(Ee.comparator)}track(e){let t=e.doc.key,r=this.W_.get(t);r?e.type!==0&&r.type===3?this.W_=this.W_.insert(t,e):e.type===3&&r.type!==1?this.W_=this.W_.insert(t,{type:r.type,doc:e.doc}):e.type===2&&r.type===2?this.W_=this.W_.insert(t,{type:2,doc:e.doc}):e.type===2&&r.type===0?this.W_=this.W_.insert(t,{type:0,doc:e.doc}):e.type===1&&r.type===0?this.W_=this.W_.remove(t):e.type===1&&r.type===2?this.W_=this.W_.insert(t,{type:1,doc:r.doc}):e.type===0&&r.type===1?this.W_=this.W_.insert(t,{type:2,doc:e.doc}):Se():this.W_=this.W_.insert(t,e)}G_(){let e=[];return this.W_.inorderTraversal((t,r)=>{e.push(r)}),e}},au=class n{constructor(e,t,r,i,s,o,a,c,l){this.query=e,this.docs=t,this.oldDocs=r,this.docChanges=i,this.mutatedKeys=s,this.fromCache=o,this.syncStateChanged=a,this.excludesMetadataChanges=c,this.hasCachedResults=l}static fromInitialDocuments(e,t,r,i,s){let o=[];return t.forEach(a=>{o.push({type:0,doc:a})}),new n(e,t,by.emptySet(t),o,r,i,!0,!1,s)}get hasPendingWrites(){return!this.mutatedKeys.isEmpty()}isEqual(e){if(!(this.fromCache===e.fromCache&&this.hasCachedResults===e.hasCachedResults&&this.syncStateChanged===e.syncStateChanged&&this.mutatedKeys.isEqual(e.mutatedKeys)&&Fy(this.query,e.query)&&this.docs.isEqual(e.docs)&&this.oldDocs.isEqual(e.oldDocs)))return!1;let t=this.docChanges,r=e.docChanges;if(t.length!==r.length)return!1;for(let i=0;i<t.length;i++)if(t[i].type!==r[i].type||!t[i].doc.isEqual(r[i].doc))return!1;return!0}};var iC=class{constructor(){this.z_=void 0,this.j_=[]}H_(){return this.j_.some(e=>e.J_())}},sC=class{constructor(){this.queries=KF(),this.onlineState="Unknown",this.Y_=new Set}terminate(){(function(t,r){let i=Pe(t),s=i.queries;i.queries=KF(),s.forEach((o,a)=>{for(let c of a.j_)c.onError(r)})})(this,new ne(q.ABORTED,"Firestore shutting down"))}};function KF(){return new ta(n=>y2(n),Fy)}function z2(n,e){return m(this,null,function*(){let t=Pe(n),r=3,i=e.query,s=t.queries.get(i);s?!s.H_()&&e.J_()&&(r=2):(s=new iC,r=e.J_()?0:1);try{switch(r){case 0:s.z_=yield t.onListen(i,!0);break;case 1:s.z_=yield t.onListen(i,!1);break;case 2:yield t.onFirstRemoteStoreListen(i)}}catch(o){let a=OC(o,`Initialization of query '${Gl(e.query)}' failed`);return void e.onError(a)}t.queries.set(i,s),s.j_.push(e),e.Z_(t.onlineState),s.z_&&e.X_(s.z_)&&LC(t)})}function G2(n,e){return m(this,null,function*(){let t=Pe(n),r=e.query,i=3,s=t.queries.get(r);if(s){let o=s.j_.indexOf(e);o>=0&&(s.j_.splice(o,1),s.j_.length===0?i=e.J_()?0:1:!s.H_()&&e.J_()&&(i=2))}switch(i){case 0:return t.queries.delete(r),t.onUnlisten(r,!0);case 1:return t.queries.delete(r),t.onUnlisten(r,!1);case 2:return t.onLastRemoteStoreUnlisten(r);default:return}})}function kZ(n,e){let t=Pe(n),r=!1;for(let i of e){let s=i.query,o=t.queries.get(s);if(o){for(let a of o.j_)a.X_(i)&&(r=!0);o.z_=i}}r&&LC(t)}function PZ(n,e,t){let r=Pe(n),i=r.queries.get(e);if(i)for(let s of i.j_)s.onError(t);r.queries.delete(e)}function LC(n){n.Y_.forEach(e=>{e.next()})}var oC,YF;(YF=oC||(oC={})).ea="default",YF.Cache="cache";var Ey=class{constructor(e,t,r){this.query=e,this.ta=t,this.na=!1,this.ra=null,this.onlineState="Unknown",this.options=r||{}}X_(e){if(!this.options.includeMetadataChanges){let r=[];for(let i of e.docChanges)i.type!==3&&r.push(i);e=new au(e.query,e.docs,e.oldDocs,r,e.mutatedKeys,e.fromCache,e.syncStateChanged,!0,e.hasCachedResults)}let t=!1;return this.na?this.ia(e)&&(this.ta.next(e),t=!0):this.sa(e,this.onlineState)&&(this.oa(e),t=!0),this.ra=e,t}onError(e){this.ta.error(e)}Z_(e){this.onlineState=e;let t=!1;return this.ra&&!this.na&&this.sa(this.ra,e)&&(this.oa(this.ra),t=!0),t}sa(e,t){if(!e.fromCache||!this.J_())return!0;let r=t!=="Offline";return(!this.options._a||!r)&&(!e.docs.isEmpty()||e.hasCachedResults||t==="Offline")}ia(e){if(e.docChanges.length>0)return!0;let t=this.ra&&this.ra.hasPendingWrites!==e.hasPendingWrites;return!(!e.syncStateChanged&&!t)&&this.options.includeMetadataChanges===!0}oa(e){e=au.fromInitialDocuments(e.query,e.docs,e.mutatedKeys,e.fromCache,e.hasCachedResults),this.na=!0,this.ta.next(e)}J_(){return this.options.source!==oC.Cache}};var Iy=class{constructor(e){this.key=e}},Ty=class{constructor(e){this.key=e}},aC=class{constructor(e,t){this.query=e,this.Ta=t,this.Ea=null,this.hasCachedResults=!1,this.current=!1,this.da=nt(),this.mutatedKeys=nt(),this.Aa=_2(e),this.Ra=new by(this.Aa)}get Va(){return this.Ta}ma(e,t){let r=t?t.fa:new wy,i=t?t.Ra:this.Ra,s=t?t.mutatedKeys:this.mutatedKeys,o=i,a=!1,c=this.query.limitType==="F"&&i.size===this.query.limit?i.last():null,l=this.query.limitType==="L"&&i.size===this.query.limit?i.first():null;if(e.inorderTraversal((u,d)=>{let f=i.get(u),p=Vy(this.query,d)?d:null,y=!!f&&this.mutatedKeys.has(f.key),v=!!p&&(p.hasLocalMutations||this.mutatedKeys.has(p.key)&&p.hasCommittedMutations),w=!1;f&&p?f.data.isEqual(p.data)?y!==v&&(r.track({type:3,doc:p}),w=!0):this.ga(f,p)||(r.track({type:2,doc:p}),w=!0,(c&&this.Aa(p,c)>0||l&&this.Aa(p,l)<0)&&(a=!0)):!f&&p?(r.track({type:0,doc:p}),w=!0):f&&!p&&(r.track({type:1,doc:f}),w=!0,(c||l)&&(a=!0)),w&&(p?(o=o.add(p),s=v?s.add(u):s.delete(u)):(o=o.delete(u),s=s.delete(u)))}),this.query.limit!==null)for(;o.size>this.query.limit;){let u=this.query.limitType==="F"?o.last():o.first();o=o.delete(u.key),s=s.delete(u.key),r.track({type:1,doc:u})}return{Ra:o,fa:r,ns:a,mutatedKeys:s}}ga(e,t){return e.hasLocalMutations&&t.hasCommittedMutations&&!t.hasLocalMutations}applyChanges(e,t,r,i){let s=this.Ra;this.Ra=e.Ra,this.mutatedKeys=e.mutatedKeys;let o=e.fa.G_();o.sort((u,d)=>function(p,y){let v=w=>{switch(w){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return Se()}};return v(p)-v(y)}(u.type,d.type)||this.Aa(u.doc,d.doc)),this.pa(r),i=i!=null&&i;let a=t&&!i?this.ya():[],c=this.da.size===0&&this.current&&!i?1:0,l=c!==this.Ea;return this.Ea=c,o.length!==0||l?{snapshot:new au(this.query,e.Ra,s,o,e.mutatedKeys,c===0,l,!1,!!r&&r.resumeToken.approximateByteSize()>0),wa:a}:{wa:a}}Z_(e){return this.current&&e==="Offline"?(this.current=!1,this.applyChanges({Ra:this.Ra,fa:new wy,mutatedKeys:this.mutatedKeys,ns:!1},!1)):{wa:[]}}Sa(e){return!this.Ta.has(e)&&!!this.Ra.has(e)&&!this.Ra.get(e).hasLocalMutations}pa(e){e&&(e.addedDocuments.forEach(t=>this.Ta=this.Ta.add(t)),e.modifiedDocuments.forEach(t=>{}),e.removedDocuments.forEach(t=>this.Ta=this.Ta.delete(t)),this.current=e.current)}ya(){if(!this.current)return[];let e=this.da;this.da=nt(),this.Ra.forEach(r=>{this.Sa(r.key)&&(this.da=this.da.add(r.key))});let t=[];return e.forEach(r=>{this.da.has(r)||t.push(new Ty(r))}),this.da.forEach(r=>{e.has(r)||t.push(new Iy(r))}),t}ba(e){this.Ta=e.Ts,this.da=nt();let t=this.ma(e.documents);return this.applyChanges(t,!0)}Da(){return au.fromInitialDocuments(this.query,this.Ra,this.mutatedKeys,this.Ea===0,this.hasCachedResults)}},cC=class{constructor(e,t,r){this.query=e,this.targetId=t,this.view=r}},lC=class{constructor(e){this.key=e,this.va=!1}},uC=class{constructor(e,t,r,i,s,o){this.localStore=e,this.remoteStore=t,this.eventManager=r,this.sharedClientState=i,this.currentUser=s,this.maxConcurrentLimboResolutions=o,this.Ca={},this.Fa=new ta(a=>y2(a),Fy),this.Ma=new Map,this.xa=new Set,this.Oa=new Bt(Ee.comparator),this.Na=new Map,this.La=new Dh,this.Ba={},this.ka=new Map,this.qa=xh.kn(),this.onlineState="Unknown",this.Qa=void 0}get isPrimaryClient(){return this.Qa===!0}};function MZ(n,e,t=!0){return m(this,null,function*(){let r=Z2(n),i,s=r.Fa.get(e);return s?(r.sharedClientState.addLocalQueryTarget(s.targetId),i=s.view.Da()):i=yield W2(r,e,t,!0),i})}function NZ(n,e){return m(this,null,function*(){let t=Z2(n);yield W2(t,e,!0,!1)})}function W2(n,e,t,r){return m(this,null,function*(){let i=yield yZ(n.localStore,us(e)),s=i.targetId,o=n.sharedClientState.addLocalQueryTarget(s,t),a;return r&&(a=yield OZ(n,e,s,o==="current",i.resumeToken)),n.isPrimaryClient&&t&&j2(n.remoteStore,i),a})}function OZ(n,e,t,r,i){return m(this,null,function*(){n.Ka=(d,f,p)=>function(v,w,E,A){return m(this,null,function*(){let x=w.view.ma(E);x.ns&&(x=yield GF(v.localStore,w.query,!1).then(({documents:C})=>w.view.ma(C,x)));let M=A&&A.targetChanges.get(w.targetId),O=A&&A.targetMismatches.get(w.targetId)!=null,$=w.view.applyChanges(x,v.isPrimaryClient,M,O);return QF(v,w.targetId,$.wa),$.snapshot})}(n,d,f,p);let s=yield GF(n.localStore,e,!0),o=new aC(e,s.Ts),a=o.ma(s.documents),c=Ch.createSynthesizedTargetChangeForCurrentChange(t,r&&n.onlineState!=="Offline",i),l=o.applyChanges(a,n.isPrimaryClient,c);QF(n,t,l.wa);let u=new cC(e,t,o);return n.Fa.set(e,u),n.Ma.has(t)?n.Ma.get(t).push(e):n.Ma.set(t,[e]),l.snapshot})}function LZ(n,e,t){return m(this,null,function*(){let r=Pe(n),i=r.Fa.get(e),s=r.Ma.get(i.targetId);if(s.length>1)return r.Ma.set(i.targetId,s.filter(o=>!Fy(o,e))),void r.Fa.delete(e);r.isPrimaryClient?(r.sharedClientState.removeLocalQueryTarget(i.targetId),r.sharedClientState.isActiveQueryTarget(i.targetId)||(yield WA(r.localStore,i.targetId,!1).then(()=>{r.sharedClientState.clearQueryState(i.targetId),t&&kC(r.remoteStore,i.targetId),dC(r,i.targetId)}).catch(Lh))):(dC(r,i.targetId),yield WA(r.localStore,i.targetId,!0))})}function FZ(n,e){return m(this,null,function*(){let t=Pe(n),r=t.Fa.get(e),i=t.Ma.get(r.targetId);t.isPrimaryClient&&i.length===1&&(t.sharedClientState.removeLocalQueryTarget(r.targetId),kC(t.remoteStore,r.targetId))})}function VZ(n,e,t){return m(this,null,function*(){let r=zZ(n);try{let i=yield function(o,a){let c=Pe(o),l=Tn.now(),u=a.reduce((p,y)=>p.add(y.key),nt()),d,f;return c.persistence.runTransaction("Locally write mutations","readwrite",p=>{let y=no(),v=nt();return c.cs.getEntries(p,u).next(w=>{y=w,y.forEach((E,A)=>{A.isValidDocument()||(v=v.add(E))})}).next(()=>c.localDocuments.getOverlayedDocuments(p,y)).next(w=>{d=w;let E=[];for(let A of a){let x=zQ(A,d.get(A.key).overlayedDocument);x!=null&&E.push(new fs(A.key,x,u2(x.value.mapValue),Qo.exists(!0)))}return c.mutationQueue.addMutationBatch(p,l,E,a)}).next(w=>{f=w;let E=w.applyToLocalDocumentSet(d,v);return c.documentOverlayCache.saveOverlays(p,w.batchId,E)})}).then(()=>({batchId:f.batchId,changes:b2(d)}))}(r.localStore,e);r.sharedClientState.addPendingMutation(i.batchId),function(o,a,c){let l=o.Ba[o.currentUser.toKey()];l||(l=new Bt(ut)),l=l.insert(a,c),o.Ba[o.currentUser.toKey()]=l}(r,i.batchId,t),yield jh(r,i.changes),yield Uy(r.remoteStore)}catch(i){let s=OC(i,"Failed to persist write");t.reject(s)}})}function K2(n,e){return m(this,null,function*(){let t=Pe(n);try{let r=yield pZ(t.localStore,e);
24e.targetChanges.forEach((i,s)=>{let o=t.Na.get(s);o&&(bt(i.addedDocuments.size+i.modifiedDocuments.size+i.removedDocuments.size<=1),i.addedDocuments.size>0?o.va=!0:i.modifiedDocuments.size>0?bt(o.va):i.removedDocuments.size>0&&(bt(o.va),o.va=!1))}),yield jh(t,r,e)}catch(r){yield Lh(r)}})}function XF(n,e,t){let r=Pe(n);if(r.isPrimaryClient&&t===0||!r.isPrimaryClient&&t===1){let i=[];r.Fa.forEach((s,o)=>{let a=o.view.Z_(e);a.snapshot&&i.push(a.snapshot)}),function(o,a){let c=Pe(o);c.onlineState=a;let l=!1;c.queries.forEach((u,d)=>{for(let f of d.j_)f.Z_(a)&&(l=!0)}),l&&LC(c)}(r.eventManager,e),i.length&&r.Ca.d_(i),r.onlineState=e,r.isPrimaryClient&&r.sharedClientState.setOnlineState(e)}}function jZ(n,e,t){return m(this,null,function*(){let r=Pe(n);r.sharedClientState.updateQueryState(e,"rejected",t);let i=r.Na.get(e),s=i&&i.key;if(s){let o=new Bt(Ee.comparator);o=o.insert(s,Ri.newNoDocument(s,Le.min()));let a=nt().add(s),c=new ly(Le.min(),new Map,new Bt(ut),o,a);yield K2(r,c),r.Oa=r.Oa.remove(s),r.Na.delete(e),FC(r)}else yield WA(r.localStore,e,!1).then(()=>dC(r,e,t)).catch(Lh)})}function $Z(n,e){return m(this,null,function*(){let t=Pe(n),r=e.batch.batchId;try{let i=yield fZ(t.localStore,e);X2(t,r,null),Y2(t,r),t.sharedClientState.updateMutationState(r,"acknowledged"),yield jh(t,i)}catch(i){yield Lh(i)}})}function UZ(n,e,t){return m(this,null,function*(){let r=Pe(n);try{let i=yield function(o,a){let c=Pe(o);return c.persistence.runTransaction("Reject batch","readwrite-primary",l=>{let u;return c.mutationQueue.lookupMutationBatch(l,a).next(d=>
24(bt(d!==null),u=d.keys(),c.mutationQueue.removeMutationBatch(l,d))).next(()=>c.mutationQueue.performConsistencyCheck(l)).next(()=>c.documentOverlayCache.removeOverlaysForBatchId(l,u,a)).next(()=>c.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(l,u)).next(()=>c.localDocuments.getDocuments(l,u))})}(r.localStore,e);X2(r,e,t),Y2(r,e),r.sharedClientState.updateMutationState(e,"rejected",t),yield jh(r,i)}catch(i){yield Lh(i)}})}function Y2(n,e){(n.ka.get(e)||[]).forEach(t=>{t.resolve()}),n.ka.delete(e)}function X2(n,e,t){let r=Pe(n),i=r.Ba[r.currentUser.toKey()];if(i){let s=i.get(e);s&&(t?s.reject(t):s.resolve(),i=i.remove(e)),r.Ba[r.currentUser.toKey()]=i}}function dC(n,e,t=null){n.sharedClientState.removeLocalQueryTarget(e);for(let r of n.Ma.get(e))n.Fa.delete(r),t&&n.Ca.$a(r,t);n.Ma.delete(e),n.isPrimaryClient&&n.La.gr(e).forEach(r=>{n.La.containsKey(r)||Q2(n,r)})}function Q2(n,e){n.xa.delete(e.path.canonicalString());let t=n.Oa.get(e);t!==null&&(kC(n.remoteStore,t),n.Oa=n.Oa.remove(e),n.Na.delete(t),FC(n))}function QF(n,e,t){for(let r of t)r instanceof Iy?(n.La.addReference(r.key,e),BZ(n,r)):r instanceof Ty?(de("SyncEngine","Document no longer in limbo: "+r.key),n.La.removeReference(r.key,e),n.La.containsKey(r.key)||Q2(n,r.key)):Se()}function BZ(n,e){let t=e.key,r=t.path.canonicalString();n.Oa.get(t)||n.xa.has(r)||(de("SyncEngine","New document in limbo: "+t),n.xa.add(r),FC(n))}function FC(n){for(;n.xa.size>0&&n.Oa.size<n.maxConcurrentLimboResolutions;){let e=n.xa.values().next().value;n.xa.delete(e);let t=new Ee(Ft.fromString(e)),r=n.qa.next();n.Na.set(r,new lC(t)),n.Oa=n.Oa.insert(t,r),j2(n.remoteStore,new Sh(us(xC(t.path)),r,"TargetPurposeLimboResolution",o2.oe))}}function jh(n,e,t){return m(this,null,function*(){let r=Pe(n),i=[],s=[],o=[];r.Fa.isEmpty()||(r.Fa.forEach((a,c)=>{o.push(r.Ka(c,e,t).then(l=>{var u;if((l||t)&&r.isPrimaryClient){let d=l?!l.fromCache:(u=t?.targetChanges.get(c.targetId))===null||u===void 0?void 0:u.current;
24r.sharedClientState.updateQueryState(c.targetId,d?"current":"not-current")}if(l){i.push(l);let d=HA.Wi(c.targetId,l);s.push(d)}}))}),yield Promise.all(o),r.Ca.d_(i),yield function(c,l){return m(this,null,function*(){let u=Pe(c);try{yield u.persistence.runTransaction("notifyLocalViewChanges","readwrite",d=>X.forEach(l,f=>X.forEach(f.$i,p=>u.persistence.referenceDelegate.addReference(d,f.targetId,p)).next(()=>X.forEach(f.Ui,p=>u.persistence.referenceDelegate.removeReference(d,f.targetId,p)))))}catch(d){if(!Fh(d))throw d;de("LocalStore","Failed to update sequence numbers: "+d)}for(let d of l){let f=d.targetId;if(!d.fromCache){let p=u.os.get(f),y=p.snapshotVersion,v=p.withLastLimboFreeSnapshotVersion(y);u.os=u.os.insert(f,v)}}})}(r.localStore,s))})}function HZ(n,e){return m(this,null,function*(){let t=Pe(n);if(!t.currentUser.isEqual(e)){de("SyncEngine","User change. New user:",e.toKey());let r=yield F2(t.localStore,e);t.currentUser=e,function(s,o){s.ka.forEach(a=>{a.forEach(c=>{c.reject(new ne(q.CANCELLED,o))})}),s.ka.clear()}(t,"'waitForPendingWrites' promise is rejected due to a user change."),t.sharedClientState.handleUserChange(e,r.removedBatchIds,r.addedBatchIds),yield jh(t,r.hs)}})}function qZ(n,e){let t=Pe(n),r=t.Na.get(e);if(r&&r.va)return nt().add(r.key);{let i=nt(),s=t.Ma.get(e);if(!s)return i;for(let o of s){let a=t.Fa.get(o);i=i.unionWith(a.view.Va)}return i}}function Z2(n){let e=Pe(n);return e.remoteStore.remoteSyncer.applyRemoteEvent=K2.bind(null,e),e.remoteStore.remoteSyncer.getRemoteKeysForTarget=qZ.bind(null,e),e.remoteStore.remoteSyncer.rejectListen=jZ.bind(null,e),e.Ca.d_=kZ.bind(null,e.eventManager),e.Ca.$a=PZ.bind(null,e.eventManager),e}function zZ(n){let e=Pe(n);return e.remoteStore.remoteSyncer.applySuccessfulWrite=$Z.bind(null,e),e.remoteStore.remoteSyncer.rejectFailedWrite=UZ.bind(null,e),e}var ZF=(()=>{class n{constructor(){this.kind="memory",this.synchronizeTabs=!1}initialize(t){return m(this,null,function*(){this.serializer=jy(t.databaseInfo.databaseId),this.sharedClientState=this.Wa(t),this.persistence=this.Ga(t),yield this.persistence.start(),this.localStore=this.za(t),this.gcScheduler=this.ja(t,this.localStore),this.indexBackfillerScheduler=this.Ha(t,this.localStore)})}ja(t,r){return null}Ha(t,r){return null}za(t){return hZ(this.persistence,new zA,t.initialUser,this.serializer)}Ga(t){return new $A(BA.Zr,this.serializer)}Wa(t){return new KA}terminate(){return m(this,null,function*(){var t,r;(t=this.gcScheduler)===null||t===void 0||t.stop(),(r=this.indexBackfillerScheduler)===null||r===void 0||r.stop(),this.sharedClientState.shutdown(),yield this.persistence.shutdown()})}}return n.provider={build:()=>new n},n})();var GZ=(()=>{class n{initialize(t,r){return m(this,null,function*(){this.localStore||(this.localStore=t.localStore,this.sharedClientState=t.sharedClientState,this.datastore=this.createDatastore(r),this.remoteStore=this.createRemoteStore(r),this.eventManager=this.createEventManager(r),this.syncEngine=this.createSyncEngine(r,!t.synchronizeTabs),this.sharedClientState.onlineStateHandler=i=>XF(this.syncEngine,i,1),this.remoteStore.remoteSyncer.handleCredentialChange=HZ.bind(null,this.syncEngine),yield RZ(this.remoteStore,this.syncEngine.isPrimaryClient))})}createEventManager(t){return function(){return new sC}()}createDatastore(t){let r=jy(t.databaseInfo.databaseId),i=function(o){return new QA(o)}(t.databaseInfo);return function(o,a,c,l){return new eC(o,a,c,l)}(t.authCredentials,t.appCheckCredentials,i,r)}createRemoteStore(t){return function(i,s,o,a,c){return new nC(i,s,o,a,c)}(this.localStore,this.datastore,t.asyncQueue,r=>XF(this.syncEngine,r,0),function(){return gy.D()?new gy:new YA}())}createSyncEngine(t,r){return function(s,o,a,c,l,u,d){let f=new uC(s,o,a,c,l,u);return d&&(f.Qa=!0),f}(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,t.initialUser,t.maxConcurrentLimboResolutions,r)}terminate(){return m(this,null,function*(){var t,r;yield function(s){return m(this,null,function*(){let o=Pe(s);de("RemoteStore","RemoteStore shutting down."),o.L_.add(5),yield Vh(o),o.k_.shutdown(),o.q_.set("Unknown")})}(this.remoteStore),(t=this.datastore)===null||t===void 0||t.terminate(),(r=this.eventManager)===null||r===void 0||r.terminate()})}}return n.provider={build:()=>new n},n})();var Ay=class{constructor(e){this.observer=e,this.muted=!1}next(e){this.muted||this.observer.next&&this.Ya(this.observer.next,e)}error(e){this.muted||(this.observer.error?this.Ya(this.observer.error,e):eo("Uncaught Error in snapshot listener:",e.toString()))}Za(){this.muted=!0}
24Ya(e,t){setTimeout(()=>{this.muted||e(t)},0)}};var hC=class{constructor(e,t,r,i,s){this.authCredentials=e,this.appCheckCredentials=t,this.asyncQueue=r,this.databaseInfo=i,this.user=mn.UNAUTHENTICATED,this.clientId=ny.newId(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this._uninitializedComponentsProvider=s,this.authCredentials.start(r,o=>m(this,null,function*(){de("FirestoreClient","Received user=",o.uid),yield this.authCredentialListener(o),this.user=o})),this.appCheckCredentials.start(r,o=>(de("FirestoreClient","Received new app check token=",o),this.appCheckCredentialListener(o,this.user)))}get configuration(){return{asyncQueue:this.asyncQueue,databaseInfo:this.databaseInfo,clientId:this.clientId,authCredentials:this.authCredentials,appCheckCredentials:this.appCheckCredentials,initialUser:this.user,maxConcurrentLimboResolutions:100}}setCredentialChangeListener(e){this.authCredentialListener=e}setAppCheckTokenChangeListener(e){this.appCheckCredentialListener=e}terminate(){this.asyncQueue.enterRestrictedMode();let e=new cs;return this.asyncQueue.enqueueAndForgetEvenWhileRestricted(()=>m(this,null,function*(){try{this._onlineComponents&&(yield this._onlineComponents.terminate()),this._offlineComponents&&(yield this._offlineComponents.terminate()),this.authCredentials.shutdown(),this.appCheckCredentials.shutdown(),e.resolve()}catch(t){let r=OC(t,"Failed to shutdown persistence");e.reject(r)}})),e.promise}};function HT(n,e){return m(this,null,function*(){n.asyncQueue.verifyOperationInProgress(),de("FirestoreClient","Initializing OfflineComponentProvider");let t=n.configuration;yield e.initialize(t);let r=t.initialUser;n.setCredentialChangeListener(i=>m(this,null,function*(){r.isEqual(i)||(yield F2(e.localStore,i),r=i)})),e.persistence.setDatabaseDeletedListener(()=>n.terminate()),n._offlineComponents=e})}function JF(n,e){return m(this,null,function*(){n.asyncQueue.verifyOperationInProgress();let t=yield WZ(n);de("FirestoreClient","Initializing OnlineComponentProvider"),yield e.initialize(t,n.configuration),n.setCredentialChangeListener(r=>WF(e.remoteStore,r)),n.setAppCheckTokenChangeListener((r,i)=>WF(e.remoteStore,i)),n._onlineComponents=e})}function WZ(n){return m(this,null,function*(){if(!n._offlineComponents)if(n._uninitializedComponentsProvider){de("FirestoreClient","Using user provided OfflineComponentProvider");try{yield HT(n,n._uninitializedComponentsProvider._offline)}catch(e){let t=e;if(!function(i){return i.name==="FirebaseError"?i.code===q.FAILED_PRECONDITION||i.code===q.UNIMPLEMENTED:!(typeof DOMException<"u"&&i instanceof DOMException)||i.code===22||i.code===20||i.code===11}(t))throw t;Zl("Error using user provided cache. Falling back to memory cache: "+t),yield HT(n,new ZF)}}else de("FirestoreClient","Using default OfflineComponentProvider"),yield HT(n,new ZF);return n._offlineComponents})}function J2(n){return m(this,null,function*(){return n._onlineComponents||(n._uninitializedComponentsProvider?(de("FirestoreClient","Using user provided OnlineComponentProvider"),yield JF(n,n._uninitializedComponentsProvider._online)):(de("FirestoreClient","Using default OnlineComponentProvider"),yield JF(n,new GZ))),n._onlineComponents})}function KZ(n){return J2(n).then(e=>e.syncEngine)}function fC(n){return m(this,null,function*(){let e=yield J2(n),t=e.eventManager;return t.onListen=MZ.bind(null,e.syncEngine),t.onUnlisten=LZ.bind(null,e.syncEngine),t.onFirstRemoteStoreListen=NZ.bind(null,e.syncEngine),t.onLastRemoteStoreUnlisten=FZ.bind(null,e.syncEngine),t})}function YZ(n,e,t={}){let r=new cs;return n.asyncQueue.enqueueAndForget(()=>m(this,null,function*(){return function(s,o,a,c,l){let u=new Ay({next:f=>{u.Za(),o.enqueueAndForget(()=>G2(s,d)),f.fromCache&&c.source==="server"?l.reject(new ne(q.UNAVAILABLE,'Failed to get documents from server. (However, these documents may exist in the local cache. Run again without setting source to "server" to retrieve the cached documents.)')):l.resolve(f)},error:f=>l.reject(f)}),d=new Ey(a,u,{includeMetadataChanges:!0,_a:!0});return z2(s,d)}(yield fC(n),n.asyncQueue,e,t,r)})),r.promise}function eV(n){let e={};return n.timeoutSeconds!==void 0&&(e.timeoutSeconds=n.timeoutSeconds),e}var e2=new Map;function tV(n,e,t){if(!t)throw new ne(q.INVALID_ARGUMENT,`Function ${n}() cannot be called with an empty ${e}.`)}function XZ(n,e,t,r){if(e===!0&&r===!0)throw new ne(q.INVALID_ARGUMENT,`${n} and ${t} cannot be used together.`)}function t2(n){if(!Ee.isDocumentKey(n))throw new ne(q.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${n} has ${n.length}.`)}function n2(n){if(Ee.isDocumentKey(n))throw new ne(q.INVALID_ARGUMENT,`Invalid collection reference. Collection references must have an odd number of segments, but ${n} has ${n.length}.`)}function By(n){if(n===void 0)return"undefined";if(n===null)return"null";if(typeof n=="string")return n.length>20&&(n=`${n.substring(0,20)}...`),JSON.stringify(n);if(typeof n=="number"||typeof n=="boolean")return""+n;if(typeof n=="object"){if(n instanceof Array)return"an array";{let e=function(r){return r.constructor?r.constructor.name:null}(n);return e?`a custom ${e} object`:"an object"}}return typeof n=="function"?"a function":Se()}function Js(n,e){if("_delegate"in n&&(n=n._delegate),!(n instanceof e)){if(e.name===n.constructor.name)throw new ne(q.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");{let t=By(n);throw new ne(q.INVALID_ARGUMENT,`Expected type '${e.name}', but it was: ${t}`)}}return n}var Cy=class{constructor(e){var t,r;if(e.host===void 0){if(e.ssl!==void 0)throw new ne(q.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host="firestore.googleapis.com",this.ssl=!0}else this.host=e.host,this.ssl=(t=e.ssl)===null||t===void 0||t;if(this.credentials=e.credentials,this.ignoreUndefinedProperties=!!e.ignoreUndefinedProperties,this.localCache=e.localCache,e.cacheSizeBytes===void 0)this.cacheSizeBytes=41943040;
24else{if(e.cacheSizeBytes!==-1&&e.cacheSizeBytes<1048576)throw new ne(q.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=e.cacheSizeBytes}XZ("experimentalForceLongPolling",e.experimentalForceLongPolling,"experimentalAutoDetectLongPolling",e.experimentalAutoDetectLongPolling),this.experimentalForceLongPolling=!!e.experimentalForceLongPolling,this.experimentalForceLongPolling?this.experimentalAutoDetectLongPolling=!1:e.experimentalAutoDetectLongPolling===void 0?this.experimentalAutoDetectLongPolling=!0:this.experimentalAutoDetectLongPolling=!!e.experimentalAutoDetectLongPolling,this.experimentalLongPollingOptions=eV((r=e.experimentalLongPollingOptions)!==null&&r!==void 0?r:{}),function(s){if(s.timeoutSeconds!==void 0){if(isNaN(s.timeoutSeconds))throw new ne(q.INVALID_ARGUMENT,`invalid long polling timeout: ${s.timeoutSeconds} (must not be NaN)`);if(s.timeoutSeconds<5)throw new ne(q.INVALID_ARGUMENT,`invalid long polling timeout: ${s.timeoutSeconds} (minimum allowed value is 5)`);if(s.timeoutSeconds>30)throw new ne(q.INVALID_ARGUMENT,`invalid long polling timeout: ${s.timeoutSeconds} (maximum allowed value is 30)`)}}(this.experimentalLongPollingOptions),this.useFetchStreams=!!e.useFetchStreams}isEqual(e){return this.host===e.host&&this.ssl===e.ssl&&this.credentials===e.credentials&&this.cacheSizeBytes===e.cacheSizeBytes&&this.experimentalForceLongPolling===e.experimentalForceLongPolling&&this.experimentalAutoDetectLongPolling===e.experimentalAutoDetectLongPolling&&function(r,i){return r.timeoutSeconds===i.timeoutSeconds}(this.experimentalLongPollingOptions,e.experimentalLongPollingOptions)&&this.ignoreUndefinedProperties===e.ignoreUndefinedProperties&&this.useFetchStreams===e.useFetchStreams}}
24,cu=class{constructor(e,t,r,i){this._authCredentials=e,this._appCheckCredentials=t,this._databaseId=r,this._app=i,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new Cy({}),this._settingsFrozen=!1,this._terminateTask="notTerminated"}get app(){if(!this._app)throw new ne(q.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this._app}get _initialized(){return this._settingsFrozen}get _terminated(){return this._terminateTask!=="notTerminated"}_setSettings(e){if(this._settingsFrozen)throw new ne(q.FAILED_PRECONDITION,"Firestore has already been started and its settings can no longer be changed. You can only modify settings before calling any other methods on a Firestore object.");this._settings=new Cy(e),e.credentials!==void 0&&(this._authCredentials=function(r){if(!r)return new qT;switch(r.type){case"firstParty":return new KT(r.sessionIndex||"0",r.iamToken||null,r.authTokenFactory||null);case"provider":return r.client;default:throw new ne(q.INVALID_ARGUMENT,"makeAuthCredentialsProvider failed due to invalid credential type")}}(e.credentials))}_getSettings(){return this._settings}_freezeSettings(){return this._settingsFrozen=!0,this._settings}_delete(){return this._terminateTask==="notTerminated"&&(this._terminateTask=this._terminate()),this._terminateTask}_restart(){return m(this,null,function*(){this._terminateTask==="notTerminated"?yield this._terminate():this._terminateTask="notTerminated"})}toJSON(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}}_terminate(){return function(t){let r=e2.get(t);r&&(de("ComponentProvider","Removing Datastore"),e2.delete(t),r.terminate())}(this),Promise.resolve()}};function VC(n,e,t,r={}){var i;let s=(n=Js(n,cu))._getSettings(),o=`${e}:${t}`;if(s.host!=="firestore.googleapis.com"&&s.host!==o&&Zl("Host has been set in both settings() and connectFirestoreEmulator(), emulator host will be used."),n._setSettings(Object.assign(Object.assign({},s),{host:o,ssl:!1})),r.mockUserToken){let a,c;if(typeof r.mockUserToken=="string")a=r.mockUserToken,c=mn.MOCK_USER;else{a=Ig(r.mockUserToken,(i=n._app)===null||i===void 0?void 0:i.options.projectId);let l=r.mockUserToken.sub||r.mockUserToken.user_id;if(!l)throw new ne(q.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");c=new mn(l)}n._authCredentials=new zT(new ty(a,c))}}var ra=class n{constructor(e,t,r){this.converter=t,this._query=r,this.type="query",this.firestore=e}withConverter(e){return new n(this.firestore,e,this._query)}},yr=class n{constructor(e,t,r){this.converter=t,this._key=r,this.type="document",this.firestore=e}get _path(){return this._key.path}get id(){return this._key.path.lastSegment()}get path(){return this._key.path.canonicalString()}get parent(){return new Zo(this.firestore,this.converter,this._key.path.popLast())}withConverter(e){return new n(this.firestore,e,this._key)}},Zo=class n extends ra{constructor(e,t,r){super(e,t,xC(r)),this._path=r,this.type="collection"}get id(){return this._query.path.lastSegment()}get path(){return this._query.path.canonicalString()}get parent(){let e=this._path.popLast();return e.isEmpty()?null:new yr(this.firestore,null,new Ee(e))}withConverter(e){return new n(this.firestore,e,this._path)}};function nV(n,e,...t){if(n=_t(n),tV("collection","path",e),n instanceof cu){let r=Ft.fromString(e,...t);return n2(r),new Zo(n,null,r)}{if(!(n instanceof yr||n instanceof Zo))throw new ne(q.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");let r=n._path.child(Ft.fromString(e,...t));return n2(r),new Zo(n.firestore,null,r)}}function jC(n,e,...t){if(n=_t(n),arguments.length===1&&(e=ny.newId()),tV("doc","path",e),n instanceof cu){let r=Ft.fromString(e,...t);return t2(r),new yr(n,null,new Ee(r))}{if(!(n instanceof yr||n instanceof Zo))throw new ne(q.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");let r=n._path.child(Ft.fromString(e,...t));
24return t2(r),new yr(n.firestore,n instanceof Zo?n.converter:null,new Ee(r))}}var Sy=class{constructor(e=Promise.resolve()){this.Pu=[],this.Iu=!1,this.Tu=[],this.Eu=null,this.du=!1,this.Au=!1,this.Ru=[],this.t_=new yy(this,"async_queue_retry"),this.Vu=()=>{let r=BT();r&&de("AsyncQueue","Visibility state changed to "+r.visibilityState),this.t_.jo()},this.mu=e;let t=BT();t&&typeof t.addEventListener=="function"&&t.addEventListener("visibilitychange",this.Vu)}get isShuttingDown(){return this.Iu}enqueueAndForget(e){this.enqueue(e)}enqueueAndForgetEvenWhileRestricted(e){this.fu(),this.gu(e)}enterRestrictedMode(e){if(!this.Iu){this.Iu=!0,this.Au=e||!1;let t=BT();t&&typeof t.removeEventListener=="function"&&t.removeEventListener("visibilitychange",this.Vu)}}enqueue(e){if(this.fu(),this.Iu)return new Promise(()=>{});let t=new cs;return this.gu(()=>this.Iu&&this.Au?Promise.resolve():(e().then(t.resolve,t.reject),t.promise)).then(()=>t.promise)}enqueueRetryable(e){this.enqueueAndForget(()=>(this.Pu.push(e),this.pu()))}pu(){return m(this,null,function*(){if(this.Pu.length!==0){try{yield this.Pu[0](),this.Pu.shift(),this.t_.reset()}catch(e){if(!Fh(e))throw e;de("AsyncQueue","Operation failed with retryable error: "+e)}this.Pu.length>0&&this.t_.Go(()=>this.pu())}})}gu(e){let t=this.mu.then(()=>(this.du=!0,e().catch(r=>{this.Eu=r,this.du=!1;let i=function(o){let a=o.message||"";return o.stack&&(a=o.stack.includes(o.message)?o.stack:o.message+` 25`+o.stack),a}(r);throw eo("INTERNAL UNHANDLED ERROR: ",i),r}).then(r=>(this.du=!1,r))));return this.mu=t,t}enqueueAfterDelay(e,t,r){this.fu(),this.Ru.indexOf(e)>-1&&(t=0);let i=rC.createAndSchedule(this,e,t,r,s=>this.yu(s));return this.Tu.push(i),i}fu(){this.Eu&&Se()}verifyOperationInProgress(){}wu(){return m(this,null,function*(){let e;do e=this.mu,yield e;while(e!==this.mu)})}Su(e){for(let t of this.Tu)if(t.timerId===e)return!0;return!1}bu(e){return this.wu().then(()=>{this.Tu.sort((t,r)=>t.targetTimeMs-r.targetTimeMs);for(let t of this.Tu)if(t.skipDelay(),e!=="all"&&t.timerId===e)break;return this.wu()})}Du(e){this.Ru.push(e)}yu(e){let t=this.Tu.indexOf(e);this.Tu.splice(t,1)}};function r2(n){return function(t,r){if(typeof t!="object"||t===null)return!1;let i=t;for(let s of r)if(s in i&&typeof i[s]=="function")return!0;return!1}(n,["next","error","complete"])}
25var ia=class extends cu{constructor(e,t,r,i){super(e,t,r,i),this.type="firestore",this._queue=new Sy,this._persistenceKey=i?.name||"[DEFAULT]"}_terminate(){return m(this,null,function*(){if(this._firestoreClient){let e=this._firestoreClient.terminate();this._queue=new Sy(e),this._firestoreClient=void 0,yield e}})}};function rV(n,e){let t=typeof n=="object"?n:ns(),r=typeof n=="string"?n:e||"(default)",i=Gs(t,"firestore").getImmediate({identifier:r});if(!i._initialized){let s=jl("firestore");s&&VC(i,...s)}return i}function $C(n){if(n._terminated)throw new ne(q.FAILED_PRECONDITION,"The client has already been terminated.");return n._firestoreClient||QZ(n),n._firestoreClient}function QZ(n){var e,t,r;let i=n._freezeSettings(),s=function(a,c,l,u){return new JT(a,c,l,u.host,u.ssl,u.experimentalForceLongPolling,u.experimentalAutoDetectLongPolling,eV(u.experimentalLongPollingOptions),u.useFetchStreams)}(n._databaseId,((e=n._app)===null||e===void 0?void 0:e.options.appId)||"",n._persistenceKey,i);n._componentsProvider||!((t=i.localCache)===null||t===void 0)&&t._offlineComponentProvider&&(!((r=i.localCache)===null||r===void 0)&&r._onlineComponentProvider)&&(n._componentsProvider={_offline:i.localCache._offlineComponentProvider,_online:i.localCache._onlineComponentProvider}),n._firestoreClient=new hC(n._authCredentials,n._appCheckCredentials,n._queue,s,n._componentsProvider&&function(a){let c=a?._online.build();return{_offline:a?._offline.build(c),_online:c}}(n._componentsProvider))}var Rh=class n{constructor(e){this._byteString=e}static fromBase64String(e){try{return new n(jn.fromBase64String(e))}catch(t){throw new ne(q.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+t)}}static fromUint8Array(e){return new n(jn.fromUint8Array(e))}toBase64(){return this._byteString.toBase64()}toUint8Array(){return this._byteString.toUint8Array()}toString(){return"Bytes(base64: "+this.toBase64()+")"}isEqual(e){return this._byteString.isEqual(e._byteString)}};var lu=class{constructor(...e){for(let t=0;t<e.length;++t)if(e[t].length===0)throw new ne(q.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new Fr(e)}isEqual(e){return this._internalPath.isEqual(e._internalPath)}};var kh=class{constructor(e){this._methodName=e}};var Ph=class{constructor(e,t){if(!isFinite(e)||e<-90||e>90)throw new ne(q.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+e);if(!isFinite(t)||t<-180||t>180)throw new ne(q.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+t);this._lat=e,this._long=t}get latitude(){return this._lat}get longitude(){return this._long}isEqual(e){return this._lat===e._lat&&this._long===e._long}toJSON(){return{latitude:this._lat,longitude:this._long}}_compareTo(e){return ut(this._lat,e._lat)||ut(this._long,e._long)}};var Mh=class{constructor(e){this._values=(e||[]).map(t=>t)}toArray(){return this._values.map(e=>e)}isEqual(e){return function(r,i){if(r.length!==i.length)return!1;for(let s=0;s<r.length;++s)if(r[s]!==i[s])return!1;return!0}(this._values,e._values)}};var ZZ=/^__.*__$/,pC=class{constructor(e,t,r){this.data=e,this.fieldMask=t,this.fieldTransforms=r}toMutation(e,t){return this.fieldMask!==null?new fs(e,this.data,this.fieldMask,t,this.fieldTransforms):new hc(e,this.data,t,this.fieldTransforms)}},xy=class{constructor(e,t,r){this.data=e,this.fieldMask=t,this.fieldTransforms=r}toMutation(e,t){return new fs(e,this.data,this.fieldMask,t,this.fieldTransforms)}};function iV(n){switch(n){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw Se()}}var mC=class n{constructor(e,t,r,i,s,o){this.settings=e,this.databaseId=t,this.serializer=r,this.ignoreUndefinedProperties=i,s===void 0&&this.vu(),this.fieldTransforms=s||[],this.fieldMask=o||[]}get path(){return this.settings.path}get Cu(){return this.settings.Cu}Fu(e){return new n(Object.assign(Object.assign({},this.settings),e),this.databaseId,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}Mu(e){var t;let r=(t=this.path)===null||t===void 0?void 0:t.child(e),i=this.Fu({path:r,xu:!1});return i.Ou(e),i}Nu(e){var t;let r=(t=this.path)===null||t===void 0?void 0:t.child(e),i=this.Fu({path:r,xu:!1});return i.vu(),i}Lu(e){return this.Fu({path:void 0,xu:!0})}Bu(e){return Ry(e,this.settings.methodName,this.settings.ku||!1,this.path,this.settings.qu)}contains(e){return this.fieldMask.find(t=>e.isPrefixOf(t))!==void 0||this.fieldTransforms.find(t=>e.isPrefixOf(t.field))!==void 0}vu(){if(this.path)for(let e=0;e<this.path.length;e++)this.Ou(this.path.get(e))}Ou(e){if(e.length===0)throw this.Bu("Document fields must not be empty");if(iV(this.Cu)&&ZZ.test(e))throw this.Bu('Document fields cannot begin and end with "__"')}},gC=class{constructor(e,t,r){this.databaseId=e,this.ignoreUndefinedProperties=t,this.serializer
vendor: 13,459 bytes, line 25
25=r||jy(e)}Qu(e,t,r,i=!1){return new mC({Cu:e,methodName:t,qu:r,path:Fr.emptyPath(),xu:!1,ku:i},this.databaseId,this.serializer,this.ignoreUndefinedProperties)}};function UC(n){let e=n._freezeSettings(),t=jy(n._databaseId);return new gC(n._databaseId,!!e.ignoreUndefinedProperties,t)}function JZ(n,e,t,r,i,s={}){let o=n.Qu(s.merge||s.mergeFields?2:0,e,t,i);BC("Data must be an object, but it was:",o,r);let a=sV(r,o),c,l;if(s.merge)c=new Xr(o.fieldMask),l=o.fieldTransforms;else if(s.mergeFields){let u=[];for(let d of s.mergeFields){let f=yC(e,d,t);if(!o.contains(f))throw new ne(q.INVALID_ARGUMENT,`Field '${f}' is specified in your field mask but missing from your input data.`);aV(u,f)||u.push(f)}c=new Xr(u),l=o.fieldTransforms.filter(d=>c.covers(d.field))}else c=null,l=o.fieldTransforms;return new pC(new Lr(a),c,l)}var Dy=class n extends kh{_toFieldTransform(e){if(e.Cu!==2)throw e.Cu===1?e.Bu(`${this._methodName}() can only appear at the top level of your update data`):e.Bu(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);return e.fieldMask.push(e.path),null}isEqual(e){return e instanceof n}};function eJ(n,e,t,r){let i=n.Qu(1,e,t);BC("Data must be an object, but it was:",i,r);let s=[],o=Lr.empty();fc(r,(c,l)=>{let u=HC(e,c,t);l=_t(l);let d=i.Nu(u);if(l instanceof Dy)s.push(u);else{let f=$h(l,d);f!=null&&(s.push(u),o.set(u,f))}});let a=new Xr(s);return new xy(o,a,i.fieldTransforms)}function tJ(n,e,t,r,i,s){let o=n.Qu(1,e,t),a=[yC(e,r,t)],c=[i];if(s.length%2!=0)throw new ne(q.INVALID_ARGUMENT,`Function ${e}() needs to be called with an even number of arguments that alternate between field names and values.`);for(let f=0;f<s.length;f+=2)a.push(yC(e,s[f])),c.push(s[f+1]);let l=[],u=Lr.empty();for(let f=a.length-1;f>=0;--f)if(!aV(l,a[f])){let p=a[f],y=c[f];y=_t(y);let v=o.Nu(p);if(y instanceof Dy)l.push(p);else{let w=$h(y,v);w!=null&&(l.push(p),u.set(p,w))}}let d=new Xr(l);return new xy(u,d,o.fieldTransforms)}function nJ(n,e,t,r=!1){return $h(t,n.Qu(r?4:3,e))}function $h(n,e){if(oV(n=_t(n)))return BC("Unsupported field value:",e,n),sV(n,e);if(n instanceof kh)return function(r,i){if(!iV(i.Cu))throw i.Bu(`${r._methodName}() can only be used with update() and set()`);if(!i.path)throw i.Bu(`${r._methodName}() is not currently supported inside arrays`);let s=r._toFieldTransform(i);s&&i.fieldTransforms.push(s)}(n,e),null;if(n===void 0&&e.ignoreUndefinedProperties)return null;if(e.path&&e.fieldMask.push(e.path),n instanceof Array){if(e.settings.xu&&e.Cu!==4)throw e.Bu("Nested arrays are not supported");return function(r,i){let s=[],o=0;for(let a of r){let c=$h(a,i.Lu(o));c==null&&(c={nullValue:"NULL_VALUE"}),s.push(c),o++}return{arrayValue:{values:s}}}(n,e)}return function(r,i){if((r=_t(r))===null)return{nullValue:"NULL_VALUE"};if(typeof r=="number")return $Q(i.serializer,r);if(typeof r=="boolean")return{booleanValue:r};if(typeof r=="string")return{stringValue:r};if(r instanceof Date){let s=Tn.fromDate(r);return{timestampValue:fy(i.serializer,s)}}if(r instanceof Tn){let s=new Tn(r.seconds,1e3*Math.floor(r.nanoseconds/1e3));return{timestampValue:fy(i.serializer,s)}}if(r instanceof Ph)return{geoPointValue:{latitude:r.latitude,longitude:r.longitude}};if(r instanceof Rh)return{bytesValue:R2(i.serializer,r._byteString)};if(r instanceof yr){let s=i.databaseId,o=r.firestore._databaseId;if(!o.isEqual(s))throw i.Bu(`Document reference is for database ${o.projectId}/${o.database} but should be for database ${s.projectId}/${s.database}`);return{referenceValue:RC(r.firestore._databaseId||i.databaseId,r._key.path)}}if(r instanceof Mh)return function(o,a){return{mapValue:{fields:{__type__:{stringValue:"__vector__"},value:{arrayValue:{values:o.toArray().map(c=>{if(typeof c!="number")throw a.Bu("VectorValues must only contain numeric values.");return DC(a.serializer,c)})}}}}}}(r,i);throw i.Bu(`Unsupported field value: ${By(r)}`)}(n,e)}function sV(n,e){let t={};return a2(n)?e.path&&e.path.length>0&&e.fieldMask.push(e.path):fc(n,(r,i)=>{let s=$h(i,e.Mu(r));s!=null&&(t[r]=s)}),{mapValue:{fields:t}}}function oV(n){return!(typeof n!="object"||n===null||n instanceof Array||n instanceof Date||n instanceof Tn||n instanceof Ph||n instanceof Rh||n instanceof yr||n instanceof kh||n instanceof Mh)}function BC(n,e,t){if(!oV(t)||!function(i){return typeof i=="object"&&i!==null&&(Object.getPrototypeOf(i)===Object.prototype||Object.getPrototypeOf(i)===null)}(t)){let r=By(t);throw r==="an object"?e.Bu(n+" a custom object"):e.Bu(n+" "+r)}}function yC(n,e,t){if((e=_t(e))instanceof lu)return e._internalPath;if(typeof e=="string")return HC(n,e);throw Ry("Field path arguments must be of type string or ",n,!1,void 0,t)}var rJ=new RegExp("[~\\*/\\[\\]]");function HC(n,e,t){if(e.search(rJ)>=0)throw Ry(`Invalid field path (${e}). Paths must not contain '~', '*', '/', '[', or ']'`,n,!1,void 0,t);try{return new lu(...e.split("."))._internalPath}catch{throw Ry(`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,n,!1,void 0,t)}}function Ry(n,e,t,r,i){let s=r&&!r.isEmpty(),o=i!==void 0,a=`Function ${e}() called with invalid data`;t&&(a+=" (via `toFirestore()`)"),a+=". ";let c="";return(s||o)&&(c+=" (found",s&&(c+=` in field ${r}`),o&&(c+=` in document ${i}`),c+=")"),new ne(q.INVALID_ARGUMENT,a+n+c)}function aV(n,e){return n.some(t=>t.isEqual(e))}var ky=class{constructor(e,t,r,i,s){this._firestore=e,this._userDataWriter=t,this._key=r,this._document=i,this._converter=s}get id(){return this._key.path.lastSegment()}get ref(){return new yr(this._firestore,this._converter,this._key)}exists(){return this._document!==null}data(){if(this._document){if(this._converter){let e=new _C(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(e)}return this._userDataWriter.convertValue(this._document.data.value)}}get(e){if(this._document){let t=this._document.data.field(Hy("DocumentSnapshot.get",e));if(t!==null)return this._userDataWriter.convertValue(t)}}},_C=class extends ky{data(){return super.data()}};function Hy(n,e){return typeof e=="string"?HC(n,e):e instanceof lu?e._internalPath:e._delegate._internalPath}function cV(n){if(n.limitType==="L"&&n.explicitOrderBy.length===0)throw new ne(q.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}var Nh=class{},Py=class extends Nh{};function lV(n,e,...t){let r=[];e instanceof Nh&&r.push(e),r=r.concat(t),function(s){let o=s.filter(c=>c instanceof vC).length,a=s.filter(c=>c instanceof My).length;if(o>1||o>0&&a>0)throw new ne(q.INVALID_ARGUMENT,"InvalidQuery. When using composite filters, you cannot use more than one filter at the top level. Consider nesting the multiple filters within an `and(...)` statement. For example: change `query(query, where(...), or(...))` to `query(query, and(where(...), or(...)))`.")}(r);for(let i of r)n=i._apply(n);return n}var My=class n extends Py{constructor(e,t,r){super(),this._field=e,this._op=t,this._value=r,this.type="where"}static _create(e,t,r){return new n(e,t,r)}_apply(e){let t=this._parse(e);return hV(e._query,t),new ra(e.firestore,e.converter,hA(e._query,t))}_parse(e){let t=UC(e.firestore);return function(s,o,a,c,l,u,d){let f;if(l.isKeyField()){if(u==="array-contains"||u==="array-contains-any")throw new ne(q.INVALID_ARGUMENT,`Invalid Query. You can't perform '${u}' queries on documentId().`);if(u==="in"||u==="not-in"){s2(d,u);let p=[];for(let y of d)p.push(i2(c,s,y));f={arrayValue:{values:p}}}else f=i2(c,s,d)}else u!=="in"&&u!=="not-in"&&u!=="array-contains-any"||s2(d,u),f=nJ(a,o,d,u==="in"||u==="not-in");return tn.create(l,u,f)}(e._query,"where",t,e.firestore._databaseId,this._field,this._op,this._value)}};function uV(n,e,t){let r=e,i=Hy("where",n);return My._create(i,r,t)}var vC=class n extends Nh{constructor(e,t){super(),this.type=e,this._queryConstraints=t}static _create(e,t){return new n(e,t)}_parse(e){let t=this._queryConstraints.map(r=>r._parse(e)).filter(r=>r.getFilters().length>0);return t.length===1?t[0]:ki.create(t,this._getOperator())}_apply(e){let t=this._parse(e);return t.getFilters().length===0?e:(function(i,s){let o=i,a=s.getFlattenedFilters();for(let c of a)hV(o,c),o=hA(o,c)}(e._query,t),new ra(e.firestore,e.converter,hA(e._query,t)))}_getQueryConstraints(){return this._queryConstraints}_getOperator(){return this.type==="and"?"and":"or"}};var bC=class n extends Py{constructor(e,t){super(),this._field=e,this._direction=t,this.type="orderBy"}static _create(e,t){return new n(e,t)}_apply(e){let t=function(i,s,o){if(i.startAt!==null)throw new ne(q.INVALID_ARGUMENT,"Invalid query. You must not call startAt() or startAfter() before calling orderBy().");if(i.endAt!==null)throw new ne(q.INVALID_ARGUMENT,"Invalid query. You must not call endAt() or endBefore() before calling orderBy().");return new lc(s,o)}(e._query,this._field,this._direction);return new ra(e.firestore,e.converter,function(i,s){let o=i.explicitOrderBy.concat([s]);return new ea(i.path,i.collectionGroup,o,i.filters.slice(),i.limit,i.limitType,i.startAt,i.endAt)}(e._query,t))}};function dV(n,e="asc"){let t=e,r=Hy("orderBy",n);return bC._create(r,t)}function i2(n,e,t){if(typeof(t=_t(t))=="string"){if(t==="")throw new ne(q.INVALID_ARGUMENT,"Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");if(!g2(e)&&t.indexOf("/")!==-1)throw new ne(q.INVALID_ARGUMENT,`Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${t}' contains a '/' character.`);let r=e.path.child(Ft.fromString(t));if(!Ee.isDocumentKey(r))throw new ne(q.INVALID_ARGUMENT,`Invalid query. When querying a collection group by documentId(), the value provided must result in a valid document path, but '${r}' is not because it has an odd number of segments (${r.length}).`);return DF(n,new Ee(r))}if(t instanceof yr)return DF(n,t._key);throw new ne(q.INVALID_ARGUMENT,`Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${By(t)}.`)}function s2(n,e){if(!Array.isArray(n)||n.length===0)throw new ne(q.INVALID_ARGUMENT,`Invalid Query. A non-empty array is required for '${e.toString()}' filters.`)}function hV(n,e){let t=function(i,s){for(let o of i)for(let a of o.getFlattenedFilters())if(s.indexOf(a.op)>=0)return a.op;return null}(n.filters,function(i){switch(i){case"!=":return["!=","not-in"];case"array-contains-any":case"in":return["not-in"];case"not-in":return["array-contains-any","in","not-in","!="];default:return[]}}(e.op));if(t!==null)throw t===e.op?new ne(q.INVALID_ARGUMENT,`Invalid query. You cannot use more than one '${e.op.toString()}' filter.`):new ne(q.INVALID_ARGUMENT,`Invalid query. You cannot use '${e.op.toString()}' filters with '${t.toString()}' filters.`)}var wC=class{convertValue(e,t="none"){switch(cc(e)){case 0:return null;case 1:return e.booleanValue;case 2:return Nt(e.integerValue||e.doubleValue);case 3:return this.convertTimestamp(e.timestampValue);case 4:return this.convertServerTimestamp(e,t);case 5:return e.stringValue;case 6:return this.convertBytes(Jo(e.bytesValue));case 7:return this.convertReference(e.referenceValue);case 8:return this.convertGeoPoint(e.geoPointValue);case 9:return this.convertArray(e.arrayValue,t);case 11:return this.convertObject(e.mapValue,t);case 10:return this.convertVectorValue(e.mapValue);default:throw Se()}}convertObject(e,t){return this.convertObjectMap(e.fields,t)}convertObjectMap(e,t="none"){let r={};return fc(e,(i,s)=>{r[i]=this.convertValue(s,t)}),r}convertVectorValue(e){var t,r,i;let s=(i=(r=(t=e.fields)===null||t===void 0?void 0:t.value.arrayValue)===null||r===void 0?void 0:r.values)===null||i===void 0?void 0:i.map(o=>Nt(o.doubleValue));return new Mh(s)}convertGeoPoint(e){return new Ph(Nt(e.latitude),Nt(e.longitude))}convertArray(e,t){return(e.values||[]).map(r=>this.convertValue(r,t))}convertServerTimestamp(e,t){switch(t){case"previous":let r=TC(e);return r==null?null:this.convertValue(r,t);case"estimate":return this.convertTimestamp(Th(e));default:return null}}convertTimestamp(e){let t=to(e);return new Tn(t.seconds,t.nanos)}convertDocumentKey(e,t){let r=Ft.fromString(e);bt(L2(r));let i=new oy(r.get(1),r.get(3)),s=new Ee(r.popFirst(5));return i.isEqual(t)||eo(`Document ${s} contains a document reference within a different database (${i.projectId}/${i.database}) which is not supported. It will be treated as a reference in the current database (${t.projectId}/${t.database}) instead.`),s}};function iJ(n,e,t){let r;return r=n?t&&(t.merge||t.mergeFields)?n.toFirestore(e,t):n.toFirestore(e):e,r}var sc=class{constructor(e,t){this.hasPendingWrites=e,this.fromCache=t}isEqual(e){return this.hasPendingWrites===e.hasPendingWrites&&this.fromCache===e.fromCache}},Ny=class extends ky{constructor(e,t,r,i,s,o){super(e,t,r,i,o),this._firestore=e,this._firestoreImpl=e,this.metadata=s}exists(){return super.exists()}data(e={}){if(this._document){if(this._converter){let t=new Ql(this._firestore,this._userDataWriter,this._key,this._document,this.metadata,null);return this._converter.fromFirestore(t,e)}return this._userDataWriter.convertValue(this._document.data.value,e.serverTimestamps)}}get(e,t={}){if(this._document){let r=this._document.data.field(Hy("DocumentSnapshot.get",e));if(r!==null)return this._userDataWriter.convertValue(r,t.serverTimestamps)}}},Ql=class extends Ny{data(e={}){return super.data(e)}}
25,Oy=class{constructor(e,t,r,i){this._firestore=e,this._userDataWriter=t,this._snapshot=i,this.metadata=new sc(i.hasPendingWrites,i.fromCache),this.query=r}get docs(){let e=[];return this.forEach(t=>e.push(t)),e}get size(){return this._snapshot.docs.size}get empty(){return this.size===0}forEach(e,t){this._snapshot.docs.forEach(r=>{e.call(t,new Ql(this._firestore,this._userDataWriter,r.key,r,new sc(this._snapshot.mutatedKeys.has(r.key),this._snapshot.fromCache),this.query.converter))})}docChanges(e={}){let t=!!e.includeMetadataChanges;if(t&&this._snapshot.excludesMetadataChanges)throw new ne(q.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===t||(this._cachedChanges=function(i,s){if(i._snapshot.oldDocs.isEmpty()){let o=0;return i._snapshot.docChanges.map(a=>{let c=new Ql(i._firestore,i._userDataWriter,a.doc.key,a.doc,new sc(i._snapshot.mutatedKeys.has(a.doc.key),i._snapshot.fromCache),i.query.converter);return a.doc,{type:"added",doc:c,oldIndex:-1,newIndex:o++}})}{let o=i._snapshot.oldDocs;return i._snapshot.docChanges.filter(a=>s||a.type!==3).map(a=>{let c=new Ql(i._firestore,i._userDataWriter,a.doc.key,a.doc,new sc(i._snapshot.mutatedKeys.has(a.doc.key),i._snapshot.fromCache),i.query.converter),l=-1,u=-1;return a.type!==0&&(l=o.indexOf(a.doc.key),o=o.delete(a.doc.key)),a.type!==1&&(o=o.add(a.doc),u=o.indexOf(a.doc.key)),{type:sJ(a.type),doc:c,oldIndex:l,newIndex:u}})}}(this,t),this._cachedChangesIncludeMetadataChanges=t),this._cachedChanges}};function sJ(n){switch(n){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return Se()}}var Oh=class extends wC{constructor(e){super(),this.firestore=e}convertBytes(e){return new Rh(e)}convertReference(e){let t=this.convertDocumentKey(e,this.firestore._databaseId);return new yr(this.firestore,null,t)}};function fV(n){n=Js(n,ra);let e=Js(n.firestore,ia),t=$C(e),r=new Oh(e);return cV(n._query),YZ(t,n._query).then(i=>new Oy(e,r,n,i))}function pV(n,e,t,...r){n=Js(n,yr);let i=Js(n.firestore,ia),s=UC(i),o;return o=typeof(e=_t(e))=="string"||e instanceof lu?tJ(s,"updateDoc",n._key,e,t,r):eJ(s,"updateDoc",n._key,e),yV(i,[o.toMutation(n._key,Qo.exists(!0))])}function mV(n,e){let t=Js(n.firestore,ia),r=jC(n),i=iJ(n.converter,e);return yV(t,[JZ(UC(n.firestore),"addDoc",r._key,i,n.converter!==null,{}).toMutation(r._key,Qo.exists(!1))]).then(()=>r)}function gV(n,...e){var t,r,i;n=_t(n);let s={includeMetadataChanges:!1,source:"default"},o=0;typeof e[o]!="object"||r2(e[o])||(s=e[o],o++);let a={includeMetadataChanges:s.includeMetadataChanges,source:s.source};if(r2(e[o])){let d=e[o];e[o]=(t=d.next)===null||t===void 0?void 0:t.bind(d),e[o+1]=(r=d.error)===null||r===void 0?void 0:r.bind(d),e[o+2]=(i=d.complete)===null||i===void 0?void 0:i.bind(d)}let c,l,u;if(n instanceof yr)l=Js(n.firestore,ia),u=xC(n._key.path),c={next:d=>{e[o]&&e[o](oJ(l,n,d))},error:e[o+1],complete:e[o+2]};else{let d=Js(n,ra);l=Js(d.firestore,ia),u=d._query;let f=new Oh(l);c={next:p=>{e[o]&&e[o](new Oy(l,f,d,p))},error:e[o+1],complete:e[o+2]},cV(n._query)}return function(f,p,y,v){let w=new Ay(v),E=new Ey(p,w,y);return f.asyncQueue.enqueueAndForget(()=>m(this,null,function*(){return z2(yield fC(f),E)})),()=>{w.Za(),f.asyncQueue.enqueueAndForget(()=>m(this,null,function*(){return G2(yield fC(f),E)}))}}($C(l),u,a,c)}function yV(n,e){return function(r,i){let s=new cs;return r.asyncQueue.enqueueAndForget(()=>m(this,null,function*(){return VZ(yield KZ(r),i,s)})),s.promise}($C(n),e)}function oJ(n,e,t){let r=t.docs.get(e._key),i=new Oh(n);return new Ny(n,i,e._key,r,new sc(t.hasPendingWrites,t.fromCache),e.converter)}(function(e,t=!0){(function(i){uu=i})(ts),Yr(new Ln("firestore",(r,{instanceIdentifier:i,options:s})=>{let o=r.getProvider("app").getImmediate(),a=new ia(new GT(r.getProvider("auth-internal")),new XT(r.getProvider("app-check-internal")),function(l,u){if(!Object.prototype.hasOwnProperty.apply(l.options,["projectId"]))throw new ne(q.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new oy(l.options.projectId,u)}(o,i),o);return s=Object.assign({useFetchStreams:t},s),a._setSettings(s),a},"PUBLIC").setMultipleInstances(!0)),vt(AF,"4.7.3",e),vt(AF,"4.7.3","esm2017")})();var ro=class{constructor(e){return e}},_V="firestore",qC=class{constructor(){return Ws(_V)}};var zC=new ue("angularfire2.firestore-instances");function aJ(n,e){let t=Ko(_V,n,e);return t&&new ro(t)}function cJ(n){return(e,t)=>{let r=e.runOutsideAngular(()=>n(t));return new ro(r)}}var lJ={provide:qC,deps:[[new kt,zC]]},uJ={provide:ro,useFactory:aJ,deps:[[new kt,zC],Or]};function vV(n,...e){return vt("angularfire",Ci.full,"fst"),Nn([uJ,lJ,{provide:zC,useFactory:cJ(n),multi:!0,deps:[st,On,is,Si,[new kt,Qs],[new kt,rs],...e]}])}var io=ft(mV,!0);var ir=ft(nV,!0);var bV=ft(VC,!0);var so=ft(jC,!0);var sa=ft(fV,!0);var wV=ft(rV,!0);var EV=ft(gV,!0);var Uh=ft(dV,!0);var mc=ft(lV,!0);var oo=ft(pV,!0);var hu=ft(uV,!0);var RV="firebasestorage.googleapis.com",kV="storageBucket",dJ=2*60*1e3,hJ=10*60*1e3;var Ht=class n extends In{constructor(e,t,r=0){super(GC(e),`Firebase Storage: ${t} (${GC(e)})`),this.status_=r,this.customData={serverResponse:null},this._baseMessage=this.message,Object.setPrototypeOf(this,n.prototype)}get status(){return this.status_}set status(e){this.status_=e}_codeEquals(e){return GC(e)===this.code}get serverResponse(){return this.customData.serverResponse}set serverResponse(e){this.customData.serverResponse=e,this.customData.serverResponse?this.message=`${this._baseMessage} 26${this.customData.serverResponse}`:this.message=this._baseMessage}},Wt=function(n){return n.UNKNOWN="unknown",n.OBJECT_NOT_FOUND="object-not-found",n.BUCKET_NOT_FOUND="bucket-not-found",n.PROJECT_NOT_FOUND="project-not-found",n.QUOTA_EXCEEDED="quota-exceeded",n.UNAUTHENTICATED="unauthenticated",n.UNAUTHORIZED="unauthorized",n.UNAUTHORIZED_APP="unauthorized-app",n.RETRY_LIMIT_EXCEEDED="retry-limit-exceeded",n.INVALID_CHECKSUM="invalid-checksum",n.CANCELED="canceled",n.INVALID_EVENT_NAME="invalid-event-name",n.INVALID_URL="invalid-url",n.INVALID_DEFAULT_BUCKET="invalid-default-bucket",n.NO_DEFAULT_BUCKET="no-default-bucket",n.CANNOT_SLICE_BLOB="cannot-slice-blob",n.SERVER_FILE_WRONG_SIZE="server-file-wrong-size",n.NO_DOWNLOAD_URL="no-download-url",n.INVALID_ARGUMENT="invalid-argument",n.INVALID_ARGUMENT_COUNT="invalid-argument-count",n.APP_DELETED="app-deleted",n.INVALID_ROOT_OPERATION="invalid-root-operation",n.INVALID_FORMAT="invalid-format",n.INTERNAL_ERROR="internal-error",n.UNSUPPORTED_ENVIRONMENT="unsupported-environment",n}(Wt||{});function GC(n){return"storage/"+n}function ZC(){let n="An unknown error occurred, please check the error payload for server response.";return new Ht(Wt.UNKNOWN,n)}function fJ(n){return new Ht(Wt.OBJECT_NOT_FOUND,"Object '"+n+"' does not exist.")}function pJ(n){return new Ht(Wt.QUOTA_EXCEEDED,"Quota for bucket '"+n+"' exceeded, please view quota on https://firebase.google.com/pricing/.")}function mJ(){let n="User is not authenticated, please authenticate using Firebase Authentication and try again.";return new Ht(Wt.UNAUTHENTICATED,n)}function gJ(){return new Ht(Wt.UNAUTHORIZED_APP,"This app does not have permission to access Firebase Storage on this project.")}function yJ(n){return new Ht(Wt.UNAUTHORIZED,"User does not have permission to access '"+n+"'.")}function _J(){return new Ht(Wt.RETRY_LIMIT_EXCEEDED,"Max retry time for operation exceeded, please try again.")}function vJ(){return new Ht(Wt.CANCELED,"User canceled the upload/download.")}function bJ(n){return new Ht(Wt.INVALID_URL,"Invalid URL '"+n+"'.")}function wJ(n){return new Ht(Wt.INVALID_DEFAULT_BUCKET,"Invalid default bucket '"+n+"'.")}function EJ(){return new Ht(Wt.NO_DEFAULT_BUCKET,"No default bucket found. Did you set the '"+kV+"' property when initializing the app?")}function IJ(){return new Ht(Wt.CANNOT_SLICE_BLOB,"Cannot slice blob for upload. Please retry the upload.")}function TJ(){return new Ht(Wt.NO_DOWNLOAD_URL,"The given file does not have any download URLs.")}function AJ(n){return new Ht(Wt.UNSUPPORTED_ENVIRONMENT,`${n} is missing. Make sure to install the required polyfills. See https://firebase.google.com/docs/web/environments-js-sdk#polyfills for more information.`)}function WC(n){return new Ht(Wt.INVALID_ARGUMENT,n)}function PV(){return new Ht(Wt.APP_DELETED,"The Firebase app was deleted.")}function CJ(n){return new Ht(Wt.INVALID_ROOT_OPERATION,"The operation '"+n+"' cannot be performed on a root reference, create a non-root reference using child, such as .child('file.png').")}function Hh(n,e){return new Ht(Wt.INVALID_FORMAT,"String does not match format '"+n+"': "+e)}function Bh(n){throw new Ht(Wt.INTERNAL_ERROR,"Internal error: "+n)}var Pi=class n{constructor(e,t){this.bucket=e,this.path_=t}get path(){return this.path_}get isRoot(){return this.path.length===0}fullServerUrl(){let e=encodeURIComponent;return"/b/"+e(this.bucket)+"/o/"+e(this.path)}bucketOnlyServerUrl(){return"/b/"+encodeURIComponent(this.bucket)+"/o"}static makeFromBucketSpec(e,t){let r;try{r=n.makeFromUrl(e,t)}catch{return new n(e,"")}if(r.path==="")return r;throw wJ(e)}static makeFromUrl(e,t){let r=null,i="([A-Za-z0-9.\\-_]+)";function s(M){M.path.charAt(M.path.length-1)==="/"&&(M.path_=M.path_.slice(0,-1))}let o="(/(.*))?$",a=new RegExp("^gs://"+i+o,"i"),c={bucket:1,path:3};function l(M){M.path_=decodeURIComponent(M.path)}let u="v[A-Za-z0-9_]+",d=t.replace(/[.]/g,"\\."),f="(/([^?#]*).*)?$",p=new RegExp(`^https?://${d}/${u}/b/${i}/o${f}`,"i"),y={bucket:1,path:3},v=t===RV?"(?:storage.googleapis.com|storage.cloud.google.com)":t,w="([^?#]*)",E=new RegExp(`^https?://${v}/${i}/${w}`,"i"),x=[{regex:a,indices:c,postModify:s},{regex:p,indices:y,postModify:l},{regex:E,indices:{bucket:1,path:2},postModify:l}];for(let M=0;M<x.length;M++){let O=x[M],$=O.regex.exec(e);if($){let C=$[O.indices.bucket],T=$[O.indices.path];T||(T=""),r=new n(C,T),O.postModify(r);break}}if(r==null)throw bJ(e);return r}},KC=class{constructor(e){this.promise_=Promise.reject(e)}getPromise(){return this.promise_}cancel(e=!1){}};function SJ(n,e,t){let r=1,i=null,s=null,o=!1,a=0;function c(){return a===2}let l=!1;function u(...w){l||(l=!0,e.apply(null,w))}function d(w){i=setTimeout(()=>{i=null,n(p,c())},w)}function f(){s&&clearTimeout(s)}function p(w,...E){if(l){f();return}if(w){f(),u.call(null,w,...E);return}if(c()||o){f(),u.call(null,w,...E);return}r<64&&(r*=2);let x;a===1?(a=2,x=0):x=(r+Math.random())*1e3,d(x)}let y=!1;
vendor: 15,261 bytes, lines 26-34
26function v(w){y||(y=!0,f(),!l&&(i!==null?(w||(a=2),clearTimeout(i),d(0)):w||(a=1)))}return d(0),s=setTimeout(()=>{o=!0,v(!0)},t),v}function xJ(n){n(!1)}function DJ(n){return n!==void 0}function RJ(n){return typeof n=="object"&&!Array.isArray(n)}function JC(n){return typeof n=="string"||n instanceof String}function TV(n){return eS()&&n instanceof Blob}function eS(){return typeof Blob<"u"}function AV(n,e,t,r){if(r<e)throw WC(`Invalid value for '${n}'. Expected ${e} or greater.`);if(r>t)throw WC(`Invalid value for '${n}'. Expected ${t} or less.`)}function tS(n,e,t){let r=e;return t==null&&(r=`https://${e}`),`${t}://${r}/v0${n}`}function MV(n){let e=encodeURIComponent,t="?";for(let r in n)if(n.hasOwnProperty(r)){let i=e(r)+"="+e(n[r]);t=t+i+"&"}return t=t.slice(0,-1),t}var pu=function(n){return n[n.NO_ERROR=0]="NO_ERROR",n[n.NETWORK_ERROR=1]="NETWORK_ERROR",n[n.ABORT=2]="ABORT",n}(pu||{});function kJ(n,e){let t=n>=500&&n<600,i=[408,429].indexOf(n)!==-1,s=e.indexOf(n)!==-1;return t||i||s}var YC=class{constructor(e,t,r,i,s,o,a,c,l,u,d,f=!0){this.url_=e,this.method_=t,this.headers_=r,this.body_=i,this.successCodes_=s,this.additionalRetryCodes_=o,this.callback_=a,this.errorCallback_=c,this.timeout_=l,this.progressCallback_=u,this.connectionFactory_=d,this.retry=f,this.pendingConnection_=null,this.backoffId_=null,this.canceled_=!1,this.appDelete_=!1,this.promise_=new Promise((p,y)=>{this.resolve_=p,this.reject_=y,this.start_()})}start_(){let e=(r,i)=>{if(i){r(!1,new fu(!1,null,!0));return}let s=this.connectionFactory_();this.pendingConnection_=s;let o=a=>{let c=a.loaded,l=a.lengthComputable?a.total:-1;this.progressCallback_!==null&&this.progressCallback_(c,l)};this.progressCallback_!==null&&s.addUploadProgressListener(o),s.send(this.url_,this.method_,this.body_,this.headers_).then(()=>{this.progressCallback_!==null&&s.removeUploadProgressListener(o),this.pendingConnection_=null;let a=s.getErrorCode()===pu.NO_ERROR,c=s.getStatus();if(!a||kJ(c,this.additionalRetryCodes_)&&this.retry){let u=s.getErrorCode()===pu.ABORT;r(!1,new fu(!1,null,u));return}let l=this.successCodes_.indexOf(c)!==-1;r(!0,new fu(l,s))})},t=(r,i)=>{let s=this.resolve_,o=this.reject_,a=i.connection;if(i.wasSuccessCode)try{let c=this.callback_(a,a.getResponse());DJ(c)?s(c):s()}catch(c){o(c)}else if(a!==null){let c=ZC();c.serverResponse=a.getErrorText(),this.errorCallback_?o(this.errorCallback_(a,c)):o(c)}else if(i.canceled){let c=this.appDelete_?PV():vJ();o(c)}else{let c=_J();o(c)}};this.canceled_?t(!1,new fu(!1,null,!0)):this.backoffId_=SJ(e,t,this.timeout_)}getPromise(){return this.promise_}cancel(e){this.canceled_=!0,this.appDelete_=e||!1,this.backoffId_!==null&&xJ(this.backoffId_),this.pendingConnection_!==null&&this.pendingConnection_.abort()}},fu=class{constructor(e,t,r){this.wasSuccessCode=e,this.connection=t,this.canceled=!!r}};function PJ(n,e){e!==null&&e.length>0&&(n.Authorization="Firebase "+e)}function MJ(n,e){n["X-Firebase-Storage-Version"]="webjs/"+(e??"AppManager")}function NJ(n,e){e&&(n["X-Firebase-GMPID"]=e)}function OJ(n,e){e!==null&&(n["X-Firebase-AppCheck"]=e)}function LJ(n,e,t,r,i,s,o=!0){let a=MV(n.urlParams),c=n.url+a,l=Object.assign({},n.headers);return NJ(l,e),PJ(l,t),MJ(l,s),OJ(l,r),new YC(c,n.method,l,n.body,n.successCodes,n.additionalRetryCodes,n.handler,n.errorHandler,n.timeout,n.progressCallback,i,o)}function FJ(){return typeof BlobBuilder<"u"?BlobBuilder:typeof WebKitBlobBuilder<"u"?WebKitBlobBuilder:void 0}function VJ(...n){let e=FJ();if(e!==void 0){let t=new e;for(let r=0;r<n.length;r++)t.append(n[r]);return t.getBlob()}else{if(eS())return new Blob(n);throw new Ht(Wt.UNSUPPORTED_ENVIRONMENT,"This browser doesn't seem to support creating Blobs")}}function jJ(n,e,t){return n.webkitSlice?n.webkitSlice(e,t):n.mozSlice?n.mozSlice(e,t):n.slice?n.slice(e,t):null}function $J(n){if(typeof atob>"u")throw AJ("base-64");return atob(n)}var ps={RAW:"raw",BASE64:"base64",BASE64URL:"base64url",DATA_URL:"data_url"},qh=class{constructor(e,t){this.data=e,this.contentType=t||null}};function UJ(n,e){switch(n){case ps.RAW:return new qh(NV(e));case ps.BASE64:case ps.BASE64URL:return new qh(OV(n,e));case ps.DATA_URL:return new qh(HJ(e),qJ(e))}throw ZC()}function NV(n){let e=[];for(let t=0;t<n.length;t++){let r=n.charCodeAt(t);if(r<=127)e.push(r);else if(r<=2047)e.push(192|r>>6,128|r&63);else if((r&64512)===55296)if(!(t<n.length-1&&(n.charCodeAt(t+1)&64512)===56320))e.push(239,191,189);else{let s=r,o=n.charCodeAt(++t);r=65536|(s&1023)<<10|o&1023,e.push(240|r>>18,128|r>>12&63,128|r>>6&63,128|r&63)}else(r&64512)===56320?e.push(239,191,189):e.push(224|r>>12,128|r>>6&63,128|r&63)}return new Uint8Array(e)}function BJ(n){let e;try{e=decodeURIComponent(n)}catch{throw Hh(ps.DATA_URL,"Malformed data URL.")}return NV(e)}function OV(n,e){switch(n){case ps.BASE64:{let i=e.indexOf("-")!==-1,s=e.indexOf("_")!==-1;if(i||s)throw Hh(n,"Invalid character '"+(i?"-":"_")+"' found: is it base64url encoded?");break}case ps.BASE64URL:{let i=e.indexOf("+")!==-1,s=e.indexOf("/")!==-1;if(i||s)throw Hh(n,"Invalid character '"+(i?"+":"/")+"' found: is it base64 encoded?");e=e.replace(/-/g,"+").replace(/_/g,"/");break}}let t;try{t=$J(e)}catch(i){throw i.message.includes("polyfill")?i:Hh(n,"Invalid character found")}let r=new Uint8Array(t.length);for(let i=0;i<t.length;i++)r[i]=t.charCodeAt(i);return r}var zy=class{constructor(e){this.base64=!1,this.contentType=null;let t=e.match(/^data:([^,]+)?,/);if(t===null)throw Hh(ps.DATA_URL,"Must be formatted 'data:[<mediatype>][;base64],<data>");let r=t[1]||null;r!=null&&(this.base64=zJ(r,";base64"),this.contentType=this.base64?r.substring(0,r.length-7):r),this.rest=e.substring(e.indexOf(",")+1)}};function HJ(n){let e=new zy(n);return e.base64?OV(ps.BASE64,e.rest):BJ(e.rest)}function qJ(n){return new zy(n).contentType}function zJ(n,e){return n.length>=e.length?n.substring(n.length-e.length)===e:!1}var Gy=class n{constructor(e,t){let r=0,i="";TV(e)?(this.data_=e,r=e.size,i=e.type):e instanceof ArrayBuffer?(t?this.data_=new Uint8Array(e):(this.data_=new Uint8Array(e.byteLength),this.data_.set(new Uint8Array(e))),r=this.data_.length):e instanceof Uint8Array&&(t?this.data_=e:(this.data_=new Uint8Array(e.length),this.data_.set(e)),r=e.length),this.size_=r,this.type_=i}size(){return this.size_}type(){return this.type_}slice(e,t){if(TV(this.data_)){let r=this.data_,i=jJ(r,e,t);return i===null?null:new n(i)}else{let r=new Uint8Array(this.data_.buffer,e,t-e);return new n(r,!0)}}static getBlob(...e){if(eS()){let t=e.map(r=>r instanceof n?r.data_:r);return new n(VJ.apply(null,t))}else{let t=e.map(o=>JC(o)?UJ(ps.RAW,o).data:o.data_),r=0;t.forEach(o=>{r+=o.byteLength});let i=new Uint8Array(r),s=0;return t.forEach(o=>{for(let a=0;a<o.length;a++)i[s++]=o[a]}),new n(i,!0)}}uploadData(){return this.data_}};function LV(n){let e;try{e=JSON.parse(n)}catch{return null}return RJ(e)?e:null}function GJ(n){if(n.length===0)return null;let e=n.lastIndexOf("/");return e===-1?"":n.slice(0,e)}function WJ(n,e){let t=e.split("/").filter(r=>r.length>0).join("/");return n.length===0?t:n+"/"+t}function FV(n){let e=n.lastIndexOf("/",n.length-2);return e===-1?n:n.slice(e+1)}function KJ(n,e){return e}var An=class{constructor(e,t,r,i){this.server=e,this.local=t||e,this.writable=!!r,this.xform=i||KJ}},qy=null;function YJ(n){return!JC(n)||n.length<2?n:FV(n)}function VV(){if(qy)return qy;let n=[];n.push(new An("bucket")),n.push(new An("generation")),n.push(new An("metageneration")),n.push(new An("name","fullPath",!0));function e(s,o){return YJ(o)}let t=new An("name");t.xform=e,n.push(t);function r(s,o){return o!==void 0?Number(o):o}let i=new An("size");return i.xform=r,n.push(i),n.push(new An("timeCreated")),n.push(new An("updated")),n.push(new An("md5Hash",null,!0)),n.push(new An("cacheControl",null,!0)),n.push(new An("contentDisposition",null,!0)),n.push(new An("contentEncoding",null,!0)),n.push(new An("contentLanguage",null,!0)),n.push(new An("contentType",null,!0)),n.push(new An("metadata","customMetadata",!0)),qy=n,qy}function XJ(n,e){function t(){let r=n.bucket,i=n.fullPath,s=new Pi(r,i);return e._makeStorageReference(s)}Object.defineProperty(n,"ref",{get:t})}function QJ(n,e,t){let r={};r.type="file";let i=t.length;for(let s=0;s<i;s++){let o=t[s];r[o.local]=o.xform(r,e[o.server])}return XJ(r,n),r}function jV(n,e,t){let r=LV(e);return r===null?null:QJ(n,r,t)}function ZJ(n,e,t,r){let i=LV(e);if(i===null||!JC(i.downloadTokens))return null;let s=i.downloadTokens;if(s.length===0)return null;let o=encodeURIComponent;return s.split(",").map(l=>{let u=n.bucket,d=n.fullPath,f="/b/"+o(u)+"/o/"+o(d),p=tS(f,t,r),y=MV({alt:"media",token:l});return p+y})[0]}function JJ(n,e){let t={},r=e.length;for(let i=0;i<r;i++){let s=e[i];s.writable&&(t[s.server]=n[s.local])}return JSON.stringify(t)}var Wy=class{constructor(e,t,r,i){this.url=e,this.method=t,this.handler=r,this.timeout=i,this.urlParams={},this.headers={},this.body=null,this.errorHandler=null,this.progressCallback=null,this.successCodes=[200],this.additionalRetryCodes=[]}};function $V(n){if(!n)throw ZC()}function eee(n,e){function t(r,i){let s=jV(n,i,e);return $V(s!==null),s}return t}function tee(n,e){function t(r,i){let s=jV(n,i,e);return $V(s!==null),ZJ(s,i,n.host,n._protocol)}return t}function UV(n){function e(t,r){let i;return t.getStatus()===401?t.getErrorText().includes("Firebase App Check token is invalid")?i=gJ():i=mJ():t.getStatus()===402?i=pJ(n.bucket):t.getStatus()===403?i=yJ(n.path):i=r,i.status=t.getStatus(),i.serverResponse=r.serverResponse,i}return e}function nee(n){let e=UV(n);function t(r,i){let s=e(r,i);return r.getStatus()===404&&(s=fJ(n.path)),s.serverResponse=i.serverResponse,s}return t}function ree(n,e,t){let r=e.fullServerUrl(),i=tS(r,n.host,n._protocol),s="GET",o=n.maxOperationRetryTime,a=new Wy(i,s,tee(n,t),o);return a.errorHandler=nee(e),a}function iee(n,e){return n&&n.contentType||e&&e.type()||"application/octet-stream"}function see(n,e,t){let r=Object.assign({},t);return r.fullPath=n.path,r.size=e.size(),r.contentType||(r.contentType=iee(null,e)),r}function oee(n,e,t,r,i){let s=e.bucketOnlyServerUrl(),o={"X-Goog-Upload-Protocol":"multipart"};function a(){let x="";for(let M=0;M<2;M++)x=x+Math.random().toString().slice(2);return x}let c=a();o["Content-Type"]="multipart/related; boundary="+c;let l=see(e,r,i),u=JJ(l,t),d="--"+c+`\r 27Content-Type: application/json; charset=utf-8\r 28\r 29`+u+`\r 30--`+c+`\r 31Content-Type: `+l.contentType+`\r 32\r 33`,f=`\r 34--`+c+"--",p=Gy.getBlob(d,r,f);if(p===null)throw IJ();let y={name:l.fullPath},v=tS(s,n.host,n._protocol),w="POST",E=n.maxUploadRetryTime,A=new Wy(v,w,eee(n,t),E);return A.urlParams=y,A.headers=o,A.body=p.uploadData(),A.errorHandler=UV(e),A}var A0e=256*1024;var CV=null,XC=class{constructor(){this.sent_=!1,this.xhr_=new XMLHttpRequest,this.initXhr(),this.errorCode_=pu.NO_ERROR,this.sendPromise_=new Promise(e=>{this.xhr_.addEventListener("abort",()=>{this.errorCode_=pu.ABORT,e()}),this.xhr_.addEventListener("error",()=>{this.errorCode_=pu.NETWORK_ERROR,e()}),this.xhr_.addEventListener("load",()=>{e()})})}send(e,t,r,i){if(this.sent_)throw Bh("cannot .send() more than once");if(this.sent_=!0,this.xhr_.open(t,e,!0),i!==void 0)for(let s in i)i.hasOwnProperty(s)&&this.xhr_.setRequestHeader(s,i[s].toString());return r!==void 0?this.xhr_.send(r):this.xhr_.send(),this.sendPromise_}getErrorCode(){if(!this.sent_)throw Bh("cannot .getErrorCode() before sending");return this.errorCode_}getStatus(){if(!this.sent_)throw Bh("cannot .getStatus() before sending");try{return this.xhr_.status}catch{return-1}}getResponse(){if(!this.sent_)throw Bh("cannot .getResponse() before sending");return this.xhr_.response}getErrorText(){if(!this.sent_)throw Bh("cannot .getErrorText() before sending");return this.xhr_.statusText}abort(){this.xhr_.abort()}getResponseHeader(e){return this.xhr_.getResponseHeader(e)}addUploadProgressListener(e){this.xhr_.upload!=null&&this.xhr_.upload.addEventListener("progress",e)}removeUploadProgressListener(e){this.xhr_.upload!=null&&this.xhr_.upload.removeEventListener("progress",e)}},QC=class extends XC{initXhr(){this.xhr_.responseType="text"}};function BV(){return CV?CV():new QC}var mu=class n{constructor(e,t){this._service=e,t instanceof Pi?this._location=t:this._location=Pi.makeFromUrl(t,e.host)}toString(){return"gs://"+this._location.bucket+"/"+this._location.path}_newRef(e,t){return new n(e,t)}get root(){let e=new Pi(this._location.bucket,"");return this._newRef(this._service,e)}get bucket(){return this._location.bucket}get fullPath(){return this._location.path}get name(){return FV(this._location.path)}get storage(){return this._service}get parent(){let e=GJ(this._location.path);if(e===null)return null;let t=new Pi(this._location.bucket,e);return new n(this._service,t)}_throwIfRoot(e){if(this._location.path==="")throw CJ(e)}};function aee(n,e,t){n._throwIfRoot("uploadBytes");let r=oee(n.storage,n._location,VV(),new Gy(e,!0),t);return n.storage.makeRequestWithTokens(r,BV).then(i=>({metadata:i,ref:n}))}function cee(n){n._throwIfRoot("getDownloadURL");let e=ree(n.storage,n._location,VV());return n.storage.makeRequestWithTokens(e,BV).then(t=>{if(t===null)throw TJ();return t})}function lee(n,e){let t=WJ(n._location.path,e),r=new Pi(n._location.bucket,t);return new mu(n.storage,r)}function uee(n){return/^[A-Za-z]+:\/\//.test(n)}function dee(n,e){return new mu(n,e)}function HV(n,e){if(n instanceof zh){let t=n;if(t._bucket==null)throw EJ();let r=new mu(t,t._bucket);return e!=null?HV(r,e):r}else return e!==void 0?lee(n,e):n}function hee(n,e){if(e&&uee(e)){if(n instanceof zh)return dee(n,e);throw WC("To use ref(service, url), the first argument must be a Storage instance.")}else return HV(n,e)}function SV(n,e){let t=e?.[kV];return t==null?null:Pi.makeFromBucketSpec(t,n)}function fee(n,e,t,r={}){n.host=`${e}:${t}`,n._protocol="http";let{mockUserToken:i}=r;i&&(n._overrideAuthToken=typeof i=="string"?i:Ig(i,n.app.options.projectId))}var zh=class{constructor(e,t,r,i,s){this.app=e,this._authProvider=t,this._appCheckProvider=r,this._url=i,this._firebaseVersion=s,this._bucket=null,this._host=RV,this._protocol="https",this._appId=null,this._deleted=!1,this._maxOperationRetryTime=dJ,this._maxUploadRetryTime=hJ,this._requests=new Set,i!=null?this._bucket=Pi.makeFromBucketSpec(i,this._host):this._bucket=SV(this._host,this.app.options)}get host(){return this._host}set host(e){this._host=e,this._url!=null?this._bucket=Pi.makeFromBucketSpec(this._url,e):this._bucket=SV(e,this.app.options)}get maxUploadRetryTime(){return this._maxUploadRetryTime}set maxUploadRetryTime(e){AV("time",0,Number.POSITIVE_INFINITY,e),this._maxUploadRetryTime=e}get maxOperationRetryTime(){return this._maxOperationRetryTime}set maxOperationRetryTime(e){AV("time",0,Number.POSITIVE_INFINITY,e),this._maxOperationRetryTime=e}_getAuthToken(){return m(this,null,function*(){if(this._overrideAuthToken)return this._overrideAuthToken;let e=this._authProvider.getImmediate({optional:!0});if(e){let t=yield e.getToken();if(t!==null)return t.accessToken}return null})}_getAppCheckToken(){return m(this,null,function*(){let e=this._appCheckProvider.getImmediate({optional:!0});return e?(yield e.getToken()).token:null})}_delete(){return this._deleted||(this._deleted=!0,this._requests.forEac
34h(e=>e.cancel()),this._requests.clear()),Promise.resolve()}_makeStorageReference(e){return new mu(this,e)}_makeRequest(e,t,r,i,s=!0){if(this._deleted)return new KC(PV());{let o=LJ(e,this._appId,r,i,t,this._firebaseVersion,s);return this._requests.add(o),o.getPromise().then(()=>this._requests.delete(o),()=>this._requests.delete(o)),o}}makeRequestWithTokens(e,t){return m(this,null,function*(){let[r,i]=yield Promise.all([this._getAuthToken(),this._getAppCheckToken()]);return this._makeRequest(e,t,r,i).getPromise()})}},xV="@firebase/storage",DV="0.13.2";var qV="storage";function zV(n,e,t){return n=_t(n),aee(n,e,t)}function GV(n){return n=_t(n),cee(n)}function WV(n,e){return n=_t(n),hee(n,e)}function KV(n=ns(),e){n=_t(n);let r=Gs(n,qV).getImmediate({identifier:e}),i=jl("storage");return i&&nS(r,...i),r}function nS(n,e,t,r={}){fee(n,e,t,r)}function pee(n,{instanceIdentifier:e}){let t=n.getProvider("app").getImmediate(),r=n.getProvider("auth-internal"),i=n.getProvider("app-check-internal");return new zh(t,r,i,e,ts)}function mee(){Yr(new Ln(qV,pee,"PUBLIC").setMultipleInstances(!0)),vt(xV,DV,""),vt(xV,DV,"esm2017")}mee();var gc=class{constructor(e){return e}},YV="storage",rS=class{constructor(){return Ws(YV)}};var iS=new ue("angularfire2.storage-instances");function gee(n,e){let t=Ko(YV,n,e);return t&&new gc(t)}function yee(n){return(e,t)=>{let r=e.runOutsideAngular(()=>n(t));return new gc(r)}}var _ee={provide:rS,deps:[[new kt,iS]]},vee={provide:gc,useFactory:gee,deps:[[new kt,iS],Or]};function XV(n,...e){return vt("angularfire",Ci.full,"gcs"),Nn([vee,_ee,{provide:iS,useFactory:yee(n),multi:!0,deps:[st,On,is,Si,[new kt,Qs],[new kt,rs],...e]}])}var QV=ft(nS,!0);var sS=ft(GV,!0);var ZV=ft(KV,!0);var oS=ft(WV,!0);var aS=ft(zV,!0);var wee="type.googleapis.com/google.protobuf.Int64Value",Eee="type.googleapis.com/google.protobuf.UInt64Value";function nj(n,e){let t={};for(let r in n)n.hasOwnProperty(r)&&(t[r]=e(n[r]));return t}function cS(n){if(n==null)return null;if(n instanceof Number&&(n=n.valueOf()),typeof n=="number"&&isFinite(n)||n===!0||n===!1||Object.prototype.toString.call(n)==="[object String]")return n;if(n instanceof Date)return n.toISOString();if(Array.isArray(n))return n.map(e=>cS(e));if(typeof n=="function"||typeof n=="object")return nj(n,e=>cS(e));throw new Error("Data cannot be encoded in JSON: "+n)}function Ky(n){if(n==null)return n;if(n["@type"])switch(n["@type"]){case wee:case Eee:{let e=Number(n.value);if(isNaN(e))throw new Error("Data cannot be decoded from JSON: "+n);return e}default:throw new Error("Data cannot be decoded from JSON: "+n)}return Array.isArray(n)?n.map(e=>Ky(e)):typeof n=="function"||typeof n=="object"?nj(n,e=>Ky(e)):n}var hS="functions";var JV={OK:"ok",CANCELLED:"cancelled",UNKNOWN:"unknown",INVALID_ARGUMENT:"invalid-argument",DEADLINE_EXCEEDED:"deadline-exceeded",NOT_FOUND:"not-found",ALREADY_EXISTS:"already-exists",PERMISSION_DENIED:"permission-denied",UNAUTHENTICATED:"unauthenticated",RESOURCE_EXHAUSTED:"resource-exhausted",FAILED_PRECONDITION:"failed-precondition",ABORTED:"aborted",OUT_OF_RANGE:"out-of-range",UNIMPLEMENTED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"},oa=class extends In{constructor(e,t,r){super(`${hS}/${e}`,t||""),this.details=r}};function Iee(n){if(n>=200&&n<300)return"ok";switch(n){case 0:return"internal";case 400:return"invalid-argument";case 401:return"unauthenticated";case 403:return"permission-denied";case 404:return"not-found";case 409:return"aborted";case 429:return"resource-exhausted";case 499:return"cancelled";case 500:return"internal";case 501:return"unimplemented";case 503:return"unavailable";case 504:return"deadline-exceeded"}return"unknown"}function Tee(n,e){let t=Iee(n),r=t,i;try{let s=e&&e.error;if(s){let o=s.status;if(typeof o=="string"){if(!JV[o])return new oa("internal","internal");t=JV[o],r=o}let a=s.message;typeof a=="string"&&(r=a),i=s.details,i!==void 0&&(i=Ky(i))}}catch{}return t==="ok"?null:new oa(t,r,i)}var lS=class{constructor(e,t,r){this.auth=null,this.messaging=null,this.appCheck=null,this.auth=e.getImmediate({optional:!0}),this.messaging=t.getImmediate({optional:!0}),this.auth||e.get().then(i=>this.auth=i,()=>{}),this.messaging||t.get().then(i=>this.messaging=i,()=>{}),this.appCheck||r.get().then(i=>this.appCheck=i,()=>{})}getAuthToken(){return m(this,null,function*(){if(this.auth)try{let e=yield this.auth.getToken();return e?.accessToken}catch{return}})}getMessagingToken(){return m(this,null,function*(){if(!(!this.messaging||!("Notification"in self)||Notification.permission!=="granted"))try{return yield this.messaging.getToken()}catch{return}})}getAppCheckToken(e){return m(this,null,function*(){if(this.appCheck){let t=e?yield this.appCheck.getLimitedUseToken():yield this.appCheck.getToken();return t.error?null:t.token}return null})}getContext(e){return m(this,null,function*(){let t=yield this.getAuthToken(),r=yield this.getMessagingToken(),i=yield this.getAppCheckToken(e);
34return{authToken:t,messagingToken:r,appCheckToken:i}})}};var uS="us-central1";function Aee(n){let e=null;return{promise:new Promise((t,r)=>{e=setTimeout(()=>{r(new oa("deadline-exceeded","deadline-exceeded"))},n)}),cancel:()=>{e&&clearTimeout(e)}}}var dS=class{constructor(e,t,r,i,s=uS,o){this.app=e,this.fetchImpl=o,this.emulatorOrigin=null,this.contextProvider=new lS(t,r,i),this.cancelAllRequests=new Promise(a=>{this.deleteService=()=>Promise.resolve(a())});try{let a=new URL(s);this.customDomain=a.origin+(a.pathname==="/"?"":a.pathname),this.region=uS}catch{this.customDomain=null,this.region=s}}_delete(){return this.deleteService()}_url(e){let t=this.app.options.projectId;return this.emulatorOrigin!==null?`${this.emulatorOrigin}/${t}/${this.region}/${e}`:this.customDomain!==null?`${this.customDomain}/${e}`:`https://${this.region}-${t}.cloudfunctions.net/${e}`}};function Cee(n,e,t){n.emulatorOrigin=`http://${e}:${t}`}function See(n,e,t){return r=>Dee(n,e,r,t||{})}function xee(n,e,t,r){return m(this,null,function*(){t["Content-Type"]="application/json";let i;try{i=yield r(n,{method:"POST",body:JSON.stringify(e),headers:t})}catch{return{status:0,json:null}}let s=null;try{s=yield i.json()}catch{}return{status:i.status,json:s}})}function Dee(n,e,t,r){let i=n._url(e);return Ree(n,i,t,r)}function Ree(n,e,t,r){return m(this,null,function*(){t=cS(t);let i={data:t},s={},o=yield n.contextProvider.getContext(r.limitedUseAppCheckTokens);o.authToken&&(s.Authorization="Bearer "+o.authToken),o.messagingToken&&(s["Firebase-Instance-ID-Token"]=o.messagingToken),o.appCheckToken!==null&&(s["X-Firebase-AppCheck"]=o.appCheckToken);let a=r.timeout||7e4,c=Aee(a),l=yield Promise.race([xee(e,i,s,n.fetchImpl),c.promise,n.cancelAllRequests]);if(c.cancel(),!l)throw new oa("cancelled","Firebase Functions instance was deleted.");let u=Tee(l.status,l.json);if(u)throw u;if(!l.json)throw new oa("internal","Response is not valid JSON object.");let d=l.json.data;if(typeof d>"u"&&(d=l.json.result),typeof d>"u")throw new oa("internal","Response is missing data field.");return{data:Ky(d)}})}var ej="@firebase/functions",tj="0.11.8";var kee="auth-internal",Pee="app-check-internal",Mee="messaging-internal";function Nee(n,e){let t=(r,{instanceIdentifier:i})=>{let s=r.getProvider("app").getImmediate(),o=r.getProvider(kee),a=r.getProvider(Mee),c=r.getProvider(Pee);return new dS(s,o,a,c,i,n)};Yr(new Ln(hS,t,"PUBLIC").setMultipleInstances(!0)),vt(ej,tj,e),vt(ej,tj,"esm2017")}function rj(n=ns(),e=uS){let r=Gs(_t(n),hS).getImmediate({identifier:e}),i=jl("functions");return i&&fS(r,...i),r}function fS(n,e,t){Cee(_t(n),e,t)}function ij(n,e,t){return See(_t(n),e,t)}Nee(fetch.bind(self));var ao=class{constructor(e){return e}},sj="functions",pS=class{constructor(){return Ws(sj)}};var mS=new ue("angularfire2.functions-instances");function Oee(n,e){let t=Ko(sj,n,e);return t&&new ao(t)}function Lee(n){return(e,t)=>{let r=e.runOutsideAngular(()=>n(t));return new ao(r)}}var Fee={provide:pS,deps:[[new kt,mS]]},Vee={provide:ao,useFactory:Oee,deps:[[new kt,mS],Or]};function oj(n,...e){return vt("angularfire",Ci.full,"fn"),Nn([Vee,Fee,{provide:mS,useFactory:Lee(n),multi:!0,deps:[st,On,is,Si,[new kt,Qs],[new kt,rs],...e]}])}var aj=ft(fS,!0),cj=ft(rj,!0),co=ft(ij,!0);function yS(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var _c=yS();function pj(n){_c=n}var mj=/[&<>"']/,jee=new RegExp(mj.source,"g"),gj=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,$ee=new RegExp(gj.source,"g"),Uee={"&":"&","<":"<",">":">",'"':""","'":"'"},uj=n=>Uee[n];function Vr(n,e){if(e){if(mj.test(n))return n.replace(jee,uj)}else if(gj.test(n))return n.replace($ee,uj);return n}var Bee=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function Hee(n){return n.replace(Bee,(e,t)=>(t=t.toLowerCase(),t==="colon"?":":t.charAt(0)==="#"?t.charAt(1)==="x"?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):""))}var qee=/(^|[^\[])\^/g;function pt(n,e){n=typeof n=="string"?n:n.source,e=e||"";let t={replace:(r,i)=>(i=typeof i=="object"&&"source"in i?i.source:i,i=i.replace(qee,"$1"),n=n.replace(r,i),t),getRegex:()=>new RegExp(n,e)};return t}function dj(n){try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}var Xy={exec:()=>null};function hj(n,e){let t=n.replace(/\|/g,(s,o,a)=>{let c=!1,l=o;for(;--l>=0&&a[l]==="\\";)c=!c;return c?"|":" |"}),r=t.split(/ \|/),i=0;if(r[0].trim()||r.shift(),r.length>0&&!r[r.length-1].trim()&&r.pop(),e)if(r.length>e)r.splice(e);else for(;r.length<e;)r.push("");for(;i<r.length;i++)r[i]=r[i].trim().replace(/\\\|/g,"|");return r}function Yy(n,e,t){let r=n.length;if(r===0)return"";let i=0;for(;i<r;){let s=n.charAt(r-i-1);if(s===e&&!t)i++;else if(s!==e&&t)i++;else break}return n.slice(0,r-i)}function zee(n,e){if(n.indexOf(e[1])===-1)return-1;let t=0;for(let r=0;r<n.length;r++)if(n[r]==="\\")r++;else if(n[r]===e[0])t++;else if(n[r]===e[1]&&(t--,t<0))return r;return-1}function fj(n,e,t,r){let i=e.href,s=e.title?Vr(e.title):null,o=n[1].replace(/\\([\[\]])/g,"$1");if(n[0].charAt(0)!=="!"){r.state.inLink=!0;let a={type:"link",raw:t,href:i,title:s,text:o,tokens:r.inlineTokens(o)};return r.state.inLink=!1,a}return{type:"image",raw:t,href:i,title:s,text:Vr(o)}}function Gee(n,e){let t=n.match(/^(\s+)(?:```)/);if(t===null)return e;let r=t[1];return e.split(` 35`).map(i=>{let s=i.match(/^\s+/);if(s===null)return i;let[o]=s;return o.length>
vendor: 8,484 bytes, lines 35-47
35=r.length?i.slice(r.length):i}).join(` 36`)}var yu=class{options;rules;lexer;constructor(e){this.options=e||_c}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let r=t[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?r:Yy(r,` 37`)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let r=t[0],i=Gee(r,t[3]||"");return{type:"code",raw:r,lang:t[2]?t[2].trim().replace(this.rules.inline._escapes,"$1"):t[2],text:i}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let r=t[2].trim();if(/#$/.test(r)){let i=Yy(r,"#");(this.options.pedantic||!i||/ $/.test(i))&&(r=i.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:t[0]}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let r=Yy(t[0].replace(/^ *>[ \t]?/gm,""),` 38`),i=this.lexer.state.top;this.lexer.state.top=!0;let s=this.lexer.blockTokens(r);return this.lexer.state.top=i,{type:"blockquote",raw:t[0],tokens:s,text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){let r=t[1].trim(),i=r.length>1,s={type:"list",raw:"",ordered:i,start:i?+r.slice(0,-1):"",loose:!1,items:[]};r=i?`\\d{1,9}\\${r.slice(-1)}`:`\\${r}`,this.options.pedantic&&(r=i?r:"[*+-]");let o=new RegExp(`^( {0,3}${r})((?:[ ][^\\n]*)?(?:\\n|$))`),a="",c="",l=!1;for(;e;){let u=!1;if(!(t=o.exec(e))||this.rules.block.hr.test(e))break;a=t[0],e=e.substring(a.length);let d=t[2].split(` 39`,1)[0].replace(/^\t+/,E=>" ".repeat(3*E.length)),f=e.split(` 40`,1)[0],p=0;this.options.pedantic?(p=2,c=d.trimStart()):(p=t[2].search(/[^ ]/),p=p>4?1:p,c=d.slice(p),p+=t[1].length);let y=!1;if(!d&&/^ *$/.test(f)&&(a+=f+` 41`,e=e.substring(f.length+1),u=!0),!u){let E=new RegExp(`^ {0,${Math.min(3,p-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),A=new RegExp(`^ {0,${Math.min(3,p-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),x=new RegExp(`^ {0,${Math.min(3,p-1)}}(?:\`\`\`|~~~)`),M=new RegExp(`^ {0,${Math.min(3,p-1)}}#`);for(;e;){let O=e.split(` 42`,1)[0];if(f=O,this.options.pedantic&&(f=f.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),x.test(f)||M.test(f)||E.test(f)||A.test(e))break;if(f.search(/[^ ]/)>=p||!f.trim())c+=` 43`+f.slice(p);else{if(y||d.search(/[^ ]/)>=4||x.test(d)||M.test(d)||A.test(d))break;c+=` 44`+f}!y&&!f.trim()&&(y=!0),a+=O+` 45`,e=e.substring(O.length+1),d=f.slice(p)}}s.loose||(l?s.loose=!0:/\n *\n *$/.test(a)&&(l=!0));let v=null,w;this.options.gfm&&(v=/^\[[ xX]\] /.exec(c),v&&(w=v[0]!=="[ ] ",c=c.replace(/^\[[ xX]\] +/,""))),s.items.push({type:"list_item",raw:a,task:!!v,checked:w,loose:!1,text:c,tokens:[]}),s.raw+=a}s.items[s.items.length-1].raw=a.trimEnd(),s.items[s.items.length-1].text=c.trimEnd(),s.raw=s.raw.trimEnd();for(let u=0;u<s.items.length;u++)if(this.lexer.state.top=!1,s.items[u].tokens=this.lexer.blockTokens(s.items[u].text,[]),!s.loose){let d=s.items[u].tokens.filter(p=>p.type==="space"),f=d.length>0&&d.some(p=>/\n.*\n/.test(p.raw));s.loose=f}if(s.loose)for(let u=0;u<s.items.length;u++)s.items[u].loose=!0;return s}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:"html",block:!0,raw:t[0],pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let r=t[1].toLowerCase().replace(/\s+/g," "),i=t[2]?t[2].replace(/^<(.*)>$/,"$1").replace(this.rules.inline._escapes,"$1"):"",s=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline._escapes,"$1"):t[3];return{type:"def",tag:r,raw:t[0],href:i,title:s}}}table(e){let t=this.rules.block.table.exec(e);if(t){if(!/[:|]/.test(t[2]))return;let r={type:"table",raw:t[0],header:hj(t[1]).map(i=>({text:i,tokens:[]})),align:t[2].replace(/^\||\| *$/g,"").split("|"),rows:t[3]&&t[3].trim()?t[3].replace(/\n[ \t]*$/,"").split(` 46`):[]};if(r.header.length===r.align.length){let i=r.align.length,s,o,a,c;for(s=0;s<i;s++){let l=r.align[s];l&&(/^ *-+: *$/.test(l)?r.align[s]="right":/^ *:-+: *$/.test(l)?r.align[s]="center":/^ *:-+ *$/.test(l)?r.align[s]="left":r.align[s]=null)}for(i=r.rows.length,s=0;s<i;s++)r.rows[s]=hj(r.rows[s],r.header.length).map(l=>({text:l,tokens:[]}));for(i=r.header.length,o=0;o<i;o++)r.header[o].tokens=this.lexer.inline(r.header[o].text);for(i=r.rows.length,o=0;o<i;o++)for(c=r.rows[o],a=0;a<c.length;a++)c[a].tokens=this.lexer.inline(c[a].text);return r}}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:t[2].charAt(0)==="="?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let r=t[1].charAt(t[1].length-1)===` 47`?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:r,tokens:this.lexer.inline(r)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:Vr(t[1])}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&/^<a /i.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let r=t[2].trim();if(!this.options.pedantic&&/^</.test(r)){if(!/>$/.test(r))return;let o=Yy(r.slice(0,-1),"\\");if((r.length-o.length)%2===0)return}else{let o=zee(t[2],"()");if(o>-1){let c=(t[0].indexOf("!")===0?5:4)+t[1].length+o;t[2]=t[2].substring(0,o),t[0]=t[0].substring(0,c).trim(),t[3]=""}}let i=t[2],s="";if(this.options.pedantic){let o=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(i);o&&(i=o[1],s=o[3])}else s=t[3]?t[3].slice(1,-1):"";return i=i.trim(),/^</.test(i)&&(this.options.pedantic&&!/>$/.test(r)?i=i.slice(1):i=i.slice(1,-1)),fj(t,{href:i&&i.replace(this.rules.inline._escapes,"$1"),title:s&&s.replace(this.rules.inline._escapes,"$1")},t[0],this.lexer)}}reflink(e,t){let r;if((r=this.rules.inline.reflink.exec(e))||(r=this.rules.inline.nolink.exec(e))){let i=(r[2]||r[1]).replace(/\s+/g," ");if(i=t[i.toLowerCase()],!i){let s=r[0].charAt(0);return{type:"text",raw:s,text:s}}return fj(r,i,r[0],this.lexer)}}emStrong(e,t,r=""){let i=this.rules.inline.emStrong.lDelim.exec(e);if(!i||i[3]&&r.match(/[\p{L}\p{N}]/u))return;if(!(i[1]||i[2]||"")||!r||this.rules.inline.punctuation.exec(r)){let o=[...i[0]].length-1,a,c,l=o,u=0,d=i[0][0]==="*"?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(d.lastIndex=0,t=t.slice(-1*e.length+o);(i=d.exec(t))!=null;){if(a=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!a)continue;if(c=[...a].length,i[3]||i[4]){l+=c;continue}else if((i[5]||i[6])&&o%3&&!((o+c)%3)){u+=c;continue}if(l-=c,l>0)continue;c=Math.min(c,c+l+u);let f=[...i[0]][0].length,p=e.slice(0,o+i.index+f+c);if(Math.min(o,c)%2){let v=p.slice(1,-1);return{type:"em",raw:p,text:v,tokens:this.lexer.inlineTokens(v)}}let y=p.slice(2,-2);return{type:"strong",raw:p,text:y,tokens:this.lexer.inlineTokens(y)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let r=t[2].replace(/\n/g," "),i=/[^ ]/.test(r),s=/^ /.test(r)&&/ $/.test(r);return i&&s&&(r=r.substring(1,r.length-1)),r=Vr(r,!0),{type:"codespan",raw:t[0],text:r}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){let t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let r,i;return t[2]==="@"?(r=Vr(t[1]),i="mailto:"+r):(r=Vr(t[1]),i=r),{type:"link",raw:t[0],text:r,href:i,tokens:[{type:"text",raw:r,text:r}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let r,i;if(t[2]==="@")r=Vr(t[0]),i="mailto:"+r;else{let s;do s=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])[0];while(s!==t[0]);r=Vr(t[0]),t[1]==="www."?i="http://"+t[0]:i=t[0]}return{type:"link",raw:t[0],text:r,href:i,tokens:[{type:"text",raw:r,text:r}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let r;return this.lexer.state.inRawBlock?r=t[0]:r=Vr(t[0]),{type:"text",raw:t[0],text:r}}}},ve={newline:/^(?: *(?:\n|$))+/,code:/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,fences:/^ {0,3}(`{3,}
47(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,hr:/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/,html:"^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))",def:/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/,table:Xy,lheading:/^(?!bull )((?:.|\n(?!\s*?\n|bull ))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};ve._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/;ve._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/;ve.def=pt(ve.def).replace("label",ve._label).replace("title",ve._title).getRegex();ve.bullet=/(?:[*+-]|\d{1,9}[.)])/;ve.listItemStart=pt(/^( *)(bull) */).replace("bull",ve.bullet).getRegex();ve.list=pt(ve.list).replace(/bull/g,ve.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+ve.def.source+")").getRegex();ve._tag="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul";ve._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/;ve.html=pt(ve.html,"i").replace("comment",ve._comment).replace("tag",ve._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();ve.lheading=pt(ve.lheading).replace(/bull/g,ve.bullet).getRegex();ve.paragraph=pt(ve._paragraph).replace("hr",ve.hr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ve._tag).getRegex();ve.blockquote=pt(ve.blockquote).replace("paragraph",ve.paragraph).getRegex();ve.normal=_({},ve);ve.gfm=D(_({},ve.normal),{table:"^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"});ve.gfm.table=pt(ve.gfm.table).replace("hr",ve.hr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ve._tag).getRegex();ve.gfm.paragraph=pt(ve._paragraph).replace("hr",ve.hr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",ve.gfm.table).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ve._tag).getRegex();ve.pedantic=D(_({},ve.normal),{html:pt(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",ve._comment).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Xy,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:pt(ve.normal._paragraph).replace("hr",ve.hr).replace("heading",` *#{1,6} *[^ 48]`).replace("lheading",ve.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()});var ee={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:Xy,tag:"^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",link:/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,reflink:/^!?\[(label)\]\[(ref)\]/,nolink:/^!?\[(ref)\](?:\[\])?/,reflinkSearch:"reflink|nolink(?!\\()",emStrong:{lDelim:/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/,rDelimAst:/^[^_*]*?__[^_*]*?\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\*)[punct](\*+)(?=[\s]|$)|[^punct\s](\*+)(?!\*)(?=[punct\s]|$)|(?!\*)[punct\s](\*+)(?=[^punct\s])|[\s](\*+)(?!\*)(?=[punct])|(?!\*)[punct](\*+)(?!\*)(?=[punct])|[^punct\s](\*+)(?=[^punct\s])/,rDelimUnd:/^[^_*]*?\*\*[^_*]*?_[^_*]*?(?=\*\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\s]|$)|[^punct\s](_+)(?!_)(?=[punct\s]|$)|(?!_)[punct\s](_+)(?=[^punct\s])|[\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])/},code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br:/^( {2,}|\\)\n(?!\s*$)/,del:Xy,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^((?![*_])[\spunctuation])/};ee._punctuation="\\p{P}$+<=>`^|~";ee.punctuation=pt(ee.punctuation,"u").replace(/punctuation/g,ee._punctuation).getRegex();ee.blockSkip=/\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g;ee.anyPunctuation=/\\[punct]/g;ee._escapes=/\\([punct])/g;ee._comment=pt(ve._comment).replace("(?:-->|$)","-->").getRegex();ee.emStrong.lDelim=pt(ee.emStrong.lDelim,"u").replace(/punct/g,ee._punctuation).getRegex();ee.emStrong.rDelimAst=pt(ee.emStrong.rDelimAst,"gu").replace(/punct/g,ee._punctuation).getRegex();ee.emStrong.rDelimUnd=pt(ee.emStrong.rDelimUnd,"gu").replace(/punct/g,ee._punctuation).getRegex();ee.anyPunctuation=pt(ee.anyPunctuation,"gu").replace(/punct/g,ee._punctuation).getRegex();ee._escapes=pt(ee._escapes,"gu").replace(/punct/g,ee._punctuation).getRegex();ee._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/;ee._email=/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/;ee.autolink=pt(ee.autolink).replace("scheme",ee._scheme).replace("email",ee._email).getRegex();ee._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/;ee.tag=pt(ee.tag).replace("comment",ee._comment).replace("attribute",ee._attribute).getRegex();ee._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;ee._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/;ee._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/;ee.link=pt(ee.link).replace("label",ee._label).replace("href",ee._href).replace("title",ee._title).getRegex();ee.reflink=pt(ee.reflink).replace("label",ee._label).replace("ref",ve._label).getRegex();ee.nolink=pt(ee.nolink).replace("ref",ve._label).getRegex();ee.reflinkSearch=pt(ee.reflinkSearch,"g").replace("reflink",ee.reflink).replace("nolink",ee.nolink).getRegex();ee.normal=_({},ee);ee.pedantic=D(_({},ee.normal),{strong:{start:/^__|\*\*/,middle:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,endAst:/\*\*(?!\*)/g,endUnd:/__(?!_)/g},em:{start:/^_|\*/,middle:/^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,endAst:/\*(?!\*)/g,endUnd:/_(?!_)/g},link:pt(/^!?\[(label)\]\((.*?)\)/).replace("label",ee._label).getRegex(),reflink:pt(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",ee._label).getRegex()});ee.gfm=D(_({},ee.normal),{escape:pt(ee.escape).replace("])","~|])").getRegex(),_extended_email:/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,url:/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/});ee.gfm.url=pt(ee.gfm.url,"i").replace("email",ee.gfm._extended_email).getRegex();ee.breaks=D(_({},ee.gfm),{br:pt(ee.br).replace("{2,}","*").getRegex(),text:pt(ee.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()});var lo=class n{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||_c,this.options.tokenizer=this.options.tokenizer||new yu,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={block:ve.normal,inline:ee.normal};this.options.pedantic?(t.block=ve.pedantic,t.inline=ee.pedantic):this.options.gfm&&(t.block=ve.gfm,this.options.breaks?t.inline=ee.breaks:t.inline=ee.gfm),this.tokenizer.rules=t}static get rules(){return{block:ve,inline:ee}}static lex(e,t){return new n(t).lex(e)}static lexInline(e,t){return new n(t).inlineTokens(e)}lex(e){e=e.replace(/\r\n|\r/g,` 49`),this.blockTokens(e,this.tokens);let t;for(;
vendor: 14,894 bytes, lines 49-78
49t=this.inlineQueue.shift();)this.inlineTokens(t.src,t.tokens);return this.tokens}blockTokens(e,t=[]){this.options.pedantic?e=e.replace(/\t/g," ").replace(/^ +$/gm,""):e=e.replace(/^( *)(\t+)/gm,(a,c,l)=>c+" ".repeat(l.length));let r,i,s,o;for(;e;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some(a=>(r=a.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))){if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length),r.raw.length===1&&t.length>0?t[t.length-1].raw+=` 50`:t.push(r);continue}if(r=this.tokenizer.code(e)){e=e.substring(r.raw.length),i=t[t.length-1],i&&(i.type==="paragraph"||i.type==="text")?(i.raw+=` 51`+r.raw,i.text+=` 52`+r.text,this.inlineQueue[this.inlineQueue.length-1].src=i.text):t.push(r);continue}if(r=this.tokenizer.fences(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.heading(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.hr(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.blockquote(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.list(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.html(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.def(e)){e=e.substring(r.raw.length),i=t[t.length-1],i&&(i.type==="paragraph"||i.type==="text")?(i.raw+=` 53`+r.raw,i.text+=` 54`+r.raw,this.inlineQueue[this.inlineQueue.length-1].src=i.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title});continue}if(r=this.tokenizer.table(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.lheading(e)){e=e.substring(r.raw.length),t.push(r);continue}if(s=e,this.options.extensions&&this.options.extensions.startBlock){let a=1/0,c=e.slice(1),l;this.options.extensions.startBlock.forEach(u=>{l=u.call({lexer:this},c),typeof l=="number"&&l>=0&&(a=Math.min(a,l))}),a<1/0&&a>=0&&(s=e.substring(0,a+1))}if(this.state.top&&(r=this.tokenizer.paragraph(s))){i=t[t.length-1],o&&i.type==="paragraph"?(i.raw+=` 55`+r.raw,i.text+=` 56`+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=i.text):t.push(r),o=s.length!==e.length,e=e.substring(r.raw.length);continue}if(r=this.tokenizer.text(e)){e=e.substring(r.raw.length),i=t[t.length-1],i&&i.type==="text"?(i.raw+=` 57`+r.raw,i.text+=` 58`+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=i.text):t.push(r);continue}if(e){let a="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(a);break}else throw new Error(a)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let r,i,s,o=e,a,c,l;if(this.tokens.links){let u=Object.keys(this.tokens.links);if(u.length>0)for(;(a=this.tokenizer.rules.inline.reflinkSearch.exec(o))!=null;)u.includes(a[0].slice(a[0].lastIndexOf("[")+1,-1))&&(o=o.slice(0,a.index)+"["+"a".repeat(a[0].length-2)+"]"+o.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(a=this.tokenizer.rules.inline.blockSkip.exec(o))!=null;)o=o.slice(0,a.index)+"["+"a".repeat(a[0].length-2)+"]"+o.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(a=this.tokenizer.rules.inline.anyPunctuation.exec(o))!=null;)o=o.slice(0,a.index)+"++"+o.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;e;)if(c||(l=""),c=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(u=>(r=u.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))){if(r=this.tokenizer.escape(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.tag(e)){e=e.substring(r.raw.length),i=t[t.length-1],i&&r.type==="text"&&i.type==="text"?(i.raw+=r.raw,i.text+=r.text):t.push(r);continue}if(r=this.tokenizer.link(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(r.raw.length),i=t[t.length-1],i&&r.type==="text"&&i.type==="text"?(i.raw+=r.raw,i.text+=r.text):t.push(r);continue}if(r=this.tokenizer.emStrong(e,o,l)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.codespan(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.br(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.del(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.autolink(e)){e=e.substring(r.raw.length),t.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(e))){e=e.substring(r.raw.length),t.push(r);continue}if(s=e,this.options.extensions&&this.options.extensions.startInline){let u=1/0,d=e.slice(1),f;this.options.extensions.startInline.forEach(p=>{f=p.call({lexer:this},d),typeof f=="number"&&f>=0&&(u=Math.min(u,f))}),u<1/0&&u>=0&&(s=e.substring(0,u+1))}if(r=this.tokenizer.inlineText(s)){e=e.substring(r.raw.length),r.raw.slice(-1)!=="_"&&(l=r.raw.slice(-1)),c=!0,i=t[t.length-1],i&&i.type==="text"?(i.raw+=r.raw,i.text+=r.text):t.push(r);continue}if(e){let u="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(u);break}else throw new Error(u)}}return t}},Qr=class{options;constructor(e){this.options=e||_c}code(e,t,r){let i=(t||"").match(/^\S*/)?.[0];return e=e.replace(/\n$/,"")+` 59`,i?'<pre><code class="language-'+Vr(i)+'">'+(r?e:Vr(e,!0))+`</code></pre> 60`:"<pre><code>"+(r?e:Vr(e,!0))+`</code></pre> 61`}blockquote(e){return`<blockquote> 62${e}</blockquote> 63`}html(e,t){return e}heading(e,t,r){return`<h${t}>${e}</h${t}> 64`}hr(){return`<hr> 65`}list(e,t,r){let i=t?"ol":"ul",s=t&&r!==1?' start="'+r+'"':"";return"<"+i+s+`> 66`+e+"</"+i+`> 67`}listitem(e,t,r){return`<li>${e}</li> 68`}checkbox(e){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph(e){return`<p>${e}</p> 69`}table(e,t){return t&&(t=`<tbody>${t}</tbody>`),`<table> 70<thead> 71`+e+`</thead> 72`+t+`</table> 73`}tablerow(e){return`<tr> 74${e}</tr> 75`}tablecell(e,t){let r=t.header?"th":"td";return(t.align?`<${r} align="${t.align}">`:`<${r}>`)+e+`</${r}> 76`}strong(e){return`<strong>${e}</strong>`}em(e){return`<em>${e}</em>`}codespan(e){return`<code>${e}</code>`}br(){return"<br>"}del(e){return`<del>${e}</del>`}link(e,t,r){let i=dj(e);if(i===null)return r;e=i;let s='<a href="'+e+'"';return t&&(s+=' title="'+t+'"'),s+=">"+r+"</a>",s}image(e,t,r){let i=dj(e);if(i===null)return r;e=i;let s=`<img src="${e}" alt="${r}"`;return t&&(s+=` title="${t}"`),s+=">",s}text(e){return e}},Gh=class{strong(e){return e}em(e){return e}codespan(e){return e}del(e){return e}html(e){return e}text(e){return e}link(e,t,r){return""+r}image(e,t,r){return""+r}br(){return""}},uo=class n{options;renderer;textRenderer;constructor(e){this.options=e||_c,this.options.renderer=this.options.renderer||new Qr,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new Gh}static parse(e,t){return new n(t).parse(e)}static parseInline(e,t){return new n(t).parseInline(e)}parse(e,t=!0){let r="";for(let i=0;i<e.length;i++){let s=e[i];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[s.type]){let o=s,a=this.options.extensions.renderers[o.type].call({parser:this},o);if(a!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(o.type)){r+=a||"";continue}}switch(s.type){case"space":continue;case"hr":{r+=this.renderer.hr();continue}case"heading":{let o=s;r+=this.renderer.heading(this.parseInline(o.tokens),o.depth,Hee(this.parseInline(o.tokens,this.textRenderer)));continue}case"code":{let o=s;r+=this.renderer.code(o.text,o.lang,!!o.escaped);continue}case"table":{let o=s,a="",c="";for(let u=0;u<o.header.length;u++)c+=this.renderer.tablecell(this.parseInline(o.header[u].tokens),{header:!0,align:o.align[u]});a+=this.renderer.tablerow(c);let l="";for(let u=0;u<o.rows.length;u++){let d=o.rows[u];c="";for(let f=0;f<d.length;f++)c+=this.renderer.tablecell(this.parseInline(d[f].tokens),{header:!1,align:o.align[f]});l+=this.renderer.tablerow(c)}r+=this.renderer.table(a,l);continue}case"blockquote":{let o=s,a=this.parse(o.tokens);r+=this.renderer.blockquote(a);continue}case"list":{let o=s,a=o.ordered,c=o.start,l=o.loose,u="";for(let d=0;d<o.items.length;d++){let f=o.items[d],p=f.checked,y=f.task,v="";if(f.task){let w=this.renderer.checkbox(!!p);l?f.tokens.length>0&&f.tokens[0].type==="paragraph"?(f.tokens[0].text=w+" "+f.tokens[0].text,f.tokens[0].tokens&&f.tokens[0].tokens.length>0&&f.tokens[0].tokens[0].type==="text"&&(f.tokens[0].tokens[0].text=w+" "+f.tokens[0].tokens[0].text)):f.tokens.unshift({type:"text",text:w+" "}):v+=w+" "}v+=this.parse(f.tokens,l),u+=this.renderer.listitem(v,y,!!p)}r+=this.renderer.list(u,a,c);continue}case"html":{let o=s;r+=this.renderer.html(o.text,o.block);continue}case"paragraph":{let o=s;r+=this.renderer.paragraph(this.parseInline(o.tokens));continue}case"text":{let o=s,a=o.tokens?this.parseInline(o.tokens):o.text;for(;i+1<e.length&&e[i+1].type==="text";)o=e[++i],a+=` 77`+(o.tokens?this.parseInline(o.tokens):o.text);r+=t?this.renderer.paragraph(a):a;continue}default:{let o='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return r}parseInline(e,t){t=t||this.renderer;let r="";for(let i=0;i<e.length;i++){let s=e[i];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[s.type]){let o=this.options.extensions.renderers[s.type].call({parser:this},s);if(o!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type)){r+=o||"";continue}}switch(s.type){case"escape":{let o=s;r+=t.text(o.text);break}case"html":{let o=s;r+=t.html(o.text);break}case"link":{let o=s;r+=t.link(o.href,o.title,this.parseInline(o.tokens,t));break}case"image":{let o=s;r+=t.image(o.href,o.title,o.text);break}case"strong":{let o=s;r+=t.strong(this.parseInline(o.tokens,t));break}case"em":{let o=s;r+=t.em(this.parseInline(o.tokens,t));break}case"codespan":{let o=s;r+=t.codespan(o.text);break}case"br":{r+=t.br();break}case"del":{let o=s;r+=t.del(this.parseInline(o.tokens,t));break}case"text":{let o=s;r+=t.text(o.text);break}default:{let o='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return r}},gu=class{options;constructor(e){this.options=e||_c}static passThroughHooks=new Set(["preprocess","postprocess"]);preprocess(e){return e}postprocess(e){return e}},gS=class{defaults=yS();options=this.setOptions;parse=this.#e(lo.lex,uo.parse);parseInline=this.#e(lo.lexInline,uo.parseInline);Parser=uo;Renderer=Qr;TextRenderer=Gh;Lexer=lo;Tokenizer=yu;Hooks=gu;constructor(...e){this.use(...e)}walkTokens(e,t){let r=[];for(let i of e)switch(r=r.concat(t.call(this,i)),i.type){case"table":{let s=i;for(let o of s.header)r=r.concat(this.walkTokens(o.tokens,t));for(let o of s.rows)for(let a of o)r=r.concat(this.walkTokens(a.tokens,t));break}case"list":{let s=i;r=r.concat(this.walkTokens(s.items,t));break}default:{let s=i;this.defaults.extensions?.childTokens?.[s.type]?this.defaults.extensions.childTokens[s.type].forEach(o=>{r=r.concat(this.walkTokens(s[o],t))}):s.tokens&&(r=r.concat(this.walkTokens(s.tokens,t)))}}return r}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(r=>{let i=_({},r);if(i.async=this.defaults.async||i.async||!1,r.extensions&&(r.extensions.forEach(s=>{if(!s.name)throw new Error("extension name required");if("renderer"in s){let o=t.renderers[s.name];o?t.renderers[s.name]=function(...a){let c=s.renderer.apply(this,a);return c===!1&&(c=o.apply(this,a)),c}:t.renderers[s.name]=s.renderer}if("tokenizer"in s){if(!s.level||s.level!=="block"&&s.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let o=t[s.level];o?o.unshift(s.tokenizer):t[s.level]=[s.tokenizer],s.start&&(s.level==="block"?t.startBlock?t.startBlock.push(s.start):t.startBlock=[s.start]:s.level==="inline"&&(t.startInline?t.startInline.push(s.start):t.startInline=[s.start]))}"childTokens"in s&&s.childTokens&&(t.childTokens[s.name]=s.childTokens)}),i.extensions=t),r.renderer){let s=this.defaults.renderer||new Qr(this.defaults);for(let o in r.renderer){let a=r.renderer[o],c=o,l=s[c];s[c]=(...u)=>{let d=a.apply(s,u);return d===!1&&(d=l.apply(s,u)),d||""}}i.renderer=s}if(r.tokenizer){let s=this.defaults.tokenizer||new yu(this.defaults);for(let o in r.tokenizer){let a=r.tokenizer[o],c=o,l=s[c];s[c]=(...u)=>{let d=a.apply(s,u);return d===!1&&(d=l.apply(s,u)),d}}i.tokenizer=s}if(r.hooks){let s=this.defaults.hooks||new gu;for(let o in r.hooks){let a=r.hooks[o],c=o,l=s[c];gu.passThroughHooks.has(o)?s[c]=u=>{if(this.defaults.async)return Promise.resolve(a.call(s,u)).then(f=>l.call(s,f));let d=a.call(s,u);return l.call(s,d)}:s[c]=(...u)=>{let d=a.apply(s,u);return d===!1&&(d=l.apply(s,u)),d}}i.hooks=s}if(r.walkTokens){let s=this.defaults.walkTokens,o=r.walkTokens;i.walkTokens=function(a){let c=[];return c.push(o.call(this,a)),s&&(c=c.concat(s.call(this,a))),c}}this.defaults=_(_({},this.defaults),i)}),this}setOptions(e){return this.defaults=_(_({},this.defaults),e),this}lexer(e,t){return lo.lex(e,t??this.defaults)}parser(e,t){return uo.parse(e,t??this.defaults)}#e(e,t){return(r,i)=>{let s=_({},i),o=_(_({},this.defaults),s);this.defaults.async===!0&&s.async===!1&&(o.silent||console.warn("marked(): The async option was set to true by an extension. The async: false option sent to parse will be ignored."),o.async=!0);let a=this.#t(!!o.silent,!!o.async);if(typeof r>"u"||r===null)return a(new Error("marked(): input parameter is undefined or null"));if(typeof r!="string")return a(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(r)+", string expected"));if(o.hooks&&(o.hooks.options=o),o.async)return Promise.resolve(o.hooks?o.hooks.preprocess(r):r).then(c=>e(c,o)).then(c=>o.walkTokens?Promise.all(this.walkTokens(c,o.walkTokens)).then(()=>c):c).then(c=>t(c,o)).then(c=>o.hooks?o.hooks.postprocess(c):c).catch(a);try{o.hooks&&(r=o.hooks.preprocess(r));let c=e(r,o);o.walkTokens&&this.walkTokens(c,o.walkTokens);let l=t(c,o);return o.hooks&&(l=o.hooks.postprocess(l)),l}catch(c){return a(c)}}}#t(e,t){return r=>{if(r.message+=` 78Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error occurred:</p><pre>"+Vr(r.message+"",!0)+"</pre>";return t?Promise.resolve(i):i}if(t)return Promise.reject(r);throw r}}},yc=new gS;function ct(n,e){return yc.parse(n,e)}ct.options=ct.setOptions=function(n){return yc.setOptions(n),ct.defaults=yc.defaults,pj(ct.defaults),ct};ct.getDefaults=yS;ct.defaults=_c;ct.use=function(...n){return yc.use(...n),ct.defaults=yc.defaults,pj(ct.defaults),ct};ct.walkTokens=function(n,e){return yc.walkTokens(n,e)};ct.parseInline=yc.parseInline;ct.Parser=uo;ct.parser=uo.parse;ct.Renderer=Qr;ct.TextRenderer=Gh;ct.Lexer=lo;ct.lexer=lo.lex;ct.Tokenizer=yu;ct.Hooks=gu;ct.parse=ct;
78var uEe=ct.options,dEe=ct.setOptions,hEe=ct.use,fEe=ct.walkTokens,pEe=ct.parseInline;var mEe=uo.parse,gEe=lo.lex;var Wee=["*"],Kee="Copy",Yee="Copied",Xee=(()=>{class n{constructor(){this._buttonClick$=new mt,this.copied$=this._buttonClick$.pipe(Jn(()=>tw(Ae(!0),ew(3e3).pipe(ud(!1)))),nw(),ow(1)),this.copiedText$=this.copied$.pipe(dd(!1),ke(t=>t?Yee:Kee))}onCopyToClipboardClick(){this._buttonClick$.next()}static{this.\u0275fac=function(r){return new(r||n)}}static{this.\u0275cmp=xr({type:n,selectors:[["markdown-clipboard"]],standalone:!0,features:[Pr],decls:4,vars:7,consts:[[1,"markdown-clipboard-button",3,"click"]],template:function(r,i){r&1&&(F(0,"button",0),Yi(1,"async"),_e("click",function(){return i.onCopyToClipboardClick()}),H(2),Yi(3,"async"),L()),r&2&&(kr("copied",Xi(1,3,i.copied$)),j(2),Zt(Xi(3,5,i.copiedText$)))},dependencies:[Km],encapsulation:2,changeDetection:0})}}return n})(),Qee=new ue("CLIPBOARD_OPTIONS");var _S=function(n){return n.CommandLine="command-line",n.LineHighlight="line-highlight",n.LineNumbers="line-numbers",n}(_S||{}),_j=new ue("MARKED_EXTENSIONS"),vS=new ue("MARKED_OPTIONS"),Zee="[ngx-markdown] When using the `emoji` attribute you *have to* include Emoji-Toolkit files to `angular.json` or use imports. See README for more information",Jee="[ngx-markdown] When using the `katex` attribute you *have to* include KaTeX files to `angular.json` or use imports. See README for more information",ete="[ngx-markdown] When using the `mermaid` attribute you *have to* include Mermaid files to `angular.json` or use imports. See README for more information",tte="[ngx-markdown] When using the `clipboard` attribute you *have to* include Clipboard files to `angular.json` or use imports. See README for more information",nte="[ngx-markdown] When using the `clipboard` attribute you *have to* provide the `viewContainerRef` parameter to `MarkdownService.render()` function",rte="[ngx-markdown] When using the `src` attribute you *have to* pass the `HttpClient` as a parameter of the `forRoot` method. See README for more information",vj=new ue("SECURITY_CONTEXT");var bj=(()=>{class n{get options(){return this._options}set options(t){this._options=_(_({},this.DEFAULT_MARKED_OPTIONS),t)}get renderer(){return this.options.renderer}set renderer(t){this.options.renderer=t}constructor(t,r,i,s,o,a,c){this.clipboardOptions=t,this.extensions=r,this.platform=s,this.securityContext=o,this.http=a,this.sanitizer=c,this.DEFAULT_MARKED_OPTIONS={renderer:new Qr},this.DEFAULT_KATEX_OPTIONS={delimiters:[{left:"$$",right:"$$",display:!0},{left:"$",right:"$",display:!1},{left:"\\(",right:"\\)",display:!1},{left:"\\begin{equation}",right:"\\end{equation}",display:!0},{left:"\\begin{align}",right:"\\end{align}",display:!0},{left:"\\begin{alignat}",right:"\\end{alignat}",display:!0},{left:"\\begin{gather}",right:"\\end{gather}",display:!0},{left:"\\begin{CD}",right:"\\end{CD}",display:!0},{left:"\\[",right:"\\]",display:!0}]},this.DEFAULT_MERMAID_OPTIONS={startOnLoad:!1},this.DEFAULT_CLIPBOARD_OPTIONS={buttonComponent:void 0},this.DEFAULT_PARSE_OPTIONS={decodeHtml:!1,inline:!1,emoji:!1,mermaid:!1,markedOptions:void 0,disableSanitizer:!1},this.DEFAULT_RENDER_OPTIONS={clipboard:!1,clipboardOptions:void 0,katex:!1,katexOptions:void 0,mermaid:!1,mermaidOptions:void 0},this._reload$=new mt,this.reload$=this._reload$.asObservable(),this.options=i}parse(t,r=this.DEFAULT_PARSE_OPTIONS){let{decodeHtml:i,inline:s,emoji:o,mermaid:a,disableSanitizer:c}=r,l=_(_({},this.options),r.markedOptions),u=l.renderer||this.renderer||new Qr;this.extensions&&(this.renderer=this.extendsRendererForExtensions(u)),a&&(this.renderer=this.extendsRendererForMermaid(u));let d=this.trimIndentation(t),f=i?this.decodeHtml(d):d,p=o?this.parseEmoji(f):f,y=this.parseMarked(p,l,s);return(c?y:this.sanitizer.sanitize(this.securityContext,y))||""}render(t,r=this.DEFAULT_RENDER_OPTIONS,i){let{clipboard:s,clipboardOptions:o,katex:a,katexOptions:c,mermaid:l,mermaidOptions:u}=r;s&&this.renderClipboard(t,i,_(_(_({},this.DEFAULT_CLIPBOARD_OPTIONS),this.clipboardOptions),o)),a&&this.renderKatex(t,_(_({},this.DEFAULT_KATEX_OPTIONS),c)),l&&this.renderMermaid(t,_(_({},this.DEFAULT_MERMAID_OPTIONS),u)),this.highlight(t)}reload(){this._reload$.next()}getSource(t){if(!this.http)throw new Error(rte);return this.http.get(t,{responseType:"text"}).pipe(ke(r=>this.handleExtension(t,r)))}highlight(t){if(!za(this.platform)||typeof Prism>"u"||typeof Prism.highlightAllUnder>"u")return;t||(t=document);let r=t.querySelectorAll('pre code:not([class*="language-"])');Array.prototype.forEach.call(r,i=>i.classList.add("language-none")),Prism.highlightAllUnder(t)}decodeHtml(t){if(!za(this.platform))return t;let r=document.createElement("textarea");return r.innerHTML=t,r.value}extendsRendererForExtensions(t){let r=t;return r.\u0275NgxMarkdownRendererExtendedForExtensions===!0||(this.extensions?.length>0&&ct.use(...this.extensions),r.\u0275NgxMarkdownRendererExtendedForExtensions=!0),t}extendsRendererForMermaid(t){let r=t;if(r.\u0275NgxMarkdownRendererExtendedForMermaid===!0)return t;let i=t.code;return t.code=function(s,o,a){return o==="mermaid"?`<div class="mermaid">${s}</div>`:i.call(this,s,o,a)},r.\u0275NgxMarkdownRendererExtendedForMermaid=!0,t}handleExtension(t,r){let i=t.lastIndexOf("://"),s=i>-1?t.substring(i+4):t,o=s.lastIndexOf("/"),a=o>-1?s.substring(o+1).split("?")[0]:"",c=a.lastIndexOf("."),l=c>-1?a.substring(c+1):"";return l&&l!=="md"?"```"+l+` 79`+r+"\n```":r}parseMarked(t,r,i=!1){return r.renderer&&(ct.use({renderer:r.renderer}),delete r.renderer),i?ct.parseInline(t,r):ct.parse(t,r)}parseEmoji(t){if(!za(this.platform))return t;if(typeof joypixels>"u"||typeof joypixels.shortnameToUnicode>"u")throw new Error(Zee);return joypixels.shortnameToUnicode(t)}renderKatex(t,r){if(za(this.platform)){if(typeof katex>"u"||typeof renderMathInElement>"u")throw new Error(Jee);renderMathInElement(t,r)}}renderClipboard(t,r,i){if(!za(this.platform))return;if(typeof ClipboardJS>"u")throw new Error(tte);if(!r)throw new Error(nte);let{buttonComponent:s,buttonTemplate:o}=i,a=t.querySelectorAll("pre");for(let c=0;c<a.length;c++){let l=a.item(c),u=document.createElement("div");u.style.position="relative",l.parentNode.insertBefore(u,l),u.appendChild(l);let d=document.createElement("div");d.style.position="absolute",d.style.top=".5em",d.style.right=".5em",d.style.opacity="0",d.style.transition="opacity 250ms ease-out",u.insertAdjacentElement("beforeend",d),l.onmouseover=()=>d.style.opacity="1",l.onmouseout=()=>d.style.opacity="0";let f;s?f=r.createComponent(s).hostView:o?f=r.createEmbeddedView(o):f=r.createComponent(Xee).hostView;let p;
79f.rootNodes.forEach(y=>{y.onmouseover=()=>d.style.opacity="1",d.appendChild(y),p=new ClipboardJS(y,{text:()=>l.innerText})}),f.onDestroy(()=>p.destroy())}}renderMermaid(t,r=this.DEFAULT_MERMAID_OPTIONS){if(!za(this.platform))return;if(typeof mermaid>"u"||typeof mermaid.initialize>"u")throw new Error(ete);let i=t.querySelectorAll(".mermaid");i.length!==0&&(mermaid.initialize(r),mermaid.run({nodes:i}))}trimIndentation(t){if(!t)return"";let r;return t.split(` 80`).map(i=>{let s=r;return i.length>0&&(s=isNaN(s)?i.search(/\S|$/):Math.min(i.search(/\S|$/),s)),isNaN(r)&&(r=s),s?i.substring(s):i}).join(` 81`)}static{this.\u0275fac=function(r){return new(r||n)(Y(Qee,8),Y(_j,8),Y(vS,8),Y(Gr),Y(vj),Y(RE,8),Y(VE))}}static{this.\u0275prov=Q({token:n,factory:n.\u0275fac})}}return n})(),wj=(()=>{class n{get disableSanitizer(){return this._disableSanitizer}set disableSanitizer(t){this._disableSanitizer=this.coerceBooleanProperty(t)}get inline(){return this._inline}set inline(t){this._inline=this.coerceBooleanProperty(t)}get clipboard(){return this._clipboard}set clipboard(t){this._clipboard=this.coerceBooleanProperty(t)}get emoji(){return this._emoji}set emoji(t){this._emoji=this.coerceBooleanProperty(t)}get katex(){return this._katex}set katex(t){this._katex=this.coerceBooleanProperty(t)}get mermaid(){return this._mermaid}set mermaid(t){this._mermaid=this.coerceBooleanProperty(t)}get lineHighlight(){return this._lineHighlight}set lineHighlight(t){this._lineHighlight=this.coerceBooleanProperty(t)}get lineNumbers(){return this._lineNumbers}set lineNumbers(t){this._lineNumbers=this.coerceBooleanProperty(t)}get commandLine(){return this._commandLine}set commandLine(t){this._commandLine=this.coerceBooleanProperty(t)}constructor(t,r,i){this.element=t,this.markdownService=r,this.viewContainerRef=i,this.error=new $t,this.load=new $t,this.ready=new $t,this._clipboard=!1,this._commandLine=!1,this._disableSanitizer=!1,this._emoji=!1,this._inline=!1,this._katex=!1,this._lineHighlight=!1,this._lineNumbers=!1,this._mermaid=!1,this.destroyed$=new mt}ngOnChanges(){this.loadContent()}loadContent(){if(this.data!=null){this.handleData();return}if(this.src!=null){this.handleSrc();return}}ngAfterViewInit(){!this.data&&!this.src&&this.handleTransclusion(),this.markdownService.reload$.pipe(pi(this.destroyed$)).subscribe(()=>this.loadContent())}ngOnDestroy(){this.destroyed$.next(),this.destroyed$.complete()}render(t,r=!1){return m(this,null,function*(){let i={decodeHtml:r,inline:this.inline,emoji:this.emoji,mermaid:this.mermaid,disableSanitizer:this.disableSanitizer},s={clipboard:this.clipboard,clipboardOptions:{buttonComponent:this.clipboardButtonComponent,buttonTemplate:this.clipboardButtonTemplate},katex:this.katex,katexOptions:this.katexOptions,mermaid:this.mermaid,mermaidOptions:this.mermaidOptions},o=yield this.markdownService.parse(t,i);this.element.nativeElement.innerHTML=o,this.handlePlugins(),this.markdownService.render(this.element.nativeElement,s,this.viewContainerRef),this.ready.emit()})}coerceBooleanProperty(t){return t!=null&&`${String(t)}`!="false"}handleData(){this.render(this.data)}handleSrc(){this.markdownService.getSource(this.src).subscribe({next:t=>{this.render(t).then(()=>{this.load.emit(t)})},error:t=>this.error.emit(t)})}handleTransclusion(){this.render(this.element.nativeElement.innerHTML,!0)}handlePlugins(){this.commandLine&&(this.setPluginClass(this.element.nativeElement,_S.CommandLine),this.setPluginOptions(this.element.nativeElement,{dataFilterOutput:this.filterOutput,dataHost:this.host,dataPrompt:this.prompt,dataOutput:this.output,dataUser:this.user})),this.lineHighlight&&this.setPluginOptions(this.element.nativeElement,{dataLine:this.line,dataLineOffset:this.lineOffset}),this.lineNumbers&&(this.setPluginClass(this.element.nativeElement,_S.LineNumbers),this.setPluginOptions(this.element.nativeElement,{dataStart:this.start}))}setPluginClass(t,r){let i=t.querySelectorAll("pre");for(let s=0;s<i.length;s++){let o=r instanceof Array?r:[r];i.item(s).classList.add(...o)}}setPluginOptions(t,r){let i=t.querySelectorAll("pre");for(let s=0;s<i.length;s++)Object.keys(r).forEach(o=>{let a=r[o];if(a){let c=this.toLispCase(o);i.item(s).setAttribute(c,a.toString())}})}toLispCase(t){let r=t.match(/([A-Z])/g);if(!r)return t;let i=t.toString();for(let s=0,o=r.length;s<o;s++)i=i.replace(new RegExp(r[s]),"-"+r[s].toLowerCase());return i.slice(0,1)==="-"&&(i=i.slice(1)),i}static{this.\u0275fac=function(r){return new(r||n)(oe(nr),oe(bj),oe(Ti))}}static{this.\u0275cmp=xr({type:n,selectors:[["markdown"],["","markdown",""]],inputs:{data:"data",src:"src",disableSanitizer:"disableSanitizer",inline:"inline",clipboard:"clipboard",clipboardButtonComponent:"
81clipboardButtonComponent",clipboardButtonTemplate:"clipboardButtonTemplate",emoji:"emoji",katex:"katex",katexOptions:"katexOptions",mermaid:"mermaid",mermaidOptions:"mermaidOptions",lineHighlight:"lineHighlight",line:"line",lineOffset:"lineOffset",lineNumbers:"lineNumbers",start:"start",commandLine:"commandLine",filterOutput:"filterOutput",host:"host",prompt:"prompt",output:"output",user:"user"},outputs:{error:"error",load:"load",ready:"ready"},standalone:!0,features:[Ei,Pr],ngContentSelectors:Wee,decls:1,vars:0,template:function(r,i){r&1&&(RN(),kN(0))},encapsulation:2})}}return n})();function bS(n){return[bj,n?.loader??[],n?.clipboardOptions??[],n?.markedOptions??[],{provide:_j,useValue:n?.markedExtensions??[]},{provide:vj,useValue:n?.sanitize??Ii.HTML}]}var Ej=(()=>{class n{static forRoot(t){return{ngModule:n,providers:[bS(t)]}}static forChild(){return{ngModule:n}}static{this.\u0275fac=function(r){return new(r||n)}}static{this.\u0275mod=Wi({type:n})}static{this.\u0275inj=Gi({imports:[Ai]})}}return n})(),yj;(function(n){let e;(function(i){i.Strict="strict",i.Loose="loose",i.Antiscript="antiscript",i.Sandbox="sandbox"})(e=n.SecurityLevel||(n.SecurityLevel={}));let t;(function(i){i.Base="base",i.Forest="forest",i.Dark="dark",i.Default="default",i.Neutral="neutral"})(t=n.Theme||(n.Theme={}));let r;(function(i){i[i.Debug=1]="Debug",i[i.Info=2]="Info",i[i.Warn=3]="Warn",i[i.Error=4]="Error",i[i.Fatal=5]="Fatal"})(r=n.LogLevel||(n.LogLevel={}))})(yj||(yj={}));var Pj=(()=>{class n{constructor(t,r){this._renderer=t,this._elementRef=r,this.onChange=i=>{},this.onTouched=()=>{}}setProperty(t,r){this._renderer.setProperty(this._elementRef.nativeElement,t,r)}registerOnTouched(t){this.onTouched=t}registerOnChange(t){this.onChange=t}setDisabledState(t){this.setProperty("disabled",t)}static{this.\u0275fac=function(r){return new(r||n)(oe(Bs),oe(nr))}}static{this.\u0275dir=Mt({type:n})}}return n})(),vu=(()=>{class n extends Pj{static{this.\u0275fac=(()=>{let t;return function(i){return(t||(t=zr(n)))(i||n)}})()}static{this.\u0275dir=Mt({type:n,features:[Rr]})}}return n})(),vc=new ue(""),ste={provide:vc,useExisting:Hr(()=>Xh),multi:!0},Xh=(()=>{class n extends vu{writeValue(t){this.setProperty("checked",t)}static{this.\u0275fac=(()=>{let t;return function(i){return(t||(t=zr(n)))(i||n)}})()}static{this.\u0275dir=Mt({type:n,selectors:[["input","type","checkbox","formControlName",""],["input","type","checkbox","formControl",""],["input","type","checkbox","ngModel",""]],hostBindings:function(r,i){r&1&&_e("change",function(o){return i.onChange(o.target.checked)})("blur",function(){return i.onTouched()})},features:[Ki([ste]),Rr]})}}return n})(),ote={provide:vc,useExisting:Hr(()=>bu),multi:!0};function ate(){let n=Hs()?Hs().getUserAgent():"";return/android (\d+)/.test(n.toLowerCase())}var cte=new ue(""),bu=(()=>{class n extends Pj{constructor(t,r,i){super(t,r),this._compositionMode=i,this._composing=!1,this._compositionMode==null&&(this._compositionMode=!ate())}writeValue(t){let r=t??"";this.setProperty("value",r)}_handleInput(t){(!this._compositionMode||this._compositionMode&&!this._composing)&&this.onChange(t)}_compositionStart(){this._composing=!0}_compositionEnd(t){this._composing=!1,this._compositionMode&&this.onChange(t)}static{this.\u0275fac=function(r){return new(r||n)(oe(Bs),oe(nr),oe(cte,8))}}static{this.\u0275dir=Mt({type:n,selectors:[["input","formControlName","",3,"type","checkbox"],["textarea","formControlName",""],["input","formControl","",3,"type","checkbox"],["textarea","formControl",""],["input","ngModel","",3,"type","checkbox"],["textarea","ngModel",""],["","ngDefaultControl",""]],hostBindings:function(r,i){r&1&&_e("input",function(o){return i._handleInput(o.target.value)})("blur",function(){return i.onTouched()})("compositionstart",function(){return i._compositionStart()})("compositionend",function(o){return i._compositionEnd(o.target.value)})},features:[Ki([ote]),Rr]})}}return n})();function Zy(n){return n==null||(typeof n=="string"||Array.isArray(n))&&n.length===0}var AS=new ue(""),lte=new ue("");function ute(n){return e=>{if(Zy(e.value)||Zy(n))return null;let t=parseFloat(e.value);return!isNaN(t)&&t<n?{min:{min:n,actual:e.value}}:null}}function dte(n){return e=>{if(Zy(e.value)||Zy(n))return null;let t=parseFloat(e.value);return!isNaN(t)&&t>n?{max:{max:n,actual:e.value}}:null}}function Ij(n){return null}function Mj(n){return n!=null}function Nj(n){return $o(n)?Rt(n):n}function Oj(n){let e={};
81return n.forEach(t=>{e=t!=null?_(_({},e),t):e}),Object.keys(e).length===0?null:e}function Lj(n,e){return e.map(t=>t(n))}function hte(n){return!n.validate}function Fj(n){return n.map(e=>hte(e)?e:t=>e.validate(t))}function fte(n){if(!n)return null;let e=n.filter(Mj);return e.length==0?null:function(t){return Oj(Lj(t,e))}}function Vj(n){return n!=null?fte(Fj(n)):null}function pte(n){if(!n)return null;let e=n.filter(Mj);return e.length==0?null:function(t){let r=Lj(t,e).map(Nj);return Jb(r).pipe(ke(Oj))}}function jj(n){return n!=null?pte(Fj(n)):null}function Tj(n,e){return n===null?[e]:Array.isArray(n)?[...n,e]:[n,e]}function mte(n){return n._rawValidators}function gte(n){return n._rawAsyncValidators}function wS(n){return n?Array.isArray(n)?n:[n]:[]}function Jy(n,e){return Array.isArray(n)?n.includes(e):n===e}function Aj(n,e){let t=wS(e);return wS(n).forEach(i=>{Jy(t,i)||t.push(i)}),t}function Cj(n,e){return wS(e).filter(t=>!Jy(n,t))}var e_=class{constructor(){this._rawValidators=[],this._rawAsyncValidators=[],this._onDestroyCallbacks=[]}get value(){return this.control?this.control.value:null}get valid(){return this.control?this.control.valid:null}get invalid(){return this.control?this.control.invalid:null}get pending(){return this.control?this.control.pending:null}get disabled(){return this.control?this.control.disabled:null}get enabled(){return this.control?this.control.enabled:null}get errors(){return this.control?this.control.errors:null}get pristine(){return this.control?this.control.pristine:null}get dirty(){return this.control?this.control.dirty:null}get touched(){return this.control?this.control.touched:null}get status(){return this.control?this.control.status:null}get untouched(){return this.control?this.control.untouched:null}get statusChanges(){return this.control?this.control.statusChanges:null}get valueChanges(){return this.control?this.control.valueChanges:null}get path(){return null}_setValidators(e){this._rawValidators=e||[],this._composedValidatorFn=Vj(this._rawValidators)}_setAsyncValidators(e){this._rawAsyncValidators=e||[],this._composedAsyncValidatorFn=jj(this._rawAsyncValidators)}get validator(){return this._composedValidatorFn||null}get asyncValidator(){return this._composedAsyncValidatorFn||null}_registerOnDestroy(e){this._onDestroyCallbacks.push(e)}_invokeOnDestroyCallbacks(){this._onDestroyCallbacks.forEach(e=>e()),this._onDestroyCallbacks=[]}reset(e=void 0){this.control&&this.control.reset(e)}hasError(e,t){return this.control?this.control.hasError(e,t):!1}getError(e,t){return this.control?this.control.getError(e,t):null}},ES=class extends e_{get formDirective(){return null}get path(){return null}},Yh=class extends e_{constructor(){super(...arguments),this._parent=null,this.name=null,this.valueAccessor=null}},IS=class{constructor(e){this._cd=e}get isTouched(){return!!this._cd?.control?.touched}get isUntouched(){return!!this._cd?.control?.untouched}get isPristine(){return!!this._cd?.control?.pristine}get isDirty(){return!!this._cd?.control?.dirty}get isValid(){return!!this._cd?.control?.valid}get isInvalid(){return!!this._cd?.control?.invalid}get isPending(){return!!this._cd?.control?.pending}get isSubmitted(){return!!this._cd?.submitted}},yte={"[class.ng-untouched]":"isUntouched","[class.ng-touched]":"isTouched","[class.ng-pristine]":"isPristine","[class.ng-dirty]":"isDirty","[class.ng-valid]":"isValid","[class.ng-invalid]":"isInvalid","[class.ng-pending]":"isPending"},XEe=D(_({},yte),{"[class.ng-submitted]":"isSubmitted"}),wu=(()=>{class n extends IS{constructor(t){super(t)}static{this.\u0275fac=function(r){return new(r||n)(oe(Yh,2))}}static{this.\u0275dir=Mt({type:n,selectors:[["","formControlName",""],["","ngModel",""],["","formControl",""]],hostVars:14,hostBindings:function(r,i){r&2&&kr("ng-untouched",i.isUntouched)("ng-touched",i.isTouched)("ng-pristine",i.isPristine)("ng-dirty",i.isDirty)("ng-valid",i.isValid)("ng-invalid",i.isInvalid)("ng-pending",i.isPending)},features:[Rr]})}}return n})();var Wh="VALID",Qy="INVALID",_u="PENDING",Kh="DISABLED";function _te(n){return(t_(n)?n.validators:n)||null}function vte(n){return Array.isArray(n)?Vj(n):n||null}function bte(n,e){return(t_(e)?e.asyncValidators:n)||null}function wte(n){return Array.isArray(n)?jj(n):n||null}function t_(n){return n!=null&&!Array.isArray(n)&&typeof n=="object"}var TS=class{constructor(e,t){this._pendingDirty=!1,this._hasOwnPendingAsyncValidator=!1,this._pendingTouched=!1,this._onCollectionChange=()=>{},this._parent=null,this.pristine=!0,this.touched=!1,this._onDisabledChange=[],this._assignValidators(e),this._assignAsyncValidators(t)}get validator(){return this._composedValidatorFn}set validator(e){this._rawValidators=this._composedValidatorFn=e}get asyncValidator(){return this._composedAsyncValidatorFn}set asyncValidator(e){this._rawAsyncValidators=this._composedAsyncValidatorFn=e}get parent(){return this._parent}get valid(){return this.status===Wh}get invalid(){return this.status===Qy}get pending(){return this.status==_u}get disabled(){return this.status===Kh}get enabled(){return this.status!==Kh}get dirty(){return!this.pristine}get untouched(){return!this.touched}get updateOn(){return this._updateOn?this._updateOn:this.parent?this.parent.updateOn:"change"}setValidators(e){this._assignValidators(e)}setAsyncValidators(e){this._assignAsyncValidators(e)}addValidators(e){this.setValidators(Aj(e,this._rawValidators))}addAsyncValidators(e){this.setAsyncValidators(Aj(e,this._rawAsyncValidators))}removeValidators(e){this.setValidators(Cj(e,this._rawValidators))}removeAsyncValidators(e){this.setAsyncValidators(Cj(e,this._rawAsyncValidators))}hasValidator(e){return Jy(this._rawValidators,e)}hasAsyncValidator(e){return Jy(this._rawAsyncValidators,e)}clearValidators(){this.validator=null}clearAsyncValidators(){this.asyncValidator=null}markAsTouched(e={}){this.touched=!0,this._parent&&!e.onlySelf&&this._parent.markAsTouched(e)}markAllAsTouched(){this.markAsTouched({onlySelf:!0}
81),this._forEachChild(e=>e.markAllAsTouched())}markAsUntouched(e={}){this.touched=!1,this._pendingTouched=!1,this._forEachChild(t=>{t.markAsUntouched({onlySelf:!0})}),this._parent&&!e.onlySelf&&this._parent._updateTouched(e)}markAsDirty(e={}){this.pristine=!1,this._parent&&!e.onlySelf&&this._parent.markAsDirty(e)}markAsPristine(e={}){this.pristine=!0,this._pendingDirty=!1,this._forEachChild(t=>{t.markAsPristine({onlySelf:!0})}),this._parent&&!e.onlySelf&&this._parent._updatePristine(e)}markAsPending(e={}){this.status=_u,e.emitEvent!==!1&&this.statusChanges.emit(this.status),this._parent&&!e.onlySelf&&this._parent.markAsPending(e)}disable(e={}){let t=this._parentMarkedDirty(e.onlySelf);this.status=Kh,this.errors=null,this._forEachChild(r=>{r.disable(D(_({},e),{onlySelf:!0}))}),this._updateValue(),e.emitEvent!==!1&&(this.valueChanges.emit(this.value),this.statusChanges.emit(this.status)),this._updateAncestors(D(_({},e),{skipPristineCheck:t})),this._onDisabledChange.forEach(r=>r(!0))}enable(e={}){let t=this._parentMarkedDirty(e.onlySelf);this.status=Wh,this._forEachChild(r=>{r.enable(D(_({},e),{onlySelf:!0}))}),this.updateValueAndValidity({onlySelf:!0,emitEvent:e.emitEvent}),this._updateAncestors(D(_({},e),{skipPristineCheck:t})),this._onDisabledChange.forEach(r=>r(!1))}_updateAncestors(e){this._parent&&!e.onlySelf&&(this._parent.updateValueAndValidity(e),e.skipPristineCheck||this._parent._updatePristine(),this._parent._updateTouched())}setParent(e){this._parent=e}getRawValue(){return this.value}updateValueAndValidity(e={}){this._setInitialStatus(),this._updateValue(),this.enabled&&(this._cancelExistingSubscription(),this.errors=this._runValidator(),this.status=this._calculateStatus(),(this.status===Wh||this.status===_u)&&this._runAsyncValidator(e.emitEvent)),e.emitEvent!==!1&&(this.valueChanges.emit(this.value),this.statusChanges.emit(this.status)),this._parent&&!e.onlySelf&&this._parent.updateValueAndValidity(e)}_updateTreeValidity(e={emitEvent:!0}){this._forEachChild(t=>t._updateTreeValidity(e)),this.updateValueAndValidity({onlySelf:!0,emitEvent:e.emitEvent})}_setInitialStatus(){this.status=this._allControlsDisabled()?Kh:Wh}_runValidator(){return this.validator?this.validator(this):null}_runAsyncValidator(e){if(this.asyncValidator){this.status=_u,this._hasOwnPendingAsyncValidator=!0;let t=Nj(this.asyncValidator(this));this._asyncValidationSubscription=t.subscribe(r=>{this._hasOwnPendingAsyncValidator=!1,this.setErrors(r,{emitEvent:e})})}}_cancelExistingSubscription(){this._asyncValidationSubscription&&(this._asyncValidationSubscription.unsubscribe(),this._hasOwnPendingAsyncValidator=!1)}setErrors(e,t={}){this.errors=e,this._updateControlsErrors(t.emitEvent!==!1)}get(e){let t=e;return t==null||(Array.isArray(t)||(t=t.split(".")),t.length===0)?null:t.reduce((r,i)=>r&&r._find(i),this)}getError(e,t){let r=t?this.get(t):this;return r&&r.errors?r.errors[e]:null}hasError(e,t){return!!this.getError(e,t)}get root(){let e=this;for(;e._parent;)e=e._parent;return e}_updateControlsErrors(e){this.status=this._calculateStatus(),e&&this.statusChanges.emit(this.status),this._parent&&this._parent._updateControlsErrors(e)}_initObservables(){this.valueChanges=new $t,this.statusChanges=new $t}_calculateStatus(){return this._allControlsDisabled()?Kh:this.errors?Qy:this._hasOwnPendingAsyncValidator||this._anyControlsHaveStatus(_u)?_u:this._anyControlsHaveStatus(Qy)?Qy:Wh}_anyControlsHaveStatus(e){return this._anyControls(t=>t.status===e)}_anyControlsDirty(){return this._anyControls(e=>e.dirty)}_anyControlsTouched(){return this._anyControls(e=>e.touched)}_updatePristine(e={}){this.pristine=!this._anyControlsDirty(),this._parent&&!e.onlySelf&&this._parent._updatePristine(e)}_updateTouched(e={}){this.touched=this._anyControlsTouched(),this._parent&&!e.onlySelf&&this._parent._updateTouched(e)}_registerOnCollectionChange(e){this._onCollectionChange=e}_setUpdateStrategy(e){t_(e)&&e.updateOn!=null&&(this._updateOn=e.updateOn)}_parentMarkedDirty(e){let t=this._parent&&this._parent.dirty;return!e&&!!t&&!this._parent._anyControlsDirty()}_find(e){return null}_assignValidators(e){this._rawValidators=Array.isArray(e)?e.slice():e,this._composedValidatorFn=vte(this._rawValidators)}_assignAsyncValidators(e){this._rawAsyncValidators=Array.isArray(e)?e.slice():e,this._composedAsyncValidatorFn=wte(this._rawAsyncValidators)}};var $j=new ue("CallSetDisabledState",{providedIn:"root",factory:()=>CS}),CS="always";function Ete(n,e){return[...e.path,n]}function Ite(n,e,t=CS){Ate(n,e),e.valueAccessor.writeValue(n.value),(n.disabled||t==="always")&&e.valueAccessor.setDisabledState?.(n.disabled),Cte(n,e),xte(n,e),Ste(n,e),Tte(n,e)}
vendor: 1,270 bytes, line 81
81function Sj(n,e){n.forEach(t=>{t.registerOnValidatorChange&&t.registerOnValidatorChange(e)})}function Tte(n,e){if(e.valueAccessor.setDisabledState){let t=r=>{e.valueAccessor.setDisabledState(r)};n.registerOnDisabledChange(t),e._registerOnDestroy(()=>{n._unregisterOnDisabledChange(t)})}}function Ate(n,e){let t=mte(n);e.validator!==null?n.setValidators(Tj(t,e.validator)):typeof t=="function"&&n.setValidators([t]);let r=gte(n);e.asyncValidator!==null?n.setAsyncValidators(Tj(r,e.asyncValidator)):typeof r=="function"&&n.setAsyncValidators([r]);let i=()=>n.updateValueAndValidity();Sj(e._rawValidators,i),Sj(e._rawAsyncValidators,i)}function Cte(n,e){e.valueAccessor.registerOnChange(t=>{n._pendingValue=t,n._pendingChange=!0,n._pendingDirty=!0,n.updateOn==="change"&&Uj(n,e)})}function Ste(n,e){e.valueAccessor.registerOnTouched(()=>{n._pendingTouched=!0,n.updateOn==="blur"&&n._pendingChange&&Uj(n,e),n.updateOn!=="submit"&&n.markAsTouched()})}function Uj(n,e){n._pendingDirty&&n.markAsDirty(),n.setValue(n._pendingValue,{emitModelToViewChange:!1}),e.viewToModelUpdate(n._pendingValue),n._pendingChange=!1}function xte(n,e){let t=(r,i)=>{e.valueAccessor.writeValue(r),i&&e.viewToModelUpdate(r)};n.registerOnChange(t),e._registerOnDestroy(()=>{n._unregisterOnChange(t)}
81)}function Dte(n,e){if(!n.hasOwnProperty("model"))return!1;let t=n.model;return t.isFirstChange()?!0:!Object.is(e,t.currentValue)}function Rte(n){return Object.getPrototypeOf(n.constructor)===vu}function kte(n,e){if(!e)return null;Array.isArray(e);let t,r,i;return e.forEach(s=>{s.constructor===bu?t=s:Rte(s)?r=s:i=s}),i||r||t||null}function xj(n,e){let t=n.indexOf(e);t>-1&&n.splice(t,1)}function Dj(n){return typeof n=="object"&&n!==null&&Object.keys(n).length===2&&"value"in n&&"disabled"in n}var Pte=class extends TS{constructor(e=null,t,r){super(_te(t),bte(r,t)),this.defaultValue=null,this._onChange=[],this._pendingChange=!1,this._applyFormState(e),this._setUpdateStrategy(t),this._initObservables(),this.updateValueAndValidity({onlySelf:!0,emitEvent:!!this.asyncValidator}),t_(t)&&(t.nonNullable||t.initialValueIsDefault)&&(Dj(e)?this.defaultValue=e.value:this.defaultValue=e)}setValue(e,t={}){this.value=this._pendingValue=e,this._onChange.length&&t.emitModelToViewChange!==!1&&this._onChange.forEach(r=>r(this.value,t.emitViewToModelChange!==!1)),this.updateValueAndValidity(t)}patchValue(e,t={}){this.setValue(e,t)}reset(e=this.defaultValue,t={}){this._applyFormState(e),this.markAsPristine(t),this.markAsUntouched(t),this.setValue(this.value,t),this._pendingChange=!1}_updateValue(){}_anyControls(e){return!1}_allControlsDisabled(){return this.disabled}registerOnChange(e){this._onChange.push(e)}_unregisterOnChange(e){xj(this._onChange,e)}registerOnDisabledChange(e){this._onDisabledChange.push(e)}_unregisterOnDisabledChange(e){xj(this._onDisabledChange,e)}_forEachChild(e){}_syncPendingControls(){return this.updateOn==="submit"&&(this._pendingDirty&&this.markAsDirty(),this._pendingTouched&&this.markAsTouched(),this._pendingChange)?(this.setValue(this._pendingValue,{onlySelf:!0,emitModelToViewChange:!1}),!0):!1}_applyFormState(e){Dj(e)?(this.value=this._pendingValue=e.value,e.disabled?this.disable({onlySelf:!0,emitEvent:!1}):this.enable({onlySelf:!0,emitEvent:!1})):this.value=this._pendingValue=e}};var Mte={provide:Yh,useExisting:Hr(()=>bc)},Rj=Promise.resolve(),bc=(()=>{class n extends Yh{constructor(t,r,i,s,o,a){super(),this._changeDetectorRef=o,this.callSetDisabledState=a,this.control=new Pte,this._registered=!1,this.name="",this.update=new $t,this._parent=t,this._setValidators(r),this._setAsyncValidators(i),this.valueAccessor=kte(this,s)}ngOnChanges(t){if(this._checkForErrors(),!this._registered||"name"in t){if(this._registered&&(this._checkName(),this.formDirective)){let r=t.name.previousValue;this.formDirective.removeControl({name:r,path:this._getPath(r)})}this._setUpControl()}"isDisabled"in t&&this._updateDisabled(t),Dte(t,this.viewModel)&&(this._updateValue(this.model),this.viewModel=this.model)}ngOnDestroy(){this.formDirective&&this.formDirective.removeControl(this)}get path(){return this._getPath(this.name)}get formDirective(){return this._parent?this._parent.formDirective:null}viewToModelUpdate(t){this.viewModel=t,this.update.emit(t)}_setUpControl(){this._setUpdateStrategy(),this._isStandalone()?this._setUpStandalone():this.formDirective.addControl(this),this._registered=!0}_setUpdateStrategy(){this.options&&this.options.updateOn!=null&&(this.control._updateOn=this.options.updateOn)}_isStandalone(){return!this._parent||!!(this.options&&this.options.standalone)}_setUpStandalone(){Ite(this.control,this,this.callSetDisabledState),this.control.updateValueAndValidity({emitEvent:!1})}_checkForErrors(){this._isStandalone()||this._checkParentType(),this._checkName()}_checkParentType(){}_checkName(){this.options&&this.options.name&&(this.name=this.options.name),!this._isStandalone()&&this.name}_updateValue(t){Rj.then(()=>{this.control.setValue(t,{emitViewToModelChange:!1}),this._changeDetectorRef?.markForCheck()})}_updateDisabled(t){let r=t.isDisabled.currentValue,i=r!==0&&Bm(r);Rj.then(()=>{i&&!this.control.disabled?this.control.disable():!i&&this.control.disabled&&this.control.enable(),this._changeDetectorRef?.markForCheck()})}_getPath(t){return this._parent?Ete(t,this._parent):[t]}static{this.\u0275fac=function(r){return new(r||n)(oe(ES,9),oe(AS,10),oe(lte,10),oe(vc,10),oe(Uo,8),oe($j,8))}}static{this.\u0275dir=Mt({type:n,selectors:[["","ngModel","",3,"formControlName","",3,"formControl",""]],inputs:{name:"name",isDisabled:[Cr.None,"disabled","isDisabled"],model:[Cr.None,"ngModel","model"],options:[Cr.None,"ngModelOptions","options"]},outputs:{update:"ngModelChange"},exportAs:["ngModel"],features:[Ki([Mte]),Rr,Ei]})}}return n})();var Nte={provide:vc,useExisting:Hr(()=>SS),multi:!0},SS=(()=>{class n extends vu{writeValue(t){let r=t??"";this.setProperty("value",r)}registerOnChange(t){this.onChange=r=>{t(r==""?null:parseFloat(r))}}static{this.\u0275fac=(()=>{let t;return function(i){return(t||(t=zr(n)))(i||n)}})()}static{this.\u0275dir=Mt({type:n,selectors:[["input","type","number","formControlName",""],["input","type","number","formControl",""],["input","type","number","ngModel",""]],hostBindings:function(r,i){r&1&&_e("input",function(o){return i.onChange(o.target.value)})("blur",function(){return i.onTouched()})},features:[Ki([Nte]),Rr]})}}return n})();var Ote={provide:vc,useExisting:Hr(()=>xS),multi:!0},xS=(()=>{class n extends vu{writeValue(t){this.setProperty("value",parseFloat(t))}registerOnChange(t){this.onChange=r=>{t(r==""?null:parseFloat(r))}}static{this.\u0275fac=(()=>{let t;return function(i){return(t||(t=zr(n)))(i||n)}})()}static{this.\u0275dir=Mt({type:n,selectors:[["input","type","range","formControlName",""],["input","type","range","formControl",""],["input","type","range","ngModel",""]],hostBindings:function(r,i){r&1&&_e("change",function(o){return i.onChange(o.target.value)})("input",function(o){return i.onChange(o.target.value)})("blur",function(){return i.onTouched()})},features:[Ki([Ote]),Rr]})}}return n})();var Lte={provide:vc,useExisting:Hr(()=>Eu),multi:!0};function Bj(n,e){return n==null?`${e}`:(e&&typeof e=="object"&&(e="Object"),`${n}: ${e}`.slice(0,50))}function Fte(n){return n.split(":")[0]}var Eu=(()=>{class n extends vu{constructor(){super(...arguments),this._optionMap=new Map,this._idCounter=0,this._compareWith=Object.is}set compareWith(t){this._compareWith=t}writeValue(t){this.value=t;let r=this._getOptionId(t),i=Bj(r,t);this.setProperty("value",i)}registerOnChange(t){this.onChange=r=>{this.value=this._getOptionValue(r),t(this.value)}}_registerOption(){return(this._idCounter++).toString()}_getOptionId(t){for(let r of this._optionMap.keys())if(this._compareWith(this._optionMap.get(r),t))return r;return null}_getOptionValue(t){let r=Fte(t);return this._optionMap.has(r)?this._optionMap.get(r):t}static{this.\u0275fac=(()=>{let t;return function(i){return(t||(t=zr(n)))(i||n)}})()}static{this.\u0275dir=Mt({type:n,selectors:[["select","formControlName","",3,"multiple",""],["select","formControl","",3,"multiple",""],["select","ngModel","",3,"multiple",""]],hostBindings:function(r,i){r&1&&_e("change",function(o){return i.onChange(o.target.value)})("blur",function(){return i.onTouched()})},inputs:{compareWith:"compareWith"},features:[Ki([Lte]),Rr]})}}return n})(),n_=(()=>{class n{constructor(t,r,i){this._element=t,this._renderer=r,this._select=i,this._select&&(this.id=this._select._registerOption())}set ngValue(t){this._select!=null&&(this._select._optionMap.set(this.id,t),this._setElementValue(Bj(this.id,t)),this._select.writeValue(this._select.value))}set value(t){this._setElementValue(t),this._select&&this._select.writeValue(this._select.value)}_setElementValue(t){this._renderer.setProperty(this._element.nativeElement,"value",t)}ngOnDestroy(){this._select&&(this._select._optionMap.delete(this.id
81),this._select.writeValue(this._select.value))}static{this.\u0275fac=function(r){return new(r||n)(oe(nr),oe(Bs),oe(Eu,9))}}static{this.\u0275dir=Mt({type:n,selectors:[["option"]],inputs:{ngValue:"ngValue",value:"value"}})}}return n})(),Vte={provide:vc,useExisting:Hr(()=>Hj),multi:!0};function kj(n,e){return n==null?`${e}`:(typeof e=="string"&&(e=`'${e}'`),e&&typeof e=="object"&&(e="Object"),`${n}: ${e}`.slice(0,50))}function jte(n){return n.split(":")[0]}var Hj=(()=>{class n extends vu{constructor(){super(...arguments),this._optionMap=new Map,this._idCounter=0,this._compareWith=Object.is}set compareWith(t){this._compareWith=t}writeValue(t){this.value=t;let r;if(Array.isArray(t)){let i=t.map(s=>this._getOptionId(s));r=(s,o)=>{s._setSelected(i.indexOf(o.toString())>-1)}}else r=(i,s)=>{i._setSelected(!1)};this._optionMap.forEach(r)}registerOnChange(t){this.onChange=r=>{let i=[],s=r.selectedOptions;if(s!==void 0){let o=s;for(let a=0;a<o.length;a++){let c=o[a],l=this._getOptionValue(c.value);i.push(l)}}else{let o=r.options;for(let a=0;a<o.length;a++){let c=o[a];if(c.selected){let l=this._getOptionValue(c.value);i.push(l)}}}this.value=i,t(i)}}_registerOption(t){let r=(this._idCounter++).toString();return this._optionMap.set(r,t),r}_getOptionId(t){for(let r of this._optionMap.keys())if(this._compareWith(this._optionMap.get(r)._value,t))return r;return null}_getOptionValue(t){let r=jte(t);return this._optionMap.has(r)?this._optionMap.get(r)._value:t}static{this.\u0275fac=(()=>{let t;return function(i){return(t||(t=zr(n)))(i||n)}})()}static{this.\u0275dir=Mt({type:n,selectors:[["select","multiple","","formControlName",""],["select","multiple","","formControl",""],["select","multiple","","ngModel",""]],hostBindings:function(r,i){r&1&&_e("change",function(o){return i.onChange(o.target)})("blur",function(){return i.onTouched()})},inputs:{compareWith:"compareWith"},features:[Ki([Vte]),Rr]})}}return n})(),r_=(()=>{class n{constructor(t,r,i){this._element=t,this._renderer=r,this._select=i,this._select&&(this.id=this._select._registerOption(this))}set ngValue(t){this._select!=null&&(this._value=t,this._setElementValue(kj(this.id,t)),this._select.writeValue(this._select.value))}set value(t){this._select?(this._value=t,this._setElementValue(kj(this.id,t)),this._select.writeValue(this._select.value)):this._setElementValue(t)}_setElementValue(t){this._renderer.setProperty(this._element.nativeElement,"value",t)}_setSelected(t){this._renderer.setProperty(this._element.nativeElement,"selected",t)}ngOnDestroy(){this._select&&(this._select._optionMap.delete(this.id),this._select.writeValue(this._select.value))}static{this.\u0275fac=function(r){return new(r||n)(oe(nr),oe(Bs),oe(Hj,9))}}static{this.\u0275dir=Mt({type:n,selectors:[["option"]],inputs:{ngValue:"ngValue",value:"value"}})}}return n})();function qj(n){return typeof n=="number"?n:parseFloat(n)}var zj=(()=>{class n{constructor(){this._validator=Ij}ngOnChanges(t){if(this.inputName in t){let r=this.normalizeInput(t[this.inputName].currentValue);this._enabled=this.enabled(r),this._validator=this._enabled?this.createValidator(r):Ij,this._onChange&&this._onChange()}}validate(t){return this._validator(t)}registerOnValidatorChange(t){this._onChange=t}enabled(t){return t!=null}static{this.\u0275fac=function(r){return new(r||n)}}static{this.\u0275dir=Mt({type:n,features:[Ei]})}}return n})(),$te={provide:AS,useExisting:Hr(()=>DS),multi:!0},DS=(()=>{class n extends zj{constructor(){super(...arguments),this.inputName="max",this.normalizeInput=t=>qj(t),this.createValidator=t=>dte(t)}static{this.\u0275fac=(()=>{let t;return function(i){return(t||(t=zr(n)))(i||n)}})()}static{this.\u0275dir=Mt({type:n,selectors:[["input","type","number","max","","formControlName",""],["input","type","number","max","","formControl",""],["input","type","number","max","","ngModel",""]],hostVars:1,hostBindings:function(r,i){r&2&&kd("max",i._enabled?i.max:null)},inputs:{max:"max"},features:[Ki([$te]),Rr]})}}return n})(),Ute={provide:AS,useExisting:Hr(()=>RS),multi:!0},RS=(()=>{class n extends zj{constructor(){super(...arguments),this.inputName="min",this.normalizeInput=t=>qj(t),this.createValidator=t=>ute(t)}static{this.\u0275fac=(()=>{let t;return function(i){return(t||(t=zr(n)))(i||n)}})()}static{this.\u0275dir=Mt({type:n,selectors:[["input","type","number","min","","formControlName",""],["input","type","number","min","","formControl",""],["input","type","number","min","","ngModel",""]],hostVars:1,hostBindings:function(r,i){r&2&&kd("min",i._enabled?i.min:null)},inputs:{min:"min"},features:[Ki([Ute]),Rr]})}}return n})();var Bte=(()=>{class n{static{this.\u0275fac=function(r){return new(r||n)}}static{this.\u0275mod=Wi({type:n})}static{this.\u0275inj=Gi({})}}return n})();var Iu=(()=>{class n{static withConfig(t){return{ngModule:n,providers:[{provide:$j,useValue:t.callSetDisabledState??CS}]}}static{this.\u0275fac=function(r){return new(r||n)}}static{this.\u0275mod=Wi({type:n})}static{this.\u0275inj=Gi({imports:[Bte]})}}return n})();var Zr=(()=>
81{class n{constructor(){this.promptLogsSubject=new gt([]),this.promptLogs$=this.promptLogsSubject.asObservable(),this.isLoggingEnabled=!1}enableLogging(t){this.isLoggingEnabled=t,t||this.clearLogs()}isLoggingActive(){return this.isLoggingEnabled}addPromptLog(t){if(!this.isLoggingEnabled)return"";let r=D(_({},t),{id:this.generateId(),expanded:!1}),i=this.promptLogsSubject.value;return this.promptLogsSubject.next([...i,r]),r.id}clearLogsForContext(t){if(!t){this.clearLogs();return}let i=this.promptLogsSubject.value.filter(s=>s.sessionContext!==t);this.promptLogsSubject.next(i)}updatePromptLog(t,r){if(!t)return;let s=this.promptLogsSubject.value.map(o=>{if(o.id!==t)return o;let u=r,{metadata:a}=u,c=Xt(u,["metadata"]),l=a?_(_({},o.metadata),a):o.metadata;return D(_(_({},o),c),{metadata:l,timestamp:r.timestamp?r.timestamp:o.timestamp})});this.promptLogsSubject.next(s)}toggleExpanded(t){let i=this.promptLogsSubject.value.map(s=>s.id===t?D(_({},s),{expanded:!s.expanded}):s);this.promptLogsSubject.next(i)}clearLogs(){this.promptLogsSubject.next([])}getLogsForSession(t){return this.promptLogsSubject.value.filter(r=>!t||r.sessionContext===t)}getLogsForMessage(t){return this.promptLogsSubject.value.filter(r=>r.messageId===t)}generateId(){return`prompt_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}getTruncatedContent(t,r=3){let i=t.split(` 82`);return i.length<=r?{preview:t,isTruncated:!1}:{preview:i.slice(0,r).join(` 83`)+"...",isTruncated:!0}}updatePromptLogMessageId(t,r){this.updatePromptLog(t,{messageId:r})}static{this.\u0275fac=function(r){return new(r||n)}}static{this.\u0275prov=Q({token:n,factory:n.\u0275fac,providedIn:"root"})}}return n})();function Hte(n,e){if(n&1&&(F(0,"span",10),H(1),Yi(2,"titlecase"),L()),n&2){let t=G();B("ngClass",t.statusClasses),j(),Ut(" ",Xi(2,2,t.entry.status)," ")}}function qte(n,e){n&1&&(F(0,"div",11),H(1," Click to expand... "),L())}var Gj=(()=>{class n{constructor(t){this.promptLogging=t,this.hovered=!1}get displayContent(){return this.entry.expanded?this.entry.content:this.promptLogging.getTruncatedContent(this.entry.content,3).preview}get isTruncated(){return this.promptLogging.getTruncatedContent(this.entry.content,3).isTruncated}get isSearchResults(){return this.entry.provider==="RAG Search"&&this.entry.model==="Document Search"}get isMcpQuery(){return this.entry.sessionContext==="mcp-tool-call"&&this.entry.type==="request"}get isMcpResponse(){return this.entry.sessionContext==="mcp-tool-call"&&this.entry.type==="response"}get isFollowUp(){return this.entry.sessionContext?.startsWith("multi-agent-followup-")||!1}get isLocalOperation(){let t=this.entry.provider;return t?["Multi-Agent Planner","Task Executor","Multi-task Executor","Result Verifier","Response Critic","Multi-Agent Orchestrator"].some(i=>t.includes(i)):!1}get isLocalRequest(){return this.isLocalOperation&&this.entry.type==="request"}get isLocalResponse(){return this.isLocalOperation&&this.entry.type==="response"}get displayTitle(){return this.entry.title?this.entry.title:this.entry.metadata&&typeof this.entry.metadata.title=="string"?this.entry.metadata.title:this.isFollowUp?this.entry.type==="request"?"Follow-up Request":"Follow-up Response":`${this.entry.type==="request"?"Request":"Response"} \xB7 ${this.entry.provider}`}get variantClasses(){return this.isMcpQuery||this.isLocalRequest?{container:"border-prompt-mcp bg-[rgba(40,167,69,0.1)]",containerHover:"bg-[rgba(40,167,69,0.08)]",text:"text-prompt-mcp",label:"text-white"}:this.isMcpResponse||this.isLocalResponse?{container:"border-prompt-mcp-response bg-[rgba(23,162,184,0.1)]",containerHover:"bg-[rgba(23,162,184,0.08)]",text:"text-prompt-mcp-response",label:"text-white"}:this.isFollowUp&&this.entry.type==="request"?{container:"border-prompt-followup bg-[rgba(111,66,193,0.1)]",containerHover:"bg-[rgba(111,66,193,0.08)]",text:"text-prompt-followup",label:"text-white"}:this.isFollowUp&&this.entry.type==="response"?{container:"border-prompt-followup-response bg-[rgba(232,62,140,0.1)]",containerHover:"bg-[rgba(232,62,140,0.08)]",text:"text-prompt-followup-response",label:"text-white"}:this.isSearchResults?{container:"border-prompt-search bg-[rgba(23,162,184,0.05)]",containerHover:"bg-[rgba(23,162,184,0.08)]",text:"text-prompt-search",label:"text-prompt-search"}:this.entry.type==="request"?{container:"border-prompt-request bg-[rgba(253,126,20,0.1)]",containerHover:"bg-[rgba(253,126,20,0.08)]",text:"text-prompt-request",label:"text-white"}:{container:"border-prompt-response bg-[rgba(220,53,69,0.08)]",containerHover:"bg-[rgba(220,53,69,0.08)]",text:"text-prompt-response",label:"text-white"}}
83get statusClasses(){switch(this.entry.status){case"pending":return"bg-[rgba(253,126,20,0.15)] text-prompt-request";case"completed":return"bg-[rgba(40,167,69,0.15)] text-prompt-mcp";case"error":return"bg-[rgba(220,53,69,0.15)] text-prompt-response";default:return"bg-[rgba(108,117,125,0.1)] text-[#6c757d]"}}toggleExpanded(){this.promptLogging.toggleExpanded(this.entry.id)}static{this.\u0275fac=function(r){return new(r||n)(oe(Zr))}}static{this.\u0275cmp=xr({type:n,selectors:[["app-prompt-message"]],inputs:{entry:"entry"},standalone:!0,features:[Pr],decls:16,vars:19,consts:[[1,"my-2","border","rounded-md","text-sm","cursor-pointer",3,"mouseenter","mouseleave","ngClass"],[1,"flex","flex-col","gap-1","text-white","py-2","px-3","bg-black/35","border-b","border-black/10","text-[0.9em]"],[1,"flex","justify-between","items-center","gap-3"],[1,"font-semibold","text-white"],["class","rounded-full text-xs font-semibold uppercase py-0.5 px-2",3,"ngClass",4,"ngIf"],[1,"font-medium",3,"ngClass"],[1,"text-[0.8em]","text-white/85"],[1,"px-3","py-2",3,"click"],[1,"m-0","whitespace-pre-wrap","font-mono","bg-transparent","border-none","overflow-hidden","text-[0.8em]","max-h-[60px]","transition-all","duration-300",3,"ngClass"],["class","text-center mt-1 italic text-[#6c757d] text-[0.75em]",4,"ngIf"],[1,"rounded-full","text-xs","font-semibold","uppercase","py-0.5","px-2",3,"ngClass"],[1,"text-center","mt-1","italic","text-[#6c757d]","text-[0.75em]"]],template:function(r,i){r&1&&(F(0,"div",0),_e("mouseenter",function(){return i.hovered=!0})("mouseleave",function(){return i.hovered=!1}),F(1,"div",1)(2,"div",2)(3,"span",3),H(4),L(),me(5,Hte,3,4,"span",4),L(),F(6,"div",2)(7,"span",5),H(8),Yi(9,"titlecase"),L(),F(10,"span",6),H(11),L()()(),F(12,"div",7),_e("click",function(){return i.toggleExpanded()}),F(13,"pre",8),H(14),L(),me(15,qte,2,0,"div",9),L()()),r&2&&(B("ngClass",i.variantClasses.container),j(4),Zt(i.displayTitle),j(),B("ngIf",i.entry.status),j(2),B("ngClass",i.variantClasses.label),j(),cE(" ",i.entry.type==="request"?"\u{1F4E4}":"\u{1F4E5}"," ",i.isFollowUp?"\u{1F504} Follow-up ":"","",Xi(9,17,i.entry.type)," \xB7 ",i.entry.provider,"",i.entry.model?"/"+i.entry.model:""," "),j(3),Zt(i.entry.timestamp.toLocaleTimeString()),j(2),kr("overflow-visible",i.entry.expanded)("!max-h-none",i.entry.expanded),B("ngClass",i.variantClasses.text),j(),Zt(i.displayContent),j(),B("ngIf",i.isTruncated&&!i.entry.expanded))},dependencies:[Ai,Gm,xl,tO],encapsulation:2})}}return n})();var $n={FILE_SIZE:{DOCUMENT_MAX_SIZE:52428800,PDF_MAX_SIZE:52428800,IMAGE_MAX_SIZE:10485760},TIMEOUTS:{UPLOAD_COMPLETE_DISPLAY:2e3,SCROLL_DELAY:100,SCROLL_DELAY_EXTENDED:200,DOCUMENT_STATUS_POLL:2e3},DOCUMENT_PROCESSING:{CHUNK_SIZE:1024,CHUNK_OVERLAP:100},PDF_PROCESSING:{CHUNK_SIZE:400,CHUNK_OVERLAP:50},SUPPORTED_DOCUMENT_TYPES:{"application/pdf":{extension:".pdf",label:"PDF"},"application/vnd.openxmlformats-officedocument.wordprocessingml.document":{extension:".docx",label:"Word"},"application/vnd.openxmlformats-officedocument.presentationml.presentation":{extension:".pptx",label:"PowerPoint"},"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":{extension:".xlsx",label:"Excel"},"text/html":{extension:".html",label:"HTML"},"image/png":{extension:".png",label:"PNG Image"},"image/jpeg":{extension:".jpg",label:"JPEG Image"},"image/tiff":{extension:".tiff",label:"TIFF Image"}},FILE_TYPES:{PDF:"application/pdf",IMAGE_PREFIX:"image/"},MEMORY:{MAX_MESSAGES:20},UI:{MAX_TITLE_LENGTH:40}},Au=Object.keys($n.SUPPORTED_DOCUMENT_TYPES),Wj=Au.join(",");var nf={};nf.d=(n,e)=>{for(var t in e)nf.o(e,t)&&!nf.o(n,t)&&Object.defineProperty(n,t,{enumerable:!0,get:e[t]})};nf.o=(n,e)=>Object.prototype.hasOwnProperty.call(n,e);var De=globalThis.pdfjsLib={};nf.d(De,{AbortException:()=>ys,AnnotationEditorLayer:()=>Une,AnnotationEditorParamsType:()=>rt,AnnotationEditorType:()=>je,AnnotationEditorUIManager:()=>lf,AnnotationLayer:()=>Gx,AnnotationMode:()=>aa,ColorPicker:()=>F_,DOMSVGFactory:()=>pf,DrawLayer:()=>tD,FeatureTest:()=>Cn,GlobalWorkerOptions:()=>Ec,ImageKind:()=>l_,InvalidPDFException:()=>sf,MissingPDFException:()=>Ic,OPS:()=>Mi,OutputScale:()=>cf,PDFDataRangeTransport:()=>A_,PDFDateString:()=>h_,PDFWorker:()=>xu,PasswordResponses:()=>Yte,PermissionFlag:()=>Kte,PixelsPerInch:()=>
83la,RenderingCancelledException:()=>af,TextLayer:()=>hf,TouchManager:()=>p_,UnexpectedResponseException:()=>Du,Util:()=>pe,VerbosityLevel:()=>$_,XfaLayer:()=>x_,build:()=>Vne,createValidAbsoluteUrl:()=>Jte,fetchData:()=>q_,getDocument:()=>Nne,getFilenameFromUrl:()=>ane,getPdfFilenameFromUrl:()=>cne,getXfaPageViewport:()=>lne,isDataScheme:()=>z_,isPdfFile:()=>iD,noContextMenu:()=>Ni,normalizeUnicode:()=>ine,setLayerDimensions:()=>Tc,shadow:()=>Xe,stopEvent:()=>$r,version:()=>Fne});var Hn=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),l$=[1,0,0,1,0,0],FS=[.001,0,0,.001,0,0],zte=1e7,c_=1.35,Gte=.35,iIe=Gte/c_,jr={ANY:1,DISPLAY:2,PRINT:4,SAVE:8,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},aa={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},Wte="pdfjs_internal_editor_",je={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},rt={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_DEFAULT_COLOR:32,HIGHLIGHT_THICKNESS:33,HIGHLIGHT_FREE:34,HIGHLIGHT_SHOW_ALL:35,DRAW_STEP:41},Kte={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},Un={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_ADD_TO_PATH:4,STROKE_ADD_TO_PATH:5,FILL_STROKE_ADD_TO_PATH:6,ADD_TO_PATH:7,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},l_={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},ln={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,SOUND:18,MOVIE:19,WIDGET:20,SCREEN:21,PRINTERMARK:22,TRAPNET:23,WATERMARK:24,THREED:25,REDACT:26};var Qh={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5};var $_={ERRORS:0,WARNINGS:1,INFOS:5},Mi={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91,setStrokeTransparent:92,setFillTransparent:93},Yte={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},U_=$_.WARNINGS;function Xte(n){Number.isInteger(n)&&(U_=n)}function Qte(){return U_}function B_(n){U_>=$_.INFOS&&console.log(`Info: ${n}`)}function $e(n){U_>=$_.WARNINGS&&console.log(`Warning: ${n}`)}function Ct(n){throw new Error(n)}function rn(n,e){n||Ct(e)}function Zte(n){switch(n?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function Jte(n,e=null,t=null){if(!n)return null;try{if(t&&typeof n=="string"&&(t.addDefaultProtocol&&n.startsWith("www.")&&n.match(/\./g)?.length>=2&&(n=`http://${n}`),t.tryConvertEncoding))try{n=rne(n)}catch{}let r=e?new URL(n,e):new URL(n);if(Zte(r))return r}catch{}return null}function Xe(n,e,t,r=!1){return Object.defineProperty(n,e,{value:t,enumerable:!r,configurable:!0,writable:!1}),t}var ua=function(){function e(t,r){this.message=t,this.name=r}return e.prototype=new Error,e.constructor=e,e}(),u_=class extends ua{constructor(e,t){super(e,"PasswordException"),this.code=t}},rf=class extends ua{constructor(e,t){super(e,"UnknownErrorException"),this.details=t}},sf=class extends ua{constructor(e){super(e,"InvalidPDFException")}},Ic=class extends ua{constructor(e){super(e,"MissingPDFException")}},Du=class extends ua{constructor(e,t){super(e,"UnexpectedResponseException"),this.status=t}},VS=class extends ua{constructor(e){super(e,"FormatError")}},ys=class extends ua{constructor(e){super(e,"AbortException")}};function u$(n){(typeof n!="object"||n?.length===void 0)&&Ct("Invalid argument for bytesToString");let e=n.length,t=8192;if(e<t)return String.fromCharCode.apply(null,n);let r=[];for(let i=0;i<e;i+=t){let s=Math.min(i+t,e),o=n.subarray(i,s);r.push(String.fromCharCode.apply(null,o))}return r.join("")}
83function H_(n){typeof n!="string"&&Ct("Invalid argument for stringToBytes");let e=n.length,t=new Uint8Array(e);for(let r=0;r<e;++r)t[r]=n.charCodeAt(r)&255;return t}function ene(n){return String.fromCharCode(n>>24&255,n>>16&255,n>>8&255,n&255)}function nD(n){let e=Object.create(null);for(let[t,r]of n)e[t]=r;return e}function tne(){let n=new Uint8Array(4);return n[0]=1,new Uint32Array(n.buffer,0,1)[0]===1}function nne(){try{return new Function(""),!0}catch{return!1}}var Cn=class{static get isLittleEndian(){return Xe(this,"isLittleEndian",tne())}static get isEvalSupported(){return Xe(this,"isEvalSupported",nne())}static get isOffscreenCanvasSupported(){return Xe(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get isImageDecoderSupported(){return Xe(this,"isImageDecoderSupported",typeof ImageDecoder<"u")}static get platform(){return typeof navigator<"u"&&typeof navigator?.platform=="string"?Xe(this,"platform",{isMac:navigator.platform.includes("Mac"),isWindows:navigator.platform.includes("Win"),isFirefox:typeof navigator?.userAgent=="string"&&navigator.userAgent.includes("Firefox")}):Xe(this,"platform",{isMac:!1,isWindows:!1,isFirefox:!1})}static get isCSSRoundSupported(){return Xe(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}},PS=Array.from(Array(256).keys(),n=>n.toString(16).padStart(2,"0")),pe=class{static makeHexColor(e,t,r){return`#${PS[e]}${PS[t]}${PS[r]}`}static scaleMinMax(e,t){let r;e[0]?(e[0]<0&&(r=t[0],t[0]=t[2],t[2]=r),t[0]*=e[0],t[2]*=e[0],e[3]<0&&(r=t[1],t[1]=t[3],t[3]=r),t[1]*=e[3],t[3]*=e[3]):(r=t[0],t[0]=t[1],t[1]=r,r=t[2],t[2]=t[3],t[3]=r,e[1]<0&&(r=t[1],t[1]=t[3],t[3]=r),t[1]*=e[1],t[3]*=e[1],e[2]<0&&(r=t[0],t[0]=t[2],t[2]=r),t[0]*=e[2],t[2]*=e[2]),t[0]+=e[4],t[1]+=e[5],t[2]+=e[4],t[3]+=e[5]}static transform(e,t){return[e[0]*t[0]+e[2]*t[1],e[1]*t[0]+e[3]*t[1],e[0]*t[2]+e[2]*t[3],e[1]*t[2]+e[3]*t[3],e[0]*t[4]+e[2]*t[5]+e[4],e[1]*t[4]+e[3]*t[5]+e[5]]}static applyTransform(e,t){let r=e[0]*t[0]+e[1]*t[2]+t[4],i=e[0]*t[1]+e[1]*t[3]+t[5];return[r,i]}static applyInverseTransform(e,t){let r=t[0]*t[3]-t[1]*t[2],i=(e[0]*t[3]-e[1]*t[2]+t[2]*t[5]-t[4]*t[3])/r,s=(-e[0]*t[1]+e[1]*t[0]+t[4]*t[1]-t[5]*t[0])/r;return[i,s]}static getAxialAlignedBoundingBox(e,t){let r=this.applyTransform(e,t),i=this.applyTransform(e.slice(2,4),t),s=this.applyTransform([e[0],e[3]],t),o=this.applyTransform([e[2],e[1]],t);return[Math.min(r[0],i[0],s[0],o[0]),Math.min(r[1],i[1],s[1],o[1]),Math.max(r[0],i[0],s[0],o[0]),Math.max(r[1],i[1],s[1],o[1])]}static inverseTransform(e){let t=e[0]*e[3]-e[1]*e[2];return[e[3]/t,-e[1]/t,-e[2]/t,e[0]/t,(e[2]*e[5]-e[4]*e[3])/t,(e[4]*e[1]-e[5]*e[0])/t]}static singularValueDecompose2dScale(e){let t=[e[0],e[2],e[1],e[3]],r=e[0]*t[0]+e[1]*t[2],i=e[0]*t[1]+e[1]*t[3],s=e[2]*t[0]+e[3]*t[2],o=e[2]*t[1]+e[3]*t[3],a=(r+o)/2,c=Math.sqrt((r+o)**2-4*(r*o-s*i))/2,l=a+c||1,u=a-c||1;return[Math.sqrt(l),Math.sqrt(u)]}static normalizeRect(e){let t=e.slice(0);return e[0]>e[2]&&(t[0]=e[2],t[2]=e[0]),e[1]>e[3]&&(t[1]=e[3],t[3]=e[1]),t}static intersect(e,t){let r=Math.max(Math.min(e[0],e[2]),Math.min(t[0],t[2])),i=Math.min(Math.max(e[0],e[2]),Math.max(t[0],t[2]));if(r>i)return null;let s=Math.max(Math.min(e[1],e[3]),Math.min(t[1],t[3])),o=Math.min(Math.max(e[1],e[3]),Math.max(t[1],t[3]));return s>o?null:[r,s,i,o]}static#e(e,t,r,i,s,o,a,c,l,u){if(l<=0||l>=1)return;let d=1-l,f=l*l,p=f*l,y=d*(d*(d*e+3*l*t)+3*f*r)+p*i,v=d*(d*(d*s+3*l*o)+3*f*a)+p*c;u[0]=Math.min(u[0],y),u[1]=Math.min(u[1],v),u[2]=Math.max(u[2],y),u[3]=Math.max(u[3],v)}static#t(e,t,r,i,s,o,a,c,l,u,d,f){if(Math.abs(l)<1e-12){Math.abs(u)>=1e-12&&this.#e(e,t,r,i,s,o,a,c,-d/u,f);return}let p=u**2-4*d*l;if(p<0)return;let y=Math.sqrt(p),v=2*l;this.#e(e,t,r,i,s,o,a,c,(-u+y)/v,f),this.#e(e,t,r,i,s,o,a,c,(-u-y)/v,f)}static bezierBoundingBox(e,t,r,i,s,o,a,c,l){return l?(l[0]=Math.min(l[0],e,a),l[1]=Math.min(l[1],t,c),l[2]=Math.max(l[2],e,a),l[3]=Math.max(l[3],t,c)):l=[Math.min(e,a),Math.min(t,c),Math.max(e,a),Math.max(t,c)],this.#t(e,r,s,a,t,i,o,c,3*(-e+3*(r-s)+a),6*(e-2*r+s),3*(r-e),l),this.#t(e,r,s,a,t,i,o,c,3*(-t+3*(i-o)+c),6*(t-2*i+o),3*(i-t),l),l}};function rne(n){return decodeURIComponent(escape(n))}var MS=null,Kj=null;function ine(n){return MS||(MS=/([\u00a0\u00b5\u037e\u0eb3\u2000-\u200a\u202f\u2126\ufb00-\ufb04\ufb06\ufb20-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufba1\ufba4-\ufba9\ufbae-\ufbb1\ufbd3-\ufbdc\ufbde-\ufbe7\ufbea-\ufbf8\ufbfc-\ufbfd\ufc00-\ufc5d\ufc64-\ufcf1\ufcf5-\ufd3d\ufd88\ufdf4\ufdfa-\ufdfb\ufe71\ufe77\ufe79\ufe7b\ufe7d]+)|(\ufb05+)/gu,Kj=new Map([["\uFB05","\u017Ft"]])),n.replaceAll(MS,(e,t,r)=>t?t.normalize("NFKC"):Kj.get(r))}function sne(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();let n=new Uint8Array(32);return crypto.getRandomValues(n),u$(n)}var rD="pdfjs_internal_id_";function one(n){return Uint8Array.prototype.toBase64?n.toBase64():btoa(u$(n))}typeof Promise.try!="function"&&(Promise.try=function(n,...e){return new Promise(t=>{t(n(...e))})});var ho="http://www.w3.org/2000/svg",la=class{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF};function q_(n,e="text"){return m(this,null,function*(){if(tf(n,document.baseURI)){let t=yield fetch(n);if(!t.ok)throw new Error(t.statusText);switch(e){case"arraybuffer":return t.arrayBuffer();case"blob":return t.blob();case"json":return t.json()}return t.text()}return new Promise((t,r)=>{let i=new XMLHttpRequest;i.open("GET",n,!0),i.responseType=e,i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE){if(i.status===200||i.status===0){switch(e){case"arraybuffer":case"blob":case"json":t(i.response);return}t(i.responseText);return}r(new Error(i.statusText))}},i.send(null)})})}var of=class n{constructor({viewBox:e,userUnit:t,scale:r,rotation:i,offsetX:s=0,offsetY:o=0,dontFlip:a=!1}){this.viewBox=e,this.userUnit=t,this.scale=r,this.rotation=i,this.offsetX=s,this.offsetY=o,r*=t;
83let c=(e[2]+e[0])/2,l=(e[3]+e[1])/2,u,d,f,p;switch(i%=360,i<0&&(i+=360),i){case 180:u=-1,d=0,f=0,p=1;break;case 90:u=0,d=1,f=1,p=0;break;case 270:u=0,d=-1,f=-1,p=0;break;case 0:u=1,d=0,f=0,p=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}a&&(f=-f,p=-p);let y,v,w,E;u===0?(y=Math.abs(l-e[1])*r+s,v=Math.abs(c-e[0])*r+o,w=(e[3]-e[1])*r,E=(e[2]-e[0])*r):(y=Math.abs(c-e[0])*r+s,v=Math.abs(l-e[1])*r+o,w=(e[2]-e[0])*r,E=(e[3]-e[1])*r),this.transform=[u*r,d*r,f*r,p*r,y-u*r*c-f*r*l,v-d*r*c-p*r*l],this.width=w,this.height=E}get rawDims(){let{userUnit:e,viewBox:t}=this,r=t.map(i=>i*e);return Xe(this,"rawDims",{pageWidth:r[2]-r[0],pageHeight:r[3]-r[1],pageX:r[0],pageY:r[1]})}clone({scale:e=this.scale,rotation:t=this.rotation,offsetX:r=this.offsetX,offsetY:i=this.offsetY,dontFlip:s=!1}={}){return new n({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:e,rotation:t,offsetX:r,offsetY:i,dontFlip:s})}convertToViewportPoint(e,t){return pe.applyTransform([e,t],this.transform)}convertToViewportRectangle(e){let t=pe.applyTransform([e[0],e[1]],this.transform),r=pe.applyTransform([e[2],e[3]],this.transform);return[t[0],t[1],r[0],r[1]]}convertToPdfPoint(e,t){return pe.applyInverseTransform([e,t],this.transform)}},af=class extends ua{constructor(e,t=0){super(e,"RenderingCancelledException"),this.extraDelay=t}};function z_(n){let e=n.length,t=0;for(;t<e&&n[t].trim()==="";)t++;return n.substring(t,t+5).toLowerCase()==="data:"}function iD(n){return typeof n=="string"&&/\.pdf$/i.test(n)}function ane(n){return[n]=n.split(/[#?]/,1),n.substring(n.lastIndexOf("/")+1)}function cne(n,e="document.pdf"){if(typeof n!="string")return e;if(z_(n))return $e('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),e;let t=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/,r=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,i=t.exec(n),s=r.exec(i[1])||r.exec(i[2])||r.exec(i[3]);if(s&&(s=s[0],s.includes("%")))try{s=r.exec(decodeURIComponent(s))[0]}catch{}return s||e}var d_=class{started=Object.create(null);times=[];time(e){e in this.started&&$e(`Timer is already running for ${e}`),this.started[e]=Date.now()}timeEnd(e){e in this.started||$e(`Timer has not been started for ${e}`),this.times.push({name:e,start:this.started[e],end:Date.now()}),delete this.started[e]}toString(){let e=[],t=0;for(let{name:r}of this.times)t=Math.max(r.length,t);for(let{name:r,start:i,end:s}of this.times)e.push(`${r.padEnd(t)} ${s-i}ms 84`);return e.join("")}};function tf(n,e){try{let{protocol:t}=e?new URL(n,e):new URL(n);return t==="http:"||t==="https:"}catch{return!1}}function Ni(n){n.preventDefault()}function $r(n){n.preventDefault(),n.stopPropagation()}var h_=class{static#e;static toDateObject(e){if(!e||typeof e!="string")return null;this.#e||=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?");let t=this.#e.exec(e);if(!t)return null;let r=parseInt(t[1],10),i=parseInt(t[2],10);i=i>=1&&i<=12?i-1:0;let s=parseInt(t[3],10);s=s>=1&&s<=31?s:1;let o=parseInt(t[4],10);o=o>=0&&o<=23?o:0;let a=parseInt(t[5],10);a=a>=0&&a<=59?a:0;let c=parseInt(t[6],10);c=c>=0&&c<=59?c:0;let l=t[7]||"Z",u=parseInt(t[8],10);u=u>=0&&u<=23?u:0;let d=parseInt(t[9],10)||0;return d=d>=0&&d<=59?d:0,l==="-"?(o+=u,a+=d):l==="+"&&(o-=u,a-=d),new Date(Date.UTC(r,i,s,o,a,c))}};function lne(n,{scale:e=1,rotation:t=0}){let{width:r,height:i}=n.attributes.style,s=[0,0,parseInt(r),parseInt(i)];return new of({viewBox:s,userUnit:1,scale:e,rotation:t})}function sD(n){if(n.startsWith("#")){let e=parseInt(n.slice(1),16);return[(e&16711680)>>16,(e&65280)>>8,e&255]}return n.startsWith("rgb(")?n.slice(4,-1).split(",").map(e=>parseInt(e)):n.startsWith("rgba(")?n.slice(5,-1).split(",").map(e=>parseInt(e)).slice(0,3):($e(`Not a valid color format: "${n}"`),[0,0,0])}function une(n){let e=document.createElement("span");e.style.visibility="hidden",document.body.append(e);for(let t of n.keys()){e.style.color=t;let r=window.getComputedStyle(e).color;n.set(t,sD(r))}e.remove()}function Ot(n){let{a:e,b:t,c:r,d:i,e:s,f:o}=n.getTransform();return[e,t,r,i,s,o]}function ms(n){let{a:e,b:t,c:r,d:i,e:s,f:o}=n.getTransform().invertSelf();return[e,t,r,i,s,o]}function Tc(n,e,t=!1,r=!0){if(e instanceof of){let{pageWidth:i,pageHeight:s}=e.rawDims,{style:o}=n,a=Cn.isCSSRoundSupported,c=`var(--scale-factor) * ${i}px`,l=`var(--scale-factor) * ${s}px`,u=a?`round(down, ${c}, var(--scale-round-x, 1px))`:`calc(${c})`,d=a?`round(down, ${l}, var(--scale-round-y, 1px))`:`calc(${l})`;!t||e.rotation%180===0?(o.width=u,o.height=d):(o.width=d,o.height=u)}r&&n.setAttribute("data-main-rotation",e.rotation)}var cf=class{constructor(){let e=window.devicePixelRatio||1;this.sx=e,this.sy=e}get scaled(){return this.sx!==1||this.sy!==1}get symmetric(){return this.sx===this.sy}},jS=class n{#e=null;#t=null;#n;#r=null;#s=null;static#i=null;constructor(e){this.#n=e,n.#i||=Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button"})}render(){let e=this.#e=document.createElement("div");e.classList.add("editToolbar","hidden"),e.setAttribute("role","toolbar");let t=this.#n._uiManager._signal;e.addEventListener("contextmenu",Ni,{signal:t}),e.addEventListener("pointerdown",n.#c,{signal:t});let r=this.#r=document.createElement("div");r.className="buttons",e.append(r);let i=this.#n.toolbarPosition;if(i){let{style:s}=e,o=this.#n._uiManager.direction==="ltr"?1-i[0]:i[0];s.insetInlineEnd=`${100*o}%`,s.top=`calc(${100*i[1]}% + var(--editor-toolbar-vert-offset))`}return this.#h(),e}get div(){return this.#e}static#c(e){e.stopPropagation()}#a(e){this.#n._focusEventsAllowed=!1,$r(e)}#u(e){this.#n._focusEventsAllowed=!0,$r(e)}#l(e){let t=this.#n._uiManager._signal;e.addEventListener("focusin",this.#a.bind(this),{capture:!0,signal:t}),e.addEventListener("focusout",this.#u.bind(this),{capture:!0,signal:t}),e.addEventListener("contextmenu",Ni,{signal:t})}hide(){this.#e.classList.add("hidden"),this.#t?.hideDropdown()}show(){this.#e.classList.remove("hidden"),this.#s?.shown()}#h(){let{editorType:e,_uiManager:t}=this.#n,r=document.createElement("button");r.className="delete",r.tabIndex=0,r.setAttribute("data-l10n-id",n.#i[e]),this.#l(r),r.addEventListener("click",i=>{t.delete()},{signal:t._signal}),this.#r.append(r)}get#d(){let e=document.createElement("div");return e.className="divider",e}addAltText(e){return m(this,null,function*(){let t=yield e.render();this.#l(t),this.#r.prepend(t,this.#d),this.#s=e})}
84addColorPicker(e){this.#t=e;let t=e.renderButton();this.#l(t),this.#r.prepend(t,this.#d)}remove(){this.#e.remove(),this.#t?.destroy(),this.#t=null}},$S=class{#e=null;#t=null;#n;constructor(e){this.#n=e}#r(){let e=this.#t=document.createElement("div");e.className="editToolbar",e.setAttribute("role","toolbar"),e.addEventListener("contextmenu",Ni,{signal:this.#n._signal});let t=this.#e=document.createElement("div");return t.className="buttons",e.append(t),this.#i(),e}#s(e,t){let r=0,i=0;for(let s of e){let o=s.y+s.height;if(o<r)continue;let a=s.x+(t?s.width:0);if(o>r){i=a,r=o;continue}t?a>i&&(i=a):a<i&&(i=a)}return[t?1-i:i,r]}show(e,t,r){let[i,s]=this.#s(t,r),{style:o}=this.#t||=this.#r();e.append(this.#t),o.insetInlineEnd=`${100*i}%`,o.top=`calc(${100*s}% + var(--editor-toolbar-vert-offset))`}hide(){this.#t.remove()}#i(){let e=document.createElement("button");e.className="highlightButton",e.tabIndex=0,e.setAttribute("data-l10n-id","pdfjs-highlight-floating-button1");let t=document.createElement("span");e.append(t),t.className="visuallyHidden",t.setAttribute("data-l10n-id","pdfjs-highlight-floating-button-label");let r=this.#n._signal;e.addEventListener("contextmenu",Ni,{signal:r}),e.addEventListener("click",()=>{this.#n.highlightSelection("floating_button")},{signal:r}),this.#e.append(e)}};function f_(n,e,t){for(let r of t)e.addEventListener(r,n[r].bind(n))}var US=class{#e=0;get id(){return`${Wte}${this.#e++}`}},BS=class n{#e=sne();#t=0;#n=null;static get _isSVGFittingCanvas(){let e='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>',r=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),i=new Image;i.src=e;let s=i.decode().then(()=>(r.drawImage(i,0,0,1,1,0,0,1,3),new Uint32Array(r.getImageData(0,0,1,1).data.buffer)[0]===0));return Xe(this,"_isSVGFittingCanvas",s)}#r(e,t){return m(this,null,function*(){this.#n||=new Map;let r=this.#n.get(e);if(r===null)return null;if(r?.bitmap)return r.refCounter+=1,r;try{r||={bitmap:null,id:`image_${this.#e}_${this.#t++}`,refCounter:0,isSvg:!1};let i;if(typeof t=="string"?(r.url=t,i=yield q_(t,"blob")):t instanceof File?i=r.file=t:t instanceof Blob&&(i=t),i.type==="image/svg+xml"){let s=n._isSVGFittingCanvas,o=new FileReader,a=new Image,c=new Promise((l,u)=>{a.onload=()=>{r.bitmap=a,r.isSvg=!0,l()},o.onload=()=>m(this,null,function*(){let d=r.svgUrl=o.result;a.src=(yield s)?`${d}#svgView(preserveAspectRatio(none))`:d}),a.onerror=o.onerror=u});o.readAsDataURL(i),yield c}else r.bitmap=yield createImageBitmap(i);r.refCounter=1}catch(i){$e(i),r=null}return this.#n.set(e,r),r&&this.#n.set(r.id,r),r})}getFromFile(e){return m(this,null,function*(){let{lastModified:t,name:r,size:i,type:s}=e;return this.#r(`${t}_${r}_${i}_${s}`,e)})}getFromUrl(e){return m(this,null,function*(){return this.#r(e,e)})}getFromBlob(e,t){return m(this,null,function*(){let r=yield t;return this.#r(e,r)})}getFromId(e){return m(this,null,function*(){this.#n||=new Map;let t=this.#n.get(e);if(!t)return null;if(t.bitmap)return t.refCounter+=1,t;if(t.file)return this.getFromFile(t.file);if(t.blobPromise){let{blobPromise:r}=t;return delete t.blobPromise,this.getFromBlob(t.id,r)}return this.getFromUrl(t.url)})}getFromCanvas(e,t){this.#n||=new Map;let r=this.#n.get(e);if(r?.bitmap)return r.refCounter+=1,r;let i=new OffscreenCanvas(t.width,t.height);return i.getContext("2d").drawImage(t,0,0),r={bitmap:i.transferToImageBitmap(),id:`image_${this.#e}_${this.#t++}`,refCounter:1,isSvg:!1},this.#n.set(e,r),this.#n.set(r.id,r),r}getSvgUrl(e){let t=this.#n.get(e);return t?.isSvg?t.svgUrl:null}deleteId(e){this.#n||=new Map;let t=this.#n.get(e);if(!t||(t.refCounter-=1,t.refCounter!==0))return;let{bitmap:r}=t;if(!t.url&&!t.file){let i=new OffscreenCanvas(r.width,r.height);i.getContext("bitmaprenderer").transferFromImageBitmap(r),t.blobPromise=i.convertToBlob()}r.close?.(),t.bitmap=null}isValidId(e){return e.startsWith(`image_${this.#e}_`)}},HS=class{#e=[];#t=!1;#n;#r=-1;constructor(e=128){this.#n=e}add({cmd:e,undo:t,post:r,mustExec:i,type:s=NaN,overwriteIfSameType:o=!1,keepUndo:a=!1}){if(i&&e(),this.#t)return;let c={cmd:e,undo:t,post:r,type:s};if(this.#r===-1){this.#e.length>0&&(this.#e.length=0),this.#r=0,this.#e.push(c);return}if(o&&this.#e[this.#r].type===s){a&&(c.undo=this.#e[this.#r].undo),this.#e[this.#r]=c;return}let l=this.#r+1;l===this.#n?this.#e.splice(0,1):(this.#r=l,l<this.#e.length&&this.#e.splice(l)),this.#e.push(c)}undo(){if(this.#r===-1)return;this.#t=!0;let{undo:e,post:t}=this.#e[this.#r];e(),t?.(),this.#t=!1,this.#r-=1}redo(){if(this.#r<this.#e.length-1){this.#r+=1,this.#t=!0;let{cmd:e,post:t}=this.#e[this.#r];e(),t?.(),this.#t=!1}}hasSomethingToUndo(){return this.#r!==-1}hasSomethingToRedo(){return this.#r<this.#e.length-1}cleanType(e){if(this.#r!==-1){for(let t=this.#r;t>=0;t--)if(this.#e[t].type!==e){this.#e.splice(t+1,this.#r-t),this.#r=t;return}this.#e.length=0,this.#r=-1}}destroy(){this.#e=null}},Ac=class{constructor(e){this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;let{isMac:t}=Cn.platform;for(let[r,i,s={}]of e)for(let o of r){let a=o.startsWith("mac+");t&&a?(this.callbacks.set(o.slice(4),{callback:i,options:s}),this.allKeys.add(o.split("+").at(-1))):!t&&!a&&(this.callbacks.set(o,{callback:i,options:s}),this.allKeys.add(o.split("+").at(-1)))}}#e(e){e.altKey&&this.buffer.push("alt"),e.ctrlKey&&this.buffer.push("ctrl"),e.metaKey&&this.buffer.push("meta"),e.shiftKey&&this.buffer.push("shift"),this.buffer.push(e.key);let t=this.buffer.join("+");return this.buffer.length=0,t}exec(e,t){if(!this.allKeys.has(t.key))return;let r=this.callbacks.get(this.#e(t));if(!r)return;let{callback:i,options:{bubbles:s=!1,args:o=[],checker:a=null}}=r;a&&!a(e,t)||(i.bind(e,...o,t)(),s||$r(t))}},qS=class n{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){let e=new Map([["CanvasText",null],["Canvas",null]]);return une(e),Xe(this,"_colors",e)}convert(e){let t=sD(e);if(!window.matchMedia("(forced-colors: active)").matches)return t;for(let[r,i]of this._colors)if(i.every((s,o)=>s===t[o]))return n._colorsMapping.get(r);return t}getHexCode(e){let t=this._colors.get(e);return t?pe.makeHexColor(...t):e}},lf=(()=>{class n{#e=new AbortController;#t=null;#n=new Map;#r=new Map;#s=null;#i=null;#c=null;#a=new HS;#u=null;#l=null;#h=0;#d=new Set;#f=null;#o=null;#p=new Set;_editorUndoBar=null;#g=!1;#m=!1;#y=!1;#b=null;#_=null;#w=null;#I=null;#A=!1;#S=null;#D=new US;#E=!1;#x=!1;#C=null;#k=null;#N=null;#L=null;#T=je.NONE;#v=new Set;#M=null;#U=null;#B=null;#H={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#F=[0,0];#O=null;#V=null;#q=null;#P=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){let t=n.prototype,r=a=>a.#V.contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&a.hasSomethingToControl(),i=(a,{target:c})=>{if(c instanceof HTMLInputElement){let{type:l}=c;return l!=="text"&&l!=="number"}return!0},s=this.TRANSLATE_SMALL,o=this.TRANSLATE_BIG;return Xe(this,"_keyboardManager",new Ac([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:i}],[["ctrl+z","mac+meta+z"],t.undo,{checker:i}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.redo,{checker:i}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],t.delete,{checker:i}],[["Enter","mac+Enter"],t.addNewEditorFromKeyboard,{checker:(a,{target:c})=>
84!(c instanceof HTMLButtonElement)&&a.#V.contains(c)&&!a.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(a,{target:c})=>!(c instanceof HTMLButtonElement)&&a.#V.contains(document.activeElement)}],[["Escape","mac+Escape"],t.unselectAll],[["ArrowLeft","mac+ArrowLeft"],t.translateSelectedEditors,{args:[-s,0],checker:r}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-o,0],checker:r}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[s,0],checker:r}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[o,0],checker:r}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-s],checker:r}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-o],checker:r}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,s],checker:r}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,o],checker:r}]]))}constructor(t,r,i,s,o,a,c,l,u,d,f,p,y){let v=this._signal=this.#e.signal;this.#V=t,this.#q=r,this.#s=i,this._eventBus=s,s._on("editingaction",this.onEditingAction.bind(this),{signal:v}),s._on("pagechanging",this.onPageChanging.bind(this),{signal:v}),s._on("scalechanging",this.onScaleChanging.bind(this),{signal:v}),s._on("rotationchanging",this.onRotationChanging.bind(this),{signal:v}),s._on("setpreference",this.onSetPreference.bind(this),{signal:v}),s._on("switchannotationeditorparams",w=>this.updateParams(w.type,w.value),{signal:v}),this.#te(),this.#se(),this.#K(),this.#i=o.annotationStorage,this.#b=o.filterFactory,this.#U=a,this.#I=c||null,this.#g=l,this.#m=u,this.#y=d,this.#L=f||null,this.viewParameters={realScale:la.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=p||null,this._supportsPinchToZoom=y!==!1}destroy(){this.#P?.resolve(),this.#P=null,this.#e?.abort(),this.#e=null,this._signal=null;for(let t of this.#r.values())t.destroy();this.#r.clear(),this.#n.clear(),this.#p.clear(),this.#t=null,this.#v.clear(),this.#a.destroy(),this.#s?.destroy(),this.#S?.hide(),this.#S=null,this.#_&&(clearTimeout(this.#_),this.#_=null),this.#O&&(clearTimeout(this.#O),this.#O=null),this._editorUndoBar?.destroy()}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return this.#L}get useNewAltTextFlow(){return this.#m}get useNewAltTextWhenAddingImage(){return this.#y}get hcmFilter(){return Xe(this,"hcmFilter",this.#U?this.#b.addHCMFilter(this.#U.foreground,this.#U.background):"none")}get direction(){return Xe(this,"direction",getComputedStyle(this.#V).direction)}get highlightColors(){return Xe(this,"highlightColors",this.#I?new Map(this.#I.split(",").map(t=>t.split("=").map(r=>r.trim()))):null)}get highlightColorNames(){return Xe(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}setCurrentDrawingSession(t){t?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),this.#l=t}setMainHighlightColorPicker(t){this.#N=t}editAltText(t,r=!1){this.#s?.editAltText(this,t,r)}switchToMode(t,r){this._eventBus.on("annotationeditormodechanged",r,{once:!0,signal:this._signal}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:t})}setPreference(t,r){this._eventBus.dispatch("setpreference",{source:this,name:t,value:r})}onSetPreference({name:t,value:r}){switch(t){case"enableNewAltTextWhenAddingImage":this.#y=r;break}}onPageChanging({pageNumber:t}){this.#h=t-1}focusMainContainer(){this.#V.focus()}findParent(t,r){for(let i of this.#r.values()){let{x:s,y:o,width:a,height:c}=i.div.getBoundingClientRect();if(t>=s&&t<=s+a&&r>=o&&r<=o+c)return i}return null}disableUserSelect(t=!1){this.#q.classList.toggle("noUserSelect",t)}addShouldRescale(t){this.#p.add(t)}removeShouldRescale(t){this.#p.delete(t)}onScaleChanging({scale:t}){this.commitOrRemove(),this.viewParameters.realScale=t*la.PDF_TO_CSS_UNITS;for(let r of this.#p)r.onScaleChanging();this.#l?.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}#j({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t}#W(t){let{currentLayer:r}=this;if(r.hasTextLayer(t))return r;for(let i of this.#r.values())if(i.hasTextLayer(t))return i;return null}highlightSelection(t=""){let r=document.getSelection();if(!r||r.isCollapsed)return;let{anchorNode:i,anchorOffset:s,focusNode:o,focusOffset:a}=r,c=r.toString(),u=this.#j(r).closest(".textLayer"),d=this.getSelectionBoxes(u);if(!d)return;r.empty();let f=this.#W(u),p=this.#T===je.NONE,y=()=>{f?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:d,anchorNode:i,anchorOffset:s,focusNode:o,focusOffset:a,text:c}),p&&this.showAllEditors("highlight",!0,!0)};if(p){this.switchToMode(je.HIGHLIGHT,y);return}y()}#J(){let t=document.getSelection();if(!t||t.isCollapsed)return;let i=this.#j(t).closest(".textLayer"),s=this.getSelectionBoxes(i);s&&(this.#S||=new $S(this),this.#S.show(i,s,this.direction==="ltr"))}addToAnnotationStorage(t){!t.isEmpty()&&this.#i&&!this.#i.has(t.id)&&this.#i.setValue(t.id,t)}#ee(){let t=document.getSelection();if(!t||t.isCollapsed){this.#M&&(this.#S?.hide(),this.#M=null,this.#R({hasSelectedText:!1}));return}let{anchorNode:r}=t;if(r===this.#M)return;let s=this.#j(t).closest(".textLayer");if(!s){this.#M&&(this.#S?.hide(),this.#M=null,this.#R({hasSelectedText:!1}));return}if(this.#S?.hide(),this.#M=r,this.#R({hasSelectedText:!0}),!(this.#T!==je.HIGHLIGHT&&this.#T!==je.NONE)&&(this.#T===je.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#A=this.isShiftKeyDown,!this.isShiftKeyDown)){let o=this.#T===je.HIGHLIGHT?this.#W(s):null;o?.toggleDrawing();let a=new AbortController,c=this.combinedSignal(a),l=u=>{u.type==="pointerup"&&u.button!==0||(a.abort(),o?.toggleDrawing(!0),u.type==="pointerup"&&this.#G("main_toolbar"))};window.addEventListener("pointerup",l,{signal:c}),window.addEventListener("blur",l,{signal:c})}}#G(t=""){this.#T===je.HIGHLIGHT?this.highlightSelection(t):this.#g&&this.#J()}#te(){document.addEventListener("selectionchange",this.#ee.bind(this),{signal:this._signal})}
84#ne(){if(this.#w)return;this.#w=new AbortController;let t=this.combinedSignal(this.#w);window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})}#re(){this.#w?.abort(),this.#w=null}blur(){if(this.isShiftKeyDown=!1,this.#A&&(this.#A=!1,this.#G("main_toolbar")),!this.hasSelection)return;let{activeElement:t}=document;for(let r of this.#v)if(r.div.contains(t)){this.#k=[r,t],r._focusEventsAllowed=!1;break}}focus(){if(!this.#k)return;let[t,r]=this.#k;this.#k=null,r.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),r.focus()}#K(){if(this.#C)return;this.#C=new AbortController;let t=this.combinedSignal(this.#C);window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})}#ie(){this.#C?.abort(),this.#C=null}#Y(){if(this.#u)return;this.#u=new AbortController;let t=this.combinedSignal(this.#u);document.addEventListener("copy",this.copy.bind(this),{signal:t}),document.addEventListener("cut",this.cut.bind(this),{signal:t}),document.addEventListener("paste",this.paste.bind(this),{signal:t})}#X(){this.#u?.abort(),this.#u=null}#se(){let t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}addEditListeners(){this.#K(),this.#Y()}removeEditListeners(){this.#ie(),this.#X()}dragOver(t){for(let{type:r}of t.dataTransfer.items)for(let i of this.#o)if(i.isHandlingMimeForPasting(r)){t.dataTransfer.dropEffect="copy",t.preventDefault();return}}drop(t){for(let r of t.dataTransfer.items)for(let i of this.#o)if(i.isHandlingMimeForPasting(r.type)){i.paste(r,this.currentLayer),t.preventDefault();return}}copy(t){if(t.preventDefault(),this.#t?.commitOrRemove(),!this.hasSelection)return;let r=[];for(let i of this.#v){let s=i.serialize(!0);s&&r.push(s)}r.length!==0&&t.clipboardData.setData("application/pdfjs",JSON.stringify(r))}cut(t){this.copy(t),this.delete()}paste(t){return m(this,null,function*(){t.preventDefault();let{clipboardData:r}=t;for(let o of r.items)for(let a of this.#o)if(a.isHandlingMimeForPasting(o.type)){a.paste(o,this.currentLayer);return}let i=r.getData("application/pdfjs");if(!i)return;try{i=JSON.parse(i)}catch(o){$e(`paste: "${o.message}".`);return}if(!Array.isArray(i))return;this.unselectAll();let s=this.currentLayer;try{let o=[];for(let l of i){let u=yield s.deserialize(l);if(!u)return;o.push(u)}let a=()=>{for(let l of o)this.#Q(l);this.#Z(o)},c=()=>{for(let l of o)l.remove()};this.addCommands({cmd:a,undo:c,mustExec:!0})}catch(o){$e(`paste: "${o.message}".`)}})}keydown(t){!this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!0),this.#T!==je.NONE&&!this.isEditorHandlingKeyboard&&n._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!1,this.#A&&(this.#A=!1,this.#G("main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu");break}}#R(t){Object.entries(t).some(([i,s])=>this.#H[i]!==s)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(this.#H,t)}),this.#T===je.HIGHLIGHT&&t.hasSelectedEditor===!1&&this.#$([[rt.HIGHLIGHT_FREE,!0]]))}#$(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){t?(this.#ne(),this.#Y(),this.#R({isEditing:this.#T!==je.NONE,isEmpty:this.#z(),hasSomethingToUndo:this.#a.hasSomethingToUndo(),hasSomethingToRedo:this.#a.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#re(),this.#X(),this.#R({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!this.#o){this.#o=t;for(let r of this.#o)this.#$(r.defaultPropertiesToUpdate)}}getId(){return this.#D.id}get currentLayer(){return this.#r.get(this.#h)}getLayer(t){return this.#r.get(t)}get currentPageIndex(){return this.#h}addLayer(t){this.#r.set(t.pageIndex,t),this.#E?t.enable():t.disable()}removeLayer(t){this.#r.delete(t.pageIndex)}updateMode(t,r=null,i=!1){return m(this,null,function*(){if(this.#T!==t&&!(this.#P&&(yield this.#P.promise,!this.#P))){if(this.#P=Promise.withResolvers(),this.#T=t,t===je.NONE){this.setEditingState(!1),this.#ae(),this._editorUndoBar?.hide(),this.#P.resolve();return}this.setEditingState(!0),yield this.#oe(),this.unselectAll();for(let s of this.#r.values())s.updateMode(t);if(!r){i&&this.addNewEditorFromKeyboard(),this.#P.resolve();return}for(let s of this.#n.values())s.annotationElementId===r?(this.setSelected(s),s.enterInEditMode()):s.unselect();this.#P.resolve()}})}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t!==this.#T&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:t})}updateParams(t,r){if(this.#o){switch(t){case rt.CREATE:this.currentLayer.addNewEditor();return;case rt.HIGHLIGHT_DEFAULT_COLOR:this.#N?.updateColor(r);break;case rt.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#B||=new Map).set(t,r),this.showAllEditors("highlight",r);break}for(let i of this.#v)i.updateParams(t,r);for(let i of this.#o)i.updateDefaultParams(t,r)}}showAllEditors(t,r,i=!1){for(let o of this.#n.values())o.editorType===t&&o.show(r);(this.#B?.get(rt.HIGHLIGHT_SHOW_ALL)??!0)!==r&&this.#$([[rt.HIGHLIGHT_SHOW_ALL,r]])}enableWaiting(t=!1){if(this.#x!==t){this.#x=t;for(let r of this.#r.values())t?r.disableClick():r.enableClick(),r.div.classList.toggle("waiting",t)}}
vendor: 10,901 bytes, line 84
84#oe(){return m(this,null,function*(){if(!this.#E){this.#E=!0;let t=[];for(let r of this.#r.values())t.push(r.enable());yield Promise.all(t);for(let r of this.#n.values())r.enable()}})}#ae(){if(this.unselectAll(),this.#E){this.#E=!1;for(let t of this.#r.values())t.disable();for(let t of this.#n.values())t.disable()}}getEditors(t){let r=[];for(let i of this.#n.values())i.pageIndex===t&&r.push(i);return r}getEditor(t){return this.#n.get(t)}addEditor(t){this.#n.set(t.id,t)}removeEditor(t){t.div.contains(document.activeElement)&&(this.#_&&clearTimeout(this.#_),this.#_=setTimeout(()=>{this.focusMainContainer(),this.#_=null},0)),this.#n.delete(t.id),this.unselect(t),(!t.annotationElementId||!this.#d.has(t.annotationElementId))&&this.#i?.remove(t.id)}addDeletedAnnotationElement(t){this.#d.add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return this.#d.has(t)}removeDeletedAnnotationElement(t){this.#d.delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}#Q(t){let r=this.#r.get(t.pageIndex);r?r.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))}setActiveEditor(t){this.#t!==t&&(this.#t=t,t&&this.#$(t.propertiesToUpdate))}get#ce(){let t=null;for(t of this.#v);return t}updateUI(t){this.#ce===t&&this.#$(t.propertiesToUpdate)}updateUIForDefaultProperties(t){this.#$(t.defaultPropertiesToUpdate)}toggleSelected(t){if(this.#v.has(t)){this.#v.delete(t),t.unselect(),this.#R({hasSelectedEditor:this.hasSelection});return}this.#v.add(t),t.select(),this.#$(t.propertiesToUpdate),this.#R({hasSelectedEditor:!0})}setSelected(t){this.#l?.commitOrRemove();for(let r of this.#v)r!==t&&r.unselect();this.#v.clear(),this.#v.add(t),t.select(),this.#$(t.propertiesToUpdate),this.#R({hasSelectedEditor:!0})}isSelected(t){return this.#v.has(t)}get firstSelectedEditor(){return this.#v.values().next().value}unselect(t){t.unselect(),this.#v.delete(t),this.#R({hasSelectedEditor:this.hasSelection})}get hasSelection(){return this.#v.size!==0}get isEnterHandled(){return this.#v.size===1&&this.firstSelectedEditor.isEnterHandled}undo(){this.#a.undo(),this.#R({hasSomethingToUndo:this.#a.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#z()}),this._editorUndoBar?.hide()}redo(){this.#a.redo(),this.#R({hasSomethingToUndo:!0,hasSomethingToRedo:this.#a.hasSomethingToRedo(),isEmpty:this.#z()})}addCommands(t){this.#a.add(t),this.#R({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#z()})}cleanUndoStack(t){this.#a.cleanType(t)}#z(){if(this.#n.size===0)return!0;if(this.#n.size===1)for(let t of this.#n.values())return t.isEmpty();return!1}delete(){this.commitOrRemove();let t=this.currentLayer?.endDrawingSession(!0);if(!this.hasSelection&&!t)return;let r=t?[t]:[...this.#v],i=()=>{this._editorUndoBar?.show(s,r.length===1?r[0].editorType:r.length);for(let o of r)o.remove()},s=()=>{for(let o of r)this.#Q(o)};this.addCommands({cmd:i,undo:s,mustExec:!0})}commitOrRemove(){this.#t?.commitOrRemove()}hasSomethingToControl(){return this.#t||this.hasSelection}#Z(t){for(let r of this.#v)r.unselect();this.#v.clear();for(let r of t)r.isEmpty()||(this.#v.add(r),r.select());this.#R({hasSelectedEditor:this.hasSelection})}selectAll(){for(let t of this.#v)t.commit();this.#Z(this.#n.values())}unselectAll(){if(!(this.#t&&(this.#t.commitOrRemove(),this.#T!==je.NONE))&&!this.#l?.commitOrRemove()&&this.hasSelection){for(let t of this.#v)t.unselect();this.#v.clear(),this.#R({hasSelectedEditor:!1})}}translateSelectedEditors(t,r,i=!1){if(i||this.commitOrRemove(),!this.hasSelection)return;this.#F[0]+=t,this.#F[1]+=r;let[s,o]=this.#F,a=[...this.#v],c=1e3;this.#O&&clearTimeout(this.#O),this.#O=setTimeout(()=>{this.#O=null,this.#F[0]=this.#F[1]=0,this.addCommands({cmd:()=>{for(let l of a)this.#n.has(l.id)&&l.translateInPage(s,o)},undo:()=>{for(let l of a)this.#n.has(l.id)&&l.translateInPage(-s,-o)},mustExec:!1})},c);for(let l of a)l.translateInPage(t,r)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#f=new Map;for(let t of this.#v)this.#f.set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#f)return!1;this.disableUserSelect(!1);let t=this.#f;this.#f=null;let r=!1;for(let[{x:s,y:o,pageIndex:a},c]of t)c.newX=s,c.newY=o,c.newPageIndex=a,r||=s!==c.savedX||o!==c.savedY||a!==c.savedPageIndex;if(!r)return!1;let i=(s,o,a,c)=>{if(this.#n.has(s.id)){let l=this.#r.get(c);l?s._setParentAndPosition(l,o,a):(s.pageIndex=c,s.x=o,s.y=a)}};return this.addCommands({cmd:()=>{for(let[s,{newX:o,newY:a,newPageIndex:c}]of t)i(s,o,a,c)},undo:()=>{for(let[s,{savedX:o,savedY:a,savedPageIndex:c}]of t)i(s,o,a,c)},mustExec:!0}),!0}dragSelectedEditors(t,r){if(this.#f)for(let i of this.#f.keys())i.drag(t,r)}rebuild(t){if(t.parent===null){let r=this.getLayer(t.pageIndex);r?(r.changeParent(t),r.addOrRebuild(t)):(this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild())}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){return this.getActive()?.shouldGetKeyboardEvents()||this.#v.size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return this.#t===t}getActive(){return this.#t}getMode(){return this.#T}get imageManager(){return Xe(this,"imageManager",new BS)}getSelectionBoxes(t){if(!t)return null;let r=document.getSelection();for(let u=0,d=r.rangeCount;u<d;u++)if(!t.contains(r.getRangeAt(u).commonAncestorContainer))return null;let{x:i,y:s,width:o,height:a}=t.getBoundingClientRect(),c;switch(t.getAttribute("data-main-rotation")){case"90":c=(u,d,f,p)=>({x:(d-s)/a,y:1-(u+f-i)/o,width:p/a,height:f/o});break;case"180":c=(u,d,f,p)=>({x:1-(u+f-i)/o,y:1-(d+p-s)/a,width:f/o,height:p/a});break;case"270":c=(u,d,f,p)=>({x:1-(d+p-s)/a,y:(u-i)/o,width:p/a,height:f/o});break;default:c=(u,d,f,p)=>({x:(u-i)/o,y:(d-s)/a,width:f/o,height:p/a});break}let l=[];for(let u=0,d=r.rangeCount;u<d;u++){let f=r.getRangeAt(u);if(!f.collapsed)for(let{x:p,y,width:v,height:w}of f.getClientRects())v===0||w===0||l.push(c(p,y,v,w))}return l.length===0?null:l}addChangedExistingAnnotation({annotationElementId:t,id:r}){(this.#c||=new Map).set(t,r)}removeChangedExistingAnnotation({annotationElementId:t}){this.#c?.delete(t)}renderAnnotationElement(t){let r=this.#c?.get(t.data.id);if(!r)return;let i=this.#i.getRawValue(r);i&&(this.#T===je.NONE&&!i.hasBeenModified||i.renderAnnotationElement(t))}}return n})(),Yj=(()=>{class n{#e=null;#t=!1;#n=null;#r=null;#s=null;#i=null;#c=!1;#a=null;#u=null;#l=null;#h=null;#d=!1;static#f=null;static _l10n=null;constructor(t){this.#u=t,this.#d=t._uiManager.useNewAltTextFlow,n.#f||=Object.freeze({added:"pdfjs-editor-new-alt-text-added-button","added-label":"pdfjs-editor-new-alt-text-added-button-label",missing:"pdfjs-editor-new-alt-text-missing-button","missing-label":"pdfjs-editor-new-alt-text-missing-button-label",review:"pdfjs-editor-new-alt-text-to-review-button","review-label":"pdfjs-editor-new-alt-text-to-review-button-label"})}static initialize(t){n._l10n??=t}render(){return m(this,null,function*(){let t=this.#n=document.createElement("button");t.className="altText",t.tabIndex="0";let r=this.#r=document.createElement("span");t.append(r),this.#d?(t.classList.add("new"),t.setAttribute("data-l10n-id",n.#f.missing),r.setAttribute("data-l10n-id",n.#f["missing-label"])):(t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),r.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));let i=this.#u._uiManager._signal;t.addEventListener("contextmenu",Ni,{signal:i}),t.addEventListener("pointerdown",o=>o.stopPropagation(),{signal:i});let s=o=>{o.preventDefault(),this.#u._uiManager.editAltText(this.#u),this.#d&&this.#u._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:this.#o}})};return t.addEventListener("click",s,{capture:!0,signal:i}),t.addEventListener("keydown",o=>{o.target===t&&o.key==="Enter"&&(this.#c=!0,s(o))},{signal:i}),yield this.#p(),t})}get#o(){return this.#e&&"added"||this.#e===null&&this.guessedText&&"review"||"missing"}finish(){this.#n&&(this.#n.focus({focusVisible:this.#c}),this.#c=!1)}isEmpty(){return this.#d?this.#e===null:!this.#e&&!this.#t}hasData(){return this.#d?this.#e!==null||!!this.#l:this.isEmpty()}get guessedText(){return this.#l}setGuessedText(t){return m(this,null,function*(){this.#e===null&&(this.#l=t,this.#h=yield n._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t}),this.#p())})}toggleAltTextBadge(t=!1){if(!this.#d||this.#e){this.#a?.remove(),this.#a=null;return}if(!this.#a){let r=this.#a=document.createElement("div");r.className="noAltTextBadge",this.#u.div.append(r)}this.#a.classList.toggle("hidden",!t)}serialize(t){let r=this.#e;return!t&&this.#l===r&&(r=this.#h),{altText:r,decorative:this.#t,guessedText:this.#l,textWithDisclaimer:this.#h}}get data(){return{altText:this.#e,decorative:this.#t}}set data({altText:t,decorative:r,guessedText:i,textWithDisclaimer:s,cancel:o=!1}){i&&(this.#l=i,this.#h=s),!(this.#e===t&&this.#t===r)&&(o||(this.#e=t,this.#t=r),this.#p())}toggle(t=!1){this.#n&&(!t&&this.#i&&(clearTimeout(this.#i),this.#i=null),this.#n.disabled=!t)}shown(){this.#u._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:this.#o}})}destroy(){this.#n?.remove(),this.#n=null,this.#r=null,this.#s=null,this.#a?.remove(),this.#a=null}#p(){return m(this,null,function*(){let t=this.#n;if(!t)return;if(this.#d){if(t.classList.toggle("done",!!this.#e),t.setAttribute("data-l10n-id",n.#f[this.#o]),this.#r?.setAttribute("data-l10n-id",n.#f[`${this.#o}-label`]),!this.#e){this.#s?.remove();return}}else{if(!this.#e&&!this.#t){t.classList.remove("done"),this.#s?.remove();return}t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let r=this.#s;if(!r){this.#s=r=document.createElement("span"),r.className="tooltip",r.setAttribute("role","tooltip"),r.id=`alt-text-tooltip-${this.#u.id}`;let s=100,o=this.#u._uiManager._signal;o.addEventListener("abort",()=>{clearTimeout(this.#i),this.#i=null},{once:!0}),t.addEventListener("mouseenter",()=>{this.#i=setTimeout(()=>{this.#i=null,this.#s.classList.add("show"),this.#u._reportTelemetry({action:"alt_text_tooltip"})},s)},{signal:o}),t.addEventListener("mouseleave",()=>{this.#i&&(clearTimeout(this.#i),this.#i=null),this.#s?.classList.remove("show")},{signal:o})}this.#t?r.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(r.removeAttribute("data-l10n-id"),r.textContent=this.#e),r.parentNode||t.append(r),this.#u.getImageForAltText()?.setAttribute("aria-describedby",r.id)})}}return n})(),p_=class n{#e;#t=!1;#n=null;#r;#s;#i;#c;#a;#u=null;#l;#h=null;constructor({container:e,isPinchingDisabled:t=null,isPinchingStopped:r=null,onPinchStart:i=null,onPinching:s=null,onPinchEnd:o=null,signal:a}){this.#e=e,this.#n=r,this.#r=t,this.#s=i,this.#i=s,this.#c=o,this.#l=ne
84w AbortController,this.#a=AbortSignal.any([a,this.#l.signal]),e.addEventListener("touchstart",this.#d.bind(this),{passive:!1,signal:this.#a})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return Xe(this,"MIN_TOUCH_DISTANCE_TO_PINCH",35/(window.devicePixelRatio||1))}#d(e){if(this.#r?.()||e.touches.length<2)return;if(!this.#h){this.#h=new AbortController;let i=AbortSignal.any([this.#a,this.#h.signal]),s=this.#e,o={signal:i,passive:!1};s.addEventListener("touchmove",this.#f.bind(this),o),s.addEventListener("touchend",this.#o.bind(this),o),s.addEventListener("touchcancel",this.#o.bind(this),o),this.#s?.()}if($r(e),e.touches.length!==2||this.#n?.()){this.#u=null;return}let[t,r]=e.touches;t.identifier>r.identifier&&([t,r]=[r,t]),this.#u={touch0X:t.screenX,touch0Y:t.screenY,touch1X:r.screenX,touch1Y:r.screenY}}#f(e){if(!this.#u||e.touches.length!==2)return;let[t,r]=e.touches;t.identifier>r.identifier&&([t,r]=[r,t]);let{screenX:i,screenY:s}=t,{screenX:o,screenY:a}=r,c=this.#u,{touch0X:l,touch0Y:u,touch1X:d,touch1Y:f}=c,p=d-l,y=f-u,v=o-i,w=a-s,E=Math.hypot(v,w)||1,A=Math.hypot(p,y)||1;if(!this.#t&&Math.abs(A-E)<=n.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(c.touch0X=i,c.touch0Y=s,c.touch1X=o,c.touch1Y=a,e.preventDefault(),!this.#t){this.#t=!0;return}let x=[(i+o)/2,(s+a)/2];this.#i?.(x,A,E)}#o(e){this.#h.abort(),this.#h=null,this.#c?.(),this.#u&&(e.preventDefault(),this.#u=null,this.#t=!1)}destroy(){this.#l?.abort(),this.#l=null}},Vt=class n{#e=null;#t=null;#n=null;#r=!1;#s=null;#i="";#c=!1;#a=null;#u=null;#l=null;#h=null;#d="";#f=!1;#o=null;#p=!1;#g=!1;#m=!1;#y=null;#b=0;#_=0;#w=null;#I=null;_editToolbar=null;_initialOptions=Object.create(null);_initialData=null;_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;static _l10n=null;static _l10nResizer=null;#A=!1;#S=n._zIndex++;static _borderLineWidth=-1;static _colorManager=new qS;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){let e=n.prototype._resizeWithKeyboard,t=lf.TRANSLATE_SMALL,r=lf.TRANSLATE_BIG;return Xe(this,"_resizerKeyboardManager",new Ac([[["ArrowLeft","mac+ArrowLeft"],e,{args:[-t,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e,{args:[-r,0]}],[["ArrowRight","mac+ArrowRight"],e,{args:[t,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e,{args:[r,0]}],[["ArrowUp","mac+ArrowUp"],e,{args:[0,-t]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e,{args:[0,-r]}],[["ArrowDown","mac+ArrowDown"],e,{args:[0,t]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e,{args:[0,r]}],[["Escape","mac+Escape"],n.prototype._stopResizingWithKeyboard]]))}constructor(e){this.parent=e.parent,this.id=e.id,this.width=this.height=null,this.pageIndex=e.parent.pageIndex,this.name=e.name,this.div=null,this._uiManager=e.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=e.isCentered,this._structTreeParentId=null;let{rotation:t,rawDims:{pageWidth:r,pageHeight:i,pageX:s,pageY:o}}=this.parent.viewport;this.rotation=t,this.pageRotation=(360+t-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[r,i],this.pageTranslation=[s,o];let[a,c]=this.parentDimensions;this.x=e.x/a,this.y=e.y/c,this.isAttachedToDOM=!1,this.deleted=!1}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get isDrawer(){return!1}static get _defaultLineColor(){return Xe(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(e){let t=new zS({id:e.parent.getNextId(),parent:e.parent,uiManager:e._uiManager});t.annotationElementId=e.annotationElementId,t.deleted=!0,t._uiManager.addToAnnotationStorage(t)}static initialize(e,t){if(n._l10n??=e,n._l10nResizer||=Object.freeze({topLeft:"pdfjs-editor-resizer-top-left",topMiddle:"pdfjs-editor-resizer-top-middle",topRight:"pdfjs-editor-resizer-top-right",middleRight:"pdfjs-editor-resizer-middle-right",bottomRight:"pdfjs-editor-resizer-bottom-right",bottomMiddle:"pdfjs-editor-resizer-bottom-middle",bottomLeft:"pdfjs-editor-resizer-bottom-left",middleLeft:"pdfjs-editor-resizer-middle-left"}),n._borderLineWidth!==-1)return;let r=getComputedStyle(document.documentElement);n._borderLineWidth=parseFloat(r.getPropertyValue("--outline-width"))||0}static updateDefaultParams(e,t){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(e){return!1}static paste(e,t){Ct("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#A}set _isDraggable(e){this.#A=e,this.div?.classList.toggle("draggable",e)}get isEnterHandled(){return!0}center(){let[e,t]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*t/(e*2),this.y+=this.width*e/(t*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*t/(e*2),this.y-=this.width*e/(t*2);break;default:this.x-=this.width/2,this.y-=this.height/2;break}this.fixAndSetPosition()}addCommands(e){this._uiManager.addCommands(e)}get currentLayer(){return this._uiManager.currentLayer}
84setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=this.#S}setParent(e){e!==null?(this.pageIndex=e.pageIndex,this.pageDimensions=e.pageDimensions):this.#j(),this.parent=e}focusin(e){this._focusEventsAllowed&&(this.#f?this.#f=!1:this.parent.setSelected(this))}focusout(e){!this._focusEventsAllowed||!this.isAttachedToDOM||e.relatedTarget?.closest(`#${this.id}`)||(e.preventDefault(),this.parent?.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(e,t,r,i){let[s,o]=this.parentDimensions;[r,i]=this.screenToPageTranslation(r,i),this.x=(e+r)/s,this.y=(t+i)/o,this.fixAndSetPosition()}#D([e,t],r,i){[r,i]=this.screenToPageTranslation(r,i),this.x+=r/e,this.y+=i/t,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}translate(e,t){this.#D(this.parentDimensions,e,t)}translateInPage(e,t){this.#o||=[this.x,this.y,this.width,this.height],this.#D(this.pageDimensions,e,t),this.div.scrollIntoView({block:"nearest"})}drag(e,t){this.#o||=[this.x,this.y,this.width,this.height];let{div:r,parentDimensions:[i,s]}=this;if(this.x+=e/i,this.y+=t/s,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){let{x:d,y:f}=this.div.getBoundingClientRect();this.parent.findNewParent(this,d,f)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:o,y:a}=this,[c,l]=this.getBaseTranslation();o+=c,a+=l;let{style:u}=r;u.left=`${(100*o).toFixed(2)}%`,u.top=`${(100*a).toFixed(2)}%`,this._onTranslating(o,a),r.scrollIntoView({block:"nearest"})}_onTranslating(e,t){}_onTranslated(e,t){}get _hasBeenMoved(){return!!this.#o&&(this.#o[0]!==this.x||this.#o[1]!==this.y)}get _hasBeenResized(){return!!this.#o&&(this.#o[2]!==this.width||this.#o[3]!==this.height)}getBaseTranslation(){let[e,t]=this.parentDimensions,{_borderLineWidth:r}=n,i=r/e,s=r/t;switch(this.rotation){case 90:return[-i,s];case 180:return[i,s];case 270:return[i,-s];default:return[-i,-s]}}get _mustFixPosition(){return!0}fixAndSetPosition(e=this.rotation){let{div:{style:t},pageDimensions:[r,i]}=this,{x:s,y:o,width:a,height:c}=this;if(a*=r,c*=i,s*=r,o*=i,this._mustFixPosition)switch(e){case 0:s=Math.max(0,Math.min(r-a,s)),o=Math.max(0,Math.min(i-c,o));break;case 90:s=Math.max(0,Math.min(r-c,s)),o=Math.min(i,Math.max(a,o));break;case 180:s=Math.min(r,Math.max(a,s)),o=Math.min(i,Math.max(c,o));break;case 270:s=Math.min(r,Math.max(c,s)),o=Math.max(0,Math.min(i-a,o));break}this.x=s/=r,this.y=o/=i;let[l,u]=this.getBaseTranslation();s+=l,o+=u,t.left=`${(100*s).toFixed(2)}%`,t.top=`${(100*o).toFixed(2)}%`,this.moveInDOM()}static#E(e,t,r){switch(r){case 90:return[t,-e];case 180:return[-e,-t];case 270:return[-t,e];default:return[e,t]}}screenToPageTranslation(e,t){return n.#E(e,t,this.parentRotation)}pageTranslationToScreen(e,t){return n.#E(e,t,360-this.parentRotation)}#x(e){switch(e){case 90:{let[t,r]=this.pageDimensions;return[0,-t/r,r/t,0]}case 180:return[-1,0,0,-1];case 270:{let[t,r]=this.pageDimensions;return[0,t/r,-r/t,0]}default:return[1,0,0,1]}}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){let{parentScale:e,pageDimensions:[t,r]}=this;return[t*e,r*e]}setDims(e,t){let[r,i]=this.parentDimensions,{style:s}=this.div;s.width=`${(100*e/r).toFixed(2)}%`,this.#c||(s.height=`${(100*t/i).toFixed(2)}%`)}fixDims(){let{style:e}=this.div,{height:t,width:r}=e,i=r.endsWith("%"),s=!this.#c&&t.endsWith("%");if(i&&s)return;let[o,a]=this.parentDimensions;i||(e.width=`${(100*parseFloat(r)/o).toFixed(2)}%`),!this.#c&&!s&&(e.height=`${(100*parseFloat(t)/a).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}#C(){if(this.#a)return;this.#a=document.createElement("div"),this.#a.classList.add("resizers");let e=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],t=this._uiManager._signal;for(let r of e){let i=document.createElement("div");this.#a.append(i),i.classList.add("resizer",r),i.setAttribute("data-resizer-name",r),i.addEventListener("pointerdown",this.#k.bind(this,r),{signal:t}),i.addEventListener("contextmenu",Ni,{signal:t}),i.tabIndex=-1}this.div.prepend(this.#a)}#k(e,t){t.preventDefault();let{isMac:r}=Cn.platform;if(t.button!==0||t.ctrlKey&&r)return;this.#n?.toggle(!1);let i=this._isDraggable;this._isDraggable=!1,this.#u=[t.screenX,t.screenY];let s=new AbortController,o=this._uiManager.combinedSignal(s);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",this.#T.bind(this,e),{passive:!0,capture:!0,signal:o}),window.addEventListener("touchmove",$r,{passive:!1,signal:o}),window.addEventListener("contextmenu",Ni,{signal:o}),this.#l={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let a=this.parent.div.style.cursor,c=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(t.target).cursor;let l=()=>{s.abort(),this.parent.togglePointerEvents(!0),this.#n?.toggle(!0),this._isDraggable=i,this.parent.div.style.cursor=a,this.div.style.cursor=c,this.#L()};window.addEventListener("pointerup",l,{signal:o}),window.addEventListener("blur",l,{signal:o})}#N(e,t,r,i){this.width=r,this.height=i,this.x=e,this.y=t;let[s,o]=this.parentDimensions;this.setDims(s*r,o*i),this.fixAndSetPosition(),this._onResized()}_onResized(){}#L(){if(!this.#l)return;
84let{savedX:e,savedY:t,savedWidth:r,savedHeight:i}=this.#l;this.#l=null;let s=this.x,o=this.y,a=this.width,c=this.height;s===e&&o===t&&a===r&&c===i||this.addCommands({cmd:this.#N.bind(this,s,o,a,c),undo:this.#N.bind(this,e,t,r,i),mustExec:!0})}static _round(e){return Math.round(e*1e4)/1e4}#T(e,t){let[r,i]=this.parentDimensions,s=this.x,o=this.y,a=this.width,c=this.height,l=n.MIN_SIZE/r,u=n.MIN_SIZE/i,d=this.#x(this.rotation),f=(le,ce)=>[d[0]*le+d[2]*ce,d[1]*le+d[3]*ce],p=this.#x(360-this.rotation),y=(le,ce)=>[p[0]*le+p[2]*ce,p[1]*le+p[3]*ce],v,w,E=!1,A=!1;switch(e){case"topLeft":E=!0,v=(le,ce)=>[0,0],w=(le,ce)=>[le,ce];break;case"topMiddle":v=(le,ce)=>[le/2,0],w=(le,ce)=>[le/2,ce];break;case"topRight":E=!0,v=(le,ce)=>[le,0],w=(le,ce)=>[0,ce];break;case"middleRight":A=!0,v=(le,ce)=>[le,ce/2],w=(le,ce)=>[0,ce/2];break;case"bottomRight":E=!0,v=(le,ce)=>[le,ce],w=(le,ce)=>[0,0];break;case"bottomMiddle":v=(le,ce)=>[le/2,ce],w=(le,ce)=>[le/2,0];break;case"bottomLeft":E=!0,v=(le,ce)=>[0,ce],w=(le,ce)=>[le,0];break;case"middleLeft":A=!0,v=(le,ce)=>[0,ce/2],w=(le,ce)=>[le,ce/2];break}let x=v(a,c),M=w(a,c),O=f(...M),$=n._round(s+O[0]),C=n._round(o+O[1]),T=1,S=1,k,P;if(t.fromKeyboard)({deltaX:k,deltaY:P}=t);else{let{screenX:le,screenY:ce}=t,[un,ur]=this.#u;[k,P]=this.screenToPageTranslation(le-un,ce-ur),this.#u[0]=le,this.#u[1]=ce}if([k,P]=y(k/r,P/i),E){let le=Math.hypot(a,c);T=S=Math.max(Math.min(Math.hypot(M[0]-x[0]-k,M[1]-x[1]-P)/le,1/a,1/c),l/a,u/c)}else A?T=Math.max(l,Math.min(1,Math.abs(M[0]-x[0]-k)))/a:S=Math.max(u,Math.min(1,Math.abs(M[1]-x[1]-P)))/c;let N=n._round(a*T),R=n._round(c*S);O=f(...w(N,R));let ze=$-O[0],Yt=C-O[1];this.#o||=[this.x,this.y,this.width,this.height],this.width=N,this.height=R,this.x=ze,this.y=Yt,this.setDims(r*N,i*R),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#n?.finish()}addEditToolbar(){return m(this,null,function*(){return this._editToolbar||this.#g?this._editToolbar:(this._editToolbar=new jS(this),this.div.append(this._editToolbar.render()),this.#n&&(yield this._editToolbar.addAltText(this.#n)),this._editToolbar)})}removeEditToolbar(){this._editToolbar&&(this._editToolbar.remove(),this._editToolbar=null,this.#n?.destroy())}addContainer(e){let t=this._editToolbar?.div;t?t.before(e):this.div.append(e)}getClientDimensions(){return this.div.getBoundingClientRect()}addAltTextButton(){return m(this,null,function*(){this.#n||(Yj.initialize(n._l10n),this.#n=new Yj(this),this.#e&&(this.#n.data=this.#e,this.#e=null),yield this.addEditToolbar())})}get altTextData(){return this.#n?.data}set altTextData(e){this.#n&&(this.#n.data=e)}get guessedAltText(){return this.#n?.guessedText}setGuessedAltText(e){return m(this,null,function*(){yield this.#n?.setGuessedText(e)})}serializeAltText(e){return this.#n?.serialize(e)}hasAltText(){return!!this.#n&&!this.#n.isEmpty()}hasAltTextData(){return this.#n?.hasData()??!1}render(){this.div=document.createElement("div"),this.div.setAttribute("data-editor-rotation",(360-this.rotation)%360),this.div.className=this.name,this.div.setAttribute("id",this.id),this.div.tabIndex=this.#r?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground(),this.#F();let[e,t]=this.parentDimensions;this.parentRotation%180!==0&&(this.div.style.maxWidth=`${(100*t/e).toFixed(2)}%`,this.div.style.maxHeight=`${(100*e/t).toFixed(2)}%`);let[r,i]=this.getInitialTranslation();return this.translate(r,i),f_(this,this.div,["pointerdown"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(this.#I||=new p_({container:this.div,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#v.bind(this),onPinching:this.#M.bind(this),onPinchEnd:this.#U.bind(this),signal:this._uiManager._signal})),this._uiManager._editorUndoBar?.hide(),this.div}
vendor: 2,773 bytes, line 84
84#v(){this.#l={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#n?.toggle(!1),this.parent.togglePointerEvents(!1)}#M(e,t,r){let s=.7*(r/t)+1-.7;if(s===1)return;let o=this.#x(this.rotation),a=($,C)=>[o[0]*$+o[2]*C,o[1]*$+o[3]*C],[c,l]=this.parentDimensions,u=this.x,d=this.y,f=this.width,p=this.height,y=n.MIN_SIZE/c,v=n.MIN_SIZE/l;s=Math.max(Math.min(s,1/f,1/p),y/f,v/p);let w=n._round(f*s),E=n._round(p*s);if(w===f&&E===p)return;this.#o||=[u,d,f,p];let A=a(f/2,p/2),x=n._round(u+A[0]),M=n._round(d+A[1]),O=a(w/2,E/2);this.x=x-O[0],this.y=M-O[1],this.width=w,this.height=E,this.setDims(c*w,l*E),this.fixAndSetPosition(),this._onResizing()}#U(){this.#n?.toggle(!0),this.parent.togglePointerEvents(!0),this.#L()}pointerdown(e){let{isMac:t}=Cn.platform;if(e.button!==0||e.ctrlKey&&t){e.preventDefault();return}if(this.#f=!0,this._isDraggable){this.#H(e);return}this.#B(e)}get isSelected(){return this._uiManager.isSelected(this)}#B(e){let{isMac:t}=Cn.platform;e.ctrlKey&&!t||e.shiftKey||e.metaKey&&t?this.parent.toggleSelected(this):this.parent.setSelected(this)}#H(e){let{isSelected:t}=this;this._uiManager.setUpDragSession();let r=!1,i=new AbortController,s=this._uiManager.combinedSignal(i),o={capture:!0,passive:!1,signal:s},a=l=>{i.abort(),this.#s=null,this.#f=!1,this._uiManager.endDragSession()||this.#B(l),r&&this._onStopDragging()};t&&(this.#b=e.clientX,this.#_=e.clientY,this.#s=e.pointerId,this.#i=e.pointerType,window.addEventListener("pointermove",l=>{r||(r=!0,this._onStartDragging());let{clientX:u,clientY:d,pointerId:f}=l;if(f!==this.#s){$r(l);return}let[p,y]=this.screenToPageTranslation(u-this.#b,d-this.#_);this.#b=u,this.#_=d,this._uiManager.dragSelectedEditors(p,y)},o),window.addEventListener("touchmove",$r,o),window.addEventListener("pointerdown",l=>{l.pointerType===this.#i&&(this.#I||l.isPrimary)&&a(l),$r(l)},o));let c=l=>{if(!this.#s||this.#s===l.pointerId){a(l);return}$r(l)};window.addEventListener("pointerup",c,{signal:s}),window.addEventListener("blur",c,{signal:s})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){this.#y&&clearTimeout(this.#y),this.#y=setTimeout(()=>{this.#y=null,this.parent?.moveEditorInDOM(this)},0)}_setParentAndPosition(e,t,r){e.changeParent(this),this.x=t,this.y=r,this.fixAndSetPosition(),this._onTranslated()}getRect(e,t,r=this.rotation){let i=this.parentScale,[s,o]=this.pageDimensions,[a,c]=this.pageTranslation,l=e/i,u=t/i,d=this.x*s,f=this.y*o,p=this.width*s,y=this.height*o;switch(r){case 0:return[d+l+a,o-f-u-y+c,d+l+p+a,o-f-u+c];case 90:return[d+u+a,o-f+l+c,d+u+y+a,o-f+l+p+c];case 180:return[d-l-p+a,o-f+u+c,d-l+a,o-f+u+y+c];case 270:return[d-u-y+a,o-f-l-p+c,d-u+a,o-f-l+c];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(e,t){let[r,i,s,o]=e,a=s-r,c=o-i;
84switch(this.rotation){case 0:return[r,t-o,a,c];case 90:return[r,t-i,c,a];case 180:return[s,t-i,a,c];case 270:return[s,t-o,c,a];default:throw new Error("Invalid rotation")}}onceAdded(e){}isEmpty(){return!1}enableEditMode(){this.#g=!0}disableEditMode(){this.#g=!1}isInEditMode(){return this.#g}shouldGetKeyboardEvents(){return this.#m}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){let{top:e,left:t,bottom:r,right:i}=this.getClientDimensions(),{innerHeight:s,innerWidth:o}=window;return t<o&&i>0&&e<s&&r>0}#F(){if(this.#h||!this.div)return;this.#h=new AbortController;let e=this._uiManager.combinedSignal(this.#h);this.div.addEventListener("focusin",this.focusin.bind(this),{signal:e}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:e})}rebuild(){this.#F()}rotate(e){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize(e=!1,t=null){Ct("An editor must be serializable")}static deserialize(e,t,r){return m(this,null,function*(){let i=new this.prototype.constructor({parent:t,id:t.getNextId(),uiManager:r});i.rotation=e.rotation,i.#e=e.accessibilityData;let[s,o]=i.pageDimensions,[a,c,l,u]=i.getRectInCurrentCoords(e.rect,o);return i.x=a/s,i.y=c/o,i.width=l/s,i.height=u/o,i})}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){if(this.#h?.abort(),this.#h=null,this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.#y&&(clearTimeout(this.#y),this.#y=null),this.#j(),this.removeEditToolbar(),this.#w){for(let e of this.#w.values())clearTimeout(e);this.#w=null}this.parent=null,this.#I?.destroy(),this.#I=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#C(),this.#a.classList.remove("hidden"),f_(this,this.div,["keydown"]))}get toolbarPosition(){return null}keydown(e){if(!this.isResizable||e.target!==this.div||e.key!=="Enter")return;this._uiManager.setSelected(this),this.#l={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let t=this.#a.children;if(!this.#t){this.#t=Array.from(t);let o=this.#O.bind(this),a=this.#V.bind(this),c=this._uiManager._signal;for(let l of this.#t){let u=l.getAttribute("data-resizer-name");l.setAttribute("role","spinbutton"),l.addEventListener("keydown",o,{signal:c}),l.addEventListener("blur",a,{signal:c}),l.addEventListener("focus",this.#q.bind(this,u),{signal:c}),l.setAttribute("data-l10n-id",n._l10nResizer[u])}}let r=this.#t[0],i=0;for(let o of t){if(o===r)break;i++}let s=(360-this.rotation+this.parentRotation)%360/90*(this.#t.length/4);if(s!==i){if(s<i)for(let a=0;a<i-s;a++)this.#a.append(this.#a.firstChild);else if(s>i)for(let a=0;a<s-i;a++)this.#a.firstChild.before(this.#a.lastChild);let o=0;for(let a of t){let l=this.#t[o++].getAttribute("data-resizer-name");a.setAttribute("data-l10n-id",n._l10nResizer[l])}}this.#P(0),this.#m=!0,this.#a.firstChild.focus({focusVisible:!0}),e.preventDefault(),e.stopImmediatePropagation()}#O(e){n._resizerKeyboardManager.exec(this,e)}#V(e){this.#m&&e.relatedTarget?.parentNode!==this.#a&&this.#j()}#q(e){this.#d=this.#m?e:""}#P(e){if(this.#t)for(let t of this.#t)t.tabIndex=e}_resizeWithKeyboard(e,t){this.#m&&this.#T(this.#d,{deltaX:e,deltaY:t,fromKeyboard:!0})}#j(){this.#m=!1,this.#P(-1),this.#L()}_stopResizingWithKeyboard(){this.#j(),this.div.focus()}select(){if(this.makeResizable(),this.div?.classList.add("selectedEditor"),!this._editToolbar){this.addEditToolbar().then(()=>{this.div?.classList.contains("selectedEditor")&&this._editToolbar?.show()});return}this._editToolbar?.show(),this.#n?.toggleAltTextBadge(!1)}unselect(){this.#a?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this._editToolbar?.hide(),this.#n?.toggleAltTextBadge(!0)}updateParams(e,t){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return this.#p}set isEditing(e){this.#p=e,this.parent&&(e?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(e,t){this.#c=!0;let r=e/t,{style:i}=this.div;i.aspectRatio=r,i.height="auto"}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(e,t=!1){if(t){this.#w||=new Map;let{action:r}=e,i=this.#w.get(r);i&&clearTimeout(i),i=setTimeout(()=>{this._reportTelemetry(e),this.#w.delete(r),this.#w.size===0&&(this.#w=null)},n._telemetryTimeout),this.#w.set(r,i);return}e.type||=this.editorType,this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:e}})}show(e=this._isVisible){this.div.classList.toggle("hidden",!e),this._isVisible=e}enable(){this.div&&(this.div.tabIndex=0),this.#r=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#r=!0}renderAnnotationElement(e){let t=e.container.querySelector(".annotationContent");
84if(!t)t=document.createElement("div"),t.classList.add("annotationContent",this.editorType),e.container.prepend(t);else if(t.nodeName==="CANVAS"){let r=t;t=document.createElement("div"),t.classList.add("annotationContent",this.editorType),r.before(t)}return t}resetAnnotationElement(e){let{firstChild:t}=e.container;t?.nodeName==="DIV"&&t.classList.contains("annotationContent")&&t.remove()}},zS=class extends Vt{constructor(e){super(e),this.annotationElementId=e.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}},Xj=3285377520,Jr=4294901760,gs=65535,m_=class{constructor(e){this.h1=e?e&4294967295:Xj,this.h2=e?e&4294967295:Xj}update(e){let t,r;if(typeof e=="string"){t=new Uint8Array(e.length*2),r=0;for(let v=0,w=e.length;v<w;v++){let E=e.charCodeAt(v);E<=255?t[r++]=E:(t[r++]=E>>>8,t[r++]=E&255)}}else if(ArrayBuffer.isView(e))t=e.slice(),r=t.byteLength;else throw new Error("Invalid data format, must be a string or TypedArray.");let i=r>>2,s=r-i*4,o=new Uint32Array(t.buffer,0,i),a=0,c=0,l=this.h1,u=this.h2,d=3432918353,f=461845907,p=d&gs,y=f&gs;for(let v=0;v<i;v++)v&1?(a=o[v],a=a*d&Jr|a*p&gs,a=a<<15|a>>>17,a=a*f&Jr|a*y&gs,l^=a,l=l<<13|l>>>19,l=l*5+3864292196):(c=o[v],c=c*d&Jr|c*p&gs,c=c<<15|c>>>17,c=c*f&Jr|c*y&gs,u^=c,u=u<<13|u>>>19,u=u*5+3864292196);switch(a=0,s){case 3:a^=t[i*4+2]<<16;case 2:a^=t[i*4+1]<<8;case 1:a^=t[i*4],a=a*d&Jr|a*p&gs,a=a<<15|a>>>17,a=a*f&Jr|a*y&gs,i&1?l^=a:u^=a}this.h1=l,this.h2=u}hexdigest(){let e=this.h1,t=this.h2;return e^=t>>>1,e=e*3981806797&Jr|e*36045&gs,t=t*4283543511&Jr|((t<<16|e>>>16)*2950163797&Jr)>>>16,e^=t>>>1,e=e*444984403&Jr|e*60499&gs,t=t*3301882366&Jr|((t<<16|e>>>16)*3120437893&Jr)>>>16,e^=t>>>1,(e>>>0).toString(16).padStart(8,"0")+(t>>>0).toString(16).padStart(8,"0")}},GS=Object.freeze({map:null,hash:"",transfer:void 0}),uf=class{#e=!1;#t=null;#n=new Map;constructor(){this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(e,t){let r=this.#n.get(e);return r===void 0?t:Object.assign(t,r)}getRawValue(e){return this.#n.get(e)}remove(e){if(this.#n.delete(e),this.#n.size===0&&this.resetModified(),typeof this.onAnnotationEditor=="function"){for(let t of this.#n.values())if(t instanceof Vt)return;this.onAnnotationEditor(null)}}setValue(e,t){let r=this.#n.get(e),i=!1;if(r!==void 0)for(let[s,o]of Object.entries(t))r[s]!==o&&(i=!0,r[s]=o);else i=!0,this.#n.set(e,t);i&&this.#r(),t instanceof Vt&&typeof this.onAnnotationEditor=="function"&&this.onAnnotationEditor(t.constructor._type)}has(e){return this.#n.has(e)}getAll(){return this.#n.size>0?nD(this.#n):null}setAll(e){for(let[t,r]of Object.entries(e))this.setValue(t,r)}get size(){return this.#n.size}#r(){this.#e||(this.#e=!0,typeof this.onSetModified=="function"&&this.onSetModified())}resetModified(){this.#e&&(this.#e=!1,typeof this.onResetModified=="function"&&this.onResetModified())}get print(){return new g_(this)}get serializable(){if(this.#n.size===0)return GS;let e=new Map,t=new m_,r=[],i=Object.create(null),s=!1;for(let[o,a]of this.#n){let c=a instanceof Vt?a.serialize(!1,i):a;c&&(e.set(o,c),t.update(`${o}:${JSON.stringify(c)}`),s||=!!c.bitmap)}if(s)for(let o of e.values())o.bitmap&&r.push(o.bitmap);return e.size>0?{map:e,hash:t.hexdigest(),transfer:r}:GS}get editorStats(){let e=null,t=new Map;for(let r of this.#n.values()){if(!(r instanceof Vt))continue;let i=r.telemetryFinalData;if(!i)continue;let{type:s}=i;t.has(s)||t.set(s,Object.getPrototypeOf(r).constructor),e||=Object.create(null);let o=e[s]||=new Map;for(let[a,c]of Object.entries(i)){if(a==="type")continue;let l=o.get(a);l||(l=new Map,o.set(a,l));let u=l.get(c)??0;l.set(c,u+1)}}for(let[r,i]of t)e[r]=i.computeTelemetryFinalData(e[r]);return e}resetModifiedIds(){this.#t=null}get modifiedIds(){if(this.#t)return this.#t;let e=[];for(let t of this.#n.values())!(t instanceof Vt)||!t.annotationElementId||!t.serialize()||e.push(t.annotationElementId);return this.#t={ids:new Set(e),hash:e.join(",")}}},g_=class extends uf{#e;constructor(e){super();let{map:t,hash:r,transfer:i}=e.serializable,s=structuredClone(t,i?{transfer:i}:null);this.#e={map:s,hash:r,transfer:i}}get print(){Ct("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#e}get modifiedIds(){return Xe(this,"modifiedIds",{ids:new Set,hash:""})}},WS=class{#e=new Set;constructor({ownerDocument:e=globalThis.document,styleElement:t=null}){this._document=e,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(e){this.nativeFontFaces.add(e),this._document.fonts.add(e)}removeNativeFontFace(e){this.nativeFontFaces.delete(e),this._document.fonts.delete(e)}insertRule(e){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));let t=this.styleElement.sheet;t.insertRule(e,t.cssRules.length)}clear(){for(let e of this.nativeFontFaces)this._document.fonts.delete(e);this.nativeFontFaces.clear(),this.#e.clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}loadSystemFont(r){return m(this,arguments,function*({systemFontInfo:e,_inspectFont:t}
84){if(!(!e||this.#e.has(e.loadedName))){if(rn(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){let{loadedName:i,src:s,style:o}=e,a=new FontFace(i,s,o);this.addNativeFontFace(a);try{yield a.load(),this.#e.add(i),t?.(e)}catch{$e(`Cannot load system font: ${e.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(a)}return}Ct("Not implemented: loadSystemFont without the Font Loading API.")}})}bind(e){return m(this,null,function*(){if(e.attached||e.missingFile&&!e.systemFontInfo)return;if(e.attached=!0,e.systemFontInfo){yield this.loadSystemFont(e);return}if(this.isFontLoadingAPISupported){let r=e.createNativeFontFace();if(r){this.addNativeFontFace(r);try{yield r.loaded}catch(i){throw $e(`Failed to load font '${r.family}': '${i}'.`),e.disableFontFace=!0,i}}return}let t=e.createFontFaceRule();if(t){if(this.insertRule(t),this.isSyncFontLoadingSupported)return;yield new Promise(r=>{let i=this._queueLoadingCallback(r);this._prepareFontLoadEvent(e,i)})}})}get isFontLoadingAPISupported(){let e=!!this._document?.fonts;return Xe(this,"isFontLoadingAPISupported",e)}get isSyncFontLoadingSupported(){let e=!1;return(Hn||typeof navigator<"u"&&typeof navigator?.userAgent=="string"&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(e=!0),Xe(this,"isSyncFontLoadingSupported",e)}_queueLoadingCallback(e){function t(){for(rn(!i.done,"completeRequest() cannot be called twice."),i.done=!0;r.length>0&&r[0].done;){let s=r.shift();setTimeout(s.callback,0)}}let{loadingRequests:r}=this,i={done:!1,complete:t,callback:e};return r.push(i),i}get _loadTestFont(){let e=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return Xe(this,"_loadTestFont",e)}_prepareFontLoadEvent(e,t){function r(M,O){return M.charCodeAt(O)<<24|M.charCodeAt(O+1)<<16|M.charCodeAt(O+2)<<8|M.charCodeAt(O+3)&255}function i(M,O,$,C){let T=M.substring(0,O),S=M.substring(O+$);return T+C+S}let s,o,a=this._document.createElement("canvas");a.width=1,a.height=1;let c=a.getContext("2d"),l=0;function u(M,O){if(++l>30){$e("Load test font never loaded."),O();return}if(c.font="30px "+M,c.fillText(".",0,20),c.getImageData(0,0,1,1).data[3]>0){O();return}setTimeout(u.bind(null,M,O))}let d=`lt${Date.now()}${this.loadTestFontId++}`,f=this._loadTestFont;f=i(f,976,d.length,d);let y=16,v=1482184792,w=r(f,y);for(s=0,o=d.length-3;s<o;s+=4)w=w-v+r(d,s)|0;s<d.length&&(w=w-v+r(d+"XXX",s)|0),f=i(f,y,4,ene(w));let E=`url(data:font/opentype;base64,${btoa(f)});`,A=`@font-face {font-family:"${d}";src:${E}}`;this.insertRule(A);let x=this._document.createElement("div");x.style.visibility="hidden",x.style.width=x.style.height="10px",x.style.position="absolute",x.style.top=x.style.left="0px";for(let M of[e.loadedName,d]){let O=this._document.createElement("span");O.textContent="Hi",O.style.fontFamily=M,x.append(O)}this._document.body.append(x),u(d,()=>{x.remove(),t.complete()})}},KS=class{constructor(e,{disableFontFace:t=!1,fontExtraProperties:r=!1,inspectFont:i=null}){this.compiledGlyphs=Object.create(null);for(let s in e)this[s]=e[s];this.disableFontFace=t===!0,this.fontExtraProperties=r===!0,this._inspectFont=i}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let e;if(!this.cssFontInfo)e=new FontFace(this.loadedName,this.data,{});else{let t={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(t.style=`oblique ${this.cssFontInfo.italicAngle}deg`),e=new FontFace(this.cssFontInfo.fontFamily,this.data,t)}return this._inspectFont?.(this),e}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;let e=`url(data:${this.mimetype};base64,${one(this.data)});`,t;if(!this.cssFontInfo)t=`@font-face {font-family:"${this.loadedName}";src:${e}}`;else{let r=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(r+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),t=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${r}src:${e}}`}return this._inspectFont?.(this,e),t}getPathGenerator(e,t){if(this.compiledGlyphs[t]!==void 0)return this.compiledGlyphs[t];let r=this.loadedName+"_path_"+t,i;try{i=e.get(r)}catch(o){$e(`getPathGenerator - ignoring character: "${o}".`)}let s=new Path2D(i||"");return this.fontExtraProperties||e.delete(r),this.compiledGlyphs[t]=s}},i_={DATA:1,ERROR:2},nn={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function Qj(){}function vr(n){if(n instanceof ys||n instanceof sf||n instanceof Ic||n instanceof u_||n instanceof Du||n instanceof rf)return n;switch(n instanceof Error||typeof n=="object"&&n!==null||Ct('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),n.name){case"AbortException":return new ys(n.message);case"InvalidPDFException":return new sf(n.message);case"MissingPDFException":return new Ic(n.message);case"PasswordException":return new u_(n.message,n.code);case"UnexpectedResponseException":return new Du(n.message,n.status);case"UnknownErrorException":return new rf(n.message,n.details)}return new rf(n.message,n.toString())}var wc=class{#e=new AbortController;constructor(e,t,r){this.sourceName=e,this.targetName=t,this.comObj=r,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),r.addEventListener("message",this.#t.b
84ind(this),{signal:this.#e.signal})}#t({data:e}){if(e.targetName!==this.sourceName)return;if(e.stream){this.#r(e);return}if(e.callback){let r=e.callbackId,i=this.callbackCapabilities[r];if(!i)throw new Error(`Cannot resolve callback ${r}`);if(delete this.callbackCapabilities[r],e.callback===i_.DATA)i.resolve(e.data);else if(e.callback===i_.ERROR)i.reject(vr(e.reason));else throw new Error("Unexpected callback case");return}let t=this.actionHandler[e.action];if(!t)throw new Error(`Unknown action from worker: ${e.action}`);if(e.callbackId){let r=this.sourceName,i=e.sourceName,s=this.comObj;Promise.try(t,e.data).then(function(o){s.postMessage({sourceName:r,targetName:i,callback:i_.DATA,callbackId:e.callbackId,data:o})},function(o){s.postMessage({sourceName:r,targetName:i,callback:i_.ERROR,callbackId:e.callbackId,reason:vr(o)})});return}if(e.streamId){this.#n(e);return}t(e.data)}on(e,t){let r=this.actionHandler;if(r[e])throw new Error(`There is already an actionName called "${e}"`);r[e]=t}send(e,t,r){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,data:t},r)}sendWithPromise(e,t,r){let i=this.callbackId++,s=Promise.withResolvers();this.callbackCapabilities[i]=s;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,callbackId:i,data:t},r)}catch(o){s.reject(o)}return s.promise}sendWithStream(e,t,r,i){let s=this.streamId++,o=this.sourceName,a=this.targetName,c=this.comObj;return new ReadableStream({start:l=>{let u=Promise.withResolvers();return this.streamControllers[s]={controller:l,startCall:u,pullCall:null,cancelCall:null,isClosed:!1},c.postMessage({sourceName:o,targetName:a,action:e,streamId:s,data:t,desiredSize:l.desiredSize},i),u.promise},pull:l=>{let u=Promise.withResolvers();return this.streamControllers[s].pullCall=u,c.postMessage({sourceName:o,targetName:a,stream:nn.PULL,streamId:s,desiredSize:l.desiredSize}),u.promise},cancel:l=>{rn(l instanceof Error,"cancel must have a valid reason");let u=Promise.withResolvers();return this.streamControllers[s].cancelCall=u,this.streamControllers[s].isClosed=!0,c.postMessage({sourceName:o,targetName:a,stream:nn.CANCEL,streamId:s,reason:vr(l)}),u.promise}},r)}#n(e){let t=e.streamId,r=this.sourceName,i=e.sourceName,s=this.comObj,o=this,a=this.actionHandler[e.action],c={enqueue(l,u=1,d){if(this.isCancelled)return;let f=this.desiredSize;this.desiredSize-=u,f>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),s.postMessage({sourceName:r,targetName:i,stream:nn.ENQUEUE,streamId:t,chunk:l},d)},close(){this.isCancelled||(this.isCancelled=!0,s.postMessage({sourceName:r,targetName:i,stream:nn.CLOSE,streamId:t}),delete o.streamSinks[t])},error(l){rn(l instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,s.postMessage({sourceName:r,targetName:i,stream:nn.ERROR,streamId:t,reason:vr(l)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:e.desiredSize,ready:null};c.sinkCapability.resolve(),c.ready=c.sinkCapability.promise,this.streamSinks[t]=c,Promise.try(a,e.data,c).then(function(){s.postMessage({sourceName:r,targetName:i,stream:nn.START_COMPLETE,streamId:t,success:!0})},function(l){s.postMessage({sourceName:r,targetName:i,stream:nn.START_COMPLETE,streamId:t,reason:vr(l)})})}#r(e){let t=e.streamId,r=this.sourceName,i=e.sourceName,s=this.comObj,o=this.streamControllers[t],a=this.streamSinks[t];switch(e.stream){case nn.START_COMPLETE:e.success?o.startCall.resolve():o.startCall.reject(vr(e.reason));break;case nn.PULL_COMPLETE:e.success?o.pullCall.resolve():o.pullCall.reject(vr(e.reason));break;case nn.PULL:if(!a){s.postMessage({sourceName:r,targetName:i,stream:nn.PULL_COMPLETE,streamId:t,success:!0});break}a.desiredSize<=0&&e.desiredSize>0&&a.sinkCapability.resolve(),a.desiredSize=e.desiredSize,Promise.try(a.onPull||Qj).then(function(){s.postMessage({sourceName:r,targetName:i,stream:nn.PULL_COMPLETE,streamId:t,success:!0})},function(l){s.postMessage({sourceName:r,targetName:i,stream:nn.PULL_COMPLETE,streamId:t,reason:vr(l)})});break;case nn.ENQUEUE:if(rn(o,"enqueue should have stream controller"),o.isClosed)break;o.controller.enqueue(e.chunk);break;case nn.CLOSE:if(rn(o,"close should have stream controller"),o.isClosed)break;o.isClosed=!0,o.controller.close(),this.#s(o,t);break;case nn.ERROR:rn(o,"error should have stream controller"),o.controller.error(vr(e.reason)),this.#s(o,t);break;case nn.CANCEL_COMPLETE:e.success?o.cancelCall.resolve():o.cancelCall.reject(vr(e.reason)),this.#s(o,t);break;case nn.CANCEL:if(!a)break;let c=vr(e.reason);Promise.try(a.onCancel||Qj,c).then(function(){s.postMessage({sourceName:r,targetName:i,stream:nn.CANCEL_COMPLETE,streamId:t,success:!0})},function(l){s.postMessage({sourceName:r,targetName:i,stream:nn.CANCEL_COMPLETE,streamId:t,reason:vr(l)})}),a.sinkCapability.reject(c),a.isCancelled=!0,delete this.streamSinks[t];break;default:throw new Error("Unexpected stream case")}}#s(e,t){return m(this,null,function*(){yield Promise.allSettled([e.startCall?.promise,e.pullCall?.promise,e.cancelCall?.promise]),delete this.streamControllers[t]})}destroy(){this.#e?.abort(),this.#e=null}},y_=class{#e=!1;constructor({enableHWA:e=!1}){this.#e=e}create(e,t){if(e<=0||t<=0)throw new Error("Invalid canvas size");let r=this._createCanvas(e,t);return{canvas:r,context:r.getContext("2d",{willReadFrequently:!this.#e})}}reset(e,t,r){if(!e.canvas)throw new Error("Canvas is not specified");if(t<=0||r<=0)throw new Error("Invalid canvas size");e.canvas.width=t,e.canvas.height=r}destroy(e){if(!e.canvas)throw new Error("Canvas is not specified");e.canvas.width=0,e.canvas.height=0,e.canvas=null,e.context=null}_createCanvas(e,t){Ct("Abstract method `_createCanvas` called.")}}
84,YS=class extends y_{constructor({ownerDocument:e=globalThis.document,enableHWA:t=!1}){super({enableHWA:t}),this._document=e}_createCanvas(e,t){let r=this._document.createElement("canvas");return r.width=e,r.height=t,r}},__=class{constructor({baseUrl:e=null,isCompressed:t=!0}){this.baseUrl=e,this.isCompressed=t}fetch(t){return m(this,arguments,function*({name:e}){if(!this.baseUrl)throw new Error("Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided.");if(!e)throw new Error("CMap name must be specified.");let r=this.baseUrl+e+(this.isCompressed?".bcmap":"");return this._fetch(r).then(i=>({cMapData:i,isCompressed:this.isCompressed})).catch(i=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${r}`)})})}_fetch(e){return m(this,null,function*(){Ct("Abstract method `_fetch` called.")})}},v_=class extends __{_fetch(e){return m(this,null,function*(){let t=yield q_(e,this.isCompressed?"arraybuffer":"text");return t instanceof ArrayBuffer?new Uint8Array(t):H_(t)})}},b_=class{addFilter(e){return"none"}addHCMFilter(e,t){return"none"}addAlphaFilter(e){return"none"}addLuminosityFilter(e){return"none"}addHighlightHCMFilter(e,t,r,i,s){return"none"}destroy(e=!1){}},XS=class extends b_{#e;#t;#n;#r;#s;#i;#c=0;constructor({docId:e,ownerDocument:t=globalThis.document}){super(),this.#r=e,this.#s=t}get#a(){return this.#t||=new Map}get#u(){return this.#i||=new Map}get#l(){if(!this.#n){let e=this.#s.createElement("div"),{style:t}=e;t.visibility="hidden",t.contain="strict",t.width=t.height=0,t.position="absolute",t.top=t.left=0,t.zIndex=-1;let r=this.#s.createElementNS(ho,"svg");r.setAttribute("width",0),r.setAttribute("height",0),this.#n=this.#s.createElementNS(ho,"defs"),e.append(r),r.append(this.#n),this.#s.body.append(e)}return this.#n}#h(e){if(e.length===1){let c=e[0],l=new Array(256);for(let d=0;d<256;d++)l[d]=c[d]/255;let u=l.join(",");return[u,u,u]}let[t,r,i]=e,s=new Array(256),o=new Array(256),a=new Array(256);for(let c=0;c<256;c++)s[c]=t[c]/255,o[c]=r[c]/255,a[c]=i[c]/255;return[s.join(","),o.join(","),a.join(",")]}#d(e){if(this.#e===void 0){this.#e="";let t=this.#s.URL;t!==this.#s.baseURI&&(z_(t)?$e('#createUrl: ignore "data:"-URL for performance reasons.'):this.#e=t.split("#",1)[0])}return`url(${this.#e}#${e})`}addFilter(e){if(!e)return"none";let t=this.#a.get(e);if(t)return t;let[r,i,s]=this.#h(e),o=e.length===1?r:`${r}${i}${s}`;if(t=this.#a.get(o),t)return this.#a.set(e,t),t;let a=`g_${this.#r}_transfer_map_${this.#c++}`,c=this.#d(a);this.#a.set(e,c),this.#a.set(o,c);let l=this.#p(a);return this.#m(r,i,s,l),c}addHCMFilter(e,t){let r=`${e}-${t}`,i="base",s=this.#u.get(i);if(s?.key===r||(s?(s.filter?.remove(),s.key=r,s.url="none",s.filter=null):(s={key:r,url:"none",filter:null},this.#u.set(i,s)),!e||!t))return s.url;let o=this.#b(e);e=pe.makeHexColor(...o);let a=this.#b(t);if(t=pe.makeHexColor(...a),this.#l.style.color="",e==="#000000"&&t==="#ffffff"||e===t)return s.url;let c=new Array(256);for(let p=0;p<=255;p++){let y=p/255;c[p]=y<=.03928?y/12.92:((y+.055)/1.055)**2.4}let l=c.join(","),u=`g_${this.#r}_hcm_filter`,d=s.filter=this.#p(u);this.#m(l,l,l,d),this.#o(d);let f=(p,y)=>{let v=o[p]/255,w=a[p]/255,E=new Array(y+1);for(let A=0;A<=y;A++)E[A]=v+A/y*(w-v);return E.join(",")};return this.#m(f(0,5),f(1,5),f(2,5),d),s.url=this.#d(u),s.url}addAlphaFilter(e){let t=this.#a.get(e);if(t)return t;let[r]=this.#h([e]),i=`alpha_${r}`;if(t=this.#a.get(i),t)return this.#a.set(e,t),t;let s=`g_${this.#r}_alpha_map_${this.#c++}`,o=this.#d(s);this.#a.set(e,o),this.#a.set(i,o);let a=this.#p(s);return this.#y(r,a),o}addLuminosityFilter(e){let t=this.#a.get(e||"luminosity");if(t)return t;let r,i;if(e?([r]=this.#h([e]),i=`luminosity_${r}`):i="luminosity",t=this.#a.get(i),t)return this.#a.set(e,t),t;let s=`g_${this.#r}_luminosity_map_${this.#c++}`,o=this.#d(s);this.#a.set(e,o),this.#a.set(i,o);let a=this.#p(s);return this.#f(a),e&&this.#y(r,a),o}addHighlightHCMFilter(e,t,r,i,s){let o=`${t}-${r}-${i}-${s}`,a=this.#u.get(e);if(a?.key===o||(a?(a.filter?.remove(),a.key=o,a.url="none",a.filter=null):(a={key:o,url:"none",filter:null},this.#u.set(e,a)),!t||!r))return a.url;let[c,l]=[t,r].map(this.#b.bind(this)),u=Math.round(.2126*c[0]+.7152*c[1]+.0722*c[2]),d=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),[f,p]=[i,s].map(this.#b.bind(this));d<u&&([u,d,f,p]=[d,u,p,f]),this.#l.style.color="";let y=(E,A,x)=>{let M=new Array(256),O=(d-u)/x,$=E/255,C=(A-E)/(255*x),T=0;for(let S=0;S<=x;S++){let k=Math.round(u+S*O),P=$+S*C;for(let N=T;N<=k;N++)M[N]=P;T=k+1}for(let S=T;S<256;S++)M[S]=M[T-1];return M.join(",")},v=`g_${this.#r}_hcm_${e}_filter`,w=a.filter=this.#p(v);return this.#o(w),this.#m(y(f[0],p[0],5),y(f[1],p[1],5),y(f[2],p[2],5),w),a.url=this.#d(v),a.url}destroy(e=!1){e&&this.#i?.size||(this.#n?.parentNode.parentNode.remove(),this.#n=null,this.#t?.clear(),this.#t=null,this.#i?.clear(),this.#i=null,this.#c=0)}#f(e){let t=this.#s.createElementNS(ho,"feColorMatrix");t.setAttribute("type","matrix"),t.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),e.a
84ppend(t)}#o(e){let t=this.#s.createElementNS(ho,"feColorMatrix");t.setAttribute("type","matrix"),t.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),e.append(t)}#p(e){let t=this.#s.createElementNS(ho,"filter");return t.setAttribute("color-interpolation-filters","sRGB"),t.setAttribute("id",e),this.#l.append(t),t}#g(e,t,r){let i=this.#s.createElementNS(ho,t);i.setAttribute("type","discrete"),i.setAttribute("tableValues",r),e.append(i)}#m(e,t,r,i){let s=this.#s.createElementNS(ho,"feComponentTransfer");i.append(s),this.#g(s,"feFuncR",e),this.#g(s,"feFuncG",t),this.#g(s,"feFuncB",r)}#y(e,t){let r=this.#s.createElementNS(ho,"feComponentTransfer");t.append(r),this.#g(r,"feFuncA",e)}#b(e){return this.#l.style.color=e,sD(getComputedStyle(this.#l).getPropertyValue("color"))}},w_=class{constructor({baseUrl:e=null}){this.baseUrl=e}fetch(t){return m(this,arguments,function*({filename:e}){if(!this.baseUrl)throw new Error("Ensure that the `standardFontDataUrl` API parameter is provided.");if(!e)throw new Error("Font filename must be specified.");let r=`${this.baseUrl}${e}`;return this._fetch(r).catch(i=>{throw new Error(`Unable to load font data at: ${r}`)})})}_fetch(e){return m(this,null,function*(){Ct("Abstract method `_fetch` called.")})}},E_=class extends w_{_fetch(e){return m(this,null,function*(){let t=yield q_(e,"arraybuffer");return new Uint8Array(t)})}};Hn&&$e("Please use the `legacy` build in Node.js environments.");function d$(n){return m(this,null,function*(){let t=yield process.getBuiltinModule("fs").promises.readFile(n);return new Uint8Array(t)})}var QS=class extends b_{},ZS=class extends y_{_createCanvas(e,t){return process.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(e,t)}},JS=class extends __{_fetch(e){return m(this,null,function*(){return d$(e)})}},ex=class extends w_{_fetch(e){return m(this,null,function*(){return d$(e)})}},Bn={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function tx(n,e){if(!e)return;let t=e[2]-e[0],r=e[3]-e[1],i=new Path2D;i.rect(e[0],e[1],t,r),n.clip(i)}var df=class{getPattern(){Ct("Abstract method `getPattern` called.")}},nx=class extends df{constructor(e){super(),this._type=e[1],this._bbox=e[2],this._colorStops=e[3],this._p0=e[4],this._p1=e[5],this._r0=e[6],this._r1=e[7],this.matrix=null}_createGradient(e){let t;this._type==="axial"?t=e.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):this._type==="radial"&&(t=e.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(let r of this._colorStops)t.addColorStop(r[0],r[1]);return t}getPattern(e,t,r,i){let s;if(i===Bn.STROKE||i===Bn.FILL){let o=t.current.getClippedPathBoundingBox(i,Ot(e))||[0,0,0,0],a=Math.ceil(o[2]-o[0])||1,c=Math.ceil(o[3]-o[1])||1,l=t.cachedCanvases.getCanvas("pattern",a,c),u=l.context;u.clearRect(0,0,u.canvas.width,u.canvas.height),u.beginPath(),u.rect(0,0,u.canvas.width,u.canvas.height),u.translate(-o[0],-o[1]),r=pe.transform(r,[1,0,0,1,o[0],o[1]]),u.transform(...t.baseTransform),this.matrix&&u.transform(...this.matrix),tx(u,this._bbox),u.fillStyle=this._createGradient(u),u.fill(),s=e.createPattern(l.canvas,"no-repeat");let d=new DOMMatrix(r);s.setTransform(d)}else tx(e,this._bbox),s=this._createGradient(e);return s}};function NS(n,e,t,r,i,s,o,a){let c=e.coords,l=e.colors,u=n.data,d=n.width*4,f;c[t+1]>c[r+1]&&(f=t,t=r,r=f,f=s,s=o,o=f),c[r+1]>c[i+1]&&(f=r,r=i,i=f,f=o,o=a,a=f),c[t+1]>c[r+1]&&(f=t,t=r,r=f,f=s,s=o,o=f);let p=(c[t]+e.offsetX)*e.scaleX,y=(c[t+1]+e.offsetY)*e.scaleY,v=(c[r]+e.offsetX)*e.scaleX,w=(c[r+1]+e.offsetY)*e.scaleY,E=(c[i]+e.offsetX)*e.scaleX,A=(c[i+1]+e.offsetY)*e.scaleY;if(y>=A)return;let x=l[s],M=l[s+1],O=l[s+2],$=l[o],C=l[o+1],T=l[o+2],S=l[a],k=l[a+1],P=l[a+2],N=Math.round(y),R=Math.round(A),ze,Yt,le,ce,un,ur,$i,dr;for(let Et=N;Et<=R;Et++){if(Et<w){let dt=Et<y?0:(y-Et)/(y-w);ze=p-(p-v)*dt,Yt=x-(x-$)*dt,le=M-(M-C)*dt,ce=O-(O-T)*dt}else{let dt;Et>A?dt=1:w===A?dt=0:dt=(w-Et)/(w-A),ze=v-(v-E)*dt,Yt=$-($-S)*dt,le=C-(C-k)*dt,ce=T-(T-P)*dt}let Ze;Et<y?Ze=0:Et>A?Ze=1:Ze=(y-Et)/(y-A),un=p-(p-E)*Ze,ur=x-(x-S)*Ze,$i=M-(M-k)*Ze,dr=O-(O-P)*Ze;let Io=Math.round(Math.min(ze,un)),li=Math.round(Math.max(ze,un)),hr=d*Et+Io*4;for(let dt=Io;dt<=li;
84dt++)Ze=(ze-dt)/(ze-un),Ze<0?Ze=0:Ze>1&&(Ze=1),u[hr++]=Yt-(Yt-ur)*Ze|0,u[hr++]=le-(le-$i)*Ze|0,u[hr++]=ce-(ce-dr)*Ze|0,u[hr++]=255}}function dne(n,e,t){let r=e.coords,i=e.colors,s,o;switch(e.type){case"lattice":let a=e.verticesPerRow,c=Math.floor(r.length/a)-1,l=a-1;for(s=0;s<c;s++){let u=s*a;for(let d=0;d<l;d++,u++)NS(n,t,r[u],r[u+1],r[u+a],i[u],i[u+1],i[u+a]),NS(n,t,r[u+a+1],r[u+1],r[u+a],i[u+a+1],i[u+1],i[u+a])}break;case"triangles":for(s=0,o=r.length;s<o;s+=3)NS(n,t,r[s],r[s+1],r[s+2],i[s],i[s+1],i[s+2]);break;default:throw new Error("illegal figure")}}var rx=class extends df{constructor(e){super(),this._coords=e[2],this._colors=e[3],this._figures=e[4],this._bounds=e[5],this._bbox=e[7],this._background=e[8],this.matrix=null}_createMeshCanvas(e,t,r){let a=Math.floor(this._bounds[0]),c=Math.floor(this._bounds[1]),l=Math.ceil(this._bounds[2])-a,u=Math.ceil(this._bounds[3])-c,d=Math.min(Math.ceil(Math.abs(l*e[0]*1.1)),3e3),f=Math.min(Math.ceil(Math.abs(u*e[1]*1.1)),3e3),p=l/d,y=u/f,v={coords:this._coords,colors:this._colors,offsetX:-a,offsetY:-c,scaleX:1/p,scaleY:1/y},w=d+2*2,E=f+2*2,A=r.getCanvas("mesh",w,E),x=A.context,M=x.createImageData(d,f);if(t){let $=M.data;for(let C=0,T=$.length;C<T;C+=4)$[C]=t[0],$[C+1]=t[1],$[C+2]=t[2],$[C+3]=255}for(let $ of this._figures)dne(M,$,v);return x.putImageData(M,2,2),{canvas:A.canvas,offsetX:a-2*p,offsetY:c-2*y,scaleX:p,scaleY:y}}getPattern(e,t,r,i){tx(e,this._bbox);let s;if(i===Bn.SHADING)s=pe.singularValueDecompose2dScale(Ot(e));else if(s=pe.singularValueDecompose2dScale(t.baseTransform),this.matrix){let a=pe.singularValueDecompose2dScale(this.matrix);s=[s[0]*a[0],s[1]*a[1]]}let o=this._createMeshCanvas(s,i===Bn.SHADING?null:this._background,t.cachedCanvases);return i!==Bn.SHADING&&(e.setTransform(...t.baseTransform),this.matrix&&e.transform(...this.matrix)),e.translate(o.offsetX,o.offsetY),e.scale(o.scaleX,o.scaleY),e.createPattern(o.canvas,"no-repeat")}},ix=class extends df{getPattern(){return"hotpink"}};function hne(n){switch(n[0]){case"RadialAxial":return new nx(n);case"Mesh":return new rx(n);case"Dummy":return new ix}throw new Error(`Unknown IR type: ${n[0]}`)}var Zj={COLORED:1,UNCOLORED:2},fne=(()=>{class n{static MAX_PATTERN_SIZE=3e3;constructor(t,r,i,s,o){this.operatorList=t[2],this.matrix=t[3],this.bbox=t[4],this.xstep=t[5],this.ystep=t[6],this.paintType=t[7],this.tilingType=t[8],this.color=r,this.ctx=i,this.canvasGraphicsFactory=s,this.baseTransform=o}createPatternCanvas(t){let{bbox:r,operatorList:i,paintType:s,tilingType:o,color:a,canvasGraphicsFactory:c}=this,{xstep:l,ystep:u}=this;l=Math.abs(l),u=Math.abs(u),B_("TilingType: "+o);let d=r[0],f=r[1],p=r[2],y=r[3],v=p-d,w=y-f,E=pe.singularValueDecompose2dScale(this.matrix),A=pe.singularValueDecompose2dScale(this.baseTransform),x=E[0]*A[0],M=E[1]*A[1],O=v,$=w,C=!1,T=!1,S=Math.ceil(l*x),k=Math.ceil(u*M),P=Math.ceil(v*x),N=Math.ceil(w*M);S>=P?O=l:C=!0,k>=N?$=u:T=!0;let R=this.getSizeAndScale(O,this.ctx.canvas.width,x),ze=this.getSizeAndScale($,this.ctx.canvas.height,M),Yt=t.cachedCanvases.getCanvas("pattern",R.size,ze.size),le=Yt.context,ce=c.createCanvasGraphics(le);if(ce.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(ce,s,a),le.translate(-R.scale*d,-ze.scale*f),ce.transform(R.scale,0,0,ze.scale,0,0),le.save(),this.clipBbox(ce,d,f,p,y),ce.baseTransform=Ot(ce.ctx),ce.executeOperatorList(i),ce.endDrawing(),le.restore(),C||T){let un=Yt.canvas;C&&(O=l),T&&($=u);let ur=this.getSizeAndScale(O,this.ctx.canvas.width,x),$i=this.getSizeAndScale($,this.ctx.canvas.height,M),dr=ur.size,Et=$i.size,Ze=t.cachedCanvases.getCanvas("pattern-workaround",dr,Et),Io=Ze.context,li=C?Math.floor(v/l):0,hr=T?Math.floor(w/u):0;for(let dt=0;dt<=li;dt++)for(let Ur=0;Ur<=hr;Ur++)Io.drawImage(un,dr*dt,Et*Ur,dr,Et,0,0,dr,Et);return{canvas:Ze.canvas,scaleX:ur.scale,scaleY:$i.scale,offsetX:d,offsetY:f}}return{canvas:Yt.canvas,scaleX:R.scale,scaleY:ze.scale,offsetX:d,offsetY:f}}getSizeAndScale(t,r,i){let s=Math.max(n.MAX_PATTERN_SIZE,r),o=Math.ceil(t*i);return o>=s?o=s:i=o/t,{scale:i,size:o}}clipBbox(t,r,i,s,o){let a=s-r,c=o-i;t.ctx.rect(r,i,a,c),t.current.updateRectMinMax(Ot(t.ctx),[r,i,s,o]
84),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,r,i){let s=t.ctx,o=t.current;switch(r){case Zj.COLORED:let a=this.ctx;s.fillStyle=a.fillStyle,s.strokeStyle=a.strokeStyle,o.fillColor=a.fillStyle,o.strokeColor=a.strokeStyle;break;case Zj.UNCOLORED:let c=pe.makeHexColor(i[0],i[1],i[2]);s.fillStyle=c,s.strokeStyle=c,o.fillColor=c,o.strokeColor=c;break;default:throw new VS(`Unsupported paint type: ${r}`)}}getPattern(t,r,i,s){let o=i;s!==Bn.SHADING&&(o=pe.transform(o,r.baseTransform),this.matrix&&(o=pe.transform(o,this.matrix)));let a=this.createPatternCanvas(r),c=new DOMMatrix(o);c=c.translate(a.offsetX,a.offsetY),c=c.scale(1/a.scaleX,1/a.scaleY);let l=t.createPattern(a.canvas,"repeat");return l.setTransform(c),l}}return n})();function pne({src:n,srcPos:e=0,dest:t,width:r,height:i,nonBlackColor:s=4294967295,inverseDecode:o=!1}){let a=Cn.isLittleEndian?4278190080:255,[c,l]=o?[s,a]:[a,s],u=r>>3,d=r&7,f=n.length;t=new Uint32Array(t.buffer);let p=0;for(let y=0;y<i;y++){for(let w=e+u;e<w;e++){let E=e<f?n[e]:255;t[p++]=E&128?l:c,t[p++]=E&64?l:c,t[p++]=E&32?l:c,t[p++]=E&16?l:c,t[p++]=E&8?l:c,t[p++]=E&4?l:c,t[p++]=E&2?l:c,t[p++]=E&1?l:c}if(d===0)continue;let v=e<f?n[e++]:255;for(let w=0;w<d;w++)t[p++]=v&1<<7-w?l:c}return{srcPos:e,destPos:p}}var Jj=16,e$=100,mne=15,t$=10,n$=1e3,br=16;function gne(n,e){if(n._removeMirroring)throw new Error("Context is already forwarding operations.");n.__originalSave=n.save,n.__originalRestore=n.restore,n.__originalRotate=n.rotate,n.__originalScale=n.scale,n.__originalTranslate=n.translate,n.__originalTransform=n.transform,n.__originalSetTransform=n.setTransform,n.__originalResetTransform=n.resetTransform,n.__originalClip=n.clip,n.__originalMoveTo=n.moveTo,n.__originalLineTo=n.lineTo,n.__originalBezierCurveTo=n.bezierCurveTo,n.__originalRect=n.rect,n.__originalClosePath=n.closePath,n.__originalBeginPath=n.beginPath,n._removeMirroring=()=>{n.save=n.__originalSave,n.restore=n.__originalRestore,n.rotate=n.__originalRotate,n.scale=n.__originalScale,n.translate=n.__originalTranslate,n.transform=n.__originalTransform,n.setTransform=n.__originalSetTransform,n.resetTransform=n.__originalResetTransform,n.clip=n.__originalClip,n.moveTo=n.__originalMoveTo,n.lineTo=n.__originalLineTo,n.bezierCurveTo=n.__originalBezierCurveTo,n.rect=n.__originalRect,n.closePath=n.__originalClosePath,n.beginPath=n.__originalBeginPath,delete n._removeMirroring},n.save=function(){e.save(),this.__originalSave()},n.restore=function(){e.restore(),this.__originalRestore()},n.translate=function(r,i){e.translate(r,i),this.__originalTranslate(r,i)},n.scale=function(r,i){e.scale(r,i),this.__originalScale(r,i)},n.transform=function(r,i,s,o,a,c){e.transform(r,i,s,o,a,c),this.__originalTransform(r,i,s,o,a,c)},n.setTransform=function(r,i,s,o,a,c){e.setTransform(r,i,s,o,a,c),this.__originalSetTransform(r,i,s,o,a,c)},n.resetTransform=function(){e.resetTransform(),this.__originalResetTransform()},n.rotate=function(r){e.rotate(r),this.__originalRotate(r)},n.clip=function(r){e.clip(r),this.__originalClip(r)},n.moveTo=function(t,r){e.moveTo(t,r),this.__originalMoveTo(t,r)},n.lineTo=function(t,r){e.lineTo(t,r),this.__originalLineTo(t,r)},n.bezierCurveTo=function(t,r,i,s,o,a){e.bezierCurveTo(t,r,i,s,o,a),this.__originalBezierCurveTo(t,r,i,s,o,a)},n.rect=function(t,r,i,s){e.rect(t,r,i,s),this.__originalRect(t,r,i,s)},n.closePath=function(){e.closePath(),this.__originalClosePath()},n.beginPath=function(){e.beginPath(),this.__originalBeginPath()}}var sx=class{constructor(e){this.canvasFactory=e,this.cache=Object.create(null)}getCanvas(e,t,r){let i;return this.cache[e]!==void 0?(i=this.cache[e],this.canvasFactory.reset(i,t,r)):(i=this.canvasFactory.create(t,r),this.cache[e]=i),i}delete(e){delete this.cache[e]}clear(){for(let e in this.cache){let t=this.cache[e];this.canvasFactory.destroy(t),delete this.cache[e]}}};function s_(n,e,t,r,i,s,o,a,c,l){let[u,d,f,p,y,v]=Ot(n);if(d===0&&f===0){let A=o*u+y,x=Math.round(A),M=a*p+v,O=Math.round(M),$=(o+c)*u+y,C=Math.abs(Math.round($)-x)||1,T=(a+l)*p+v,S=Math.abs(Math.round(T)-O)||1;return n.setTransform(Math.sign(u),0,0,Math.sign(p),x,O),n.drawImage(e,t,r,i,s,0,0,C,S),n.setTransform(u,d,f,p,y,v),[C,S]}if(u===0&&p===0){let A=a*f+y,x=Math.round(A),M=o*d+v,O=Math.round(M),$=(a+l)*f+y,C=Math.abs(Math.round($)-x)||1,T=(o+c)*d+v,S=Math.abs(Math.round(T)-O)||1;return n.setTransform(0,Math.sign(d),Math.sign(f),0,x,O),n.drawImage(e,t,r,i,s,0,0,S,C),n.setTransform(u,d,f,p,y,v),[S,C]}n.drawImage(e,t,r,i,s,o,a,c,l);let w=Math.hypot(u,d),E=Math.hypot(f,p);return[w*c,E*l]}function yne(n){let{width:e,height:t}=n;if(e>n$||t>n$)return null;let r=1e3,i=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),s=e+1,o=new Uint8Array(s*(t+1)),a,c,l,u=e+7&-8,d=new Uint8Array(u*t),f=0;for(let E of n.data){let A=128;for(;A>0;)d[f++]=E&A?0:255,A>>=1}let p=0;for(f=0,d[f]!==0&&(o[0]=1,++p),c=1;c<e;c++)d[f]!==d[f+1]&&(o[c]=d[f]?2:1,++p),f++;for(d[f]!==0&&(o[c]=2,++p),a=1;a<t;a++){f=a*u,l=a*s,d[f-u]!==d[f]&&(o[l]=d[f]?1:8,++p);let E=(d[f]?4:0)+(d[f-u]?8:0);for(c=1;c<e;c++)E=(E>>2)+(d[f+1]?4:0)+(d[f-u+1]?8:0),i[E]&&(o[l+c]=i[E],++p),f++;if(d[f-u]!==d[f]&&(o[l+c]=d[f]?2:4,++p),p>r)return null}for(f=u*(t-1),l=a*s,d[f]!==0&&(o[l]=8,++p),c=1;c<e;c++)d[f]!==d[f+1]&&(o[l+c]=d[f]?4:8,++p),f++;if(d[f]!==0&&(o[l+c]=4,++p),p>r)return null;let y=new Int32Array([0,s,-1,0,-s,0,0,0,1]),v=new Path2D;for(a=0;p&&a<=t;a++){let E=a*s,A=E+e;for(;E<A&&!o[E];)E++;
84if(E===A)continue;v.moveTo(E%s,a);let x=E,M=o[E];do{let O=y[M];do E+=O;while(!o[E]);let $=o[E];$!==5&&$!==10?(M=$,o[E]=0):(M=$&51*M>>4,o[E]&=M>>2|M<<2),v.lineTo(E%s,E/s|0),o[E]||--p}while(x!==E);--a}return d=null,o=null,function(E){E.save(),E.scale(1/e,-1/t),E.translate(0,-t),E.fill(v),E.beginPath(),E.restore()}}var I_=class{constructor(e,t){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=l$,this.textMatrixScale=1,this.fontMatrix=FS,this.leading=0,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRenderingMode=Un.FILL,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.patternStroke=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.startNewPathAndClipBox([0,0,e,t])}clone(){let e=Object.create(this);return e.clipBox=this.clipBox.slice(),e}setCurrentPoint(e,t){this.x=e,this.y=t}updatePathMinMax(e,t,r){[t,r]=pe.applyTransform([t,r],e),this.minX=Math.min(this.minX,t),this.minY=Math.min(this.minY,r),this.maxX=Math.max(this.maxX,t),this.maxY=Math.max(this.maxY,r)}updateRectMinMax(e,t){let r=pe.applyTransform(t,e),i=pe.applyTransform(t.slice(2),e),s=pe.applyTransform([t[0],t[3]],e),o=pe.applyTransform([t[2],t[1]],e);this.minX=Math.min(this.minX,r[0],i[0],s[0],o[0]),this.minY=Math.min(this.minY,r[1],i[1],s[1],o[1]),this.maxX=Math.max(this.maxX,r[0],i[0],s[0],o[0]),this.maxY=Math.max(this.maxY,r[1],i[1],s[1],o[1])}updateScalingPathMinMax(e,t){pe.scaleMinMax(e,t),this.minX=Math.min(this.minX,t[0]),this.minY=Math.min(this.minY,t[1]),this.maxX=Math.max(this.maxX,t[2]),this.maxY=Math.max(this.maxY,t[3])}updateCurvePathMinMax(e,t,r,i,s,o,a,c,l,u){let d=pe.bezierBoundingBox(t,r,i,s,o,a,c,l,u);u||this.updateRectMinMax(e,d)}getPathBoundingBox(e=Bn.FILL,t=null){let r=[this.minX,this.minY,this.maxX,this.maxY];if(e===Bn.STROKE){t||Ct("Stroke bounding box must include transform.");let i=pe.singularValueDecompose2dScale(t),s=i[0]*this.lineWidth/2,o=i[1]*this.lineWidth/2;r[0]-=s,r[1]-=o,r[2]+=s,r[3]+=o}return r}updateClipFromPath(){let e=pe.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(e||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}startNewPathAndClipBox(e){this.clipBox=e,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}getClippedPathBoundingBox(e=Bn.FILL,t=null){return pe.intersect(this.clipBox,this.getPathBoundingBox(e,t))}};function r$(n,e){if(e instanceof ImageData){n.putImageData(e,0,0);return}let t=e.height,r=e.width,i=t%br,s=(t-i)/br,o=i===0?s:s+1,a=n.createImageData(r,br),c=0,l,u=e.data,d=a.data,f,p,y,v;if(e.kind===l_.GRAYSCALE_1BPP){let w=u.byteLength,E=new Uint32Array(d.buffer,0,d.byteLength>>2),A=E.length,x=r+7>>3,M=4294967295,O=Cn.isLittleEndian?4278190080:255;for(f=0;f<o;f++){for(y=f<s?br:i,l=0,p=0;p<y;p++){let $=w-c,C=0,T=$>x?r:$*8-7,S=T&-8,k=0,P=0;for(;C<S;C+=8)P=u[c++],E[l++]=P&128?M:O,E[l++]=P&64?M:O,E[l++]=P&32?M:O,E[l++]=P&16?M:O,E[l++]=P&8?M:O,E[l++]=P&4?M:O,E[l++]=P&2?M:O,E[l++]=P&1?M:O;for(;C<T;C++)k===0&&(P=u[c++],k=128),E[l++]=P&k?M:O,k>>=1}for(;l<A;)E[l++]=0;n.putImageData(a,0,f*br)}}else if(e.kind===l_.RGBA_32BPP){for(p=0,v=r*br*4,f=0;f<s;f++)d.set(u.subarray(c,c+v)),c+=v,n.putImageData(a,0,p),p+=br;f<o&&(v=r*i*4,d.set(u.subarray(c,c+v)),n.putImageData(a,0,p))}else if(e.kind===l_.RGB_24BPP)for(y=br,v=r*y,f=0;f<o;f++){for(f>=s&&(y=i,v=r*y),l=0,p=v;p--;)d[l++]=u[c++],d[l++]=u[c++],d[l++]=u[c++],d[l++]=255;n.putImageData(a,0,f*br)}else throw new Error(`bad image kind: ${e.kind}`)}function i$(n,e){if(e.bitmap){n.drawImage(e.bitmap,0,0);return}let t=e.height,r=e.width,i=t%br,s=(t-i)/br,o=i===0?s:s+1,a=n.createImageData(r,br),c=0,l=e.data,u=a.data;for(let d=0;d<o;d++){let f=d<s?br:i;({srcPos:c}=pne({src:l,srcPos:c,dest:u,width:r,height:f,nonBlackColor:0})),n.putImageData(a,0,d*br)}}function Zh(n,e){let t=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(let r of t)n[r]!==void 0&&(e[r]=n[r]);n.setLineDash!==void 0&&(e.setLineDash(n.getLineDash()),e.lineDashOffset=n.lineDashOffset)}function o_(n){if(n.strokeStyle=n.fillStyle="#000000",n.fillRule="nonzero",n.globalAlpha=1,n.lineWidth=1,n.lineCap="butt",n.lineJoin="miter",n.miterLimit=10,n.globalCompositeOperation="source-over",n.font="10px sans-serif",n.set
84LineDash!==void 0&&(n.setLineDash([]),n.lineDashOffset=0),!Hn){let{filter:e}=n;e!=="none"&&e!==""&&(n.filter="none")}}function s$(n,e){if(e)return!0;let t=pe.singularValueDecompose2dScale(n);t[0]=Math.fround(t[0]),t[1]=Math.fround(t[1]);let r=Math.fround((globalThis.devicePixelRatio||1)*la.PDF_TO_CSS_UNITS);return t[0]<=r&&t[1]<=r}var _ne=["butt","round","square"],vne=["miter","round","bevel"],bne={},o$={},Su=class n{constructor(e,t,r,i,s,{optionalContentConfig:o,markedContentStack:a=null},c,l){this.ctx=e,this.current=new I_(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=t,this.objs=r,this.canvasFactory=i,this.filterFactory=s,this.groupStack=[],this.processingType3=null,this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=a||[],this.optionalContentConfig=o,this.cachedCanvases=new sx(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=c,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=l,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(e,t=null){return typeof e=="string"?e.startsWith("g_")?this.commonObjs.get(e):this.objs.get(e):t}beginDrawing({transform:e,viewport:t,transparency:r=!1,background:i=null}){let s=this.ctx.canvas.width,o=this.ctx.canvas.height,a=this.ctx.fillStyle;if(this.ctx.fillStyle=i||"#ffffff",this.ctx.fillRect(0,0,s,o),this.ctx.fillStyle=a,r){let c=this.cachedCanvases.getCanvas("transparent",s,o);this.compositeCtx=this.ctx,this.transparentCanvas=c.canvas,this.ctx=c.context,this.ctx.save(),this.ctx.transform(...Ot(this.compositeCtx))}this.ctx.save(),o_(this.ctx),e&&(this.ctx.transform(...e),this.outputScaleX=e[0],this.outputScaleY=e[0]),this.ctx.transform(...t.transform),this.viewportScale=t.scale,this.baseTransform=Ot(this.ctx)}executeOperatorList(e,t,r,i){let s=e.argsArray,o=e.fnArray,a=t||0,c=s.length;if(c===a)return a;let l=c-a>t$&&typeof r=="function",u=l?Date.now()+mne:0,d=0,f=this.commonObjs,p=this.objs,y;for(;;){if(i!==void 0&&a===i.nextBreakPoint)return i.breakIt(a,r),a;if(y=o[a],y!==Mi.dependency)this[y].apply(this,s[a]);else for(let v of s[a]){let w=v.startsWith("g_")?f:p;if(!w.has(v))return w.get(v,r),a}if(a++,a===c)return a;if(l&&++d>t$){if(Date.now()>u)return r(),a;d=0}}}#e(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null,this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null)}endDrawing(){this.#e(),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(let e of this._cachedBitmapsMap.values()){for(let t of e.values())typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement&&(t.width=t.height=0);e.clear()}this._cachedBitmapsMap.clear(),this.#t()}#t(){if(this.pageColors){let e=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(e!=="none"){let t=this.ctx.filter;this.ctx.filter=e,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=t}}}_scaleImage(e,t){let r=e.width??e.displayWidth,i=e.height??e.displayHeight,s=Math.max(Math.hypot(t[0],t[1]),1),o=Math.max(Math.hypot(t[2],t[3]),1),a=r,c=i,l="prescale1",u,d;for(;s>2&&a>1||o>2&&c>1;){let f=a,p=c;s>2&&a>1&&(f=a>=16384?Math.floor(a/2)-1||1:Math.ceil(a/2),s/=a/f),o>2&&c>1&&(p=c>=16384?Math.floor(c/2)-1||1:Math.ceil(c)/2,o/=c/p),u=this.cachedCanvases.getCanvas(l,f,p),d=u.context,d.clearRect(0,0,f,p),d.drawImage(e,0,0,a,c,0,0,f,p),e=u.canvas,a=f,c=p,l=l==="prescale1"?"prescale2":"prescale1"}return{img:e,paintWidth:a,paintHeight:c}}_createMaskCanvas(e){let t=this.ctx,{width:r,height:i}=e,s=this.current.fillColor,o=this.current.patternFill,a=Ot(t),c,l,u,d;if((e.bitmap||e.data)&&e.count>1){let T=e.bitmap||e.data.buffer;l=JSON.stringify(o?a:[a.slice(0,4),s]),c=this._cachedBitmapsMap.get(T),c||(c=new Map,this._cachedBitmapsMap.set(T,c));let S=c.get(l);if(S&&!o){let k=Math.round(Math.min(a[0],a[2])+a[4]),P=Math.round(Math.min(a[1],a[3])+a[5]);return{canvas:S,offsetX:k,offsetY:P}}u=S}u||(d=this.cachedCanvases.getCanvas("maskCanvas",r,i),i$(d.context,e));let f=pe.transform(a,[1/r,0,0,-1/i,0,0]);f=pe.transform(f,[1,0,0,1,0,-i]);let[p,y,v,w]=pe.getAxialAlignedBoundingBox([0,0,r,i],f),E=Math.round(v-p)||1,A=Math.round(w-y)||1,x=this.cachedCanvases.getCanvas("fillCanvas",E,A),M=x.context,O=p,$=y;M.translate(-O,-$),M.transform(...f),u||(u=this._scaleImage(d.canvas,ms(M)),u=u.img,c&&o&&c.set(l,u)),M.imageSmoothingEnabled=s$(Ot(M),e.interpolate),s_(M,u,0,0,u.width,u.height,0,0,r,i),M.globalCompositeOperation="source-in";let C=pe.transform(ms(M),[1,0,0,1,-O,-$]);return M.fillStyle=o?s.getPattern(t,this,C,Bn.FILL):s,M.fillRect(0,0,r,i),c&&!o&&(this.cachedCanvases.delete("fillCanvas"),c.set(l,x.canvas)),{canvas:x.canvas,offsetX:Math.round(O),offsetY:Math.round($)}}setLineWidth(e){e!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=e,this.ctx.lineWidth=e}setLineCap(e){this.ctx.lineCap=_ne[e]}setLineJoin(e){this.ctx.lineJoin=vne[e]}setMiterLimit(e){this.ctx.miterLimit=e}setDash(e,t){let r=this.ctx;r.setLineDash!==void 0&&(r.setLineDash(e),r.lineDashOffset=t)}
84setRenderingIntent(e){}setFlatness(e){}setGState(e){for(let[t,r]of e)switch(t){case"LW":this.setLineWidth(r);break;case"LC":this.setLineCap(r);break;case"LJ":this.setLineJoin(r);break;case"ML":this.setMiterLimit(r);break;case"D":this.setDash(r[0],r[1]);break;case"RI":this.setRenderingIntent(r);break;case"FL":this.setFlatness(r);break;case"Font":this.setFont(r[0],r[1]);break;case"CA":this.current.strokeAlpha=r;break;case"ca":this.current.fillAlpha=r,this.ctx.globalAlpha=r;break;case"BM":this.ctx.globalCompositeOperation=r;break;case"SMask":this.current.activeSMask=r?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(r);break}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){let e=this.inSMaskMode;this.current.activeSMask&&!e?this.beginSMaskMode():!this.current.activeSMask&&e&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");let e=this.ctx.canvas.width,t=this.ctx.canvas.height,r="smaskGroupAt"+this.groupLevel,i=this.cachedCanvases.getCanvas(r,e,t);this.suspendedCtx=this.ctx,this.ctx=i.context;let s=this.ctx;s.setTransform(...Ot(this.suspendedCtx)),Zh(this.suspendedCtx,s),gne(s,this.suspendedCtx),this.setGState([["BM","source-over"],["ca",1],["CA",1]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),Zh(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(e){if(!this.current.activeSMask)return;e?(e[0]=Math.floor(e[0]),e[1]=Math.floor(e[1]),e[2]=Math.ceil(e[2]),e[3]=Math.ceil(e[3])):e=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];let t=this.current.activeSMask,r=this.suspendedCtx;this.composeSMask(r,t,this.ctx,e),this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore()}composeSMask(e,t,r,i){let s=i[0],o=i[1],a=i[2]-s,c=i[3]-o;a===0||c===0||(this.genericComposeSMask(t.context,r,a,c,t.subtype,t.backdrop,t.transferMap,s,o,t.offsetX,t.offsetY),e.save(),e.globalAlpha=1,e.globalCompositeOperation="source-over",e.setTransform(1,0,0,1,0,0),e.drawImage(r.canvas,0,0),e.restore())}genericComposeSMask(e,t,r,i,s,o,a,c,l,u,d){let f=e.canvas,p=c-u,y=l-d;if(o){let w=pe.makeHexColor(...o);if(p<0||y<0||p+r>f.width||y+i>f.height){let E=this.cachedCanvases.getCanvas("maskExtension",r,i),A=E.context;A.drawImage(f,-p,-y),A.globalCompositeOperation="destination-atop",A.fillStyle=w,A.fillRect(0,0,r,i),A.globalCompositeOperation="source-over",f=E.canvas,p=y=0}else{e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0);let E=new Path2D;E.rect(p,y,r,i),e.clip(E),e.globalCompositeOperation="destination-atop",e.fillStyle=w,e.fillRect(p,y,r,i),e.restore()}}t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0),s==="Alpha"&&a?t.filter=this.filterFactory.addAlphaFilter(a):s==="Luminosity"&&(t.filter=this.filterFactory.addLuminosityFilter(a));let v=new Path2D;v.rect(c,l,r,i),t.clip(v),t.globalCompositeOperation="destination-in",t.drawImage(f,p,y,r,i,c,l,r,i),t.restore()}save(){this.inSMaskMode?(Zh(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();let e=this.current;this.stateStack.push(e),this.current=e.clone()}restore(){this.stateStack.length===0&&this.inSMaskMode&&this.endSMaskMode(),this.stateStack.length!==0&&(this.current=this.stateStack.pop(),this.inSMaskMode?(this.suspendedCtx.restore(),Zh(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(e,t,r,i,s,o){this.ctx.transform(e,t,r,i,s,o),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(e,t,r){let i=this.ctx,s=this.current,o=s.x,a=s.y,c,l,u=Ot(i),d=u[0]===0&&u[3]===0||u[1]===0&&u[2]===0,f=d?r.slice(0):null;for(let p=0,y=0,v=e.length;p<v;p++)switch(e[p]|0){case Mi.rectangle:o=t[y++],a=t[y++];let w=t[y++],E=t[y++],A=o+w,x=a+E;i.moveTo(o,a),w===0||E===0?i.lineTo(A,x):(i.lineTo(A,a),i.lineTo(A,x),i.lineTo(o,x)),d||s.updateRectMinMax(u,[o,a,A,x]),i.closePath();break;case Mi.moveTo:o=t[y++],a=t[y++],i.moveTo(o,a),d||s.updatePathMinMax(u,o,a);break;case Mi.lineTo:o=t[y++],a=t[y++],i.lineTo(o,a),d||s.updatePathMinMax(u,o,a);break;case Mi.curveTo:c=o,l=a,o=t[y+4],a=t[y+5],i.bezierCurveTo(t[y],t[y+1],t[y+2],t[y+3],o,a),s.updateCurvePathMinMax(u,c,l,t[y],t[y+1],t[y+2],t[y+3],o,a,f),y+=6;break;case Mi.curveTo2:c=o,l=a,i.bezierCurveTo(o,a,t[y],t[y+1],t[y+2],t[y+3]),s.updateCurvePathMinMax(u,c,l,o,a,t[y],t[y+1],t[y+2],t[y+3],f),o=t[y+2],a=t[y+3],y+=4;break;case Mi.curveTo3:c=o,l=a,o=t[y+2],a=t[y+3],i.bezierCurveTo(t[y],t[y+1],o,a,o,a),s.updateCurvePathMinMax(u,c,l,t[y],t[y+1],o,a,o,a,f),y+=4;break;case Mi.closePath:i.closePath();break}d&&s.updateScalingPathMinMax(u,f),s.setCurrentPoint(o,a)}closePath(){this.ctx.closePath()}stroke(e=!0){let t=this.ctx,r=this.current.strokeColor;t.globalAlpha=this.current.strokeAlpha,this.contentVisible&&(typeof r=="object"&&r?.getPattern?(t.save(),t.strokeStyle=r.getPattern(t,this,ms(t),Bn.STROKE),this.rescaleAndStroke(!1),t.restore(
84)):this.rescaleAndStroke(!0)),e&&this.consumePath(this.current.getClippedPathBoundingBox()),t.globalAlpha=this.current.fillAlpha}closeStroke(){this.closePath(),this.stroke()}fill(e=!0){let t=this.ctx,r=this.current.fillColor,i=this.current.patternFill,s=!1;i&&(t.save(),t.fillStyle=r.getPattern(t,this,ms(t),Bn.FILL),s=!0);let o=this.current.getClippedPathBoundingBox();this.contentVisible&&o!==null&&(this.pendingEOFill?(t.fill("evenodd"),this.pendingEOFill=!1):t.fill()),s&&t.restore(),e&&this.consumePath(o)}eoFill(){this.pendingEOFill=!0,this.fill()}fillStroke(){this.fill(!1),this.stroke(!1),this.consumePath()}eoFillStroke(){this.pendingEOFill=!0,this.fillStroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.pendingEOFill=!0,this.closePath(),this.fillStroke()}endPath(){this.consumePath()}clip(){this.pendingClip=bne}eoClip(){this.pendingClip=o$}beginText(){this.current.textMatrix=l$,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){let e=this.pendingTextPaths,t=this.ctx;if(e===void 0){t.beginPath();return}let r=new Path2D,i=t.getTransform().invertSelf();for(let{transform:s,x:o,y:a,fontSize:c,path:l}of e)r.addPath(l,new DOMMatrix(s).preMultiplySelf(i).translate(o,a).scale(c,-c));t.clip(r),t.beginPath(),delete this.pendingTextPaths}setCharSpacing(e){this.current.charSpacing=e}setWordSpacing(e){this.current.wordSpacing=e}setHScale(e){this.current.textHScale=e/100}setLeading(e){this.current.leading=-e}setFont(e,t){let r=this.commonObjs.get(e),i=this.current;if(!r)throw new Error(`Can't find font for ${e}`);if(i.fontMatrix=r.fontMatrix||FS,(i.fontMatrix[0]===0||i.fontMatrix[3]===0)&&$e("Invalid font matrix for font "+e),t<0?(t=-t,i.fontDirection=-1):i.fontDirection=1,this.current.font=r,this.current.fontSize=t,r.isType3Font)return;let s=r.loadedName||"sans-serif",o=r.systemFontInfo?.css||`"${s}", ${r.fallbackName}`,a="normal";r.black?a="900":r.bold&&(a="bold");let c=r.italic?"italic":"normal",l=t;t<Jj?l=Jj:t>e$&&(l=e$),this.current.fontSizeScale=t/l,this.ctx.font=`${c} ${a} ${l}px ${o}`}setTextRenderingMode(e){this.current.textRenderingMode=e}setTextRise(e){this.current.textRise=e}moveText(e,t){this.current.x=this.current.lineX+=e,this.current.y=this.current.lineY+=t}setLeadingMoveText(e,t){this.setLeading(-t),this.moveText(e,t)}setTextMatrix(e,t,r,i,s,o){this.current.textMatrix=[e,t,r,i,s,o],this.current.textMatrixScale=Math.hypot(e,t),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}#n(e,t,r){let i=new Path2D;return i.addPath(e,new DOMMatrix(r).invertSelf().multiplySelf(t)),i}paintChar(e,t,r,i,s){let o=this.ctx,a=this.current,c=a.font,l=a.textRenderingMode,u=a.fontSize/a.fontSizeScale,d=l&Un.FILL_STROKE_MASK,f=!!(l&Un.ADD_TO_PATH_FLAG),p=a.patternFill&&!c.missingFile,y=a.patternStroke&&!c.missingFile,v;if((c.disableFontFace||f||p||y)&&(v=c.getPathGenerator(this.commonObjs,e)),c.disableFontFace||p||y){if(o.save(),o.translate(t,r),o.scale(u,-u),d===Un.FILL||d===Un.FILL_STROKE)if(i){let w=o.getTransform();o.setTransform(...i),o.fill(this.#n(v,w,i))}else o.fill(v);if(d===Un.STROKE||d===Un.FILL_STROKE)if(s){let w=o.getTransform();o.setTransform(...s),o.stroke(this.#n(v,w,s))}else o.lineWidth/=u,o.stroke(v);o.restore()}else(d===Un.FILL||d===Un.FILL_STROKE)&&o.fillText(e,t,r),(d===Un.STROKE||d===Un.FILL_STROKE)&&o.strokeText(e,t,r);f&&(this.pendingTextPaths||=[]).push({transform:Ot(o),x:t,y:r,fontSize:u,path:v})}get isFontSubpixelAAEnabled(){let{context:e}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);e.scale(1.5,1),e.fillText("I",0,10);let t=e.getImageData(0,0,10,10).data,r=!1;for(let i=3;i<t.length;i+=4)if(t[i]>0&&t[i]<255){r=!0;break}return Xe(this,"isFontSubpixelAAEnabled",r)}showText(e){let t=this.current,r=t.font;if(r.isType3Font)return this.showType3Text(e);let i=t.fontSize;if(i===0)return;let s=this.ctx,o=t.fontSizeScale,a=t.charSpacing,c=t.wordSpacing,l=t.fontDirection,u=t.textHScale*l,d=e.length,f=r.vertical,p=f?1:-1,y=r.defaultVMetrics,v=i*t.fontMatrix[0],w=t.textRenderingMode===Un.FILL&&!r.disableFontFace&&!t.patternFill;s.save(),s.transform(...t.textMatrix),s.translate(t.x,t.y+t.textRise),l>0?s.scale(u,-1):s.scale(u,1);let E,A;if(t.patternFill){s.save();let C=t.fillColor.getPattern(s,this,ms(s),Bn.FILL);
84E=Ot(s),s.restore(),s.fillStyle=C}if(t.patternStroke){s.save();let C=t.strokeColor.getPattern(s,this,ms(s),Bn.STROKE);A=Ot(s),s.restore(),s.strokeStyle=C}let x=t.lineWidth,M=t.textMatrixScale;if(M===0||x===0){let C=t.textRenderingMode&Un.FILL_STROKE_MASK;(C===Un.STROKE||C===Un.FILL_STROKE)&&(x=this.getSinglePixelWidth())}else x/=M;if(o!==1&&(s.scale(o,o),x/=o),s.lineWidth=x,r.isInvalidPDFjsFont){let C=[],T=0;for(let S of e)C.push(S.unicode),T+=S.width;s.fillText(C.join(""),0,0),t.x+=T*v*u,s.restore(),this.compose();return}let O=0,$;for($=0;$<d;++$){let C=e[$];if(typeof C=="number"){O+=p*C*i/1e3;continue}let T=!1,S=(C.isSpace?c:0)+a,k=C.fontChar,P=C.accent,N,R,ze=C.width;if(f){let le=C.vmetric||y,ce=-(C.vmetric?le[1]:ze*.5)*v,un=le[2]*v;ze=le?-le[0]:ze,N=ce/o,R=(O+un)/o}else N=O/o,R=0;if(r.remeasure&&ze>0){let le=s.measureText(k).width*1e3/i*o;if(ze<le&&this.isFontSubpixelAAEnabled){let ce=ze/le;T=!0,s.save(),s.scale(ce,1),N/=ce}else ze!==le&&(N+=(ze-le)/2e3*i/o)}if(this.contentVisible&&(C.isInFont||r.missingFile)){if(w&&!P)s.fillText(k,N,R);else if(this.paintChar(k,N,R,E,A),P){let le=N+i*P.offset.x/o,ce=R-i*P.offset.y/o;this.paintChar(P.fontChar,le,ce,E,A)}}let Yt=f?ze*v-S*l:ze*v+S*l;O+=Yt,T&&s.restore()}f?t.y-=O:t.x+=O*u,s.restore(),this.compose()}showType3Text(e){let t=this.ctx,r=this.current,i=r.font,s=r.fontSize,o=r.fontDirection,a=i.vertical?1:-1,c=r.charSpacing,l=r.
84wordSpacing,u=r.textHScale*o,d=r.fontMatrix||FS,f=e.length,p=r.textRenderingMode===Un.INVISIBLE,y,v,w,E;if(!(p||s===0)){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,t.save(),t.transform(...r.textMatrix),t.translate(r.x,r.y),t.scale(u,o),y=0;y<f;++y){if(v=e[y],typeof v=="number"){E=a*v*s/1e3,this.ctx.translate(E,0),r.x+=E*u;continue}let A=(v.isSpace?l:0)+c,x=i.charProcOperatorList[v.operatorListId];if(!x){$e(`Type3 character "${v.operatorListId}" is not available.`);continue}this.contentVisible&&(this.processingType3=v,this.save(),t.scale(s,s),t.transform(...d),this.executeOperatorList(x),this.restore()),w=pe.applyTransform([v.width,0],d)[0]*s+A,t.translate(w,0),r.x+=w*u}t.restore(),this.processingType3=null}}setCharWidth(e,t){}setCharWidthAndBounds(e,t,r,i,s,o){this.ctx.rect(r,i,s-r,o-i),this.ctx.clip(),this.endPath()}getColorN_Pattern(e){let t;if(e[0]==="TilingPattern"){let r=e[1],i=this.baseTransform||Ot(this.ctx),s={createCanvasGraphics:o=>new n(o,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};t=new fne(e,r,this.ctx,s,i)}else t=this._getPattern(e[1],e[2]);return t}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments),this.current.patternStroke=!0}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(e,t,r){this.ctx.strokeStyle=this.current.strokeColor=pe.makeHexColor(e,t,r),this.current.patternStroke=!1}
84setStrokeTransparent(){this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(e,t,r){this.ctx.fillStyle=this.current.fillColor=pe.makeHexColor(e,t,r),this.current.patternFill=!1}setFillTransparent(){this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(e,t=null){let r;return this.cachedPatterns.has(e)?r=this.cachedPatterns.get(e):(r=hne(this.getObject(e)),this.cachedPatterns.set(e,r)),t&&(r.matrix=t),r}shadingFill(e){if(!this.contentVisible)return;let t=this.ctx;this.save();let r=this._getPattern(e);t.fillStyle=r.getPattern(t,this,ms(t),Bn.SHADING);let i=ms(t);if(i){let{width:s,height:o}=t.canvas,[a,c,l,u]=pe.getAxialAlignedBoundingBox([0,0,s,o],i);this.ctx.fillRect(a,c,l-a,u-c)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){Ct("Should not call beginInlineImage")}beginImageData(){Ct("Should not call beginImageData")}paintFormXObjectBegin(e,t){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),e&&this.transform(...e),this.baseTransform=Ot(this.ctx),t)){let r=t[2]-t[0],i=t[3]-t[1];this.ctx.rect(t[0],t[1],r,i),this.current.updateRectMinMax(Ot(this.ctx),t),this.clip(),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(e){if(!this.contentVisible)return;this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);let t=this.ctx;
84e.isolated||B_("TODO: Support non-isolated groups."),e.knockout&&$e("Knockout groups not supported.");let r=Ot(t);if(e.matrix&&t.transform(...e.matrix),!e.bbox)throw new Error("Bounding box is required.");let i=pe.getAxialAlignedBoundingBox(e.bbox,Ot(t)),s=[0,0,t.canvas.width,t.canvas.height];i=pe.intersect(i,s)||[0,0,0,0];let o=Math.floor(i[0]),a=Math.floor(i[1]),c=Math.max(Math.ceil(i[2])-o,1),l=Math.max(Math.ceil(i[3])-a,1);this.current.startNewPathAndClipBox([0,0,c,l]);let u="groupAt"+this.groupLevel;e.smask&&(u+="_smask_"+this.smaskCounter++%2);let d=this.cachedCanvases.getCanvas(u,c,l),f=d.context;f.translate(-o,-a),f.transform(...r),e.smask?this.smaskStack.push({canvas:d.canvas,context:f,offsetX:o,offsetY:a,subtype:e.smask.subtype,backdrop:e.smask.backdrop,transferMap:e.smask.transferMap||null,startTransformInverse:null}):(t.setTransform(1,0,0,1,0,0),t.translate(o,a),t.save()),Zh(t,f),this.ctx=f,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(t),this.groupLevel++}endGroup(e){if(!this.contentVisible)return;this.groupLevel--;let t=this.ctx,r=this.groupStack.pop();if(this.ctx=r,this.ctx.imageSmoothingEnabled=!1,e.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();let i=Ot(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...i);let s=pe.getAxialAlignedBoundingBox([0,0,t.canvas.width,t.canvas.height],i);this.ctx.drawImage(t.canvas,0,0),this.ctx.restore(),this.compose(s)}}beginAnnotation(e,t,r,i,s){if(this.#e(),o_(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),t){let o=t[2]-t[0],a=t[3]-t[1];if(s&&this.annotationCanvasMap){r=r.slice(),r[4]-=t[0],r[5]-=t[1],t=t.slice(),t[0]=t[1]=0,t[2]=o,t[3]=a;let[c,l]=pe.singularValueDecompose2dScale(Ot(this.ctx)),{viewportScale:u}=this,d=Math.ceil(o*this.outputScaleX*u),f=Math.ceil(a*this.outputScaleY*u);this.annotationCanvas=this.canvasFactory.create(d,f);let{canvas:p,context:y}=this.annotationCanvas;this.annotationCanvasMap.set(e,p),this.annotationCanvas.savedCtx=this.ctx,this.ctx=y,this.ctx.save(),this.ctx.setTransform(c,0,0,-l,0,a*l),o_(this.ctx)}else o_(this.ctx),this.endPath(),this.ctx.rect(t[0],t[1],o,a),this.ctx.clip(),this.ctx.beginPath()}this.current=new I_(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...r),this.transform(...i)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),this.#t(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(e){if(!this.contentVisible)return;let t=e.count;e=this.getObject(e.data,e),e.count=t;let r=this.ctx,i=this.processingType3;if(i&&(i.compiled===void 0&&(i.compiled=yne(e)),i.compiled)){i.compiled(r);return}let s=this._createMaskCanvas(e),o=s.canvas;r.save(),r.setTransform(1,0,0,1,0,0),r.drawImage(o,s.offsetX,s.offsetY),r.restore(),this.compose()}paintImageMaskXObjectRepeat(e,t,r=0,i=0,s,o){if(!this.contentVisible)return;e=this.getObject(e.data,e);let a=this.ctx;a.save();let c=Ot(a);a.transform(t,r,i,s,0,0);let l=this._createMaskCanvas(e);a.setTransform(1,0,0,1,l.offsetX-c[4],l.offsetY-c[5]);for(let u=0,d=o.length;u<d;u+=2){let f=pe.transform(c,[t,r,i,s,o[u],o[u+1]]),[p,y]=pe.applyTransform([0,0],f);a.drawImage(l.canvas,p,y)}a.restore(),this.compose()}paintImageMaskXObjectGroup(e){if(!this.contentVisible)return;let t=this.ctx,r=this.current.fillColor,i=this.current.patternFill;for(let s of e){let{data:o,width:a,height:c,transform:l}=s,u=this.cachedCanvases.getCanvas("maskCanvas",a,c),d=u.context;d.save();let f=this.getObject(o,s);i$(d,f),d.globalCompositeOperation="source-in",d.fillStyle=i?r.getPattern(d,this,ms(t),Bn.FILL):r,d.fillRect(0,0,a,c),d.restore(),t.save(),t.transform(...l),t.scale(1,-1),s_(t,u.canvas,0,0,a,c,0,-1,1,1),t.restore()}this.compose()}paintImageXObject(e){if(!this.contentVisible)return;let t=this.getObject(e);if(!t){$e("Dependent image isn't ready yet");return}this.paintInlineImageXObject(t)}paintImageXObjectRepeat(e,t,r,i){if(!this.contentVisible)return;let s=this.getObject(e);if(!s){$e("Dependent image isn't ready yet");return}let o=s.width,a=s.height,c=[];for(let l=0,u=i.length;l<u;l+=2)c.push({transform:[t,0,0,r,i[l],i[l+1]],x:0,y:0,w:o,h:a});this.paintInlineImageXObjectGroup(s,c)}applyTransferMapsToCanvas(e){return this.current.transferMaps!=="none"&&(e.filter=this.current.transferMaps,e.drawImage(e.canvas,0,0),e.filter="none"),e.canvas}applyTransferMapsToBitmap(e){if(this.current.transferMaps==="none")return e.bitmap;let{bitmap:t,width:r,height:i}=e,s=this.cachedCanvases.getCanvas("inlineImage",r,i),o=s.context;return o.filter=this.current.transferMaps,o.drawImage(t,0,0),o.filter="none",s.canvas}paintInlineImageXObject(e){if(!this.contentVisible)return;let t=e.width,r=e.height,i=this.ctx;if(this.save(),!Hn){let{filter:a}=i;a!=="none"&&a!==""&&(i.filter="none")}i.scale(1/t,-1/r);let s;if(e.bitmap)s=this.applyTransferMapsToBitmap(e);else if(typeof HTMLElement=="function"&&e instanceof HTMLElement||!e.data)s=e;else{let c=this.cachedCanvases.getCanvas("inlineImage",t,r).context;r$(c,e),s=this.applyTransferMapsToCanvas(c)}let o=this._scaleImage(s,ms(i));i.imageSmoothingEnabled=s$(Ot(i),e.interpolate),s_(i,o.img,0,0,o.paintWidth,o.paintHeight,0,-r,t,r),this.compose(),this.restore(
84)}paintInlineImageXObjectGroup(e,t){if(!this.contentVisible)return;let r=this.ctx,i;if(e.bitmap)i=e.bitmap;else{let s=e.width,o=e.height,c=this.cachedCanvases.getCanvas("inlineImage",s,o).context;r$(c,e),i=this.applyTransferMapsToCanvas(c)}for(let s of t)r.save(),r.transform(...s.transform),r.scale(1,-1),s_(r,i,s.x,s.y,s.w,s.h,0,-1,1,1),r.restore();this.compose()}paintSolidColorImageMask(){this.contentVisible&&(this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(e){}markPointProps(e,t){}beginMarkedContent(e){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(e,t){e==="OC"?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(t)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(e){let t=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(e);let r=this.ctx;this.pendingClip&&(t||(this.pendingClip===o$?r.clip("evenodd"):r.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),r.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){let e=Ot(this.ctx);if(e[1]===0&&e[2]===0)this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(e[0]),Math.abs(e[3]));else{let t=Math.abs(e[0]*e[3]-e[2]*e[1]),r=Math.hypot(e[0],e[2]),i=Math.hypot(e[1],e[3]);this._cachedGetSinglePixelWidth=Math.max(r,i)/t}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(this._cachedScaleForStroking[0]===-1){let{lineWidth:e}=this.current,{a:t,b:r,c:i,d:s}=this.ctx.getTransform(),o,a;if(r===0&&i===0){let c=Math.abs(t),l=Math.abs(s);if(c===l)if(e===0)o=a=1/c;else{let u=c*e;o=a=u<1?1/u:1}else if(e===0)o=1/c,a=1/l;else{let u=c*e,d=l*e;o=u<1?1/u:1,a=d<1?1/d:1}}else{let c=Math.abs(t*s-r*i),l=Math.hypot(t,r),u=Math.hypot(i,s);if(e===0)o=u/c,a=l/c;else{let d=e*c;o=u>d?u/d:1,a=l>d?l/d:1}}this._cachedScaleForStroking[0]=o,this._cachedScaleForStroking[1]=a}return this._cachedScaleForStroking}rescaleAndStroke(e){let{ctx:t}=this,{lineWidth:r}=this.current,[i,s]=this.getScaleForStroking();if(t.lineWidth=r||1,i===1&&s===1){t.stroke();return}let o=t.getLineDash();if(e&&t.save(),t.scale(i,s),o.length>0){let a=Math.max(i,s);t.setLineDash(o.map(c=>c/a)),t.lineDashOffset/=a}t.stroke(),e&&t.restore()}isContentVisible(){for(let e=this.markedContentStack.length-1;e>=0;e--)if(!this.markedContentStack[e].visible)return!1;return!0}};for(let n in Mi)Su.prototype[n]!==void 0&&(Su.prototype[Mi[n]]=Su.prototype[n]);var Ec=class{static#e=null;static#t="";static get workerPort(){return this.#e}static set workerPort(e){if(!(typeof Worker<"u"&&e instanceof Worker)&&e!==null)throw new Error("Invalid `workerPort` type.");this.#e=e}static get workerSrc(){return this.#t}static set workerSrc(e){if(typeof e!="string")throw new Error("Invalid `workerSrc` type.");this.#t=e}},ox=class{#e;#t;constructor({parsedData:e,rawData:t}){this.#e=e,this.#t=t}getRaw(){return this.#t}get(e){return this.#e.get(e)??null}getAll(){return nD(this.#e)}has(e){return this.#e.has(e)}},Cu=Symbol("INTERNAL"),ax=class{#e=!1;#t=!1;#n=!1;#r=!0;constructor(e,{name:t,intent:r,usage:i,rbGroups:s}){this.#e=!!(e&jr.DISPLAY),this.#t=!!(e&jr.PRINT),this.name=t,this.intent=r,this.usage=i,this.rbGroups=s}get visible(){if(this.#n)return this.#r;if(!this.#r)return!1;let{print:e,view:t}=this.usage;return this.#e?t?.viewState!=="OFF":this.#t?e?.printState!=="OFF":!0}_setVisible(e,t,r=!1){e!==Cu&&Ct("Internal method `_setVisible` called."),this.#n=r,this.#r=t}},cx=class{#e=null;#t=new Map;#n=null;#r=null;constructor(e,t=jr.DISPLAY){if(this.renderingIntent=t,this.name=null,this.creator=null,e!==null){this.name=e.name,this.creator=e.creator,this.#r=e.order;for(let r of e.groups)this.#t.set(r.id,new ax(t,r));if(e.baseState==="OFF")for(let r of this.#t.values())r._setVisible(Cu,!1);for(let r of e.on)this.#t.get(r)._setVisible(Cu,!0);for(let r of e.off)this.#t.get(r)._setVisible(Cu,!1);this.#n=this.getHash()}}#s(e){let t=e.length;if(t<2)return!0;let r=e[0];for(let i=1;i<t;i++){let s=e[i],o;
84if(Array.isArray(s))o=this.#s(s);else if(this.#t.has(s))o=this.#t.get(s).visible;else return $e(`Optional content group not found: ${s}`),!0;switch(r){case"And":if(!o)return!1;break;case"Or":if(o)return!0;break;case"Not":return!o;default:return!0}}return r==="And"}isVisible(e){if(this.#t.size===0)return!0;if(!e)return B_("Optional content group not defined."),!0;if(e.type==="OCG")return this.#t.has(e.id)?this.#t.get(e.id).visible:($e(`Optional content group not found: ${e.id}`),!0);if(e.type==="OCMD"){if(e.expression)return this.#s(e.expression);if(!e.policy||e.policy==="AnyOn"){for(let t of e.ids){if(!this.#t.has(t))return $e(`Optional content group not found: ${t}`),!0;if(this.#t.get(t).visible)return!0}return!1}else if(e.policy==="AllOn"){for(let t of e.ids){if(!this.#t.has(t))return $e(`Optional content group not found: ${t}`),!0;if(!this.#t.get(t).visible)return!1}return!0}else if(e.policy==="AnyOff"){for(let t of e.ids){if(!this.#t.has(t))return $e(`Optional content group not found: ${t}`),!0;if(!this.#t.get(t).visible)return!0}return!1}else if(e.policy==="AllOff"){for(let t of e.ids){if(!this.#t.has(t))return $e(`Optional content group not found: ${t}`),!0;if(this.#t.get(t).visible)return!1}return!0}return $e(`Unknown optional content policy ${e.policy}.`),!0}return $e(`Unknown group type ${e.type}.`),!0}setVisibility(e,t=!0,r=!0){let i=this.#t.get(e);if(!i){$e(`Optional content group not found: ${e}`);return}if(r&&t&&i.rbGroups.length)for(let s of i.rbGroups)for(let o of s)o!==e&&this.#t.get(o)?._setVisible(Cu,!1,!0);i._setVisible(Cu,!!t,!0),this.#e=null}setOCGState({state:e,preserveRB:t}){let r;for(let i of e){switch(i){case"ON":case"OFF":case"Toggle":r=i;continue}let s=this.#t.get(i);if(s)switch(r){case"ON":this.setVisibility(i,!0,t);break;case"OFF":this.setVisibility(i,!1,t);break;case"Toggle":this.setVisibility(i,!s.visible,t);break}}this.#e=null}get hasInitialVisibility(){return this.#n===null||this.getHash()===this.#n}getOrder(){return this.#t.size?this.#r?this.#r.slice():[...this.#t.keys()]:null}getGroups(){return this.#t.size>0?nD(this.#t):null}getGroup(e){return this.#t.get(e)||null}getHash(){if(this.#e!==null)return this.#e;let e=new m_;for(let[t,r]of this.#t)e.update(`${t}:${r.visible}`);return this.#e=e.hexdigest()}},lx=class{constructor(e,{disableRange:t=!1,disableStream:r=!1}){rn(e,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');let{length:i,initialData:s,progressiveDone:o,contentDispositionFilename:a}=e;if(this._queuedChunks=[],this._progressiveDone=o,this._contentDispositionFilename=a,s?.length>0){let c=s instanceof Uint8Array&&s.byteLength===s.buffer.byteLength?s.buffer:new Uint8Array(s).buffer;this._queuedChunks.push(c)}this._pdfDataRangeTransport=e,this._isStreamingSupported=!r,this._isRangeSupported=!t,this._contentLength=i,this._fullRequestReader=null,this._rangeReaders=[],e.addRangeListener((c,l)=>{this._onReceiveData({begin:c,chunk:l})}),e.addProgressListener((c,l)=>{this._onProgress({loaded:c,total:l})}),e.addProgressiveReadListener(c=>{this._onReceiveData({chunk:c})}),e.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),e.transportReady()}_onReceiveData({begin:e,chunk:t}){let r=t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength?t.buffer:new Uint8Array(t).buffer;if(e===void 0)this._fullRequestReader?this._fullRequestReader._enqueue(r):this._queuedChunks.push(r);else{let i=this._rangeReaders.some(function(s){return s._begin!==e?!1:(s._enqueue(r),!0)});rn(i,"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}_onProgress(e){e.total===void 0?this._rangeReaders[0]?.onProgress?.({loaded:e.loaded}):this._fullRequestReader?.onProgress?.({loaded:e.loaded,total:e.total})}_onProgressiveDone(){this._fullRequestReader?.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(e){let t=this._rangeReaders.indexOf(e);t>=0&&this._rangeReaders.splice(t,1)}getFullReader(){rn(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");let e=this._queuedChunks;return this._queuedChunks=null,new ux(this,e,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;let r=new dx(this,e,t);return this._pdfDataRangeTransport.requestDataRange(e,t),this._rangeReaders.push(r),r}cancelAllRequests(e){this._fullRequestReader?.cancel(e);for(let t of this._rangeReaders.slice(0))t.cancel(e);this._pdfDataRangeTransport.abort()}},ux=class{constructor(e,t,r=!1,i=null){this._stream=e,this._done=r||!1,this._filename=iD(i)?i:null,this._queuedChunks=t||[],this._loaded=0;for(let s of this._queuedChunks)this._loaded+=s.byteLength;
84this._requests=[],this._headersReady=Promise.resolve(),e._fullRequestReader=this,this.onProgress=null}_enqueue(e){this._done||(this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunks.push(e),this._loaded+=e.byteLength)}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}read(){return m(this,null,function*(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};let e=Promise.withResolvers();return this._requests.push(e),e.promise})}cancel(e){this._done=!0;for(let t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}},dx=class{constructor(e,t,r){this._stream=e,this._begin=t,this._end=r,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(e){if(!this._done){if(this._requests.length===0)this._queuedChunk=e;else{this._requests.shift().resolve({value:e,done:!1});for(let r of this._requests)r.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}read(){return m(this,null,function*(){if(this._queuedChunk){let t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};let e=Promise.withResolvers();return this._requests.push(e),e.promise})}cancel(e){this._done=!0;for(let t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}};function wne(n){let e=!0,t=r("filename\\*","i").exec(n);if(t){t=t[1];let u=a(t);return u=unescape(u),u=c(u),u=l(u),s(u)}if(t=o(n),t){let u=l(t);return s(u)}if(t=r("filename","i").exec(n),t){t=t[1];let u=a(t);return u=l(u),s(u)}function r(u,d){return new RegExp("(?:^|;)\\s*"+u+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',d)}function i(u,d){if(u){if(!/^[\x00-\xFF]+$/.test(d))return d;try{let f=new TextDecoder(u,{fatal:!0}),p=H_(d);d=f.decode(p),e=!1}catch{}}return d}function s(u){return e&&/[\x80-\xff]/.test(u)&&(u=i("utf-8",u),e&&(u=i("iso-8859-1",u))),u}function o(u){let d=[],f,p=r("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(f=p.exec(u))!==null;){let[,v,w,E]=f;if(v=parseInt(v,10),v in d){if(v===0)break;continue}d[v]=[w,E]}let y=[];for(let v=0;v<d.length&&v in d;++v){let[w,E]=d[v];E=a(E),w&&(E=unescape(E),v===0&&(E=c(E))),y.push(E)}return y.join("")}function a(u){if(u.startsWith('"')){let d=u.slice(1).split('\\"');for(let f=0;f<d.length;++f){let p=d[f].indexOf('"');p!==-1&&(d[f]=d[f].slice(0,p),d.length=f+1),d[f]=d[f].replaceAll(/\\(.)/g,"$1")}u=d.join('"')}return u}function c(u){let d=u.indexOf("'");if(d===-1)return u;let f=u.slice(0,d),y=u.slice(d+1).replace(/^[^']*'/,"");return i(f,y)}function l(u){return!u.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(u)?u:u.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(d,f,p,y){if(p==="q"||p==="Q")return y=y.replaceAll("_"," "),y=y.replaceAll(/=([0-9a-fA-F]{2})/g,function(v,w){return String.fromCharCode(parseInt(w,16))}),i(f,y);try{y=atob(y)}catch{}return i(f,y)})}return""}function h$(n,e){let t=new Headers;if(!n||!e||typeof e!="object")return t;for(let r in e){let i=e[r];i!==void 0&&t.append(r,i)}return t}function G_(n){try{return new URL(n).origin}catch{}return null}function f$({responseHeaders:n,isHttp:e,rangeChunkSize:t,disableRange:r}){let i={allowRangeRequests:!1,suggestedLength:void 0},s=parseInt(n.get("Content-Length"),10);return!Number.isInteger(s)||(i.suggestedLength=s,s<=2*t)||r||!e||n.get("Accept-Ranges")!=="bytes"||(n.get("Content-Encoding")||"identity")!=="identity"||(i.allowRangeRequests=!0),i}function p$(n){let e=n.get("Content-Disposition");if(e){let t=wne(e);if(t.includes("%"))try{t=decodeURIComponent(t)}catch{}if(iD(t))return t}return null}function W_(n,e){return n===404||n===0&&e.startsWith("file:")?new Ic('Missing PDF "'+e+'".'):new Du(`Unexpected server response
84(${n}) while retrieving PDF "${e}".`,n)}function m$(n){return n===200||n===206}function g$(n,e,t){return{method:"GET",headers:n,signal:t.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"}}function y$(n){return n instanceof Uint8Array?n.buffer:n instanceof ArrayBuffer?n:($e(`getArrayBuffer - unexpected data format: ${n}`),new Uint8Array(n).buffer)}var T_=class{_responseOrigin=null;constructor(e){this.source=e,this.isHttp=/^https?:/i.test(e.url),this.headers=h$(this.isHttp,e.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return rn(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new hx(this),this._fullRequestReader}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;let r=new fx(this,e,t);return this._rangeRequestReaders.push(r),r}cancelAllRequests(e){this._fullRequestReader?.cancel(e);for(let t of this._rangeRequestReaders.slice(0))t.cancel(e)}},hx=class{constructor(e){this._stream=e,this._reader=null,this._loaded=0,this._filename=null;let t=e.source;this._withCredentials=t.withCredentials||!1,this._contentLength=t.length,this._headersCapability=Promise.withResolvers(),this._disableRange=t.disableRange||!1,this._rangeChunkSize=t.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!t.disableStream,this._isRangeSupported=!t.disableRange;let r=new Headers(e.headers),i=t.url;fetch(i,g$(r,this._withCredentials,this._abortController)).then(s=>{if(e._responseOrigin=G_(s.url),!m$(s.status))throw W_(s.status,i);this._reader=s.body.getReader(),this._headersCapability.resolve();let o=s.headers,{allowRangeRequests:a,suggestedLength:c}=f$({responseHeaders:o,isHttp:e.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=a,this._contentLength=c||this._contentLength,this._filename=p$(o),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new ys("Streaming is disabled."))}).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}read(){return m(this,null,function*(){yield this._headersCapability.promise;let{value:e,done:t}=yield this._reader.read();return t?{value:e,done:t}:(this._loaded+=e.byteLength,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:y$(e),done:!1})})}cancel(e){this._reader?.cancel(e),this._abortController.abort()}},fx=class{constructor(e,t,r){this._stream=e,this._reader=null,this._loaded=0;let i=e.source;this._withCredentials=i.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!i.disableStream,this._abortController=new AbortController;let s=new Headers(e.headers);s.append("Range",`bytes=${t}-${r-1}`);let o=i.url;fetch(o,g$(s,this._withCredentials,this._abortController)).then(a=>{let c=G_(a.url);if(c!==e._responseOrigin)throw new Error(`Expected range response-origin "${c}" to match "${e._responseOrigin}".`);if(!m$(a.status))throw W_(a.status,o);this._readCapability.resolve(),this._reader=a.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}read(){return m(this,null,function*(){yield this._readCapability.promise;let{value:e,done:t}=yield this._reader.read();return t?{value:e,done:t}:(this._loaded+=e.byteLength,this.onProgress?.({loaded:this._loaded}),{value:y$(e),done:!1})})}cancel(e){this._reader?.cancel(e),this._abortController.abort()}},OS=200,LS=206;function Ene(n){let e=n.response;return typeof e!="string"?e:H_(e).buffer}var px=class{_responseOrigin=null;constructor({url:e,httpHeaders:t,withCredentials:r}){this.url=e,this.isHttp=/^https?:/i.test(e),this.headers=h$(this.isHttp,t),this.withCredentials=r||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}request(e){let t=new XMLHttpRequest,r=this.currXhrId++,i=this.pendingRequests[r]={x
84hr:t};t.open("GET",this.url),t.withCredentials=this.withCredentials;for(let[s,o]of this.headers)t.setRequestHeader(s,o);return this.isHttp&&"begin"in e&&"end"in e?(t.setRequestHeader("Range",`bytes=${e.begin}-${e.end-1}`),i.expectedStatus=LS):i.expectedStatus=OS,t.responseType="arraybuffer",rn(e.onError,"Expected `onError` callback to be provided."),t.onerror=()=>{e.onError(t.status)},t.onreadystatechange=this.onStateChange.bind(this,r),t.onprogress=this.onProgress.bind(this,r),i.onHeadersReceived=e.onHeadersReceived,i.onDone=e.onDone,i.onError=e.onError,i.onProgress=e.onProgress,t.send(null),r}onProgress(e,t){let r=this.pendingRequests[e];r&&r.onProgress?.(t)}onStateChange(e,t){let r=this.pendingRequests[e];if(!r)return;let i=r.xhr;if(i.readyState>=2&&r.onHeadersReceived&&(r.onHeadersReceived(),delete r.onHeadersReceived),i.readyState!==4||!(e in this.pendingRequests))return;if(delete this.pendingRequests[e],i.status===0&&this.isHttp){r.onError(i.status);return}let s=i.status||OS;if(!(s===OS&&r.expectedStatus===LS)&&s!==r.expectedStatus){r.onError(i.status);return}let a=Ene(i);if(s===LS){let c=i.getResponseHeader("Content-Range"),l=/bytes (\d+)-(\d+)\/(\d+)/.exec(c);l?r.onDone({begin:parseInt(l[1],10),chunk:a}):($e('Missing or invalid "Content-Range" header.'),r.onError(0))}else a?r.onDone({begin:0,chunk:a}):r.onError(i.status)}getRequestXhr(e){return this.pendingRequests[e].xhr}isPendingRequest(e){return e in this.pendingRequests}abortRequest(e){let t=this.pendingRequests[e].xhr;delete this.pendingRequests[e],t.abort()}},mx=class{constructor(e){this._source=e,this._manager=new px(e),this._rangeChunkSize=e.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(e){let t=this._rangeRequestReaders.indexOf(e);t>=0&&this._rangeRequestReaders.splice(t,1)}getFullReader(){return rn(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new gx(this._manager,this._source),this._fullRequestReader}getRangeReader(e,t){let r=new yx(this._manager,e,t);return r.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(r),r}cancelAllRequests(e){this._fullRequestReader?.cancel(e);for(let t of this._rangeRequestReaders.slice(0))t.cancel(e)}},gx=class{constructor(e,t){this._manager=e,this._url=t.url,this._fullRequestId=e.request({onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._headersCapability=Promise.withResolvers(),this._disableRange=t.disableRange||!1,this._contentLength=t.length,this._rangeChunkSize=t.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){let e=this._fullRequestId,t=this._manager.getRequestXhr(e);this._manager._responseOrigin=G_(t.responseURL);let r=t.getAllResponseHeaders(),i=new Headers(r?r.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map(a=>{let[c,...l]=a.split(": ");return[c,l.join(": ")]}):[]),{allowRangeRequests:s,suggestedLength:o}=f$({responseHeaders:i,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});s&&(this._isRangeSupported=!0),this._contentLength=o||this._contentLength,this._filename=p$(i),this._isRangeSupported&&this._manager.abortRequest(e),this._headersCapability.resolve()}_onDone(e){if(e&&(this._requests.length>0?this._requests.shift().resolve({value:e.chunk,done:!1}):this._cachedChunks.push(e.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(let t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(e){this._storedError=W_(e,this._url),this._headersCapability.reject(this._storedError);for(let t of this._requests)t.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(e){this.onProgress?.({loaded:e.loaded,total:e.lengthComputable?e.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersCapability.promise}read(){return m(this,null,function*(){if(yield this._headersCapability.promise,this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};let e=Promise.withResolvers();return this._requests.push(e),e.promise})}cancel(e){this._done=!0,this._headersCapability.reject(e);for(let t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest
84(this._fullRequestId),this._fullRequestReader=null}},yx=class{constructor(e,t,r){this._manager=e,this._url=e.url,this._requestId=e.request({begin:t,end:r,onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_onHeadersReceived(){let e=G_(this._manager.getRequestXhr(this._requestId)?.responseURL);e!==this._manager._responseOrigin&&(this._storedError=new Error(`Expected range response-origin "${e}" to match "${this._manager._responseOrigin}".`),this._onError(0))}_close(){this.onClosed?.(this)}_onDone(e){let t=e.chunk;this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunk=t,this._done=!0;for(let r of this._requests)r.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(e){this._storedError??=W_(e,this._url);for(let t of this._requests)t.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(e){this.isStreamingSupported||this.onProgress?.({loaded:e.loaded})}get isStreamingSupported(){return!1}read(){return m(this,null,function*(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){let t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};let e=Promise.withResolvers();return this._requests.push(e),e.promise})}cancel(e){this._done=!0;for(let t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}},Ine=/^[a-z][a-z0-9\-+.]+:/i;function Tne(n){if(Ine.test(n))return new URL(n);let e=process.getBuiltinModule("url");return new URL(e.pathToFileURL(n))}var _x=class{constructor(e){this.source=e,this.url=Tne(e.url),rn(this.url.protocol==="file:","PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return rn(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new vx(this),this._fullRequestReader}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;let r=new bx(this,e,t);return this._rangeRequestReaders.push(r),r}cancelAllRequests(e){this._fullRequestReader?.cancel(e);for(let t of this._rangeRequestReaders.slice(0))t.cancel(e)}},vx=class{constructor(e){this._url=e.url,this._done=!1,this._storedError=null,this.onProgress=null;let t=e.source;this._contentLength=t.length,this._loaded=0,this._filename=null,this._disableRange=t.disableRange||!1,this._rangeChunkSize=t.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!t.disableStream,this._isRangeSupported=!t.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers();let r=process.getBuiltinModule("fs");r.promises.lstat(this._url).then(i=>{this._contentLength=i.size,this._setReadableStream(r.createReadStream(this._url)),this._headersCapability.resolve()},i=>{i.code==="ENOENT"&&(i=new Ic(`Missing PDF "${this._url}".`)),this._storedError=i,this._headersCapability.reject(i)})}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}read(){return m(this,null,function*(){if(yield this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;let e=this._readableStream.read();return e===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=e.length,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(e).buffer,done:!1})})}cancel(e){if(!this._readableStream){this._error(e);return}this._readableStream.destroy(e)}_error(e){this._storedError=e,this._readCapability.resolve()}_setReadableStream(e){this._readableStream=e,e.on("readable",()=>{this._readCapability.resolve()}),e.on("end",()=>{e.destroy(),this._done=!0,this._readCapability.resolve()}),e.on("error",t=>{this._error(t)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new ys("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}},bx=class{constructor(e,t,r){this._url=e.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();let i=e.source;this._isStreamingSupported=!i.disableStream;let s=process.getBuiltinModule("fs");this._setReadableStream(s.createReadStream(this._url,{start:t,end:r-1}))}get isStreamingSupported(){return this._isStreamingSupported}read(){return m(this,null,function*(){if(yield this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;let e=this._readableStream.read();return e===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=e.length,this.onProgress?.({loaded:this._loaded}),{value:new Uint8Array(e).buffer,done:!1})})}cancel(e){if(!this._readableStream){this._error(e);return}this._readableStream.destroy(e)}_error(e){this._storedError=e,this._readCapability.resolve()}_setReadableStream(e){this._readableStream=e,e.on("readable",()=>{this._readCapability.resolve()}),e.on("end",()=>{e.destroy(),this._done=!0,this._readCapability.resolve()}),e.on("error",t=>{this._error(t)}),this._storedError&&this._readableStream.destroy(this._storedError)}},Ane=1e5,_r=30,Cne=.8,hf=class n{#e=Promise.withResolvers();#t=null;#n=!1;#r=!!globalThis.FontInspector?.enabled;#s=null;#i=null;#c=0;#a=0;#u=null;#l=null;#h=0;#d=0;#f=Object.create(null);#o=[];#p=null;#g=[];#m=new WeakMap;#y=null;static#b=new Map;static#_=new Map;static#w=new WeakMap;static#I=null;static#A=new Set;constructor({textContentSource:e,container:t,viewport:r}){if(e instanceof ReadableStream)this.#p=e;else if(typeof e=="object")this.#p=new ReadableStream({start(c){c.enqueue(e),c.close()}});else throw new Error('No "textContentSource" parameter specified.');this.#t=this.#l=t,this.#d=r.scale*(globalThis.devicePixelRatio||1),this.#h=r.rotation,this.#i={div:null,properties:null,ctx:null};let{pageWidth:i,pageHeight:s,pageX:o,pageY:a}=r.rawDims;this.#y=[1,0,0,-1,-o,a+s],this.#a=i,this.#c=s,n.#k(),Tc(t,r),this.#e.promise.finally(()=>{n.#A.delete(this),this.#i=null,this.#f=null}).catch(()=>{})}static get fontFamilyMap(){let{isWindows:e,isFirefox:t}=Cn.platform;return Xe(this,"fontFamilyMap",new Map([["sans-serif",`${e&&t?"Calibri, ":""}sans-serif`],["monospace",`${e&&t?"Lucida Console, ":""}monospace`]]))}render(){let e=()=>{this.#u.read().then(({value:t,done:r})=>{if(r){this.#e.resolve();return}this.#s??=t.lang,Object.assign(this.#f,t.styles),this.#S(t.items),e()},this.#e.reject)};return this.#u=this.#p.getReader(),n.#A.add(this),e(),this.#e.promise}update({viewport:e,onBefore:t=null}){let r=e.scale*(globalThis.devicePixelRatio||1),i=e.rotation;if(i!==this.#h&&(t?.(),this.#h=i,Tc(this.#l,{rotation:i})),r!==this.#d){t?.(),this.#d=r;let s={div:null,properties:null,ctx:n.#x(this.#s)};for(let o of this.#g)s.properties=this.#m.get(o),s.div=o,this.#E(s)}}cancel(){let e=new ys("TextLayer task cancelled.");this.#u?.cancel(e).catch(()=>{}),this.#u=null,this.#e.reject(e)}get textDivs(){return this.#g}get textContentItemsStr(){return this.#o}#S(e){if(this.#n)return;this.#i.ctx??=n.#x(this.#s);let t=this.#g,r=this.#o;for(let i of e){if(t.length>
84Ane){$e("Ignoring additional textDivs for performance reasons."),this.#n=!0;return}if(i.str===void 0){if(i.type==="beginMarkedContentProps"||i.type==="beginMarkedContent"){let s=this.#t;this.#t=document.createElement("span"),this.#t.classList.add("markedContent"),i.id!==null&&this.#t.setAttribute("id",`${i.id}`),s.append(this.#t)}else i.type==="endMarkedContent"&&(this.#t=this.#t.parentNode);continue}r.push(i.str),this.#D(i)}}#D(e){let t=document.createElement("span"),r={angle:0,canvasWidth:0,hasText:e.str!=="",hasEOL:e.hasEOL,fontSize:0};this.#g.push(t);let i=pe.transform(this.#y,e.transform),s=Math.atan2(i[1],i[0]),o=this.#f[e.fontName];o.vertical&&(s+=Math.PI/2);let a=this.#r&&o.fontSubstitution||o.fontFamily;a=n.fontFamilyMap.get(a)||a;let c=Math.hypot(i[2],i[3]),l=c*n.#N(a,this.#s),u,d;s===0?(u=i[4],d=i[5]-l):(u=i[4]+l*Math.sin(s),d=i[5]-l*Math.cos(s));let f="calc(var(--scale-factor)*",p=t.style;this.#t===this.#l?(p.left=`${(100*u/this.#a).toFixed(2)}%`,p.top=`${(100*d/this.#c).toFixed(2)}%`):(p.left=`${f}${u.toFixed(2)}px)`,p.top=`${f}${d.toFixed(2)}px)`),p.fontSize=`${f}${(n.#I*c).toFixed(2)}px)`,p.fontFamily=a,r.fontSize=c,t.setAttribute("role","presentation"),t.textContent=e.str,t.dir=e.dir,this.#r&&(t.dataset.fontName=o.fontSubstitutionLoadedName||e.fontName),s!==0&&(r.angle=s*(180/Math.PI));let y=!1;if(e.str.length>1)y=!0;else if(e.str!==" "&&e.transform[0]!==e.transform[3]){let v=Math.abs(e.transform[0]),w=Math.abs(e.transform[3]);v!==w&&Math.max(v,w)/Math.min(v,w)>1.5&&(y=!0)}if(y&&(r.canvasWidth=o.vertical?e.height:e.width),this.#m.set(t,r),this.#i.div=t,this.#i.properties=r,this.#E(this.#i),r.hasText&&this.#t.append(t),r.hasEOL){let v=document.createElement("br");v.setAttribute("role","presentation"),this.#t.append(v)}}#E(e){let{div:t,properties:r,ctx:i}=e,{style:s}=t,o="";if(n.#I>1&&(o=`scale(${1/n.#I})`),r.canvasWidth!==0&&r.hasText){let{fontFamily:a}=s,{canvasWidth:c,fontSize:l}=r;n.#C(i,l*this.#d,a);let{width:u}=i.measureText(t.textContent);u>0&&(o=`scaleX(${c*this.#d/u}) ${o}`)}r.angle!==0&&(o=`rotate(${r.angle}deg) ${o}`),o.length>0&&(s.transform=o)}static cleanup(){if(!(this.#A.size>0)){this.#b.clear();for(let{canvas:e}of this.#_.values())e.remove();this.#_.clear()}}static#x(e=null){let t=this.#_.get(e||="");if(!t){let r=document.createElement("canvas");r.className="hiddenCanvasElement",r.lang=e,document.body.append(r),t=r.getContext("2d",{alpha:!1,willReadFrequently:!0}),this.#_.set(e,t),this.#w.set(t,{size:0,family:""})}return t}static#C(e,t,r){let i=this.#w.get(e);t===i.size&&r===i.family||(e.font=`${t}px ${r}`,i.size=t,i.family=r)}static#k(){if(this.#I!==null)return;let e=document.createElement("div");e.style.opacity=0,e.style.lineHeight=1,e.style.fontSize="1px",e.style.position="absolute",e.textContent="X",document.body.append(e),this.#I=e.getBoundingClientRect().height,e.remove()}static#N(e,t){let r=this.#b.get(e);if(r)return r;let i=this.#x(t);i.canvas.width=i.canvas.height=_r,this.#C(i,_r,e);let s=i.measureText(""),o=s.fontBoundingBoxAscent,a=Math.abs(s.fontBoundingBoxDescent);if(o){let u=o/(o+a);return this.#b.set(e,u),i.canvas.width=i.canvas.height=0,u}i.strokeStyle="red",i.clearRect(0,0,_r,_r),i.strokeText("g",0,0);let c=i.getImageData(0,0,_r,_r).data;a=0;for(let u=c.length-1-3;u>=0;u-=4)if(c[u]>0){a=Math.ceil(u/4/_r);break}i.clearRect(0,0,_r,_r),i.strokeText("A",0,_r),c=i.getImageData(0,0,_r,_r).data,o=0;for(let u=0,d=c.length;u<d;u+=4)if(c[u]>0){o=_r-Math.floor(u/4/_r);break}i.canvas.width=i.canvas.height=0;let l=o?o/(o+a):Cne;return this.#b.set(e,l),l}},ff=class n{static textContent(e){let t=[],r={items:t,styles:Object.create(null)};function i(s){if(!s)return;let o=null,a=s.name;if(a==="#text")o=s.value;else if(n.shouldBuildText(a))s?.attributes?.textContent?o=s.attributes.textContent:s.value&&(o=s.value);else return;if(o!==null&&t.push({str:o}),!!s.children)for(let c of s.children)i(c)}return i(e),r}static shouldBuildText(e){return!(e==="textarea"||e==="input"||e==="option"||e==="select")}},Sne=65536,xne=100,Dne=5e3,Rne=Hn?ZS:YS,kne=Hn?JS:v_,Pne=Hn?QS:XS,Mne=Hn?ex:E_;function Nne(n={}){typeof n=="string"||n instanceof URL?n={url:n}:(n instanceof ArrayBuffer||ArrayBuffer.isView(n))&&(n={data:n});let e=new wx,{docId:t}=e,r=n.url?One(n.url):null,i=n.data?Lne(n.data):null,s=n.httpHeaders||null,o=n.withCredentials===!0,a=n.password??null,c=n.range instanceof A_?n.range:null,l=Number.isInteger(n.rangeChunkSize)&&n.rangeChunkSize>0?n.rangeChunkSize:Sne,u=n.worker instanceof xu?n.worker:null,d=n.verbosity,f=typeof n.docBaseUrl=="string"&&!z_(n.docBaseUrl)?n.docBaseUrl:null,p=typeof n.cMapUrl=="string"?n.cMapUrl:null,y=n.cMapPacked!==!1,v=n.CMapReaderFactory||kne,w=typeof n.standardFontDataUrl=="string"?n.standardFontDataUrl:null,E=n.StandardFontDataFactory||Mne,A=n.stopAtErrors!==!0,x=Number.isInteger(n.maxImageSize)&&n.maxImageSize>-1?n.maxImageSize:-1,M=n.isEvalSupported!==!1,O=typeof n.isOffscreenCanvasSupported=="boolean"?n.isOffscreenCanvasSupported:!Hn,$=typeof n.isImageDecoderSupported=="boolean"?n.isImageDecoderSupported:!Hn&&(Cn.platform.isFirefox||!globalThis.chrome),C=Number.isInteger(n.canvasMaxAreaInBytes)?n.canvasMaxAreaInBytes:-1,T=typeof n.disableFontFace=="boolean"?n.disableFontFace:Hn,S=n.fontExtraProperties===!0,k=n.enableXfa===!0,P=n.ownerDocument||globalThis.document,N=n.disableRange===!0,R=n.disableStream===!0,ze=n.disableAutoFetch===!0,Yt=n.pdfBug===!0,le=n.CanvasFactory||Rne,ce=n.FilterFactory||Pne,un=n.enableHWA===!0,ur=c?c.length:n.length??NaN,$i=typeof n.useSystemFonts=="boolean"?n.useSystemFonts:!Hn&&!T,dr=typeof n.useWorkerFetch=="boolean"?n.useWorkerFetch:v===v_&&E===E_&&p&&w&&tf(p,document.baseURI)&&tf(w,document.baseURI),Et=null;Xte(d);let Ze={canvasFactory:new le({ownerDocument:P,enableHWA:un}),filterFactory:new ce({docId:t,ownerDocument:P}),cMapReaderFactory:dr?null:new v({baseUrl:p,isCompressed:y}),standardFontDataFactory:dr?null:new E({baseUrl:w})};if(!u){let hr={verbosity:d,port:Ec.workerPort};u=hr.port?xu.fromPort(hr):new xu(hr),e._worker=u}let Io={docId:t,apiVersion:"4.10.38",data:i,password:a,disableAutoFetch:ze,rangeChunkSize:l,length:ur,docBaseUrl:f,enableXfa:k,evaluatorOptions:{maxImageSize:x,disableFontFace:T,ignoreErrors:A,isEvalSupported:M,isOffscreenCanvasSupported:O,isImageDecoderSupported:$,canvasMaxAreaInBytes:C,fontExtraProperties:S,useSystemFonts:$i,cMapUrl:dr?p:null,standardFontDataUrl:dr?w:null}},li={disableFontFace:T,fontExtraProperties:S,ownerDocument:P,pdfBug:Yt,styleElement:Et,loadingParams:{disableAutoFetch:ze,enableXfa:k}};return u.promise.then(function(){if(e.destroyed)throw new Error("Loading aborted");if(u.destroyed)throw new Error("Worker was destroyed");
84let hr=u.messageHandler.sendWithPromise("GetDocRequest",Io,i?[i.buffer]:null),dt;if(c)dt=new lx(c,{disableRange:N,disableStream:R});else if(!i){if(!r)throw new Error("getDocument - no `url` parameter provided.");let Ur;if(Hn)if(tf(r)){if(typeof fetch>"u"||typeof Response>"u"||!("body"in Response.prototype))throw new Error("getDocument - the Fetch API was disabled in Node.js, see `--no-experimental-fetch`.");Ur=T_}else Ur=_x;else Ur=tf(r)?T_:mx;dt=new Ur({url:r,length:ur,httpHeaders:s,withCredentials:o,rangeChunkSize:l,disableRange:N,disableStream:R})}return hr.then(Ur=>{if(e.destroyed)throw new Error("Loading aborted");if(u.destroyed)throw new Error("Worker was destroyed");let Kf=new wc(t,Ur,u.port),qc=new Ax(Kf,e,dt,li,Ze);e._transport=qc,Kf.send("Ready",null)})}).catch(e._capability.reject),e}function One(n){if(n instanceof URL)return n.href;try{return new URL(n,window.location).href}catch{if(Hn&&typeof n=="string")return n}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function Lne(n){if(Hn&&typeof Buffer<"u"&&n instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(n instanceof Uint8Array&&n.byteLength===n.buffer.byteLength)return n;if(typeof n=="string")return H_(n);if(n instanceof ArrayBuffer||ArrayBuffer.isView(n)||typeof n=="object"&&!isNaN(n?.length))return new Uint8Array(n);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function a$(n){return typeof n=="object"&&Number.isInteger(n?.num)&&n.num>=0&&Number.isInteger(n?.gen)&&n.gen>=0}var wx=class n{static#e=0;constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId=`d${n.#e++}`,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}destroy(){return m(this,null,function*(){this.destroyed=!0;try{this._worker?.port&&(this._worker._pendingDestroy=!0),yield this._transport?.destroy()}catch(e){throw this._worker?.port&&delete this._worker._pendingDestroy,e}this._transport=null,this._worker?.destroy(),this._worker=null})}},A_=class{constructor(e,t,r=!1,i=null){this.length=e,this.initialData=t,this.progressiveDone=r,this.contentDispositionFilename=i,this._rangeListeners=[],this._progressListeners=[],this._progressiveReadListeners=[],this._progressiveDoneListeners=[],this._readyCapability=Promise.withResolvers()}addRangeListener(e){this._rangeListeners.push(e)}addProgressListener(e){this._progressListeners.push(e)}addProgressiveReadListener(e){this._progressiveReadListeners.push(e)}addProgressiveDoneListener(e){this._progressiveDoneListeners.push(e)}onDataRange(e,t){for(let r of this._rangeListeners)r(e,t)}onDataProgress(e,t){this._readyCapability.promise.then(()=>{for(let r of this._progressListeners)r(e,t)})}onDataProgressiveRead(e){this._readyCapability.promise.then(()=>{for(let t of this._progressiveReadListeners)t(e)})}onDataProgressiveDone(){this._readyCapability.promise.then(()=>{for(let e of this._progressiveDoneListeners)e()})}transportReady(){this._readyCapability.resolve()}requestDataRange(e,t){Ct("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}},Ex=class{constructor(e,t){this._pdfInfo=e,this._transport=t}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return Xe(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(e){return this._transport.getPage(e)}getPageIndex(e){return this._transport.getPageIndex(e)}
84getDestinations(){return this._transport.getDestinations()}getDestination(e){return this._transport.getDestination(e)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:e="display"}={}){let{renderingIntent:t}=this._transport.getRenderingIntent(e);return this._transport.getOptionalContentConfig(t)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(e=!1){return this._transport.startCleanup(e||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(e){return this._transport.cachedPageNumber(e)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}},Ix=class{#e=null;#t=!1;constructor(e,t,r,i=!1){this._pageIndex=e,this._pageInfo=t,this._transport=r,this._stats=i?new d_:null,this._pdfBug=i,this.commonObjs=r.commonObjs,this.objs=new C_,this._maybeCleanupAfterRender=!1,this._intentStates=new Map,this.destroyed=!1}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:e,rotation:t=this.rotate,offsetX:r=0,offsetY:i=0,dontFlip:s=!1}={}){return new of({viewBox:this.view,userUnit:this.userUnit,scale:e,rotation:t,offsetX:r,offsetY:i,dontFlip:s})}getAnnotations({intent:e="display"}={}){let{renderingIntent:t}=this._transport.getRenderingIntent(e);return this._transport.getAnnotations(this._pageIndex,t)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return Xe(this,"isPureXfa",!!this._transport._htmlForXfa)}getXfa(){return m(this,null,function*(){return this._transport._htmlForXfa?.children[this._pageIndex]||null})}render({canvasContext:e,viewport:t,intent:r="display",annotationMode:i=aa.ENABLE,transform:s=null,background:o=null,optionalContentConfigPromise:a=null,annotationCanvasMap:c=null,pageColors:l=null,printAnnotationStorage:u=null,isEditing:d=!1}){this._stats?.time("Overall");let f=this._transport.getRenderingIntent(r,i,u,d),{renderingIntent:p,cacheKey:y}=f;this.#t=!1,this.#r(),a||=this._transport.getOptionalContentConfig(p);let v=this._intentStates.get(y);v||(v=Object.create(null),this._intentStates.set(y,v)),v.streamReaderCancelTimeout&&(clearTimeout(v.streamReaderCancelTimeout),v.streamReaderCancelTimeout=null);let w=!!(p&jr.PRINT);v.displayReadyCapability||(v.displayReadyCapability=Promise.withResolvers(),v.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(f));let E=M=>{v.renderTasks.delete(A),(this._maybeCleanupAfterRender||w)&&(this.#t=!0),this.#n(!w),M?(A.capability.reject(M),this._abortOperatorList({intentState:v,reason:M instanceof Error?M:new Error(M)})):A.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},A=new Sx({callback:E,params:{canvasContext:e,viewport:t,transform:s,background:o},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:c,operatorList:v.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!w,pdfBug:this._pdfBug,page
84Colors:l});(v.renderTasks||=new Set).add(A);let x=A.task;return Promise.all([v.displayReadyCapability.promise,a]).then(([M,O])=>{if(this.destroyed){E();return}if(this._stats?.time("Rendering"),!(O.renderingIntent&p))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");A.initializeGraphics({transparency:M,optionalContentConfig:O}),A.operatorListChanged()}).catch(E),x}getOperatorList({intent:e="display",annotationMode:t=aa.ENABLE,printAnnotationStorage:r=null,isEditing:i=!1}={}){function s(){a.operatorList.lastChunk&&(a.opListReadCapability.resolve(a.operatorList),a.renderTasks.delete(c))}let o=this._transport.getRenderingIntent(e,t,r,i,!0),a=this._intentStates.get(o.cacheKey);a||(a=Object.create(null),this._intentStates.set(o.cacheKey,a));let c;return a.opListReadCapability||(c=Object.create(null),c.operatorListChanged=s,a.opListReadCapability=Promise.withResolvers(),(a.renderTasks||=new Set).add(c),a.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(o)),a.opListReadCapability.promise}streamTextContent({includeMarkedContent:e=!1,disableNormalization:t=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:e===!0,disableNormalization:t===!0},{highWaterMark:100,size(i){return i.items.length}})}getTextContent(e={}){if(this._transport._htmlForXfa)return this.getXfa().then(r=>ff.textContent(r));let t=this.streamTextContent(e);return new Promise(function(r,i){function s(){o.read().then(function({value:c,done:l}){if(l){r(a);return}a.lang??=c.lang,Object.assign(a.styles,c.styles),a.items.push(...c.items),s()},i)}let o=t.getReader(),a={items:[],styles:Object.create(null),lang:null};s()})}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;let e=[];for(let t of this._intentStates.values())if(this._abortOperatorList({intentState:t,reason:new Error("Page was destroyed."),force:!0}),!t.opListReadCapability)for(let r of t.renderTasks)e.push(r.completed),r.cancel();return this.objs.clear(),this.#t=!1,this.#r(),Promise.all(e)}cleanup(e=!1){this.#t=!0;let t=this.#n(!1);return e&&t&&(this._stats&&=new d_),t}#n(e=!1){if(this.#r(),!this.#t||this.destroyed)return!1;if(e)return this.#e=setTimeout(()=>{this.#e=null,this.#n(!1)},Dne),!1;for(let{renderTasks:t,operatorList:r}of this._intentStates.values())if(t.size>0||!r.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),this.#t=!1,!0}#r(){this.#e&&(clearTimeout(this.#e),this.#e=null)}_startRenderPage(e,t){let r=this._intentStates.get(t);r&&(this._stats?.timeEnd("Page Request"),r.displayReadyCapability?.resolve(e))}_renderPageChunk(e,t){for(let r=0,i=e.length;r<i;r++)t.operatorList.fnArray.push(e.fnArray[r]),t.operatorList.argsArray.push(e.argsArray[r]);t.operatorList.lastChunk=e.lastChunk,t.operatorList.separateAnnots=e.separateAnnots;for(let r of t.renderTasks)r.operatorListChanged();e.lastChunk&&this.#n(!0)}_pumpOperatorList({renderingIntent:e,cacheKey:t,annotationStorageSerializable:r,modifiedIds:i}){let{map:s,transfer:o}=r,c=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:e,cacheKey:t,annotationStorage:s,modifiedIds:i},o).getReader(),l=this._intentStates.get(t);l.streamReader=c;let u=()=>{c.read().then(({value:d,done:f})=>{if(f){l.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(d,l),u())},d=>{if(l.streamReader=null,!this._transport.destroyed){if(l.operatorList){l.operatorList.lastChunk=!0;for(let f of l.renderTasks)f.operatorListChanged();this.#n(!0)}if(l.displayReadyCapability)l.displayReadyCapability.reject(d);else if(l.opListReadCapability)l.opListReadCapability.reject(d);else throw d}})};u()}_abortOperatorList({intentState:e,reason:t,force:r=!1}){if(e.streamReader){if(e.streamReaderCancelTimeout&&(clearTimeout(e.streamReaderCancelTimeout),e.streamReaderCancelTimeout=null),!r){if(e.renderTasks.size>0)return;if(t instanceof af){let i=xne;t.extraDelay>0&&t.extraDelay<1e3&&(i+=t.extraDelay),e.streamReaderCancelTimeout=setTimeout(()=>{e.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:e,reason:t,force:!0})},i);return}}if(e.streamReader.cancel(new ys(t.message)).catch(()=>{}),e.streamReader=null,!this._transport.destroyed){for(let[i,s]of this._intentStates)if(s===e){this._intentStates.delete(i);break}this.cleanup()}}}get stats(){return this._stats}},Tx=class{#e=new Map;#t=Promise.resolve();postMessage(e,t){let r={data:structuredClone(e,t?{transfer:t}:null)};this.#t.then(()=>{for(let[i]of this.#e)i.call(this,r)})}addEventListener(e,t,r=null){let i=null;if(r?.signal instanceof AbortSignal){let{signal:s}=r;if(s.aborted){$e("LoopbackPort - cannot use an `aborted` signal.");return}let o=()=>this.removeEventListener(e,t);i=()=>s.removeEventListener("abort",o),s.addEventListener("abort",o)}this.#e.set(t,i)}removeEventListener(e,t){this.#e.get(t)?.(),this.#e.delete(t)}terminate(){for(let[,e]of this.#e)e?.();this.#e.clear()}},xu=class n{static#e=0;static#t=!1;static#n;static{Hn&&(this.#t=!0,Ec.workerSrc||="./pdf.worker.mjs"),this._isSameOrigin=(e,t)=>{let r;try{if(r=new URL(e),!r.origin||r.origin==="null")return!1}catch{return!1}let i=new URL(t,r);return r.origin===i.origin},this._createCDNWrapper=e=>{let t=`await import("${e}");`;return URL.createObjectURL(new Blob([t],{type:"text/javascript"}))}}constructor({name:e=null,port:t=null,verbosity:r=Qte()}={}){if(this.name=e,this.destroyed=!1,this.verbosity=r,this._readyCapability=Promise.withResolvers(),this._port=null,this._webWorker=null,this._messageHandler=null,t){if(n.#n?.has(t))throw new Error("Cannot use more than one PDFWorker per port.");(n.#n||=new WeakMap).set(t,this),this._initializeFromPort(t);return}this._initialize()}get promise(){return this._readyCapability.promise}#r(){this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(e){this._port=e,this._messageHandler=new wc("main","worker",e),this._messageHandler.on("ready",function(){}),this.#r()}_initialize(){if(n.#t||n.#s){this._setupFakeWorker();return}let{workerSrc:e}=n;try{n._isSameOrigin(window.location.href,e)||(e=n._createCDNWrapper(new URL(e,window.location).href));let t=new Worker(e,{type:"module"}),r=new wc("main","worker",t),i=()=>{s.abort(),r.destroy(),t.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},s=new AbortController;t.addEventListener("error",()=>{this._webWorker||i()},{signal:s.signal}),r.on("test",a=>{if(s.abort(),this.destroyed||!a){i();return}this._messageHandler=r,this._port=t,this._webWorker=t,this.#r()}),r.on("ready",a=>
84{if(s.abort(),this.destroyed){i();return}try{o()}catch{this._setupFakeWorker()}});let o=()=>{let a=new Uint8Array;r.send("test",a,[a.buffer])};o();return}catch{B_("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){n.#t||($e("Setting up fake worker."),n.#t=!0),n._setupFakeWorkerGlobal.then(e=>{if(this.destroyed){this._readyCapability.reject(new Error("Worker was destroyed"));return}let t=new Tx;this._port=t;let r=`fake${n.#e++}`,i=new wc(r+"_worker",r,t);e.setup(i,t),this._messageHandler=new wc(r,r+"_worker",t),this.#r()}).catch(e=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${e.message}".`))})}destroy(){this.destroyed=!0,this._webWorker?.terminate(),this._webWorker=null,n.#n?.delete(this._port),this._port=null,this._messageHandler?.destroy(),this._messageHandler=null}static fromPort(e){if(!e?.port)throw new Error("PDFWorker.fromPort - invalid method signature.");let t=this.#n?.get(e.port);if(t){if(t._pendingDestroy)throw new Error("PDFWorker.fromPort - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return t}return new n(e)}static get workerSrc(){if(Ec.workerSrc)return Ec.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get#s(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return Xe(this,"_setupFakeWorkerGlobal",m(this,null,function*(){return this.#s?this.#s:(yield import(this.workerSrc)).WorkerMessageHandler}))}},Ax=class{#e=new Map;#t=new Map;#n=new Map;#r=new Map;#s=null;constructor(e,t,r,i,s){this.messageHandler=e,this.loadingTask=t,this.commonObjs=new C_,this.fontLoader=new WS({ownerDocument:i.ownerDocument,styleElement:i.styleElement}),this.loadingParams=i.loadingParams,this._params=i,this.canvasFactory=s.canvasFactory,this.filterFactory=s.filterFactory,this.cMapReaderFactory=s.cMapReaderFactory,this.standardFontDataFactory=s.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=r,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}#i(e,t=null){let r=this.#e.get(e);if(r)return r;let i=this.messageHandler.sendWithPromise(e,t);return this.#e.set(e,i),i}get annotationStorage(){return Xe(this,"annotationStorage",new uf)}getRenderingIntent(e,t=aa.ENABLE,r=null,i=!1,s=!1){let o=jr.DISPLAY,a=GS;switch(e){case"any":o=jr.ANY;break;case"display":break;case"print":o=jr.PRINT;break;default:$e(`getRenderingIntent - invalid intent: ${e}`)}let c=o&jr.PRINT&&r instanceof g_?r:this.annotationStorage;switch(t){case aa.DISABLE:o+=jr.ANNOTATIONS_DISABLE;break;case aa.ENABLE:break;case aa.ENABLE_FORMS:o+=jr.ANNOTATIONS_FORMS;break;case aa.ENABLE_STORAGE:o+=jr.ANNOTATIONS_STORAGE,a=c.serializable;break;default:$e(`getRenderingIntent - invalid annotationMode: ${t}`)}i&&(o+=jr.IS_EDITING),s&&(o+=jr.OPLIST);let{ids:l,hash:u}=c.modifiedIds,d=[o,a.hash,u];return{renderingIntent:o,cacheKey:d.join("_"),annotationStorageSerializable:a,modifiedIds:l}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#s?.reject(new Error("Worker was destroyed during onPassword callback"));let e=[];for(let r of this.#t.values())e.push(r._destroy());this.#t.clear(),this.#n.clear(),this.#r.clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();let t=this.messageHandler.sendWithPromise("Terminate",null);return e.push(t),Promise.all(e).then(()=>{this.commonObjs.clear(),this.fontLoader.clear(),this.#e.clear(),this.filterFactory.destroy(),hf.cleanup(),this._networkStream?.cancelAllRequests(new ys("Worker was terminated.")),this.messageHandler?.destroy(),this.messageHandler=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){let{messageHandler:e,loadingTask:t}=this;e.on("GetReader",(r,i)=>{rn(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=s=>{this._lastProgress={loaded:s.loaded,total:s.total}},i.onPull=()=>{this._fullReader.read().then(function({value:s,done:o}){if(o){i.close();return}rn(s instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(s),1,[s])}).catch(s=>{i.error(s)})},i.onCancel=s=>{this._fullReader.cancel(s),i.ready.catch(o=>{if(!this.destroyed)throw o})}}),e.on("ReaderHeadersReady",r=>m(this,null,function*(){yield this._fullReader.headersReady;let{isStreamingSupported:i,isRangeSupported:s,contentLength:o}=this._fullReader;return(!i||!s)&&(this._lastProgress&&t.onProgress?.(this._lastProgress),this._fullReader.onProgress=a=>{t.onProgress?.({loaded:a.loaded,total:a.total})}),{isStreamingSupported:i,isRangeSupported:s,contentLength:o}})),e.on("GetRangeReader",(r,i)=>{rn(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");let s=this._networkStream.getRangeReader(r.begin,r.end);if(!s){i.close();return}i.onPull=()=>{s.read().then(function({value:o,done:a}){if(a){i.close();return}rn(o instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(o),1,[o])}).catch(o=>{i.error(o)})},i.onCancel=o=>{s.cancel(o),i.ready.catch(a=>{if(!this.destroyed)throw a})}}),e.on("GetDoc",({pdfInfo:r})=>{this._numPages=r.numPages,this._htmlForXfa=r.htmlForXfa,delete r.htmlForXfa,t._capability.resolve(new Ex(r,this))}),e.on("DocException",r=>{t._capability.reject(vr(r))}),e.on("PasswordRequest",r=>{this.#s=Promise.withResolvers();try{if(!t.onPassword)throw vr(r);let i=s=>{s instanceof Error?this.#s.reject(s):this.#s.resolve({password:s})};t.onPassword(i,r.code)}catch(i){this.#s.reject(i)}return this.#s.promise}),e.on("DataLoaded",r=>{t.onProgress?.({loaded:r.length,total:r.length}),this.downloadInfoCapability.resolve(r)}),e.on("StartRenderPage",r=>{if(this.destroyed)return;this.#t.get(r.pageIndex)._startRenderPage(r.transparency,r.cacheKey)}),e.on("commonobj",([r,i,s])=>{if(this.destroyed||this.commonObjs.has(r))return null;switch(i){case"Font":let{disableFontFace:o,fontExtraProperties:a,pdfBug:c}=this._params;if("error"in s){let f=s.error;$e(`Error during font loading: ${f}`),this.commonObjs.resolve(r,f);break}let l=c&&globalThis.FontInspector?.enabled?(f,p)=>globalThis.FontInspector.fontAdded(f,p):null,u=new KS(s,{disableFontFace:o,fontExtraProperties:a,inspectFont:l});this.fontLoader.bind(u).catch(()=>
84e.sendWithPromise("FontFallback",{id:r})).finally(()=>{!a&&u.data&&(u.data=null),this.commonObjs.resolve(r,u)});break;case"CopyLocalImage":let{imageRef:d}=s;rn(d,"The imageRef must be defined.");for(let f of this.#t.values())for(let[,p]of f.objs)if(p?.ref===d)return p.dataLen?(this.commonObjs.resolve(r,structuredClone(p)),p.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(r,s);break;default:throw new Error(`Got unknown common object type ${i}`)}return null}),e.on("obj",([r,i,s,o])=>{if(this.destroyed)return;let a=this.#t.get(i);if(!a.objs.has(r)){if(a._intentStates.size===0){o?.bitmap?.close();return}switch(s){case"Image":a.objs.resolve(r,o),o?.dataLen>zte&&(a._maybeCleanupAfterRender=!0);break;case"Pattern":a.objs.resolve(r,o);break;default:throw new Error(`Got unknown object type ${s}`)}}}),e.on("DocProgress",r=>{this.destroyed||t.onProgress?.({loaded:r.loaded,total:r.total})}),e.on("FetchBuiltInCMap",r=>m(this,null,function*(){if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.cMapReaderFactory)throw new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter.");return this.cMapReaderFactory.fetch(r)})),e.on("FetchStandardFontData",r=>m(this,null,function*(){if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.standardFontDataFactory)throw new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter.");return this.standardFontDataFactory.fetch(r)}))}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&$e("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");let{map:e,transfer:t}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:e,filename:this._fullReader?.filename??null},t).finally(()=>{this.annotationStorage.resetModified()})}getPage(e){if(!Number.isInteger(e)||e<=0||e>this._numPages)return Promise.reject(new Error("Invalid page request."));let t=e-1,r=this.#n.get(t);if(r)return r;let i=this.messageHandler.sendWithPromise("GetPage",{pageIndex:t}).then(s=>{if(this.destroyed)throw new Error("Transport destroyed");s.refStr&&this.#r.set(s.refStr,e);let o=new Ix(t,s,this,this._params.pdfBug);return this.#t.set(t,o),o});return this.#n.set(t,i),i}getPageIndex(e){return a$(e)?this.messageHandler.sendWithPromise("GetPageIndex",{num:e.num,gen:e.gen}):Promise.reject(new Error("Invalid pageIndex request."))}getAnnotations(e,t){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:e,intent:t})}getFieldObjects(){return this.#i("GetFieldObjects")}hasJSActions(){return this.#i("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(e){return typeof e!="string"?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:e})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getDocJSActions(){return this.#i("GetDocJSActions")}getPageJSActions(e){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:e})}getStructTree(e){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:e})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(e){return this.#i("GetOptionalContentConfig").then(t=>new cx(t,e))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){let e="GetMetadata",t=this.#e.get(e);if(t)return t;
84let r=this.messageHandler.sendWithPromise(e,null).then(i=>({info:i[0],metadata:i[1]?new ox(i[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null}));return this.#e.set(e,r),r}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}startCleanup(e=!1){return m(this,null,function*(){if(!this.destroyed){yield this.messageHandler.sendWithPromise("Cleanup",null);for(let t of this.#t.values())if(!t.cleanup())throw new Error(`startCleanup: Page ${t.pageNumber} is currently rendering.`);this.commonObjs.clear(),e||this.fontLoader.clear(),this.#e.clear(),this.filterFactory.destroy(!0),hf.cleanup()}})}cachedPageNumber(e){if(!a$(e))return null;let t=e.gen===0?`${e.num}R`:`${e.num}R${e.gen}`;return this.#r.get(t)??null}},Jh=Symbol("INITIAL_DATA"),C_=class{#e=Object.create(null);#t(e){return this.#e[e]||=D(_({},Promise.withResolvers()),{data:Jh})}get(e,t=null){if(t){let i=this.#t(e);return i.promise.then(()=>t(i.data)),null}let r=this.#e[e];if(!r||r.data===Jh)throw new Error(`Requesting object that isn't resolved yet ${e}.`);return r.data}has(e){let t=this.#e[e];return!!t&&t.data!==Jh}delete(e){let t=this.#e[e];return!t||t.data===Jh?!1:(delete this.#e[e],!0)}resolve(e,t=null){let r=this.#t(e);r.data=t,r.resolve()}clear(){for(let e in this.#e){let{data:t}=this.#e[e];t?.bitmap?.close()}this.#e=Object.create(null)}*[Symbol.iterator](){for(let e in this.#e){let{data:t}=this.#e[e];t!==Jh&&(yield[e,t])}}},Cx=class{#e=null;constructor(e){this.#e=e,this.onContinue=null}get promise(){return this.#e.capability.promise}cancel(e=0){this.#e.cancel(null,e)}get separateAnnots(){let{separateAnnots:e}=this.#e.operatorList;if(!e)return!1;let{annotationCanvasMap:t}=this.#e;return e.form||e.canvas&&t?.size>0}},Sx=class n{#e=null;static#t=new WeakSet;constructor({callback:e,params:t,objs:r,commonObjs:i,annotationCanvasMap:s,operatorList:o,pageIndex:a,canvasFactory:c,filterFactory:l,useRequestAnimationFrame:u=!1,pdfBug:d=!1,pageColors:f=null}){this.callback=e,this.params=t,this.objs=r,this.commonObjs=i,this.annotationCanvasMap=s,this.operatorListIdx=null,this.operatorList=o,this._pageIndex=a,this.canvasFactory=c,this.filterFactory=l,this._pdfBug=d,this.pageColors=f,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=u===!0&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new Cx(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=t.canvasContext.canvas}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:e=!1,optionalContentConfig:t}){if(this.cancelled)return;if(this._canvas){if(n.#t.has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");n.#t.add(this._canvas)}this._pdfBug&&globalThis.StepperManager?.enabled&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());let{canvasContext:r,viewport:i,transform:s,background:o}=this.params;this.gfx=new Su(r,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:t},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:s,viewport:i,transparency:e,background:o}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}cancel(e=null,t=0){this.running=!1,this.cancelled=!0,this.gfx?.endDrawing(),this.#e&&(window.cancelAnimationFrame(this.#e),this.#e=null),n.#t.delete(this._canvas),this.callback(e||new af(`Rendering cancelled, page ${this._pageIndex+1}`,t))}operatorListChanged(){if(!this.graphicsReady){this.graphicsReadyCallback||=this._continueBound;return}this.stepper?.updateOperatorList(this.operatorList),!this.running&&this._continue()}_continue(){this.running=!0,!this.cancelled&&(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?this.#e=window.requestAnimationFrame(()=>{this.#e=null,this._nextBound().catch(this._cancelBound)}
84):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}_next(){return m(this,null,function*(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),n.#t.delete(this._canvas),this.callback())))})}},Fne="4.10.38",Vne="f9bea397f";function c$(n){return Math.floor(Math.max(0,Math.min(1,n))*255).toString(16).padStart(2,"0")}function ef(n){return Math.max(0,Math.min(255,255*n))}var S_=class{static CMYK_G([e,t,r,i]){return["G",1-Math.min(1,.3*e+.59*r+.11*t+i)]}static G_CMYK([e]){return["CMYK",0,0,0,1-e]}static G_RGB([e]){return["RGB",e,e,e]}static G_rgb([e]){return e=ef(e),[e,e,e]}static G_HTML([e]){let t=c$(e);return`#${t}${t}${t}`}static RGB_G([e,t,r]){return["G",.3*e+.59*t+.11*r]}static RGB_rgb(e){return e.map(ef)}static RGB_HTML(e){return`#${e.map(c$).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([e,t,r,i]){return["RGB",1-Math.min(1,e+i),1-Math.min(1,r+i),1-Math.min(1,t+i)]}static CMYK_rgb([e,t,r,i]){return[ef(1-Math.min(1,e+i)),ef(1-Math.min(1,r+i)),ef(1-Math.min(1,t+i))]}static CMYK_HTML(e){let t=this.CMYK_RGB(e).slice(1);return this.RGB_HTML(t)}static RGB_CMYK([e,t,r]){let i=1-e,s=1-t,o=1-r,a=Math.min(i,s,o);return["CMYK",i,s,o,a]}},xx=class{create(e,t,r=!1){if(e<=0||t<=0)throw new Error("Invalid SVG dimensions");let i=this._createSVG("svg:svg");return i.setAttribute("version","1.1"),r||(i.setAttribute("width",`${e}px`),i.setAttribute("height",`${t}px`)),i.setAttribute("preserveAspectRatio","none"),i.setAttribute("viewBox",`0 0 ${e} ${t}`),i}createElement(e){if(typeof e!="string")throw new Error("Invalid SVG element type");return this._createSVG(e)}_createSVG(e){Ct("Abstract method `_createSVG` called.")}},pf=class extends xx{_createSVG(e){return document.createElementNS(ho,e)}},x_=class{static setupStorage(e,t,r,i,s){let o=i.getValue(t,{value:null});switch(r.name){case"textarea":if(o.value!==null&&(e.textContent=o.value),s==="print")break;e.addEventListener("input",a=>{i.setValue(t,{value:a.target.value})});break;case"input":if(r.attributes.type==="radio"||r.attributes.type==="checkbox"){if(o.value===r.attributes.xfaOn?e.setAttribute("checked",!0):o.value===r.attributes.xfaOff&&e.removeAttribute("checked"),s==="print")break;e.addEventListener("change",a=>{i.setValue(t,{value:a.target.checked?a.target.getAttribute("xfaOn"):a.target.getAttribute("xfaOff")})})}else{if(o.value!==null&&e.setAttribute("value",o.value),s==="print")break;e.addEventListener("input",a=>{i.setValue(t,{value:a.target.value})})}break;case"select":if(o.value!==null){e.setAttribute("value",o.value);for(let a of r.children)a.attributes.value===o.value?a.attributes.selected=!0:a.attributes.hasOwnProperty("selected")&&delete a.attributes.selected}e.addEventListener("input",a=>{let c=a.target.options,l=c.selectedIndex===-1?"":c[c.selectedIndex].value;i.setValue(t,{value:l})});break}}static setAttributes({html:e,element:t,storage:r=null,intent:i,linkService:s}){let{attributes:o}=t,a=e instanceof HTMLAnchorElement;o.type==="radio"&&(o.name=`${o.name}-${i}`);for(let[c,l]of Object.entries(o))if(l!=null)switch(c){case"class":l.length&&e.setAttribute(c,l.join(" "));break;case"dataId":break;case"id":e.setAttribute("data-element-id",l);break;case"style":Object.assign(e.style,l);break;case"textContent":e.textContent=l;break;default:(!a||c!=="href"&&c!=="newWindow")&&e.setAttribute(c,l)}a&&s.addLinkAttributes(e,o.href,o.newWindow),r&&o.dataId&&this.setupStorage(e,o.dataId,t,r)}static render(e){let t=e.annotationStorage,r=e.linkService,i=e.xfaHtml,s=e.intent||"display",o=document.createElement(i.name);i.attributes&&this.setAttributes({html:o,element:i,intent:s,linkService:r});let a=s!=="richText",c=e.div;if(c.append(o),e.viewport){let d=`matrix(${e.viewport.transform.join(",")})`;c.style.transform=d}a&&c.setAttribute("class","xfaLayer xfaFont");let l=[];if(i.children.length===0){if(i.value){let d=document.createTextNode(i.value);o.append(d),a&&ff.shouldBuildText(i.name)&&l.push(d)}return{textDivs:l}}let u=[[i,-1,o]];for(;u.length>0;){let[d,f,p]=u.at(-1);if(f+1===d.children.length){u.pop();continue}let y=d.children[++u.at(-1)[1]];if(y===null)continue;let{name:v}=y;if(v==="#text"){let E=document.createTextNode(y.value);l.push(E),p.append(E);continue}let w=y?.attributes?.xmlns?document.createElementNS(y.attributes.xmlns,v):document.createElement(v);
84if(p.append(w),y.attributes&&this.setAttributes({html:w,element:y,storage:t,intent:s,linkService:r}),y.children?.length>0)u.push([y,-1,w]);else if(y.value){let E=document.createTextNode(y.value);a&&ff.shouldBuildText(v)&&l.push(E),w.append(E)}}for(let d of c.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))d.setAttribute("readOnly",!0);return{textDivs:l}}static update(e){let t=`matrix(${e.viewport.transform.join(",")})`;e.div.style.transform=t,e.div.hidden=!1}},vf=1e3,jne=9,Cc=new WeakSet;function ca(n){return{width:n[2]-n[0],height:n[3]-n[1]}}var Dx=class{static create(e){switch(e.data.annotationType){case ln.LINK:return new D_(e);case ln.TEXT:return new Rx(e);case ln.WIDGET:switch(e.data.fieldType){case"Tx":return new kx(e);case"Btn":return e.data.radioButton?new R_(e):e.data.checkBox?new Mx(e):new Nx(e);case"Ch":return new Ox(e);case"Sig":return new Px(e)}return new fo(e);case ln.POPUP:return new mf(e);case ln.FREETEXT:return new k_(e);case ln.LINE:return new Fx(e);case ln.SQUARE:return new Vx(e);case ln.CIRCLE:return new jx(e);case ln.POLYLINE:return new P_(e);case ln.CARET:return new Ux(e);case ln.INK:return new gf(e);case ln.POLYGON:return new $x(e);case ln.HIGHLIGHT:return new M_(e);case ln.UNDERLINE:return new Bx(e);case ln.SQUIGGLY:return new Hx(e);case ln.STRIKEOUT:return new qx(e);case ln.STAMP:return new N_(e);case ln.FILEATTACHMENT:return new zx(e);default:return new Kt(e)}}},Kt=class n{#e=null;#t=!1;#n=null;constructor(e,{isRenderable:t=!1,ignoreBorder:r=!1,createQuadrilaterals:i=!1}={}){this.isRenderable=t,this.data=e.data,this.layer=e.layer,this.linkService=e.linkService,this.downloadManager=e.downloadManager,this.imageResourcesPath=e.imageResourcesPath,this.renderForms=e.renderForms,this.svgFactory=e.svgFactory,this.annotationStorage=e.annotationStorage,this.enableScripting=e.enableScripting,this.hasJSActions=e.hasJSActions,this._fieldObjects=e.fieldObjects,this.parent=e.parent,t&&(this.container=this._createContainer(r)),i&&this._createQuadrilaterals()}static _hasPopupData({titleObj:e,contentsObj:t,richText:r}){return!!(e?.str||t?.str||r?.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return n._hasPopupData(this.data)}updateEdited(e){if(!this.container)return;this.#e||={rect:this.data.rect.slice(0)};let{rect:t}=e;t&&this.#r(t),this.#n?.popup.updateEdited(e)}resetEdited(){this.#e&&(this.#r(this.#e.rect),this.#n?.popup.resetEdited(),this.#e=null)}#r(e){let{container:{style:t},data:{rect:r,rotation:i},parent:{viewport:{rawDims:{pageWidth:s,pageHeight:o,pageX:a,pageY:c}}}}=this;r?.splice(0,4,...e);let{width:l,height:u}=ca(e);t.left=`${100*(e[0]-a)/s}%`,t.top=`${100*(o-e[3]+c)/o}%`,i===0?(t.width=`${100*l/s}%`,t.height=`${100*u/o}%`):this.setRotation(i)}_createContainer(e){let{data:t,parent:{page:r,viewport:i}}=this,s=document.createElement("section");s.setAttribute("data-annotation-id",t.id),this instanceof fo||(s.tabIndex=vf);let{style:o}=s;if(o.zIndex=this.parent.zIndex++,t.alternativeText&&(s.title=t.alternativeText),t.noRotate&&s.classList.add("norotate"),!t.rect||this instanceof mf){let{rotation:v}=t;return!t.hasOwnCanvas&&v!==0&&this.setRotation(v,s),s}let{width:a,height:c}=ca(t.rect);if(!e&&t.borderStyle.width>0){o.borderWidth=`${t.borderStyle.width}px`;let v=t.borderStyle.horizontalCornerRadius,w=t.borderStyle.verticalCornerRadius;if(v>0||w>0){let A=`calc(${v}px * var(--scale-factor)) / calc(${w}px * var(--scale-factor))`;o.borderRadius=A}else if(this instanceof R_){let A=`calc(${a}px * var(--scale-factor)) / calc(${c}px * var(--scale-factor))`;o.borderRadius=A}switch(t.borderStyle.style){case Qh.SOLID:o.borderStyle="solid";break;case Qh.DASHED:o.borderStyle="dashed";break;case Qh.BEVELED:$e("Unimplemented border style: beveled");break;case Qh.INSET:$e("Unimplemented border style: inset");break;case Qh.UNDERLINE:o.borderBottomStyle="solid";break;default:break}let E=t.borderColor||null;E?(this.#t=!0,o.borderColor=pe.makeHexColor(E[0]|0,E[1]|0,E[2]|0)):o.borderWidth=0}let l=pe.normalizeRect([t.rect[0],r.view[3]-t.rect[1]+r.view[1],t.rect[2],r.view[3]-t.rect[3]+r.view[1]]),{pageWidth:u,pageHeight:d,pageX:f,pageY:p}=i.rawDims;o.left=`${100*(l[0]-f)/u}%`,o.top=`${100*(l[1]-p)/d}%`;let{rotation:y}=t;return t.hasOwnCanvas||y===0?(o.width=`${100*a/u}%`,o.height=`${100*c/d}%`):this.setRotation(y,s),s}setRotation(e,t=this.container){if(!this.data.rect)return;let{pageWidth:r,pageHeight:i}=this.parent.viewport.rawDims,{width:s,height:o}=ca(this.data.rect),a,c;e%180===0?(a=100*s/r,c=100*o/i):(a=100*o/r,c=100*s/i),t.style.width=`${a}%`,t.style.height=`${c}%`,t.setAttribute("data-main-rotation",(360-e)%360)}get _commonActions(){let e=(t,r,i)=>{let s=i.detail[t],o=s[0],a=s.slice(1);i.target.style[r]=S_[`${o}_HTML`](a),this.annotationStorage.setValue(this.data.id,{[r]:S_[`${o}_rgb`](a)})};return Xe(this,"_commonActions",{display:t=>{let{display:r}=t.detail,i=r%2===1;this.container.style.visibility=i?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:i,noPrint:r===1||r===2})},print:t=>{this.annotationStorage.setValue(this.data.id,{noPrint:!t.detail.print})},hidden:t=>{let{hidden:r}=t.detail;this.container.style.visibility=r?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:r,noView:r})},focus:t=>{setTimeout(()=>
84t.target.focus({preventScroll:!1}),0)},userName:t=>{t.target.title=t.detail.userName},readonly:t=>{t.target.disabled=t.detail.readonly},required:t=>{this._setRequired(t.target,t.detail.required)},bgColor:t=>{e("bgColor","backgroundColor",t)},fillColor:t=>{e("fillColor","backgroundColor",t)},fgColor:t=>{e("fgColor","color",t)},textColor:t=>{e("textColor","color",t)},borderColor:t=>{e("borderColor","borderColor",t)},strokeColor:t=>{e("strokeColor","borderColor",t)},rotation:t=>{let r=t.detail.rotation;this.setRotation(r),this.annotationStorage.setValue(this.data.id,{rotation:r})}})}_dispatchEventFromSandbox(e,t){let r=this._commonActions;for(let i of Object.keys(t.detail))(e[i]||r[i])?.(t)}_setDefaultPropertiesFromJS(e){if(!this.enableScripting)return;let t=this.annotationStorage.getRawValue(this.data.id);if(!t)return;let r=this._commonActions;for(let[i,s]of Object.entries(t)){let o=r[i];if(o){let a={detail:{[i]:s},target:e};o(a),delete t[i]}}}_createQuadrilaterals(){if(!this.container)return;let{quadPoints:e}=this.data;if(!e)return;let[t,r,i,s]=this.data.rect.map(v=>Math.fround(v));if(e.length===8){let[v,w,E,A]=e.subarray(2,6);if(i===v&&s===w&&t===E&&r===A)return}let{style:o}=this.container,a;if(this.#t){let{borderColor:v,borderWidth:w}=o;o.borderWidth=0,a=["url('data:image/svg+xml;utf8,",'<svg xmlns="http://www.w3.org/2000/svg"',' preserveAspectRatio="none" viewBox="0 0 1 1">',`<g fill="transparent" stroke="${v}" stroke-width="${w}">`],this.container.classList.add("hasBorder")}let c=i-t,l=s-r,{svgFactory:u}=this,d=u.createElement("svg");d.classList.add("quadrilateralsContainer"),d.setAttribute("width",0),d.setAttribute("height",0);let f=u.createElement("defs");d.append(f);let p=u.createElement("clipPath"),y=`clippath_${this.data.id}`;p.setAttribute("id",y),p.setAttribute("clipPathUnits","objectBoundingBox"),f.append(p);for(let v=2,w=e.length;v<w;v+=8){let E=e[v],A=e[v+1],x=e[v+2],M=e[v+3],O=u.createElement("rect"),$=(x-t)/c,C=(s-A)/l,T=(E-x)/c,S=(A-M)/l;O.setAttribute("x",$),O.setAttribute("y",C),O.setAttribute("width",T),O.setAttribute("height",S),p.append(O),a?.push(`<rect vector-effect="non-scaling-stroke" x="${$}" y="${C}" width="${T}" height="${S}"/>`)}this.#t&&(a.push("</g></svg>')"),o.backgroundImage=a.join("")),this.container.append(d),this.container.style.clipPath=`url(#${y})`}_createPopup(){let{data:e}=this,t=this.#n=new mf({data:{color:e.color,titleObj:e.titleObj,modificationDate:e.modificationDate,contentsObj:e.contentsObj,richText:e.richText,parentRect:e.rect,borderStyle:0,id:`popup_${e.id}`,rotation:e.rotation},parent:this.parent,elements:[this]});this.parent.div.append(t.render())}render(){Ct("Abstract method `AnnotationElement.render` called")}_getElementsByName(e,t=null){let r=[];if(this._fieldObjects){let i=this._fieldObjects[e];if(i)for(let{page:s,id:o,exportValues:a}of i){if(s===-1||o===t)continue;let c=typeof a=="string"?a:null,l=document.querySelector(`[data-element-id="${o}"]`);if(l&&!Cc.has(l)){$e(`_getElementsByName - element not allowed: ${o}`);continue}r.push({id:o,exportValue:c,domElement:l})}return r}for(let i of document.getElementsByName(e)){let{exportValue:s}=i,o=i.getAttribute("data-element-id");o!==t&&Cc.has(i)&&r.push({id:o,exportValue:s,domElement:i})}return r}show(){this.container&&(this.container.hidden=!1),this.popup?.maybeShow()}hide(){this.container&&(this.container.hidden=!0),this.popup?.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){let e=this.getElementsToTriggerPopup();if(Array.isArray(e))for(let t of e)t.classList.add("highlightArea");else e.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;let{annotationEditorType:e,data:{id:t}}=this;this.container.addEventListener("dblclick",()=>{this.linkService.eventBus?.dispatch("switchannotationeditormode",{source:this,mode:e,editId:t})})}},D_=class extends Kt{constructor(e,t=null){super(e,{isRenderable:!0,ignoreBorder:!!t?.ignoreBorder,createQuadrilaterals:!0}),this.isTooltipOnly=e.data.isTooltipOnly}render(){let{data:e,linkService:t}=this,r=document.createElement("a");r.setAttribute("data-element-id",e.id);let i=!1;return e.url?(t.addLinkAttributes(r,e.url,e.newWindow),i=!0):e.action?(this._bindNamedAction(r,e.action),i=!0):e.attachment?(this.#t(r,e.attachment,e.attachmentDest),i=!0):e.setOCGState?(this.#n(r,e.
84setOCGState),i=!0):e.dest?(this._bindLink(r,e.dest),i=!0):(e.actions&&(e.actions.Action||e.actions["Mouse Up"]||e.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(r,e),i=!0),e.resetForm?(this._bindResetFormAction(r,e.resetForm),i=!0):this.isTooltipOnly&&!i&&(this._bindLink(r,""),i=!0)),this.container.classList.add("linkAnnotation"),i&&this.container.append(r),this.container}#e(){this.container.setAttribute("data-internal-link","")}_bindLink(e,t){e.href=this.linkService.getDestinationHash(t),e.onclick=()=>(t&&this.linkService.goToDestination(t),!1),(t||t==="")&&this.#e()}_bindNamedAction(e,t){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeNamedAction(t),!1),this.#e()}#t(e,t,r=null){e.href=this.linkService.getAnchorUrl(""),t.description&&(e.title=t.description),e.onclick=()=>(this.downloadManager?.openOrDownloadData(t.content,t.filename,r),!1),this.#e()}#n(e,t){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeSetOCGState(t),!1),this.#e()}_bindJSAction(e,t){e.href=this.linkService.getAnchorUrl("");let r=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(let i of Object.keys(t.actions)){let s=r.get(i);s&&(e[s]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t.id,name:i}}),!1))}e.onclick||(e.onclick=()=>!1),this.#e()}_bindResetFormAction(e,t){let r=e.onclick;if(r||(e.href=this.linkService.getAnchorUrl("")),this.#e(),!this._fieldObjects){$e('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),r||(e.onclick=()=>!1);return}e.onclick=()=>{r?.();let{fields:i,refs:s,include:o}=t,a=[];if(i.length!==0||s.length!==0){let u=new Set(s);for(let d of i){let f=this._fieldObjects[d]||[];for(let{id:p}of f)u.add(p)}for(let d of Object.values(this._fieldObjects))for(let f of d)u.has(f.id)===o&&a.push(f)}else for(let u of Object.values(this._fieldObjects))a.push(...u);let c=this.annotationStorage,l=[];for(let u of a){let{id:d}=u;switch(l.push(d),u.type){case"text":{let p=u.defaultValue||"";c.setValue(d,{value:p});break}case"checkbox":case"radiobutton":{let p=u.defaultValue===u.exportValues;c.setValue(d,{value:p});break}case"combobox":case"listbox":{let p=u.defaultValue||"";c.setValue(d,{value:p});break}default:continue}let f=document.querySelector(`[data-element-id="${d}"]`);if(f){if(!Cc.has(f)){$e(`_bindResetFormAction - element not allowed: ${d}`);continue}}else continue;f.dispatchEvent(new Event("resetform"))}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:l,name:"ResetForm"}}),!1}}},Rx=class extends Kt{constructor(e){super(e,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");let e=document.createElement("img");return e.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",e.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),e.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.append(e),this.container}},fo=class extends Kt{render(){return this.container}showElementAndHideCanvas(e){this.data.hasOwnCanvas&&(e.previousSibling?.nodeName==="CANVAS"&&(e.previousSibling.hidden=!0),e.hidden=!1)}_getKeyModifier(e){return Cn.platform.isMac?e.metaKey:e.ctrlKey}_setEventListener(e,t,r,i,s){r.includes("mouse")?e.addEventListener(r,o=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:s(o),shift:o.shiftKey,modifier:this._getKeyModifier(o)}})}):e.addEventListener(r,o=>{if(r==="blur"){if(!t.focused||!o.relatedTarget)return;t.focused=!1}else if(r==="focus"){if(t.focused)return;t.focused=!0}s&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:s(o)}})})}_setEventListeners(e,t,r,i){for(let[s,o]of r)(o==="Action"||this.data.actions?.[o])&&((o==="Focus"||o==="Blur")&&(t||={focused:!1}),this._setEventListener(e,t,s,o,i),o==="Focus"&&!this.data.actions?.Blur?this._setEventListener(e,t,"blur","Blur",null):o==="Blur"&&!this.data.actions?.Focus&&this._setEventListener(e,t,"focus","Focus",null))}
84_setBackgroundColor(e){let t=this.data.backgroundColor||null;e.style.backgroundColor=t===null?"transparent":pe.makeHexColor(t[0],t[1],t[2])}_setTextStyle(e){let t=["left","center","right"],{fontColor:r}=this.data.defaultAppearanceData,i=this.data.defaultAppearanceData.fontSize||jne,s=e.style,o,a=2,c=l=>Math.round(10*l)/10;if(this.data.multiLine){let l=Math.abs(this.data.rect[3]-this.data.rect[1]-a),u=Math.round(l/(c_*i))||1,d=l/u;o=Math.min(i,c(d/c_))}else{let l=Math.abs(this.data.rect[3]-this.data.rect[1]-a);o=Math.min(i,c(l/c_))}s.fontSize=`calc(${o}px * var(--scale-factor))`,s.color=pe.makeHexColor(r[0],r[1],r[2]),this.data.textAlignment!==null&&(s.textAlign=t[this.data.textAlignment])}_setRequired(e,t){t?e.setAttribute("required",!0):e.removeAttribute("required"),e.setAttribute("aria-required",t)}},kx=class extends fo{constructor(e){let t=e.renderForms||e.data.hasOwnCanvas||!e.data.hasAppearance&&!!e.data.fieldValue;super(e,{isRenderable:t})}setPropertyOnSiblings(e,t,r,i){let s=this.annotationStorage;for(let o of this._getElementsByName(e.name,e.id))o.domElement&&(o.domElement[t]=r),s.setValue(o.id,{[i]:r})}render(){let e=this.annotationStorage,t=this.data.id;this.container.classList.add("textWidgetAnnotation");let r=null;if(this.renderForms){let i=e.getValue(t,{value:this.data.fieldValue}),s=i.value||"",o=e.getValue(t,{charLimit:this.data.maxLen}).charLimit;o&&s.length>o&&(s=s.slice(0,o));let a=i.formattedValue||this.data.textContent?.join(` 85`)||null;a&&this.data.comb&&(a=a.replaceAll(/\s+/g,""));let c={userValue:s,formattedValue:a,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(r=document.createElement("textarea"),r.textContent=a??s,this.data.doNotScroll&&(r.style.overflowY="hidden")):(r=document.createElement("input"),r.type="text",r.setAttribute("value",a??s),this.data.doNotScroll&&(r.style.overflowX="hidden")),this.data.hasOwnCanvas&&(r.hidden=!0),Cc.add(r),r.setAttribute("data-element-id",t),r.disabled=this.data.readOnly,r.name=this.data.fieldName,r.tabIndex=vf,this._setRequired(r,this.data.required),o&&(r.maxLength=o),r.addEventListener("input",u=>{e.setValue(t,{value:u.target.value}),this.setPropertyOnSiblings(r,"value",u.target.value,"value"),c.formattedValue=null}),r.addEventListener("resetform",u=>{let d=this.data.defaultFieldValue??"";r.value=c.userValue=d,c.formattedValue=null});let l=u=>{let{formattedValue:d}=c;d!=null&&(u.target.value=d),u.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){r.addEventListener("focus",d=>{if(c.focused)return;let{target:f}=d;c.userValue&&(f.value=c.userValue),c.lastCommittedValue=f.value,c.commitKey=1,this.data.actions?.Focus||(c.focused=!0)}),r.addEventListener("updatefromsandbox",d=>{this.showElementAndHideCanvas(d.target);let f={value(p){c.userValue=p.detail.value??"",e.setValue(t,{value:c.userValue.toString()}),p.target.value=c.userValue},formattedValue(p){let{formattedValue:y}=p.detail;c.formattedValue=y,y!=null&&p.target!==document.activeElement&&(p.target.value=y),e.setValue(t,{formattedValue:y})},selRange(p){p.target.setSelectionRange(...p.detail.selRange)},charLimit:p=>{let{charLimit:y}=p.detail,{target:v}=p;if(y===0){v.removeAttribute("maxLength");return}v.setAttribute("maxLength",y);let w=c.userValue;!w||w.length<=y||(w=w.slice(0,y),v.value=c.userValue=w,e.setValue(t,{value:w}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:w,willCommit:!0,commitKey:1,selStart:v.selectionStart,selEnd:v.selectionEnd}}))}};this._dispatchEventFromSandbox(f,d)}),r.addEventListener("keydown",d=>{c.commitKey=1;let f=-1;if(d.key==="Escape"?f=0:d.key==="Enter"&&!this.data.multiLine?f=2:d.key==="Tab"&&(c.commitKey=3),f===-1)return;let{value:p}=d.target;c.lastCommittedValue!==p&&(c.lastCommittedValue=p,c.userValue=p,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:p,willCommit:!0,commitKey:f,selStart:d.target.selectionStart,selEnd:d.target.selectionEnd}}))});let u=l;l=null,r.addEventListener("blur",d=>{if(!c.focused||!d.relatedTarget)return;this.data.actions?.Blur||(c.focused=!1);let{value:f}=d.target;c.userValue=f,c.lastCommittedValue!==f&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:f,willCommit:!0,
85commitKey:c.commitKey,selStart:d.target.selectionStart,selEnd:d.target.selectionEnd}}),u(d)}),this.data.actions?.Keystroke&&r.addEventListener("beforeinput",d=>{c.lastCommittedValue=null;let{data:f,target:p}=d,{value:y,selectionStart:v,selectionEnd:w}=p,E=v,A=w;switch(d.inputType){case"deleteWordBackward":{let x=y.substring(0,v).match(/\w*[^\w]*$/);x&&(E-=x[0].length);break}case"deleteWordForward":{let x=y.substring(v).match(/^[^\w]*\w*/);x&&(A+=x[0].length);break}case"deleteContentBackward":v===w&&(E-=1);break;case"deleteContentForward":v===w&&(A+=1);break}d.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:y,change:f||"",willCommit:!1,selStart:E,selEnd:A}})}),this._setEventListeners(r,c,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],d=>d.target.value)}if(l&&r.addEventListener("blur",l),this.data.comb){let d=(this.data.rect[2]-this.data.rect[0])/o;r.classList.add("comb"),r.style.letterSpacing=`calc(${d}px * var(--scale-factor) - 1ch)`}}else r=document.createElement("div"),r.textContent=this.data.fieldValue,r.style.verticalAlign="middle",r.style.display="table-cell",this.data.hasOwnCanvas&&(r.hidden=!0);return this._setTextStyle(r),this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}},Px=class extends fo{constructor(e){super(e,{isRenderable:!!e.data.hasOwnCanvas})}},Mx=class extends fo{constructor(e){super(e,{isRenderable:e.renderForms})}render(){let e=this.annotationStorage,t=this.data,r=t.id,i=e.getValue(r,{value:t.exportValue===t.fieldValue}).value;typeof i=="string"&&(i=i!=="Off",e.setValue(r,{value:i})),this.container.classList.add("buttonWidgetAnnotation","checkBox");let s=document.createElement("input");return Cc.add(s),s.setAttribute("data-element-id",r),s.disabled=t.readOnly,this._setRequired(s,this.data.required),s.type="checkbox",s.name=t.fieldName,i&&s.setAttribute("checked",!0),s.setAttribute("exportValue",t.exportValue),s.tabIndex=vf,s.addEventListener("change",o=>{let{name:a,checked:c}=o.target;for(let l of this._getElementsByName(a,r)){let u=c&&l.exportValue===t.exportValue;l.domElement&&(l.domElement.checked=u),e.setValue(l.id,{value:u})}e.setValue(r,{value:c})}),s.addEventListener("resetform",o=>{let a=t.defaultFieldValue||"Off";o.target.checked=a===t.exportValue}),this.enableScripting&&this.hasJSActions&&(s.addEventListener("updatefromsandbox",o=>{let a={value(c){c.target.checked=c.detail.value!=="Off",e.setValue(r,{value:c.target.checked})}};this._dispatchEventFromSandbox(a,o)}),this._setEventListeners(s,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],o=>o.target.checked)),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}},R_=class extends fo{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");let e=this.annotationStorage,t=this.data,r=t.id,i=e.getValue(r,{value:t.fieldValue===t.buttonValue}).value;if(typeof i=="string"&&(i=i!==t.buttonValue,e.setValue(r,{value:i})),i)for(let o of this._getElementsByName(t.fieldName,r))e.setValue(o.id,{value:!1});let s=document.createElement("input");if(Cc.add(s),s.setAttribute("data-element-id",r),s.disabled=t.readOnly,this._setRequired(s,this.data.required),s.type="radio",s.name=t.fieldName,i&&s.setAttribute("checked",!0),s.tabIndex=vf,s.addEventListener("change",o=>{let{name:a,checked:c}=o.target;for(let l of this._getElementsByName(a,r))e.setValue(l.id,{value:!1});e.setValue(r,{value:c})}),s.addEventListener("resetform",o=>{let a=t.defaultFieldValue;o.target.checked=a!=null&&a===t.buttonValue}),this.enableScripting&&this.hasJSActions){let o=t.buttonValue;s.addEventListener("updatefromsandbox",a=>{let c={value:l=>{let u=o===l.detail.value;for(let d of this._getElementsByName(l.target.name)){let f=u&&d.id===r;d.domElement&&(d.domElement.checked=f),e.setValue(d.id,{value:f})}}};this._dispatchEventFromSandbox(c,a)}),this._setEventListeners(s,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],a=>a.target.checked)}
85return this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}},Nx=class extends D_{constructor(e){super(e,{ignoreBorder:e.data.hasAppearance})}render(){let e=super.render();e.classList.add("buttonWidgetAnnotation","pushButton");let t=e.lastChild;return this.enableScripting&&this.hasJSActions&&t&&(this._setDefaultPropertiesFromJS(t),t.addEventListener("updatefromsandbox",r=>{this._dispatchEventFromSandbox({},r)})),e}},Ox=class extends fo{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");let e=this.annotationStorage,t=this.data.id,r=e.getValue(t,{value:this.data.fieldValue}),i=document.createElement("select");Cc.add(i),i.setAttribute("data-element-id",t),i.disabled=this.data.readOnly,this._setRequired(i,this.data.required),i.name=this.data.fieldName,i.tabIndex=vf;let s=this.data.combo&&this.data.options.length>0;this.data.combo||(i.size=this.data.options.length,this.data.multiSelect&&(i.multiple=!0)),i.addEventListener("resetform",u=>{let d=this.data.defaultFieldValue;for(let f of i.options)f.selected=f.value===d});for(let u of this.data.options){let d=document.createElement("option");d.textContent=u.displayValue,d.value=u.exportValue,r.value.includes(u.exportValue)&&(d.setAttribute("selected",!0),s=!1),i.append(d)}let o=null;if(s){let u=document.createElement("option");u.value=" ",u.setAttribute("hidden",!0),u.setAttribute("selected",!0),i.prepend(u),o=()=>{u.remove(),i.removeEventListener("input",o),o=null},i.addEventListener("input",o)}let a=u=>{let d=u?"value":"textContent",{options:f,multiple:p}=i;return p?Array.prototype.filter.call(f,y=>y.selected).map(y=>y[d]):f.selectedIndex===-1?null:f[f.selectedIndex][d]},c=a(!1),l=u=>{let d=u.target.options;return Array.prototype.map.call(d,f=>({displayValue:f.textContent,exportValue:f.value}))};return this.enableScripting&&this.hasJSActions?(i.addEventListener("updatefromsandbox",u=>{let d={value(f){o?.();let p=f.detail.value,y=new Set(Array.isArray(p)?p:[p]);for(let v of i.options)v.selected=y.has(v.value);e.setValue(t,{value:a(!0)}),c=a(!1)},multipleSelection(f){i.multiple=!0},remove(f){let p=i.options,y=f.detail.remove;p[y].selected=!1,i.remove(y),p.length>0&&Array.prototype.findIndex.call(p,w=>w.selected)===-1&&(p[0].selected=!0),e.setValue(t,{value:a(!0),items:l(f)}),c=a(!1)},clear(f){for(;i.length!==0;)i.remove(0);e.setValue(t,{value:null,items:[]}),c=a(!1)},insert(f){let{index:p,displayValue:y,exportValue:v}=f.detail.insert,w=i.children[p],E=document.createElement("option");E.textContent=y,E.value=v,w?w.before(E):i.append(E),e.setValue(t,{value:a(!0),items:l(f)}),c=a(!1)},items(f){let{items:p}=f.detail;for(;i.length!==0;)i.remove(0);for(let y of p){let{displayValue:v,exportValue:w}=y,E=document.createElement("option");E.textContent=v,E.value=w,i.append(E)}i.options.length>0&&(i.options[0].selected=!0),e.setValue(t,{value:a(!0),items:l(f)}),c=a(!1)},indices(f){let p=new Set(f.detail.indices);for(let y of f.target.options)y.selected=p.has(y.index);e.setValue(t,{value:a(!0)}),c=a(!1)},editable(f){f.target.disabled=!f.detail.editable}};this._dispatchEventFromSandbox(d,u)}),i.addEventListener("input",u=>{let d=a(!0),f=a(!1);e.setValue(t,{value:d}),u.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:c,change:f,changeEx:d,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(i,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],u=>u.target.value)):i.addEventListener("input",function(u){e.setValue(t,{value:a(!0)})}),this.data.combo&&this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}},mf=class extends Kt{constructor(e){let{data:t,elements:r}=e;super(e,{isRenderable:Kt._hasPopupData(t)}),this.elements=r,this.popup=null}render(){this.container.classList.add("popupAnnotation");let e=this.popup=new Lx({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open}),t=[];for(let r of this.elements)r.popup=e,r.container.ariaHasPopup="dialog",t.push(r.data.id),r.addHighlightArea();return this.container.setAttribute("aria-controls",t.map(r=>`${rD}${r}`).join(",")),this.container}}
85,Lx=class{#e=this.#S.bind(this);#t=this.#C.bind(this);#n=this.#x.bind(this);#r=this.#E.bind(this);#s=null;#i=null;#c=null;#a=null;#u=null;#l=null;#h=null;#d=!1;#f=null;#o=null;#p=null;#g=null;#m=null;#y=null;#b=!1;constructor({container:e,color:t,elements:r,titleObj:i,modificationDate:s,contentsObj:o,richText:a,parent:c,rect:l,parentRect:u,open:d}){this.#i=e,this.#m=i,this.#c=o,this.#g=a,this.#l=c,this.#s=t,this.#p=l,this.#h=u,this.#u=r,this.#a=h_.toDateObject(s),this.trigger=r.flatMap(f=>f.getElementsToTriggerPopup());for(let f of this.trigger)f.addEventListener("click",this.#r),f.addEventListener("mouseenter",this.#n),f.addEventListener("mouseleave",this.#t),f.classList.add("popupTriggerArea");for(let f of r)f.container?.addEventListener("keydown",this.#e);this.#i.hidden=!0,d&&this.#E()}render(){if(this.#f)return;let e=this.#f=document.createElement("div");if(e.className="popup",this.#s){let s=e.style.outlineColor=pe.makeHexColor(...this.#s);CSS.supports("background-color","color-mix(in srgb, red 30%, white)")?e.style.backgroundColor=`color-mix(in srgb, ${s} 30%, white)`:e.style.backgroundColor=pe.makeHexColor(...this.#s.map(a=>Math.floor(.7*(255-a)+a)))}let t=document.createElement("span");t.className="header";let r=document.createElement("h1");if(t.append(r),{dir:r.dir,str:r.textContent}=this.#m,e.append(t),this.#a){let s=document.createElement("span");s.classList.add("popupDate"),s.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),s.setAttribute("data-l10n-args",JSON.stringify({dateObj:this.#a.valueOf()})),t.append(s)}let i=this.#_;if(i)x_.render({xfaHtml:i,intent:"richText",div:e}),e.lastChild.classList.add("richText","popupContent");else{let s=this._formatContents(this.#c);e.append(s)}this.#i.append(e)}get#_(){let e=this.#g,t=this.#c;return e?.str&&(!t?.str||t.str===e.str)&&this.#g.html||null}get#w(){return this.#_?.attributes?.style?.fontSize||0}get#I(){return this.#_?.attributes?.style?.color||null}#A(e){let t=[],r={str:e,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:t}]}},i={style:{color:this.#I,fontSize:this.#w?`calc(${this.#w}px * var(--scale-factor))`:""}};for(let s of e.split(` 86`))t.push({name:"span",value:s,attributes:i});return r}_formatContents({str:e,dir:t}){let r=document.createElement("p");r.classList.add("popupContent"),r.dir=t;let i=e.split(/(?:\r\n?|\n)/);for(let s=0,o=i.length;s<o;++s){let a=i[s];r.append(document.createTextNode(a)),s<o-1&&r.append(document.createElement("br"))}return r}#S(e){e.altKey||e.shiftKey||e.ctrlKey||e.metaKey||(e.key==="Enter"||e.key==="Escape"&&this.#d)&&this.#E()}updateEdited({rect:e,popupContent:t}){this.#y||={contentsObj:this.#c,richText:this.#g},e&&(this.#o=null),t&&(this.#g=this.#A(t),this.#c=null),this.#f?.remove(),this.#f=null}resetEdited(){this.#y&&({contentsObj:this.#c,richText:this.#g}=this.#y,this.#y=null,this.#f?.remove(),this.#f=null,this.#o=null)}#D(){if(this.#o!==null)return;let{page:{view:e},viewport:{rawDims:{pageWidth:t,pageHeight:r,pageX:i,pageY:s}}}=this.#l,o=!!this.#h,a=o?this.#h:this.#p;for(let y of this.#u)if(!a||pe.intersect(y.data.rect,a)!==null){a=y.data.rect,o=!0;break}let c=pe.normalizeRect([a[0],e[3]-a[1]+e[1],a[2],e[3]-a[3]+e[1]]),u=o?a[2]-a[0]+5:0,d=c[0]+u,f=c[1];this.#o=[100*(d-i)/t,100*(f-s)/r];let{style:p}=this.#i;p.left=`${this.#o[0]}%`,p.top=`${this.#o[1]}%`}#E(){this.#d=!this.#d,this.#d?(this.#x(),this.#i.addEventListener("click",this.#r),this.#i.addEventListener("keydown",this.#e)):(this.#C(),this.#i.removeEventListener("click",this.#r),this.#i.removeEventListener("keydown",this.#e))}#x(){this.#f||this.render(),this.isVisible?this.#d&&this.#i.classList.add("focused"):(this.#D(),this.#i.hidden=!1,this.#i.style.zIndex=parseInt(this.#i.style.zIndex)+1e3)}#C(){this.#i.classList.remove("focused"),!(this.#d||!this.isVisible)&&(this.#i.hidden=!0,this.#i.style.zIndex=parseInt(this.#i.style.zIndex)-1e3)}forceHide(){this.#b=this.isVisible,this.#b&&(this.#i.hidden=!0)}maybeShow(){this.#b&&(this.#f||this.#x(),this.#b=!1,this.#i.hidden=!1)}get isVisible(){return this.#i.hidden===!1}},k_=class extends Kt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.textContent=e.data.textContent,this.textPosition=e.data.textPosition,this.annotationEditorType=je.FREETEXT}
86render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){let e=document.createElement("div");e.classList.add("annotationTextContent"),e.setAttribute("role","comment");for(let t of this.textContent){let r=document.createElement("span");r.textContent=t,e.append(r)}this.container.append(e)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}},Fx=class extends Kt{#e=null;constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");let e=this.data,{width:t,height:r}=ca(e.rect),i=this.svgFactory.create(t,r,!0),s=this.#e=this.svgFactory.createElement("svg:line");return s.setAttribute("x1",e.rect[2]-e.lineCoordinates[0]),s.setAttribute("y1",e.rect[3]-e.lineCoordinates[1]),s.setAttribute("x2",e.rect[2]-e.lineCoordinates[2]),s.setAttribute("y2",e.rect[3]-e.lineCoordinates[3]),s.setAttribute("stroke-width",e.borderStyle.width||1),s.setAttribute("stroke","transparent"),s.setAttribute("fill","transparent"),i.append(s),this.container.append(i),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#e}addHighlightArea(){this.container.classList.add("highlightArea")}},Vx=class extends Kt{#e=null;constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");let e=this.data,{width:t,height:r}=ca(e.rect),i=this.svgFactory.create(t,r,!0),s=e.borderStyle.width,o=this.#e=this.svgFactory.createElement("svg:rect");return o.setAttribute("x",s/2),o.setAttribute("y",s/2),o.setAttribute("width",t-s),o.setAttribute("height",r-s),o.setAttribute("stroke-width",s||1),o.setAttribute("stroke","transparent"),o.setAttribute("fill","transparent"),i.append(o),this.container.append(i),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#e}addHighlightArea(){this.container.classList.add("highlightArea")}},jx=class extends Kt{#e=null;constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");let e=this.data,{width:t,height:r}=ca(e.rect),i=this.svgFactory.create(t,r,!0),s=e.borderStyle.width,o=this.#e=this.svgFactory.createElement("svg:ellipse");return o.setAttribute("cx",t/2),o.setAttribute("cy",r/2),o.setAttribute("rx",t/2-s/2),o.setAttribute("ry",r/2-s/2),o.setAttribute("stroke-width",s||1),o.setAttribute("stroke","transparent"),o.setAttribute("fill","transparent"),i.append(o),this.container.append(i),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#e}addHighlightArea(){this.container.classList.add("highlightArea")}},P_=class extends Kt{#e=null;constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);let{data:{rect:e,vertices:t,borderStyle:r,popupRef:i}}=this;if(!t)return this.container;let{width:s,height:o}=ca(e),a=this.svgFactory.create(s,o,!0),c=[];for(let u=0,d=t.length;u<d;u+=2){let f=t[u]-e[0],p=e[3]-t[u+1];c.push(`${f},${p}`)}c=c.join(" ");let l=this.#e=this.svgFactory.createElement(this.svgElementName);return l.setAttribute("points",c),l.setAttribute("stroke-width",r.width||1),l.setAttribute("stroke","transparent"),l.setAttribute("fill","transparent"),a.append(l),this.container.append(a),!i&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#e}addHighlightArea(){this.container.classList.add("highlightArea")}},$x=class extends P_{constructor(e){super(e),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}},Ux=class extends Kt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}},gf=class extends Kt{#e=null;#t=[];constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=this.data.it==="InkHighlight"?je.HIGHLIGHT:je.INK}#n(e,t){switch(e){case 90:return{transform:`rotate(90) translate(${-t[0]},${t[1]}) scale(1,-1)`,width:t[3]-t[1],height:t[2]-t[0]};case 180:return{transform:`rotate(180) translate(${-t[2]},${t[1]}) scale(1,-1)`,width:t[2]-t[0],height:t[3]-t[1]};case 270:return{transform:`rotate(270) translate(${-t[2]},${t[3]}) scale(1,-1)`,width:t[3]-t[1],height:t[2]-t[0]};default:return{transform:`translate(${-t[0]},${t[3]}) scale(1,-1)`,width:t[2]-t[0],height:t[3]-t[1]}}}render(){this.container.classList.add(this.containerClassName);let{data:{rect:e,rotation:t,inkLists:r,borderStyle:i,popupRef:s}}=this,{transform:o,width:a,height:c}=this.#n(t,e),l=this.svgFactory.create(a,c,!0),u=this.#e=this.svgFactory.createElement("svg:g");l.append(u),u.setAttribute("stroke-width",i.width||1),u.setAttribute("stroke-linecap","round"),u.setAttribute("stroke-linejoin","round"),u.setAttribute("stroke-miterlimit",10),u.setAttribute("stroke","transparent"),u.setAttribute("fill","transparent"),u.setAttribute("transform",o);for(let d=0,f=r.length;d<f;d++){let p=this.svgFactory.createElement(this.svgElementName);this.#t.push(p),p.setAttribute("points",r[d].join(",")),u.append(p)}return!s&&this.hasPopupData&&this._createPopup(),this.container.append(l),this._editOnDoubleClick(),this.container}updateEdited(e){super.updateEdited(e);let{thickness:t,points:r,rect:i}=e,s=this.#e;if(t>
86=0&&s.setAttribute("stroke-width",t||1),r)for(let o=0,a=this.#t.length;o<a;o++)this.#t[o].setAttribute("points",r[o].join(","));if(i){let{transform:o,width:a,height:c}=this.#n(this.data.rotation,i);s.parentElement.setAttribute("viewBox",`0 0 ${a} ${c}`),s.setAttribute("transform",o)}}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}},M_=class extends Kt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=je.HIGHLIGHT}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),this.container}},Bx=class extends Kt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),this.container}},Hx=class extends Kt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),this.container}},qx=class extends Kt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),this.container}},N_=class extends Kt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=je.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}},zx=class extends Kt{#e=null;constructor(e){super(e,{isRenderable:!0});let{file:t}=this.data;this.filename=t.filename,this.content=t.content,this.linkService.eventBus?.dispatch("fileattachmentannotation",_({source:this},t))}render(){this.container.classList.add("fileAttachmentAnnotation");let{container:e,data:t}=this,r;t.hasAppearance||t.fillAlpha===0?r=document.createElement("div"):(r=document.createElement("img"),r.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(t.name)?"paperclip":"pushpin"}.svg`,t.fillAlpha&&t.fillAlpha<1&&(r.style=`filter: opacity(${Math.round(t.fillAlpha*100)}%);`)),r.addEventListener("dblclick",this.#t.bind(this)),this.#e=r;let{isMac:i}=Cn.platform;return e.addEventListener("keydown",s=>{s.key==="Enter"&&(i?s.metaKey:s.ctrlKey)&&this.#t()}),!t.popupRef&&this.hasPopupData?this._createPopup():r.classList.add("popupTriggerArea"),e.append(r),e}getElementsToTriggerPopup(){return this.#e}addHighlightArea(){this.container.classList.add("highlightArea")}#t(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}},Gx=class{#e=null;#t=null;#n=new Map;#r=null;constructor({div:e,accessibilityManager:t,annotationCanvasMap:r,annotationEditorUIManager:i,page:s,viewport:o,structTreeLayer:a}){this.div=e,this.#e=t,this.#t=r,this.#r=a||null,this.page=s,this.viewport=o,this.zIndex=0,this._annotationEditorUIManager=i}hasEditableAnnotations(){return this.#n.size>0}#s(e,t){return m(this,null,function*(){let r=e.firstChild||e,i=r.id=`${rD}${t}`,s=yield this.#r?.getAriaAttributes(i);if(s)for(let[o,a]of s)r.setAttribute(o,a);this.div.append(e),this.#e?.moveElementInDOM(this.div,e,r,!1)})}render(e){return m(this,null,function*(){let{annotations:t}=e,r=this.div;Tc(r,this.viewport);let i=new Map,s={data:null,layer:r,linkService:e.linkService,downloadManager:e.downloadManager,imageResourcesPath:e.imageResourcesPath||"",renderForms:e.renderForms!==!1,svgFactory:new pf,annotationStorage:e.annotationStorage||new uf,enableScripting:e.enableScripting===!0,hasJSActions:e.hasJSActions,fieldObjects:e.fieldObjects,parent:this,elements:null};for(let o of t){if(o.noHTML)continue;let a=o.annotationType===ln.POPUP;if(a){let u=i.get(o.id);if(!u)continue;s.elements=u}else{let{width:u,height:d}=ca(o.rect);if(u<=0||d<=0)continue}s.data=o;let c=Dx.create(s);if(!c.isRenderable)continue;if(!a&&o.popupRef){let u=i.get(o.popupRef);u?u.push(c):i.set(o.popupRef,[c])}let l=c.render();o.hidden&&(l.style.visibility="hidden"),yield this.#s(l,o.id),c._isEditable&&(this.#n.set(c.data.id,c),this._annotationEditorUIManager?.renderAnnotationElement(c))}this.#i()})}update({viewport:e}){let t=this.div;this.viewport=e,Tc(t,{rotation:e.rotation}),this.#i(),t.hidden=!1}#i(){if(!this.#t)return;let e=this.div;for(let[t,r]of this.#t){let i=e.querySelector(`[data-annotation-id="${t}"]`);if(!i)continue;r.className="annotationContent";let{firstChild:s}=i;s?s.nodeName==="CANVAS"?s.replaceWith(r):s.classList.contains("annotationContent")?s.after(r):s.before(r):i.append(r)}this.#t.clear()}getEditableAnnotations(){return Array.from(this.#n.values())}getEditableAnnotation(e){return this.#n.get(e)}},a_=/\r\n?|\n/g,Wx=class n extends Vt{#e;#t="";#n=`${this.id}-editor`;#r=null;#s;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){let e=n.prototype,t=s=>s.isEmpty(),r=lf.TRANSLATE_SMALL,i=lf.TRANSLATE_BIG;return Xe(this,"_keyboardManager",new Ac([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],e.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],e.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],e._translateEmpty,{args:[-r,0],checker:t}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e._translateEmpty,{args:[-i,0],checker:t}],[["ArrowRight","mac+ArrowRight"],e._translateEmpty,{args:[r,0],checker:t}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e._translateEmpty,{args:[i,0],checker:t}],[["ArrowUp","mac+ArrowUp"],e._translateEmpty,{args:[0,-r],checker:t}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e._translateEmpty,{args:[0,-i],checker:t}],[["ArrowDown","mac+ArrowDown"],e._translateEmpty,{args:[0,r],checker:t}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e._translateEmpty,{args:[0,i],checker:t}]]))}static _type="freetext";static _editorType=je.FREETEXT;constructor(e){super(D(_({},e),{name:"freeTextEditor"})),this.#e=e.color||n._defaultColor||Vt._defaultLineColor,this.#s=e.fontSize||n._defaultFontSize}static initialize(e,t){Vt.initialize(e,t);let r=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(r.getPropertyValue("--freetext-padding"))}
86static updateDefaultParams(e,t){switch(e){case rt.FREETEXT_SIZE:n._defaultFontSize=t;break;case rt.FREETEXT_COLOR:n._defaultColor=t;break}}updateParams(e,t){switch(e){case rt.FREETEXT_SIZE:this.#i(t);break;case rt.FREETEXT_COLOR:this.#c(t);break}}static get defaultPropertiesToUpdate(){return[[rt.FREETEXT_SIZE,n._defaultFontSize],[rt.FREETEXT_COLOR,n._defaultColor||Vt._defaultLineColor]]}get propertiesToUpdate(){return[[rt.FREETEXT_SIZE,this.#s],[rt.FREETEXT_COLOR,this.#e]]}#i(e){let t=i=>{this.editorDiv.style.fontSize=`calc(${i}px * var(--scale-factor))`,this.translate(0,-(i-this.#s)*this.parentScale),this.#s=i,this.#u()},r=this.#s;this.addCommands({cmd:t.bind(this,e),undo:t.bind(this,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:rt.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}#c(e){let t=i=>{this.#e=this.editorDiv.style.color=i},r=this.#e;this.addCommands({cmd:t.bind(this,e),undo:t.bind(this,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:rt.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(e,t){this._uiManager.translateSelectedEditors(e,t,!0)}getInitialTranslation(){let e=this.parentScale;return[-n._internalPadding*e,-(n._internalPadding+this.#s)*e]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(this.isInEditMode())return;this.parent.setEditingState(!1),this.parent.updateToolbar(je.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),this.#r=new AbortController;let e=this._uiManager.combinedSignal(this.#r);this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:e}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:e}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:e}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:e}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:e})}disableEditMode(){this.isInEditMode()&&(this.parent.setEditingState(!0),super.disableEditMode(),this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",this.#n),this._isDraggable=!0,this.#r?.abort(),this.#r=null,this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"))}focusin(e){this._focusEventsAllowed&&(super.focusin(e),e.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(e){this.width||(this.enableEditMode(),e&&this.editorDiv.focus(),this._initialOptions?.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||this.editorDiv.innerText.trim()===""}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}#a(){let e=[];this.editorDiv.normalize();let t=null;for(let r of this.editorDiv.childNodes)t?.nodeType===Node.TEXT_NODE&&r.nodeName==="BR"||(e.push(n.#l(r)),t=r);return e.join(` 87`)}#u(){let[e,t]=this.parentDimensions,r;if(this.isAttachedToDOM)r=this.div.getBoundingClientRect();else{let{currentLayer:i,div:s}=this,o=s.style.display,a=s.classList.contains("hidden");s.classList.remove("hidden"),s.style.display="hidden",i.div.append(this.div),r=s.getBoundingClientRect(),s.remove(),s.style.display=o,s.classList.toggle("hidden",a)}this.rotation%180===this.parentRotation%180?(this.width=r.width/e,this.height=r.height/t):(this.width=r.height/e,this.height=r.width/t),this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();let e=this.#t,t=this.#t=this.#a().trimEnd();if(e===t)return;let r=i=>{if(this.#t=i,!i){this.remove();return}this.#h(),this._uiManager.rebuild(this),this.#u()};this.addCommands({cmd:()=>{r(t)},undo:()=>{r(e)},mustExec:!1}),this.#u()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}dblclick(e){this.enterInEditMode()}keydown(e){e.target===this.div&&e.key==="Enter"&&(this.enterInEditMode(),e.preventDefault())}editorDivKeydown(e){n._keyboardManager.exec(this,e)}editorDivFocus(e){this.isEditing=!0}editorDivBlur(e){this.isEditing=!1}editorDivInput(e){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}
87render(){if(this.div)return this.div;let e,t;this.width&&(e=this.x,t=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",this.#n),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;let{style:r}=this.editorDiv;if(r.fontSize=`calc(${this.#s}px * var(--scale-factor))`,r.color=this.#e,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),f_(this,this.div,["dblclick","keydown"]),this.width){let[i,s]=this.parentDimensions;if(this.annotationElementId){let{position:o}=this._initialData,[a,c]=this.getInitialTranslation();[a,c]=this.pageTranslationToScreen(a,c);let[l,u]=this.pageDimensions,[d,f]=this.pageTranslation,p,y;switch(this.rotation){case 0:p=e+(o[0]-d)/l,y=t+this.height-(o[1]-f)/u;break;case 90:p=e+(o[0]-d)/l,y=t-(o[1]-f)/u,[a,c]=[c,-a];break;case 180:p=e-this.width+(o[0]-d)/l,y=t-(o[1]-f)/u,[a,c]=[-a,-c];break;case 270:p=e+(o[0]-d-this.height*u)/l,y=t+(o[1]-f-this.width*l)/u,[a,c]=[-c,a];break}this.setAt(p*i,y*s,a,c)}else this.setAt(e*i,t*s,this.width*i,this.height*s);this.#h(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static#l(e){return(e.nodeType===Node.TEXT_NODE?e.nodeValue:e.innerText).replaceAll(a_,"")}editorDivPaste(e){let t=e.clipboardData||window.clipboardData,{types:r}=t;if(r.length===1&&r[0]==="text/plain")return;e.preventDefault();let i=n.#f(t.getData("text")||"").replaceAll(a_,` 88`);if(!i)return;let s=window.getSelection();if(!s.rangeCount)return;this.editorDiv.normalize(),s.deleteFromDocument();let o=s.getRangeAt(0);if(!i.includes(` 89`)){o.insertNode(document.createTextNode(i)),this.editorDiv.normalize(),s.collapseToStart();return}let{startContainer:a,startOffset:c}=o,l=[],u=[];if(a.nodeType===Node.TEXT_NODE){let p=a.parentElement;if(u.push(a.nodeValue.slice(c).replaceAll(a_,"")),p!==this.editorDiv){let y=l;for(let v of this.editorDiv.childNodes){if(v===p){y=u;continue}y.push(n.#l(v))}}l.push(a.nodeValue.slice(0,c).replaceAll(a_,""))}else if(a===this.editorDiv){let p=l,y=0;for(let v of this.editorDiv.childNodes)y++===c&&(p=u),p.push(n.#l(v))}this.#t=`${l.join(` 90`)}${i}${u.join(` 91`)}`,this.#h();let d=new Range,f=l.reduce((p,y)=>p+y.length,0);for(let{firstChild:p}of this.editorDiv.childNodes)if(p.nodeType===Node.TEXT_NODE){let y=p.nodeValue.length;if(f<=y){d.setStart(p,f),d.setEnd(p,f);break}f-=y}s.removeAllRanges(),s.addRange(d)}#h(){if(this.editorDiv.replaceChildren(),!!this.#t)for(let e of this.#t.split(` 92`)){let t=document.createElement("div");t.append(e?document.createTextNode(e):document.createElement("br")),this.editorDiv.append(t)}}#d(){return this.#t.replaceAll("\xA0"," ")}static#f(e){return e.replaceAll(" ","\xA0")}get contentDiv(){return this.editorDiv}static deserialize(e,t,r){return m(this,null,function*(){let i=null;if(e instanceof k_){let{data:{defaultAppearanceData:{fontSize:o,fontColor:a},rect:c,rotation:l,id:u,popupRef:d},textContent:f,textPosition:p,parent:{page:{pageNumber:y}}}=e;if(!f||f.length===0)return null;i=e={annotationType:je.FREETEXT,color:Array.from(a),fontSize:o,value:f.join(` 93`),position:p,pageIndex:y-1,rect:c.slice(0),rotation:l,id:u,deleted:!1,popupRef:d}}let s=yield dn(n,this,"deserialize").call(this,e,t,r);return s.#s=e.fontSize,s.#e=pe.makeHexColor(...e.color),s.#t=n.#f(e.value),s.annotationElementId=e.id||null,s._initialData=i,s})}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let t=n._internalPadding*this.parentScale,r=this.getRect(t,t),i=Vt._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.#e),s={annotationType:je.FREETEXT,color:i,fontSize:this.#s,value:this.#d(),pageIndex:this.pageIndex,rect:r,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return e?s:this.annotationElementId&&!this.#o(s)?null:(s.id=this.annotationElementId,s)}#o(e){let{value:t,fontSize:r,color:i,pageIndex:s}=this._initialData;return this._hasBeenMoved||e.value!==t||e.fontSize!==r||e.color.some((o,a)=>o!==i[a])||e.pageIndex!==s}renderAnnotationElement(e){let t=super.renderAnnotationElement(e);
93if(this.deleted)return t;let{style:r}=t;r.fontSize=`calc(${this.#s}px * var(--scale-factor))`,r.color=this.#e,t.replaceChildren();for(let s of this.#t.split(` 94`)){let o=document.createElement("div");o.append(s?document.createTextNode(s):document.createElement("br")),t.append(o)}let i=n._internalPadding*this.parentScale;return e.updateEdited({rect:this.getRect(i,i),popupContent:this.#t}),t}resetAnnotationElement(e){super.resetAnnotationElement(e),e.resetEdited()}},ae=(()=>{class n{static PRECISION=1e-4;toSVGPath(){Ct("Abstract method `toSVGPath` must be implemented.")}get box(){Ct("Abstract getter `box` must be implemented.")}serialize(t,r){Ct("Abstract method `serialize` must be implemented.")}static _rescale(t,r,i,s,o,a){a||=new Float32Array(t.length);for(let c=0,l=t.length;c<l;c+=2)a[c]=r+t[c]*s,a[c+1]=i+t[c+1]*o;return a}static _rescaleAndSwap(t,r,i,s,o,a){a||=new Float32Array(t.length);for(let c=0,l=t.length;c<l;c+=2)a[c]=r+t[c+1]*s,a[c+1]=i+t[c]*o;return a}static _translate(t,r,i,s){s||=new Float32Array(t.length);for(let o=0,a=t.length;o<a;o+=2)s[o]=r+t[o],s[o+1]=i+t[o+1];return s}static svgRound(t){return Math.round(t*1e4)}static _normalizePoint(t,r,i,s,o){switch(o){case 90:return[1-r/i,t/s];case 180:return[1-t/i,1-r/s];case 270:return[r/i,1-t/s];default:return[t/i,r/s]}}static _normalizePagePoint(t,r,i){switch(i){case 90:return[1-r,t];case 180:return[1-t,1-r];case 270:return[r,1-t];default:return[t,r]}}static createBezierPoints(t,r,i,s,o,a){return[(t+5*i)/6,(r+5*s)/6,(5*i+o)/6,(5*s+a)/6,(i+o)/2,(s+a)/2]}}return n})(),O_=class n{#e;#t=[];#n;#r;#s=[];#i=new Float32Array(18);#c;#a;#u;#l;#h;#d;#f=[];static#o=8;static#p=2;static#g=n.#o+n.#p;constructor({x:e,y:t},r,i,s,o,a=0){this.#e=r,this.#d=s*i,this.#r=o,this.#i.set([NaN,NaN,NaN,NaN,e,t],6),this.#n=a,this.#l=n.#o*i,this.#u=n.#g*i,this.#h=i,this.#f.push(e,t)}isEmpty(){return isNaN(this.#i[8])}#m(){let e=this.#i.subarray(4,6),t=this.#i.subarray(16,18),[r,i,s,o]=this.#e;return[(this.#c+(e[0]-t[0])/2-r)/s,(this.#a+(e[1]-t[1])/2-i)/o,(this.#c+(t[0]-e[0])/2-r)/s,(this.#a+(t[1]-e[1])/2-i)/o]}add({x:e,y:t}){this.#c=e,this.#a=t;let[r,i,s,o]=this.#e,[a,c,l,u]=this.#i.subarray(8,12),d=e-l,f=t-u,p=Math.hypot(d,f);if(p<this.#u)return!1;let y=p-this.#l,v=y/p,w=v*d,E=v*f,A=a,x=c;a=l,c=u,l+=w,u+=E,this.#f?.push(e,t);let M=-E/y,O=w/y,$=M*this.#d,C=O*this.#d;return this.#i.set(this.#i.subarray(2,8),0),this.#i.set([l+$,u+C],4),this.#i.set(this.#i.subarray(14,18),12),this.#i.set([l-$,u-C],16),isNaN(this.#i[6])?(this.#s.length===0&&(this.#i.set([a+$,c+C],2),this.#s.push(NaN,NaN,NaN,NaN,(a+$-r)/s,(c+C-i)/o),this.#i.set([a-$,c-C],14),this.#t.push(NaN,NaN,NaN,NaN,(a-$-r)/s,(c-C-i)/o)),this.#i.set([A,x,a,c,l,u],6),!this.isEmpty()):(this.#i.set([A,x,a,c,l,u],6),Math.abs(Math.atan2(x-c,A-a)-Math.atan2(E,w))<Math.PI/2?([a,c,l,u]=this.#i.subarray(2,6),this.#s.push(NaN,NaN,NaN,NaN,((a+l)/2-r)/s,((c+u)/2-i)/o),[a,c,A,x]=this.#i.subarray(14,18),this.#t.push(NaN,NaN,NaN,NaN,((A+a)/2-r)/s,((x+c)/2-i)/o),!0):([A,x,a,c,l,u]=this.#i.subarray(0,6),this.#s.push(((A+5*a)/6-r)/s,((x+5*c)/6-i)/o,((5*a+l)/6-r)/s,((5*c+u)/6-i)/o,((a+l)/2-r)/s,((c+u)/2-i)/o),[l,u,a,c,A,x]=this.#i.subarray(12,18),this.#t.push(((A+5*a)/6-r)/s,((x+5*c)/6-i)/o,((5*a+l)/6-r)/s,((5*c+u)/6-i)/o,((a+l)/2-r)/s,((c+u)/2-i)/o),!0))}toSVGPath(){if(this.isEmpty())return"";let e=this.#s,t=this.#t;if(isNaN(this.#i[6])&&!this.isEmpty())return this.#y();let r=[];r.push(`M${e[4]} ${e[5]}`);for(let i=6;i<e.length;i+=6)isNaN(e[i])?r.push(`L${e[i+4]} ${e[i+5]}`):r.push(`C${e[i]} ${e[i+1]} ${e[i+2]} ${e[i+3]} ${e[i+4]} ${e[i+5]}`);this.#_(r);for(let i=t.length-6;i>=6;i-=6)isNaN(t[i])?r.push(`L${t[i+4]} ${t[i+5]}`):r.push(`C${t[i]} ${t[i+1]} ${t[i+2]} ${t[i+3]} ${t[i+4]} ${t[i+5]}`);return this.#b(r),r.join(" ")}#y(){let[e,t,r,i]=this.#e,[s,o,a,c]=this.#m();return`M${(this.#i[2]-e)/r} ${(this.#i[3]-t)/i} L${(this.#i[4]-e)/r} ${(this.#i[5]-t)/i} L${s} ${o} L${a} ${c} L${(this.#i[16]-e)/r} ${(this.#i[17]-t)/i} L${(this.#i[14]-e)/r} ${(this.#i[15]-t)/i} Z`}#b(e){let t=this.#t;e.push(`L${t[4]} ${t[5]} Z`)}#_(e){let[t,r,i,s]=this.#e,o=this.#i.subarray(4,6),a=this.#i.subarray(16,18),[c,l,u,d]=this.#m();e.push(`L${(o[0]-t)/i} ${(o[1]-r)/s} L${c} ${l} L${u} ${d} L${(a[0]-t)/i} ${(a[1]-r)/s}`)}newFreeDrawOutline(e,t,r,i,s,o){return new L_(e,t,r,i,s,o)}getOutlines(){let e=this.#s,t=this.#t,r=this.#i,[i,s,o,a]=this.#e,c=new Float32Array((this.#f?.length??0)+2);for(let d=0,f=c.length-2;d<f;d+=2)c[d]=(this.#f[d]-i)/o,c[d+1]=(this.#f[d+1]-s)/a;if(c[c.length-2]=(this.#c-i)/o,c[c.length-1]=(this.#a-s)/a,isNaN(r[6])&&!this.isEmpty())return this.#w(c);let l=new Float32Array(this.#s.length+24+this.#t.length),u=e.length;for(let d=0;d<u;d+=2){if(isNaN(e[d])){l[d]=l[d+1]=NaN;continue}l[d]=e[d],l[d+1]=e[d+1]}u=this.#A(l,u);for(let d=t.length-6;d>=6;d-=6)for(let f=0;f<6;
94f+=2){if(isNaN(t[d+f])){l[u]=l[u+1]=NaN,u+=2;continue}l[u]=t[d+f],l[u+1]=t[d+f+1],u+=2}return this.#I(l,u),this.newFreeDrawOutline(l,c,this.#e,this.#h,this.#n,this.#r)}#w(e){let t=this.#i,[r,i,s,o]=this.#e,[a,c,l,u]=this.#m(),d=new Float32Array(36);return d.set([NaN,NaN,NaN,NaN,(t[2]-r)/s,(t[3]-i)/o,NaN,NaN,NaN,NaN,(t[4]-r)/s,(t[5]-i)/o,NaN,NaN,NaN,NaN,a,c,NaN,NaN,NaN,NaN,l,u,NaN,NaN,NaN,NaN,(t[16]-r)/s,(t[17]-i)/o,NaN,NaN,NaN,NaN,(t[14]-r)/s,(t[15]-i)/o],0),this.newFreeDrawOutline(d,e,this.#e,this.#h,this.#n,this.#r)}#I(e,t){let r=this.#t;return e.set([NaN,NaN,NaN,NaN,r[4],r[5]],t),t+=6}#A(e,t){let r=this.#i.subarray(4,6),i=this.#i.subarray(16,18),[s,o,a,c]=this.#e,[l,u,d,f]=this.#m();return e.set([NaN,NaN,NaN,NaN,(r[0]-s)/a,(r[1]-o)/c,NaN,NaN,NaN,NaN,l,u,NaN,NaN,NaN,NaN,d,f,NaN,NaN,NaN,NaN,(i[0]-s)/a,(i[1]-o)/c],t),t+=24}},L_=class extends ae{#e;#t=new Float32Array(4);#n;#r;#s;#i;#c;constructor(e,t,r,i,s,o){super(),this.#c=e,this.#s=t,this.#e=r,this.#i=i,this.#n=s,this.#r=o,this.lastPoint=[NaN,NaN],this.#a(o);let[a,c,l,u]=this.#t;for(let d=0,f=e.length;d<f;d+=2)e[d]=(e[d]-a)/l,e[d+1]=(e[d+1]-c)/u;for(let d=0,f=t.length;d<f;d+=2)t[d]=(t[d]-a)/l,t[d+1]=(t[d+1]-c)/u}toSVGPath(){let e=[`M${this.#c[4]} ${this.#c[5]}`];for(let t=6,r=this.#c.length;t<r;t+=6){if(isNaN(this.#c[t])){e.push(`L${this.#c[t+4]} ${this.#c[t+5]}`);continue}e.push(`C${this.#c[t]} ${this.#c[t+1]} ${this.#c[t+2]} ${this.#c[t+3]} ${this.#c[t+4]} ${this.#c[t+5]}`)}return e.push("Z"),e.join(" ")}serialize([e,t,r,i],s){let o=r-e,a=i-t,c,l;switch(s){case 0:c=ae._rescale(this.#c,e,i,o,-a),l=ae._rescale(this.#s,e,i,o,-a);break;case 90:c=ae._rescaleAndSwap(this.#c,e,t,o,a),l=ae._rescaleAndSwap(this.#s,e,t,o,a);break;case 180:c=ae._rescale(this.#c,r,t,-o,a),l=ae._rescale(this.#s,r,t,-o,a);break;case 270:c=ae._rescaleAndSwap(this.#c,r,i,-o,-a),l=ae._rescaleAndSwap(this.#s,r,i,-o,-a);break}return{outline:Array.from(c),points:[Array.from(l)]}}#a(e){let t=this.#c,r=t[4],i=t[5],s=r,o=i,a=r,c=i,l=r,u=i,d=e?Math.max:Math.min;for(let p=6,y=t.length;p<y;p+=6){if(isNaN(t[p]))s=Math.min(s,t[p+4]),o=Math.min(o,t[p+5]),a=Math.max(a,t[p+4]),c=Math.max(c,t[p+5]),u<t[p+5]?(l=t[p+4],u=t[p+5]):u===t[p+5]&&(l=d(l,t[p+4]));else{let v=pe.bezierBoundingBox(r,i,...t.slice(p,p+6));s=Math.min(s,v[0]),o=Math.min(o,v[1]),a=Math.max(a,v[2]),c=Math.max(c,v[3]),u<v[3]?(l=v[2],u=v[3]):u===v[3]&&(l=d(l,v[2]))}r=t[p+4],i=t[p+5]}let f=this.#t;f[0]=s-this.#n,f[1]=o-this.#n,f[2]=a-s+2*this.#n,f[3]=c-o+2*this.#n,this.lastPoint=[l,u]}get box(){return this.#t}newOutliner(e,t,r,i,s,o=0){return new O_(e,t,r,i,s,o)}getNewOutline(e,t){let[r,i,s,o]=this.#t,[a,c,l,u]=this.#e,d=s*l,f=o*u,p=r*l+a,y=i*u+c,v=this.newOutliner({x:this.#s[0]*d+p,y:this.#s[1]*f+y},this.#e,this.#i,e,this.#r,t??this.#n);for(let w=2;w<this.#s.length;w+=2)v.add({x:this.#s[w]*d+p,y:this.#s[w+1]*f+y});return v.getOutlines()}},yf=class{#e;#t;#n=[];#r=[];constructor(e,t=0,r=0,i=!0){let s=1/0,o=-1/0,a=1/0,c=-1/0,u=10**-4;for(let{x:E,y:A,width:x,height:M}of e){let O=Math.floor((E-t)/u)*u,$=Math.ceil((E+x+t)/u)*u,C=Math.floor((A-t)/u)*u,T=Math.ceil((A+M+t)/u)*u,S=[O,C,T,!0],k=[$,C,T,!1];this.#n.push(S,k),s=Math.min(s,O),o=Math.max(o,$),a=Math.min(a,C),c=Math.max(c,T)}let d=o-s+2*r,f=c-a+2*r,p=s-r,y=a-r,v=this.#n.at(i?-1:-2),w=[v[0],v[2]];for(let E of this.#n){let[A,x,M]=E;E[0]=(A-p)/d,E[1]=(x-y)/f,E[2]=(M-y)/f}this.#e=new Float32Array([p,y,d,f]),this.#t=w}getOutlines(){this.#n.sort((t,r)=>t[0]-r[0]||t[1]-r[1]||t[2]-r[2]);let e=[];for(let t of this.#n)t[3]?(e.push(...this.#u(t)),this.#c(t)):(this.#a(t),e.push(...this.#u(t)));return this.#s(e)}#s(e){let t=[],r=new Set;for(let o of e){let[a,c,l]=o;t.push([a,c,o],[a,l,o])}t.sort((o,a)=>o[1]-a[1]||o[0]-a[0]);for(let o=0,a=t.length;o<a;o+=2){let c=t[o][2],l=t[o+1][2];c.push(l),l.push(c),r.add(c),r.add(l)}let i=[],s;for(;r.size>0;){let o=r.values().next().value,[a,c,l,u,d]=o;r.delete(o);let f=a,p=c;for(s=[a,l],i.push(s);;){let y;if(r.has(u))y=u;else if(r.has(d))y=d;else break;r.delete(y),[a,c,l,u,d]=y,f!==a&&(s.push(f,p,a,p===c?c:l),f=a),p=p===c?l:c}s.push(f,p)}return new Kx(i,this.#e,this.#t)}#i(e){let t=this.#r,r=0,i=t.length-1;for(;r<=i;){let s=r+i>>1,o=t[s][0];if(o===e)return s;o<e?r=s+1:i=s-1}return i+1}#c([,e,t]){let r=this.#i(e);this.#r.splice(r,0,[e,t])}#a([,e,t]){let r=this.#i(e);for(let i=r;i<this.#r.length;i++){let[s,o]=this.#r[i];if(s!==e)break;if(s===e&&o===t){this.#r.splice(i,1);return}}for(let i=r-1;i>=0;i--){let[s,o]=this.#r[i];if(s!==e)break;if(s===e&&o===t){this.#r.splice(i,1);return}}}#u(e){let[t,r,i]=e,s=[[t,r,i]],o=this.#i(i);for(let a=0;a<o;a++){let[c,l]=this.#r[a];for(let u=0,d=s.length;u<d;u++){let[,f,p]=s[u];if(!(l<=f||p<=c)){if(f>=c){if(p>l)s[u][1]=l;else{if(d===1)return[];s.splice(u,1),u--,d--}continue}s[u][2]=c,p>l&&s.push([t,l,p])}}}return s}},Kx=class extends ae{#e;#t;constructor(e,t,r){super(),this.#t=e,this.#e=t,this.lastPoint=r}toSVGPath(){let e=[];for(let t of this.#t){let[r,i]=t;e.push(`M${r} ${i}`);for(let s=2;s<t.length;s+=2){let o=t[s],a=t[s+1];o===r?(e.push(`V${a}`),i=a):a===i&&(e.push(`H${o}`),r=o)}e.push("Z")}return e.join(" ")}serialize([e,t,r,i],s){let o=[],a=r-e,c=i-t;for(let l of this.#t){let u=new Array(l.length);for(let d=0;d<l.length;d+=2)u[d]=e+l[d]*a,u[d+1]=i-l[d+1]*c;o.push(u)}return o}get box(){return this.#e}
94get classNamesForOutlining(){return["highlightOutline"]}},_f=class extends O_{newFreeDrawOutline(e,t,r,i,s,o){return new Yx(e,t,r,i,s,o)}},Yx=class extends L_{newOutliner(e,t,r,i,s,o=0){return new _f(e,t,r,i,s,o)}},F_=class n{#e=null;#t=null;#n;#r=null;#s=!1;#i=!1;#c=null;#a;#u=null;#l=null;#h;static#d=null;static get _keyboardManager(){return Xe(this,"_keyboardManager",new Ac([[["Escape","mac+Escape"],n.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],n.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],n.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],n.prototype._moveToPrevious],[["Home","mac+Home"],n.prototype._moveToBeginning],[["End","mac+End"],n.prototype._moveToEnd]]))}constructor({editor:e=null,uiManager:t=null}){e?(this.#i=!1,this.#h=rt.HIGHLIGHT_COLOR,this.#c=e):(this.#i=!0,this.#h=rt.HIGHLIGHT_DEFAULT_COLOR),this.#l=e?._uiManager||t,this.#a=this.#l._eventBus,this.#n=e?.color||this.#l?.highlightColors.values().next().value||"#FFFF98",n.#d||=Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"})}renderButton(){let e=this.#e=document.createElement("button");e.className="colorPicker",e.tabIndex="0",e.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),e.setAttribute("aria-haspopup",!0);let t=this.#l._signal;e.addEventListener("click",this.#g.bind(this),{signal:t}),e.addEventListener("keydown",this.#p.bind(this),{signal:t});let r=this.#t=document.createElement("span");return r.className="swatch",r.setAttribute("aria-hidden",!0),r.style.backgroundColor=this.#n,e.append(r),e}renderMainDropdown(){let e=this.#r=this.#f();return e.setAttribute("aria-orientation","horizontal"),e.setAttribute("aria-labelledby","highlightColorPickerLabel"),e}#f(){let e=document.createElement("div"),t=this.#l._signal;e.addEventListener("contextmenu",Ni,{signal:t}),e.className="dropdown",e.role="listbox",e.setAttribute("aria-multiselectable",!1),e.setAttribute("aria-orientation","vertical"),e.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown");for(let[r,i]of this.#l.highlightColors){let s=document.createElement("button");s.tabIndex="0",s.role="option",s.setAttribute("data-color",i),s.title=r,s.setAttribute("data-l10n-id",n.#d[r]);let o=document.createElement("span");s.append(o),o.className="swatch",o.style.backgroundColor=i,s.setAttribute("aria-selected",i===this.#n),s.addEventListener("click",this.#o.bind(this,i),{signal:t}),e.append(s)}return e.addEventListener("keydown",this.#p.bind(this),{signal:t}),e}#o(e,t){t.stopPropagation(),this.#a.dispatch("switchannotationeditorparams",{source:this,type:this.#h,value:e})}_colorSelectFromKeyboard(e){if(e.target===this.#e){this.#g(e);return}let t=e.target.getAttribute("data-color");t&&this.#o(t,e)}_moveToNext(e){if(!this.#y){this.#g(e);return}if(e.target===this.#e){this.#r.firstChild?.focus();return}e.target.nextSibling?.focus()}_moveToPrevious(e){if(e.target===this.#r?.firstChild||e.target===this.#e){this.#y&&this._hideDropdownFromKeyboard();return}this.#y||this.#g(e),e.target.previousSibling?.focus()}_moveToBeginning(e){if(!this.#y){this.#g(e);return}this.#r.firstChild?.focus()}_moveToEnd(e){if(!this.#y){this.#g(e);return}this.#r.lastChild?.focus()}#p(e){n._keyboardManager.exec(this,e)}#g(e){if(this.#y){this.hideDropdown();return}if(this.#s=e.detail===0,this.#u||(this.#u=new AbortController,window.addEventListener("pointerdown",this.#m.bind(this),{signal:this.#l.combinedSignal(this.#u)})),this.#r){this.#r.classList.remove("hidden");return}let t=this.#r=this.#f();this.#e.append(t)}#m(e){this.#r?.contains(e.target)||this.hideDropdown()}hideDropdown(){this.#r?.classList.add("hidden"),this.#u?.abort(),this.#u=null}get#y(){return this.#r&&!this.#r.classList.contains("hidden")}_hideDropdownFromKeyboard(){if(!this.#i){if(!this.#y){this.#c?.unselect();return}this.hideDropdown(),this.#e.focus({preventScroll:!0,focusVisible:this.#s})}}updateColor(e){if(this.#t&&(this.#t.style.backgroundColor=e),!this.#r)return;let t=this.#l.highlightColors.values();for(let r of this.#r.children)r.setAttribute("aria-selected",t.next().value===e)}destroy(){this.#e?.remove(),this.#e=null,this.#t=null,this.#r?.remove(),this.#r=null}},V_=class n extends Vt{#e=null;#t=0;#n;#r=null;#s=null;#i=null;#c=null;#a=0;#u=null;#l=null;#h=null;#d=!1;#f=null;#o;#p=null;#g="";#m;#y="";static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _type="highlight";static _editorType=je.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){let e=n.prototype;return Xe(this,"_keyboardManager",new Ac([[["ArrowLeft","mac+ArrowLeft"],e._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],e._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],e._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],e._moveCaret,{args:[3]}]]))}constructor(e){super(D(_({},e),{name:"highlightEditor"})),this.color=e.color||n._defaultColor,this.#m=e.thickness||n._defaultThickness,this.#o=e.opacity||n._defaultOpacity,this.#n=e.boxes||null,this.#y=e.methodOfCreation||"",this.#g=e.text||"",this._isDraggable=!1,e.highlightId>-1?(this.#d=!0,this.#_(e),this.#D()):this.#n&&(this.#e=e.anchorNode,this.#t=e.anchorOffset,this.#c=e.focusNode,this.#a=e.focusOffset,this.#b(),this.#D(),this.rotate(this.rotation))}get telemetryInitialData(){return{action:"added",type:this.#d?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:this.#m,methodOfCreation:this.#y}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(e){return{numberOfColors:e.get("
94color").size}}#b(){let e=new yf(this.#n,.001);this.#l=e.getOutlines(),[this.x,this.y,this.width,this.height]=this.#l.box;let t=new yf(this.#n,.0025,.001,this._uiManager.direction==="ltr");this.#i=t.getOutlines();let{lastPoint:r}=this.#i;this.#f=[(r[0]-this.x)/this.width,(r[1]-this.y)/this.height]}#_({highlightOutlines:e,highlightId:t,clipPathId:r}){this.#l=e;let i=1.5;if(this.#i=e.getNewOutline(this.#m/2+i,.0025),t>=0)this.#h=t,this.#r=r,this.parent.drawLayer.finalizeDraw(t,{bbox:e.box,path:{d:e.toSVGPath()}}),this.#p=this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:this.#i.box,path:{d:this.#i.toSVGPath()}},!0);else if(this.parent){let u=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(this.#h,{bbox:n.#E(this.#l.box,(u-this.rotation+360)%360),path:{d:e.toSVGPath()}}),this.parent.drawLayer.updateProperties(this.#p,{bbox:n.#E(this.#i.box,u),path:{d:this.#i.toSVGPath()}})}let[s,o,a,c]=e.box;switch(this.rotation){case 0:this.x=s,this.y=o,this.width=a,this.height=c;break;case 90:{let[u,d]=this.parentDimensions;this.x=o,this.y=1-s,this.width=a*d/u,this.height=c*u/d;break}case 180:this.x=1-s,this.y=1-o,this.width=a,this.height=c;break;case 270:{let[u,d]=this.parentDimensions;this.x=1-o,this.y=s,this.width=a*d/u,this.height=c*u/d;break}}let{lastPoint:l}=this.#i;this.#f=[(l[0]-s)/a,(l[1]-o)/c]}static initialize(e,t){Vt.initialize(e,t),n._defaultColor||=t.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(e,t){switch(e){case rt.HIGHLIGHT_DEFAULT_COLOR:n._defaultColor=t;break;case rt.HIGHLIGHT_THICKNESS:n._defaultThickness=t;break}}translateInPage(e,t){}get toolbarPosition(){return this.#f}updateParams(e,t){switch(e){case rt.HIGHLIGHT_COLOR:this.#w(t);break;case rt.HIGHLIGHT_THICKNESS:this.#I(t);break}}static get defaultPropertiesToUpdate(){return[[rt.HIGHLIGHT_DEFAULT_COLOR,n._defaultColor],[rt.HIGHLIGHT_THICKNESS,n._defaultThickness]]}get propertiesToUpdate(){return[[rt.HIGHLIGHT_COLOR,this.color||n._defaultColor],[rt.HIGHLIGHT_THICKNESS,this.#m||n._defaultThickness],[rt.HIGHLIGHT_FREE,this.#d]]}#w(e){let t=(s,o)=>{this.color=s,this.#o=o,this.parent?.drawLayer.updateProperties(this.#h,{root:{fill:s,"fill-opacity":o}}),this.#s?.updateColor(s)},r=this.color,i=this.#o;this.addCommands({cmd:t.bind(this,e,n._defaultOpacity),undo:t.bind(this,r,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:rt.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(e)},!0)}#I(e){let t=this.#m,r=i=>{this.#m=i,this.#A(i)};this.addCommands({cmd:r.bind(this,e),undo:r.bind(this,t),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:rt.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:e},!0)}addEditToolbar(){return m(this,null,function*(){let e=yield dn(n.prototype,this,"addEditToolbar").call(this);return e?(this._uiManager.highlightColors&&(this.#s=new F_({editor:this}),e.addColorPicker(this.#s)),e):null})}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(this.#k())}getBaseTranslation(){return[0,0]}getRect(e,t){return super.getRect(e,t,this.#k())}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this),e&&this.div.focus()}remove(){this.#S(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.#D(),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){let t=!1;this.parent&&!e?this.#S():e&&(this.#D(e),t=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(e),this.show(this._isVisible),t&&this.select()}#A(e){if(!this.#d)return;this.#_({highlightOutlines:this.#l.getNewOutline(e/2)}),this.fixAndSetPosition();let[t,r]=this.parentDimensions;this.setDims(this.width*t,this.height*r)}#S(){this.#h===null||!this.parent||(this.parent.drawLayer.remove(this.#h),this.#h=null,this.parent.drawLayer.remove(this.#p),this.#p=null)}#D(e=this.parent){this.#h===null&&({id:this.#h,clipPathId:this.#r}=e.drawLayer.draw({bbox:this.#l.box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.#o},rootClass:{highlight:!0,free:this.#d},path:{d:this.#l.toSVGPath()}},!1,!0),this.#p=e.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:this.#d},bbox:this.#i.box,path:{d:this.#i.toSVGPath()}},this.#d),this.#u&&(this.#u.style.clipPath=this.#r))}static#E([e,t,r,i],s){switch(s){case 90:return[1-t-i,e,i,r];case 180:return[1-e-r,1-t-i,r,i];case 270:return[t,1-e-r,i,r]}return[e,t,r,i]}rotate(e){let{drawLayer:t}=this.parent,r;this.#d?(e=(e-this.rotation+360)%360,r=n.#E(this.#l.box,e)):r=n.#E([this.x,this.y,this.width,this.height],e),t.updateProperties(this.#h,{bbox:r,root:{"data-main-rotation":e}}),t.updateProperties(this.#p,{bbox:n.#E(this.#i.box,e),root:{"data-main-rotation":e}})}
94render(){if(this.div)return this.div;let e=super.render();this.#g&&(e.setAttribute("aria-label",this.#g),e.setAttribute("role","mark")),this.#d?e.classList.add("free"):this.div.addEventListener("keydown",this.#x.bind(this),{signal:this._uiManager._signal});let t=this.#u=document.createElement("div");e.append(t),t.setAttribute("aria-hidden","true"),t.className="internal",t.style.clipPath=this.#r;let[r,i]=this.parentDimensions;return this.setDims(this.width*r,this.height*i),f_(this,this.#u,["pointerover","pointerleave"]),this.enableEditing(),e}pointerover(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#p,{rootClass:{hovered:!0}})}pointerleave(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#p,{rootClass:{hovered:!1}})}#x(e){n._keyboardManager.exec(this,e)}_moveCaret(e){switch(this.parent.unselect(this),e){case 0:case 2:this.#C(!0);break;case 1:case 3:this.#C(!1);break}}#C(e){if(!this.#e)return;let t=window.getSelection();e?t.setPosition(this.#e,this.#t):t.setPosition(this.#c,this.#a)}select(){super.select(),this.#p&&this.parent?.drawLayer.updateProperties(this.#p,{rootClass:{hovered:!1,selected:!0}})}unselect(){super.unselect(),this.#p&&(this.parent?.drawLayer.updateProperties(this.#p,{rootClass:{selected:!1}}),this.#d||this.#C(!1))}get _mustFixPosition(){return!this.#d}show(e=this._isVisible){super.show(e),this.parent&&(this.parent.drawLayer.updateProperties(this.#h,{rootClass:{hidden:!e}}),this.parent.drawLayer.updateProperties(this.#p,{rootClass:{hidden:!e}}))}#k(){return this.#d?this.rotation:0}#N(){if(this.#d)return null;let[e,t]=this.pageDimensions,[r,i]=this.pageTranslation,s=this.#n,o=new Float32Array(s.length*8),a=0;for(let{x:c,y:l,width:u,height:d}of s){let f=c*e+r,p=(1-l)*t+i;o[a]=o[a+4]=f,o[a+1]=o[a+3]=p,o[a+2]=o[a+6]=f+u*e,o[a+5]=o[a+7]=p-d*t,a+=8}return o}#L(e){return this.#l.serialize(e,this.#k())}static startHighlighting(e,t,{target:r,x:i,y:s}){let{x:o,y:a,width:c,height:l}=r.getBoundingClientRect(),u=new AbortController,d=e.combinedSignal(u),f=p=>{u.abort(),this.#v(e,p)};window.addEventListener("blur",f,{signal:d}),window.addEventListener("pointerup",f,{signal:d}),window.addEventListener("pointerdown",$r,{capture:!0,passive:!1,signal:d}),window.addEventListener("contextmenu",Ni,{signal:d}),r.addEventListener("pointermove",this.#T.bind(this,e),{signal:d}),this._freeHighlight=new _f({x:i,y:s},[o,a,c,l],e.scale,this._defaultThickness/2,t,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0)}static#T(e,t){this._freeHighlight.add(t)&&e.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}static#v(e,t){this._freeHighlight.isEmpty()?e.drawLayer.remove(this._freeHighlightId):e.createAndAddNewEditor(t,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""}static deserialize(e,t,r){return m(this,null,function*(){let i=null;if(e instanceof M_){let{data:{quadPoints:y,rect:v,rotation:w,id:E,color:A,opacity:x,popupRef:M},parent:{page:{pageNumber:O}}}=e;i=e={annotationType:je.HIGHLIGHT,color:Array.from(A),opacity:x,quadPoints:y,boxes:null,pageIndex:O-1,rect:v.slice(0),rotation:w,id:E,deleted:!1,popupRef:M}}else if(e instanceof gf){let{data:{inkLists:y,rect:v,rotation:w,id:E,color:A,borderStyle:{rawWidth:x},popupRef:M},parent:{page:{pageNumber:O}}}=e;i=e={annotationType:je.HIGHLIGHT,color:Array.from(A),thickness:x,inkLists:y,boxes:null,pageIndex:O-1,rect:v.slice(0),rotation:w,id:E,deleted:!1,popupRef:M}}let{color:s,quadPoints:o,inkLists:a,opacity:c}=e,l=yield dn(n,this,"deserialize").call(this,e,t,r);l.color=pe.makeHexColor(...s),l.#o=c||1,a&&(l.#m=e.thickness),l.annotationElementId=e.id||null,l._initialData=i;let[u,d]=l.pageDimensions,[f,p]=l.pageTranslation;if(o){let y=l.#n=[];for(let v=0;v<o.length;v+=8)y.push({x:(o[v]-f)/u,y:1-(o[v+1]-p)/d,width:(o[v+2]-o[v])/u,height:(o[v+1]-o[v+5])/d});l.#b(),l.#D(),l.rotate(l.rotation)}else if(a){l.#d=!0;let y=a[0],v={x:y[0]-f,y:d-(y[1]-p)},w=new _f(v,[0,0,u,d],1,l.#m/2,!0,.001);for(let x=0,M=y.length;x<M;x+=2)v.x=y[x]-f,v.y=d-(y[x+1]-p),w.add(v);let{id:E,clipPathId:A}=t.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:l.color,"fill-opacity":l._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:w.toSVGPath()}},!0,!0);l.#_({highlightOutlines:w.getOutlines(),highlightId:E,clipPathId:A}),l.#D()}return l})}serialize(e=!1){if(this.isEmpty()||e)return null;if(this.deleted)return this.serializeDeleted();let t=this.getRect(0,0),r=Vt._colorManager.convert(this.color),i={annotationType:je.HIGHLIGHT,color:r,opacity:this.#o,thickness:this.#m,quadPoints:this.#N(),outlines:this.#L(t),pageIndex:this.pageIndex,rect:t,rotation:this.#k(),structTreeParentId:this._structTreeParentId};return this.annotationElementId&&!this.#M(i)?null:(i.id=this.annotationElementId,i)}
94#M(e){let{color:t}=this._initialData;return e.color.some((r,i)=>r!==t[i])}renderAnnotationElement(e){return e.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}},Xx=class{#e=Object.create(null);updateProperty(e,t){this[e]=t,this.updateSVGProperty(e,t)}updateProperties(e){if(e)for(let[t,r]of Object.entries(e))this.updateProperty(t,r)}updateSVGProperty(e,t){this.#e[e]=t}toSVGProperties(){let e=this.#e;return this.#e=Object.create(null),{root:e}}reset(){this.#e=Object.create(null)}updateAll(e=this){this.updateProperties(e)}clone(){Ct("Not implemented")}},$ne=(()=>{class n extends Vt{#e=null;#t;_drawId=null;static _currentDrawId=-1;static _currentParent=null;static#n=null;static#r=null;static#s=null;static#i=NaN;static#c=null;static#a=null;static#u=NaN;static _INNER_MARGIN=3;constructor(t){super(t),this.#t=t.mustBeCommitted||!1,t.drawOutlines&&(this.#l(t),this.#f())}#l({drawOutlines:t,drawId:r,drawingOptions:i}){this.#e=t,this._drawingOptions||=i,r>=0?(this._drawId=r,this.parent.drawLayer.finalizeDraw(r,t.defaultProperties)):this._drawId=this.#h(t,this.parent),this.#g(t.box)}#h(t,r){let{id:i}=r.drawLayer.draw(n._mergeSVGProperties(this._drawingOptions.toSVGProperties(),t.defaultSVGProperties),!1,!1);return i}static _mergeSVGProperties(t,r){let i=new Set(Object.keys(t));for(let[s,o]of Object.entries(r))i.has(s)?Object.assign(t[s],o):t[s]=o;return t}static getDefaultDrawingOptions(t){Ct("Not implemented")}static get typesMap(){Ct("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(t,r){let i=this.typesMap.get(t);i&&this._defaultDrawingOptions.updateProperty(i,r),this._currentParent&&(n.#n.updateProperty(i,r),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(t,r){let i=this.constructor.typesMap.get(t);i&&this._updateProperty(t,i,r)}static get defaultPropertiesToUpdate(){let t=[],r=this._defaultDrawingOptions;for(let[i,s]of this.typesMap)t.push([i,r[s]]);return t}get propertiesToUpdate(){let t=[],{_drawingOptions:r}=this;for(let[i,s]of this.constructor.typesMap)t.push([i,r[s]]);return t}_updateProperty(t,r,i){let s=this._drawingOptions,o=s[r],a=c=>{s.updateProperty(r,c);let l=this.#e.updateProperty(r,c);l&&this.#g(l),this.parent?.drawLayer.updateProperties(this._drawId,s.toSVGProperties())};this.addCommands({cmd:a.bind(this,i),undo:a.bind(this,o),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:t,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,n._mergeSVGProperties(this.#e.getPathResizingSVGProperties(this.#p()),{bbox:this.#m()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,n._mergeSVGProperties(this.#e.getPathResizedSVGProperties(this.#p()),{bbox:this.#m()}))}_onTranslating(t,r){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#m(t,r)})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,n._mergeSVGProperties(this.#e.getPathTranslatedSVGProperties(this.#p(),this.parentDimensions),{bbox:this.#m()}))}_onStartDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,this.#t&&(this.#t=!1,this.commit(),this.parent.setSelected(this),t&&this.isOnScreen&&this.div.focus())}remove(){this.#d(),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.#f(),this.#g(this.#e.box),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let r=!1;this.parent&&!t?(this._uiManager.removeShouldRescale(this),this.#d()):t&&(this._uiManager.addShouldRescale(this),this.#f(t),r=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),r&&this.select()}#d(){this._drawId===null||!this.parent||(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())}#f(t=this.parent){if(!(this._drawId!==null&&this.parent===t)){if(this._drawId!==null){this.parent.drawLayer.updateParent(this._drawId,t.drawLayer);return}this._drawingOptions.updateAll(),this._drawId=this.#h(this.#e,t)}}#o([t,r,i,s]){let{parentDimensions:[o,a],rotation:c}=this;switch(c){case 90:return[r,1-t,i*(a/o),s*(o/a)];case 180:return[1-t,1-r,i,s];case 270:return[1-r,t,i*(a/o),s*(o/a)];default:return[t,r,i,s]}}#p(){let{x:t,y:r,width:i,height:s,parentDimensions:[o,a],rotation:c}=this;switch(c){case 90:return[1-r,t,i*(o/a),s*(a/o)];case 180:return[1-t,1-r,i,s];case 270:return[r,1-t,i*(o/a),s*(a/o)];default:return[t,r,i,s]}}#g(t){if([this.x,this.y,this.width,this.height]=this.#o(t),this.div){this.fixAndSetPosition();let[r,i]=this.parentDimensions;this.setDims(this.width*r,this.height*i)}this._onResized()}#m(){let{x:t,y:r,width:i,height:s,rotation:o,parentRotation:a,parentDimensions:[c,l]}=this;switch((o*4+a)/90){case 1:return[1-r-s,t,s,i];case 2:return[1-t-i,1-r-s,i,s];case 3:return[r,1-t-i,s,i];case 4:return[t,r-i*(c/l),s*(l/c),i*(c/l)];case 5:return[1-r,t,i*(c/l),s*(l/c)];case 6:return[1-t-s*(l/c),1-r,s*(l/c),i*(c/l)];case 7:return[r-i*(c/l),1-t-s*(l/c),i*(c/l),s*(l/c)];case 8:return[t-i,r-s,i,s];case 9:return[1-r,t-i,s,i];case 10:return[1-t,1-r,i,s];case 11:return[r-s,1-t,s,i];case 12:return[t-s*(l/c),r,s*(l/c),i*(c/l)];case 13:return[1-r-i*(c/l),t-s*(l/c),i*(c/l),s*(l/c)];case 14:return[1-t,1-r-i*(c/l),s*(l/c),i*(c/l)];case 15:return[r,1-t,i*(c/l),s*(l/c)];default:return[t,r,i,s]}}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,n._mergeSVGProperties({bbox:this.#m()},this.#e.updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&this.#g(this.#e.updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}
94render(){if(this.div)return this.div;let t=super.render();t.classList.add("draw");let r=document.createElement("div");t.append(r),r.setAttribute("aria-hidden","true"),r.className="internal";let[i,s]=this.parentDimensions;return this.setDims(this.width*i,this.height*s),this._uiManager.addShouldRescale(this),this.disableEditing(),t}static createDrawerInstance(t,r,i,s,o){Ct("Not implemented")}static startDrawing(t,r,i,s){let{target:o,offsetX:a,offsetY:c,pointerId:l,pointerType:u}=s;if(n.#c&&n.#c!==u)return;let{viewport:{rotation:d}}=t,{width:f,height:p}=o.getBoundingClientRect(),y=n.#r=new AbortController,v=t.combinedSignal(y);if(n.#i||=l,n.#c??=u,window.addEventListener("pointerup",w=>{n.#i===w.pointerId?this._endDraw(w):n.#a?.delete(w.pointerId)},{signal:v}),window.addEventListener("pointercancel",w=>{n.#i===w.pointerId?this._currentParent.endDrawingSession():n.#a?.delete(w.pointerId)},{signal:v}),window.addEventListener("pointerdown",w=>{n.#c===w.pointerType&&((n.#a||=new Set).add(w.pointerId),n.#n.isCancellable()&&(n.#n.removeLastElement(),n.#n.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:v}),window.addEventListener("contextmenu",Ni,{signal:v}),o.addEventListener("pointermove",this._drawMove.bind(this),{signal:v}),o.addEventListener("touchmove",w=>{w.timeStamp===n.#u&&$r(w)},{signal:v}),t.toggleDrawing(),r._editorUndoBar?.hide(),n.#n){t.drawLayer.updateProperties(this._currentDrawId,n.#n.startNew(a,c,f,p,d));return}r.updateUIForDefaultProperties(this),n.#n=this.createDrawerInstance(a,c,f,p,d),n.#s=this.getDefaultDrawingOptions(),this._currentParent=t,{id:this._currentDrawId}=t.drawLayer.draw(this._mergeSVGProperties(n.#s.toSVGProperties(),n.#n.defaultSVGProperties),!0,!1)}static _drawMove(t){if(n.#u=-1,!n.#n)return;let{offsetX:r,offsetY:i,pointerId:s}=t;if(n.#i===s){if(n.#a?.size>=1){this._endDraw(t);return}this._currentParent.drawLayer.updateProperties(this._currentDrawId,n.#n.add(r,i)),n.#u=t.timeStamp,$r(t)}}static _cleanup(t){t&&(this._currentDrawId=-1,this._currentParent=null,n.#n=null,n.#s=null,n.#c=null,n.#u=NaN),n.#r&&(n.#r.abort(),n.#r=null,n.#i=NaN,n.#a=null)}static _endDraw(t){let r=this._currentParent;if(r){if(r.toggleDrawing(!0),this._cleanup(!1),t&&r.drawLayer.updateProperties(this._currentDrawId,n.#n.end(t.offsetX,t.offsetY)),this.supportMultipleDrawings){let i=n.#n,s=this._currentDrawId,o=i.getLastElement();r.addCommands({cmd:()=>{r.drawLayer.updateProperties(s,i.setLastElement(o))},undo:()=>{r.drawLayer.updateProperties(s,i.removeLastElement())},mustExec:!1,type:rt.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(t){let r=this._currentParent;if(!r)return null;if(r.toggleDrawing(!0),r.cleanUndoStack(rt.DRAW_STEP),!n.#n.isEmpty()){let{pageDimensions:[i,s],scale:o}=r,a=r.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:n.#n.getOutlines(i*o,s*o,o,this._INNER_MARGIN),drawingOptions:n.#s,mustBeCommitted:!t});return this._cleanup(!0),a}return r.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(t){}static deserializeDraw(t,r,i,s,o,a){Ct("Not implemented")}static deserialize(t,r,i){return m(this,null,function*(){let{rawDims:{pageWidth:s,pageHeight:o,pageX:a,pageY:c}}=r.viewport,l=this.deserializeDraw(a,c,s,o,this._INNER_MARGIN,t),u=yield dn(n,this,"deserialize").call(this,t,r,i);return u.createDrawingOptions(t),u.#l({drawOutlines:l}),u.#f(),u.onScaleChanging(),u.rotate(),u})}serializeDraw(t){let[r,i]=this.pageTranslation,[s,o]=this.pageDimensions;return this.#e.serialize([r,i,s,o],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}}return n})(),Qx=class{#e=new Float64Array(6);#t;#n;#r;#s;#i;#c="";#a=0;#u=new j_;#l;#h;constructor(e,t,r,i,s,o){this.#l=r,this.#h=i,this.#r=s,this.#s=o,[e,t]=this.#d(e,t);let a=this.#t=[NaN,NaN,NaN,NaN,e,t];this.#i=[e,t],this.#n=[{line:a,points:this.#i}],this.#e.set(a,0)}updateProperty(e,t){e==="stroke-width"&&(this.#s=t)}#d(e,t){return ae._normalizePoint(e,t,this.#l,this.#h,this.#r)}isEmpty(){return!this.#n||this.#n.length===0}isCancellable(){return this.#i.length<=10}add(e,t){[e,t]=this.#d(e,t);let[r,i,s,o]=this.#e.subarray(2,6),a=e-s,c=t-o;return Math.hypot(this.#l*a,this.#h*c)<=2?null:(this.#i.push(e,t),isNaN(r)?(this.#e.set([s,o,e,t],2),this.#t.push(NaN,NaN,NaN,NaN,e,t),{path:{d:this.toSVGPath()}}):(isNaN(this.#e[0])&&this.#t.splice(6,6),this.#e.set([r,i,s,o,e,t],0),this.#t.push(...ae.createBezierPoints(r,i,s,o,e,t)),{path:{d:this.toSVGPath()}}))}end(e,t){let r=this.add(e,t);return r||(this.#i.length===2?{path:{d:this.toSVGPath()}}:null)}startNew(e,t,r,i,s){this.#l=r,this.#h=i,this.#r=s,[e,t]=this.#d(e,t);let o=this.#t=[NaN,NaN,NaN,NaN,e,t];this.#i=[e,t];let a=this.#n.at(-1);return a&&(a.line=new Float32Array(a.line),a.points=new Float32Array(a.points)),this.#n.push({line:o,points:this.#i}),this.#e.set(o,0),this.#a=0,this.toSVGPath(),null}getLastElement(){return this.#n.at(-1)}setLastElement(e){return this.#n?(this.#n.push(e),this.#t=e.line,this.#i=e.points,this.#a=0,{path:{d:this.toSVGPath()}}):this.#u.setLastElement(e)}removeLastElement(){if(!this.#n)return this.#u.removeLastElement();this.#n.pop(),this.#c="";for(let e=0,t=this.#n.length;e<t;e++){let{line:r,points:i}=this.#n[e];this.#t=r,this.#i=i,this.#a=0,this.toSVGPath()}return{path:{d:this.#c}}}toSVGPath(){let e=ae.svgRound(this.#t[4]),t=ae.svgRound(this.#t[5]);if(this.#i.length===2)return this.#c=`${this.#c} M ${e} ${t} Z`,this.#c;if(this.#i.length<=6){let i=this.#c.lastIndexOf("M");this.#c=`${this.#c.slice(0,i)} M ${e} ${t}`,this.#a=6}if(this.#i.length===4){let i=ae.svgRound(this.#t[10]),s=ae.svgRound(this.#t[11]);return this.#c=`${this.#c} L ${i} ${s}`,this.#a=12,this.#c}let r=[];this.#a===0&&(r.push(`M ${e} ${t}`),this.#a=6);for(let i=this.#a,s=this.#t.length;i<s;i+=6){let[o,a,c,l,u,d]=this.#t.slice(i,i+6).map(ae.svgRound);r.push(`C${o} ${a} ${c} ${l} ${u} ${d}`)}return this.#c+=r.join(" "),this.#a=this.#t.length,this.#c}getOutlines(e,t,r,i){let s=this.#n.at(-1);return s.line=new Float32Array(s.line),s.points=new Float32Array(s.points),this.#u.build(this.#n,e,t,r,this.#r,this.#s,i),this.#e=null,this.#t=null,this.#n=null,this.#c=null,this.#u}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}},j_=class n extends ae{#e;#t=0;#n;#r;#s;#i;#c;#a;#u;build(e,t,r,i,s,o,a){this.#s=t,this.#i=r,this.#c=i,this.#a=s,this.#u=o,this.#n=a??0,this.#r=e,this.#d()}setLastElement(e){return this.#r.push(e),{path:{d:this.toSVGPath()}}}removeLastElement(){return this.#r.pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){let e=[];for(let{line:t}of this.#r){if(e.push(`M${ae.svgRound(t[4])} ${ae.svgRound(t[5])}`),t.length===6){e.push("Z");continue}if(t.length===12){e.push(`L${ae.svgRound(t[10])} ${ae.svgRound(t[11])}`);continue}for(let r=6,i=t.length;r<i;r+=6){let[s,o,a,c,l,u]=t.subarray(r,r+6).map(ae.svgRound);e.push(`C${s} ${o} ${a} ${c} ${l} ${u}`)}}return e.join("")}serialize([e,t,r,i],s){let o=[],a=[],[c,l,u,d]=this.#h(),f,p,y,v,w,E,A,x,M;switch(this.#a){case 0:M=ae._rescale,f=e,p=t+i,y=r,v=-i,w=e+c*r,E=t+(1-l-d)*i,A=e+(c+u)*r,x=t+(1-l)*i;break;case 90:M=ae._rescaleAndSwap,f=e,p=t,y=r,v=i,w=e+l*r,E=t+c*i,A=e+(l+d)*r,x=t+(c+u)*i;break;case 180:M=ae._rescale,f=e+r,p=t,y=-r,v=i,w=e+(1-c-u)*r,E=t+l*i,A=e+(1-c)*r,x=t+(l+d)*i;break;case 270:M=ae._rescaleAndSwap,f=e+r,p=t+i,y=-r,v=-i,w=e+(1-l-d)*r,E=t+(1-c-u)*i,A=e+(1-l)*r,x=t+(1-c)*i;break}for(let{line:O,points:$}of this.#r)o.push(M(O,f,p,y,v,s?new Array(O.length):null)),a.push(M($,f,p,y,v,s?new Array($.length):null));return{lines:o,points:a,rect:[w,E,A,x]}}static deserialize(e,t,r,i,s,{paths:{lines:o,points:a},rotation:c,thickness:l}){let u=[],d,f,p,y,v;switch(c){case 0:v=ae._rescale,d=-e/r,f=t/i+1,p=1/r,y=-1/i;break;case 90:v=ae._rescaleAndSwap,d=-t/i,f=-e/r,p=1/i,y=1/r;break;case 180:v=ae._rescale,d=e/r+1,f=-t/i,p=-1/r,y=1/i;break;case 270:v=ae._rescaleAndSwap,d=t/i+1,f=e/r+1,p=-1/i,y=-1/r;break}if(!o){o=[];for(let E of a){let A=E.length;if(A===2){o.push(new Float32Array([NaN,NaN,NaN,NaN,E[0],E[1]]));continue}if(A===4){o.push(new Float32Array([NaN,NaN,NaN,NaN,E[0],E[1],NaN,NaN,NaN,NaN,E[2],E[3]]));continue}let x=new Float32Array(3*(A-2));o.push(x);let[M,O,$,C]=E.subarray(0,4);x.set([NaN,NaN,NaN,NaN,M,O],0);for(let T=4;T<A;T+=2){let S=E[T],k=E[T+1];x.set(ae.createBezierPoints(M,O,$,C,S,k),(T-2)*3),[M,O,$,C]=[$,C,S,k]}}}for(let E=0,A=o.length;E<A;E++)u.push({line:v(o[E].map(x=>x??NaN),d,f,p,y),points:v(a[E].map(x=>x??NaN),d,f,p,y)});let w=new n;return w.build(u,r,i,1,c,l,s),w}#l(e=this.#u){let t=this.#n+e/2*this.#c;return this.#a%180===0?[t/this.#s,t/this.#i]:[t/this.#i,t/this.#s]}#h(){let[e,t,r,i]=this.#e,[s,o]=this.#l(0);return[e+s,t+o,r-2*s,i-2*o]}#d(){let e=this.#e=new Float32Array([1/0,1/0,-1/0,-1/0]);for(let{line:i}of this.#r){if(i.length<=12){for(let a=4,c=i.length;a<c;a+=6){let[l,u]=i.subarray(a,a+2);e[0]=Math.min(e[0],l),e[1]=Math.min(e[1],u),e[2]=Math.max(e[2],l),e[3]=Math.max(e[3],u)}continue}let s=i[4],o=i[5];for(let a=6,c=i.length;a<c;a+=6){let[l,u,d,f,p,y]=i.subarray(a,a+6);pe.bezierBoundingBox(s,o,l,u,d,f,p,y,e),s=p,o=y}}let[t,r]=this.#l();e[0]=Math.min(1,Math.max(0,e[0]-t)),e[1]=Math.min(1,Math.max(0,e[1]-r)),e[2]=Math.min(1,Math.max(0,e[2]+t)),e[3]=Math.min(1,Math.max(0,e[3]+r)),e[2]-=e[0],e[3]-=e[1]}get box(){return this.#e}updateProperty(e,t){return e==="stroke-width"?this.#f(t):null}#f(e){let[t,r]=this.#l();this.#u=e;let[i,s]=this.#l(),[o,a]=[i-t,s-r],c=this.#e;return c[0]-=o,c[1]-=a,c[2]+=2*o,c[3]+=2*a,c}updateParentDimensions([e,t],r){let[i,s]=this.#l();this.#s=e,this.#i=t,this.#c=r;let[o,a]=this.#l(),c=o-i,l=a-s,u=this.#e;return u[0]-=c,u[1]-=l,u[2]+=2*c,u[3]+=2*l,u}updateRotation(e){return this.#t=e,{path:{transform:this.rotationTransform}}}get viewBox(){return this.#e.map(ae.svgRound).join(" ")}get defaultProperties(){let[e,t]=this.#e;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${ae.svgRound(e)} ${ae.svgRound(t)}`}}}get rotationTransform(){let[,,e,t]=this.#e,r=0,i=0,s=0,o=0,a=0,c=0;switch(this.#t){case 90:i=t/e,s=-e/t,a=e;break;case 180:r=-1,o=-1,a=e,c=t;break;case 270:i=-t/e,s=e/t,c=t;break;default:return""}return`matrix(${r} ${i} ${s} ${o} ${ae.svgRound(a)} ${ae.svgRound(c)})`}getPathResizingSVGProperties([e,t,r,i]){let[s,o]=this.#l(),[a,c,l,u]=this.#e;if(Math.abs(l-s)<=ae.PRECISION||Math.abs(u-o)<=ae.PRECISION){let v=e+r/2-(a+l/2),w=t+i/2-(c+u/2);return{path:{"transform-origin":`${ae.svgRound(e)} ${ae.svgRound(t)}`,transform:`${this.rotationTransform} translate(${v} ${w})`}}}let d=(r-2*s)/(l-2*s),f=(i-2*o)/(u-2*o),p=l/r,y=u/i;return{path:{"transform-origin":`${ae.svgRound(a)} ${ae.svgRound(c)}`,transform:`${this.rotationTransform} scale(${p} ${y}) translate(${ae.svgRound(s)} ${ae.svgRound(o)}) scale(${d} ${f}) translate(${ae.svgRound(-s)} ${ae.svgRound(-o)})`}}}getPathResizedSVGProperties([e,t,r,i]){let[s,o]=this.#l(),a=this.#e,[c,l,u,d]=a;if(a[0]=e,a[1]=t,a[2]=r,a[3]=i,Math.abs(u-s)<=ae.PRECISION||Math.abs(d-o)<=ae.PRECISION){let w=e+r/2-(c+u/2),E=t+i/2-(l+d/2);for(let{line:A,points:x}of this.#r)ae._translate(A,w,E,A),ae._translate(x,w,E,x);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${ae.svgRound(e)} ${ae.svgRound(t)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}let f=(r-2*s)/(u-2*s),p=(i-2*o)/(d-2*o),y=-f*(c+s)+e+s,v=-p*(l+o)+t+o;if(f!==1||p!==1||y!==0||v!==0)for(let{line:w,points:E}of this.#r)ae._rescale(w,y,v,f,p,w),ae._rescale(E,y,v,f,p,E);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${ae.svgRound(e)} ${ae.svgRound(t)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([e,t],r){let[i,s]=r,o=this.#e,a=e-o[0],c=t-o[1];if(this.#s===i&&this.#i===s)for(let{line:l,points:u}of this.#r)ae._translate(l,a,c,l),ae._translate(u,a,c,u);else{let l=this.#s/i,u=this.#i/s;this.#s=i,this.#i=s;for(let{line:d,points:f}
94of this.#r)ae._rescale(d,a,c,l,u,d),ae._rescale(f,a,c,l,u,f);o[2]*=l,o[3]*=u}return o[0]=e,o[1]=t,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${ae.svgRound(e)} ${ae.svgRound(t)}`}}}get defaultSVGProperties(){let e=this.#e;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${ae.svgRound(e[0])} ${ae.svgRound(e[1])}`,transform:this.rotationTransform||null},bbox:e}}},Zx=class n extends Xx{#e;constructor(e){super(),this.#e=e,super.updateProperties({fill:"none",stroke:Vt._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(e,t){e==="stroke-width"&&(t??=this["stroke-width"],t*=this.#e.realScale),super.updateSVGProperty(e,t)}clone(){let e=new n(this.#e);return e.updateAll(this),e}},Jx=class n extends $ne{static _type="ink";static _editorType=je.INK;static _defaultDrawingOptions=null;constructor(e){super(D(_({},e),{name:"inkEditor"})),this._willKeepAspectRatio=!0}static initialize(e,t){Vt.initialize(e,t),this._defaultDrawingOptions=new Zx(t.viewParameters)}static getDefaultDrawingOptions(e){let t=this._defaultDrawingOptions.clone();return t.updateProperties(e),t}static get supportMultipleDrawings(){return!0}static get typesMap(){return Xe(this,"typesMap",new Map([[rt.INK_THICKNESS,"stroke-width"],[rt.INK_COLOR,"stroke"],[rt.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(e,t,r,i,s){return new Qx(e,t,r,i,s,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(e,t,r,i,s,o){return j_.deserialize(e,t,r,i,s,o)}static deserialize(e,t,r){return m(this,null,function*(){let i=null;if(e instanceof gf){let{data:{inkLists:o,rect:a,rotation:c,id:l,color:u,opacity:d,borderStyle:{rawWidth:f},popupRef:p},parent:{page:{pageNumber:y}}}=e;i=e={annotationType:je.INK,color:Array.from(u),thickness:f,opacity:d,paths:{points:o},boxes:null,pageIndex:y-1,rect:a.slice(0),rotation:c,id:l,deleted:!1,popupRef:p}}let s=yield dn(n,this,"deserialize").call(this,e,t,r);return s.annotationElementId=e.id||null,s._initialData=i,s})}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();let{_drawId:e,_drawingOptions:t,parent:r}=this;t.updateSVGProperty("stroke-width"),r.drawLayer.updateProperties(e,t.toSVGProperties())}static onScaleChangingWhenDrawing(){let e=this._currentParent;e&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),e.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:e,thickness:t,opacity:r}){this._drawingOptions=n.getDefaultDrawingOptions({stroke:pe.makeHexColor(...e),"stroke-width":t,"stroke-opacity":r})}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let{lines:t,points:r,rect:i}=this.serializeDraw(e),{_drawingOptions:{stroke:s,"stroke-opacity":o,"stroke-width":a}}=this,c={annotationType:je.INK,color:Vt._colorManager.convert(s),opacity:o,thickness:a,paths:{lines:t,points:r},pageIndex:this.pageIndex,rect:i,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return e?c:this.annotationElementId&&!this.#e(c)?null:(c.id=this.annotationElementId,c)}#e(e){let{color:t,thickness:r,opacity:i,pageIndex:s}=this._initialData;return this._hasBeenMoved||this._hasBeenResized||e.color.some((o,a)=>o!==t[a])||e.thickness!==r||e.opacity!==i||e.pageIndex!==s}renderAnnotationElement(e){let{points:t,rect:r}=this.serializeDraw(!1);return e.updateEdited({rect:r,thickness:this._drawingOptions["stroke-width"],points:t}),null}},eD=class n extends Vt{#e=null;#t=null;#n=null;#r=null;#s=null;#i="";#c=null;#a=null;#u=!1;#l=!1;static _type="stamp";static _editorType=je.STAMP;constructor(e){super(D(_({},e),{name:"stampEditor"})),this.#r=e.bitmapUrl,this.#s=e.bitmapFile}static initialize(e,t){Vt.initialize(e,t)}static get supportedTypes(){return Xe(this,"supportedTypes",["apng","avif","bmp","gif","jpeg","png","svg+xml","webp","x-icon"].map(t=>`image/${t}`))}static get supportedTypesStr(){return Xe(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(e){return this.supportedTypes.includes(e)}static paste(e,t){t.pasteEditor(je.STAMP,{bitmapFile:e.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){return{type:"stamp",hasAltText:!!this.altTextData?.altText}}static computeTelemetryFinalData(e){let t=e.get("hasAltText");return{hasAltText:t.get(!0)??0,hasNoAltText:t.get(!1)??0}}#h(e,t=!1){if(!e){this.remove();return}this.#e=e.bitmap,t||(this.#t=e.id,this.#u=e.isSvg),e.file&&(this.#i=e.file.name),this.#o()}#d(){if(this.#n=null,this._uiManager.enableWaiting(!1),!!this.#c){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#e){this._editToolbar.hide(),this._uiManager.editAltText(this,!0);return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#e){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}}mlGuessAltText(e=null,t=!0){return m(this,null,function*(){if(this.hasAltTextData())return null;let{mlManager:r}=this._uiManager;if(!r)throw new Error("No ML.");if(!(yield r.isEnabledFor("altText")))throw new Error("ML isn't enabled for alt text.");let{data:i,width:s,height:o}=e||this.copyCanvas(null,null,!0).imageData,a=yield r.guess({name:"altText",request:{data:i,width:s,height:o,channels:i.length/(s*o)}});if(!a)throw new Error("No response from the AI service.");if(a.error)throw new Error("Error from the AI service.");if(a.cancel)return null;if(!a.output)throw new Error("No valid response from the AI service.");let c=a.output;return yield this.setGuessedAltText(c),t&&!this.hasAltTextData()&&(this.altTextData={alt:c,decorative:!1}),c})}
94#f(){if(this.#t){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(this.#t).then(r=>this.#h(r,!0)).finally(()=>this.#d());return}if(this.#r){let r=this.#r;this.#r=null,this._uiManager.enableWaiting(!0),this.#n=this._uiManager.imageManager.getFromUrl(r).then(i=>this.#h(i)).finally(()=>this.#d());return}if(this.#s){let r=this.#s;this.#s=null,this._uiManager.enableWaiting(!0),this.#n=this._uiManager.imageManager.getFromFile(r).then(i=>this.#h(i)).finally(()=>this.#d());return}let e=document.createElement("input");e.type="file",e.accept=n.supportedTypesStr;let t=this._uiManager._signal;this.#n=new Promise(r=>{e.addEventListener("change",()=>m(this,null,function*(){if(!e.files||e.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);let i=yield this._uiManager.imageManager.getFromFile(e.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),this.#h(i)}r()}),{signal:t}),e.addEventListener("cancel",()=>{this.remove(),r()},{signal:t})}).finally(()=>this.#d()),e.click()}remove(){this.#t&&(this.#e=null,this._uiManager.imageManager.deleteId(this.#t),this.#c?.remove(),this.#c=null,this.#a&&(clearTimeout(this.#a),this.#a=null)),super.remove()}rebuild(){if(!this.parent){this.#t&&this.#f();return}super.rebuild(),this.div!==null&&(this.#t&&this.#c===null&&this.#f(),this.isAttachedToDOM||this.parent.add(this))}onceAdded(e){this._isDraggable=!0,e&&this.div.focus()}isEmpty(){return!(this.#n||this.#e||this.#r||this.#s||this.#t)}get isResizable(){return!0}render(){if(this.div)return this.div;let e,t;if(this.width&&(e=this.x,t=this.y),super.render(),this.div.hidden=!0,this.div.setAttribute("role","figure"),this.addAltTextButton(),this.#e?this.#o():this.#f(),this.width&&!this.annotationElementId){let[r,i]=this.parentDimensions;this.setAt(e*r,t*i,this.width*r,this.height*i)}return this._uiManager.addShouldRescale(this),this.div}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;this.#a!==null&&clearTimeout(this.#a);let e=200;this.#a=setTimeout(()=>{this.#a=null,this.#g()},e)}#o(){let{div:e}=this,{width:t,height:r}=this.#e,[i,s]=this.pageDimensions,o=.75;if(this.width)t=this.width*i,r=this.height*s;else if(t>o*i||r>o*s){let u=Math.min(o*i/t,o*s/r);t*=u,r*=u}let[a,c]=this.parentDimensions;this.setDims(t*a/i,r*c/s),this._uiManager.enableWaiting(!1);let l=this.#c=document.createElement("canvas");l.setAttribute("role","img"),this.addContainer(l),this.width=t/i,this.height=r/s,this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)&&(e.hidden=!1),this.#g(),this.#l||(this.parent.addUndoableEditor(this),this.#l=!0),this._reportTelemetry({action:"inserted_image"}),this.#i&&l.setAttribute("aria-label",this.#i)}copyCanvas(e,t,r=!1){e||(e=224);let{width:i,height:s}=this.#e,o=new cf,a=this.#e,c=i,l=s,u=null;if(t){if(i>t||s>t){let $=Math.min(t/i,t/s);c=Math.floor(i*$),l=Math.floor(s*$)}u=document.createElement("canvas");let f=u.width=Math.ceil(c*o.sx),p=u.height=Math.ceil(l*o.sy);this.#u||(a=this.#p(f,p));let y=u.getContext("2d");y.filter=this._uiManager.hcmFilter;let v="white",w="#cfcfd8";this._uiManager.hcmFilter!=="none"?w="black":window.matchMedia?.("(prefers-color-scheme: dark)").matches&&(v="#8f8f9d",w="#42414d");let E=15,A=E*o.sx,x=E*o.sy,M=new OffscreenCanvas(A*2,x*2),O=M.getContext("2d");O.fillStyle=v,O.fillRect(0,0,A*2,x*2),O.fillStyle=w,O.fillRect(0,0,A,x),O.fillRect(A,x,A,x),y.fillStyle=y.createPattern(M,"repeat"),y.fillRect(0,0,f,p),y.drawImage(a,0,0,a.width,a.height,0,0,f,p)}let d=null;if(r){let f,p;if(o.symmetric&&a.width<e&&a.height<e)f=a.width,p=a.height;else if(a=this.#e,i>e||s>e){let w=Math.min(e/i,e/s);f=Math.floor(i*w),p=Math.floor(s*w),this.#u||(a=this.#p(f,p))}let v=new OffscreenCanvas(f,p).getContext("2d",{willReadFrequently:!0});v.drawImage(a,0,0,a.width,a.height,0,0,f,p),d={width:f,height:p,data:v.getImageData(0,0,f,p).data}}return{canvas:u,width:c,height:l,imageData:d}}#p(e,t){let{width:r,height:i}=this.#e,s=r,o=i,a=this.#e;for(;s>2*e||o>2*t;){let c=s,l=o;s>2*e&&(s=s>=16384?Math.floor(s/2)-1:Math.ceil(s/2)),o>2*t&&(o=o>=16384?Math.floor(o/2)-1:Math.ceil(o/2));let u=new OffscreenCanvas(s,o);u.getContext("2d").drawImage(a,0,0,c,l,0,0,s,o),a=u.transferToImageBitmap()}return a}#g(){let[e,t]=this.parentDimensions,{width:r,height:i}=this,s=new cf,o=Math.ceil(r*e*s.sx),a=Math.ceil(i*t*s.sy),c=this.#c;if(!c||c.width===o&&c.height===a)return;c.width=o,c.height=a;let l=this.#u?this.#e:this.#p(o,a),u=c.getContext("2d");u.filter=this._uiManager.hcmFilter,u.drawImage(l,0,0,l.width,l.height,0,0,o,a)}getImageForAltText(){return this.#c}#m(e){if(e){if(this.#u){let i=this._uiManager.imageManager.getSvgUrl(this.#t);if(i)return i}let t=document.createElement("canvas");return{width:t.width,height:t.height}=this.#e,t.getContext("2d").drawImage(this.#e,0,0),t.toDataURL()}if(this.#u){let[t,r]=this.pageDimensions,i=Math.round(this.width*t*la.PDF_TO_CSS_UNITS),s=Math.round(this.height*r*la.PDF_TO_CSS_UNITS),o=new OffscreenCanvas(i,s);return o.getContext("2d").drawImage(this.#e,0,0,this.#e.width,this.#e.height,0,0,i,s),o.transferToImageBitmap()}return structuredClone(this.#e)}static deserialize(e,t,r){return m(this,null,function*(){let i=null;if(e instanceof N_){let{data:{rect:y,rotation:v,id:w,structParent:E,popupRef:A},container:x,parent:{page:{pageNumber:M}}}=e,O=x.querySelector("canvas"),$=r.imageManager.getFromCanvas(x.id,O);O.remove();let C=(yield t._structTree.getAriaAttributes(`${rD}${w}`))?.get("aria-label")||"";i=e={annotationType:je.STAMP,bitmapId:$.id,bitmap:$.bitmap,pageIndex:M-1,rect:y.slice(0),rotation:v,id:w,deleted:!1,accessibilityData:{decorative:!1,altText:C},isSvg:!1,structParent:E,popupRef:A}}let s=yield dn(n,this,"deserialize").call(this,e,t,r),{rect:o,bitmap:a,bitmapUrl:c,bitmapId:l,isSvg:u,accessibilityData:d}=e;l&&r.imageManager.isValidId(l)?(s.#t=l,a&&(s.#e=a)):s.#r=c,s.#u=u;let[f,p]=s.pageDimensions;return s.width=(o[2]-o[0])/f,s.height=(o[3]-o[1])/p,s.annotationElementId=e.id||null,d&&(s.altTextData=d),s._initialData=i,s.#l=!!i,s})}serialize(e=!1,t=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let r={annotationType:je.STAMP,bitmapId:this.#t,pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:this.#u,structTreeParentId:this._structTreeParentId};if(e)return r.bitmapUrl=this.#m(!0),r.accessibilityData=this.serializeAltText(!0),r;let{decorative:i,altText:s}=this.serializeAltText(!1);if(!i&&s&&(r.accessibilityData={type:"Figure",alt:s}
94),this.annotationElementId){let a=this.#y(r);if(a.isSame)return null;a.isSameAltText?delete r.accessibilityData:r.accessibilityData.structParent=this._initialData.structParent??-1}if(r.id=this.annotationElementId,t===null)return r;t.stamps||=new Map;let o=this.#u?(r.rect[2]-r.rect[0])*(r.rect[3]-r.rect[1]):null;if(!t.stamps.has(this.#t))t.stamps.set(this.#t,{area:o,serialized:r}),r.bitmap=this.#m(!1);else if(this.#u){let a=t.stamps.get(this.#t);o>a.area&&(a.area=o,a.serialized.bitmap.close(),a.serialized.bitmap=this.#m(!1))}return r}#y(e){let{pageIndex:t,accessibilityData:{altText:r}}=this._initialData,i=e.pageIndex===t,s=(e.accessibilityData?.alt||"")===r;return{isSame:!this._hasBeenMoved&&!this._hasBeenResized&&i&&s,isSameAltText:s}}renderAnnotationElement(e){return e.updateEdited({rect:this.getRect(0,0)}),null}},Une=(()=>{class n{#e;#t=!1;#n=null;#r=null;#s=null;#i=new Map;#c=!1;#a=!1;#u=!1;#l=null;#h=null;#d=null;#f=null;#o;static _initialized=!1;static#p=new Map([Wx,Jx,eD,V_].map(t=>[t._editorType,t]));constructor({uiManager:t,pageIndex:r,div:i,structTreeLayer:s,accessibilityManager:o,annotationLayer:a,drawLayer:c,textLayer:l,viewport:u,l10n:d}){let f=[...n.#p.values()];if(!n._initialized){n._initialized=!0;for(let p of f)p.initialize(d,t)}t.registerEditorTypes(f),this.#o=t,this.pageIndex=r,this.div=i,this.#e=o,this.#n=a,this.viewport=u,this.#d=l,this.drawLayer=c,this._structTree=s,this.#o.addLayer(this)}get isEmpty(){return this.#i.size===0}get isInvisible(){return this.isEmpty&&this.#o.getMode()===je.NONE}updateToolbar(t){this.#o.updateToolbar(t)}updateMode(t=this.#o.getMode()){switch(this.#_(),t){case je.NONE:this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case je.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case je.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);let{classList:r}=this.div;for(let i of n.#p.values())r.toggle(`${i._type}Editing`,t===i._editorType);this.div.hidden=!1}hasTextLayer(t){return t===this.#d?.div}setEditingState(t){this.#o.setEditingState(t)}addCommands(t){this.#o.addCommands(t)}cleanUndoStack(t){this.#o.cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){this.#n?.div.classList.toggle("disabled",!t)}enable(){return m(this,null,function*(){this.#u=!0,this.div.tabIndex=0,this.togglePointerEvents(!0);let t=new Set;for(let i of this.#i.values())i.enableEditing(),i.show(!0),i.annotationElementId&&(this.#o.removeChangedExistingAnnotation(i),t.add(i.annotationElementId));if(!this.#n){this.#u=!1;return}let r=this.#n.getEditableAnnotations();for(let i of r){if(i.hide(),this.#o.isDeletedAnnotationElement(i.data.id)||t.has(i.data.id))continue;let s=yield this.deserialize(i);s&&(this.addOrRebuild(s),s.enableEditing())}this.#u=!1})}disable(){this.#a=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1);let t=new Map,r=new Map;for(let s of this.#i.values())if(s.disableEditing(),!!s.annotationElementId){if(s.seri
94alize()!==null){t.set(s.annotationElementId,s);continue}else r.set(s.annotationElementId,s);this.getEditableAnnotation(s.annotationElementId)?.show(),s.remove()}if(this.#n){let s=this.#n.getEditableAnnotations();for(let o of s){let{id:a}=o.data;if(this.#o.isDeletedAnnotationElement(a))continue;let c=r.get(a);if(c){c.resetAnnotationElement(o),c.show(!1),o.show();continue}c=t.get(a),c&&(this.#o.addChangedExistingAnnotation(c),c.renderAnnotationElement(o)&&c.show(!1)),o.show()}}this.#_(),this.isEmpty&&(this.div.hidden=!0);let{classList:i}=this.div;for(let s of n.#p.values())i.remove(`${s._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),this.#a=!1}getEditableAnnotation(t){return this.#n?.getEditableAnnotation(t)||null}setActiveEditor(t){this.#o.getActive()!==t&&this.#o.setActiveEditor(t)}enableTextSelection(){if(this.div.tabIndex=-1,this.#d?.div&&!this.#f){this.#f=new AbortController;let t=this.#o.combinedSignal(this.#f);this.#d.div.addEventListener("pointerdown",this.#g.bind(this),{signal:t}),this.#d.div.classList.add("highlighting")}}disableTextSelection(){this.div.tabIndex=0,this.#d?.div&&this.#f&&(this.#f.abort(),this.#f=null,this.#d.div.classList.remove("highlighting"))}#g(t){this.#o.unselectAll();let{target:r}=t;if(r===this.#d.div||(r.getAttribute("role")==="img"||r.classList.contains("endOfContent"))&&this.#d.div.contains(r)){let{isMac:i}=Cn.platform;if(t.button!==0||t.ctrlKey&&i)return;this.#o.showAllEditors("highlight",!0,!0),this.#d.div.classList.add("free"),this.toggleDrawing(),V_.startHighlighting(this,this.#o.direction==="ltr",{target:this.#d.div,x:t.x,y:t.y}),this.#d.div.addEventListener("pointerup",()=>{this.#d.div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:this.#o._signal}),t.preventDefault()}}enableClick(){if(this.#r)return;this.#r=new AbortController;let t=this.#o.combinedSignal(this.#r);this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t});let r=this.pointerup.bind(this);this.div.addEventListener("pointerup",r,{signal:t}),this.div.addEventListener("pointercancel",r,{signal:t})}disableClick(){this.#r?.abort(),this.#r=null}attach(t){this.#i.set(t.id,t);let{annotationElementId:r}=t;r&&this.#o.isDeletedAnnotationElement(r)&&this.#o.removeDeletedAnnotationElement(t)}detach(t){this.#i.delete(t.id),this.#e?.removePointerInTextLayer(t.contentDiv),!this.#a&&t.annotationElementId&&this.#o.addDeletedAnnotationElement(t)}remove(t){this.detach(t),this.#o.removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){t.parent!==this&&(t.parent&&t.annotationElementId&&(this.#o.addDeletedAnnotationElement(t.annotationElementId),Vt.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),t.parent?.detach(t),t.setParent(this),t.div&&t.isAttachedToDOM&&(t.div.remove(),this.div.append(t.div)))}add(t){if(!(t.parent===this&&t.isAttachedToDOM)){if(this.changeParent(t),this.#o.addEditor(t),this.attach(t),!t.isAttachedToDOM){let r=t.render();this.div.append(r),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!this.#u),this.#o.addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){if(!t.isAttachedToDOM)return;let{activeElement:r}=document;t.div.contains(r)&&!this.#s&&(t._focusEventsAllowed=!1,this.#s=setTimeout(()=>{this.#s=null,t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this.#o._signal}),r.focus())},0)),t._structTreeParentId=this.#e?.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||=this,t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){let r=()=>t._uiManager.rebuild(t),i=()=>{t.remove()};this.addCommands({cmd:r,undo:i,mustExec:!1})}getNextId(){return this.#o.getId()}get#m(){return n.#p.get(this.#o.getMode())}combinedSignal(t){return this.#o.combinedSignal(t)}#y(t){let r=this.#m;return r?new r.prototype.constructor(t):null}canCreateNewEmptyEditor(){return this.#m?.canCreateNewEmptyEditor()}pasteEditor(t,r){this.#o.updateToolbar(t),this.#o.updateMode(t);let{offsetX:i,offsetY:s}=this.#b(),o=this.getNextId(),a=this.#y(_({parent:this,id:o,x:i,y:s,uiManager:this.#o,isCentered:!0},r));a&&this.add(a)}deserialize(t){return m(this,null,function*(){return(yield n.#p.get(t.annotationType??t.annotationEditorType)?.deserialize(t,this,this.#o))||null})}createAndAddNewEditor(t,r,i={}){let s=this.getNextId(),o=this.#y(_({parent:this,id:s,x:t.offsetX,y:t.offsetY,uiManager:this.#o,isCentered:r},i));return o&&this.add(o),o}#b(){let{x:t,y:r,width:i,height:s}=this.div.getBoundingClientRect(),o=Math.max(0,t),a=Math.max(0,r),c=Math.min(window.innerWidth,t+i),l=Math.min(window.innerHeight,r+s),u=(o+c)/2-t,d=(a+l)/2-r,[f,p]=this.viewport.rotation%180===0?[u,d]:[d,u];return{offsetX:f,offsetY:p}}addNewEditor(){this.createAndAddNewEditor(this.#b(),!0)}setSelected(t){this.#o.setSelected(t)}toggleSelected(t){this.#o.toggleSelected(t)}unselect(t){this.#o.unselect(t)}pointerup(t){let{isMac:r}=Cn.platform;if(!(t.button!==0||t.ctrlKey&&r)&&t.target===this.div&&this.#c&&(this.#c=!1,!(this.#m?.isDrawer&&this.#m.supp
94ortMultipleDrawings))){if(!this.#t){this.#t=!0;return}if(this.#o.getMode()===je.STAMP){this.#o.unselectAll();return}this.createAndAddNewEditor(t,!1)}}pointerdown(t){if(this.#o.getMode()===je.HIGHLIGHT&&this.enableTextSelection(),this.#c){this.#c=!1;return}let{isMac:r}=Cn.platform;if(t.button!==0||t.ctrlKey&&r||t.target!==this.div)return;if(this.#c=!0,this.#m?.isDrawer){this.startDrawingSession(t);return}let i=this.#o.getActive();this.#t=!i||i.isEmpty()}startDrawingSession(t){if(this.div.focus(),this.#l){this.#m.startDrawing(this,this.#o,!1,t);return}this.#o.setCurrentDrawingSession(this),this.#l=new AbortController;let r=this.#o.combinedSignal(this.#l);this.div.addEventListener("blur",({relatedTarget:i})=>{i&&!this.div.contains(i)&&(this.#h=null,this.commitOrRemove())},{signal:r}),this.#m.startDrawing(this,this.#o,!1,t)}pause(t){if(t){let{activeElement:r}=document;this.div.contains(r)&&(this.#h=r);return}this.#h&&setTimeout(()=>{this.#h?.focus(),this.#h=null},0)}endDrawingSession(t=!1){return this.#l?(this.#o.setCurrentDrawingSession(null),this.#l.abort(),this.#l=null,this.#h=null,this.#m.endDrawing(t)):null}findNewParent(t,r,i){let s=this.#o.findParent(r,i);return s===null||s===this?!1:(s.changeParent(t),!0)}commitOrRemove(){return this.#l?(this.endDrawingSession(),!0):!1}onScaleChanging(){this.#l&&this.#m.onScaleChangingWhenDrawing(this)}destroy(){this.commitOrRemove(),this.#o.getActive()?.parent===this&&(this.#o.commitOrRemove(),this.#o.setActiveEditor(null)),this.#s&&(clearTimeout(this.#s),this.#s=null);for(let t of this.#i.values())this.#e?.removePointerInTextLayer(t.contentDiv),t.setParent(null),t.isAttachedToDOM=!1,t.div.remove();this.div=null,this.#i.clear(),this.#o.removeLayer(this)}#_(){for(let t of this.#i.values())t.isEmpty()&&t.remove()}render({viewport:t}){this.viewport=t,Tc(this.div,t);for(let r of this.#o.getEditors(this.pageIndex))this.add(r),r.rebuild();this.updateMode()}update({viewport:t}){this.#o.commitOrRemove(),this.#_();let r=this.viewport.rotation,i=t.rotation;if(this.viewport=t,Tc(this.div,{rotation:i}),r!==i)for(let s of this.#i.values())s.rotate(i)}get pageDimensions(){let{pageWidth:t,pageHeight:r}=this.viewport.rawDims;return[t,r]}get scale(){return this.#o.viewParameters.realScale}}return n})(),tD=class n{#e=null;#t=0;#n=new Map;#r=new Map;constructor({pageIndex:e}){this.pageIndex=e}setParent(e){if(!this.#e){this.#e=e;return}if(this.#e!==e){if(this.#n.size>0)for(let t of this.#n.values())t.remove(),e.append(t);this.#e=e}}static get _svgFactory(){return Xe(this,"_svgFactory",new pf)}static#s(e,[t,r,i,s]){let{style:o}=e;o.top=`${100*r}%`,o.left=`${100*t}%`,o.width=`${100*i}%`,o.height=`${100*s}%`}#i(){let e=n._svgFactory.create(1,1,!0);return this.#e.append(e),e.setAttribute("aria-hidden",!0),e}#c(e,t){let r=n._svgFactory.createElement("clipPath");e.append(r);let i=`clip_${t}`;r.setAttribute("id",i),r.setAttribute("clipPathUnits","objectBoundingBox");let s=n._svgFactory.createElement("use");return r.append(s),s.setAttribute("href",`#${t}`),s.classList.add("clip"),i}#a(e,t){for(let[r,i]of Object.entries(t))i===null?e.removeAttribute(r):e.setAttribute(r,i)}draw(e,t=!1,r=!1){let i=this.#t++,s=this.#i(),o=n._svgFactory.createElement("defs");s.append(o);let a=n._svgFactory.createElement("path");o.append(a);let c=`path_p${this.pageIndex}_${i}`;a.setAttribute("id",c),a.setAttribute("vector-effect","non-scaling-stroke"),t&&this.#r.set(i,a);let l=r?this.#c(o,c):null,u=n._svgFactory.createElement("use");return s.append(u),u.setAttribute("href",`#${c}`),this.updateProperties(s,e),this.#n.set(i,s),{id:i,clipPathId:`url(#${l})`}}drawOutline(e,t){let r=this.#t++,i=this.#i(),s=n._svgFactory.createElement("defs");i.append(s);let o=n._svgFactory.createElement("path");s.append(o);let a=`path_p${this.pageIndex}_${r}`;o.setAttribute("id",a),o.setAttribute("vector-effect","non-scaling-stroke");let c;if(t){let d=n._svgFactory.createElement("mask");s.append(d),c=`mask_p${this.pageIndex}_${r}`,d.setAttribute("id",c),d.setAttribute("maskUnits","objectBoundingBox");let f=n._svgFactory.createElement("rect");d.append(f),f.setAttribute("width","1"),f.setAttribute("height","1"),f.setAttribute("fill","white");let p=n._svgFactory.createElement("use");d.append(p),p.setAttribute("href",`#${a}`),p.setAttribute("stroke","none"),p.setAttribute("fill","black"),p.setAttribute("fill-rule","nonzero"),p.classList.add("mask")}let l=n._svgFactory.createElement("use");i.append(l),l.setAttribute("href",`#${a}`),c&&l.setAttribute("mask",`url(#${c})`);let u=l.cloneNode();return i.append(u),l.classList.add("mainOutline"),u.classList.add("secondaryOutline"),this.updateProperties(i,e),this.#n.set(r,i),r}finalizeDraw(e,t){this.#r.delete(e),this.updateProperties(e,t)}updateProperties(e,t){if(!t)return;let{root:r,bbox:i,rootClass:s,path:o}=t,a=typeof e=="number"?this.#n.get(e):e;if(a){if(r&&this.#a(a,r),i&&n.#s(a,i),s){let{classList:c}=a;for(let[l,u]of Object.entries(s))c.toggle(l,u)}if(o){let l=a.firstChild.firstChild;this.#a(l,o)}}}updateParent(e,t){if(t===this)return;let r=this.#n.get(e);r&&(t.#e.append(r),this.#n.delete(e),t.#n.set(e,r))}remove(e){this.#r.delete(e),this.#e!==null&&(this.#n.get(e).remove(),this.#n.delete(e))}destroy(){this.#e=null;for(let e of this.#n.values())e.remove();this.#n.clear(),this.#r.clear()}};globalThis.pdfjsTestingUtils={HighlightOutliner:yf};var sIe=De.AbortException,oIe=De.AnnotationEditorLayer,aIe=De.AnnotationEditorParamsType,cIe=De.AnnotationEditorType,lIe=De.AnnotationEditorUIManager,uIe=De.AnnotationLayer,dIe=De.AnnotationMode,hIe=De.ColorPicker,fIe=De.DOMSVGFactory,pIe=De.DrawLayer,mIe=De.FeatureTest,_$=De.GlobalWorkerOptions,gIe=De.ImageKind,yIe=De.InvalidPDFException,_Ie=De.MissingPDFException,vIe=De.OPS,bIe
94=De.OutputScale,wIe=De.PDFDataRangeTransport,EIe=De.PDFDateString,IIe=De.PDFWorker,TIe=De.PasswordResponses,AIe=De.PermissionFlag,CIe=De.PixelsPerInch,SIe=De.RenderingCancelledException,xIe=De.TextLayer,DIe=De.TouchManager,RIe=De.UnexpectedResponseException,kIe=De.Util,PIe=De.VerbosityLevel,MIe=De.XfaLayer,NIe=De.build,OIe=De.createValidAbsoluteUrl,LIe=De.fetchData,v$=De.getDocument,FIe=De.getFilenameFromUrl,VIe=De.getPdfFilenameFromUrl,jIe=De.getXfaPageViewport,$Ie=De.isDataScheme,UIe=De.isPdfFile,BIe=De.noContextMenu,HIe=De.normalizeUnicode,qIe=De.setLayerDimensions,zIe=De.shadow,GIe=De.stopEvent,WIe=De.version;var K_=class{constructor(e){Object.defineProperty(this,"pageContent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metadata",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.pageContent=e.pageContent!==void 0?e.pageContent.toString():"",this.metadata=e.metadata??{},this.id=e.id}};var fa={};Jk(fa,{BRAND:()=>pre,DIRTY:()=>Sc,EMPTY_PATH:()=>Gne,INVALID:()=>Ie,NEVER:()=>Zre,OK:()=>qn,ParseStatus:()=>Sn,Schema:()=>qe,ZodAny:()=>Q_,ZodArray:()=>Ef,ZodBigInt:()=>lD,ZodBoolean:()=>uD,ZodBranded:()=>If,ZodCatch:()=>bD,ZodDate:()=>dD,ZodDefault:()=>vD,ZodDiscriminatedUnion:()=>Z_,ZodEffects:()=>Ou,ZodEnum:()=>nv,ZodError:()=>vs,ZodFirstPartyTypeKind:()=>K,ZodFunction:()=>ev,ZodIntersection:()=>mD,ZodIssueCode:()=>W,ZodLazy:()=>gD,ZodLiteral:()=>yD,ZodMap:()=>D$,ZodNaN:()=>P$,ZodNativeEnum:()=>_D,ZodNever:()=>xc,ZodNull:()=>fD,ZodNullable:()=>Lu,ZodNumber:()=>cD,ZodObject:()=>Mu,ZodOptional:()=>ha,ZodParsedType:()=>te,ZodPipeline:()=>Tf,ZodPromise:()=>rv,ZodReadonly:()=>wD,ZodRecord:()=>J_,ZodSchema:()=>qe,ZodSet:()=>R$,ZodString:()=>tv,ZodSymbol:()=>S$,ZodTransformer:()=>Ou,ZodTuple:()=>Nu,ZodType:()=>qe,ZodUndefined:()=>hD,ZodUnion:()=>pD,ZodUnknown:()=>wf,ZodVoid:()=>x$,addIssueToContext:()=>J,any:()=>Ire,array:()=>Sre,bigint:()=>_re,boolean:()=>L$,coerce:()=>Qre,custom:()=>M$,date:()=>vre,datetimeRegex:()=>C$,defaultErrorMap:()=>po,discriminatedUnion:()=>kre,effect:()=>Hre,enum:()=>$re,function:()=>Fre,getErrorMap:()=>Ru,getParsedType:()=>_s,instanceof:()=>gre,intersection:()=>Pre,isAborted:()=>Y_,isAsync:()=>ku,isDirty:()=>X_,isValid:()=>da,late:()=>mre,lazy:()=>Vre,literal:()=>jre,makeIssue:()=>bf,map:()=>Ore,nan:()=>yre,nativeEnum:()=>Ure,never:()=>Are,null:()=>Ere,nullable:()=>zre,number:()=>O$,object:()=>xre,objectUtil:()=>b$,oboolean:()=>Xre,onumber:()=>Yre,optional:()=>qre,ostring:()=>Kre,pipeline:()=>Wre,preprocess:()=>Gre,promise:()=>Bre,quotelessJson:()=>Hne,record:()=>Nre,set:()=>Lre,setErrorMap:()=>zne,strictObject:()=>Dre,string:()=>N$,symbol:()=>bre,transformer:()=>Hre,tuple:()=>Mre,undefined:()=>wre,union:()=>Rre,unknown:()=>Tre,util:()=>Je,void:()=>Cre});var Je;(function(n){n.assertEqual=i=>{};function e(i){}n.assertIs=e;function t(i){throw new Error}n.assertNever=t,n.arrayToEnum=i=>{let s={};for(let o of i)s[o]=o;return s},n.getValidEnumValues=i=>{let s=n.objectKeys(i).filter(a=>typeof i[i[a]]!="number"),o={};for(let a of s)o[a]=i[a];return n.objectValues(o)},n.objectValues=i=>n.objectKeys(i).map(function(s){return i[s]}),n.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{let s=[];for(let o in i)Object.prototype.hasOwnProperty.call(i,o)&&s.push(o);return s},n.find=(i,s)=>{for(let o of i)if(s(o))return o},n.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function r(i,s=" | "){return i.map(o=>typeof o=="string"?`'${o}'`:o).join(s)}n.joinValues=r,n.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(Je||(Je={}));var b$=function(n){return n.mergeShapes=(e,t)=>_(_({},e),t),n}(b$||{}),te=Je.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),_s=n=>{switch(typeof n){case"undefined":return te.undefined;case"string":return te.string;case"number":return Number.isNaN(n)?te.nan:te.number;case"boolean":return te.boolean;case"function":return te.function;case"bigint":return te.bigint;case"symbol":return te.symbol;case"object":return Array.isArray(n)?te.array:n===null?te.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?te.promise:typeof Map<"u"&&n instanceof Map?te.map:typeof Set<"u"&&n instanceof Set?te.set:typeof Date<"u"&&n instanceof Date?te.date:te.object;default:return te.unknown}};
vendor: 4,779 bytes, line 94
94var W=Je.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Hne=n=>JSON.stringify(n,null,2).replace(/"([^"]+)":/g,"$1:"),vs=(()=>{class n extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=i=>{this.issues=[...this.issues,i]},this.addIssues=(i=[])=>{this.issues=[...this.issues,...i]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=t}format(t){let r=t||function(o){return o.message},i={_errors:[]},s=o=>{for(let a of o.issues)if(a.code==="invalid_union")a.unionErrors.map(s);else if(a.code==="invalid_return_type")s(a.returnTypeError);else if(a.code==="invalid_arguments")s(a.argumentsError);else if(a.path.length===0)i._errors.push(r(a));else{let c=i,l=0;for(;l<a.path.length;){let u=a.path[l];l===a.path.length-1?(c[u]=c[u]||{_errors:[]},c[u]._errors.push(r(a))):c[u]=c[u]||{_errors:[]},c=c[u],l++}}};return s(this),i}static assert(t){if(!(t instanceof n))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Je.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=r=>r.message){let r={},i=[];for(let s of this.issues)if(s.path.length>0){let o=s.path[0];r[o]=r[o]||[],r[o].push(t(s))}else i.push(t(s));return{formErrors:i,fieldErrors:r}}get formErrors(){return this.flatten()}}return n.create=e=>new n(e),n})();var qne=(n,e)=>{let t;switch(n.code){case W.invalid_type:n.received===te.undefined?t="Required":t=`Expected ${n.expected}, received ${n.received}`;break;case W.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(n.expected,Je.jsonStringifyReplacer)}`;break;case W.unrecognized_keys:t=`Unrecognized key(s) in object: ${Je.joinValues(n.keys,", ")}`;break;case W.invalid_union:t="Invalid input";break;case W.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Je.joinValues(n.options)}`;break;case W.invalid_enum_value:t=`Invalid enum value. Expected ${Je.joinValues(n.options)}, received '${n.received}'`;break;case W.invalid_arguments:t="Invalid function arguments";break;case W.invalid_return_type:t="Invalid function return type";break;case W.invalid_date:t="Invalid date";break;case W.invalid_string:typeof n.validation=="object"?"includes"in n.validation?(t=`Invalid input: must include "${n.validation.includes}"`,typeof n.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${n.validation.position}`)):"startsWith"in n.validation?t=`Invalid input: must start with "${n.validation.startsWith}"`:"endsWith"in n.validation?t=`Invalid input: must end with "${n.validation.endsWith}"`:Je.assertNever(n.validation):n.validation!=="regex"?t=`Invalid ${n.validation}`:t="Invalid";break;case W.too_small:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at least":"more than"} ${n.minimum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at least":"over"} ${n.minimum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="bigint"?t=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(n.minimum))}`:t="Invalid input";break;case W.too_big:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at most":"less than"} ${n.maximum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at most":"under"} ${n.maximum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="bigint"?t=`BigInt must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly":n.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(n.maximum))}`:t="Invalid input";break;case W.custom:t="Invalid input";break;case W.invalid_intersection_types:t="Intersection results could not be merged";break;case W.not_multiple_of:t=`Number must be a multiple of ${n.multipleOf}`;break;case W.not_finite:t="Number must be finite";break;default:t=e.defaultError,Je.assertNever(n)}return{message:t}},po=qne;var w$=po;function zne(n){w$=n}function Ru(){return w$}var bf=n=>
94{let{data:e,path:t,errorMaps:r,issueData:i}=n,s=[...t,...i.path||[]],o=D(_({},i),{path:s});if(i.message!==void 0)return D(_({},i),{path:s,message:i.message});let a="",c=r.filter(l=>!!l).slice().reverse();for(let l of c)a=l(o,{data:e,defaultError:a}).message;return D(_({},i),{path:s,message:a})},Gne=[];function J(n,e){let t=Ru(),r=bf({issueData:e,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,t,t===po?void 0:po].filter(i=>!!i)});n.common.issues.push(r)}var Sn=class n{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){let r=[];for(let i of t){if(i.status==="aborted")return Ie;i.status==="dirty"&&e.dirty(),r.push(i.value)}return{status:e.value,value:r}}static mergeObjectAsync(e,t){return m(this,null,function*(){let r=[];for(let i of t){let s=yield i.key,o=yield i.value;r.push({key:s,value:o})}return n.mergeObjectSync(e,r)})}static mergeObjectSync(e,t){let r={};for(let i of t){let{key:s,value:o}=i;if(s.status==="aborted"||o.status==="aborted")return Ie;s.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof o.value<"u"||i.alwaysSet)&&(r[s.value]=o.value)}return{status:e.value,value:r}}},Ie=Object.freeze({status:"aborted"}),Sc=n=>({status:"dirty",value:n}),qn=n=>({status:"valid",value:n}),Y_=n=>n.status==="aborted",X_=n=>n.status==="dirty",da=n=>n.status==="valid",ku=n=>typeof Promise<"u"&&n instanceof Promise;var he=function(n){return n.errToObj=e=>typeof e=="string"?{message:e}:e||{},n.toString=e=>typeof e=="string"?e:e?.message,n}(he||{});
94var ei=class{constructor(e,t,r,i){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=i}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},E$=(n,e)=>{if(da(e))return{success:!0,data:e.value};if(!n.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let t=new vs(n.common.issues);return this._error=t,this._error}}};function Fe(n){if(!n)return{};let{errorMap:e,invalid_type_error:t,required_error:r,description:i}=n;if(e&&(t||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(o,a)=>{let{message:c}=n;return o.code==="invalid_enum_value"?{message:c??a.defaultError}:typeof a.data>"u"?{message:c??r??a.defaultError}:o.code!=="invalid_type"?{message:a.defaultError}:{message:c??t??a.defaultError}},description:i}}var qe=class{get description(){return this._def.description}_getType(e){return _s(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:_s(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Sn,ctx:{common:e.parent.common,data:e.data,parsedType:_s(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(ku(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){let r={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:_s(e)},i=this._parseSync({data:e,path:r.path,parent:r});return E$(r,i)}"~validate"(e){let t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:_s(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:t});return da(r)?{value:r.value}:{issues:t.common.issues}}catch(r){r?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(r=>da(r)?{value:r.value}:{issues:t.common.issues})}parseAsync(e,t){return m(this,null,function*(){let r=yield this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error})}safeParseAsync(e,t){return m(this,null,function*(){let r={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:_s(e)},i=this._parse({data:e,path:r.path,parent:r}),s=yield ku(i)?i:Promise.resolve(i);return E$(r,s)})}refine(e,t){let r=i=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(i):t;return this._refinement((i,s)=>{let o=e(i),a=()=>s.addIssue(_({code:W.custom},r(i)));return typeof Promise<"u"&&o instanceof Promise?o.then(c=>c?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(e,t){return this._refinement((r,i)=>e(r)?!0:(i.addIssue(typeof t=="function"?t(r,i):t),!1))}_refinement(e){return new Ou({schema:this,typeName:K.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return ha.create(this,this._def)}nullable(){return Lu.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ef.create(this)}promise(){return rv.create(this,this._def)}or(e){return pD.create([this,e],this._def)}and(e){return mD.create(this,e,this._def)}transform(e){return new Ou(D(_({},Fe(this._def)),{schema:this,typeName:K.ZodEffects,effect:{type:"transform",transform:e}}))}default(e){let t=typeof e=="function"?e:()=>e;return new vD(D(_({},Fe(this._def)),{innerType:this,defaultValue:t,typeName:K.ZodDefault}))}brand(){return new If(_({typeName:K.ZodBranded,type:this},Fe(this._def)))}catch(e){let t=typeof e=="function"?e:()=>e;return new bD(D(_({},Fe(this._def)),{innerType:this,catchValue:t,typeName:K.ZodCatch}))}describe(e){let t=this.constructor;return new t(D(_({},this._def),{description:e}))}pipe(e){return Tf.create(this,e)}readonly(){return wD.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Wne=/^c[^\s-]{8,}
vendor: 4,593 bytes, line 94
94$/i,Kne=/^[0-9a-z]+$/,Yne=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Xne=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Qne=/^[a-z0-9_-]{21}$/i,Zne=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Jne=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,ere=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,tre="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",oD,nre=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,rre=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ire=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,sre=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,ore=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,are=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,T$="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",cre=new RegExp(`^${T$}$`);function A$(n){let e="[0-5]\\d";n.precision?e=`${e}\\.\\d{${n.precision}}`:n.precision==null&&(e=`${e}(\\.\\d+)?`);let t=n.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function lre(n){return new RegExp(`^${A$(n)}$`)}function C$(n){let e=`${T$}T${A$(n)}`,t=[];return t.push(n.local?"Z?":"Z"),n.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function ure(n,e){return!!((e==="v4"||!e)&&nre.test(n)||(e==="v6"||!e)&&ire.test(n))}function dre(n,e){if(!Zne.test(n))return!1;try{let[t]=n.split(".");if(!t)return!1;let r=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),i=JSON.parse(atob(r));return!(typeof i!="object"||i===null||"typ"in i&&i?.typ!=="JWT"||!i.alg||e&&i.alg!==e)}catch{return!1}}function hre(n,e){return!!((e==="v4"||!e)&&rre.test(n)||(e==="v6"||!e)&&sre.test(n))}var tv=(()=>{class n extends qe{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==te.string){let o=this._getOrReturnCtx(t);return J(o,{code:W.invalid_type,expected:te.string,received:o.parsedType}),Ie}let i=new Sn,s;for(let o of this._def.checks)if(o.kind==="min")t.data.length<o.value&&(s=this._getOrReturnCtx(t,s),J(s,{code:W.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),i.dirty());else if(o.kind==="max")t.data.length>o.value&&(s=this._getOrReturnCtx(t,s),J(s,{code:W.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),i.dirty());else if(o.kind==="length"){let a=t.data.length>o.value,c=t.data.length<o.value;(a||c)&&(s=this._getOrReturnCtx(t,s),a?J(s,{code:W.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}):c&&J(s,{code:W.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}),i.dirty())}else if(o.kind==="email")ere.test(t.data)||(s=this._getOrReturnCtx(t,s),J(s,{validation:"email",code:W.invali
94d_string,message:o.message}),i.dirty());else if(o.kind==="emoji")oD||(oD=new RegExp(tre,"u")),oD.test(t.data)||(s=this._getOrReturnCtx(t,s),J(s,{validation:"emoji",code:W.invalid_string,message:o.message}),i.dirty());else if(o.kind==="uuid")Xne.test(t.data)||(s=this._getOrReturnCtx(t,s),J(s,{validation:"uuid",code:W.invalid_string,message:o.message}),i.dirty());else if(o.kind==="nanoid")Qne.test(t.data)||(s=this._getOrReturnCtx(t,s),J(s,{validation:"nanoid",code:W.invalid_string,message:o.message}),i.dirty());else if(o.kind==="cuid")Wne.test(t.data)||(s=this._getOrReturnCtx(t,s),J(s,{validation:"cuid",code:W.invalid_string,message:o.message}),i.dirty());else if(o.kind==="cuid2")Kne.test(t.data)||(s=this._getOrReturnCtx(t,s),J(s,{validation:"cuid2",code:W.invalid_string,message:o.message}),i.dirty());else if(o.kind==="ulid")Yne.test(t.data)||(s=this._getOrReturnCtx(t,s),J(s,{validation:"ulid",code:W.invalid_string,message:o.message}),i.dirty());else if(o.kind==="url")try{new URL(t.data)}catch{s=this._getOrReturnCtx(t,s),J(s,{validation:"url",code:W.invalid_string,message:o.message}),i.dirty()}else o.kind==="regex"?(o.regex.lastIndex=0,o.regex.test(t.data)||(s=this._getOrReturnCtx(t,s),J(s,{validation:"regex",code:W.invalid_string,message:o.message}),i.dirty())):o.kind==="trim"?t.data=t.data.trim():o.kind==="includes"?t.data.includes(o.value,o.position)||(s=this._getOrReturnCtx(t,s),J(s,{code:W.invalid_string,validation:{includes:o.value,position:o.position},message:o.message}),i.dirty()):o.kind==="toLowerCase"?t.data=t.data.toLowerCase():o.kind==="toUpperCase"?t.data=t.data.toUpperCase():o.kind==="startsWith"?t.data.startsWith(o.value)||(s=this._getOrReturnCtx(t,s),J(s,{code:W.invalid_string,validation:{startsWith:o.value},message:o.message}),i.dirty()):o.kind==="endsWith"?t.data.endsWith(o.value)||(s=this._getOrReturnCtx(t,s),J(s,{code:W.invalid_string,validation:{endsWith:o.value},message:o.message}),i.dirty()):o.kind==="datetime"?C$(o).test(t.data)||(s=this._getOrReturnCtx(t,s),J(s,{code:W.invalid_string,validation:"datetime",message:o.message}),i.dirty()):o.kind==="date"?cre.test(t.data)||(s=this._getOrReturnCtx(t,s),J(s,{code:W.invalid_string,validation:"date",message:o.message}),i.dirty()):o.kind==="time"?lre(o).test(t.data)||(s=this._getOrReturnCtx(t,s),J(s,{code:W.invalid_string,validation:"time",message:o.message}),i.dirty()):o.kind==="duration"?Jne.test(t.data)||(s=this._getOrReturnCtx(t,s),J(s,{validation:"duration",code:W.invalid_string,message:o.message}),i.dirty()):o.kind==="ip"?ure(t.data,o.version)||(s=this._getOrReturnCtx(t,s),J(s,{validation:"ip",code:W.invalid_string,message:o.message}),i.dirty()):o.kind==="jwt"?dre(t.data,o.alg)||(s=this._getOrReturnCtx(t,s),J(s,{validation:"jwt",code:W.invalid_string,message:o.message}),i.dirty()):o.kind==="cidr"?hre(t.data,o.version)||(s=this._getOrReturnCtx(t,s),J(s,{validation:"cidr",code:W.invalid_string,message:o.message}),i.dirty()):o.kind==="base64"?ore.test(t.data)||(s=this._getOrReturnCtx(t,s),J(s,{validation:"base64",code:W.invalid_string,message:o.message}),i.dirty()):o.kind==="base64url"?are.test(t.data)||(s=this._getOrReturnCtx(t,s),J(s,{validation:"base64url",code:W.invalid_string,message:o.message}),i.dirty()):Je.assertNever(o);return{status:i.value,value:t.data}}_regex(t,r,i){return this.refinement(s=>t.test(s),_({validation:r,code:W.invalid_string},he.errToObj(i)))}_addCheck(t){return new n(D(_({},this._def),{checks:[...this._def.checks,t]}))}email(t){return this._addCheck(_({kind:"email"},he.errToObj(t)))}url(t){return this._addCheck(_({kind:"url"},he.errToObj(t)))}emoji(t){return this._addCheck(_({kind:"emoji"},he.errToObj(t)))}uuid(t){return this._addCheck(_({kind:"uuid"},he.errToObj(t)))}nanoid(t){return this._addCheck(_({kind:"nanoid"},he.errToObj(t)))}cuid(t){return this._addCheck(_({kind:"cuid"},he.errToObj(t)))}cuid2(t){return this._addCheck(_({kind:"cuid2"},he.errToObj(t)))}ulid(t){return this._addCheck(_({kind:"ulid"},he.errToObj(t)))}base64(t){return this._addCheck(_({kind:"base64"},he.errToObj(t)))}base64url(t){return this._addCheck(_({kind:"base64url"},he.errToObj(t)))}jwt(t){return this._addCheck(_({kind:"jwt"},he.errToObj(t)))}ip(t){return this._addCheck(_({kind:"ip"},he.errToObj(t)))}cidr(t){return this._addCheck(_({kind:"cidr"},he.errToObj(t)))}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck(_({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:t?.offset??!1,local:t?.local??!1},he.errToObj(t?.message)))}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck(_({kind:"time",precision:typeof t?.precision>"u"?null:t?.precision},he.errToObj(t?.message)))}duration(t){return this._addCheck(_({kind:"duration"},he.errToObj(t)))}regex(t,r){return this._addCheck(_({kind:"regex",regex:t},he.errToObj(r)))}includes(t,r){return this._addCheck(_({kind:"includes",value:t,position:r?.position},he.errToObj(r?.message)))}startsWith(t,r){return this._addCheck(_({kind:"startsWith",value:t},he.errToObj(r)))}endsWith(t,r){return this._addCheck(_({kind:"endsWith",value:t},he.errToObj(r)))}min(t,r){return this._addCheck(_({kind:"min",value:t},he.errToObj(r)))}max(t,r){return this._addCheck(_({kind:"max",value:t},he.errToObj(r)))}length(t,r){return this._addCheck(_({kind:"length",value:t},he.errToObj(r)))}nonempty(t){return this.min(1,he.errToObj(t))}trim(){return new n(D(_({},this._def),{checks:[...this._def.checks,{kind:"trim"}]}))}toLowerCase(){return new n(D(_({},this._def),{checks:[...this._def.checks,{kind:"toLowerCase"}]}))}toUpperCase(){return new n(D(_({},this._def),{checks:[...this._def.checks,{kind:"toUpperCase"}]}))}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}
94get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxLength(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}}return n.create=e=>new n(_({checks:[],typeName:K.ZodString,coerce:e?.coerce??!1},Fe(e))),n})();function fre(n,e){let t=(n.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,i=t>r?t:r,s=Number.parseInt(n.toFixed(i).replace(".","")),o=Number.parseInt(e.toFixed(i).replace(".",""));return s%o/10**i}var cD=(()=>{class n extends qe{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==te.number){let o=this._getOrReturnCtx(t);return J(o,{code:W.invalid_type,expected:te.number,received:o.parsedType}),Ie}let i,s=new Sn;for(let o of this._def.checks)o.kind==="int"?Je.isInteger(t.data)||(i=this._getOrReturnCtx(t,i),J(i,{code:W.invalid_type,expected:"integer",received:"float",message:o.message}),s.dirty()):o.kind==="min"?(o.inclusive?t.data<o.value:t.data<=o.value)&&(i=this._getOrReturnCtx(t,i),J(i,{code:W.too_small,minimum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),s.dirty()):o.kind==="max"?(o.inclusive?t.data>o.value:t.data>=o.value)&&(i=this._getOrReturnCtx(t,i),J(i,{code:W.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),s.dirty()):o.kind==="multipleOf"?fre(t.data,o.value)!==0&&(i=this._getOrReturnCtx(t,i),J(i,{code:W.not_multiple_of,multipleOf:o.value,message:o.message}),s.dirty()):o.kind==="finite"?Number.isFinite(t.data)||(i=this._getOrReturnCtx(t,i),J(i,{code:W.not_finite,message:o.message}),s.dirty()):Je.assertNever(o);return{status:s.value,value:t.data}}gte(t,r){return this.setLimit("min",t,!0,he.toString(r))}gt(t,r){return this.setLimit("min",t,!1,he.toString(r))}lte(t,r){return this.setLimit("max",t,!0,he.toString(r))}lt(t,r){return this.setLimit("max",t,!1,he.toString(r))}setLimit(t,r,i,s){return new n(D(_({},this._def),{checks:[...this._def.checks,{kind:t,value:r,inclusive:i,message:he.toString(s)}]}))}_addCheck(t){return new n(D(_({},this._def),{checks:[...this._def.checks,t]}))}int(t){return this._addCheck({kind:"int",message:he.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:he.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:he.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:he.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:he.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:he.toString(r)})}finite(t){return this._addCheck({kind:"finite",message:he.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:he.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:he.toString(t)})}get minValue(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&Je.isInteger(t.value))}get isFinite(){let t=null,r=null;for(let i of this._def.checks){if(i.kind==="finite"||i.kind==="int"||i.kind==="multipleOf")return!0;
94i.kind==="min"?(r===null||i.value>r)&&(r=i.value):i.kind==="max"&&(t===null||i.value<t)&&(t=i.value)}return Number.isFinite(r)&&Number.isFinite(t)}}return n.create=e=>new n(_({checks:[],typeName:K.ZodNumber,coerce:e?.coerce||!1},Fe(e))),n})(),lD=(()=>{class n extends qe{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==te.bigint)return this._getInvalidInput(t);let i,s=new Sn;for(let o of this._def.checks)o.kind==="min"?(o.inclusive?t.data<o.value:t.data<=o.value)&&(i=this._getOrReturnCtx(t,i),J(i,{code:W.too_small,type:"bigint",minimum:o.value,inclusive:o.inclusive,message:o.message}),s.dirty()):o.kind==="max"?(o.inclusive?t.data>o.value:t.data>=o.value)&&(i=this._getOrReturnCtx(t,i),J(i,{code:W.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),s.dirty()):o.kind==="multipleOf"?t.data%o.value!==BigInt(0)&&(i=this._getOrReturnCtx(t,i),J(i,{code:W.not_multiple_of,multipleOf:o.value,message:o.message}),s.dirty()):Je.assertNever(o);return{status:s.value,value:t.data}}_getInvalidInput(t){let r=this._getOrReturnCtx(t);return J(r,{code:W.invalid_type,expected:te.bigint,received:r.parsedType}),Ie}gte(t,r){return this.setLimit("min",t,!0,he.toString(r))}gt(t,r){return this.setLimit("min",t,!1,he.toString(r))}lte(t,r){return this.setLimit("max",t,!0,he.toString(r))}lt(t,r){return this.setLimit("max",t,!1,he.toString(r))}setLimit(t,r,i,s){return new n(D(_({},this._def),{checks:[...this._def.checks,{kind:t,value:r,inclusive:i,message:he.toString(s)}]}))}_addCheck(t){return new n(D(_({},this._def),{checks:[...this._def.checks,t]}))}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:he.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:he.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:he.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:he.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:he.toString(r)})}get minValue(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}}return n.create=e=>new n(_({checks:[],typeName:K.ZodBigInt,coerce:e?.coerce??!1},Fe(e))),n})(),uD=(()=>{class n extends qe{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==te.boolean){let i=this._getOrReturnCtx(t);return J(i,{code:W.invalid_type,expected:te.boolean,received:i.parsedType}),Ie}return qn(t.data)}}return n.create=e=>new n(_({typeName:K.ZodBoolean,coerce:e?.coerce||!1},Fe(e))),n})(),dD=(()=>{class n extends qe{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==te.date){let o=this._getOrReturnCtx(t);return J(o,{code:W.invalid_type,expected:te.date,received:o.parsedType}),Ie}if(Number.isNaN(t.data.getTime())){let o=this._getOrReturnCtx(t);return J(o,{code:W.invalid_date}),Ie}let i=new Sn,s;for(let o of this._def.checks)o.kind==="min"?t.data.getTime()<o.value&&(s=this._getOrReturnCtx(t,s),J(s,{code:W.too_small,message:o.message,inclusive:!0,exact:!1,minimum:o.value,type:"date"}),i.dirty()):o.kind==="max"?t.data.getTime()>o.value&&(s=this._getOrReturnCtx(t,s),J(s,{code:W.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),i.dirty()):Je.assertNever(o);return{status:i.value,value:new Date(t.data.getTime())}}_addCheck(t){return new n(D(_({},this._def),{checks:[...this._def.checks,t]}))}min(t,r){return this._addCheck({kind:"min",value:t.getTime(),message:he.toString(r)})}max(t,r){return this._addCheck({kind:"max",value:t.getTime(),message:he.toString(r)})}get minDate(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t!=null?new Date(t):null}}return n.create=e=>new n(_({checks:[],coerce:e?.coerce||!1,typeName:K.ZodDate},Fe(e))),n})(),S$=(()=>{class n extends qe{_parse(t){if(this._getType(t)!==te.symbol){let i=this._getOrReturnCtx(t);
94return J(i,{code:W.invalid_type,expected:te.symbol,received:i.parsedType}),Ie}return qn(t.data)}}return n.create=e=>new n(_({typeName:K.ZodSymbol},Fe(e))),n})(),hD=(()=>{class n extends qe{_parse(t){if(this._getType(t)!==te.undefined){let i=this._getOrReturnCtx(t);return J(i,{code:W.invalid_type,expected:te.undefined,received:i.parsedType}),Ie}return qn(t.data)}}return n.create=e=>new n(_({typeName:K.ZodUndefined},Fe(e))),n})(),fD=(()=>{class n extends qe{_parse(t){if(this._getType(t)!==te.null){let i=this._getOrReturnCtx(t);return J(i,{code:W.invalid_type,expected:te.null,received:i.parsedType}),Ie}return qn(t.data)}}return n.create=e=>new n(_({typeName:K.ZodNull},Fe(e))),n})(),Q_=(()=>{class n extends qe{constructor(){super(...arguments),this._any=!0}_parse(t){return qn(t.data)}}return n.create=e=>new n(_({typeName:K.ZodAny},Fe(e))),n})(),wf=(()=>{class n extends qe{constructor(){super(...arguments),this._unknown=!0}_parse(t){return qn(t.data)}}return n.create=e=>new n(_({typeName:K.ZodUnknown},Fe(e))),n})(),xc=(()=>{class n extends qe{_parse(t){let r=this._getOrReturnCtx(t);return J(r,{code:W.invalid_type,expected:te.never,received:r.parsedType}),Ie}}return n.create=e=>new n(_({typeName:K.ZodNever},Fe(e))),n})(),x$=(()=>{class n extends qe{_parse(t){if(this._getType(t)!==te.undefined){let i=this._getOrReturnCtx(t);return J(i,{code:W.invalid_type,expected:te.void,received:i.parsedType}),Ie}return qn(t.data)}}return n.create=e=>new n(_({typeName:K.ZodVoid},Fe(e))),n})(),Ef=(()=>{class n extends qe{_parse(t){let{ctx:r,status:i}=this._processInputParams(t),s=this._def;if(r.parsedType!==te.array)return J(r,{code:W.invalid_type,expected:te.array,received:r.parsedType}),Ie;if(s.exactLength!==null){let a=r.data.length>s.exactLength.value,c=r.data.length<s.exactLength.value;(a||c)&&(J(r,{code:a?W.too_big:W.too_small,minimum:c?s.exactLength.value:void 0,maximum:a?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),i.dirty())}if(s.minLength!==null&&r.data.length<s.minLength.value&&(J(r,{code:W.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),i.dirty()),s.maxLength!==null&&r.data.length>s.maxLength.value&&(J(r,{code:W.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),i.dirty()),r.common.async)return Promise.all([...r.data].map((a,c)=>s.type._parseAsync(new ei(r,a,r.path,c)))).then(a=>Sn.mergeArray(i,a));let o=[...r.data].map((a,c)=>s.type._parseSync(new ei(r,a,r.path,c)));return Sn.mergeArray(i,o)}get element(){return this._def.type}min(t,r){return new n(D(_({},this._def),{minLength:{value:t,message:he.toString(r)}}))}max(t,r){return new n(D(_({},this._def),{maxLength:{value:t,message:he.toString(r)}}))}length(t,r){return new n(D(_({},this._def),{exactLength:{value:t,message:he.toString(r)}}))}nonempty(t){return this.min(1,t)}}return n.create=(e,t)=>new n(_({type:e,minLength:null,maxLength:null,exactLength:null,typeName:K.ZodArray},Fe(t))),n})();function Pu(n){if(n instanceof Mu){let e={};for(let t in n.shape){let r=n.shape[t];e[t]=ha.create(Pu(r))}return new Mu(D(_({},n._def),{shape:()=>e}))}else return n instanceof Ef?new Ef(D(_({},n._def),{type:Pu(n.element)})):n instanceof ha?ha.create(Pu(n.unwrap())):n instanceof Lu?Lu.create(Pu(n.unwrap())):n instanceof Nu?Nu.create(n.items.map(e=>Pu(e))):n}var Mu=(()=>{class n extends qe{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let t=this._def.shape(),r=Je.objectKeys(t);return this._cached={shape:t,keys:r},this._cached}_parse(t){if(this._getType(t)!==te.object){let u=this._getOrReturnCtx(t);return J(u,{code:W.invalid_type,expected:te.object,received:u.parsedType}),Ie}let{status:i,ctx:s}=this._processInputParams(t),{shape:o,keys:a}=this._getCached(),c=[];if(!(this._def.catchall instanceof xc&&this._def.unknownKeys==="strip"))for(let u in s.data)a.includes(u)||c.push(u);let l=[];for(let u of a){let d=o[u],f=s.data[u];
94l.push({key:{status:"valid",value:u},value:d._parse(new ei(s,f,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof xc){let u=this._def.unknownKeys;if(u==="passthrough")for(let d of c)l.push({key:{status:"valid",value:d},value:{status:"valid",value:s.data[d]}});else if(u==="strict")c.length>0&&(J(s,{code:W.unrecognized_keys,keys:c}),i.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let u=this._def.catchall;for(let d of c){let f=s.data[d];l.push({key:{status:"valid",value:d},value:u._parse(new ei(s,f,s.path,d)),alwaysSet:d in s.data})}}return s.common.async?Promise.resolve().then(()=>m(this,null,function*(){let u=[];for(let d of l){let f=yield d.key,p=yield d.value;u.push({key:f,value:p,alwaysSet:d.alwaysSet})}return u})).then(u=>Sn.mergeObjectSync(i,u)):Sn.mergeObjectSync(i,l)}get shape(){return this._def.shape()}strict(t){return he.errToObj,new n(_(D(_({},this._def),{unknownKeys:"strict"}),t!==void 0?{errorMap:(r,i)=>{let s=this._def.errorMap?.(r,i).message??i.defaultError;return r.code==="unrecognized_keys"?{message:he.errToObj(t).message??s}:{message:s}}}:{}))}strip(){return new n(D(_({},this._def),{unknownKeys:"strip"}))}passthrough(){return new n(D(_({},this._def),{unknownKeys:"passthrough"}))}extend(t){return new n(D(_({},this._def),{shape:()=>_(_({},this._def.shape()),t)}))}merge(t){return new n({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>_(_({},this._def.shape()),t._def.shape()),typeName:K.ZodObject})}setKey(t,r){return this.augment({[t]:r})}catchall(t){return new n(D(_({},this._def),{catchall:t}))}pick(t){let r={};for(let i of Je.objectKeys(t))t[i]&&this.shape[i]&&(r[i]=this.shape[i]);return new n(D(_({},this._def),{shape:()=>r}))}omit(t){let r={};for(let i of Je.objectKeys(this.shape))t[i]||(r[i]=this.shape[i]);return new n(D(_({},this._def),{shape:()=>r}))}deepPartial(){return Pu(this)}partial(t){let r={};for(let i of Je.objectKeys(this.shape)){let s=this.shape[i];t&&!t[i]?r[i]=s:r[i]=s.optional()}return new n(D(_({},this._def),{shape:()=>r}))}required(t){let r={};for(let i of Je.objectKeys(this.shape))if(t&&!t[i])r[i]=this.shape[i];else{let o=this.shape[i];for(;o instanceof ha;)o=o._def.innerType;r[i]=o}return new n(D(_({},this._def),{shape:()=>r}))}keyof(){return k$(Je.objectKeys(this.shape))}}return n.create=(e,t)=>new n(_({shape:()=>e,unknownKeys:"strip",catchall:xc.create(),typeName:K.ZodObject},Fe(t))),n.strictCreate=(e,t)=>new n(_({shape:()=>e,unknownKeys:"strict",catchall:xc.create(),typeName:K.ZodObject},Fe(t))),n.lazycreate=(e,t)=>new n(_({shape:e,unknownKeys:"strip",catchall:xc.create(),typeName:K.ZodObject},Fe(t))),n})(),pD=(()=>{class n extends qe{_parse(t){let{ctx:r}=this._processInputParams(t),i=this._def.options;function s(o){for(let c of o)if(c.result.status==="valid")return c.result;for(let c of o)if(c.result.status==="dirty")return r.common.issues.push(...c.ctx.common.issues),c.result;let a=o.map(c=>new vs(c.ctx.common.issues));return J(r,{code:W.invalid_union,unionErrors:a}),Ie}if(r.common.async)return Promise.all(i.map(o=>m(this,null,function*(){let a=D(_({},r),{common:D(_({},r.common),{issues:[]}),parent:null});return{result:yield o._parseAsync({data:r.data,path:r.path,parent:a}),ctx:a}}))).then(s);{let o,a=[];for(let l of i){let u=D(_({},r),{common:D(_({},r.common),{issues:[]}),parent:null}),d=l._parseSync({data:r.data,path:r.path,parent:u});if(d.status==="valid")return d;d.status==="dirty"&&!o&&(o={result:d,ctx:u}),u.common.issues.length&&a.push(u.common.issues)}if(o)return r.common.issues.push(...o.ctx.common.issues),o.result;let c=a.map(l=>new vs(l));return J(r,{code:W.invalid_union,unionErrors:c}),Ie}}get options(){return this._def.options}}return n.create=(e,t)=>new n(_({options:e,typeName:K.ZodUnion},Fe(t))),n})(),mo=n=>n instanceof gD?mo(n.schema):n instanceof Ou?mo(n.innerType()):n instanceof yD?[n.value]:n instanceof nv?n.options:n instanceof _D?Je.objectValues(n.enum):n instanceof vD?mo(n._def.innerType):n instanceof hD?[void 0]:n instanceof fD?[null]:n instanceof ha?[void 0,...mo(n.unwrap())]:n instanceof Lu?[null,...mo(n.unwrap())]:n instanceof If||n instanceof wD?mo(n.unwrap()):n instanceof bD?mo(n._def.innerType):[],Z_=class n extends qe{_parse(e){let{ctx:t}=this._processInputParams(e);
94if(t.parsedType!==te.object)return J(t,{code:W.invalid_type,expected:te.object,received:t.parsedType}),Ie;let r=this.discriminator,i=t.data[r],s=this.optionsMap.get(i);return s?t.common.async?s._parseAsync({data:t.data,path:t.path,parent:t}):s._parseSync({data:t.data,path:t.path,parent:t}):(J(t,{code:W.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),Ie)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){let i=new Map;for(let s of t){let o=mo(s.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let a of o){if(i.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);i.set(a,s)}}return new n(_({typeName:K.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:i},Fe(r)))}};function aD(n,e){let t=_s(n),r=_s(e);if(n===e)return{valid:!0,data:n};if(t===te.object&&r===te.object){let i=Je.objectKeys(e),s=Je.objectKeys(n).filter(a=>i.indexOf(a)!==-1),o=_(_({},n),e);for(let a of s){let c=aD(n[a],e[a]);if(!c.valid)return{valid:!1};o[a]=c.data}return{valid:!0,data:o}}else if(t===te.array&&r===te.array){if(n.length!==e.length)return{valid:!1};let i=[];for(let s=0;s<n.length;s++){let o=n[s],a=e[s],c=aD(o,a);if(!c.valid)return{valid:!1};i.push(c.data)}return{valid:!0,data:i}}else return t===te.date&&r===te.date&&+n==+e?{valid:!0,data:n}:{valid:!1}}var mD=(()=>{class n extends qe{_parse(t){let{status:r,ctx:i}=this._processInputParams(t),s=(o,a)=>{if(Y_(o)||Y_(a))return Ie;let c=aD(o.value,a.value);return c.valid?((X_(o)||X_(a))&&r.dirty(),{status:r.value,value:c.data}):(J(i,{code:W.invalid_intersection_types}),Ie)};return i.common.async?Promise.all([this._def.left._parseAsync({data:i.data,path:i.path,parent:i}),this._def.right._parseAsync({data:i.data,path:i.path,parent:i})]).then(([o,a])=>s(o,a)):s(this._def.left._parseSync({data:i.data,path:i.path,parent:i}),this._def.right._parseSync({data:i.data,path:i.path,parent:i}))}}return n.create=(e,t,r)=>new n(_({left:e,right:t,typeName:K.ZodIntersection},Fe(r))),n})(),Nu=(()=>{class n extends qe{_parse(t){let{status:r,ctx:i}=this._processInputParams(t);if(i.parsedType!==te.array)return J(i,{code:W.invalid_type,expected:te.array,received:i.parsedType}),Ie;if(i.data.length<this._def.items.length)return J(i,{code:W.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Ie;!this._def.rest&&i.data.length>this._def.items.length&&(J(i,{code:W.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let o=[...i.data].map((a,c)=>{let l=this._def.items[c]||this._def.rest;return l?l._parse(new ei(i,a,i.path,c)):null}).filter(a=>!!a);return i.common.async?Promise.all(o).then(a=>Sn.mergeArray(r,a)):Sn.mergeArray(r,o)}get items(){return this._def.items}rest(t){return new n(D(_({},this._def),{rest:t}))}}return n.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new n(_({items:e,typeName:K.ZodTuple,rest:null},Fe(t)))},n})(),J_=class n extends qe{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==te.object)return J(r,{code:W.invalid_type,expected:te.object,received:r.parsedType}),Ie;let i=[],s=this._def.keyType,o=this._def.valueType;for(let a in r.data)i.push({key:s._parse(new ei(r,a,r.path,a)),value:o._parse(new ei(r,r.data[a],r.path,a)),alwaysSet:a in r.data});return r.common.async?Sn.mergeObjectAsync(t,i):Sn.mergeObjectSync(t,i)}get element(){return this._def.valueType}static create(e,t,r){return t instanceof qe?new n(_({keyType:e,valueType:t,typeName:K.ZodRecord},Fe(r))):new n(_({keyType:tv.create(),valueType:e,typeName:K.ZodRecord},Fe(t)))}},D$=(()=>{class n extends qe{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:i}=this._processInputParams(t);
94if(i.parsedType!==te.map)return J(i,{code:W.invalid_type,expected:te.map,received:i.parsedType}),Ie;let s=this._def.keyType,o=this._def.valueType,a=[...i.data.entries()].map(([c,l],u)=>({key:s._parse(new ei(i,c,i.path,[u,"key"])),value:o._parse(new ei(i,l,i.path,[u,"value"]))}));if(i.common.async){let c=new Map;return Promise.resolve().then(()=>m(this,null,function*(){for(let l of a){let u=yield l.key,d=yield l.value;if(u.status==="aborted"||d.status==="aborted")return Ie;(u.status==="dirty"||d.status==="dirty")&&r.dirty(),c.set(u.value,d.value)}return{status:r.value,value:c}}))}else{let c=new Map;for(let l of a){let u=l.key,d=l.value;if(u.status==="aborted"||d.status==="aborted")return Ie;(u.status==="dirty"||d.status==="dirty")&&r.dirty(),c.set(u.value,d.value)}return{status:r.value,value:c}}}}return n.create=(e,t,r)=>new n(_({valueType:t,keyType:e,typeName:K.ZodMap},Fe(r))),n})(),R$=(()=>{class n extends qe{_parse(t){let{status:r,ctx:i}=this._processInputParams(t);if(i.parsedType!==te.set)return J(i,{code:W.invalid_type,expected:te.set,received:i.parsedType}),Ie;let s=this._def;s.minSize!==null&&i.data.size<s.minSize.value&&(J(i,{code:W.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),r.dirty()),s.maxSize!==null&&i.data.size>s.maxSize.value&&(J(i,{code:W.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),r.dirty());let o=this._def.valueType;function a(l){let u=new Set;for(let d of l){if(d.status==="aborted")return Ie;d.status==="dirty"&&r.dirty(),u.add(d.value)}return{status:r.value,value:u}}let c=[...i.data.values()].map((l,u)=>o._parse(new ei(i,l,i.path,u)));return i.common.async?Promise.all(c).then(l=>a(l)):a(c)}min(t,r){return new n(D(_({},this._def),{minSize:{value:t,message:he.toString(r)}}))}max(t,r){return new n(D(_({},this._def),{maxSize:{value:t,message:he.toString(r)}}))}size(t,r){return this.min(t,r).max(t,r)}nonempty(t){return this.min(1,t)}}return n.create=(e,t)=>new n(_({valueType:e,minSize:null,maxSize:null,typeName:K.ZodSet},Fe(t))),n})(),ev=class n extends qe{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==te.function)return J(t,{code:W.invalid_type,expected:te.function,received:t.parsedType}),Ie;function r(a,c){return bf({data:a,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Ru(),po].filter(l=>!!l),issueData:{code:W.invalid_arguments,argumentsError:c}})}function i(a,c){return bf({data:a,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Ru(),po].filter(l=>!!l),issueData:{code:W.invalid_return_type,returnTypeError:c}})}let s={errorMap:t.common.contextualErrorMap},o=t.data;if(this._def.returns instanceof rv){let a=this;return qn(function(...c){return m(this,null,function*(){let l=new vs([]),u=yield a._def.args.parseAsync(c,s).catch(p=>{throw l.addIssue(r(c,p)),l}),d=yield Reflect.apply(o,this,u);return yield a._def.returns._def.type.parseAsync(d,s).catch(p=>{throw l.addIssue(i(d,p)),l})})})}else{let a=this;return qn(function(...c){let l=a._def.args.safeParse(c,s);if(!l.success)throw new vs([r(c,l.error)]);let u=Reflect.apply(o,this,l.data),d=a._def.returns.safeParse(u,s);if(!d.success)throw new vs([i(u,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new n(D(_({},this._def),{args:Nu.create(e).rest(wf.create())}))}returns(e){return new n(D(_({},this._def),{returns:e}))}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new n(_({args:e||Nu.create([]).rest(wf.create()),returns:t||wf.create(),typeName:K.ZodFunction},Fe(r)))}},gD=(()=>{class n extends qe{get schema(){return this._def.getter()}_parse(t){let{ctx:r}=this._processInputParams(t);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}}return n.create=(e,t)=>new n(_({getter:e,typeName:K.ZodLazy},Fe(t))),n})(),yD=(()=>{class n extends qe{_parse(t){if(t.data!==this._def.value){let r=this._getOrReturnCtx(t);
94return J(r,{received:r.data,code:W.invalid_literal,expected:this._def.value}),Ie}return{status:"valid",value:t.data}}get value(){return this._def.value}}return n.create=(e,t)=>new n(_({value:e,typeName:K.ZodLiteral},Fe(t))),n})();function k$(n,e){return new nv(_({values:n,typeName:K.ZodEnum},Fe(e)))}var nv=(()=>{class n extends qe{_parse(t){if(typeof t.data!="string"){let r=this._getOrReturnCtx(t),i=this._def.values;return J(r,{expected:Je.joinValues(i),received:r.parsedType,code:W.invalid_type}),Ie}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){let r=this._getOrReturnCtx(t),i=this._def.values;return J(r,{received:r.data,code:W.invalid_enum_value,options:i}),Ie}return qn(t.data)}get options(){return this._def.values}get enum(){let t={};for(let r of this._def.values)t[r]=r;return t}get Values(){let t={};for(let r of this._def.values)t[r]=r;return t}get Enum(){let t={};for(let r of this._def.values)t[r]=r;return t}extract(t,r=this._def){return n.create(t,_(_({},this._def),r))}exclude(t,r=this._def){return n.create(this.options.filter(i=>!t.includes(i)),_(_({},this._def),r))}}return n.create=k$,n})(),_D=(()=>{class n extends qe{_parse(t){let r=Je.getValidEnumValues(this._def.values),i=this._getOrReturnCtx(t);if(i.parsedType!==te.string&&i.parsedType!==te.number){let s=Je.objectValues(r);return J(i,{expected:Je.joinValues(s),received:i.parsedType,code:W.invalid_type}),Ie}if(this._cache||(this._cache=new Set(Je.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){let s=Je.objectValues(r);return J(i,{received:i.data,code:W.invalid_enum_value,options:s}),Ie}return qn(t.data)}get enum(){return this._def.values}}return n.create=(e,t)=>new n(_({values:e,typeName:K.ZodNativeEnum},Fe(t))),n})(),rv=(()=>{class n extends qe{unwrap(){return this._def.type}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==te.promise&&r.common.async===!1)return J(r,{code:W.invalid_type,expected:te.promise,received:r.parsedType}),Ie;let i=r.parsedType===te.promise?r.data:Promise.resolve(r.data);return qn(i.then(s=>this._def.type.parseAsync(s,{path:r.path,errorMap:r.common.contextualErrorMap})))}}return n.create=(e,t)=>new n(_({type:e,typeName:K.ZodPromise},Fe(t))),n})(),Ou=(()=>{class n extends qe{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===K.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:r,ctx:i}=this._processInputParams(t),s=this._def.effect||null,o={addIssue:a=>{J(i,a),a.fatal?r.abort():r.dirty()},get path(){return i.path}};if(o.addIssue=o.addIssue.bind(o),s.type==="preprocess"){let a=s.transform(i.data,o);if(i.common.async)return Promise.resolve(a).then(c=>m(this,null,function*(){if(r.value==="aborted")return Ie;let l=yield this._def.schema._parseAsync({data:c,path:i.path,parent:i});return l.status==="aborted"?Ie:l.status==="dirty"?Sc(l.value):r.value==="dirty"?Sc(l.value):l}));{if(r.value==="aborted")return Ie;let c=this._def.schema._parseSync({data:a,path:i.path,parent:i});return c.status==="aborted"?Ie:c.status==="dirty"?Sc(c.value):r.value==="dirty"?Sc(c.value):c}}if(s.type==="refinement"){let a=c=>{let l=s.refinement(c,o);if(i.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return c};if(i.common.async===!1){let c=this._def.schema._parseSync({data:i.data,path:i.path,parent:i});return c.status==="aborted"?Ie:(c.status==="dirty"&&r.dirty(),a(c.value),{status:r.value,value:c.value})}else return this._def.schema._parseAsync({data:i.data,path:i.path,parent:i}).then(c=>c.status==="aborted"?Ie:(c.status==="dirty"&&r.dirty(),a(c.value).then(()=>({status:r.value,value:c.value}))))}if(s.type==="transform")if(i.common.async===!1){let a=this._def.schema._parseSync({data:i.data,path:i.path,parent:i});if(!da(a))return Ie;let c=s.transform(a.value,o);if(c instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:c}}else return this._def.schema._parseAsync({data:i.data,path:i.path,parent:i}).then(a=>da(a)?Promise.resolve(s.transform(a.value,o)).then(c=>({status:r.value,value:c})):Ie);Je.assertNever(s)}}return n.create=(e,t,r)=>new n(_({schema:e,typeName:K.ZodEffects,effect:t},Fe(r))),n.createWithPreprocess=(e,t,r)=>new n(_({schema:t,effect:{type:"preprocess",transform:e},typeName:K.ZodEffects},Fe(r))),n})();var ha=(()=>{class n extends qe{_parse(t){return this._getType(t)===te.undefined?qn(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}return n.create=(e,t)=>
94new n(_({innerType:e,typeName:K.ZodOptional},Fe(t))),n})(),Lu=(()=>{class n extends qe{_parse(t){return this._getType(t)===te.null?qn(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}return n.create=(e,t)=>new n(_({innerType:e,typeName:K.ZodNullable},Fe(t))),n})(),vD=(()=>{class n extends qe{_parse(t){let{ctx:r}=this._processInputParams(t),i=r.data;return r.parsedType===te.undefined&&(i=this._def.defaultValue()),this._def.innerType._parse({data:i,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}return n.create=(e,t)=>new n(_({innerType:e,typeName:K.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default},Fe(t))),n})(),bD=(()=>{class n extends qe{_parse(t){let{ctx:r}=this._processInputParams(t),i=D(_({},r),{common:D(_({},r.common),{issues:[]})}),s=this._def.innerType._parse({data:i.data,path:i.path,parent:_({},i)});return ku(s)?s.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new vs(i.common.issues)},input:i.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new vs(i.common.issues)},input:i.data})}}removeCatch(){return this._def.innerType}}return n.create=(e,t)=>new n(_({innerType:e,typeName:K.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch},Fe(t))),n})(),P$=(()=>{class n extends qe{_parse(t){if(this._getType(t)!==te.nan){let i=this._getOrReturnCtx(t);return J(i,{code:W.invalid_type,expected:te.nan,received:i.parsedType}),Ie}return{status:"valid",value:t.data}}}return n.create=e=>new n(_({typeName:K.ZodNaN},Fe(e))),n})(),pre=Symbol("zod_brand"),If=class extends qe{_parse(e){let{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}},Tf=class n extends qe{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return m(this,null,function*(){let s=yield this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?Ie:s.status==="dirty"?(t.dirty(),Sc(s.value)):this._def.out._parseAsync({data:s.value,path:r.path,parent:r})});{let i=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?Ie:i.status==="dirty"?(t.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:r.path,parent:r})}}static create(e,t){return new n({in:e,out:t,typeName:K.ZodPipeline})}},wD=(()=>{class n extends qe{_parse(t){let r=this._def.innerType._parse(t),i=s=>(da(s)&&(s.value=Object.freeze(s.value)),s);return ku(r)?r.then(s=>i(s)):i(r)}unwrap(){return this._def.innerType}}return n.create=(e,t)=>new n(_({innerType:e,typeName:K.ZodReadonly},Fe(t))),n})();function I$(n,e){let t=typeof n=="function"?n(e):typeof n=="string"?{message:n}:n;return typeof t=="string"?{message:t}:t}function M$(n,e={},t){return n?Q_.create().superRefine((r,i)=>{let s=n(r);if(s instanceof Promise)return s.then(o=>{if(!o){let a=I$(e,r),c=a.fatal??t??!0;i.addIssue(D(_({code:"custom"},a),{fatal:c}))}});if(!s){let o=I$(e,r),a=o.fatal??t??!0;i.addIssue(D(_({code:"custom"},o),{fatal:a}))}}):Q_.create()}var mre={object:Mu.lazycreate},K=function(n){return n.ZodString="ZodString",n.ZodNumber="ZodNumber",n.ZodNaN="ZodNaN",n.ZodBigInt="ZodBigInt",n.ZodBoolean="ZodBoolean",n.ZodDate="ZodDate",n.ZodSymbol="ZodSymbol",n.ZodUndefined="ZodUndefined",n.ZodNull="ZodNull",n.ZodAny="ZodAny",n.ZodUnknown="ZodUnknown",n.ZodNever="ZodNever",n.ZodVoid="ZodVoid",n.ZodArray="ZodArray",n.ZodObject="ZodObject",n.ZodUnion="ZodUnion",
94n.ZodDiscriminatedUnion="ZodDiscriminatedUnion",n.ZodIntersection="ZodIntersection",n.ZodTuple="ZodTuple",n.ZodRecord="ZodRecord",n.ZodMap="ZodMap",n.ZodSet="ZodSet",n.ZodFunction="ZodFunction",n.ZodLazy="ZodLazy",n.ZodLiteral="ZodLiteral",n.ZodEnum="ZodEnum",n.ZodEffects="ZodEffects",n.ZodNativeEnum="ZodNativeEnum",n.ZodOptional="ZodOptional",n.ZodNullable="ZodNullable",n.ZodDefault="ZodDefault",n.ZodCatch="ZodCatch",n.ZodPromise="ZodPromise",n.ZodBranded="ZodBranded",n.ZodPipeline="ZodPipeline",n.ZodReadonly="ZodReadonly",n}(K||{});var gre=(n,e={message:`Input not instance of ${n.name}`})=>M$(t=>t instanceof n,e),N$=tv.create,O$=cD.create,yre=P$.create,_re=lD.create,L$=uD.create,vre=dD.create,bre=S$.create,wre=hD.create,Ere=fD.create,Ire=Q_.create,Tre=wf.create,Are=xc.create,Cre=x$.create,Sre=Ef.create,xre=Mu.create,Dre=Mu.strictCreate,Rre=pD.create,kre=Z_.create,Pre=mD.create,Mre=Nu.create,Nre=J_.create,Ore=D$.create,Lre=R$.create,Fre=ev.create,Vre=gD.create,jre=yD.create,$re=nv.create,Ure=_D.create,Bre=rv.create,Hre=Ou.create,qre=ha.create,zre=Lu.create,Gre=Ou.createWithPreprocess,Wre=Tf.create,Kre=()=>N$().optional(),Yre=()=>O$().optional(),Xre=()=>L$().optional(),Qre={string:n=>tv.create(D(_({},n),{coerce:!0})),number:n=>cD.create(D(_({},n),{coerce:!0})),boolean:n=>uD.create(D(_({},n),{coerce:!0})),bigint:n=>lD.create(D(_({},n),{coerce:!0})),date:n=>dD.create(D(_({},n),{coerce:!0}))};var Zre=Ie;var FR=di(ov(),1);var q$=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;function iie(n){return typeof n=="string"&&q$.test(n)}var Rc=iie;var xn=[];for(av=0;av<256;++av)xn.push((av+256).toString(16).slice(1));var av;function z$(n,e=0){return(xn[n[e+0]]+xn[n[e+1]]+xn[n[e+2]]+xn[n[e+3]]+"-"+xn[n[e+4]]+xn[n[e+5]]+"-"+xn[n[e+6]]+xn[n[e+7]]+"-"+xn[n[e+8]]+xn[n[e+9]]+"-"+xn[n[e+10]]+xn[n[e+11]]+xn[n[e+12]]+xn[n[e+13]]+xn[n[e+14]]+xn[n[e+15]]).toLowerCase()}var cv,sie=new Uint8Array(16);function ED(){if(!cv&&(cv=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!cv))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return cv(sie)}var oie=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),ID={randomUUID:oie};function aie(n,e,t){if(ID.randomUUID&&!e&&!n)return ID.randomUUID();n=n||{};var r=n.random||(n.rng||ED)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,e){t=t||0;for(var i=0;i<16;++i)e[t+i]=r[i];return e}return z$(r)}var sn=aie;var tU=di(ov(),1),mv=di(pv(),1);var gie=(...n)=>fetch(...n),yie=Symbol.for("ls:fetch_implementation");var be=()=>globalThis[yie]??gie;var _ie=[400,401,403,404,405,406,407,408],vie=[409],Cf=class{constructor(e){Object.defineProperty(this,"maxConcurrency",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"maxRetries",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"queue",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onFailedResponseHook",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxConcurrency=e.maxConcurrency??1/0,this.maxRetries=e.maxRetries??6,"default"in mv.default?this.queue=new mv.default.default({concurrency:this.maxConcurrency}):this.queue=new mv.default({concurrency:this.maxConcurrency}),this.onFailedResponseHook=e?.onFailedResponseHook}call(e,...t){let r=this.onFailedResponseHook;return this.queue.add(()=>(0,tU.default)(()=>e(...t).catch(s=>{throw s instanceof Error?s:new Error(s)}),{onFailedAttempt(s){return m(this,null,function*(){if(s.message.startsWith("Cancel")||s.message.startsWith("TimeoutError")||s.message.startsWith("AbortError")||s?.code==="ECONNABORTED")throw s;let o=s?.response,a=o?.status;if(a){if(_ie.includes(+a))throw s;if(vie.includes(+a))return;r&&(yield r(o))}})},retries:this.maxRetries,randomize:!0}),{throwOnTimeout:!0})}callWithOptions(e,t,...r){return e.signal?Promise.race([this.call(t,...r),new Promise((i,s)=>{e.signal?.addEventListener("abort",()=>{s(new Error("AbortError"))})})]):this.call(t,...r)}fetch(...e){return this.call(()=>be()(...e).then(t=>t.ok?t:Promise.reject(t)))}};function RD(n){return typeof n?._getType=="function"}function kD(n){let e={type:n._getType(),data:{content:n.content}};return n?.additional_kwargs&&Object.keys(n.additional_kwargs).length>0&&(e.data.additional_kwargs=_({},n.additional_kwargs)),e}function et(n,e){if(!Rc(n)){let t=e!==void 0?`Invalid UUID for ${e}: ${n}`:`Invalid UUID: ${n}`;throw new Error(t)}return n}var nU={};
94function gv(n){nU[n]||(console.warn(n),nU[n]=!0)}var XD=di(zB(),1);function GB(n,e){let t=(0,XD.parse)(n),r=(0,XD.parse)(e);if(!t||!r)throw new Error("Invalid version format.");return t.compare(r)>=0}function go(n){if(!n||n.split("/").length>2||n.startsWith("/")||n.endsWith("/")||n.split(":").length>2)throw new Error(`Invalid identifier format: ${n}`);let[e,t]=n.split(":"),r=t||"latest";if(e.includes("/")){let[i,s]=e.split("/",2);if(!i||!s)throw new Error(`Invalid identifier format: ${n}`);return[i,s,r]}else{if(!e)throw new Error(`Invalid identifier format: ${n}`);return["-",e,r]}}var QD=class extends Error{constructor(e){super(e),this.name="LangSmithConflictError"}};function Qe(n,e,t){return m(this,null,function*(){let r;if(n.ok){t&&(r=yield n.text());return}r=yield n.text();let i=`Failed to ${e}. Received status [${n.status}]: ${n.statusText}. Server response: ${r}`;throw n.status===409?new QD(i):new Error(i)})}var WB="[...]",mae={result:"[Circular]"},Dv=[],ju=[];function gae(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function Pc(n,e,t,r){try{return JSON.stringify(n,e,t)}catch(o){if(!o.message?.includes("Converting circular structure to JSON"))return console.warn("[WARNING]: LangSmith received unserializable value."),"[Unserializable]";console.warn("[WARNING]: LangSmith received circular JSON. This will decrease tracer performance."),typeof r>"u"&&(r=gae()),JD(n,"",0,[],void 0,0,r);var i;try{ju.length===0?i=JSON.stringify(n,e,t):i=JSON.stringify(n,yae(e),t)}catch{return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;Dv.length!==0;){var s=Dv.pop();s.length===4?Object.defineProperty(s[0],s[1],s[3]):s[0][s[1]]=s[2]}}return i}}function ZD(n,e,t,r){var i=Object.getOwnPropertyDescriptor(r,t);i.get!==void 0?i.configurable?(Object.defineProperty(r,t,{value:n}),Dv.push([r,t,e,i])):ju.push([e,t,n]):(r[t]=n,Dv.push([r,t,e]))}function JD(n,e,t,r,i,s,o){s+=1;var a;if(typeof n=="object"&&n!==null){for(a=0;a<r.length;a++)if(r[a]===n){ZD(mae,n,e,i);return}if(typeof o.depthLimit<"u"&&s>o.depthLimit){ZD(WB,n,e,i);return}if(typeof o.edgesLimit<"u"&&t+1>o.edgesLimit){ZD(WB,n,e,i);return}if(r.push(n),Array.isArray(n))for(a=0;a<n.length;a++)JD(n[a],a,a,r,n,s,o);else{var c=Object.keys(n);for(a=0;a<c.length;a++){var l=c[a];JD(n[l],l,a,r,n,s,o)}}r.pop()}}function yae(n){return n=typeof n<"u"?n:function(e,t){return t},function(e,t){if(ju.length>0)for(var r=0;r<ju.length;r++){var i=ju[r];if(i[1]===e&&i[0]===t){t=i[2],ju.splice(r,1);break}}return n.call(this,e,t)}}function KB(n){let e=kv(),t=YB(),r=n.extra??{},i=r.metadata;return n.extra=D(_({},r),{runtime:_(_({},e),r?.runtime),metadata:_(_(_({},t),t.revision_id||n.revision_id?{revision_id:n.revision_id??t.revision_id}:{}),i)}),n}var _ae=()=>{let n=yo("TRACING_SAMPLING_RATE");if(n===void 0)return;let e=parseFloat(n);if(e<0||e>1)throw new Error(`LANGSMITH_TRACING_SAMPLING_RATE must be between 0 and 1 if set. Got: ${e}`);return e},vae=n=>{let t=n.replace("http://","").replace("https://","").split("/")[0].split(":")[0];return t==="localhost"||t==="127.0.0.1"||t==="::1"};function bae(n){return m(this,null,function*(){let e=[];try{for(var t=Ge(n),r,i,s;r=!(i=yield t.next()).done;r=!1){let o=i.value;e.push(o)}}catch{s=[i]}finally{try{r&&(i=t.return)&&(yield i.call(t))}finally{if(s)throw s[0]}}return e})}function eR(n){if(n!==void 0)return n.trim().replace(/^"(.*)"$/,"$1").replace(/^'(.*)'$/,"$1")}var wae=n=>m(void 0,null,function*(){if(n?.status===429){let e=parseInt(n.headers.get("retry-after")??"30",10)*1e3;if(e>0)return yield new Promise(t=>setTimeout(t,e)),!0}return!1}),tR=class{constructor(){Object.defineProperty(this,"items",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"sizeBytes",{enumerable:!0,configurable:!0,writable:!0,value:0})}peek(){return this.items[0]}push(e){let t,r=new Promise(s=>{t=s}),i=Pc(e.item).length;return this.items.push({action:e.action,payload:e.item,itemPromiseResolve:t,itemPromise:r,size:i}),this.sizeBytes+=i,r}
94pop(e){if(e<1)throw new Error("Number of bytes to pop off may not be less than 1.");let t=[],r=0;for(;r+(this.peek()?.size??0)<e&&this.items.length>0;){let i=this.items.shift();i&&(t.push(i),r+=i.size,this.sizeBytes-=i.size)}if(t.length===0&&this.items.length>0){let i=this.items.shift();t.push(i),r+=i.size,this.sizeBytes-=i.size}return[t.map(i=>({action:i.action,item:i.payload})),()=>t.forEach(i=>i.itemPromiseResolve())]}},Eae=20971520,Iae=1e3,Mc=class n{constructor(e={}){Object.defineProperty(this,"apiKey",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"apiUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"webUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"caller",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"batchIngestCaller",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"timeout_ms",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_tenantId",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"hideInputs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"hideOutputs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"tracingSampleRate",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"filteredPostUuids",{enumerable:!0,configurable:!0,writable:!0,value:new Set}),Object.defineProperty(this,"autoBatchTracing",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"autoBatchQueue",{enumerable:!0,configurable:!0,writable:!0,value:new tR}),Object.defineProperty(this,"autoBatchTimeout",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"autoBatchInitialDelayMs",{enumerable:!0,configurable:!0,writable:!0,value:250}),Object.defineProperty(this,"autoBatchAggregationDelayMs",{enumerable:!0,configurable:!0,writable:!0,value:50}),Object.defineProperty(this,"batchSizeBytesLimit",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"fetchOptions",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"settings",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"blockOnRootRunFinalization",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"_serverInfo",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_getServerInfoPromise",{enumerable:!0,configurable:!0,writable:!0,value:void 0});let t=n.getDefaultClientConfig();this.tracingSampleRate=_ae(),this.apiUrl=eR(e.apiUrl??t.apiUrl)??"",this.apiUrl.endsWith("/")&&(this.apiUrl=this.apiUrl.slice(0,-1)),this.apiKey=eR(e.apiKey??t.apiKey),this.webUrl=eR(e.webUrl??t.webUrl),this.webUrl?.endsWith("/")&&(this.webUrl=this.webUrl.slice(0,-1)),this.timeout_ms=e.timeout_ms??12e3,this.caller=new Cf(e.callerOptions??{}),this.batchIngestCaller=new Cf(D(_({},e.callerOptions??{}),{onFailedResponseHook:wae})),this.hideInputs=e.hideInputs??e.anonymizer??t.hideInputs,this.hideOutputs=e.hideOutputs??e.anonymizer??t.hideOutputs,this.autoBatchTracing=e.autoBatchTracing??this.autoBatchTracing,this.blockOnRootRunFinalization=e.blockOnRootRunFinalization??this.blockOnRootRunFinalization,this.batchSizeBytesLimit=e.batchSizeBytesLimit,this.fetchOptions=e.fetchOptions||{}}static getDefaultClientConfig(){let e=yo("API_KEY"),t=yo("ENDPOINT")??"https://api.smith.langchain.com",r=yo("HIDE_INPUTS")==="true",i=yo("HIDE_OUTPUTS")==="true";return{apiUrl:t,apiKey:e,webUrl:void 0,hideInputs:r,hideOutputs:i}}getHostUrl(){return this.webUrl?this.webUrl:vae(this.apiUrl)?(this.webUrl="http://localhost:3000",this.webUrl):this.apiUrl.includes("/api")&&!this.apiUrl.split(".",1)[0].endsWith("api")?(this.webUrl=this.apiUrl.replace("/api",""),this.webUrl):this.apiUrl.split(".",1)[0].includes("dev")?(this.webUrl="https://dev.smith.langchain.com",this.webUrl):this.apiUrl.split(".",1)[0].includes("eu")?(this.webUrl="https://eu.smith.langchain.com",this.webUrl):(this.webUrl="https://smith.langchain.com",this.webUrl)}get headers(){let e={"User-Agent":`langsmith-js/${Rv}`};return this.apiKey&&(e["x-api-key"]=`${this.apiKey}`),e}processInputs(e){return this.hideInputs===!1?e:this.hideInputs===!0?{}:typeof this.hideInputs=="function"?this.hideInputs(e):e}processOutputs(e){return this.hideOutputs===!1?e:this.hideOutputs===!0?{}:typeof this.hideOutputs=="function"?this.hideOutputs(e):e}prepareRunCreateOrUpdateInputs(e){let t=_({},e);return t.inputs!==void 0&&(t.inputs=this.processInputs(t.inputs)),t.outputs!==void 0&&(t.outputs=this.processOutputs(t.outputs)),t}_getResponse(e,t){return m(this,null,function*(){let r=t?.toString()??"",i=`${this.apiUrl}${e}?${r}`,s=yield this.caller.call(be(),i,_({method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms)},this.fetchOptions));return yield Qe(s,`Failed to fetch ${e}`),s})}_get(e,t){return m(this,null,function*(){return(yield this._getResponse(e,t)).json()})}
94_getPaginated(i){return Re(this,arguments,function*(e,t=new URLSearchParams,r){let s=Number(t.get("offset"))||0,o=Number(t.get("limit"))||100;for(;;){t.set("offset",String(s)),t.set("limit",String(o));let a=`${this.apiUrl}${e}?${t}`,c=yield new z(this.caller.call(be(),a,_({method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms)},this.fetchOptions)));yield new z(Qe(c,`Failed to fetch ${e}`));let l=r?r(yield new z(c.json())):yield new z(c.json());if(l.length===0||(yield l,l.length<o))break;s+=l.length}})}_getCursorPaginatedList(e,t=null,r="POST",i="runs"){return Re(this,null,function*(){let s=t?_({},t):{};for(;;){let o=yield new z(this.caller.call(be(),`${this.apiUrl}${e}`,D(_({method:r,headers:D(_({},this.headers),{"Content-Type":"application/json"}),signal:AbortSignal.timeout(this.timeout_ms)},this.fetchOptions),{body:JSON.stringify(s)}))),a=yield new z(o.json());if(!a||!a[i])break;yield a[i];let c=a.cursors;if(!c||!c.next)break;s.cursor=c.next}})}_filterForSampling(e,t=!1){if(this.tracingSampleRate===void 0)return e;if(t){let r=[];for(let i of e)this.filteredPostUuids.has(i.id)?this.filteredPostUuids.delete(i.id):r.push(i);return r}else{let r=[];for(let i of e)i.id!==i.trace_id&&!this.filteredPostUuids.has(i.trace_id)||Math.random()<this.tracingSampleRate?r.push(i):this.filteredPostUuids.add(i.id);return r}}_getBatchSizeLimitBytes(){return m(this,null,function*(){let e=yield this._ensureServerInfo();return this.batchSizeBytesLimit??e.batch_ingest_config?.size_limit_bytes??Eae})}drainAutoBatchQueue(){return m(this,null,function*(){for(;this.autoBatchQueue.items.length>=0;){let[e,t]=this.autoBatchQueue.pop(yield this._getBatchSizeLimitBytes());if(!e.length){t();return}try{let r={runCreates:e.filter(s=>s.action==="create").map(s=>s.item),runUpdates:e.filter(s=>s.action==="update").map(s=>s.item)};(yield this._ensureServerInfo())?.batch_ingest_config?.use_multipart_endpoint?yield this.multipartIngestRuns(r):yield this.batchIngestRuns(r)}finally{t()}}})}processRunOperation(e,t){return m(this,null,function*(){let r=this.autoBatchTimeout;clearTimeout(this.autoBatchTimeout),this.autoBatchTimeout=void 0,e.action==="create"&&(e.item=KB(e.item));let i=this.autoBatchQueue.push(e),s=yield this._getBatchSizeLimitBytes();return(t||this.autoBatchQueue.sizeBytes>s)&&(yield this.drainAutoBatchQueue().catch(console.error)),this.autoBatchQueue.items.length>0&&(this.autoBatchTimeout=setTimeout(()=>{this.autoBatchTimeout=void 0,this.drainAutoBatchQueue().catch(console.error)},r?this.autoBatchAggregationDelayMs:this.autoBatchInitialDelayMs)),i})}_getServerInfo(){return m(this,null,function*(){let e=yield be()(`${this.apiUrl}/info`,_({method:"GET",headers:{Accept:"application/json"},signal:AbortSignal.timeout(Iae)},this.fetchOptions));return yield Qe(e,"get server info"),e.json()})}_ensureServerInfo(){return m(this,null,function*(){return this._getServerInfoPromise===void 0&&(this._getServerInfoPromise=m(this,null,function*(){if(this._serverInfo===void 0)try{this._serverInfo=yield this._getServerInfo()}catch{console.warn("[WARNING]: LangSmith failed to fetch info on supported operations. Falling back to single calls and default limits.")}return this._serverInfo??{}})),this._getServerInfoPromise.then(e=>(this._serverInfo===void 0&&(this._getServerInfoPromise=void 0),e))})}_getSettings(){return m(this,null,function*(){return this.settings||(this.settings=this._get("/settings")),yield this.settings})}createRun(e){return m(this,null,function*(){if(!this._filterForSampling([e]).length)return;let t=D(_({},this.headers),{"Content-Type":"application/json"}),r=e.project_name;delete e.project_name;let i=this.prepareRunCreateOrUpdateInputs(D(_({session_name:r},e),{start_time:e.start_time??Date.now()}));if(this.autoBatchTracing&&i.trace_id!==void 0&&i.dotted_order!==void 0){this.processRunOperation({action:"create",item:i}).catch(console.error);return}let s=KB(i),o=yield this.caller.call(be(),`${this.apiUrl}/runs`,_({method:"POST",headers:t,body:Pc(s),signal:AbortSignal.timeout(this.timeout_ms)},this.fetchOptions));yield Qe(o,"create run",!0)})}batchIngestRuns(r){return m(this,arguments,function*({runCreates:e,runUpdates:t}){if(e===void 0&&t===void 0)return;let i=e?.map(l=>this.prepareRunCreateOrUpdateInputs(l))??[],s=t?.map(l=>this.prepareRunCreateOrUpdateInputs(l))??[];if(i.length>0&&s.length>0){let l=i.reduce((d,f)=>(f.id&&(d[f.id]=f),d),{}),u=[];for(let d of s)d.id!==void 0&&l[d.id]?l[d.id]=_(_({},l[d.id]),d):u.push(d);i=Object.values(l),s=u}let o={post:this._filterForSampling(i),patch:this._filterForSampling(s,!0)};if(!o.post.length&&!o.patch.length)return;if((yield this._ensureServerInfo()).version===void 0){this.autoBatchTracing=!1;
94for(let l of o.post)yield this.createRun(l);for(let l of o.patch)l.id!==void 0&&(yield this.updateRun(l.id,l));return}let c={post:[],patch:[]};for(let l of["post","patch"]){let u=l,d=o[u].reverse(),f=d.pop();for(;f!==void 0;)c[u].push(f),f=d.pop()}(c.post.length>0||c.patch.length>0)&&(yield this._postBatchIngestRuns(Pc(c)))})}_postBatchIngestRuns(e){return m(this,null,function*(){let t=D(_({},this.headers),{"Content-Type":"application/json",Accept:"application/json"}),r=yield this.batchIngestCaller.call(be(),`${this.apiUrl}/runs/batch`,_({method:"POST",headers:t,body:e,signal:AbortSignal.timeout(this.timeout_ms)},this.fetchOptions));yield Qe(r,"batch create run",!0)})}multipartIngestRuns(r){return m(this,arguments,function*({runCreates:e,runUpdates:t}){if(e===void 0&&t===void 0)return;let i={},s=[];for(let f of e??[]){let p=this.prepareRunCreateOrUpdateInputs(f);p.id!==void 0&&p.attachments!==void 0&&(i[p.id]=p.attachments),delete p.attachments,s.push(p)}let o=[];for(let f of t??[])o.push(this.prepareRunCreateOrUpdateInputs(f));if(s.find(f=>f.trace_id===void 0||f.dotted_order===void 0)!==void 0)throw new Error('Multipart ingest requires "trace_id" and "dotted_order" to be set when creating a run');if(o.find(f=>f.trace_id===void 0||f.dotted_order===void 0)!==void 0)throw new Error('Multipart ingest requires "trace_id" and "dotted_order" to be set when updating a run');if(s.length>0&&o.length>0){let f=s.reduce((y,v)=>(v.id&&(y[v.id]=v),y),{}),p=[];for(let y of o)y.id!==void 0&&f[y.id]?f[y.id]=_(_({},f[y.id]),y):p.push(y);s=Object.values(f),o=p}if(s.length===0&&o.length===0)return;let l=[],u=[];for(let[f,p]of[["post",s],["patch",o]])for(let y of p){let d=y,{inputs:v,outputs:w,events:E}=d,A=Xt(d,["inputs","outputs","events"]),x={inputs:v,outputs:w,events:E},M=Pc(A);u.push({name:`${f}.${A.id}`,payload:new Blob([M],{type:`application/json; length=${M.length}`})});for(let[O,$]of Object.entries(x)){if($===void 0)continue;let C=Pc($);u.push({name:`${f}.${A.id}.${O}`,payload:new Blob([C],{type:`application/json; length=${C.length}`})})}if(A.id!==void 0){let O=i[A.id];if(O){delete i[A.id];for(let[$,[C,T]]of Object.entries(O))u.push({name:`attachment.${A.id}.${$}`,payload:new Blob([T],{type:`${C}; length=${T.length}`})})}}l.push(`trace=${A.trace_id},id=${A.id}`)}yield this._sendMultipartRequest(u,l.join("; "))})}_sendMultipartRequest(e,t){return m(this,null,function*(){try{let r=new FormData;for(let i of e)r.append(i.name,i.payload);yield this.batchIngestCaller.call(be(),`${this.apiUrl}/runs/multipart`,_({method:"POST",headers:_({},this.headers),body:r,signal:AbortSignal.timeout(this.timeout_ms)},this.fetchOptions))}catch(r){let i="Failed to multipart ingest runs";r instanceof Error?i+=`: ${r.stack||r.message}`:i+=`: ${String(r)}`,console.warn(`${i.trim()} 95 96Context: ${t}`)}})}updateRun(e,t){return m(this,null,function*(){et(e),t.inputs&&(t.inputs=this.processInputs(t.inputs)),t.outputs&&(t.outputs=this.processOutputs(t.outputs));let r=D(_({},t),{id:e});if(!this._filterForSampling([r],!0).length)return;if(this.autoBatchTracing&&r.trace_id!==void 0&&r.dotted_order!==void 0){if(t.end_time!==void 0&&r.parent_run_id===void 0&&this.blockOnRootRunFinalization){yield this.processRunOperation({action:"update",item:r},!0);return}else this.processRunOperation({action:"update",item:r}).catch(console.error);return}let i=D(_({},this.headers),{"Content-Type":"application/json"}),s=yield this.caller.call(be(),`${this.apiUrl}/runs/${e}`,_({method:"PATCH",headers:i,body:Pc(t),signal:AbortSignal.timeout(this.timeout_ms)},this.fetchOptions));yield Qe(s,"update run",!0)})}readRun(r){return m(this,arguments,function*(e,{loadChildRuns:t}={loadChildRuns:!1}){et(e);let i=yield this._get(`/runs/${e}`);return t&&i.child_run_ids&&(i=yield this._loadChildRuns(i)),i})}getRunUrl(i){return m(this,arguments,function*({runId:e,run:t,projectOpts:r}){if(t!==void 0){let s;t.session_id?s=t.session_id:r?.projectName?s=(yield this.readProject({projectName:r?.projectName})).id:r?.projectId?s=r?.projectId:s=(yield this.readProject({projectName:yo("PROJECT")||"default"})).id;let o=yield this._getTenantId();return`${this.getHostUrl()}/o/${o}/projects/p/${s}/r/${t.id}?poll=true`}else if(e!==void 0){let s=yield this.readRun(e);if(!s.app_path)throw new Error(`Run ${e} has no app_path`);return`${this.getHostUrl()}${s.app_path}`}
96else throw new Error("Must provide either runId or run")})}_loadChildRuns(e){return m(this,null,function*(){let t=yield bae(this.listRuns({id:e.child_run_ids})),r={},i={};t.sort((s,o)=>(s?.dotted_order??"").localeCompare(o?.dotted_order??""));for(let s of t){if(s.parent_run_id===null||s.parent_run_id===void 0)throw new Error(`Child run ${s.id} has no parent`);s.parent_run_id in r||(r[s.parent_run_id]=[]),r[s.parent_run_id].push(s),i[s.id]=s}e.child_runs=r[e.id]||[];for(let s in r)s!==e.id&&(i[s].child_runs=r[s]);return e})}listRuns(e){return Re(this,null,function*(){let{projectId:t,projectName:r,parentRunId:i,traceId:s,referenceExampleId:o,startTime:a,executionOrder:c,isRoot:l,runType:u,error:d,id:f,query:p,filter:y,traceFilter:v,treeFilter:w,limit:E,select:A}=e,x=[];if(t&&(x=Array.isArray(t)?t:[t]),r){let P=Array.isArray(r)?r:[r],N=yield new z(Promise.all(P.map(R=>this.readProject({projectName:R}).then(ze=>ze.id))));x.push(...N)}let M=["app_path","child_run_ids","completion_cost","completion_tokens","dotted_order","end_time","error","events","extra","feedback_stats","first_token_time","id","inputs","name","outputs","parent_run_id","parent_run_ids","prompt_cost","prompt_tokens","reference_example_id","run_type","session_id","start_time","status","tags","total_cost","total_tokens","trace_id"],O={session:x.length?x:null,run_type:u,reference_example:o,query:p,filter:y,trace_filter:v,tree_filter:w,execution_order:c,parent_run:i,start_time:a?a.toISOString():null,error:d,id:f,limit:E,trace:s,select:A||M,is_root:l},$=0;try{for(var C=Ge(this._getCursorPaginatedList("/runs/query",O)),T,S,k;T=!(S=yield new z(C.next())).done;T=!1){let P=S.value;if(E){if($>=E)break;if(P.length+$>E){let N=P.slice(0,E-$);yield*vn(N);break}$+=P.length,yield*vn(P)}else yield*vn(P)}}catch{k=[S]}finally{try{T&&(S=C.return)&&(yield new z(S.call(C)))}finally{if(k)throw k[0]}}})}getRunStats(E){return m(this,arguments,function*({id:e,trace:t,parentRun:r,runType:i,projectNames:s,projectIds:o,referenceExampleIds:a,startTime:c,endTime:l,error:u,query:d,filter:f,traceFilter:p,treeFilter:y,isRoot:v,dataSourceType:w}){let A=o||[];s&&(A=[...o||[],...yield Promise.all(s.map(C=>this.readProject({projectName:C}).then(T=>T.id)))]);let M=Object.fromEntries(Object.entries({id:e,trace:t,parent_run:r,run_type:i,session:A,reference_example:a,start_time:c,end_time:l,error:u,query:d,filter:f,trace_filter:p,tree_filter:y,is_root:v,data_source_type:w}).filter(([C,T])=>T!==void 0));return yield(yield this.caller.call(be(),`${this.apiUrl}/runs/stats`,_({method:"POST",headers:this.headers,body:JSON.stringify(M),signal:AbortSignal.timeout(this.timeout_ms)},this.fetchOptions))).json()})}shareRun(r){return m(this,arguments,function*(e,{shareId:t}={}){let i={run_id:e,share_token:t||sn()};et(e);let o=yield(yield this.caller.call(be(),`${this.apiUrl}/runs/${e}/share`,_({method:"PUT",headers:this.headers,body:JSON.stringify(i),signal:AbortSignal.timeout(this.timeout_ms)},this.fetchOptions))).json();if(o===null||!("share_token"in o))throw new Error("Invalid response from server");return`${this.getHostUrl()}/public/${o.share_token}/r`})}unshareRun(e){return m(this,null,function*(){et(e);let t=yield this.caller.call(be(),`${this.apiUrl}/runs/${e}/share`,_({method:"DELETE",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms)},this.fetchOptions));yield Qe(t,"unshare run",!0)})}readRunSharedLink(e){return m(this,null,function*(){et(e);let r=yield(yield this.caller.call(be(),`${this.apiUrl}/runs/${e}/share`,_({method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms)},this.fetchOptions))).json();if(!(r===null||!("share_token"in r)))return`${this.getHostUrl()}/public/${r.share_token}/r`})}listSharedRuns(r){return m(this,arguments,function*(e,{runIds:t}={}){let i=new URLSearchParams({share_token:e});if(t!==void 0)for(let a of t)i.append("id",a);return et(e),yield(yield this.caller.call(be(),`${this.apiUrl}/public/${e}/runs${i}`,_({method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms)},this.fetchOptions))).json()})}readDatasetSharedSchema(e,t){return m(this,null,function*(){if(!e&&!t)throw new Error("Either datasetId or datasetName must be given");e||(e=(yield this.readDataset({datasetName:t})).id),et(e);let i=yield(yield this.caller.call(be(),`${this.apiUrl}/datasets/${e}/share`,_({method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms)},this.fetchOptions))).json();return i.url=`${this.getHostUrl()}/public/${i.share_token}/d`,i})}shareDataset(e,t){return m(this,null,function*(){if(!e&&!t)throw new Error("Either datasetId or datasetName must be given");e||(e=(yield this.readDataset({datasetName:t})).id);let r={dataset_id:e};et(e);let s=yield(yield this.caller.call(be(),`${this.apiUrl}/datasets/${e}/share`,_({method:"PUT",headers:this.headers,body:JSON.stringify(r),signal:AbortSignal.timeout(this.timeout_ms)},this.fetchOptions))).json();return s.url=`${this.getHostUrl()}/public/${s.share_token}/d`,s})}unshareDataset(e){return m(this,null,function*(){et(e);let t=yield this.caller.call(be(),`${this.apiUrl}/datasets/${e}/share`,_({method:"DELETE",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms)},this.fetchOptions));yield Qe(t,"unshare dataset",!0)})}readSharedDataset(e){return m(this,null,function*(){return et(e),yield(yield this.caller.call(be(),`${this.apiUrl}/public/${e}/datasets`,_({method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms)},this.fetchOptions))).json()})}listSharedExamples(e,t){return m(this,null,function*(){let r={};t?.exampleIds&&(r.id=t.exampleIds);let i=new URLSearchParams;Object.entries(r).forEach(([a,c])=>
96{Array.isArray(c)?c.forEach(l=>i.append(a,l)):i.append(a,c)});let s=yield this.caller.call(be(),`${this.apiUrl}/public/${e}/examples?${i.toString()}`,_({method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms)},this.fetchOptions)),o=yield s.json();if(!s.ok)throw"detail"in o?new Error(`Failed to list shared examples. 97Status: ${s.status} 98Message: ${o.detail.join(` 99`)}`):new Error(`Failed to list shared examples: ${s.status} ${s.statusText}`);return o.map(a=>D(_({},a),{_hostUrl:this.getHostUrl()}))})}createProject(a){return m(this,arguments,function*({projectName:e,description:t=null,metadata:r=null,upsert:i=!1,projectExtra:s=null,referenceDatasetId:o=null}){let c=i?"?upsert=true":"",l=`${this.apiUrl}/sessions${c}`,u=s||{};r&&(u.metadata=r);let d={name:e,extra:u,description:t};o!==null&&(d.reference_dataset_id=o);let f=yield this.caller.call(be(),l,_({method:"POST",headers:D(_({},this.headers),{"Content-Type":"application/json"}),body:JSON.stringify(d),signal:AbortSignal.timeout(this.timeout_ms)},this.fetchOptions));return yield Qe(f,"create project"),yield f.json()})}updateProject(a,c){return m(this,arguments,function*(e,{name:t=null,description:r=null,metadata:i=null,projectExtra:s=null,endTime:o=null}){let l=`${this.apiUrl}/sessions/${e}`,u=s;i&&(u=D(_({},u||{}),{metadata:i}));let d={name:t,extra:u,description:r,end_time:o?new Date(o).toISOString():null},f=yield this.caller.call(be(),l,_({method:"PATCH",headers:D(_({},this.headers),{"Content-Type":"application/json"}),body:JSON.stringify(d),signal:AbortSignal.timeout(this.timeout_ms)},this.fetchOptions));return yield Qe(f,"update project"),yield f.json()})}hasProject(r){return m(this,arguments,function*({projectId:e,projectName:t}){let i="/sessions",s=new URLSearchParams;
99if(e!==void 0&&t!==void 0)throw new Error("Must provide either projectName or projectId, not both");if(e!==void 0)et(e),i+=`/${e}`;else if(t!==void 0)s.append("name",t);else throw new Error("Must provide projectName or projectId");let o=yield this.caller.call(be(),`${this.apiUrl}${i}?${s}`,_({method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms)},this.fetchOptions));try{let a=yield o.json();return o.ok?Array.isArray(a)?a.length>0:!0:!1}catch{return!1}})}readProject(i){return m(this,arguments,function*({projectId:e,projectName:t,includeStats:r}){let s="/sessions",o=new URLSearchParams;if(e!==void 0&&t!==void 0)throw new Error("Must provide either projectName or projectId, not both");if(e!==void 0)et(e),s+=`/${e}`;else if(t!==void 0)o.append("name",t);else throw new Error("Must provide projectName or projectId");r!==void 0&&o.append("include_stats",r.toString());let a=yield this._get(s,o),c;if(Array.isArray(a)){if(a.length===0)throw new Error(`Project[id=${e}, name=${t}] not found`);c=a[0]}else c=a;return c})}getProjectUrl(r){return m(this,arguments,function*({projectId:e,projectName:t}
99){if(e===void 0&&t===void 0)throw new Error("Must provide either projectName or projectId");let i=yield this.readProject({projectId:e,projectName:t}),s=yield this._getTenantId();return`${this.getHostUrl()}/o/${s}/projects/p/${i.id}`})}getDatasetUrl(r){return m(this,arguments,function*({datasetId:e,datasetName:t}){if(e===void 0&&t===void 0)throw new Error("Must provide either datasetName or datasetId");let i=yield this.readDataset({datasetId:e,datasetName:t}),s=yield this._getTenantId();return`${this.getHostUrl()}/o/${s}/datasets/${i.id}`})}_getTenantId(){return m(this,null,function*(){if(this._tenantId!==null)return this._tenantId;let e=new URLSearchParams({limit:"1"});try{for(var t=Ge(this._getPaginated("/sessions",e)),r,i,s;r=!(i=yield t.next()).done;r=!1){let o=i.value;return this._tenantId=o[0].tenant_id,o[0].tenant_id}}catch{s=[i]}finally{try{r&&(i=t.return)&&(yield i.call(t))}finally{if(s)throw s[0]}}throw new Error("No projects found to resolve tenant.")})}listProjects(){return Re(this,arguments,function*({projectIds:e,name:t,nameContains:r,referenceDatasetId:i,referenceDatasetName:s,referenceFree:o,metadata:a}={}){let c=new URLSearchParams;if(e!==void 0)for(let p of e)c.append("id",p);if(t!==void 0&&c.append("name",t),r!==void 0&&c.append("name_contains",r),i!==void 0)c.append("reference_dataset",i);else if(s!==void 0){let p=yield new z(this.readDataset({datasetName:s}));c.append("reference_dataset",p.id)}o!==void 0&&c.append("reference_free",o.toString()),a!==void 0&&c.append("metadata",JSON.stringify(a));try{for(var l=Ge(this._getPaginated("/sessions",c)),u,d,f;u=!(d=yield new z(l.next())).done;u=!1){let p=d.value;yield*vn(p)}}catch{f=[d]}finally{try{u&&(d=l.return)&&(yield new z(d.call(l)))}finally{if(f)throw f[0]}}})}deleteProject(r){return m(this,arguments,function*({projectId:e,projectName:t}){let i;
99if(e===void 0&&t===void 0)throw new Error("Must provide projectName or projectId");if(e!==void 0&&t!==void 0)throw new Error("Must provide either projectName or projectId, not both");e===void 0?i=(yield this.readProject({projectName:t})).id:i=e,et(i);let s=yield this.caller.call(be(),`${this.apiUrl}/sessions/${i}`,_({method:"DELETE",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms)},this.fetchOptions));yield Qe(s,`delete session ${i} (${t})`,!0)})}uploadCsv(c){return m(this,arguments,function*({csvFile:e,fileName:t,inputKeys:r,outputKeys:i,description:s,dataType:o,name:a}){let l=`${this.apiUrl}/datasets/upload`,u=new FormData;u.append("file",e,t),r.forEach(p=>{u.append("input_keys",p)}),i.forEach(p=>{u.append("output_keys",p)}),s&&u.append("description",s),o&&u.append("data_type",o),a&&u.append("name",a);let d=yield this.caller.call(be(),l,_({method:"POST",headers:this.headers,body:u,signal:AbortSignal.timeout(this.timeout_ms)},this.fetchOptions));return yield Qe(d,"upload CSV"),yield d.json()})}createDataset(a){return m(this,arguments,function*(e,{description:t,dataType:r,inputsSchema:i,outputsSchema:s,metadata:o}={}){let c={name:e,description:t,extra:o?{metadata:o}:void 0};r&&(c.data_type=r),i&&(c.inputs_schema_definition=i),s&&(c.outputs_schema_definition=s);let l=yield this.caller.call(be(),`${this.apiUrl}/datasets`,_({method:"POST",headers:D(_({},this.headers),{"Content-Type":"application/json"}),body:JSON.stringify(c),signal:AbortSignal.timeout(this.timeout_ms)},this.fetchOptions));return yield Qe(l,"create dataset"),yield l.json()})}readDataset(r){return m(this,arguments,function*({datasetId:e,datasetName:t}){let i="/datasets",s=new URLSearchParams({limit:"1"});
99if(e!==void 0&&t!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");if(e!==void 0)et(e),i+=`/${e}`;else if(t!==void 0)s.append("name",t);else throw new Error("Must provide datasetName or datasetId");let o=yield this._get(i,s),a;if(Array.isArray(o)){if(o.length===0)throw new Error(`Dataset[id=${e}, name=${t}] not found`);a=o[0]}else a=o;return a})}hasDataset(r){return m(this,arguments,function*({datasetId:e,datasetName:t}){try{return yield this.readDataset({datasetId:e,datasetName:t}),!0}catch(i){if(i instanceof Error&&i.message.toLocaleLowerCase().includes("not found"))return!1;throw i}})}diffDatasetVersions(s){return m(this,arguments,function*({datasetId:e,datasetName:t,fromVersion:r,toVersion:i}){let o=e;if(o===void 0&&t===void 0)throw new Error("Must provide either datasetName or datasetId");if(o!==void 0&&t!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");o===void 0&&(o=(yield this.readDataset({datasetName:t})).id);let a=new URLSearchParams({from_version:typeof r=="string"?r:r.toISOString(),to_version:typeof i=="string"?i:i.toISOString()});return yield this._get(`/datasets/${o}/versions/diff`,a)})}readDatasetOpenaiFinetuning(r){return m(this,arguments,function*({datasetId:e,datasetName:t}){let i="/datasets";if(e===void 0)if(t!==void 0)e=(yield this.readDataset({datasetName:t})).id;
99else throw new Error("Must provide datasetName or datasetId");return(yield(yield this._getResponse(`${i}/${e}/openai_ft`)).text()).trim().split(` 100`).map(c=>JSON.parse(c))})}listDatasets(){return Re(this,arguments,function*({limit:e=100,offset:t=0,datasetIds:r,datasetName:i,datasetNameContains:s,metadata:o}={}){let a="/datasets",c=new URLSearchParams({limit:e.toString(),offset:t.toString()});if(r!==void 0)for(let p of r)c.append("id",p);i!==void 0&&c.append("name",i),s!==void 0&&c.append("name_contains",s),o!==void 0&&c.append("metadata",JSON.stringify(o));try{for(var l=Ge(this._getPaginated(a,c)),u,d,f;u=!(d=yield new z(l.next())).done;u=!1){let p=d.value;yield*vn(p)}}catch{f=[d]}finally{try{u&&(d=l.return)&&(yield new z(d.call(l)))}finally{if(f)throw f[0]}}})}updateDataset(e){return m(this,null,function*(){let a=e,{datasetId:t,datasetName:r}=a,i=Xt(a,["datasetId","datasetName"]);if(!t&&!r)throw new Error("Must provide either datasetName or datasetId");let s=t??(yield this.readDataset({datasetName:r})).id;et(s);let o=yield this.caller.call(be(),`${this.apiUrl}/datasets/${s}`,_({method:"PATCH",headers:D(_({},this.headers),{"Content-Type":"application/json"}),body:JSON.stringify(i),signal:AbortSignal.timeout(this.timeout_ms)},this.fetchOptions));return yield Qe(o,"update dataset"),yield o.json()})}deleteDataset(r){return m(this,arguments,function*({datasetId:e,datasetName:t}){let i="/datasets",s=e;
100if(e!==void 0&&t!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");if(t!==void 0&&(s=(yield this.readDataset({datasetName:t})).id),s!==void 0)et(s),i+=`/${s}`;else throw new Error("Must provide datasetName or datasetId");let o=yield this.caller.call(be(),this.apiUrl+i,_({method:"DELETE",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms)},this.fetchOptions));yield Qe(o,`delete ${i}`),yield o.json()})}indexDataset(i){return m(this,arguments,function*({datasetId:e,datasetName:t,tag:r}){let s=e;if(!s&&!t)throw new Error("Must provide either datasetName or datasetId");if(s&&t)throw new Error("Must provide either datasetName or datasetId, not both");s||(s=(yield this.readDataset({datasetName:t})).id),et(s);let o={tag:r},a=yield this.caller.call(be(),`${this.apiUrl}/datasets/${s}/index`,_({method:"POST",headers:D(_({},this.headers),{"Content-Type":"application/json"}),body:JSON.stringify(o),signal:AbortSignal.timeout(this.timeout_ms)},this.fetchOptions));yield Qe(a,"index dataset"),yield a.json()})}similarExamples(s,o,a){return m(this,arguments,function*(e,t,r,{filter:i}={}){let c={limit:r,inputs:e};i!==void 0&&(c.filter=i),et(t);let l=yield this.caller.call(be(),`${this.apiUrl}/datasets/${t}/search`,_({method:"POST",headers:D(_({},this.headers),{"Content-Type":"application/json"}),body:JSON.stringify(c),signal:AbortSignal.timeout(this.timeout_ms)},this.fetchOptions));return yield Qe(l,"fetch similar examples"),(yield l.json()).examples})}createExample(u,d,f){return m(this,arguments,function*(e,t,{datasetId:r,datasetName:i,createdAt:s,exampleId:o,metadata:a,split:c,sourceRunId:l}){let p=r;
100if(p===void 0&&i===void 0)throw new Error("Must provide either datasetName or datasetId");if(p!==void 0&&i!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");p===void 0&&(p=(yield this.readDataset({datasetName:i})).id);let v={dataset_id:p,inputs:e,outputs:t,created_at:(s||new Date)?.toISOString(),id:o,metadata:a,split:c,source_run_id:l},w=yield this.caller.call(be(),`${this.apiUrl}/examples`,_({method:"POST",headers:D(_({},this.headers),{"Content-Type":"application/json"}),body:JSON.stringify(v),signal:AbortSignal.timeout(this.timeout_ms)},this.fetchOptions));return yield Qe(w,"create example"),yield w.json()})}createExamples(e){return m(this,null,function*(){let{inputs:t,outputs:r,metadata:i,sourceRunIds:s,exampleIds:o,datasetId:a,datasetName:c}=e,l=a;if(l===void 0&&c===void 0)throw new Error("Must provide either datasetName or datasetId");if(l!==void 0&&c!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");l===void 0&&(l=(yield this.readDataset({datasetName:c})).id);let u=t.map((p,y)=>({dataset_id:l,inputs:p,outputs:r?r[y]:void 0,metadata:i?i[y]:void 0,split:e.splits?e.splits[y]:void 0,id:o?o[y]:void 0,source_run_id:s?s[y]:void 0})),d=yield this.caller.call(be(),`${this.apiUrl}/examples/bulk`,_({method:"POST",headers:D(_({},this.headers),{"Content-Type":"application/json"}),body:JSON.stringify(u),signal:AbortSignal.timeout(this.timeout_ms)},this.fetchOptions));return yield Qe(d,"create examples"),yield d.json()})}createLLMExample(e,t,r){return m(this,null,function*(){return this.createExample({input:e},{output:t},r)})}createChatExample(e,t,r){return m(this,null,function*(){let i=e.map(o=>RD(o)?kD(o):o),s=RD(t)?kD(t):t;return this.createExample({input:i},{output:s},r)})}readExample(e){return m(this,null,function*(){et(e);let t=`/examples/${e}`;return yield this._get(t)})}listExamples(){return Re(this,arguments,function*({datasetId:e,datasetName:t,exampleIds:r,asOf:i,splits:s,inlineS3Urls:o,metadata:a,limit:c,offset:l,filter:u}={}){let d;
100if(e!==void 0&&t!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");if(e!==void 0)d=e;else if(t!==void 0)d=(yield new z(this.readDataset({datasetName:t}))).id;else throw new Error("Must provide a datasetName or datasetId");let f=new URLSearchParams({dataset:d}),p=i?typeof i=="string"?i:i?.toISOString():void 0;p&&f.append("as_of",p);let y=o??!0;if(f.append("inline_s3_urls",y.toString()),r!==void 0)for(let M of r)f.append("id",M);if(s!==void 0)for(let M of s)f.append("splits",M);if(a!==void 0){let M=JSON.stringify(a);f.append("metadata",M)}c!==void 0&&f.append("limit",c.toString()),l!==void 0&&f.append("offset",l.toString()),u!==void 0&&f.append("filter",u);let v=0;try{for(var w=Ge(this._getPaginated("/examples",f)),E,A,x;E=!(A=yield new z(w.next())).done;E=!1){let M=A.value;for(let O of M)yield O,v++;if(c!==void 0&&v>=c)break}}catch{x=[A]}finally{try{E&&(A=w.return)&&(yield new z(A.call(w)))}finally{if(x)throw x[0]}}})}deleteExample(e){return m(this,null,function*(){et(e);let t=`/examples/${e}`,r=yield this.caller.call(be(),this.apiUrl+t,_({method:"DELETE",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms)},this.fetchOptions));yield Qe(r,`delete ${t}`),yield r.json()})}updateExample(e,t){return m(this,null,function*(){et(e);let r=yield this.caller.call(be(),`${this.apiUrl}/examples/${e}`,_({method:"PATCH",headers:D(_({},this.headers),{"Content-Type":"application/json"}),body:JSON.stringify(t),signal:AbortSignal.timeout(this.timeout_ms)},this.fetchOptions));return yield Qe(r,"update example"),yield r.json()})}updateExamples(e){return m(this,null,function*(){let t=yield this.caller.call(be(),`${this.apiUrl}/examples/bulk`,_({method:"PATCH",headers:D(_({},this.headers),{"Content-Type":"application/json"}),body:JSON.stringify(e),signal:AbortSignal.timeout(this.timeout_ms)},this.fetchOptions));return yield Qe(t,"update examples"),yield t.json()})}listDatasetSplits(i){return m(this,arguments,function*({datasetId:e,datasetName:t,asOf:r}){let s;
100if(e===void 0&&t===void 0)throw new Error("Must provide dataset name or ID");if(e!==void 0&&t!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");e===void 0?s=(yield this.readDataset({datasetName:t})).id:s=e,et(s);let o=new URLSearchParams,a=r?typeof r=="string"?r:r?.toISOString():void 0;return a&&o.append("as_of",a),yield this._get(`/datasets/${s}/splits`,o)})}updateDatasetSplits(o){return m(this,arguments,function*({datasetId:e,datasetName:t,splitName:r,exampleIds:i,remove:s=!1}){let a;if(e===void 0&&t===void 0)throw new Error("Must provide dataset name or ID");if(e!==void 0&&t!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");e===void 0?a=(yield this.readDataset({datasetName:t})).id:a=e,et(a);let c={split_name:r,examples:i.map(u=>(et(u),u)),remove:s},l=yield this.caller.call(be(),`${this.apiUrl}/datasets/${a}/splits`,_({method:"PUT",headers:D(_({},this.headers),{"Content-Type":"application/json"}),body:JSON.stringify(c),signal:AbortSignal.timeout(this.timeout_ms)},this.fetchOptions));yield Qe(l,"update dataset splits",!0)})}evaluateRun(o,a){return m(this,arguments,function*(e,t,{sourceInfo:r,loadChildRuns:i,referenceExample:s}={loadChildRuns:!1}){gv("This method is deprecated and will be removed in future LangSmith versions, use `evaluate` from `langsmith/evaluation` instead.");let c;if(typeof e=="string")c=yield this.readRun(e,{loadChildRuns:i});else if(typeof e=="object"&&"id"in e)c=e;else throw new Error(`Invalid run type: ${typeof e}`);c.reference_example_id!==null&&c.reference_example_id!==void 0&&(s=yield this.readExample(c.reference_example_id));let l=yield t.evaluateRun(c,s),[u,d]=yield this._logEvaluationFeedback(l,c,r);return d[0]})}createFeedback(y,v,w){return m(this,arguments,function*(e,t,{score:r,value:i,correction:s,comment:o,sourceInfo:a,feedbackSourceType:c="api",sourceRunId:l,feedbackId:u,feedbackConfig:d,projectId:f,comparativeExperimentId:p}){if(!e&&!f)throw new Error("One of runId or projectId must be provided");if(e&&f)throw new Error("Only one of runId or projectId can be provided");let E={type:c??"api",metadata:a??{}};l!==void 0&&E?.metadata!==void 0&&!E.metadata.__run&&(E.metadata.__run={run_id:l}),E?.metadata!==void 0&&E.metadata.__run?.run_id!==void 0&&et(E.metadata.__run.run_id);let A={id:u??sn(),run_id:e,key:t,score:r,value:i,correction:s,comment:o,feedback_source:E,comparative_experiment_id:p,feedbackConfig:d,session_id:f},x=`${this.apiUrl}/feedback`,M=yield this.caller.call(be(),x,_({method:"POST",headers:D(_({},this.headers),{"Content-Type":"application/json"}),body:JSON.stringify(A),signal:AbortSignal.timeout(this.timeout_ms)},this.fetchOptions));return yield Qe(M,"create feedback",!0),A})}updateFeedback(o,a){return m(this,arguments,function*(e,{score:t,value:r,correction:i,comment:s}){let c={};t!=null&&(c.score=t),r!=null&&(c.value=r),i!=null&&(c.correction=i),s!=null&&(c.comment=s),et(e);let l=yield this.caller.call(be(),`${this.apiUrl}/feedback/${e}`,_({method:"PATCH",headers:D(_({},this.headers),{"Content-Type":"application/json"}),body:JSON.stringify(c),signal:AbortSignal.timeout(this.timeout_ms)},this.fetchOptions));yield Qe(l,"update feedback",!0)})}readFeedback(e){return m(this,null,function*(){et(e);let t=`/feedback/${e}`;return yield this._get(t)})}deleteFeedback(e){return m(this,null,function*(){et(e);let t=`/feedback/${e}`,r=yield this.caller.call(be(),this.apiUrl+t,_({method:"DELETE",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms)},this.fetchOptions));yield Qe(r,`delete ${t}`),yield r.json()})}listFeedback(){return Re(this,arguments,function*({runIds:e,feedbackKeys:t,feedbackSourceTypes:r}={}){let i=new URLSearchParams;if(e&&i.append("run",e.join(",")),t)for(let l of t)i.append("key",l);if(r)for(let l of r)i.append("source",l);try{for(var s=Ge(this._getPaginated("/feedback",i)),o,a,c;o=!(a=yield new z(s.next())).done;o=!1){let l=a.value;yield*vn(l)}}catch{c=[a]}finally{try{o&&(a=s.return)&&(yield new z(a.call(s)))}finally{if(c)throw c[0]}}})}createPresignedFeedbackToken(s,o){return m(this,arguments,function*(e,t,{expiration:r,feedbackConfig:i}={}){let a={run_id:e,feedback_key:t,feedback_config:i};return r?typeof r=="string"?a.expires_at=r:(r?.hours||r?.minutes||r?.days)&&(a.expires_in=r):a.expires_in={hours:3},yield(yield this.caller.call(be(),`${this.apiUrl}/feedback/tokens`,_({method:"POST",headers:D(_({},this.headers),{"Content-Type":"application/json"}),body:JSON.stringify(a),signal:AbortSignal.timeout(this.timeout_ms)},this.fetchOptions))).json()})}createComparativeExperiment(c){return m(this,arguments,function*({name:e,experimentIds:t,referenceDatasetId:r,createdAt:i,description:s,metadata:o,id:a}){if(t.length===0)throw new Error("At least one experiment is required");if(r||(r=(yield this.readProject({projectId:t[0]})).reference_dataset_id),!r==null)throw new Error("A reference dataset is required");let l={id:a,name:e,experiment_ids:t,reference_dataset_id:r,description:s,created_at:(i??new Date)?.toISOString(),extra:{}};return o&&(l.extra.metadata=o),yield(yield this.caller.call(be(),`${this.apiUrl}
100/datasets/comparative`,_({method:"POST",headers:D(_({},this.headers),{"Content-Type":"application/json"}),body:JSON.stringify(l),signal:AbortSignal.timeout(this.timeout_ms)},this.fetchOptions))).json()})}listPresignedFeedbackTokens(e){return Re(this,null,function*(){et(e);let t=new URLSearchParams({run_id:e});try{for(var r=Ge(this._getPaginated("/feedback/tokens",t)),i,s,o;i=!(s=yield new z(r.next())).done;i=!1){let a=s.value;yield*vn(a)}}catch{o=[s]}finally{try{i&&(s=r.return)&&(yield new z(s.call(r)))}finally{if(o)throw o[0]}}})}_selectEvalResults(e){let t;return"results"in e?t=e.results:t=[e],t}_logEvaluationFeedback(e,t,r){return m(this,null,function*(){let i=this._selectEvalResults(e),s=[];for(let o of i){let a=r||{};o.evaluatorInfo&&(a=_(_({},o.evaluatorInfo),a));let c=null;o.targetRunId?c=o.targetRunId:t&&(c=t.id),s.push(yield this.createFeedback(c,o.key,{score:o.score,value:o.value,comment:o.comment,correction:o.correction,sourceInfo:a,sourceRunId:o.sourceRunId,feedbackConfig:o.feedbackConfig,feedbackSourceType:"model"}))}return[i,s]})}logEvaluationFeedback(e,t,r){return m(this,null,function*(){let[i]=yield this._logEvaluationFeedback(e,t,r);return i})}listAnnotationQueues(){return Re(this,arguments,function*(e={}){let{queueIds:t,name:r,nameContains:i,limit:s}=e,o=new URLSearchParams;t&&t.forEach((f,p)=>{et(f,`queueIds[${p}]`),o.append("ids",f)}),r&&o.append("name",r),i&&o.append("name_contains",i),o.append("limit",(s!==void 0?Math.min(s,100):100).toString());let a=0;try{for(var c=Ge(this._getPaginated("/annotation-queues",o)),l,u,d;l=!(u=yield new z(c.next())).done;l=!1){let f=u.value;if(yield*vn(f),a++,s!==void 0&&a>=s)break}}catch{d=[u]}finally{try{l&&(u=c.return)&&(yield new z(u.call(c)))}finally{if(d)throw d[0]}}})}createAnnotationQueue(e){return m(this,null,function*(){let{name:t,description:r,queueId:i}=e,s={name:t,description:r,id:i||sn()},o=yield this.caller.call(be(),`${this.apiUrl}/annotation-queues`,_({method:"POST",headers:D(_({},this.headers),{"Content-Type":"application/json"}),body:JSON.stringify(Object.fromEntries(Object.entries(s).filter(([c,l])=>l!==void 0))),signal:AbortSignal.timeout(this.timeout_ms)},this.fetchOptions));return yield Qe(o,"create annotation queue"),yield o.json()})}readAnnotationQueue(e){return m(this,null,function*(){let t=yield this.listAnnotationQueues({queueIds:[e]}).next();if(t.done)throw new Error(`Annotation queue with ID ${e} not found`);return t.value})}updateAnnotationQueue(e,t){return m(this,null,function*(){let{name:r,description:i}=t,s=yield this.caller.call(be(),`${this.apiUrl}/annotation-queues/${et(e,"queueId")}`,_({method:"PATCH",headers:D(_({},this.headers),{"Content-Type":"application/json"}),body:JSON.stringify({name:r,description:i}),signal:AbortSignal.timeout(this.timeout_ms)},this.fetchOptions));yield Qe(s,"update annotation queue")})}deleteAnnotationQueue(e){return m(this,null,function*(){let t=yield this.caller.call(be(),`${this.apiUrl}/annotation-queues/${et(e,"queueId")}`,_({method:"DELETE",headers:D(_({},this.headers),{Accept:"application/json"}),signal:AbortSignal.timeout(this.timeout_ms)},this.fetchOptions));yield Qe(t,"delete annotation queue")})}addRunsToAnnotationQueue(e,t){return m(this,null,function*(){let r=yield this.caller.call(be(),`${this.apiUrl}/annotation-queues/${et(e,"queueId")}/runs`,_({method:"POST",headers:D(_({},this.headers),{"Content-Type":"application/json"}),body:JSON.stringify(t.map((i,s)=>et(i,`runIds[${s}]`).toString())),signal:AbortSignal.timeout(this.timeout_ms)},this.fetchOptions));yield Qe(r,"add runs to annotation queue")})}getRunFromAnnotationQueue(e,t){return m(this,null,function*(){let r=`/annotation-queues/${et(e,"queueId")}/run`,i=yield this.caller.call(be(),`${this.apiUrl}${r}/${t}`,_({method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms)},this.fetchOptions));return yield Qe(i,"get run from annotation queue"),yield i.json()})}_currentTenantIsOwner(e){return m(this,null,function*(){let t=yield this._getSettings();return e=="-"||t.tenant_handle===e})}_ownerConflictError(e,t){return m(this,null,function*(){let r=yield this._getSettings();return new Error(`Cannot ${e} for another tenant. 101 102 Current tenant: ${r.tenant_handle} 103 104 Requested tenant: ${t}`)})}_getLatestCommitHash(e){return m(this,null,function*(){let t=yield this.caller.call(be(),`${this.apiUrl}/commits/${e}/?limit=1&offset=0`,_({method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms)},this.fetchOptions)),r=yield t.json();if(!t.ok){let i=typeof r.detail=="string"?r.detail:JSON.stringify(r.detail),s=new Error(`Error ${t.status}: ${t.statusText} 105${i}`);throw s.statusCode=t.status,s}if(r.commits.length!==0)return r.commits[0].commit_hash})}_likeOrUnlikePrompt(e,t){return m(this,null,function*(){let[r,i,s]=go(e),o=yield this.caller.call(be(),`${this.apiUrl}/likes/${r}/${i}`,_({method:"POST",body:JSON.stringify({like:t}),headers:D(_({},this.headers),{"Content-Type":"application/json"}),signal:AbortSignal.timeout(this.timeout_ms)},this.fetchOptions));return yield Qe(o,`${t?"like":"unlike"} prompt`),yield o.json()})}_getPromptUrl(e){return m(this,null,function*(){let[t,r,i]=go(e);if(yield this._currentTenantIsOwner(t)){let s=yield this._getSettings();return i!=="latest"?`${this.getHostUrl()}/prompts/${r}/${i.substring(0,8)}?organizationId=${s.id}`:`${this.getHostUrl()}/prompts/${r}?organizationId=${s.id}`}else return i!=="latest"?`${this.getHostUrl()}/hub/${t}/${r}/${i.substring(0,8)}`:`${this.getHostUrl()}/hub/${t}/${r}`})}promptExists(e){return m(this,null,function*(){return!!(yield this.getPrompt(e))})}likePrompt(e){return m(this,null,function*(){return this._likeOrUnlikePrompt(e,!0)})}unlikePrompt(e){return m(this,null,function*(){return this._likeOrUnlikePrompt(e,!1)})}listCommits(e){return Re(this,null,function*(){try{for(var t=Ge(this._getPaginated(`/commits/${e}/`,new URLSearchParams,a=>a.commits)),r,i,s;
105r=!(i=yield new z(t.next())).done;r=!1){let o=i.value;yield*vn(o)}}catch{s=[i]}finally{try{r&&(i=t.return)&&(yield new z(i.call(t)))}finally{if(s)throw s[0]}}})}listPrompts(e){return Re(this,null,function*(){let t=new URLSearchParams;t.append("sort_field",e?.sortField??"updated_at"),t.append("sort_direction","desc"),t.append("is_archived",(!!e?.isArchived).toString()),e?.isPublic!==void 0&&t.append("is_public",e.isPublic.toString()),e?.query&&t.append("query",e.query);try{for(var r=Ge(this._getPaginated("/repos",t,c=>c.repos)),i,s,o;i=!(s=yield new z(r.next())).done;i=!1){let a=s.value;yield*vn(a)}}catch{o=[s]}finally{try{i&&(s=r.return)&&(yield new z(s.call(r)))}finally{if(o)throw o[0]}}})}getPrompt(e){return m(this,null,function*(){let[t,r,i]=go(e),s=yield this.caller.call(be(),`${this.apiUrl}/repos/${t}/${r}`,_({method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms)},this.fetchOptions));if(s.status===404)return null;yield Qe(s,"get prompt");let o=yield s.json();return o.repo?o.repo:null})}createPrompt(e,t){return m(this,null,function*(){let r=yield this._getSettings();if(t?.isPublic&&!r.tenant_handle)throw new Error(`Cannot create a public prompt without first 106 107 creating a LangChain Hub handle. 108 You can add a handle by creating a public prompt at: 109 110 https://smith.langchain.com/prompts`);let[i,s,o]=go(e);if(!(yield this._currentTenantIsOwner(i)))throw yield this._ownerConflictError("create a prompt",i);let a=D(_(_(_({repo_handle:s},t?.description&&{description:t.description}),t?.readme&&{readme:t.readme}),t?.tags&&{tags:t.tags}),{is_public:!!t?.isPublic}),c=yield this.caller.call(be(),`${this.apiUrl}/repos/`,_({method:"POST",headers:D(_({},this.headers),{"Content-Type":"application/json"}),body:JSON.stringify(a),signal:AbortSignal.timeout(this.timeout_ms)},this.fetchOptions));yield Qe(c,"create prompt");let{repo:l}=yield c.json();return l})}createCommit(e,t,r){return m(this,null,function*(){if(!(yield this.promptExists(e)))throw new Error("Prompt does not exist, you must create it first.");let[i,s,o]=go(e),a=r?.parentCommitHash==="latest"||!r?.parentCommitHash?yield this._getLatestCommitHash(`${i}/${s}`):r?.parentCommitHash,c={manifest:JSON.parse(JSON.stringify(t)),parent_commit:a},l=yield this.caller.call(be(),`${this.apiUrl}/commits/${i}/${s}`,_({method:"POST",headers:D(_({},this.headers),{"Content-Type":"application/json"}),body:JSON.stringify(c),signal:AbortSignal.timeout(this.timeout_ms)},this.fetchOptions));yield Qe(l,"create commit");let u=yield l.json();return this._getPromptUrl(`${i}/${s}${u.commit_hash?`:${u.commit_hash}`:""}`)})}updatePrompt(e,t){return m(this,null,function*(){if(!(yield this.promptExists(e)))throw new Error("Prompt does not exist, you must create it first.");let[r,i]=go(e);if(!(yield this._currentTenantIsOwner(r)))throw yield this._ownerConflictError("update a prompt",r);let s={};if(t?.description!==void 0&&(s.description=t.description),t?.readme!==void 0&&(s.readme=t.readme),t?.tags!==void 0&&(s.tags=t.tags),t?.isPublic!==void 0&&(s.is_public=t.isPublic),t?.isArchived!==void 0&&(s.is_archived=t.isArchived),Object.keys(s).length===0)throw new Error("No valid update options provided");let o=yield this.caller.call(be(),`${this.apiUrl}/repos/${r}/${i}`,_({method:"PATCH",body:JSON.stringify(s),headers:D(_({},this.headers),{"Content-Type":"application/json"}),signal:AbortSignal.timeout(this.timeout_ms)},this.fetchOptions));return yield Qe(o,"update prompt"),o.json()})}deletePrompt(e){return m(this,null,function*(){if(!(yield this.promptExists(e)))throw new Error("Prompt does not exist, you must create it first.");let[t,r,i]=go(e);if(!(yield this._currentTenantIsOwner(t)))throw yield this._ownerConflictError("delete a prompt",t);return yield(yield this.caller.call(be(),`${this.apiUrl}/repos/${t}/${r}`,_({method:"DELETE",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms)},this.fetchOptions))).json()})}pullPromptCommit(e,t){return m(this,null,function*(){let[r,i,s]=go(e),o=yield this._getServerInfo(),a=GB(o.version,"0.5.23"),c=s;if(!a&&s==="latest"){let d=yield this._getLatestCommitHash(`${r}/${i}`);if(d)c=d;else throw new Error("No commits found")}let l=yield this.caller.call(be(),`${this.apiUrl}/commits/${r}/${i}/${c}${t?.includeModel?"?include_model=true":""}`,_({method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms)},this.fetchOptions));yield Qe(l,"pull prompt commit");let u=yield l.json();return{owner:r,repo:i,commit_hash:u.commit_hash,manifest:u.manifest,examples:u.examples}})}_pullPrompt(e,t){return m(this,null,function*(){let r=yield this.pullPromptCommit(e,{includeModel:t?.includeModel});return JSON.stringify(r.manifest)})}pushPrompt(e,t){return m(this,null,function*(){return(yield this.promptExists(e))?t&&Object.keys(t).some(i=>i!=="object")&&(yield this.updatePrompt(e,{description:t?.description,readme:t?.readme,tags:t?.tags,isPublic:t?.isPublic})):yield this.createPrompt(e,{description:t?.description,readme:t?.readme,tags:t?.tags,isPublic:t?.isPublic}),t?.object?yield this.createCommit(e,t?.object,{parentCommitHash:t?.parentCommitHash}):yield this._getPromptUrl(e)})}clonePublicDataset(r){return m(this,arguments,function*(e,t={}){let{sourceApiUrl:i=this.apiUrl,datasetName:s}=t,[o,a]=this.parseTokenOrUrl(e,i),c=new n({apiUrl:o,apiKey:"placeholder"}),l=yield c.readSharedDataset(a),u=s||l.name;try{if(yield this.hasDataset({datasetId:u})){console.log(`Dataset ${u} already exists in your tenant. Skipping.`);return}}catch{}let d=yield c.listSharedExamples(a),f=yield this.createDataset(u,{description:l.description,dataType:l.data_type||"kv",input
110sSchema:l.inputs_schema_definition??void 0,outputsSchema:l.outputs_schema_definition??void 0});try{yield this.createExamples({inputs:d.map(p=>p.inputs),outputs:d.flatMap(p=>p.outputs?[p.outputs]:[]),datasetId:f.id})}catch(p){throw console.error(`An error occurred while creating dataset ${u}. You should delete it manually.`),p}})}parseTokenOrUrl(e,t,r=2,i="dataset"){try{return et(e),[t,e]}catch{}try{let o=new URL(e).pathname.split("/").filter(a=>a!=="");if(o.length>=r){let a=o[o.length-r];return[t,a]}else throw new Error(`Invalid public ${i} URL: ${e}`)}catch{throw new Error(`Invalid public ${i} URL or token: ${e}`)}}awaitPendingTraceBatches(){return Promise.all(this.autoBatchQueue.items.map(({itemPromise:e})=>e))}};var Rv="0.1.68";var _o,Tae=()=>typeof window<"u"&&typeof window.document<"u",Aae=()=>typeof globalThis=="object"&&globalThis.constructor&&globalThis.constructor.name==="DedicatedWorkerGlobalScope",Cae=()=>typeof window<"u"&&window.name==="nodejs"||typeof navigator<"u"&&(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom")),XB=()=>typeof Deno<"u",Sae=()=>typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"&&!XB(),xae=()=>_o||(Tae()?_o="browser":Sae()?_o="node":Aae()?_o="webworker":Cae()?_o="jsdom":XB()?_o="deno":_o="other",_o),nR;function kv(){if(nR===void 0){let n=xae(),e=Rae();nR=_({library:"langsmith",runtime:n,sdk:"langsmith-js",sdk_version:Rv},e)}return nR}function YB(){let n=Dae()||{},e={},t=["LANGCHAIN_API_KEY","LANGCHAIN_ENDPOINT","LANGCHAIN_TRACING_V2","LANGCHAIN_PROJECT","LANGCHAIN_SESSION"];for(let[r,i]of Object.entries(n))r.startsWith("LANGCHAIN_")&&typeof i=="string"&&!t.includes(r)&&!r.toLowerCase().includes("key")&&!r.toLowerCase().includes("secret")&&!r.toLowerCase().includes("token")&&(r==="LANGCHAIN_REVISION_ID"?e.revision_id=i:e[r]=i);return e}function Dae(){try{return typeof process<"u"&&process.env?Object.entries(process.env).reduce((n,[e,t])=>(n[e]=String(t),n),{}):void 0}catch{return}}function ma(n){try{return typeof process<"u"?process.env?.[n]:void 0}catch{return}}function yo(n){return ma(`LANGSMITH_${n}`)||ma(`LANGCHAIN_${n}`)}var rR;function Rae(){if(rR!==void 0)return rR;let n=["VERCEL_GIT_COMMIT_SHA","NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA","COMMIT_REF","RENDER_GIT_COMMIT","CI_COMMIT_SHA","CIRCLE_SHA1","CF_PAGES_COMMIT_SHA","REACT_APP_GIT_SHA","SOURCE_VERSION","GITHUB_SHA","TRAVIS_COMMIT","GIT_COMMIT","BUILD_VCS_NUMBER","bamboo_planRepository_revision","Build.SourceVersion","BITBUCKET_COMMIT","DRONE_COMMIT_SHA","SEMAPHORE_GIT_SHA","BUILDKITE_COMMIT"],e={};for(let t of n){let r=ma(t);r!==void 0&&(e[t]=r)}return rR=e,e}var QB=n=>n!==void 0?n:!!["TRACING_V2","TRACING"].find(t=>yo(t)==="true");var Pv=Symbol.for("lc:context_variables");function kae(n){return n.replace(/[-:.]/g,"")}function Pae(n,e,t=1){let r=t.toFixed(0).slice(0,3).padStart(3,"0");return kae(`${new Date(n).toISOString().slice(0,-1)}${r}Z`)+e}var Mv=class n{constructor(e,t){Object.defineProperty(this,"metadata",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"tags",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.metadata=e,this.tags=t}static fromHeader(e){let t=e.split(","),r={},i=[];for(let s of t){let[o,a]=s.split("="),c=decodeURIComponent(a);o==="langsmith-metadata"?r=JSON.parse(c):o==="langsmith-tags"&&(i=c.split(","))}return new n(r,i)}toHeader(){let e=[];return this.metadata&&Object.keys(this.metadata).length>0&&e.push(`langsmith-metadata=${encodeURIComponent(JSON.stringify(this.metadata))}`),this.tags&&this.tags.length>0&&e.push(`langsmith-tags=${encodeURIComponent(this.tags.join(","))}`),e.join(",")}},pa=class n{constructor(e){if(Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"run_type",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"project_name",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"parent_run",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"child_runs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"start_time",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"end_time",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"extra",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"tags",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"error",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"serialized",{enumerable:!0,configurable:!0,writable:!0,value:void 0}
110),Object.defineProperty(this,"inputs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"outputs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"reference_example_id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"client",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"events",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"trace_id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"dotted_order",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"tracingEnabled",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"execution_order",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"child_execution_order",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),iR(e)){Object.assign(this,_({},e));return}let t=n.getDefaultConfig(),a=e,{metadata:r}=a,i=Xt(a,["metadata"]),s=i.client??n.getSharedClient(),o=_(_({},r),i?.extra?.metadata);if(i.extra=D(_({},i.extra),{metadata:o}),Object.assign(this,D(_(_({},t),i),{client:s})),this.trace_id||(this.parent_run?this.trace_id=this.parent_run.trace_id??this.id:this.trace_id=this.id),this.execution_order??=1,this.child_execution_order??=1,!this.dotted_order){let c=Pae(this.start_time,this.id,this.execution_order);this.parent_run?this.dotted_order=this.parent_run.dotted_order+"."+c:this.dotted_order=c}}static getDefaultConfig(){return{id:sn(),run_type:"chain",project_name:ma("LANGCHAIN_PROJECT")??ma("LANGCHAIN_SESSION")??"default",child_runs:[],api_url:ma("LANGCHAIN_ENDPOINT")??"http://localhost:1984",api_key:ma("LANGCHAIN_API_KEY"),caller_options:{},start_time:Date.now(),serialized:{},inputs:{},extra:{}}}static getSharedClient(){return n.sharedClient||(n.sharedClient=new Mc),n.sharedClient}createChild(e){let t=this.child_execution_order+1,r=new n(D(_({},e),{parent_run:this,project_name:this.project_name,client:this.client,tracingEnabled:this.tracingEnabled,execution_order:t,child_execution_order:t}));Pv in this&&(r[Pv]=this[Pv]);let i=Symbol.for("lc:child_config"),s=e.extra?.[i]??this.extra[i];if(Nae(s)){let c=_({},s),l=Mae(c.callbacks)?c.callbacks.copy?.():void 0;l&&(Object.assign(l,{_parentRunId:r.id}),l.handlers?.find(JB)?.updateFromRunTree?.(r),c.callbacks=l),r.extra[i]=c}let o=new Set,a=this;for(;a!=null&&!o.has(a.id);)o.add(a.id),a.child_execution_order=Math.max(a.child_execution_order,t),a=a.parent_run;return this.child_runs.push(r),r}end(s,o){return m(this,arguments,function*(e,t,r=Date.now(),i){this.outputs=this.outputs??e,this.error=this.error??t,this.end_time=this.end_time??r,i&&Object.keys(i).length>0&&(this.extra=this.extra?D(_({},this.extra),{metadata:_(_({},this.extra.metadata),i)}):{metadata:i})})}_convertToCreate(e,t,r=!0){let i=e.extra??{};if(i.runtime||(i.runtime={}),t)for(let[c,l]of Object.entries(t))i.runtime[c]||(i.runtime[c]=l);let s,o;return r?(o=e.parent_run?.id,s=[]):(s=e.child_runs.map(c=>this._convertToCreate(c,t,r)),o=void 0),{id:e.id,name:e.name,start_time:e.start_time,end_time:e.end_time,run_type:e.run_type,reference_example_id:e.reference_example_id,extra:i,serialized:e.serialized,error:e.error,inputs:e.inputs,outputs:e.outputs,session_name:e.project_name,child_runs:s,parent_run_id:o,trace_id:e.trace_id,dotted_order:e.dotted_order,tags:e.tags}}postRun(e=!0){return m(this,null,function*(){try{let t=kv(),r=yield this._convertToCreate(this,t,!0);if(yield this.client.createRun(r),!e){gv("Posting with excludeChildRuns=false is deprecated and will be removed in a future version.");for(let i of this.child_runs)yield i.postRun(!1)}}catch(t){console.error(`Error in postRun for run ${this.id}:`,t)}})}patchRun(){return m(this,null,function*(){try{let e={end_time:this.end_time,error:this.error,inputs:this.inputs,outputs:this.outputs,parent_run_id:this.parent_run?.id,reference_example_id:this.reference_example_id,extra:this.extra,events:this.events,dotted_order:this.dotted_order,trace_id:this.trace_id,tags:this.tags};yield this.client.updateRun(this.id,e)}catch(e){console.error(`Error in patchRun for run ${this.id}`,e)}})}toJSON(){return this._convertToCreate(this,void 0,!1)}static fromRunnableConfig(e,t){let r=e?.callbacks,i,s,o,a=QB();if(r){let l=r?.getParentRunId?.()??"",u=r?.handlers?.find(d=>d?.name=="langchain_tracer");i=u?.getRun?.(l),s=u?.projectName,o=u?.client,a=a||!!u}return i?new n({name:i.name,id:i.id,trace_id:i.trace_id,dotted_order:i.dotted_order,client:o,tracingEnabled:a,project_name:s,tags:[...new Set((i?.tags??[]).concat(e?.tags??[]))],extra:{metadata:_(_({},i?.extra?.metadata),e?.metadata)}}).createChild(t):new n(D(_({},t),{client:o,tracingEnabled:a,project_name:s}))}static fromDottedOrder(e){return this.fromHeaders({"langsmith-trace":e})}static fromHeaders(e,t){let r="get"in e&&typeof e.get=="function"?{"langsmith-trace":e.get("langsmith-trace"),baggage:e.get("baggage")}:e,i=r["langsmith-trace"];
110if(!i||typeof i!="string")return;let s=i.trim(),o=s.split(".").map(l=>{let[u,d]=l.split("Z");return{strTime:u,time:Date.parse(u+"Z"),uuid:d}}),a=o[0].uuid,c=D(_({},t),{name:t?.name??"parent",run_type:t?.run_type??"chain",start_time:t?.start_time??Date.now(),id:o.at(-1)?.uuid,trace_id:a,dotted_order:s});if(r.baggage&&typeof r.baggage=="string"){let l=Mv.fromHeader(r.baggage);c.metadata=l.metadata,c.tags=l.tags}return new n(c)}toHeaders(e){let t={"langsmith-trace":this.dotted_order,baggage:new Mv(this.extra?.metadata,this.tags).toHeader()};if(e)for(let[r,i]of Object.entries(t))e.set(r,i);return t}};Object.defineProperty(pa,"sharedClient",{enumerable:!0,configurable:!0,writable:!0,value:null});function iR(n){return n!==void 0&&typeof n.createChild=="function"&&typeof n.postRun=="function"}function JB(n){return typeof n=="object"&&n!=null&&typeof n.name=="string"&&n.name==="langchain_tracer"}function ZB(n){return Array.isArray(n)&&n.some(e=>JB(e))}function Mae(n){return typeof n=="object"&&n!=null&&Array.isArray(n.handlers)}function Nae(n){return n!==void 0&&typeof n.callbacks=="object"&&(ZB(n.callbacks?.handlers)||ZB(n.callbacks))}var oR=class{getStore(){}run(e,t){return t()}},sR=Symbol.for("ls:tracing_async_local_storage"),Oae=new oR,aR=class{getInstance(){return globalThis[sR]??Oae}initializeGlobalInstance(e){globalThis[sR]===void 0&&(globalThis[sR]=e)}},Lae=new aR,e4=()=>{let n=Lae.getInstance().getStore();if(!iR(n))throw new Error(["Could not get the current run tree.","","Please make sure you are calling this method within a traceable function or the tracing is enabled."].join(` 111`));return n};var SCe=Symbol.for("langsmith:traceable:root");function Nv(n){return typeof n=="function"&&"langsmith:traceable"in n}var cR={};Jk(cR,{JsonPatchError:()=>qt,_areEquals:()=>Of,applyOperation:()=>Oc,applyPatch:()=>Lc,applyReducer:()=>$ae,deepClone:()=>Vae,getValueByPointer:()=>Vv,validate:()=>i4,validator:()=>jv});var Fae=Object.prototype.hasOwnProperty;function n4(n,e){return Fae.call(n,e)}function r4(n){if(Array.isArray(n)){let t=new Array(n.length);for(let r=0;r<t.length;r++)t[r]=""+r;return t}if(Object.keys)return Object.keys(n);let e=[];for(let t in n)n4(n,t)&&e.push(t);return e}function ii(n){switch(typeof n){case"object":return JSON.parse(JSON.stringify(n));case"undefined":return null;default:return n}}function Lv(n){let e=0,t=n.length,r;for(;e<t;){if(r=n.charCodeAt(e),r>=48&&r<=57){e++;continue}return!1}return!0}function Fv(n){return n.indexOf("/")===-1&&n.indexOf("~")===-1?n:n.replace(/~/g,"~0").replace(/\//g,"~1")}function Nf(n){return n.replace(/~1/g,"/").replace(/~0/g,"~")}function Ov(n){if(n===void 0)return!0;if(n){if(Array.isArray(n)){for(let t=0,r=n.length;t<r;t++)if(Ov(n[t]))return!0}else if(typeof n=="object"){let t=r4(n),r=t.length;for(var e=0;e<r;e++)if(Ov(n[t[e]]))return!0}}return!1}function t4(n,e){let t=[n];for(let r in e){let i=typeof e[r]=="object"?JSON.stringify(e[r],null,2):e[r];typeof i<"u"&&t.push(`${r}: ${i}`)}return t.join(` 112`)}var Nc=class extends Error{constructor(e,t,r,i,s){super(t4(e,{name:t,index:r,operation:i,tree:s})),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"index",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"operation",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"tree",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.setPrototypeOf(this,new.target.prototype),this.message=t4(e,{name:t,index:r,operation:i,tree:s})}};var qt=Nc,Vae=ii,$u={add:function(n,e,t){return n[e]=this.value,{newDocument:t}},remove:function(n,e,t){var r=n[e];return delete n[e],{newDocument:t,removed:r}},replace:function(n,e,t){var r=n[e];return n[e]=this.value,{newDocument:t,removed:r}},move:function(n,e,t){let r=Vv(t,this.path);r&&(r=ii(r));let i=Oc(t,{op:"remove",path:this.from}).removed;return Oc(t,{op:"add",path:this.path,value:i}),{newDocument:t,removed:r}},copy:function(n,e,t){let r=Vv(t,this.from);return Oc(t,{op:"add",path:this.path,value:ii(r)}),{newDocument:t}},test:function(n,e,t){return{newDocument:t,test:Of(n[e],this.value)}},_get:function(n,e,t){return this.value=n[e],{newDocument:t}}},jae={add:function(n,e,t){return Lv(e)?n.splice(e,0,this.value):n[e]=this.value,{newDocument:t,index:e}},remove:function(n,e,t){var r=n.splice(e,1);return{newDocument:t,removed:r[0]}},replace:function(n,e,t){var r=n[e];return n[e]=this.value,{newDocument:t,removed:r}},move:$u.move,copy:$u.copy,test:$u.test,_get:$u._get};function Vv(n,e){if(e=="")return n;var t={op:"_get",path:e};return Oc(n,t),t.value}function Oc(n,e,t=!1,r=!0,i=!0,s=0){if(t&&(typeof t=="function"?t(e,0,n,e.path):jv(e,0)),e.path===""){let o={newDocument:n};if(e.op==="add")return o.newDocument=e.value,o;if(e.op==="replace")return o.newDocument=e.value,o.removed=n,o;if(e.op==="move"||e.op==="copy")return o.newDocument=Vv(n,e.from),e.op==="move"&&(o.removed=n),o;if(e.op==="test"){if(o.test=Of(n,e.value),o.test===!1)throw new qt("Test operation failed","TEST_OPERATION_FAILED",s,e,n);return o.newDocument=n,o}else{if(e.op==="remove")return o.removed=n,o.newDocument=null,o;if(e.op==="_get")return e.value=n,o;if(t)throw new qt("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",s,e,n);return o}}else{r||(n=ii(n));let a=(e.path||"").split("/"),c=n,l=1,u=a.length,d,f,p;for(typeof t=="function"?p=t:p=jv;;){if(f=a[l],f&&f.indexOf("~")!=-1&&(f=Nf(f)),i&&(f=="__proto__"||f=="prototype"&&l>0&&a[l-1]=="constructor"))throw new TypeError("JSON-Patch: modifying `__proto__` or `constructor/prototype` prop is banned for security reasons, if this was on purpose, please set `banPrototypeModifications` flag false and pass it to this function. More info in fast-json-patch README");if(t&&d===void 0&&(c[f]===void 0?d=a.slice(0,l).join("/"):l==u-1&&(d=e.path),d!==void 0&&p(e,0,n,d)),l++,Array.isArray(c)){if
112(f==="-")f=c.length;else{if(t&&!Lv(f))throw new qt("Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index","OPERATION_PATH_ILLEGAL_ARRAY_INDEX",s,e,n);Lv(f)&&(f=~~f)}if(l>=u){if(t&&e.op==="add"&&f>c.length)throw new qt("The specified index MUST NOT be greater than the number of elements in the array","OPERATION_VALUE_OUT_OF_BOUNDS",s,e,n);let y=jae[e.op].call(e,c,f,n);if(y.test===!1)throw new qt("Test operation failed","TEST_OPERATION_FAILED",s,e,n);return y}}else if(l>=u){let y=$u[e.op].call(e,c,f,n);if(y.test===!1)throw new qt("Test operation failed","TEST_OPERATION_FAILED",s,e,n);return y}if(c=c[f],t&&l<u&&(!c||typeof c!="object"))throw new qt("Cannot perform operation at the desired path","OPERATION_PATH_UNRESOLVABLE",s,e,n)}}}function Lc(n,e,t,r=!0,i=!0){if(t&&!Array.isArray(e))throw new qt("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");r||(n=ii(n));let s=new Array(e.length);for(let o=0,a=e.length;o<a;o++)s[o]=Oc(n,e[o],t,!0,i,o),n=s[o].newDocument;return s.newDocument=n,s}function $ae(n,e,t){let r=Oc(n,e);if(r.test===!1)throw new qt("Test operation failed","TEST_OPERATION_FAILED",t,e,n);return r.newDocument}function jv(n,e,t,r){if(typeof n!="object"||n===null||Array.isArray(n))throw new qt("Operation is not an object","OPERATION_NOT_AN_OBJECT",e,n,t);if($u[n.op]){if(typeof n.path!="string")throw new qt("Operation `path` property is not a string","OPERATION_PATH_INVALID",e,n,t);if(n.path.indexOf("/")!==0&&n.path.length>0)throw new qt('Operation `path` property must start with "/"',"OPERATION_PATH_INVALID",e,n,t);if((n.op==="move"||n.op==="copy")&&typeof n.from!="string")throw new qt("Operation `from` property is not present (applicable in `move` and `copy` operations)","OPERATION_FROM_REQUIRED",e,n,t);if((n.op==="add"||n.op==="replace"||n.op==="test")&&n.value===void 0)throw new qt("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_REQUIRED",e,n,t);if((n.op==="add"||n.op==="replace"||n.op==="test")&&Ov(n.value))throw new qt("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED",e,n,t);if(t){if(n.op=="add"){var i=n.path.split("/").length,s=r.split("/").length;if(i!==s+1&&i!==s)throw new qt("Cannot perform an `add` operation at the desired path","OPERATION_PATH_CANNOT_ADD",e,n,t)}else if(n.op==="replace"||n.op==="remove"||n.op==="_get"){if(n.path!==r)throw new qt("Cannot perform the operation at a path that does not exist","OPERATION_PATH_UNRESOLVABLE",e,n,t)}else if(n.op==="move"||n.op==="copy"){var o={op:"_get",path:n.from,value:void 0},a=i4([o],t);if(a&&a.name==="OPERATION_PATH_UNRESOLVABLE")throw new qt("Cannot perform the operation from a path that does not exist","OPERATION_FROM_UNRESOLVABLE",e,n,t)}}}else throw new qt("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",e,n,t)}function i4(n,e,t){try{if(!Array.isArray(n))throw new qt("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");if(e)Lc(ii(e),ii(n),t||!0);else{t=t||jv;for(var r=0;r<n.length;r++)t(n[r],r,e,void 0)}}catch(i){if(i instanceof qt)return i;throw i}}function Of(n,e){if(n===e)return!0;if(n&&e&&typeof n=="object"&&typeof e=="object"){var t=Array.isArray(n),r=Array.isArray(e),i,s,o;if(t&&r){if(s=n.length,s!=e.length)return!1;for(i=s;i--!==0;)if(!Of(n[i],e[i]))return!1;return!0}if(t!=r)return!1;var a=Object.keys(n);if(s=a.length,s!==Object.keys(e).length)return!1;for(i=s;i--!==0;)if(!e.hasOwnProperty(a[i]))return!1;for(i=s;i--!==0;)if(o=a[i],!Of(n[o],e[o]))return!1;return!0}return n!==n&&e!==e}var FCe=D(_({},cR),{JsonPatchError:Nc,deepClone:ii,escapePathComponent:Fv,unescapePathComponent:Nf});var p4=di(o4(),1),Wae=di(f4(),1);function m4(n,e){return e?.[n]||(0,p4.default)(n)}function g4(n,e,t){let r={};for(let i in n)Object.hasOwn(n,i)&&(r[e(i,t)]=n[i]);return r}function y4(n){return Array.isArray(n)?[...n]:_({},n)}function Kae(n,e){let t=y4(n);for(let[r,i]of Object.entries(e)){let[s,...o]=r.split(".").reverse(),a=t;for(let c of o.reverse()){if(a[c]===void 0)break;a[c]=y4(a[c]),a=a[c]}a[s]!==void 0&&(a[s]={lc:1,type:"secret",id:[i]})}return t}function uR(n){let e=Object.getPrototypeOf(n);return typeof n.lc_name=="function"&&(typeof e.lc_name!="function"||n.lc_name()!==e.lc_name())?n.lc_name():n.name}var vo=class n{static lc_name(){return this.name}get lc_id(){return[...this.lc_namespace,uR(this.constructor)]}get lc_secrets(){}get lc_attributes(){}get lc_aliases(){}constructor(e,...t){Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"lc_kwargs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.lc_kwargs=e||{}}toJSON(){if(!this.lc_serializable)return this.toJSONNotImplemented();if(this.lc_kwargs instanceof n||typeof this.lc_kwargs!="object"||Array.isArray(this.lc_kwargs))return this.toJSONNotImplemented();let e={},t={},r=Object.keys(this.lc_kwargs).reduce((i,s)=>(i[s]=s in this?this[s]:this.lc_kwargs[s],i),{});for(let i=Object.getPrototypeOf(this);i;i=Object.getPrototypeOf(i))Object.assign(e,Reflect.get(i,"lc_aliases",this)),Object.assign(t,Reflect.get(i,"lc_secrets",this)),Object.assign(r,Reflect.get(i,"lc_attributes",this));return Object.keys(t).forEach(i=>
112{let s=this,o=r,[a,...c]=i.split(".").reverse();for(let l of c.reverse()){if(!(l in s)||s[l]===void 0)return;(!(l in o)||o[l]===void 0)&&(typeof s[l]=="object"&&s[l]!=null?o[l]={}:Array.isArray(s[l])&&(o[l]=[])),s=s[l],o=o[l]}a in s&&s[a]!==void 0&&(o[a]=o[a]||s[a])}),{lc:1,type:"constructor",id:this.lc_id,kwargs:g4(Object.keys(t).length?Kae(r,t):r,m4,e)}}toJSONNotImplemented(){return{lc:1,type:"not_implemented",id:this.lc_id}}};var Yae=()=>typeof window<"u"&&typeof window.document<"u",Xae=()=>typeof globalThis=="object"&&globalThis.constructor&&globalThis.constructor.name==="DedicatedWorkerGlobalScope",Qae=()=>typeof window<"u"&&window.name==="nodejs"||typeof navigator<"u"&&(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom")),_4=()=>typeof Deno<"u",Zae=()=>typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"&&!_4(),Jae=()=>{let n;return Yae()?n="browser":Zae()?n="node":Xae()?n="webworker":Qae()?n="jsdom":_4()?n="deno":n="other",n},dR;function v4(){return m(this,null,function*(){return dR===void 0&&(dR={library:"langchain-js",runtime:Jae()}),dR})}function Oi(n){try{return typeof process<"u"?process.env?.[n]:void 0}catch{return}}var hR=class{},Fc=class n extends hR{get lc_namespace(){return["langchain_core","callbacks",this.name]}get lc_secrets(){}get lc_attributes(){}get lc_aliases(){}static lc_name(){return this.name}get lc_id(){return[...this.lc_namespace,uR(this.constructor)]}constructor(e){super(),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"lc_kwargs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ignoreLLM",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"ignoreChain",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"ignoreAgent",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"ignoreRetriever",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"ignoreCustomEvent",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"raiseError",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"awaitHandlers",{enumerable:!0,configurable:!0,writable:!0,value:Oi("LANGCHAIN_CALLBACKS_BACKGROUND")!=="true"}),this.lc_kwargs=e||{},e&&(this.ignoreLLM=e.ignoreLLM??this.ignoreLLM,this.ignoreChain=e.ignoreChain??this.ignoreChain,this.ignoreAgent=e.ignoreAgent??this.ignoreAgent,this.ignoreRetriever=e.ignoreRetriever??this.ignoreRetriever,this.ignoreCustomEvent=e.ignoreCustomEvent??this.ignoreCustomEvent,this.raiseError=e.raiseError??this.raiseError,this.awaitHandlers=this.raiseError||(e._awaitHandler??this.awaitHandlers))}copy(){return new this.constructor(this)}toJSON(){return vo.prototype.toJSON.call(this)}toJSONNotImplemented(){return vo.prototype.toJSONNotImplemented.call(this)}static fromMethods(e){class t extends n{constructor(){super(),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:sn()}),Object.assign(this,e)}}return new t}};function fR(n,e){return n&&!Array.isArray(n)&&typeof n=="object"?n:{[e]:n}}function ece(n){return n.replace(/[-:.]/g,"")}function tce(n,e,t){let r=t.toFixed(0).slice(0,3).padStart(3,"0");return ece(`${new Date(n).toISOString().slice(0,-1)}${r}Z`)+e}function Uu(n){return typeof n._addRunToRunMap=="function"}var si=class extends Fc{constructor(e){super(...arguments),Object.defineProperty(this,"runMap",{enumerable:!0,configurable:!0,writable:!0,value:new Map})}copy(){return this}stringifyError(e){return e instanceof Error?e.message+(e?.stack?` 113 114${e.stack}`:""):typeof e=="string"?e:`${e}`}_addChildRun(e,t){e.child_runs.push(t)}_addRunToRunMap(e){let t=tce(e.start_time,e.id,e.execution_order),r=_({},e);if(r.parent_run_id!==void 0){let i=this.runMap.get(r.parent_run_id);i&&(this._addChildRun(i,r),i.child_execution_order=Math.max(i.child_execution_order,r.child_execution_order),r.trace_id=i.trace_id,i.dotted_order!==void 0&&(r.dotted_order=[i.dotted_order,t].join(".")))}else r.trace_id=r.id,r.dotted_order=t;return this.runMap.set(r.id,r),r}_endTrace(e){return m(this,null,function*(){let t=e.parent_run_id!==void 0&&this.runMap.get(e.parent_run_id);t?t.child_execution_order=Math.max(t.child_execution_order,e.child_execution_order):yield this.persistRun(e),this.runMap.delete(e.id),yield this.onRunUpdate?.(e)})}_getExecutionOrder(e){let t=e!==void 0&&this.runMap.get(e);return t?t.child_execution_order+1:1}
114_createRunForLLMStart(e,t,r,i,s,o,a,c){let l=this._getExecutionOrder(i),u=Date.now(),d=a?D(_({},s),{metadata:a}):s,f={id:r,name:c??e.id[e.id.length-1],parent_run_id:i,start_time:u,serialized:e,events:[{name:"start",time:new Date(u).toISOString()}],inputs:{prompts:t},execution_order:l,child_runs:[],child_execution_order:l,run_type:"llm",extra:d??{},tags:o||[]};return this._addRunToRunMap(f)}handleLLMStart(e,t,r,i,s,o,a,c){return m(this,null,function*(){let l=this.runMap.get(r)??this._createRunForLLMStart(e,t,r,i,s,o,a,c);return yield this.onRunCreate?.(l),yield this.onLLMStart?.(l),l})}_createRunForChatModelStart(e,t,r,i,s,o,a,c){let l=this._getExecutionOrder(i),u=Date.now(),d=a?D(_({},s),{metadata:a}):s,f={id:r,name:c??e.id[e.id.length-1],parent_run_id:i,start_time:u,serialized:e,events:[{name:"start",time:new Date(u).toISOString()}],inputs:{messages:t},execution_order:l,child_runs:[],child_execution_order:l,run_type:"llm",extra:d??{},tags:o||[]};return this._addRunToRunMap(f)}handleChatModelStart(e,t,r,i,s,o,a,c){return m(this,null,function*(){let l=this.runMap.get(r)??this._createRunForChatModelStart(e,t,r,i,s,o,a,c);return yield this.onRunCreate?.(l),yield this.onLLMStart?.(l),l})}handleLLMEnd(e,t){return m(this,null,function*(){let r=this.runMap.get(t);if(!r||r?.run_type!=="llm")throw new Error("No LLM run to end.");return r.end_time=Date.now(),r.outputs=e,r.events.push({name:"end",time:new Date(r.end_time).toISOString()}),yield this.onLLMEnd?.(r),yield this._endTrace(r),r})}handleLLMError(e,t){return m(this,null,function*(){let r=this.runMap.get(t);if(!r||r?.run_type!=="llm")throw new Error("No LLM run to end.");return r.end_time=Date.now(),r.error=this.stringifyError(e),r.events.push({name:"error",time:new Date(r.end_time).toISOString()}),yield this.onLLMError?.(r),yield this._endTrace(r),r})}_createRunForChainStart(e,t,r,i,s,o,a,c){let l=this._getExecutionOrder(i),u=Date.now(),d={id:r,name:c??e.id[e.id.length-1],parent_run_id:i,start_time:u,serialized:e,events:[{name:"start",time:new Date(u).toISOString()}],inputs:t,execution_order:l,child_execution_order:l,run_type:a??"chain",child_runs:[],extra:o?{metadata:o}:{},tags:s||[]};return this._addRunToRunMap(d)}handleChainStart(e,t,r,i,s,o,a,c){return m(this,null,function*(){let l=this.runMap.get(r)??this._createRunForChainStart(e,t,r,i,s,o,a,c);return yield this.onRunCreate?.(l),yield this.onChainStart?.(l),l})}handleChainEnd(e,t,r,i,s){return m(this,null,function*(){let o=this.runMap.get(t);if(!o)throw new Error("No chain run to end.");return o.end_time=Date.now(),o.outputs=fR(e,"output"),o.events.push({name:"end",time:new Date(o.end_time).toISOString()}
114),s?.inputs!==void 0&&(o.inputs=fR(s.inputs,"input")),yield this.onChainEnd?.(o),yield this._endTrace(o),o})}handleChainError(e,t,r,i,s){return m(this,null,function*(){let o=this.runMap.get(t);if(!o)throw new Error("No chain run to end.");return o.end_time=Date.now(),o.error=this.stringifyError(e),o.events.push({name:"error",time:new Date(o.end_time).toISOString()}),s?.inputs!==void 0&&(o.inputs=fR(s.inputs,"input")),yield this.onChainError?.(o),yield this._endTrace(o),o})}_createRunForToolStart(e,t,r,i,s,o,a){let c=this._getExecutionOrder(i),l=Date.now(),u={id:r,name:a??e.id[e.id.length-1],parent_run_id:i,start_time:l,serialized:e,events:[{name:"start",time:new Date(l).toISOString()}],inputs:{input:t},execution_order:c,child_execution_order:c,run_type:"tool",child_runs:[],extra:o?{metadata:o}:{},tags:s||[]};return this._addRunToRunMap(u)}handleToolStart(e,t,r,i,s,o,a){return m(this,null,function*(){let c=this.runMap.get(r)??this._createRunForToolStart(e,t,r,i,s,o,a);return yield this.onRunCreate?.(c),yield this.onToolStart?.(c),c})}handleToolEnd(e,t){return m(this,null,function*(){let r=this.runMap.get(t);if(!r||r?.run_type!=="tool")throw new Error("No tool run to end");return r.end_time=Date.now(),r.outputs={output:e},r.events.push({name:"end",time:new Date(r.end_time).toISOString()}),yield this.onToolEnd?.(r),yield this._endTrace(r),r})}handleToolError(e,t){return m(this,null,function*(){let r=this.runMap.get(t);if(!r||r?.run_type!=="tool")throw new Error("No tool run to end");return r.end_time=Date.now(),r.error=this.stringifyError(e),r.events.push({name:"error",time:new Date(r.end_time).toISOString()}),yield this.onToolError?.(r),yield this._endTrace(r),r})}handleAgentAction(e,t){return m(this,null,function*(){let r=this.runMap.get(t);if(!r||r?.run_type!=="chain")return;let i=r;i.actions=i.actions||[],i.actions.push(e),i.events.push({name:"agent_action",time:new Date().toISOString(),kwargs:{action:e}}),yield this.onAgentAction?.(r)})}handleAgentEnd(e,t){return m(this,null,function*(){let r=this.runMap.get(t);!r||r?.run_type!=="chain"||(r.events.push({name:"agent_end",time:new Date().toISOString(),kwargs:{action:e}}),yield this.onAgentEnd?.(r))})}_createRunForRetrieverStart(e,t,r,i,s,o,a){let c=this._getExecutionOrder(i),l=Date.now(),u={id:r,name:a??e.id[e.id.length-1],parent_run_id:i,start_time:l,serialized:e,events:[{name:"start",time:new Date(l).toISOString()}],inputs:{query:t},execution_order:c,child_execution_order:c,run_type:"retriever",child_runs:[],extra:o?{metadata:o}:{},tags:s||[]};return this._addRunToRunMap(u)}handleRetrieverStart(e,t,r,i,s,o,a){return m(this,null,function*(){let c=this.runMap.get(r)??this._createRunForRetrieverStart(e,t,r,i,s,o,a);return yield this.onRunCreate?.(c),yield this.onRetrieverStart?.(c),c})}handleRetrieverEnd(e,t){return m(this,null,function*(){let r=this.runMap.get(t);if(!r||r?.run_type!=="retriever")throw new Error("No retriever run to end");return r.end_time=Date.now(),r.outputs={documents:e},r.events.push({name:"end",time:new Date(r.end_time).toISOString()}),yield this.onRetrieverEnd?.(r),yield this._endTrace(r),r})}handleRetrieverError(e,t){return m(this,null,function*(){let r=this.runMap.get(t);if(!r||r?.run_type!=="retriever")throw new Error("No retriever run to end");return r.end_time=Date.now(),r.error=this.stringifyError(e),r.events.push({name:"error",time:new Date(r.end_time).toISOString()}),yield this.onRetrieverError?.(r),yield this._endTrace(r),r})}handleText(e,t){return m(this,null,function*(){let r=this.runMap.get(t);!r||r?.run_type!=="chain"||(r.events.push({name:"text",time:new Date().toISOString(),kwargs:{text:e}}),yield this.onText?.(r))})}handleLLMNewToken(e,t,r,i,s,o){return m(this,null,function*(){let a=this.runMap.get(r);if(!a||a?.run_type!=="llm")throw new Error('Invalid "runId" provided to "handleLLMNewToken" callback.');return a.events.push({name:"new_token",time:new Date().toISOString(),kwargs:{token:e,idx:t,chunk:o?.chunk}}),yield this.onLLMNewToken?.(a,e,{chunk:o?.chunk}),a})}};var pR=di(I4(),1);function cr(n,e){return`${n.open}${e}${n.close}`}function oi(n,e){try{return JSON.stringify(n,null,2)}catch{return e}}function T4(n){return typeof n=="string"?n.trim():n==null?n:oi(n,n.toString())}function ga(n){if(!n.end_time)return"";let e=n.end_time-n.start_time;return e<1e3?`${e}ms`:`${(e/1e3).toFixed(2)}s`}var{color:Er}=pR.default,Lf=class extends si{constructor(){super(...arguments),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"console_callback_handler"})}persistRun(e){return Promise.resolve()}getParents(e){let t=[],r=e;for(;r.parent_run_id;){let i=this.runMap.get(r.parent_run_id);if(i)t.push(i),r=i;else break}return t}getBreadcrumbs(e){let r=[...this.getParents(e).reverse(),e].map((i,s,o)=>{let a=`${i.execution_order}:${i.run_type}:${i.name}`;return s===o.length-1?cr(pR.default.bold,a):a}).join(" > ");return cr(Er.grey,r)}onChainStart(e){let t=this.getBreadcrumbs(e);console.log(`${cr(Er.green,"[chain/start]")} [${t}] Entering Chain run with input: ${oi(e.inputs,"[inputs]")}`)}onChainEnd(e){let t=this.getBreadcrumbs(e);console.log(`${cr(Er.cyan,"[chain/end]")} [${t}] [${ga(e)}] Exiting Chain run with output: ${oi(e.outputs,"[outputs]")}`)}onChainError(e){let t=this.getBreadcrumbs(e);console.log(`${cr(Er.red,"[chain/error]")} [${t}] [${ga(e)}] Chain run errored with error: ${oi(e.error,"[error]")}`)}onLLMStart(e){let t=this.getBreadcrumbs(e),r="prompts"in e.inputs?{prompts:e.inputs.prompts.map(i=>i.trim())}:e.inputs;console.log(`${cr(Er.green,"[llm/start]")} [${t}] Entering LLM run with input: ${oi(r,"[inputs]")}`)}onLLMEnd(e){let t=this.getBreadcrumbs(e);console.log(`${cr(Er.cyan,"[llm/end]")} [${t}] [${ga(e)}] Exiting LLM run with output: ${oi(e.outputs,"[response]")}`)}onLLMError(e){let t=this.getBreadcrumbs(e);console.log(`${cr(Er.red,"[llm/error]")} [${t}] [${ga(e)}] LLM run errored with error: ${oi(e.error,"[error]")}`)}onToolStart(e){let t=this.getBreadcrumbs(e);console.log(`${cr(Er.green,"[tool/start]")} [${t}
114] Entering Tool run with input: "${T4(e.inputs.input)}"`)}onToolEnd(e){let t=this.getBreadcrumbs(e);console.log(`${cr(Er.cyan,"[tool/end]")} [${t}] [${ga(e)}] Exiting Tool run with output: "${T4(e.outputs?.output)}"`)}onToolError(e){let t=this.getBreadcrumbs(e);console.log(`${cr(Er.red,"[tool/error]")} [${t}] [${ga(e)}] Tool run errored with error: ${oi(e.error,"[error]")}`)}onRetrieverStart(e){let t=this.getBreadcrumbs(e);console.log(`${cr(Er.green,"[retriever/start]")} [${t}] Entering Retriever run with input: ${oi(e.inputs,"[inputs]")}`)}onRetrieverEnd(e){let t=this.getBreadcrumbs(e);console.log(`${cr(Er.cyan,"[retriever/end]")} [${t}] [${ga(e)}] Exiting Retriever run with output: ${oi(e.outputs,"[outputs]")}`)}onRetrieverError(e){let t=this.getBreadcrumbs(e);console.log(`${cr(Er.red,"[retriever/error]")} [${t}] [${ga(e)}] Retriever run errored with error: ${oi(e.error,"[error]")}`)}onAgentAction(e){let t=e,r=this.getBreadcrumbs(e);console.log(`${cr(Er.blue,"[agent/action]")} [${r}] Agent selected action: ${oi(t.actions[t.actions.length-1],"[action]")}`)}};function mR(n){return!!(n&&typeof n=="object"&&"type"in n&&n.type==="tool_call")}var $v=class extends Error{constructor(e,t){super(e),Object.defineProperty(this,"output",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.output=t}};function A4(n){if(typeof n>"u")return null;try{return JSON.parse(n)}catch{}let e="",t=[],r=!1,i=!1;for(let s of n){if(r)s==='"'&&!i?r=!1:s===` 115`&&!i?s="\\n":s==="\\"?i=!i:i=!1;else if(s==='"')r=!0,i=!1;else if(s==="{")t.push("}");else if(s==="[")t.push("]");else if(s==="}"||s==="]")if(t&&t[t.length-1]===s)t.pop();else return null;e+=s}r&&(e+='"');for(let s=t.length-1;s>=0;s-=1)e+=t[s];try{return JSON.parse(e)}catch{return null}}function Vc(n,e){return typeof n=="string"?typeof e=="string"?n+e:[{type:"text",text:n},...e]:Array.isArray(e)?Uv(n,e)??[...n,...e]:[...n,{type:"text",text:e}]}function rce(n,e){function t(r,i){if(typeof r!="object"||r===null||r===void 0)return r;if(i>=e)return Array.isArray(r)?"[Array]":"[Object]";if(Array.isArray(r))return r.map(o=>t(o,i+1));let s={};for(let o of Object.keys(r))s[o]=t(r[o],i+1);return s}return JSON.stringify(t(n,0),null,2)}var bo=class extends vo{get lc_aliases(){return{additional_kwargs:"additional_kwargs",response_metadata:"response_metadata"}}get text(){return typeof this.content=="string"?this.content:""}constructor(e,t){typeof e=="string"&&(e={content:e,additional_kwargs:t,response_metadata:{}}),e.additional_kwargs||(e.additional_kwargs={}),e.response_metadata||(e.response_metadata={}),super(e),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","messages"]}),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"content",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"additional_kwargs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"response_metadata",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=e.name,this.content=e.content,this.additional_kwargs=e.additional_kwargs,this.response_metadata=e.response_metadata,this.id=e.id}toDict(){return{type:this._getType(),data:this.toJSON().kwargs}}static lc_name(){return"BaseMessage"}
115get _printableFields(){return{id:this.id,content:this.content,name:this.name,additional_kwargs:this.additional_kwargs,response_metadata:this.response_metadata}}_updateId(e){this.id=e,this.lc_kwargs.id=e}get[Symbol.toStringTag](){return this.constructor.lc_name()}[Symbol.for("nodejs.util.inspect.custom")](e){if(e===null)return this;let t=rce(this._printableFields,Math.max(4,e));return`${this.constructor.lc_name()} ${t}`}};function ws(n,e){let t=_({},n);for(let[r,i]of Object.entries(e))if(t[r]==null)t[r]=i;else{if(i==null)continue;if(typeof t[r]!=typeof i||Array.isArray(t[r])!==Array.isArray(i))throw new Error(`field[${r}] already exists in the message chunk, but with a different type.`);if(typeof t[r]=="string"){if(r==="type")continue;t[r]+=i}else if(typeof t[r]=="object"&&!Array.isArray(t[r]))t[r]=ws(t[r],i);else if(Array.isArray(t[r]))t[r]=Uv(t[r],i);else{if(t[r]===i)continue;console.warn(`field[${r}] already exists in this message chunk and value has unsupported type.`)}}return t}function Uv(n,e){if(!(n===void 0&&e===void 0)){if(n===void 0||e===void 0)return n||e;{let t=[...n];for(let r of e)if(typeof r=="object"&&"index"in r&&typeof r.index=="number"){let i=t.findIndex(s=>s.index===r.index);i!==-1?t[i]=ws(t[i],r):t.push(r)}else{if(typeof r=="object"&&"text"in r&&r.text==="")continue;t.push(r)}return t}}}var wo=class extends bo{};var jc=class n extends wo{constructor(e){let t;if(typeof e=="string")t={content:e,tool_calls:[],invalid_tool_calls:[],tool_call_chunks:[]};else if(e.tool_call_chunks===void 0)t=D(_({},e),{tool_calls:e.tool_calls??[],invalid_tool_calls:[],tool_call_chunks:[]});else{let r=[],i=[];for(let s of e.tool_call_chunks){let o={};try{if(o=A4(s.args||"{}"),o===null||typeof o!="object"||Array.isArray(o))throw new Error("Malformed tool call chunk args.");r.push({name:s.name??"",args:o,id:s.id,type:"tool_call"})}catch{i.push({name:s.name,args:s.args,id:s.id,error:"Malformed args.",type:"invalid_tool_call"})}}t=D(_({},e),{tool_calls:r,invalid_tool_calls:i})}super(t),Object.defineProperty(this,"tool_calls",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"invalid_tool_calls",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"tool_call_chunks",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"usage_metadata",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.tool_call_chunks=t.tool_call_chunks??this.tool_call_chunks,this.tool_calls=t.tool_calls??this.tool_calls,this.invalid_tool_calls=t.invalid_tool_calls??this.invalid_tool_calls,this.usage_metadata=t.usage_metadata}get lc_aliases(){return D(_({}
115,super.lc_aliases),{tool_calls:"tool_calls",invalid_tool_calls:"invalid_tool_calls",tool_call_chunks:"tool_call_chunks"})}static lc_name(){return"AIMessageChunk"}_getType(){return"ai"}get _printableFields(){return D(_({},super._printableFields),{tool_calls:this.tool_calls,tool_call_chunks:this.tool_call_chunks,invalid_tool_calls:this.invalid_tool_calls,usage_metadata:this.usage_metadata})}concat(e){let t={content:Vc(this.content,e.content),additional_kwargs:ws(this.additional_kwargs,e.additional_kwargs),response_metadata:ws(this.response_metadata,e.response_metadata),tool_call_chunks:[],id:this.id??e.id};if(this.tool_call_chunks!==void 0||e.tool_call_chunks!==void 0){let r=Uv(this.tool_call_chunks,e.tool_call_chunks);r!==void 0&&r.length>0&&(t.tool_call_chunks=r)}if(this.usage_metadata!==void 0||e.usage_metadata!==void 0){let r=this.usage_metadata??{input_tokens:0,output_tokens:0,total_tokens:0},i=e.usage_metadata??{input_tokens:0,output_tokens:0,total_tokens:0},s={input_tokens:r.input_tokens+i.input_tokens,output_tokens:r.output_tokens+i.output_tokens,total_tokens:r.total_tokens+i.total_tokens};t.usage_metadata=s}return new n(t)}};function C4(n,e="Human",t="AI"){let r=[];for(let i of n){let s;if(i._getType()==="human")s=e;else if(i._getType()==="ai")s=t;else if(i._getType()==="system")s="System";else if(i._getType()==="function")s="Function";else if(i._getType()==="tool")s="Tool";else if(i._getType()==="generic")s=i.role;else throw new Error(`Got unsupported message type: ${i._getType()}`);let o=i.name?`${i.name}, `:"",a=typeof i.content=="string"?i.content:JSON.stringify(i.content,null,2);r.push(`${s}: ${o}${a}`)}return r.join(` 116`)}var Bu=class n extends si{constructor(e={}){super(e),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"langchain_tracer"}),Object.defineProperty(this,"projectName",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"exampleId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"client",{enumerable:!0,configurable:!0,writable:!0,value:void 0});let{exampleId:t,projectName:r,client:i}=e;this.projectName=r??Oi("LANGCHAIN_PROJECT")??Oi("LANGCHAIN_SESSION"),this.exampleId=t,this.client=i??new Mc({});let s=n.getTraceableRunTree();s&&this.updateFromRunTree(s)}_convertToCreate(e,t=void 0){return m(this,null,function*(){return D(_({},e),{extra:D(_({},e.extra),{runtime:yield v4()}),child_runs:void 0,session_name:this.projectName,reference_example_id:e.parent_run_id?void 0:t})})}persistRun(e){return m(this,null,function*(){})}onRunCreate(e){return m(this,null,function*(){let t=yield this._convertToCreate(e,this.exampleId);yield this.client.createRun(t)})}onRunUpdate(e){return m(this,null,function*(){let t={end_time:e.end_time,error:e.error,outputs:e.outputs,events:e.events,inputs:e.inputs,trace_id:e.trace_id,dotted_order:e.dotted_order,parent_run_id:e.parent_run_id};yield this.client.updateRun(e.id,t)})}getRun(e){return this.runMap.get(e)}updateFromRunTree(e){let t=e,r=new Set;for(;t.parent_run&&!(r.has(t.id)||(r.add(t.id),!t.parent_run));)t=t.parent_run;r.clear();let i=[t];for(;i.length>0;){let s=i.shift();!s||r.has(s.id)||(r.add(s.id),this.runMap.set(s.id,s),s.child_runs&&i.push(...s.child_runs))}this.client=e.client??this.client,this.projectName=e.project_name??this.projectName,this.exampleId=e.reference_example_id??this.exampleId}convertToRunTree(e){let t={},r=[];for(let[i,s]of this.runMap){let o=new pa(D(_({},s),{child_runs:[],parent_run:void 0,client:this.client,project_name:this.projectName,reference_example_id:this.exampleId,tracingEnabled:!0}));t[i]=o,r.push([i,s.dotted_order])}r.sort((i,s)=>!i[1]||!s[1]?0:i[1].localeCompare(s[1]));for(let[i]of r){let s=this.runMap.get(i),o=t[i];if(!(!s||!o)&&s.parent_run_id){let a=t[s.parent_run_id];a&&(a.child_runs.push(o),o.parent_run=a)}}return t[e]}static getTraceableRunTree(){try{return e4()}catch{return}}};var Bv=di(pv(),1);var gR;function ice(){let n="default"in Bv.default?Bv.default.default:Bv.default;return new n({autoStart:!0,concurrency:1})}function on(n,e){return m(this,null,function*(){e===!0?yield n():(typeof gR>"u"&&(gR=ice()),gR.add(n))})}var yR=n=>n!==void 0?n:!!["LANGSMITH_TRACING_V2","LANGCHAIN_TRACING_V2","LANGSMITH_TRACING","LANGCHAIN_TRACING"].find(t=>Oi(t)==="true");yR()&&Oi("LANGCHAIN_CALLBACKS_BACKGROUND")!=="true"&&["[WARN]: You have enabled LangSmith tracing without backgrounding c
116allbacks.","[WARN]: If you are not using a serverless environment where you must wait for tracing calls to finish,",'[WARN]: we suggest setting "process.env.LANGCHAIN_CALLBACKS_BACKGROUND=true" to avoid additional latency.'].join(` 117`);var _R=class{setHandler(e){return this.setHandlers([e])}},Hu=class{constructor(e,t,r,i,s,o,a,c){Object.defineProperty(this,"runId",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"handlers",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"inheritableHandlers",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"tags",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"inheritableTags",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"metadata",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(this,"inheritableMetadata",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(this,"_parentRunId",{enumerable:!0,configurable:!0,writable:!0,value:c})}get parentRunId(){return this._parentRunId}handleText(e){return m(this,null,function*(){yield Promise.all(this.handlers.map(t=>on(()=>m(this,null,function*(){try{yield t.handleText?.(e,this.runId,this._parentRunId,this.tags)}catch(r){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleText: ${r}`),t.raiseError)throw r}}),t.awaitHandlers)))})}handleCustomEvent(e,t,r,i,s){return m(this,null,function*(){yield Promise.all(this.handlers.map(o=>on(()=>m(this,null,function*(){try{yield o.handleCustomEvent?.(e,t,this.runId,this.tags,this.metadata)}catch(a){if((o.raiseError?console.error:console.warn)(`Error in handler ${o.constructor.name}, handleCustomEvent: ${a}`),o.raiseError)throw a}}),o.awaitHandlers)))})}},vR=class extends Hu{getChild(e){let t=new Es(this.runId);return t.setHandlers(this.inheritableHandlers),t.addTags(this.inheritableTags),t.addMetadata(this.inheritableMetadata),e&&t.addTags([e],!1),t}handleRetrieverEnd(e){return m(this,null,function*(){yield Promise.all(this.handlers.map(t=>on(()=>m(this,null,function*(){if(!t.ignoreRetriever)try{yield t.handleRetrieverEnd?.(e,this.runId,this._parentRunId,this.tags)}catch(r){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleRetriever`),t.raiseError)throw r}}),t.awaitHandlers)))})}handleRetrieverError(e){return m(this,null,function*(){yield Promise.all(this.handlers.map(t=>on(()=>m(this,null,function*(){if(!t.ignoreRetriever)try{yield t.handleRetrieverError?.(e,this.runId,this._parentRunId,this.tags)}catch(r){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleRetrieverError: ${r}`),t.raiseError)throw e}}),t.awaitHandlers)))})}},Hv=class extends Hu{handleLLMNewToken(e,t,r,i,s,o){return m(this,null,function*(){yield Promise.all(this.handlers.map(a=>on(()=>m(this,null,function*(){if(!a.ignoreLLM)try{yield a.handleLLMNewToken?.(e,t??{prompt:0,completion:0},this.runId,this._parentRunId,this.tags,o)}catch(c){if((a.raiseError?console.error:console.warn)(`Error in handler ${a.constructor.name}, handleLLMNewToken: ${c}`),a.raiseError)throw c}}),a.awaitHandlers)))})}handleLLMError(e){return m(this,null,function*(){yield Promise.all(this.handlers.map(t=>on(()=>m(this,null,function*(){if(!t.ignoreLLM)try{yield t.handleLLMError?.(e,this.runId,this._parentRunId,this.tags)}catch(r){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleLLMError: ${r}`),t.raiseError)throw r}}),t.awaitHandlers)))})}handleLLMEnd(e){return m(this,null,function*(){yield Promise.all(this.handlers.map(t=>on(()=>m(this,null,function*(){if(!t.ignoreLLM)try{yield t.handleLLMEnd?.(e,this.runId,this._parentRunId,this.tags)}catch(r){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleLLMEnd: ${r}`),t.raiseError)throw r}}),t.awaitHandlers)))})}},bR=class extends Hu{getChild(e){let t=new Es(this.runId);return t.setHandlers(this.inheritableHandlers),t.addTags(this.inheritableTags),t.addMetadata(this.inheritableMetadata),e&&t.addTags([e],!1),t}handleChainError(e,t,r,i,s){return m(this,null,function*(){yield Promise.all(this.handlers.map(o=>on(()=>m(this,null,function*(){if(!o.ignoreChain)try{yield o.handleChainError?.(e,this.runId,this._parentRunId,this.tags,s)}catch(a){if((o.raiseError?console.error:console.warn)(`Error in handler ${o.constructor.name}, handleChainError: ${a}`),o.raiseError)throw a}}),o.awaitHandlers)))})}handleChainEnd(e,t,r,i,s){return m(this,null,function*(){yield Promise.all(this.handlers.map(o=>on(()=>m(this,null,function*(){if(!o.ignoreChain)try{yield o.handleChainEnd?.(e,this.runId,this._parentRunId,this.tags,s)}catch(a){if((o.raiseError?console.error:console.warn)(`Error in handler ${o.constructor.name}, handleChainEnd: ${a}`),o.raiseError)throw a}}),o.awaitHandlers)))})}handleAgentAction(e){return m(this,null,function*(){yield Promise.all(this.handlers.map(t=>on(()=>m(this,null,function*(){if(!t.ignoreAgent)try{yield t.handleAgentAction?.(e,this.runId,this._parentRunId,this.tags)}catch(r){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleAgentAction: ${r}`),t.raiseError)throw r}}),t.awaitHandlers)))})}handleAgentEnd(e){return m(this,null,function*(){yield Promise.all(this.handlers.map(t=>on(()=>m(this,null,function*(){if(!t.ignoreAgent)try{yield t.handleAgentEnd?.(e,this.runId,this._parentRunId,this.tags)}catch(r){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleAgentEnd: ${r}`),t.raiseError)throw r}}),t.awaitHandlers)))})}},wR=class extends Hu{getChild(e){let t=new Es(this.runId);return t.setHandlers(this.inheritableHandlers),t.addTags(this.inheritableTags),t.addMetadata(this.inheritableMetadata),e&&t.addTags([e],!1),t}handleToolError(e){return m(this,null,function*(){yield Promise.all(this.handlers.map(t=>on(()=>m(this,null,function*(){if(!t.ignoreAgent)try{yield t.handleToolError?.(e,this.runId,this._parentRunId,this.tags)}catch(r){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleToolError: ${r}`),t.raiseError)throw r}}),t.awaitHandlers)))})}handleToolEnd(e){return m(this,null,function*(){yield Promise.all(this.handlers.map(t=>on(()=>m(this,null,function*(){if(!t.ignoreAgent)try{yield t.handleToolEnd?.(e,this.runId,this._parentRunId,this.tags)}catch(r){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleToolEnd: ${r}`),t.raiseError)throw r}}),t.awaitHandlers)))})}},Es=class n extends _R{constructor(e,t){super(),Object.defineProperty(this,"handlers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"inheritableHandlers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"tags",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"inheritableTags",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"metadata",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"inheritableMetadata",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"callback_manager"}),Object.defineProperty(this,"_parentRunId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.handlers=t?.handlers??this.handlers,this.inheritableHandlers=t?.inheritableHandlers??this.inheritableHandlers,this.tags=t?.tags??this.tags,this.inheritableTags=t?.inheritableTags??this.inheritableTags,this.metadata=t?.metadata??this.metadata,this.inheritableMetadata=t?.inheritableMetadata??this.inheritableMetadata,this._parentRunId=e}getParentRunId(){return this._parentRunId}handleLLMStart(e,t,r=void 0,i=void 0,s=void 0,o=void 0,a=void 0,c=void 0){return m(this,null,function*(){return Promise.all(t.map((l,u)=>m(this,null,function*(){let d=u===0&&r?r:sn();return yield Promise.all(this.handlers.map(f=>
117{if(!f.ignoreLLM)return Uu(f)&&f._createRunForLLMStart(e,[l],d,this._parentRunId,s,this.tags,this.metadata,c),on(()=>m(this,null,function*(){try{yield f.handleLLMStart?.(e,[l],d,this._parentRunId,s,this.tags,this.metadata,c)}catch(p){if((f.raiseError?console.error:console.warn)(`Error in handler ${f.constructor.name}, handleLLMStart: ${p}`),f.raiseError)throw p}}),f.awaitHandlers)})),new Hv(d,this.handlers,this.inheritableHandlers,this.tags,this.inheritableTags,this.metadata,this.inheritableMetadata,this._parentRunId)})))})}handleChatModelStart(e,t,r=void 0,i=void 0,s=void 0,o=void 0,a=void 0,c=void 0){return m(this,null,function*(){return Promise.all(t.map((l,u)=>m(this,null,function*(){let d=u===0&&r?r:sn();return yield Promise.all(this.handlers.map(f=>{if(!f.ignoreLLM)return Uu(f)&&f._createRunForChatModelStart(e,[l],d,this._parentRunId,s,this.tags,this.metadata,c),on(()=>m(this,null,function*(){try{if(f.handleChatModelStart)yield f.handleChatModelStart?.(e,[l],d,this._parentRunId,s,this.tags,this.metadata,c);else if(f.handleLLMStart){let p=C4(l);yield f.handleLLMStart?.(e,[p],d,this._parentRunId,s,this.tags,this.metadata,c)}}catch(p){if((f.raiseError?console.error:console.warn)(`Error in handler ${f.constructor.name}, handleLLMStart: ${p}`),f.raiseError)throw p}
117}),f.awaitHandlers)})),new Hv(d,this.handlers,this.inheritableHandlers,this.tags,this.inheritableTags,this.metadata,this.inheritableMetadata,this._parentRunId)})))})}handleChainStart(c,l){return m(this,arguments,function*(e,t,r=sn(),i=void 0,s=void 0,o=void 0,a=void 0){return yield Promise.all(this.handlers.map(u=>{if(!u.ignoreChain)return Uu(u)&&u._createRunForChainStart(e,t,r,this._parentRunId,this.tags,this.metadata,i,a),on(()=>m(this,null,function*(){try{yield u.handleChainStart?.(e,t,r,this._parentRunId,this.tags,this.metadata,i,a)}catch(d){if((u.raiseError?console.error:console.warn)(`Error in handler ${u.constructor.name}, handleChainStart: ${d}`),u.raiseError)throw d}}),u.awaitHandlers)})),new bR(r,this.handlers,this.inheritableHandlers,this.tags,this.inheritableTags,this.metadata,this.inheritableMetadata,this._parentRunId)})}handleToolStart(c,l){return m(this,arguments,function*(e,t,r=sn(),i=void 0,s=void 0,o=void 0,a=void 0){return yield Promise.all(this.handlers.map(u=>{if(!u.ignoreAgent)return Uu(u)&&u._createRunForToolStart(e,t,r,this._parentRunId,this.tags,this.metadata,a),on(()=>m(this,null,function*(){try{yield u.handleToolStart?.(e,t,r,this._parentRunId,this.tags,this.metadata,a)}catch(d){if((u.raiseError?console.error:console.warn)(`Error in handler ${u.constructor.name}, handleToolStart: ${d}`),u.raiseError)throw d}}),u.awaitHandlers)})),new wR(r,this.handlers,this.inheritableHandlers,this.tags,this.inheritableTags,this.metadata,this.inheritableMetadata,this._parentRunId)})}handleRetrieverStart(c,l){return m(this,arguments,function*(e,t,r=sn(),i=void 0,s=void 0,o=void 0,a=void 0){return yield Promise.all(this.handlers.map(u=>{if(!u.ignoreRetriever)return Uu(u)&&u._createRunForRetrieverStart(e,t,r,this._parentRunId,this.tags,this.metadata,a),on(()=>m(this,null,function*(){try{yield u.handleRetrieverStart?.(e,t,r,this._parentRunId,this.tags,this.metadata,a)}catch(d){if((u.raiseError?console.error:console.warn)(`Error in handler ${u.constructor.name}, handleRetrieverStart: ${d}`),u.raiseError)throw d}}),u.awaitHandlers)})),new vR(r,this.handlers,this.inheritableHandlers,this.tags,this.inheritableTags,this.metadata,this.inheritableMetadata,this._parentRunId)})}handleCustomEvent(e,t,r,i,s){return m(this,null,function*(){yield Promise.all(this.handlers.map(o=>on(()=>m(this,null,function*(){if(!o.ignoreCustomEvent)try{yield o.handleCustomEvent?.(e,t,r,this.tags,this.metadata)}catch(a){if((o.raiseError?console.error:console.warn)(`Error in handler ${o.constructor.name}, handleCustomEvent: ${a}`),o.raiseError)throw a}}),o.awaitHandlers)))})}addHandler(e,t=!0){this.handlers.push(e),t&&this.inheritableHandlers.push(e)}removeHandler(e){this.handlers=this.handlers.filter(t=>t!==e),this.inheritableHandlers=this.inheritableHandlers.filter(t=>t!==e)}setHandlers(e,t=!0){this.handlers=[],this.inheritableHandlers=[];for(let r of e)this.addHandler(r,t)}addTags(e,t=!0){this.removeTags(e),this.tags.push(...e),t&&this.inheritableTags.push(...e)}removeTags(e){this.tags=this.tags.filter(t=>!e.includes(t)),this.inheritableTags=this.inheritableTags.filter(t=>!e.includes(t))}addMetadata(e,t=!0){this.metadata=_(_({},this.metadata),e),t&&(this.inheritableMetadata=_(_({},this.inheritableMetadata),e))}removeMetadata(e){for(let t of Object.keys(e))delete this.metadata[t],delete this.inheritableMetadata[t]}copy(e=[],t=!0){let r=new n(this._parentRunId);for(let i of this.handlers){let s=this.inheritableHandlers.includes(i);r.addHandler(i,s)}for(let i of this.tags){let s=this.inheritableTags.includes(i);r.addTags([i],s)}for(let i of Object.keys(this.metadata)){let s=Object.keys(this.inheritableMetadata).includes(i);r.addMetadata({[i]:this.metadata[i]},s)}for(let i of e)r.handlers.filter(s=>s.name==="console_callback_handler").some(s=>s.name===i.name)||r.addHandler(i,t);return r}static fromHandlers(e){class t extends Fc{constructor(){super(),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:sn()}),Object.assign(this,e)}}let r=new this;return r.addHandler(new t),r}static configure(e,t,r,i,s,o,a){return m(this,null,function*(){return this._configureSync(e,t,r,i,s,o,a)})}static _configureSync(e,t,r,i,s,o,a){let c;(e||t)&&(Array.isArray(e)||!e?(c=new n,c.setHandlers(e?.map(Ff)??[],!0)):c=e,c=c.copy(Array.isArray(t)?t.map(Ff):t?.handlers,!1));let l=Oi("LANGCHAIN_VERBOSE")==="true"||a?.verbose,u=Bu.getTraceableRu
117nTree()?.tracingEnabled||yR(),d=u||(Oi("LANGCHAIN_TRACING")??!1);if(l||d){if(c||(c=new n),l&&!c.handlers.some(f=>f.name===Lf.prototype.name)){let f=new Lf;c.addHandler(f,!0)}if(d&&!c.handlers.some(f=>f.name==="langchain_tracer")&&u){let f=new Bu;c.addHandler(f,!0),c._parentRunId=Bu.getTraceableRunTree()?.id??c._parentRunId}}return(r||i)&&c&&(c.addTags(r??[]),c.addTags(i??[],!1)),(s||o)&&c&&(c.addMetadata(s??{}),c.addMetadata(o??{},!1)),c}};function Ff(n){return"name"in n?n:Fc.fromMethods(n)}var IR=class{getStore(){}run(e,t){return t()}},sce=new IR,ER=Symbol.for("ls:tracing_async_local_storage"),S4=Symbol.for("lc:child_config"),TR=class{getInstance(){return globalThis[ER]??sce}getRunnableConfig(){return this.getInstance().getStore()?.extra?.[S4]}runWithConfig(e,t,r){let i=Es._configureSync(e?.callbacks,void 0,e?.tags,void 0,e?.metadata),s=this.getInstance(),o=i?.getParentRunId(),a=i?.handlers?.find(l=>l?.name==="langchain_tracer"),c;return a&&o?c=a.convertToRunTree(o):r||(c=new pa({name:"<runnable_lambda>",tracingEnabled:!1})),c&&(c.extra=D(_({},c.extra),{[S4]:e})),s.run(c,t)}initializeGlobalInstance(e){globalThis[ER]===void 0&&(globalThis[ER]=e)}},Li=new TR;function Is(n,e){return m(this,null,function*(){if(e===void 0)return n;let t;return Promise.race([n.catch(r=>{if(!e?.aborted)throw r}),new Promise((r,i)=>{t=()=>{i(new Error("Aborted"))},e.addEventListener("abort",t),e.aborted&&i(new Error("Aborted"))})]).finally(()=>e.removeEventListener("abort",t))})}var Wn=class n extends ReadableStream{constructor(){super(...arguments),Object.defineProperty(this,"reader",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}ensureReader(){this.reader||(this.reader=this.getReader())}next(){return m(this,null,function*(){this.ensureReader();try{let e=yield this.reader.read();return e.done?(this.reader.releaseLock(),{done:!0,value:void 0}):{done:!1,value:e.value}}catch(e){throw this.reader.releaseLock(),e}})}return(){return m(this,null,function*(){if(this.ensureReader(),this.locked){let e=this.reader.cancel();this.reader.releaseLock(),yield e}return{done:!0,value:void 0}})}throw(e){return m(this,null,function*(){if(this.ensureReader(),this.locked){let t=this.reader.cancel();this.reader.releaseLock(),yield t}throw e})}[Symbol.asyncIterator](){return this}[Symbol.asyncDispose](){return m(this,null,function*(){yield this.return()})}static fromReadableStream(e){let t=e.getReader();return new n({start(r){return i();function i(){return t.read().then(({done:s,value:o})=>{if(s){r.close();return}return r.enqueue(o),i()})}},cancel(){t.releaseLock()}})}static fromAsyncGenerator(e){return new n({pull(r){return m(this,null,function*(){let{value:i,done:s}=yield e.next();s&&r.close(),r.enqueue(i)})},cancel(r){return m(this,null,function*(){yield e.return(r)})}})}};function AR(n,e=2){let t=Array.from({length:e},()=>[]);return t.map(function(i){return Re(this,null,function*(){for(;;)if(i.length===0){let s=yield new z(n.next());for(let o of t)o.push(s)}else{if(i[0].done)return;yield i.shift().value}})})}function Ts(n,e){if(Array.isArray(n)&&Array.isArray(e))return n.concat(e);if(typeof n=="string"&&typeof e=="string")return n+e;if(typeof n=="number"&&typeof e=="number")return n+e;if("concat"in n&&typeof n.concat=="function")return n.concat(e);if(typeof n=="object"&&typeof e=="object"){let t=_({},n);for(let[r,i]of Object.entries(e))r in t&&!Array.isArray(t[r])?t[r]=Ts(t[r],i):t[r]=i;return t}else throw new Error(`Cannot concat ${typeof n} and ${typeof e}`)}var Eo=class{constructor(e){Object.defineProperty(this,"generator",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"setup",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"config",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"signal",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"firstResult",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"firstResultUsed",{enumerable:!0,configurable:!0,writable:!0,value:!1}),this.generator=e.generator,this.config=e.config,this.signal=e.signal??this.config?.signal,this.setup=new Promise((t,r)=>{Li.runWithConfig(e.config,()=>m(this,null,function*(){this.firstResult=e.generator.next(),e.startSetup?this.firstResult.then(e.startSetup).then(t,r):this.firstResult.then(i=>t(void 0),r)}),!0)})}next(...e){return m(this,null,function*(){return this.signal?.throwIfAborted(),this.firstResultUsed?Li.runWithConfig(this.config,this.signal?()=>m(this,null,function*(){return Is(this.generator.next(...e),this.signal)}
117):()=>m(this,null,function*(){return this.generator.next(...e)}),!0):(this.firstResultUsed=!0,this.firstResult)})}return(e){return m(this,null,function*(){return this.generator.return(e)})}throw(e){return m(this,null,function*(){return this.generator.throw(e)})}[Symbol.asyncIterator](){return this}[Symbol.asyncDispose](){return m(this,null,function*(){yield this.return()})}};function x4(n,e,t,r,...i){return m(this,null,function*(){let s=new Eo({generator:e,startSetup:t,signal:r}),o=yield s.setup;return{output:n(s,o,...i),setup:o}})}var Fi=class{constructor(e){Object.defineProperty(this,"ops",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.ops=e.ops??[]}concat(e){let t=this.ops.concat(e.ops),r=Lc({},t);return new Vf({ops:t,state:r[r.length-1].newDocument})}},Vf=class n extends Fi{constructor(e){super(e),Object.defineProperty(this,"state",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.state=e.state}concat(e){let t=this.ops.concat(e.ops),r=Lc(this.state,e.ops);return new n({ops:t,state:r[r.length-1].newDocument})}static fromRunLogPatch(e){let t=Lc({},e.ops);return new n({ops:e.ops,state:t[t.length-1].newDocument})}},k4=n=>n.name==="log_stream_tracer";function D4(n,e){return m(this,null,function*(){if(e==="original")throw new Error("Do not assign inputs with original schema drop the key for now. When inputs are added to streamLog they should be added with standardized schema for streaming events.");let{inputs:t}=n;if(["retriever","llm","prompt"].includes(n.run_type))return t;if(!(Object.keys(t).length===1&&t?.input===""))return t.input})}function R4(n,e){return m(this,null,function*(){let{outputs:t}=n;return e==="original"||["retriever","llm","prompt"].includes(n.run_type)?t:t!==void 0&&Object.keys(t).length===1&&t?.output!==void 0?t.output:t})}function oce(n){return n!==void 0&&n.message!==void 0}var jf=class extends si{constructor(e){super(_({_awaitHandler:!0},e)),Object.defineProperty(this,"autoClose",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"includeNames",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"includeTypes",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"includeTags",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"excludeNames",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"excludeTypes",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"excludeTags",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_schemaFormat",{enumerable:!0,configurable:!0,writable:!0,value:"original"}),Object.defineProperty(this,"rootId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"keyMapByRunId",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"counterMapByRunName",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"transformStream",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"writer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"receiveStream",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"log_stream_tracer"}),this.autoClose=e?.autoClose??!0,this.includeNames=e?.includeNames,this.includeTypes=e?.includeTypes,this.includeTags=e?.includeTags,this.excludeNames=e?.excludeNames,this.excludeTypes=e?.excludeTypes,this.excludeTags=e?.excludeTags,this._schemaFormat=e?._schemaFormat??this._schemaFormat,this.transformStream=new TransformStream,this.writer=this.transformStream.writable.getWriter(),this.receiveStream=Wn.fromReadableStream(this.transformStream.readable)}[Symbol.asyncIterator](){return this.receiveStream}persistRun(e){return m(this,null,function*(){})}_includeRun(e){if(e.id===this.rootId)return!1;let t=e.tags??[],r=this.includeNames===void 0&&this.includeTags===void 0&&this.includeTypes===void 0;return this.includeNames!==void 0&&(r=r||this.includeNames.includes(e.name)),this.includeTypes!==void 0&&(r=r||this.includeTypes.includes(e.run_type)),this.includeTags!==void 0&&(r=r||t.find(i=>this.includeTags?.includes(i))!==void 0),this.excludeNames!==void 0&&(r=r&&!this.excludeNames.includes(e.name)),this.excludeTypes!==void 0&&(r=r&&!this.excludeTypes.includes(e.run_type)),this.excludeTags!==void 0&&(r=r&&t.every(i=>!this.excludeTags?.includes(i))),r}tapOutputIterable(e,t){return Re(this,null,function*(){try{for(var r=Ge(t),i,s,o;i=!(s=yield new z(r.next())).done;i=!1){let a=s.value;if(e!==this.rootId){let c=this.keyMapByRunId[e];c&&(yield new z(this.writer.write(new Fi({ops:[{op:"add",path:`/logs/${c}/streamed_output/-`,value:a}]}))))}yield a}}catch{o=[s]}finally{try{i&&(s=r.return)&&(yield new z(s.call(r)))}finally{if(o)throw o[0]}}})}onRunCreate(e){return m(this,null,function*(){if(this.rootId===void 0&&(this.rootId=e.id,yield this.writer.write(new Fi({ops:[{op:"replace",path:"",value:{id:e.id,name:e.name,type:e.run_type,streamed_output:[],final_output:void 0,logs:{}}}]}))),!this._includeRun(e))return;this.counterMapByRunName[e.name]===void 0&&(this.counterMapByRunName[e.name]=0),this.counterMapByRunName[e.name]+=1;let t=this.counterMapByRunName[e.name];this.keyMapByRunId[e.id]=t===1?e.name:`${e.name}:${t}`;let r={id:e.id,name:e.name,type:e.run_type,tags:e.tags??[],metadata:e.extra?.metadata??{},start_time:new Date(e.start_time).toISOString(),streamed_output:[],streamed_output_str:[],final_output:void 0,end_time:void 0};this._schemaFormat==="streaming_events"&&(r.inputs=yield D4(e,this._schemaFormat)),yield this.writer.write(new Fi({ops:[{op:"add",path:`/logs/${this.keyMapByRunId[e.id]}`,value:r}]}))})}onRunUpdate(e){return m(this,null,function*(){try{let t=this.keyMapByRunId[e.id];if(t===void 0)return;let r=[];this._schemaFormat==="streaming_events"&&r.push({op:"replace",path:`/logs/${t}/inputs`,value:yield D4(e,this._schemaFormat)}),r.push({op:"add",path:`/logs/${t}/final_output`,value:yield R4(e,this._schemaFormat)}),e.end_time!==void 0&&r.push({op:"add",path:`/logs/${t}/end_time`,value:new Date(e.end_time).toISOString()});let i=new Fi({ops:r});yield this.writer.write(i)}finally{if(e.id===this.rootId){let t=new Fi({ops:[{op:"replace",path:"/final_output",value:yield R4(e,this._schemaFormat)}]});yield this.writer.write(t),this.autoClose&&(yield this.writer.close())}}})}onLLMNewToken(e,t,r){return m(this,null,function*(){let i=this.keyMapByRunId[e.id];if(i===void 0)return;let s=e.inputs.messages!==void 0,o;s?oce(r?.chunk)?o=r?.chunk:o=new jc({id:`run-${e.id}`,content:t}):o=t;let a=new Fi({ops:[{op:"add",path:`/logs/${i}/streamed_output_str/-`,value:t},{op:"add",path:`/logs/${i}/streamed_output/-`,value:o}]});yield this.writer.write(a)})}};var $f=class n{constructor(e){Object.defineProperty(this,"text",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"generationInfo",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.text=e.text,this.generationInfo=e.generationInfo}concat(e){return new n({text:this.text+e.text,generationInfo:_(_({},this.generationInfo),e.generationInfo)})}};function qv({name:n,serialized:e}){return n!==void 0?n:e?.name!==void 0?e.name:e?.id!==void 0&&Array.isArray(e?.id)?e.id[e.id.length-1]:"Unnamed"}var P4=n=>n.name==="event_stream_tracer",zv=class extends si{constructor(e){super(_({_awaitHandler:!0},e)),Object.defineProperty(this,"autoClose",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"includeNames",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"includeTypes",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"includeTags",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"excludeNames",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"excludeTypes",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"excludeTags",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"runInfoMap",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"tappedPromises",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"transformStream",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"writer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"receiveStream",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"event_stream_tracer"}),this.autoClose=e?.autoClose??!0,this.includeNames=e?.includeNames,this.includeTypes=e?.includeTypes,this.includeTags=e?.includeTags,this.excludeNames=e?.excludeNames,this.excludeTypes=e?.excludeTypes,this.excludeTags=e?.excludeTags,this.transformStream=new TransformStream,this.writer=this.transformStream.writable.getWriter(),this.receiveStream=Wn.fromReadableStream(this.transformStream.readable)}[Symbol.asyncIterator](){return this.receiveStream}persistRun(e){return m(this,null,function*(){})}_includeRun(e){let t=e.tags??[],r=this.includeNames===void 0&&this.includeTags===void 0&&this.includeTypes===void 0;return this.includeNames!==void 0&&(r=r||this.includeNames.includes(e.name)),this.includeTypes!==void 0&&(r=r||this.includeTypes.includes(e.runType)),this.includeTags!==void 0&&(r=r||t.find(i=>this.includeTags?.includes(i))!==void 0),this.excludeNames!==void 0&&(r=r&&!this.excludeNames.includes(e.name)),this.excludeTypes!==void 0&&(r=r&&!this.excludeTypes.includes(e.runType)),this.excludeTags!==void 0&&(r=r&&t.every(i=>!this.excludeTags?.includes(i))),r}tapOutputIterable(e,t){return Re(this,null,function*(){let r=yield new z(t.
117next());if(r.done)return;let i=this.runInfoMap.get(e);if(i===void 0){yield r.value;return}function s(v,w){return v==="llm"&&typeof w=="string"?new $f({text:w}):w}let o=this.tappedPromises.get(e);if(o===void 0){let v;o=new Promise(w=>{v=w}),this.tappedPromises.set(e,o);try{let w={event:`on_${i.runType}_stream`,run_id:e,name:i.name,tags:i.tags,metadata:i.metadata,data:{}};yield new z(this.send(D(_({},w),{data:{chunk:s(i.runType,r.value)}}),i)),yield r.value;try{for(var a=Ge(t),c,l,u;c=!(l=yield new z(a.next())).done;c=!1){let E=l.value;i.runType!=="tool"&&i.runType!=="retriever"&&(yield new z(this.send(D(_({},w),{data:{chunk:s(i.runType,E)}}),i))),yield E}}catch{u=[l]}finally{try{c&&(l=a.return)&&(yield new z(l.call(a)))}finally{if(u)throw u[0]}}}finally{v()}}else{yield r.value;try{for(var d=Ge(t),f,p,y;f=!(p=yield new z(d.next())).done;f=!1){let v=p.value;yield v}}catch{y=[p]}finally{try{f&&(p=d.return)&&(yield new z(p.call(d)))}finally{if(y)throw y[0]}}}})}send(e,t){return m(this,null,function*(){this._includeRun(t)&&(yield this.writer.write(e))})}sendEndEvent(e,t){return m(this,null,function*(){let r=this.tappedPromises.get(e.run_id);r!==void 0?r.then(()=>{this.send(e,t)}):yield this.send(e,t)})}onLLMStart(e){return m(this,null,function*(){let t=qv(e),r=e.inputs.messages!==void 0?"chat_model":"llm",i={tags:e.tags??[],metadata:e.extra?.metadata??{},name:t,runType:r,inputs:e.inputs};this.runInfoMap.set(e.id,i);let s=`on_${r}_start`;yield this.send({event:s,data:{input:e.inputs},name:t,tags:e.tags??[],run_id:e.id,metadata:e.extra?.metadata??{}},i)})}onLLMNewToken(e,t,r){return m(this,null,function*(){let i=this.runInfoMap.get(e.id),s,o;if(i===void 0)throw new Error(`onLLMNewToken: Run ID ${e.id} not found in run map.`);if(this.runInfoMap.size!==1){if(i.runType==="chat_model")o="on_chat_model_stream",r?.chunk===void 0?s=new jc({content:t,id:`run-${e.id}`}):s=r.chunk.message;else if(i.runType==="llm")o="on_llm_stream",r?.chunk===void 0?s=new $f({text:t}):s=r.chunk;else throw new Error(`Unexpected run type ${i.runType}`);yield this.send({event:o,data:{chunk:s},run_id:e.id,name:i.name,tags:i.tags,metadata:i.metadata},i)}})}onLLMEnd(e){return m(this,null,function*(){let t=this.runInfoMap.get(e.id);this.runInfoMap.delete(e.id);let r;if(t===void 0)throw new Error(`onLLMEnd: Run ID ${e.id} not found in run map.`);let i=e.outputs?.generations,s;if(t.runType==="chat_model"){for(let o of i??[]){if(s!==void 0)break;s=o[0]?.message}r="on_chat_model_end"}else if(t.runType==="llm")s={generations:i?.map(o=>o.map(a=>({text:a.text,generationInfo:a.generationInfo}))),llmOutput:e.outputs?.llmOutput??{}},r="on_llm_end";else throw new Error(`onLLMEnd: Unexpected run type: ${t.runType}`);yield this.sendEndEvent({event:r,data:{output:s,input:t.inputs},run_id:e.id,name:t.name,tags:t.tags,metadata:t.metadata},t)})}onChainStart(e){return m(this,null,function*(){let t=qv(e),r=e.run_type??"chain",i={tags:e.tags??[],metadata:e.extra?.metadata??{},name:t,runType:e.run_type},s={};e.inputs.input===""&&Object.keys(e.inputs).length===1?(s={},i.inputs={}):e.inputs.input!==void 0?(s.input=e.inputs.input,i.inputs=e.inputs.input):(s.input=e.inputs,i.inputs=e.inputs),this.runInfoMap.set(e.id,i),yield this.send({event:`on_${r}_start`,data:s,name:t,tags:e.tags??[],run_id:e.id,metadata:e.extra?.metadata??{}},i)})}onChainEnd(e){return m(this,null,function*(){let t=this.runInfoMap.get(e.id);if(this.runInfoMap.delete(e.id),t===void 0)throw new Error(`onChainEnd: Run ID ${e.id} not found in run map.`);let r=`on_${e.run_type}_end`,i=e.inputs??t.inputs??{},o={output:e.outputs?.output??e.outputs,input:i};i.input&&Object.keys(i).length===1&&(o.input=i.input,t.inputs=i.input),yield this.sendEndEvent({event:r,data:o,run_id:e.id,name:t.name,tags:t.tags,metadata:t.metadata??{}},t)})}onToolStart(e){return m(this,null,function*(){let t=qv(e),r={tags:e.tags??[],metadata:e.extra?.metadata??{},name:t,runType:"tool",inputs:e.inputs??{}};this.runInfoMap.set(e.id,r),yield this.send({event:"on_tool_start",data:{input:e.inputs??{}},name:t,run_id:e.id,tags:e.tags??[],metadata:e.extra?.metadata??{}},r)})}onToolEnd(e){return m(this,null,function*(){let t=this.runInfoMap.get(e.id);if(this.runInfoMap.delete(e.id),t===void 0)throw new Error(`onToolEnd: Run ID ${e.id} not found in run map.`);
117if(t.inputs===void 0)throw new Error(`onToolEnd: Run ID ${e.id} is a tool call, and is expected to have traced inputs.`);let r=e.outputs?.output===void 0?e.outputs:e.outputs.output;yield this.sendEndEvent({event:"on_tool_end",data:{output:r,input:t.inputs},run_id:e.id,name:t.name,tags:t.tags,metadata:t.metadata},t)})}onRetrieverStart(e){return m(this,null,function*(){let t=qv(e),i={tags:e.tags??[],metadata:e.extra?.metadata??{},name:t,runType:"retriever",inputs:{query:e.inputs.query}};this.runInfoMap.set(e.id,i),yield this.send({event:"on_retriever_start",data:{input:{query:e.inputs.query}},name:t,tags:e.tags??[],run_id:e.id,metadata:e.extra?.metadata??{}},i)})}onRetrieverEnd(e){return m(this,null,function*(){let t=this.runInfoMap.get(e.id);if(this.runInfoMap.delete(e.id),t===void 0)throw new Error(`onRetrieverEnd: Run ID ${e.id} not found in run map.`);yield this.sendEndEvent({event:"on_retriever_end",data:{output:e.outputs?.documents??e.outputs,input:t.inputs},run_id:e.id,name:t.name,tags:t.tags,metadata:t.metadata},t)})}handleCustomEvent(e,t,r){return m(this,null,function*(){let i=this.runInfoMap.get(r);if(i===void 0)throw new Error(`handleCustomEvent: Run ID ${r} not found in run map.`);yield this.send({event:"on_custom_event",run_id:r,name:e,tags:i.tags,metadata:i.metadata,data:t},i)})}finish(){return m(this,null,function*(){let e=[...this.tappedPromises.values()];Promise.all(e).finally(()=>{this.writer.close()})})}};var Gv=25;function ai(n){return m(this,null,function*(){return Es._configureSync(n?.callbacks,void 0,n?.tags,void 0,n?.metadata)})}function CR(...n){let e={};for(let t of n.filter(r=>!!r))for(let r of Object.keys(t))if(r==="metadata")e[r]=_(_({},e[r]),t[r]);else if(r==="tags"){let i=e[r]??[];e[r]=[...new Set(i.concat(t[r]??[]))]}else if(r==="configurable")e[r]=_(_({},e[r]),t[r]);else if(r==="timeout")e.timeout===void 0?e.timeout=t.timeout:t.timeout!==void 0&&(e.timeout=Math.min(e.timeout,t.timeout));else if(r==="signal")e.signal===void 0?e.signal=t.signal:t.signal!==void 0&&("any"in AbortSignal?e.signal=AbortSignal.any([e.signal,t.signal]):e.signal=t.signal);else if(r==="callbacks"){let i=e.callbacks,s=t.callbacks;if(Array.isArray(s))if(!i)e.callbacks=s;else if(Array.isArray(i))e.callbacks=i.concat(s);else{let o=i.copy();for(let a of s)o.addHandler(Ff(a),!0);e.callbacks=o}else if(s)if(!i)e.callbacks=s;else if(Array.isArray(i)){let o=s.copy();for(let a of i)o.addHandler(Ff(a),!0);e.callbacks=o}else e.callbacks=new Es(s._parentRunId,{handlers:i.handlers.concat(s.handlers),inheritableHandlers:i.inheritableHandlers.concat(s.inheritableHandlers),tags:Array.from(new Set(i.tags.concat(s.tags))),inheritableTags:Array.from(new Set(i.inheritableTags.concat(s.inheritableTags))),metadata:_(_({},i.metadata),s.metadata)})}else{let i=r;e[i]=t[i]??e[i]}return e}var ace=new Set(["string","number","boolean"]);function wt(n){let e=Li.getRunnableConfig(),t={tags:[],metadata:{},recursionLimit:25,runId:void 0};if(e){let r=e,{runId:i,runName:s}=r,o=Xt(r,["runId","runName"]);t=Object.entries(o).reduce((a,[c,l])=>(l!==void 0&&(a[c]=l),a),t)}if(n&&(t=Object.entries(n).reduce((i,[s,o])=>(o!==void 0&&(i[s]=o),i),t)),t?.configurable)for(let i of Object.keys(t.configurable))ace.has(typeof t.configurable[i])&&!t.metadata?.[i]&&(t.metadata||(t.metadata={}),t.metadata[i]=t.configurable[i]);if(t.timeout!==void 0){if(t.timeout<=0)throw new Error("Timeout must be a positive number");let i=AbortSignal.timeout(t.timeout);t.signal!==void 0?"any"in AbortSignal&&(t.signal=AbortSignal.any([t.signal,i])):t.signal=i,delete t.timeout}return t}function Dn(n={},{callbacks:e,maxConcurrency:t,recursionLimit:r,runName:i,configurable:s,runId:o}={}){let a=wt(n);return e!==void 0&&(delete a.runName,a.callbacks=e),r!==void 0&&(a.recursionLimit=r),t!==void 0&&(a.maxConcurrency=t),i!==void 0&&(a.runName=i),s!==void 0&&(a.configurable=_(_({},a.configurable),s)),o!==void 0&&delete a.runId,a}var M4=di(ov(),1),Wv=di(pv(),1),cce=[400,401,402,403,404,405,406,407,409],lce=n=>{if(n.message.startsWith("Cancel")||n.message.startsWith("AbortError")||n.name==="AbortError"||n?.code==="ECONNABORTED")throw n;let e=n?.response?.status??n?.status;if(e&&cce.includes(+e))throw n;if(n?.error?.code==="insufficient_quota"){let t=new Error(n?.message);throw t.name="InsufficientQuotaError",t}},Uf=class{constructor(e){Object.defineProperty(this,"maxConcurrency",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"maxRetries",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onFailedAttempt",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"queue",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxConcurrency=e.maxConcurrency??1/0,this.maxRetries=e.maxRetries??6,this.onFailedAttempt=e.onFailedAttempt??lce;let t="default"in Wv.default?Wv.default.default:Wv.default;this.queue=new t({concurrency:this.maxConcurrency})}call(e,...t){return this.queue.add(()=>(0,M4.default)(()=>e(...t).catch(r=>{throw r instanceof Error?r:new Error(r)}),{onFailedAttempt:this.onFailedAttempt,retries:this.maxRetries,randomize:!0}),{throwOnTimeout:!0})}callWithOptions(e,t,...r){return e.signal?Promise.race([this.call(t,...r),new Promise((i,s)=>{e.signal?.addEventListener("abort",()=>{s(new Error("AbortError"))})})]):this.call(t,...r)}fetch(...e){return this.call(()=>fetch(...e).then(t=>t.ok?t:Promise.reject(t)))}};var Bf=class extends si{constructor({config:e,onStart:t,onEnd:r,onError:i}){super({_awaitHandler:!0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RootListenersTracer"}),Object.defineProperty(this,"rootId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"config",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"argOnStart",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"argOnEnd",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"argOnError",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.config=e,this.argOnStart=t,this.argOnEnd=r,this.argOnError=i}persistRun(e){return Promise.resolve()}onRunCreate(e){return m(this,null,function*(){this.rootId||(this.rootId=e.id,this.argOnStart&&(this.argOnStart.length===1?yield this.argOnStart(e):this.argOnStart.length===2&&(yield this.argOnStart(e,this.config))))})}onRunUpdate(e){return m(this,null,function*(){e.id===this.rootId&&(e.error?this.argOnError&&(this.argOnError.length===1?yield this.argOnError(e):this.argOnError.length===2&&(yield this.argOnError(e,this.config))):this.argOnEnd&&(this.argOnEnd.length===1?yield this.argOnEnd(e):this.argOnEnd.length===2&&(yield this.argOnEnd(e,this.config))))})}};function Hf(n){return n?n.lc_runnable:!1}var Kv=class{constructor(e){Object.defineProperty(this,"includeNames",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"includeTypes",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"includeTags",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"excludeNames",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"excludeTypes",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"excludeTags",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.includeNames=e.includeNames,this.includeTypes=e.includeTypes,this.includeTags=e.includeTags,this.excludeNames=e.excludeNames,this.excludeTypes=e.excludeTypes,this.excludeTags=e.excludeTags}includeEvent(e,t){let r=this.includeNames===void 0&&this.includeTypes===void 0&&this.includeTags===void 0,i=e.tags??[];return this.includeNames!==void 0&&(r=r||this.includeNames.includes(e.name)),this.includeTypes!==void 0&&(r=r||this.includeTypes.includes(t)),this.includeTags!==void 0&&(r=r||i.some(s=>this.includeTags?.includes(s))),this.excludeNames!==void 0&&(r=r&&!this.excludeNames.includes(e.name)),this.excludeTypes!==void 0&&(r=r&&!this.excludeTypes.includes(t)),this.excludeTags!==void 0&&(r=r&&i.every(s=>!this.excludeTags?.includes(s))),r}};var O4=Symbol("Let zodToJsonSchema decide on which parser to use");var N4={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref",openAiAnyTypeName:"OpenAiAnyType"},L4=n=>typeof n=="string"?D(_({},N4),{name:n}):_(_({},N4),n);var F4=n=>{let e=L4(n),t=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return D(_({},e),{flags:{hasReferencedOpenAiAnyType:!1},currentPath:t,propertyPath:void 0,seen:new Map(Object.entries(e.definitions).map(([r,i])=>[i._def,{def:i._def,path:[...e.basePath,e.definitionPath,r],jsonSchema:void 0}]))})};function SR(n,e,t,r){r?.errorMessages&&t&&(n.errorMessage=D(_({},n.errorMessage),{[e]:t}))}function it(n,e,t,r,i){n[e]=t,SR(n,e,r,i)}var Yv=(n,e)=>{let t=0;for(;t<n.length&&t<e.length&&n[t]===e[t];t++);return[(n.length-t).toString(),...e.slice(t)].join("/")};function Lt(n){if(n.target!=="openAi")return{};let e=[...n.basePath,n.definitionPath,n.openAiAnyTypeName];return n.flags.hasReferencedOpenAiAnyType=!0,{$ref:n.$refStrategy==="relative"?Yv(e,n.currentPath):e.join("/")}}function V4(n,e){let t={type:"array"};return n.type?._def&&n.type?._def?.typeName!==K.ZodAny&&(t.items=Te(n.type._def,D(_({},e),{currentPath:[...e.currentPath,"items"]}
117))),n.minLength&&it(t,"minItems",n.minLength.value,n.minLength.message,e),n.maxLength&&it(t,"maxItems",n.maxLength.value,n.maxLength.message,e),n.exactLength&&(it(t,"minItems",n.exactLength.value,n.exactLength.message,e),it(t,"maxItems",n.exactLength.value,n.exactLength.message,e)),t}function j4(n,e){let t={type:"integer",format:"int64"};if(!n.checks)return t;for(let r of n.checks)switch(r.kind){case"min":e.target==="jsonSchema7"?r.inclusive?it(t,"minimum",r.value,r.message,e):it(t,"exclusiveMinimum",r.value,r.message,e):(r.inclusive||(t.exclusiveMinimum=!0),it(t,"minimum",r.value,r.message,e));break;case"max":e.target==="jsonSchema7"?r.inclusive?it(t,"maximum",r.value,r.message,e):it(t,"exclusiveMaximum",r.value,r.message,e):(r.inclusive||(t.exclusiveMaximum=!0),it(t,"maximum",r.value,r.message,e));break;case"multipleOf":it(t,"multipleOf",r.value,r.message,e);break}return t}function $4(){return{type:"boolean"}}function Xv(n,e){return Te(n.type._def,e)}var U4=(n,e)=>Te(n.innerType._def,e);function xR(n,e,t){let r=t??e.dateStrategy;if(Array.isArray(r))return{anyOf:r.map((i,s)=>xR(n,e,i))};switch(r){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return uce(n,e)}}var uce=(n,e)=>{let t={type:"integer",format:"unix-time"};if(e.target==="openApi3")return t;for(let r of n.checks)switch(r.kind){case"min":it(t,"minimum",r.value,r.message,e);break;case"max":it(t,"maximum",r.value,r.message,e);break}return t};function B4(n,e){return D(_({},Te(n.innerType._def,e)),{default:n.defaultValue()})}function H4(n,e){return e.effectStrategy==="input"?Te(n.schema._def,e):Lt(e)}function q4(n){return{type:"string",enum:Array.from(n.values)}}var dce=n=>"type"in n&&n.type==="string"?!1:"allOf"in n;function z4(n,e){let t=[Te(n.left._def,D(_({},e),{currentPath:[...e.currentPath,"allOf","0"]})),Te(n.right._def,D(_({},e),{currentPath:[...e.currentPath,"allOf","1"]}))].filter(s=>!!s),r=e.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,i=[];return t.forEach(s=>{if(dce(s))i.push(...s.allOf),s.unevaluatedProperties===void 0&&(r=void 0);else{let a=s;if("additionalProperties"in s&&s.additionalProperties===!1){let o=s,{additionalProperties:c}=o;
117a=Xt(o,["additionalProperties"])}else r=void 0;i.push(a)}}),i.length?_({allOf:i},r):void 0}function G4(n,e){let t=typeof n.value;return t!=="bigint"&&t!=="number"&&t!=="boolean"&&t!=="string"?{type:Array.isArray(n.value)?"array":"object"}:e.target==="openApi3"?{type:t==="bigint"?"integer":t,enum:[n.value]}:{type:t==="bigint"?"integer":t,const:n.value}}var DR,Vi={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(DR===void 0&&(DR=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),DR),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function Qv(n,e){let t={type:"string"};if(n.checks)for(let r of n.checks)switch(r.kind){case"min":it(t,"minLength",typeof t.minLength=="number"?Math.max(t.minLength,r.value):r.value,r.message,e);break;case"max":it(t,"maxLength",typeof t.maxLength=="number"?Math.min(t.maxLength,r.value):r.value,r.message,e);break;case"email":switch(e.emailStrategy){case"format:email":ji(t,"email",r.message,e);break;case"format:idn-email":ji(t,"idn-email",r.message,e);break;case"pattern:zod":lr(t,Vi.email,r.message,e);break}break;case"url":ji(t,"uri",r.message,e);break;case"uuid":ji(t,"uuid",r.message,e);break;case"regex":lr(t,r.regex,r.message,e);break;case"cuid":lr(t,Vi.cuid,r.message,e);break;case"cuid2":lr(t,Vi.cuid2,r.message,e);break;case"startsWith":lr(t,RegExp(`^${RR(r.value,e)}`),r.message,e);break;case"endsWith":lr(t,RegExp(`${RR(r.value,e)}$`),r.message,e);break;case"datetime":ji(t,"date-time",r.message,e);break;case"date":ji(t,"date",r.message,e);break;case"time":ji(t,"time",r.message,e);break;case"duration":ji(t,"duration",r.message,e);break;case"length":it(t,"minLength",typeof t.minLength=="number"?Math.max(t.minLength,r.value):r.value,r.message,e),it(t,"maxLength",typeof t.maxLength=="number"?Math.min(t.maxLength,r.value):r.value,r.message,e);break;case"includes":{lr(t,RegExp(RR(r.value,e)),r.message,e);break}case"ip":{r.version!=="v6"&&ji(t,"ipv4",r.message,e),r.version!=="v4"&&ji(t,"ipv6",r.message,e);break}case"base64url":lr(t,Vi.base64url,r.message,e);break;case"jwt":lr(t,Vi.jwt,r.message,e);break;case"cidr":{r.version!=="v6"&&lr(t,Vi.ipv4Cidr,r.message,e),r.version!=="v4"&&lr(t,Vi.ipv6Cidr,r.message,e);break}case"emoji":lr(t,Vi.emoji(),r.message,e);break;case"ulid":{lr(t,Vi.ulid,r.message,e);break}case"base64":{switch(e.base64Strategy){case"format:binary":{ji(t,"binary",r.message,e);break}case"contentEncoding:base64":{it(t,"contentEncoding","base64",r.message,e);break}case"pattern:zod":{lr(t,Vi.base64,r.message,e);break}}break}case"nanoid":lr(t,Vi.nanoid,r.message,e);case"toLowerCase":case"toUpperCase":case"trim":break;default:}return t}function RR(n,e){return e.patternStrategy==="escape"?fce(n):n}var hce=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function fce(n){let e="";for(let t=0;t<n.length;t++)hce.has(n[t])||(e+="\\"),e+=n[t];return e}function ji(n,e,t,r){n.format||n.anyOf?.some(i=>i.format)?(n.anyOf||(n.anyOf=[]),n.format&&(n.anyOf.push(_({format:n.format},n.errorMessage&&r.errorMessages&&{errorMessage:{format:n.errorMessage.format}})),delete n.format,n.errorMessage&&(delete n.errorMessage.format,Object.keys(n.errorMessage).length===0&&delete n.errorMessage)),n.anyOf.push(_({format:e},t&&r.errorMessages&&{errorMessage:{format:t}}))):it(n,"format",e,t,r)}function lr(n,e,t,r){n.pattern||n.allOf?.some(i=>i.pattern)?(n.allOf||(n.allOf=[]),n.pattern&&(n.allOf.push(_({pattern:n.pattern},n.errorMessage&&r.errorMessages&&{errorMessage:{pattern:n.errorMessage.pattern}})),delete n.pattern,n.errorMessage&&(delete n.errorMessage.pattern,Object.keys(n.errorMessage).length===0&&delete n.errorMessage)),n.allOf.push(_({pattern:W4(e,r)},t&&r.errorMessages&&{errorMessage:{pattern:t}}))):it(n,"pattern",W4(e,r),t,r)}
117function W4(n,e){if(!e.applyRegexFlags||!n.flags)return n.source;let t={i:n.flags.includes("i"),m:n.flags.includes("m"),s:n.flags.includes("s")},r=t.i?n.source.toLowerCase():n.source,i="",s=!1,o=!1,a=!1;for(let c=0;c<r.length;c++){if(s){i+=r[c],s=!1;continue}if(t.i){if(o){if(r[c].match(/[a-z]/)){a?(i+=r[c],i+=`${r[c-2]}-${r[c]}`.toUpperCase(),a=!1):r[c+1]==="-"&&r[c+2]?.match(/[a-z]/)?(i+=r[c],a=!0):i+=`${r[c]}${r[c].toUpperCase()}`;continue}}else if(r[c].match(/[a-z]/)){i+=`[${r[c]}${r[c].toUpperCase()}]`;continue}}if(t.m){if(r[c]==="^"){i+=`(^|(?<=[\r 118]))`;continue}else if(r[c]==="$"){i+=`($|(?=[\r 119]))`;continue}}if(t.s&&r[c]==="."){i+=o?`${r[c]}\r 120`:`[${r[c]}\r 121]`;continue}i+=r[c],r[c]==="\\"?s=!0:o&&r[c]==="]"?o=!1:!o&&r[c]==="["&&(o=!0)}try{new RegExp(i)}catch{return console.warn(`Could not convert regex pattern at ${e.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),n.source}return i}function Zv(n,e){if(e.target==="openAi"&&console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead."),e.target==="openApi3"&&n.keyType?._def.typeName===K.ZodEnum)return{type:"object",required:n.keyType._def.values,properties:n.keyType._def.values.reduce((s,o)=>D(_({},s),{[o]:Te(n.valueType._def,D(_({},e),{currentPath:[...e.currentPath,"properties",o]}))??Lt(e)}),{}),additionalProperties:e.rejectedAdditionalProperties};let t={type:"object",additionalProperties:Te(n.valueType._def,D(_({},e),{currentPath:[...e.currentPath,"additionalProperties"]}))??e.allowedAdditionalProperties};if(e.target==="openApi3")return t;if(n.keyType?._def.typeName===K.ZodString&&n.keyType._def.checks?.length){let r=Qv(n.keyType._def,e),{type:s}=r,o=Xt(r,["type"]);return D(_({},t),{propertyNames:o})}else{if(n.keyType?._def.typeName===K.ZodEnum)return D(_({},t),{propertyNames:{enum:n.keyType._def.values}});if(n.keyType?._def.typeName===K.ZodBranded&&n.keyType._def.type._def.typeName===K.ZodString&&n.keyType._def.type._def.checks?.length){let i=Xv(n.keyType._def,e),{type:s}=i,o=Xt(i,["type"]);return D(_({},t),{propertyNames:o})}}return t}function K4(n,e){if(e.mapStrategy==="record")return Zv(n,e);let t=Te(n.keyType._def,D(_({},e),{currentPath:[...e.currentPath,"items","items","0"]}))||Lt(e),r=Te(n.valueType._def,D(_({},e),{currentPath:[...e.currentPath,"items","items","1"]}))||Lt(e);return{type:"array",maxItems:125,items:{type:"array",items:[t,r],minItems:2,maxItems:2}}}function Y4(n){let e=n.values,r=Object.keys(n.values).filter(s=>typeof e[e[s]]!="number").map(s=>e[s]),i=Array.from(new Set(r.map(s=>typeof s)));return{type:i.length===1?i[0]==="string"?"string":"number":["string","number"],enum:r}}function X4(n){return n.target==="openAi"?void 0:{not:Lt(D(_({},n),{currentPath:[...n.currentPath,"not"]}))}}function Q4(n){return n.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var qf={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function J4(n,e){if(e.target==="openApi3")return Z4(n,e);let t=n.options instanceof Map?Array.from(n.options.values()):n.options;if(t.every(r=>r._def.typeName in qf&&(!r._def.checks||!r._def.checks.length))){let r=t.reduce((i,s)=>{let o=qf[s._def.typeName];return o&&!i.includes(o)?[...i,o]:i},[]);return{type:r.length>1?r:r[0]}}else if(t.every(r=>r._def.typeName==="ZodLiteral"&&!r.description)){let r=t.reduce((i,s)=>{let o=typeof s._def.value;switch(o){case"string":case"number":case"boolean":return[...i,o];case"bigint":return[...i,"integer"];case"object":if(s._def.value===null)return[...i,"null"];case"symbol":case"undefined":case"function":default:return i}},[]);if(r.length===t.length){let i=r.filter((s,o,a)=>a.indexOf(s)===o);return{type:i.length>1?i:i[0],enum:t.reduce((s,o)=>s.includes(o._def.value)?s:[...s,o._def.value],[])}}}else if(t.every(r=>r._def.typeName==="ZodEnum"))return{type:"string",enum:t.reduce((r,i)=>[...r,...i._def.values.filter(s=>!r.includes(s))],[])};return Z4(n,e)}var Z4=(n,e)=>{let t=(n.options instanceof Map?Array.from(n.options.values()):n.options).map((r,i)=>Te(r._def,D(_({},e),{currentPath:[...e.currentPath,"anyOf",`${i}`]}))).filter(r=>!!r&&(!e.strictUnions||typeof r=="object"&&Object.keys(r).length>0));return t.length?{anyOf:t}:void 0};function e3(n,e){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(n.innerType._def.typeName)&&(!n.innerType._def.checks||!n.innerType._def.checks.length))return e.target==="openApi3"?{type:qf[n.innerType._def.typeName],nullable:!0}:{type:[qf[n.innerType._def.typeName],"null"]};if(e.target==="openApi3"){let r=Te(n.innerType._def,D(_({},e),{currentPath:[...e.currentPath]}));return r&&"$ref"in r?{allOf:[r],nullable:!0}:r&&D(_({},r),{nullable:!0})}let t=Te(n.innerType._def,D(_({},e),{currentPath:[...e.currentPath,"anyOf","0"]}));return t&&{anyOf:[t,{type:"null"}]}}function t3(n,e){let t={type:"number"};if(!n.checks)return t;for(let r of n.checks)switch(r.kind){case"int":t.type="integer",SR(t,"type",r.message,e);break;case"min":e.target==="jsonSchema7"?r.inclusive?it(t,"minimum",r.value,r.message,e):it(t,"exclusiveMinimum",r.value,r.message,e):(r.inclusive||(t.exclusiveMinimum=!0),it(t,"minimum",r.value,r.message,e));break;case"max":e.target==="jsonSchema7"?r.inclusive?it(t,"maximum",r.value,r.message,e):it(t,"exclusiveMaximum",r.value,r.message,e):(r.inclusive||(t.exclusiveMaximum=!0),it(t,"maximum",r.value,r.message,e));break;case"multipleOf":it(t,"multipleOf",r.value,r.message,e);break}return t}function n3(n,e){let t=e.target==="openAi",r={type:"object",properties:{}},i=[],s=n.shape();for(let a in s){let c=s[a];if(c===void 0||c._def===void 0)continue;let l=mce(c);l&&t&&(c._def.typeName==="ZodOptional"&&(c=c._def.innerType),c.isNullable()||(c=c.nullable()),l=!1);let u=Te(c._def,D(_({},e),{currentPath:[...e.currentPath,"properties",a],propertyPath:[...e.currentPath,"properties",a]}));u!==void 0&&(r.properties[a]=u,l||i.push(a))}i.length&&(r.required=i);let o=pce(n,e);return o!==void 0&&(r.additionalProperties=o),r}function pce(n,e){if(n.catchall._def.typeName!=="ZodNever")return Te(n.catchall._def,D(_({},e),{currentPath:[...e.currentPath,"additionalProperties"]}));switch(n.unknownKeys){case"passthrough":return e.allowedAdditionalProperties;case"strict":return e.rejectedAdditionalProperties;
121case"strip":return e.removeAdditionalStrategy==="strict"?e.allowedAdditionalProperties:e.rejectedAdditionalProperties}}function mce(n){try{return n.isOptional()}catch{return!0}}var r3=(n,e)=>{if(e.currentPath.toString()===e.propertyPath?.toString())return Te(n.innerType._def,e);let t=Te(n.innerType._def,D(_({},e),{currentPath:[...e.currentPath,"anyOf","1"]}));return t?{anyOf:[{not:Lt(e)},t]}:Lt(e)};var i3=(n,e)=>{if(e.pipeStrategy==="input")return Te(n.in._def,e);if(e.pipeStrategy==="output")return Te(n.out._def,e);let t=Te(n.in._def,D(_({},e),{currentPath:[...e.currentPath,"allOf","0"]})),r=Te(n.out._def,D(_({},e),{currentPath:[...e.currentPath,"allOf",t?"1":"0"]}));return{allOf:[t,r].filter(i=>i!==void 0)}};function s3(n,e){return Te(n.type._def,e)}function o3(n,e){let r={type:"array",uniqueItems:!0,items:Te(n.valueType._def,D(_({},e),{currentPath:[...e.currentPath,"items"]}))};return n.minSize&&it(r,"minItems",n.minSize.value,n.minSize.message,e),n.maxSize&&it(r,"maxItems",n.maxSize.value,n.maxSize.message,e),r}function a3(n,e){return n.rest?{type:"array",minItems:n.items.length,items:n.items.map((t,r)=>Te(t._def,D(_({},e),{currentPath:[...e.currentPath,"items",`${r}`]}))).reduce((t,r)=>r===void 0?t:[...t,r],[]),additionalItems:Te(n.rest._def,D(_({},e),{currentPath:[...e.currentPath,"additionalItems"]}))}:{type:"array",minItems:n.items.length,maxItems:n.items.length,items:n.items.map((t,r)=>Te(t._def,D(_({},e),{currentPath:[...e.currentPath,"items",`${r}`]}))).reduce((t,r)=>r===void 0?t:[...t,r],[])}}function c3(n){return{not:Lt(n)}}function l3(n){return Lt(n)}var u3=(n,e)=>Te(n.innerType._def,e);var d3=(n,e,t)=>{switch(e){case K.ZodString:return Qv(n,t);case K.ZodNumber:return t3(n,t);case K.ZodObject:return n3(n,t);case K.ZodBigInt:return j4(n,t);case K.ZodBoolean:return $4();case K.ZodDate:return xR(n,t);case K.ZodUndefined:return c3(t);case K.ZodNull:return Q4(t);case K.ZodArray:return V4(n,t);case K.ZodUnion:case K.ZodDiscriminatedUnion:return J4(n,t);case K.ZodIntersection:return z4(n,t);case K.ZodTuple:return a3(n,t);case K.ZodRecord:return Zv(n,t);case K.ZodLiteral:return G4(n,t);case K.ZodEnum:return q4(n);case K.ZodNativeEnum:return Y4(n);case K.ZodNullable:return e3(n,t);case K.ZodOptional:return r3(n,t);case K.ZodMap:return K4(n,t);case K.ZodSet:return o3(n,t);case K.ZodLazy:return()=>n.getter()._def;case K.ZodPromise:return s3(n,t);case K.ZodNaN:case K.ZodNever:return X4(t);case K.ZodEffects:return H4(n,t);case K.ZodAny:return Lt(t);case K.ZodUnknown:return l3(t);case K.ZodDefault:return B4(n,t);case K.ZodBranded:return Xv(n,t);case K.ZodReadonly:return u3(n,t);case K.ZodCatch:return U4(n,t);case K.ZodPipeline:return i3(n,t);case K.ZodFunction:case K.ZodVoid:case K.ZodSymbol:return;default:return(r=>{})(e)}};function Te(n,e,t=!1){let r=e.seen.get(n);if(e.override){let a=e.override?.(n,e,r,t);if(a!==O4)return a}if(r&&!t){let a=gce(r,e);if(a!==void 0)return a}let i={def:n,path:e.currentPath,jsonSchema:void 0};e.seen.set(n,i);let s=d3(n,n.typeName,e),o=typeof s=="function"?Te(s(),e):s;if(o&&yce(n,e,o),e.postProcess){let a=e.postProcess(o,n,e);return i.jsonSchema=o,a}return i.jsonSchema=o,o}var gce=(n,e)=>{switch(e.$refStrategy){case"root":return{$ref:n.path.join("/")};case"relative":return{$ref:Yv(e.currentPath,n.path)};case"none":case"seen":return n.path.length<e.currentPath.length&&n.path.every((t,r)=>e.currentPath[r]===t)?(console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`),Lt(e)):e.$refStrategy==="seen"?Lt(e):void 0}},yce=(n,e,t)=>(n.description&&(t.description=n.description,e.markdownDescription&&(t.markdownDescription=n.description)),t);var kR=(n,e)=>{let t=F4(e),r=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((c,[l,u])=>D(_({},c),{[l]:Te(u._def,D(_({},t),{currentPath:[...t.basePath,t.definitionPath,l]}),!0)??Lt(t)}),{}):void 0,i=typeof e=="string"?e:e?.nameStrategy==="title"?void 0:e?.name,s=Te(n._def,i===void 0?t:D(_({},t),{currentPath:[...t.basePath,t.definitionPath,i]}),!1)??Lt(t),o=typeof e=="object"&&e.name!==void 0&&e.nameStrategy==="title"?e.name:void 0;o!==void 0&&(s.title=o),t.flags.hasReferencedOpenAiAnyType&&(r||(r={}),r[t.openAiAnyTypeName]||(r[t.openAiAnyTypeName]={type:["string","number","integer","boolean","array","null"],items:{$ref:t.$refStrategy==="relative"?"1":[...t.basePath,t.definitionPath,t.openAiAnyTypeName].join("/")}}));let a=i===void 0?r?D(_({},s),{[t.definitionPath]:r}):s:{$ref:[...t.$refStrategy==="relative"?[]:t.basePath,t.definitionPath,i].join("/"),[t.definitionPath]:D(_({},r),{[i]:s}
121)};return t.target==="jsonSchema7"?a.$schema="http://json-schema.org/draft-07/schema#":(t.target==="jsonSchema2019-09"||t.target==="openAi")&&(a.$schema="https://json-schema.org/draft/2019-09/schema#"),t.target==="openAi"&&("anyOf"in a||"oneOf"in a||"allOf"in a||"type"in a&&Array.isArray(a.type))&&console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."),a};function PR(n){return n.replace(/[^a-zA-Z-_0-9]/g,"_")}function _ce(n,e){let t=e[n.source]??n.source,r=e[n.target]??n.target;return[t,r]}function vce(n){let e="";for(let[t,r]of Object.entries(n))e+=` classDef ${t}class fill:${r}; 122`;return e}function h3(n,e,t){let{firstNodeLabel:r,lastNodeLabel:i,nodeColors:s,withStyles:o=!0,curveStyle:a="linear",wrapLabelNWords:c=9}=t??{},l=o?`%%{init: {'flowchart': {'curve': '${a}'}}}%% 123graph TD; 124`:`graph TD; 125`;if(o){let d="default",f={[d]:"{0}([{1}]):::otherclass"};r!==void 0&&(f[r]="{0}[{0}]:::startclass"),i!==void 0&&(f[i]="{0}[{0}]:::endclass");for(let p of Object.values(n)){let y=f[p]??f[d],v=PR(p),w=p.split(":"),E=w[w.length-1];l+=` ${y.replace(/\{0\}/g,v).replace(/\{1\}/g,E)}; 126`}}let u="";for(let d of e){let f=d.source.includes(":")?d.source.split(":")[0]:void 0,p=d.target.includes(":")?d.target.split(":")[0]:void 0;u!==""&&(u!==f||u!==p)&&(l+=` end 127`,u=""),u===""&&f!==void 0&&f===p&&(l=` subgraph ${f} 128`,u=f);let[y,v]=_ce(d,n),w="";if(d.data!==void 0){let E=d.data,A=E.split(" ");A.length>c&&(E=A.reduce((x,M,O)=>(O%c===0&&x.push(""),x[x.length-1]+=` ${M}`,x),[]).join("<br>")),d.conditional?w=` -. ${E} .-> `:w=` -- ${E} --> `}else d.conditional?w=" -.-> ":w=" --> ";l+=` ${PR(y)}${w}${PR(v)}; 129`}return u!==""&&(l+=`end 130`),o&&s!==void 0&&(l+=vce(s)),l}function f3(n,e){return m(this,null,function*(){let{backgroundColor:t="white"}=e??{},r=btoa(n);t!==void 0&&(/^#(?:[0-9a-fA-F]{3}){1,2}$/.test(t)||(t=`!${t}`));let i=`https://mermaid.ink/img/${r}?bgColor=${t}`,s=yield fetch(i);if(!s.ok)throw new Error(["Failed to render the graph using the Mermaid.INK API.",`Status code: ${s.status}`,`Status text: ${s.statusText}`].join(` 131`));return yield s.blob()})}var p3=42;function MR(n){if(Rc(n.id))if(Hf(n.data))try{let e=n.data.getName();return e=e.startsWith("Runnable")?e.slice(8):e,e.length>p3&&(e=`${e.substring(0,p3)}...`),e}catch{return n.data.getName()}else return n.data.name??"UnknownSchema";else return n.id}function bce(n){return Hf(n.data)?{type:"runnable",data:{id:n.data.lc_id,name:n.data.getName()}}:{type:"schema",data:D(_({},kR(n.data.schema)),{title:n.data.name})}}var zf=class{constructor(){Object.defineProperty(this,"nodes",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"edges",{enumerable:!0,configurable:!0,writable:!0,value:[]})}toJSON(){let e={};return Object.values(this.nodes).forEach((t,r)=>{e[t.id]=Rc(t.id)?r:t.id}),{nodes:Object.values(this.nodes).map(t=>_({id:e[t.id]},bce(t))),edges:this.edges.map(t=>{let r={source:e[t.source],target:e[t.target]};return typeof t.data<"u"&&(r.data=t.data),typeof t.conditional<"u"&&(r.conditional=t.conditional),r})}}addNode(e,t){if(t!==void 0&&this.nodes[t]!==void 0)throw new Error(`Node with id ${t} already exists`);let r=t||sn(),i={id:r,data:e};return this.nodes[r]=i,i}removeNode(e){delete this.nodes[e.id],this.edges=this.edges.filter(t=>t.source!==e.id&&t.target!==e.id)}addEdge(e,t,r,i){if(this.nodes[e.id]===void 0)throw new Error(`Source node ${e.id} not in graph`);if(this.nodes[t.id]===void 0)throw new Error(`Target node ${t.id} not in graph`);let s={source:e.id,target:t.id,data:r,conditional:i};return this.edges.push(s),s}firstNode(){let e=new Set(this.edges.map(r=>r.target)),t=[];return Object.values(this.nodes).forEach(r=>{e.has(r.id)||t.push(r)}),t[0]}lastNode(){let e=new Set(this.edges.map(r=>r.source)),t=[];return Object.values(this.nodes).forEach(r=>{e.has(r.id)||t.push(r)}),t[0]}extend(e,t=""){let r=t;Object.values(e.nodes).map(l=>l.id).every(Rc)&&(r="");let s=l=>r?`${r}:${l}`:l;Object.entries(e.nodes).forEach(([l,u])=>{this.nodes[s(l)]=D(_({},u),{id:s(l)})});let o=e.edges.map(l=>D(_({},l),{source:s(l.source),target:s(l.target)}));this.edges=[...this.edges,...o];let a=e.firstNode(),c=e.lastNode();return[a?{id:s(a.id),data:a.data}:void 0,c?{id:s(c.id),data:c.data}:void 0]}trimFirstNode(){let e=this.firstNode();if(e){let t=this.edges.filter(r=>r.source===e.id);(Object.keys(this.nodes).length===1||t.length===1)&&this.removeNode(e)}}trimLastNode(){let e=this.lastNode();if(e){let t=this.edges.filter(r=>r.target===e.id);(Object.keys(this.nodes).length===1||t.length===1)&&this.removeNode(e)}}
131drawMermaid(e){let{withStyles:t,curveStyle:r,nodeColors:i={start:"#ffdfba",end:"#baffc9",other:"#fad7de"},wrapLabelNWords:s}=e??{},o={};for(let d of Object.values(this.nodes))o[d.id]=MR(d);let a=this.firstNode(),c=a?MR(a):void 0,l=this.lastNode(),u=l?MR(l):void 0;return h3(o,this.edges,{firstNodeLabel:c,lastNodeLabel:u,withStyles:t,curveStyle:r,nodeColors:i,wrapLabelNWords:s})}drawMermaidPng(e){return m(this,null,function*(){let t=this.drawMermaid(e);return f3(t,{backgroundColor:e?.backgroundColor})})}};function m3(n){let e=new TextEncoder,t=new ReadableStream({start(i){return m(this,null,function*(){try{for(var s=Ge(n),o,a,c;o=!(a=yield s.next()).done;o=!1){let l=a.value;i.enqueue(e.encode(`event: data 132data: ${JSON.stringify(l)} 133 134`))}}catch{c=[a]}finally{try{o&&(a=s.return)&&(yield a.call(s))}finally{if(c)throw c[0]}}i.enqueue(e.encode(`event: end 135 136`)),i.close()})}});return Wn.fromReadableStream(t)}function NR(n){return typeof n=="object"&&n!==null&&typeof n[Symbol.iterator]=="function"&&typeof n.next=="function"}var g3=n=>n!=null&&typeof n=="object"&&"next"in n&&typeof n.next=="function";function Jv(n){return typeof n=="object"&&n!==null&&typeof n[Symbol.asyncIterator]=="function"}function*OR(n,e){for(;;){let{value:t,done:r}=Li.runWithConfig(n,e.next.bind(e),!0);if(r)break;yield t}}function LR(n,e){return Re(this,null,function*(){let t=e[Symbol.asyncIterator]();for(;;){let{value:r,done:i}=yield new z(Li.runWithConfig(n,t.next.bind(e),!0));if(i)break;yield r}})}function gn(n,e){return n&&!Array.isArray(n)&&!(n instanceof Date)&&typeof n=="object"?n:{[e]:n}}var yn=class extends vo{constructor(){super(...arguments),Object.defineProperty(this,"lc_runnable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}getName(e){let t=this.name??this.constructor.lc_name()??this.constructor.name;return e?`${t}${e}`:t}bind(e){return new Uc({bound:this,kwargs:e,config:{}})}map(){return new VR({bound:this})}withRetry(e){return new jR(_({bound:this,kwargs:{},config:{},maxAttemptNumber:e?.stopAfterAttempt},e))}withConfig(e){return new Uc({bound:this,config:e,kwargs:{}})}withFallbacks(e){let t=Array.isArray(e)?e:e.fallbacks;return new UR({runnable:this,fallbacks:t})}_getOptionsList(e,t=0){if(Array.isArray(e)&&e.length!==t)throw new Error(`Passed "options" must be an array with the same length as the inputs, but got ${e.length} options for ${t} inputs`);if(Array.isArray(e))return e.map(wt);if(t>1&&!Array.isArray(e)&&e.runId){console.warn("Provided runId will be used only for the first element of the batch.");let r=Object.fromEntries(Object.entries(e).filter(([i])=>i!=="runId"));return Array.from({length:t},(i,s)=>wt(s===0?e:r))}return Array.from({length:t},()=>wt(e))}batch(e,t,r){return m(this,null,function*(){let i=this._getOptionsList(t??{},e.length),s=i[0]?.maxConcurrency??r?.maxConcurrency,o=new Uf({maxConcurrency:s,onFailedAttempt:c=>{throw c}}),a=e.map((c,l)=>o.call(()=>m(this,null,function*(){try{return yield this.invoke(c,i[l])}catch(u){if(r?.returnExceptions)return u;throw u}})));return Promise.all(a)})}_streamIterator(e,t){return Re(this,null,function*(){yield this.invoke(e,t)})}stream(e,t){return m(this,null,function*(){let r=wt(t),i=new Eo({generator:this._streamIterator(e,r),config:r});return yield i.setup,Wn.fromAsyncGenerator(i)})}_separateRunnableConfigFromCallOptions(e){let t;e===void 0?t=wt(e):t=wt({callbacks:e.callbacks,tags:e.tags,metadata:e.metadata,runName:e.runName,configurable:e.configurable,recursionLimit:e.recursionLimit,maxConcurrency:e.maxConcurrency,runId:e.runId,timeout:e.timeout,signal:e.signal});let r=_({},e);return delete r.callbacks,delete r.tags,delete r.metadata,delete r.runName,delete r.configurable,delete r.recursionLimit,delete r.maxConcurrency,delete r.runId,delete r.timeout,delete r.signal,[t,r]}_callWithConfig(e,t,r){return m(this,null,function*(){let i=wt(r),o=yield(yield ai(i))?.handleChainStart(this.toJSON(),gn(t,"input"),i.runId,i?.runType,void 0,void 0,i?.runName??this.getName());delete i.runId;let a;try{let c=e.call(this,t,i,o);a=yield Is(c,r?.signal)}catch(c){throw yield o?.handleChainError(c),c}return yield o?.handleChainEnd(gn(a,"output")),a})}
136_batchWithConfig(e,t,r,i){return m(this,null,function*(){let s=this._getOptionsList(r??{},t.length),o=yield Promise.all(s.map(ai)),a=yield Promise.all(o.map((l,u)=>m(this,null,function*(){let d=yield l?.handleChainStart(this.toJSON(),gn(t[u],"input"),s[u].runId,s[u].runType,void 0,void 0,s[u].runName??this.getName());return delete s[u].runId,d}))),c;try{let l=e.call(this,t,s,a,i);c=yield Is(l,s?.[0]?.signal)}catch(l){throw yield Promise.all(a.map(u=>u?.handleChainError(l))),l}return yield Promise.all(a.map(l=>l?.handleChainEnd(gn(c,"output")))),c})}_transformStreamWithConfig(e,t,r){return Re(this,null,function*(){let i,s=!0,o,a=!0,c=wt(r),l=yield new z(ai(c));function u(){return Re(this,null,function*(){try{for(var w=Ge(e),E,A,x;E=!(A=yield new z(w.next())).done;E=!1){let M=A.value;if(s)if(i===void 0)i=M;else try{i=Ts(i,M)}catch{i=void 0,s=!1}yield M}}catch{x=[A]}finally{try{E&&(A=w.return)&&(yield new z(A.call(w)))}finally{if(x)throw x[0]}}})}let d;try{let w=yield new z(x4(t.bind(this),u(),()=>m(this,null,function*(){return l?.handleChainStart(this.toJSON(),{input:""},c.runId,c.runType,void 0,void 0,c.runName??this.getName())}),r?.signal,c));delete c.runId,d=w.setup;let E=d?.handlers.find(P4),A=w.output;E!==void 0&&d!==void 0&&(A=E.tapOutputIterable(d.runId,A));let x=d?.handlers.find(k4);x!==void 0&&d!==void 0&&(A=x.tapOutputIterable(d.runId,A));try{for(var f=Ge(A),p,y,v;p=!(y=yield new z(f.next())).done;p=!1){let M=y.value;
136if(yield M,a)if(o===void 0)o=M;else try{o=Ts(o,M)}catch{o=void 0,a=!1}}}catch{v=[y]}finally{try{p&&(y=f.return)&&(yield new z(y.call(f)))}finally{if(v)throw v[0]}}}catch(w){throw yield new z(d?.handleChainError(w,void 0,void 0,void 0,{inputs:gn(i,"input")})),w}yield new z(d?.handleChainEnd(o??{},void 0,void 0,void 0,{inputs:gn(i,"input")}))})}getGraph(e){let t=new zf,r=t.addNode({name:`${this.getName()}Input`,schema:fa.any()}),i=t.addNode(this),s=t.addNode({name:`${this.getName()}Output`,schema:fa.any()});return t.addEdge(r,i),t.addEdge(i,s),t}pipe(e){return new eb({first:this,last:$c(e)})}pick(e){return this.pipe(new HR(e))}assign(e){return this.pipe(new BR(new Gf({steps:e})))}transform(e,t){return Re(this,null,function*(){let r;try{for(var i=Ge(e),s,o,a;s=!(o=yield new z(i.next())).done;s=!1){let c=o.value;r===void 0?r=c:r=Ts(r,c)}}catch{a=[o]}finally{try{s&&(o=i.return)&&(yield new z(o.call(i)))}finally{if(a)throw a[0]}}yield*vn(this._streamIterator(r,wt(t)))})}streamLog(e,t,r){return Re(this,null,function*(){let i=new jf(D(_({},r),{autoClose:!1,_schemaFormat:"original"})),s=wt(t);yield*vn(this._streamLog(e,i,s))})}_streamLog(e,t,r){return Re(this,null,function*(){let{callbacks:i}=r;if(i===void 0)r.callbacks=[t];else if(Array.isArray(i))r.callbacks=i.concat([t]);else{let f=i.copy();f.addHandler(t,!0),r.callbacks=f}let s=this.stream(e,r);function o(){return m(this,null,function*(){try{let w=yield s;try{for(var f=Ge(w),p,y,v;p=!(y=yield f.next()).done;p=!1){let E=y.value;let A=new Fi({ops:[{op:"add",path:"/streamed_output/-",value:E}]});yield t.writer.write(A)}}catch{v=[y]}finally{try{p&&(y=f.return)&&(yield y.call(f))}finally{if(v)throw v[0]}}}finally{yield t.writer.close()}})}let a=o();try{try{for(var c=Ge(t),l,u,d;l=!(u=yield new z(c.next())).done;l=!1){let f=u.value;yield f}}catch{d=[u]}finally{try{l&&(u=c.return)&&(yield new z(u.call(c)))}finally{if(d)throw d[0]}}}finally{yield new z(a)}})}streamEvents(e,t,r){let i;if(t.version==="v1")i=this._streamEventsV1(e,t,r);else if(t.version==="v2")i=this._streamEventsV2(e,t,r);else throw new Error('Only versions "v1" and "v2" of the schema are currently supported.');return t.encoding==="text/event-stream"?m3(i):Wn.fromAsyncGenerator(i)}_streamEventsV2(e,t,r){return Re(this,null,function*(){let i=new zv(D(_({},r),{autoClose:!1})),s=wt(t),o=s.runId??sn();s.runId=o;let a=s.callbacks;if(a===void 0)s.callbacks=[i];else if(Array.isArray(a))s.callbacks=a.concat(i);else{let E=a.copy();E.addHandler(i,!0),s.callbacks=E}let c=this;function l(){return m(this,null,function*(){try{let O=yield c.stream(e,s),$=i.tapOutputIterable(o,O);try{for(var E=Ge($),A,x,M;A=!(x=yield E.next()).done;A=!1){let C=x.value;;}}catch{M=[x]}finally{try{A&&(x=E.return)&&(yield x.call(E))}finally{if(M)throw M[0]}}}finally{yield i.finish()}})}let u=l(),d=!1,f;try{try{for(var p=Ge(i),y,v,w;y=!(v=yield new z(p.next())).done;y=!1){let E=v.value;if(!d){E.data.input=e,d=!0,f=E.run_id,yield E;continue}E.run_id===f&&E.event.endsWith("_end")&&E.data?.input&&delete E.data.input,yield E}}catch{w=[v]}finally{try{y&&(v=p.return)&&(yield new z(v.call(p)))}finally{if(w)throw w[0]}}}finally{yield new z(u)}})}_streamEventsV1(e,t,r){return Re(this,null,function*(){let i,s=!1,o=wt(t),a=o.tags??[],c=o.metadata??{},l=o.runName??this.getName(),u=new jf(D(_({},r),{autoClose:!1,_schemaFormat:"streaming_events"})),d=new Kv(_({},r)),f=this._streamLog(e,u,o);try{for(var y=Ge(f),v,w,E;v=!(w=yield new z(y.next())).done;v=!1){let A=w.value;if(i?i=i.concat(A):i=Vf.fromRunLogPatch(A),i.state===void 0)throw new Error('Internal error: "streamEvents" state is missing. Please open a bug report.');if(!s){s=!0;let $=_({},i.state),C={run_id:$.id,event:`on_${$.type}_start`,name:l,tags:a,metadata:c,data:{input:e}};d.includeEvent(C,$.type)&&(yield C)}let x=A.ops.filter($=>$.path.startsWith("/logs/")).map($=>$.path.split("/")[2]),M=[...new Set(x)];for(let $ of M){let C,T={},S=i.state.logs[$];if(S.end_time===void 0?S.streamed_output.length>0?C="stream":C="start":C="end",C==="start")S.inputs!==void 0&&(T.input=S.inputs);else if(C==="end")S.inputs!==void 0&&(T.input=S.inputs),T.output=S.final_output;else if(C==="stream"){let k=S.streamed_output.length;if(k!==1)throw new Error(`Expected exactly one chunk of streamed output, got ${k} instead. Encountered in: "${S.name}"`);T={chunk:S.streamed_output[0]},S.streamed_output=[]}yield{event:`on_${S.type}_${C}`,name:S.name,run_id:S.id,tags:S.tags,metadata:S.metadata,data:T}}let{state:O}=i;if(O.streamed_output.length>0){let $=O.streamed_output.length;if($!==1)throw new Error(`Expected exactly one chunk of streamed output, got ${$} instead. Encountered in: "${O.name}"`);let C={chunk:O.streamed_output[0]};O.streamed_output=[];let T={event:`on_${O.type}_stream`,run_id:O.id,tags:a,metadata:c,name:l,data:C}
136;d.includeEvent(T,O.type)&&(yield T)}}}catch{E=[w]}finally{try{v&&(w=y.return)&&(yield new z(w.call(y)))}finally{if(E)throw E[0]}}let p=i?.state;if(p!==void 0){let A={event:`on_${p.type}_end`,name:l,run_id:p.id,tags:a,metadata:c,data:{output:p.final_output}};d.includeEvent(A,p.type)&&(yield A)}})}static isRunnable(e){return Hf(e)}withListeners({onStart:e,onEnd:t,onError:r}){return new Uc({bound:this,config:{},configFactories:[i=>({callbacks:[new Bf({config:i,onStart:e,onEnd:t,onError:r})]})]})}asTool(e){return Ece(this,e)}},Uc=class n extends yn{static lc_name(){return"RunnableBinding"}constructor(e){super(e),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","runnables"]}),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"bound",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"config",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"kwargs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"configFactories",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.bound=e.bound,this.kwargs=e.kwargs,this.config=e.config,this.configFactories=e.configFactories}getName(e){return this.bound.getName(e)}_mergeConfig(...e){return m(this,null,function*(){let t=CR(this.config,...e);return CR(t,...this.configFactories?yield Promise.all(this.configFactories.map(r=>m(this,null,function*(){return yield r(t)}))):[])})}bind(e){return new this.constructor({bound:this.bound,kwargs:_(_({},this.kwargs),e),config:this.config})}withConfig(e){return new this.constructor({bound:this.bound,kwargs:this.kwargs,config:_(_({},this.config),e)})}withRetry(e){return new this.constructor({bound:this.bound.withRetry(e),kwargs:this.kwargs,config:this.config})}invoke(e,t){return m(this,null,function*(){return this.bound.invoke(e,yield this._mergeConfig(wt(t),this.kwargs))})}batch(e,t,r){return m(this,null,function*(){let i=Array.isArray(t)?yield Promise.all(t.map(s=>m(this,null,function*(){return this._mergeConfig(wt(s),this.kwargs)}))):yield this._mergeConfig(wt(t),this.kwargs);return this.bound.batch(e,i,r)})}_streamIterator(e,t){return Re(this,null,function*(){yield*vn(this.bound._streamIterator(e,yield new z(this._mergeConfig(wt(t),this.kwargs))))})}stream(e,t){return m(this,null,function*(){return this.bound.stream(e,yield this._mergeConfig(wt(t),this.kwargs))})}transform(e,t){return Re(this,null,function*(){yield*vn(this.bound.transform(e,yield new z(this._mergeConfig(wt(t),this.kwargs))))})}streamEvents(e,t,r){let i=this,s=function(){return Re(this,null,function*(){yield*vn(i.bound.streamEvents(e,D(_({},yield new z(i._mergeConfig(wt(t),i.kwargs))),{version:t.version}),r))})};return Wn.fromAsyncGenerator(s())}static isRunnableBinding(e){return e.bound&&yn.isRunnable(e.bound)}withListeners({onStart:e,onEnd:t,onError:r}){return new n({bound:this.bound,kwargs:this.kwargs,config:this.config,configFactories:[i=>({callbacks:[new Bf({config:i,onStart:e,onEnd:t,onError:r})]})]})}},VR=class n extends yn{static lc_name(){return"RunnableEach"}constructor(e){super(e),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","runnables"]}),Object.defineProperty(this,"bound",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.bound=e.bound}bind(e){return new n({bound:this.bound.bind(e)})}invoke(e,t){return m(this,null,function*(){return this._callWithConfig(this._invoke,e,t)})}_invoke(e,t,r){return m(this,null,function*(){return this.bound.batch(e,Dn(t,{callbacks:r?.getChild()}))})}withListeners({onStart:e,onEnd:t,onError:r}){return new n({bound:this.bound.withListeners({onStart:e,onEnd:t,onError:r})})}},jR=class n extends Uc{static lc_name(){return"RunnableRetry"}constructor(e){super(e),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","runnables"]}),Object.defineProperty(this,"maxAttemptNumber",{enumerable:!0,configurable:!0,writable:!0,value:3}),Object.defineProperty(this,"onFailedAttempt",{enumerable:!0,configurable:!0,writable:!0,value:()=>{}}),this.maxAttemptNumber=e.maxAttemptNumber??this.maxAttemptNumber,this.onFailedAttempt=e.onFailedAttempt??this.onFailedAttempt}_patchConfigForRetry(e,t,r){let i=e>1?`retry:attempt:${e}`:void 0;return Dn(t,{callbacks:r?.getChild(i)})}_invoke(e,t,r){return m(this,null,function*(){return(0,FR.default)(i=>dn(n.prototype,this,"invoke").call(this,e,this._patchConfigForRetry(i,t,r)),{onFailedAttempt:i=>this.onFailedAttempt(i,e),retries:Math.max(this.maxAttemptNumber-1,0),randomize:!0})})}invoke(e,t){return m(this,null,function*(){return this._callWithConfig(this._invoke,e,t)})}_batch(e,t,r,i){return m(this,null,function*(){let s={};try{yield(0,FR.default)(o=>m(this,null,function*(){let a=e.map((f,p)=>p).filter(f=>s[f.toString()]===void 0||s[f.toString()]instanceof Error),c=a.map(f=>e[f]),l=a.map(f=>this._patchConfigForRetry(o,t?.[f],r?.[f])),u=yield dn(n.prototype,this,"batch").call(this,c,l,D(_({},i),{returnExceptions:!0})),d;for(let f=0;f<u.length;f+=1){let p=u[f],y=a[f];p instanceof Error&&d===void 0&&(d=p,d.input=c[f]),s[y.toString()]=p}if(d)throw d;return u}),{onFailedAttempt:o=>this.onFailedAttempt(o,o.input),retries:Math.max(this.maxAttemptNumber-1,0),randomize:!0})}catch(o){if(i?.returnExceptions!==!0)throw o}return Object.keys(s).sort((o,a)=>parseInt(o,10)-parseInt(a,10)).map(o=>s[parseInt(o,10)])})}batch(e,t,r){return m(this,null,function*(){return this._batchWithConfig(this._batch.bind(this),e,t,r)})}},eb=class n extends yn{static lc_name(){return"RunnableSequence"}constructor(e){super(e),Object.defineProperty(this,"first",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"middle",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"last",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","runnables"]}),this.first=e.first,this.middle=e.middle??this.middle,this.last=e.last,this.name=e.name}get steps(){return[this.first,...this.middle,this.last]}invoke(e,t){return m(this,null,function*(){let r=wt(t),s=yield(yield ai(r))?.handleChainStart(this.toJSON(),gn(e,"input"),r.runId,void 0,void 0,void 0,r?.runName);delete r.runId;let o=e,a;try{let c=[this.first,...this.middle];for(let l=0;l<c.length;l+=1){let d=c[l].invoke(o,Dn(r,{callbacks:s?.getChild(`seq:step:${l+1}`)}));o=yield Is(d,t?.signal)}if(t?.signal?.aborted)throw new Error("Aborted");a=yield this.last.invoke(o,Dn(r,{callbacks:s?.getChild(`seq:step:${this.steps.length}`)}))}catch(c){throw yield s?.handleChainError(c),c}return yield s?.handleChainEnd(gn(a,"output")),a})}batch(e,t,r){return m(this,null,function*(){let i=this._getOptionsList(t??{},e.length),s=yield Promise.all(i.map(ai)),o=yield Promise.all(s.map((c,l)=>m(this,null,function*(){let u=yield c?.handleChainStart(this.toJSON(),gn(e[l],"input"),i[l].runId,void 0,void 0,void 0,i[l].runName);return delete i[l].runId,u}))),a=e;try{for(let c=0;c<this.steps.length;c+=1){let u=this.steps[c].batch(a,o.map((d,f)=>{let p=d?.getChild(`seq:step:${c+1}`);return Dn(i[f],{callbacks:p})}),r);a=yield Is(u,i[0]?.signal)}}catch(c){throw yield Promise.all(o.map(l=>l?.handleChainError(c))),c}return yield Promise.all(o.map(c=>c?.handleChainEnd(gn(a,"output")))),a})}_streamIterator(e,t){return Re(this,null,function*(){let r=yield new z(ai(t)),d=t??{},{runId:i}=d,s=Xt(d,["runId"]),o=yield new z(r?.handleChainStart(this.toJSON(),gn(e,"input"),i,void 0,void 0,void 0,s?.runName)),a=[this.first,...this.middle,this.last],c=!0,l;function u(){return Re(this,null,function*(){yield e})}try{let w=a[0].transform(u(),Dn(s,{callbacks:o?.getChild("seq:step:1")}));for(let E=1;E<a.length;E+=1){let A=a[E];w=yield new z(A.transform(w,Dn(s,{callbacks:o?.getChild(`seq:step:${E+1}`)})))}try{for(var f=Ge(w),p,y,v;p=!(y=yield new z(f.next())).done;p=!1){let E=y.value;if(t?.signal?.throwIfAborted(),yield E,c)if(l===void 0)l=E;else try{l=Ts(l,E)}catch{l=void 0,c=!1}}}catch{v=[y]}finally{try{p&&(y=f.return)&&(yield new z(y.call(f)))}finally{if(v)throw v[0]}}}catch(w){throw yield new z(o?.handleChainError(w)),w}yield new z(o?.handleChainEnd(gn(l,"output")))})}getGraph(e){let t=new zf,r=null;return this.steps.forEach((i,s)=>{let o=i.getGraph(e);s!==0&&o.trimFirstNode(),s!==this.steps.length-1&&o.trimLastNode(),t.extend(o);let a=o.firstNode();if(!a)throw new Error(`Runnable ${i} has no first node`);r&&t.addEdge(r,a),r=o.lastNode()}),t}pipe(e){return n.isRunnableSequence(e)?new n({first:this.first,middle:this.middle.concat([this.last,e.first,...e.middle]),last:e.last,name:this.name??e.name}):new n({first:this.first,middle:[...this.middle,this.last],last:$c(e),name:this.name})}static isRunnableSequence(e){return Array.isArray(e.middle)&&yn.isRunnable(e)}static from([e,...t],r){return new n({first:$c(e),middle:t.slice(0,-1).map($c),last:$c(t[t.length-1]),name:r})}},Gf=class n extends yn{static lc_name(){return"RunnableMap"}getStepsKeys(){return Object.keys(this.steps)}constructor(e){super(e),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","runnables"]}),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"steps",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.steps={};for(let[t,r]of Object.entries(e.steps))this.steps[t]=$c(r)}static from(e){return new n({steps:e})}invoke(e,t){return m(this,null,function*(){let r=wt(t),s=yield(yield ai(r))?.handleChainStart(this.toJSON(),{input:e},r.runId,void 0,void 0,void 0,r?.runName);delete r.runId;let o={};try{let a=Object.entries(this.steps).map(u=>m(this,[u],function*([c,l]){o[c]=yield l.invoke(e,Dn(r,{callbacks:s?.getChild(`map:key:${c}`)}))}));yield Is(Promise.all(a),t?.signal)}catch(a){throw yield s?.handleChainError(a),a}return yield s?.handleChainEnd(o),o})}_transform(e,t,r){return Re(this,null,function*(){let i=_({},this.steps),s=AR(e,Object.keys(i).length),o=new Map(Object.entries(i).map(([a,c],l)=>{let u=c.transform(s[l],Dn(r,{callbacks:t?.getChild(`map:key:${a}`)}));return[a,u.next().then(d=>({key:a,gen:u,result:d}))]}));for(;o.size;
136){let a=Promise.race(o.values()),{key:c,result:l,gen:u}=yield new z(Is(a,r?.signal));o.delete(c),l.done||(yield{[c]:l.value},o.set(c,u.next().then(d=>({key:c,gen:u,result:d}))))}})}transform(e,t){return this._transformStreamWithConfig(e,this._transform.bind(this),t)}stream(e,t){return m(this,null,function*(){function r(){return Re(this,null,function*(){yield e})}let i=wt(t),s=new Eo({generator:this.transform(r(),i),config:i});return yield s.setup,Wn.fromAsyncGenerator(s)})}},$R=class n extends yn{constructor(e){if(super(e),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","runnables"]}),Object.defineProperty(this,"func",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),!Nv(e.func))throw new Error("RunnableTraceable requires a function that is wrapped in traceable higher-order function");this.func=e.func}invoke(e,t){return m(this,null,function*(){let[r]=this._getOptionsList(t??{},1),i=yield ai(r),s=this.func(Dn(r,{callbacks:i}),e);return Is(s,r?.signal)})}_streamIterator(e,t){return Re(this,null,function*(){let[r]=this._getOptionsList(t??{},1),i=yield new z(this.invoke(e,t));if(Jv(i)){try{for(var s=Ge(i),o,a,c;o=!(a=yield new z(s.next())).done;o=!1){let l=a.value;r?.signal?.throwIfAborted(),yield l}}catch{c=[a]}finally{try{o&&(a=s.return)&&(yield new z(a.call(s)))}finally{if(c)throw c[0]}}return}if(g3(i)){for(;;){r?.signal?.throwIfAborted();let l=i.next();if(l.done)break;yield l.value}return}yield i})}static from(e){return new n({func:e})}};function wce(n){if(Nv(n))throw new Error("RunnableLambda requires a function that is not wrapped in traceable higher-order function. This shouldn't happen.")}var tb=class n extends yn{static lc_name(){return"RunnableLambda"}constructor(e){if(Nv(e.func))return $R.from(e.func);super(e),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","runnables"]}),Object.defineProperty(this,"func",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),wce(e.func),this.func=e.func}static from(e){return new n({func:e})}_invoke(e,t,r){return m(this,null,function*(){return new Promise((i,s)=>{let o=Dn(t,{callbacks:r?.getChild(),recursionLimit:(t?.recursionLimit??Gv)-1});Li.runWithConfig(o,()=>m(this,null,function*(){try{let d=yield this.func(e,D(_({},o),{config:o}));if(d&&yn.isRunnable(d)){if(t?.recursionLimit===0)throw new Error("Recursion limit reached.");d=yield d.invoke(e,D(_({},o),{recursionLimit:(o.recursionLimit??Gv)-1}))}else if(Jv(d)){let f;try{for(var a=Ge(LR(o,d)),c,l,u;c=!(l=yield a.next()).done;c=!1){let p=l.value;if(t?.signal?.throwIfAborted(),f===void 0)f=p;else try{f=Ts(f,p)}catch{f=p}}}catch{u=[l]}finally{try{c&&(l=a.return)&&(yield l.call(a))}finally{if(u)throw u[0]}}d=f}else if(NR(d)){let f;for(let p of OR(o,d))if(t?.signal?.throwIfAborted(),f===void 0)f=p;else try{f=Ts(f,p)}catch{f=p}d=f}i(d)}catch(d){s(d)}}))})})}invoke(e,t){return m(this,null,function*(){return this._callWithConfig(this._invoke,e,t)})}_transform(e,t,r){return Re(this,null,function*(){let i;try{for(var a=Ge(e),c,l,u;c=!(l=yield new z(a.next())).done;c=!1){let x=l.value;if(i===void 0)i=x;else try{i=Ts(i,x)}catch{i=x}}}catch{u=[l]}finally{try{c&&(l=a.return)&&(yield new z(l.call(a)))}finally{if(u)throw u[0]}}let s=Dn(r,{callbacks:t?.getChild(),recursionLimit:(r?.recursionLimit??Gv)-1}),o=yield new z(new Promise((x,M)=>{Li.runWithConfig(s,()=>m(this,null,function*(){try{let O=yield this.func(i,D(_({},s),{config:s}));x(O)}catch(O){M(O)}}))}));if(o&&yn.isRunnable(o)){if(r?.recursionLimit===0)throw new Error("Recursion limit reached.");let x=yield new z(o.stream(i,s));try{for(var d=Ge(x),f,p,y;f=!(p=yield new z(d.next())).done;f=!1){let M=p.value;yield M}}catch{y=[p]}finally{try{f&&(p=d.return)&&(yield new z(p.call(d)))}finally{if(y)throw y[0]}}}else if(Jv(o))try{for(var v=Ge(LR(s,o)),w,E,A;w=!(E=yield new z(v.next())).done;w=!1){let x=E.value;r?.signal?.throwIfAborted(),yield x}}catch{A=[E]}finally{try{w&&(E=v.return)&&(yield new z(E.call(v)))}finally{if(A)throw A[0]}}
136else if(NR(o))for(let x of OR(s,o))r?.signal?.throwIfAborted(),yield x;else yield o})}transform(e,t){return this._transformStreamWithConfig(e,this._transform.bind(this),t)}stream(e,t){return m(this,null,function*(){function r(){return Re(this,null,function*(){yield e})}let i=wt(t),s=new Eo({generator:this.transform(r(),i),config:i});return yield s.setup,Wn.fromAsyncGenerator(s)})}};var UR=class extends yn{static lc_name(){return"RunnableWithFallbacks"}constructor(e){super(e),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","runnables"]}),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"runnable",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"fallbacks",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.runnable=e.runnable,this.fallbacks=e.fallbacks}*runnables(){yield this.runnable;for(let e of this.fallbacks)yield e}invoke(e,t){return m(this,null,function*(){let r=wt(t),i=yield ai(t),l=r,{runI
136d:s}=l,o=Xt(l,["runId"]),a=yield i?.handleChainStart(this.toJSON(),gn(e,"input"),s,void 0,void 0,void 0,o?.runName),c;for(let u of this.runnables()){r?.signal?.throwIfAborted();try{let d=yield u.invoke(e,Dn(o,{callbacks:a?.getChild()}));return yield a?.handleChainEnd(gn(d,"output")),d}catch(d){c===void 0&&(c=d)}}throw c===void 0?new Error("No error stored at end of fallback."):(yield a?.handleChainError(c),c)})}_streamIterator(e,t){return Re(this,null,function*(){let r=wt(t),i=yield new z(ai(t)),d=r,{runId:s}=d,o=Xt(d,["runId"]),a=yield new z(i?.handleChainStart(this.toJSON(),gn(e,"input"),s,void 0,void 0,void 0,o?.runName)),c,l;for(let w of this.runnables()){r?.signal?.throwIfAborted();let E=Dn(o,{callbacks:a?.getChild()});try{l=yield new z(w.stream(e,E));break}catch(A){c===void 0&&(c=A)}}if(l===void 0){let w=c??new Error("No error stored at end of fallback.");throw yield new z(a?.handleChainError(w)),w}let u;try{try{for(var f=Ge(l),p,y,v;p=!(y=yield new z(f.next())).done;p=!1){let w=y.value;yield w;try{u=u===void 0?u:Ts(u,w)}catch{u=void 0}}}catch{v=[y]}finally{try{p&&(y=f.return)&&(yield new z(y.call(f)))}finally{if(v)throw v[0]}}}catch(w){throw yield new z(a?.handleChainError(w)),w}yield new z(a?.handleChainEnd(gn(u,"output")))})}batch(e,t,r){return m(this,null,function*(){if(r?.returnExceptions)throw new Error("Not implemented.");let i=this._getOptionsList(t??{},e.length),s=yield Promise.all(i.map(c=>ai(c))),o=yield Promise.all(s.map((c,l)=>m(this,null,function*(){let u=yield c?.handleChainStart(this.toJSON(),gn(e[l],"input"),i[l].runId,void 0,void 0,void 0,i[l].runName);return delete i[l].runId,u}))),a;for(let c of this.runnables()){i[0].signal?.throwIfAborted();try{let l=yield c.batch(e,o.map((u,d)=>Dn(i[d],{callbacks:u?.getChild()})),r);return yield Promise.all(o.map((u,d)=>u?.handleChainEnd(gn(l[d],"output")))),l}catch(l){a===void 0&&(a=l)}}throw a?(yield Promise.all(o.map(c=>c?.handleChainError(a))),a):new Error("No error stored at end of fallbacks.")})}};function $c(n){if(typeof n=="function")return new tb({func:n});if(yn.isRunnable(n))return n;if(!Array.isArray(n)&&typeof n=="object"){let e={};for(let[t,r]of Object.entries(n))e[t]=$c(r);return new Gf({steps:e})}else throw new Error(`Expected a Runnable, function or object. 137Instead got an unsupported type.`)}var BR=class extends yn{static lc_name(){return"RunnableAssign"}constructor(e){e instanceof Gf&&(e={mapper:e}),super(e),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","runnables"]}),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"mapper",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.mapper=e.mapper}invoke(e,t){return m(this,null,function*(){let r=yield this.mapper.invoke(e,t);return _(_({},e),r)})}_transform(e,t,r){return Re(this,null,function*(){let i=this.mapper.getStepsKeys(),[s,o]=AR(e),a=this.mapper.transform(o,Dn(r,{callbacks:t?.getChild()})),c=a.next();try{for(var l=Ge(s),u,d,f;u=!(d=yield new z(l.next())).done;u=!1){let E=d.value;if(typeof E!="object"||Array.isArray(E))throw new Error(`RunnableAssign can only be used with objects as input, got ${typeof E}`);let A=Object.fromEntries(Object.entries(E).filter(([x])=>!i.includes(x)));Object.keys(A).length>0&&(yield A)}}catch{f=[d]}finally{try{u&&(d=l.return)&&(yield new z(d.call(l)))}finally{if(f)throw f[0]}}yield(yield new z(c)).value;try{for(var p=Ge(a),y,v,w;y=!(v=yield new z(p.next())).done;y=!1){let E=v.value;yield E}}catch{w=[v]}finally{try{y&&(v=p.return)&&(yield new z(v.call(p)))}finally{if(w)throw w[0]}}})}transform(e,t){return this._transformStreamWithConfig(e,this._transform.bind(this),t)}stream(e,t){return m(this,null,function*(){function r(){return Re(this,null,function*(){yield e})}let i=wt(t),s=new Eo({generator:this.transform(r(),i),config:i});return yield s.setup,Wn.fromAsyncGenerator(s)})}},HR=class extends yn{static lc_name(){return"RunnablePick"}constructor(e){(typeof e=="string"||Array.isArray(e))&&(e={keys:e}),super(e),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","runnables"]}),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"keys",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.keys=e.keys}_pick(e){return m(this,null,function*(){if(typeof this.keys=="str
137ing")return e[this.keys];{let t=this.keys.map(r=>[r,e[r]]).filter(r=>r[1]!==void 0);return t.length===0?void 0:Object.fromEntries(t)}})}invoke(e,t){return m(this,null,function*(){return this._callWithConfig(this._pick.bind(this),e,t)})}_transform(e){return Re(this,null,function*(){try{for(var t=Ge(e),r,i,s;r=!(i=yield new z(t.next())).done;r=!1){let o=i.value;let a=yield new z(this._pick(o));a!==void 0&&(yield a)}}catch{s=[i]}finally{try{r&&(i=t.return)&&(yield new z(i.call(t)))}finally{if(s)throw s[0]}}})}transform(e,t){return this._transformStreamWithConfig(e,this._transform.bind(this),t)}stream(e,t){return m(this,null,function*(){function r(){return Re(this,null,function*(){yield e})}let i=wt(t),s=new Eo({generator:this.transform(r(),i),config:i});return yield s.setup,Wn.fromAsyncGenerator(s)})}},nb=class extends Uc{constructor(e){let t=eb.from([tb.from(r=>m(this,null,function*(){let i;if(mR(r))try{i=yield this.schema.parseAsync(r.args)}catch{throw new $v("Received tool input did not match expected schema",JSON.stringify(r.args))}else i=r;return i})).withConfig({runName:`${e.name}:parse_input`}),e.bound]).withConfig({runName:e.name});super({bound:t,config:e.config??{}}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"description",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"schema",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=e.name,this.description=e.description,this.schema=e.schema}static lc_name(){return"RunnableToolLike"}};function Ece(n,e){let t=e.name??n.getName(),r=e.description??e.schema?.description;return e.schema.constructor===fa.ZodString?new nb({name:t,description:r,schema:fa.object({input:fa.string()}).transform(i=>i.input),bound:n}):new nb({name:t,description:r,schema:e.schema,bound:n})}var rb=class extends yn{constructor(){super(...arguments),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","documents","transformers"]})}invoke(e,t){return this.transformDocuments(e)}};var b3=di(v3(),1);var Rce=Object.defineProperty,kce=(n,e,t)=>e in n?Rce(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Pce=(n,e,t)=>(kce(n,typeof e!="symbol"?e+"":e,t),t);function Mce(n,e){let t=Array.from({length:n.length},(r,i)=>({start:i,end:i+1}));for(;t.length>1;){let r=null;for(let i=0;i<t.length-1;i++){let s=n.slice(t[i].start,t[i+1].end),o=e.get(s.join(","));o!=null&&(r==null||o<r[0])&&(r=[o,i])}if(r!=null){let i=r[1];t[i]={start:t[i].start,end:t[i+1].end},t.splice(i+1,1)}else break}return t}function Nce(n,e){return n.length===1?[e.get(n.join(","))]:Mce(n,e).map(t=>e.get(n.slice(t.start,t.end).join(","))).filter(t=>t!=null)}function Oce(n){return n.replace(/[\\^$*+?.()|[\]{}]/g,"\\$&")}var zR=class{specialTokens;inverseSpecialTokens;patStr;textEncoder=new TextEncoder;textDecoder=new TextDecoder("utf-8");rankMap=new Map;textMap=new Map;constructor(n,e){this.patStr=n.pat_str;let t=n.bpe_ranks.split(` 138`).filter(Boolean).reduce((r,i)=>{let[s,o,...a]=i.split(" "),c=Number.parseInt(o,10);return a.forEach((l,u)=>r[l]=c+u),r},{});for(let[r,i]of Object.entries(t)){let s=b3.default.toByteArray(r);this.rankMap.set(s.join(","),i),this.textMap.set(i,s)}this.specialTokens=_(_({},n.special_tokens),e),this.inverseSpecialTokens=Object.entries(this.specialTokens).reduce((r,[i,s])=>(r[s]=this.textEncoder.encode(i),r),{})}encode(n,e=[],t="all"){let r=new RegExp(this.patStr,"ug"),i=zR.specialTokenRegex(Object.keys(this.specialTokens)),s=[],o=new Set(e==="all"?Object.keys(this.specialTokens):e),a=new Set(t==="all"?Object.keys(this.specialTokens).filter(l=>!o.has(l)):t);if(a.size>0){let l=zR.specialTokenRegex([...a]),u=n.match(l);if(u!=null)throw new Error(`The text contains a special token that is not allowed: ${u[0]}`)}let c=0;for(;;){let l=null,u=c;for(;i.lastIndex=u,l=i.exec(n),!(l==null||o.has(l[0]));)u=l.index+1;let d=l?.index??n.length;for(let p of n.substring(c,d).matchAll(r)){let y=this.textEncoder.encode(p[0]),v=this.rankMap.get(y.join(","));if(v!=null){s.push(v);continue}s.push(...Nce(y,this.rankMap))}if(l==null)break;let f=this.specialTokens[l[0]];s.push(f),c=l.index+l[0].length}return s}decode(n){let e=[],t=0;for(let s=0;s<n.length;++s){let o=n[s],a=this.textMap.get(o)??this.inverseSpecialTokens[o];a!=null&&(e.push(a),t+=a.length)}let r=new Uint8Array(t),i=0;for(let s of e)r.set(s,i),i+=s.length;return this.textDecoder.decode(r)}},GR=zR;Pce(GR,"specialTokenRegex",n=>new RegExp(n.map(e=>Oce(e)).join("|"),"g"));var WR=class extends rb{constructor(e){if(super(e),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain","document_transformers","text_splitters"]}),Object.defineProperty(this,"chunkSize",{enumerable:!0,configurable:!0,writable:!0,value:1e3}
138),Object.defineProperty(this,"chunkOverlap",{enumerable:!0,configurable:!0,writable:!0,value:200}),Object.defineProperty(this,"keepSeparator",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"lengthFunction",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.chunkSize=e?.chunkSize??this.chunkSize,this.chunkOverlap=e?.chunkOverlap??this.chunkOverlap,this.keepSeparator=e?.keepSeparator??this.keepSeparator,this.lengthFunction=e?.lengthFunction??(t=>t.length),this.chunkOverlap>=this.chunkSize)throw new Error("Cannot have chunkOverlap >= chunkSize")}transformDocuments(r){return m(this,arguments,function*(e,t={}){return this.splitDocuments(e,t)})}splitOnSeparator(e,t){let r;if(t)if(this.keepSeparator){let i=t.replace(/[/\-\\^$*+?.()|[\]{}]/g,"\\$&");r=e.split(new RegExp(`(?=${i})`))}else r=e.split(t);else r=e.split("");return r.filter(i=>i!=="")}createDocuments(i){return m(this,arguments,function*(e,t=[],r={}){let s=t.length>0?t:[...Array(e.length)].map(()=>({})),{chunkHeader:o="",chunkOverlapHeader:a="(cont'd) ",appendChunkOverlapHeader:c=!1}=r,l=new Array;for(let u=0;u<e.length;u+=1){let d=e[u],f=1,p=null,y=-1;for(let v of yield this.splitText(d)){let w=o,E=d.indexOf(v,y+1);if(p===null){let O=this.numberOfNewLines(d,0,E);f+=O}else{let O=y+(yield this.lengthFunction(p));if(O<E){let $=this.numberOfNewLines(d,O,E);f+=$}else if(O>E){let $=this.numberOfNewLines(d,E,O);f-=$}c&&(w+=a)}let A=this.numberOfNewLines(v),x=s[u].loc&&typeof s[u].loc=="object"?_({},s[u].loc):{};x.lines={from:f,to:f+A};let M=D(_({},s[u]),{loc:x});w+=v,l.push(new K_({pageContent:w,metadata:M})),f+=A,p=v,y=E}}return l})}numberOfNewLines(e,t,r){return(e.slice(t,r).match(/\n/g)||[]).length}splitDocuments(r){return m(this,arguments,function*(e,t={}){let i=e.filter(a=>a.pageContent!==void 0),s=i.map(a=>a.pageContent),o=i.map(a=>a.metadata);return this.createDocuments(s,o,t)})}joinDocs(e,t){let r=e.join(t).trim();return r===""?null:r}mergeSplits(e,t){return m(this,null,function*(){let r=[],i=[],s=0;for(let a of e){let c=yield this.lengthFunction(a);if(s+c+i.length*t.length>this.chunkSize&&(s>this.chunkSize&&console.warn(`Created a chunk of size ${s}, + 139which is longer than the specified ${this.chunkSize}`),i.length>0)){let l=this.joinDocs(i,t);for(l!==null&&r.push(l);s>this.chunkOverlap||s+c+i.length*t.length>this.chunkSize&&s>0;)s-=yield this.lengthFunction(i[0]),i.shift()}i.push(a),s+=c}let o=this.joinDocs(i,t);return o!==null&&r.push(o),r})}};var sb=class n extends WR{static lc_name(){return"RecursiveCharacterTextSplitter"}constructor(e){super(e),Object.defineProperty(this,"separators",{enumerable:!0,configurable:!0,writable:!0,value:[` 140 141`,` 142`," ",""]}),this.separators=e?.separators??this.separators,this.keepSeparator=e?.keepSeparator??!0}_splitText(e,t){return m(this,null,function*(){let r=[],i=t[t.length-1],s;for(let l=0;l<t.length;l+=1){let u=t[l];if(u===""){i=u;break}if(e.includes(u)){i=u,s=t.slice(l+1);break}}let o=this.splitOnSeparator(e,i),a=[],c=this.keepSeparator?"":i;for(let l of o)if((yield this.lengthFunction(l))<this.chunkSize)a.push(l);else{if(a.length){let u=yield this.mergeSplits(a,c);r.push(...u),a=[]}if(!s)r.push(l);else{let u=yield this._splitText(l,s);r.push(...u)}}if(a.length){let l=yield this.mergeSplits(a,c);r.push(...l)}return r})}splitText(e){return m(this,null,function*(){return this._splitText(e,this.separators)})}static fromLanguage(e,t){return new n(D(_({},t),{separators:n.getSeparatorsForLanguage(e)}))}static getSeparatorsForLanguage(e){if(e==="cpp")return[` 143class `,` 144void `,` 145int `,` 146float `,` 147double `,` 148if `,` 149for `,` 150while `,` 151switch `,` 152case `,` 153 154`,` 155`," ",""];if(e==="go")return[` 156func `,` 157var `,` 158const `,` 159type `,` 160if `,` 161for `,` 162switch `,` 163case `,` 164 165`,` 166`," ",""];if(e==="java")return[` 167class `,` 168public `,` 169protected `,` 170private `,` 171static `,` 172if `,` 173for `,` 174while `,` 175switch `,` 176case `,` 177 178`,` 179`," ",""];if(e==="js")return[` 180function `,` 181const `,` 182let `,` 183var `,` 184class `,` 185if `,` 186for `,` 187while `,` 188switch `,` 189case `,` 190default `,` 191 192`,` 193`," ",""];if(e==="php")return[` 194function `,` 195class `,` 196if `,` 197foreach `,` 198while `,` 199do `,` 200switch `,` 201case `,` 202 203`,` 204`," ",""];if(e==="proto")return[` 205message `,` 206service `,` 207enum `,` 208option `,` 209import `,` 210syntax `,` 211 212`,` 213`," ",""];if(e==="python")return[` 214class `,` 215def `,` 216 def `,` 217 218`,` 219`," ",""];if(e==="rst")return[` 220=== 221`,` 222--- 223`,` 224*** 225`,` 226.. `,` 227 228`,` 229`," ",""];if(e==="ruby")return[` 230def `,` 231class `,` 232if `,` 233unless `,` 234while `,` 235for `,` 236do `,` 237begin `,` 238rescue `,` 239 240`,` 241`," ",""];if(e==="rust")return[` 242fn `,` 243const `,` 244let `,` 245if `,` 246while `,` 247for `,` 248loop `,` 249match `,` 250const `,` 251 252`,` 253`," ",""];if(e==="scala")return[` 254class `,` 255object `,` 256def `,` 257val `,` 258var `,` 259if `,` 260for `,` 261while `,` 262match `,` 263case `,` 264 265`,` 266`," ",""];if(e==="swift")return[` 267func `,` 268class `,` 269struct `,` 270enum `,` 271if `,` 272for `,` 273while `,` 274do `,` 275switch `,` 276case `,` 277 278`,` 279`," ",""];if(e==="markdown")return[` 280## `,` 281### `,` 282#### `,` 283##### `,` 284###### `,"```\n\n",` 285 286*** 287 288`,` 289 290--- 291 292`,` 293 294___ 295 296`,` 297 298`,` 299`," ",""];if(e==="latex")return[` 300\\chapter{`,` 301\\section{`,` 302\\subsection{`,` 303\\subsubsection{`,` 304\\begin{enumerate}`,` 305\\begin{itemize}`,` 306\\begin{description}`,` 307\\begin{list}`,` 308\\begin{quote}`,` 309\\begin{quotation}`,` 310\\begin{verse}`,` 311\\begin{verbatim}`,` 312\\begin{align}`,"$$","$",` 313 314`,` 315`," ",""];if(e==="html")return["<body>","<div>","<p>","<br>","<li>","<h1>","<h2>","<h3>","<h4>","<h5>","<h6>","<span>","<table>","<tr>","<td>","<th>","<ul>","<ol>","<header>","<footer>","<nav>","<head>","<style>","<script>","<meta>","<title>"," ",""];if(e==="sol")return[` 316pragma `,` 317using `,` 318contract `,` 319interface `,` 320library `,` 321constructor `,` 322type `,` 323function `,` 324event `,` 325modifier `,` 326error `,` 327struct `,` 328enum `,` 329if `,` 330for `,` 331while `,` 332do while `,` 333assembly `,` 334 335`,` 336`," ",""];throw new Error(`Language ${e} is not supported.`)}};var Rn={production:!0,firebase:{apiKey:"AIzaSyCUJfZ1Ff0wBhQ-ZggZNJP_xcZ9N-Stn7A",authDomain:"aiplayground-6e5be.firebaseapp.com",projectId:"aiplayground-6e5be",storageBucket:"aiplayground-6e5be.firebasestorage.app",messagingSenderId:"236516094288",appId:"1:236516094288:web:6b8640736a959ce4eabc55",measurementId:"G-R8RH83Z0NY"},useEmulator:!1};var Hc=function(n){return n[n.ERROR=0]="ERROR",n[n.WARN=1]="WARN",n[n.INFO=2]="INFO",n[n.DEBUG=3]="DEBUG",n}(Hc||{}),Kn=(()=>{class n{constructor(){this.currentLevel=Rn.production?Hc.WARN:Hc.DEBUG}shouldLog(t){return t<=this.currentLevel}formatMessage(t,r,i){let o=`[${new Date().toISOString()}] [${t}] ${r}`;return i!==void 0?`${o} ${typeof i=="object"?JSON.stringify(i):i}`:o}error(t,r){this.shouldLog(Hc.ERROR)&&console.error(this.formatMessage("ERROR",t,r))}warn(t,r){this.shouldLog(Hc.WARN)&&console.warn(this.formatMessage("WARN",t,r))}info(t,r){this.shouldLog(Hc.INFO)&&console.info(this.formatMessage("INFO",t,r))}debug(t,r){this.shouldLog(Hc.DEBUG)&&console.debug(this.formatMessage("DEBUG",t,r))}logApiCall(t,r,i){this.debug(`API Call - ${t}`,_({operation:r},i))}logUserAction(t,r){this.info(`User Action - ${t}`,r)}logPerformance(t,r,i){let s=Date.now()-r;this.debug(`Performance - ${t}`,_({duration:`${s}ms`},i))}static{this.\u0275fac=function(r){return new(r||n)}}static{this.\u0275prov=Q({token:n,factory:n.\u0275fac,providedIn:"root"})}}return n})();_$.workerSrc="/assets/pdf.worker.min.js";var w3=(()=>{class n{constructor(t){this.logger=t}pdfToTextByPage(t){return m(this,null,function*(){let r=yield t.arrayBuffer(),i=yield v$({data:r}).promise,s=[];for(let o=1;o<=i.numPages;o++){let l=(yield(yield i.getPage(o)).getTextContent()).items.map(u=>u.str).join(" ").replace(/\s+/g," ").trim();s.push(l)}return s})}chunkPages(t){return m(this,null,function*(){let r=new sb({chunkSize:$n.PDF_PROCESSING.CHUNK_SIZE,chunkOverlap:$n.PDF_PROCESSING.CHUNK_OVERLAP,separators:[` 337 338`,` 339`," ",""]}),i=[],s=0;for(let o=0;o<t.length;o++){let a=t[o];if(a.trim().length===0)continue;let c=yield r.splitText(a);for(let l of c)i.push({text:l.trim(),page:o+1,chunkIndex:s++})}return i})}processPdfFile(t){return m(this,null,function*(){try{this.logger.info("Processing PDF file",{filename:t.name,size:t.size});let r=Date.now(),i=yield this.pdfToTextByPage(t);this.logger.debug("PDF text extraction complete",{pageCount:i.length});let s=yield this.chunkPages(i);return this.logger.logPerformance("PDF Processing",r,{filename:t.name,pageCount:i.length,chunkCount:s.length}),s}catch(r){throw this.logger.error("Error processing PDF",{filename:t.name,error:r}),r}})}static{this.\u0275fac=function(r){return new(r||n)(Y(Kn))}}static{this.\u0275prov=Q({token:n,factory:n.\u0275fac,providedIn:"root"})}}return n})();var qu={providers:{"openrouter.ai":{apiUrls:{LLM:"https://openrouter.ai/api/v1/chat/completions",VISION:"https://openrouter.ai/api/v1/chat/completions"}
339,apiKeyEnvVar:"OPENROUTER_API_KEY",capabilities:["LLM","VISION"]},"together.ai":{apiUrls:{LLM:"https://api.together.xyz/v1/chat/completions",EMBED:"https://api.together.xyz/v1/embeddings",VISION:"https://api.together.xyz/v1/chat/completions"},apiKeyEnvVar:"TOGETHER_API_KEY",capabilities:["LLM","EMBED","VISION"]},ollama:{apiUrls:{LLM:"http://localhost:11434/api/v1/chat/completions",EMBED:"http://localhost:11434/api/embed"},apiKeyEnvVar:"OLLAMA_API_KEY",capabilities:["LLM","EMBED","MCP"]},"publicai.co":{apiUrls:{LLM:"https://api.publicai.co/v1/chat/completions"},apiKeyEnvVar:"PUBLICAI_API_KEY",capabilities:["LLM"]},safeswisscloud:{apiUrls:{LLM:"https://llm02.safeswisscloud.ch/v1/chat/completions",EMBED:"https://llm02.safeswisscloud.ch/v1/embeddings",VISION:"https://llm02.safeswisscloud.ch/v1/chat/completions"},apiKeyEnvVar:"SAFESWISSCLOUD_API_KEY",capabilities:["LLM","EMBED","VISION","MCP"]}},rag:{LLM:{"openrouter.ai":["meta-llama/llama-4-maverick","z-ai/glm-4.5-air","qwen/qwen3-coder","moonshotai/kimi-k2","openai/gpt-oss-20b","qwen/qwen3-30b-a3b-thinking-2507","x-ai/grok-code-fast-1","openai/gpt-5-mini","openai/gpt-5-nano","openai/gpt-5","openai/gpt-oss-120b","anthropic/claude-opus-4.1"],"together.ai":["deepseek-ai/DeepSeek-R1-Distill-Llama-70B-free","lgai/exaone-deep-32b","meta-llama/Llama-3.3-70B-Instruct-Turbo-Free"],"publicai.co":["swiss-ai/apertus-70b-instruct"],safeswisscloud:["apertus-70b","llama33-70b","apertus-8b","mistral-v03-7b","granite-33-8b","llama4-maverick","llama4-scout-17b","gpt-oss120b","kimi-k2","qwen3-8b","qwq-32b","deepseekr1-70b","deepseekr1-670b"]},EMBED:{"together.ai":["intfloat/multilingual-e5-large-instruct","BAAI/bge-base-en-v1.5","BAAI/bge-large-en-v1.5"],ollama:["bge-m3"],safeswisscloud:["bge-m3","granite-emb-278m"]}},chat:{LLM:{"openrouter.ai":["meta-llama/llama-4-maverick","z-ai/glm-4.5-air","qwen/qwen3-coder","moonshotai/kimi-k2","openai/gpt-oss-20b","qwen/qwen3-30b-a3b-thinking-2507","x-ai/grok-code-fast-1","openai/gpt-5-mini","openai/gpt-5-nano","openai/gpt-5","openai/gpt-oss-120b","anthropic/claude-opus-4.1"],"together.ai":["deepseek-ai/DeepSeek-R1-Distill-Llama-70B-free","lgai/exaone-deep-32b","meta-llama/Llama-3.3-70B-Instruct-Turbo-Free"],"publicai.co":["swiss-ai/apertus-70b-instruct"],safeswisscloud:["apertus-70b","llama33-70b","apertus-8b","mistral-v03-7b","granite-33-8b","llama4-maverick","llama4-scout-17b","gpt-oss120b","kimi-k2","qwen3-8b","qwq-32b","deepseekr1-70b","deepseekr1-670b"]},MCP:{"openrouter.ai":["moonshotai/kimi-k2","meta-llama/llama-4-maverick","mistralai/mistral-medium-3.1","deepseek/deepseek-chat-v3.1","qwen/qwen3-coder:free","qwen/qwen3-coder","qwen/qwen3-30b-a3b-thinking-2507","x-ai/grok-code-fast-1","openai/gpt-5-mini","openai/gpt-5-nano","openai/gpt-5","openai/gpt-oss-120b","anthropic/claude-opus-4.1"],ollama:["qwen3-coder:30b"],safeswisscloud:["qwq-32b","qwen3-8b"]}},vision:{VISION:{"openrouter.ai":["google/gemini-2.5-flash-preview-09-2025","moonshotai/kimi-vl-a3b-thinking","moonshotai/kimi-k2","meta-llama/llama-4-maverick","openai/gpt-4o","anthropic/claude-3.5-sonnet","google/gemini-2.0-flash-exp","meta-llama/llama-3.2-90b-vision-instruct"],"together.ai":["meta-llama/Llama-3.2-90B-Vision-Instruct-Turbo","meta-llama/Llama-Vision-Free"],safeswisscloud:["qwq25-vl-72b","granite-vision-2b","gemma12b-it","llama4-scout-17b","llama4-maverick"]}}};function jce(){let n={},e=qu;if(e.providers)for(let[t,r]of Object.entries(e.providers)){let i=r;i.apiUrls&&(n[t]=i.apiUrls)}return n}var $ce=jce();function Uce(){let n={},e=qu;if(e.providers)for(let[t,r]of Object.entries(e.providers)){let i=r;i.apiKeyEnvVar&&(n[t]=i.apiKeyEnvVar)}return n}var Bce=Uce();function Hce(){let n=[],e=qu;if(e.providers)for(let[t,r]of Object.entries(e.providers)){let i=r;i.capabilities&&i.capabilities.includes("EMBED")&&n.push(t)}return n}var qce=Hce(),KR={referer:"https://aiplayground-6e5be.web.app",title:{default:"Firebase RAG Chatbot",chat:"Vanguard Signals AI Playground"}};function E3(n,e){return $ce[n]?.[e]||""}function I3(n){return Bce[n]||"UNKNOWN_API_KEY"}function T3(n){return qce.includes(n)}function A3(n,e,t){let r={Authorization:`Bearer ${e}`,"Content-Type":"application/json"};return n==="openrouter.ai"&&(r["HTTP-Referer"]=KR.referer,r["X-Title"]=t==="chat"?KR.title.chat:KR.title.default),r}var ob=(()=>{class n{constructor(){this.fullConfig=qu,this.config={};for(let[t,r]of Object.entries(this.fullConfig))t!=="providers"&&(this.config[t]=r)}getApps(){return Object.keys(this.config)}getModelTypes(t){return this.config[t]?Object.keys(this.config[t]):[]}getProviders(t,r){let i=this.config[t];return!i||!i[r]?[]:Object.keys(i[r])}getModels(t,r,i){let s=this.config[t];return!s||!s[r]||!s[r][i]?[]:s[r][i]}getDefaultSelection(t){let r=this.getModelTypes(t);if(r.length===0)return null;let i={};for(let s of r){let o=this.getProviders(t,s);if(o.length>0){let a=o[0],c=this.getModels(t,s,a);c.length>0&&(i[s.toLowerCase()]={provider:a,model:c[0]})}}return Object.keys(i).length>0?i:null}validateSelection(t,r,i,s){return this.getModels(t,r,i).includes(s)}getDefaultRAGSelection(){let t=this.getDefaultSelection("rag");return!t||!t.llm||!t.embed?null:{llm:t.llm,embed:t.embed}}getProviderApiUrl(t,r){return E3(t,r)}getProviderHeaders(t,r,i){return A3(t,r,i)}getApiKeyEnvVar(t){return I3(t)}supportsEmbeddings(t){return T3(t)}static{this.\u0275fac=function(r){return new(r||n)}}static{this.\u0275prov=Q({token:n,factory:n.\u0275fac,providedIn:"root"})}}return n})();
339var Cs=(()=>{class n{constructor(t,r){this.modelsConfig=t,this.logger=r,this.currentSelectionSubject=new gt(null),this.currentSelection$=this.currentSelectionSubject.asObservable(),this.currentAppSubject=new gt("rag"),this.currentApp$=this.currentAppSubject.asObservable(),this.mcpEnabledSubject=new gt(!1),this.mcpEnabled$=this.mcpEnabledSubject.asObservable(),this.modelParamsSubject=new gt({temperature:1,seed:-1,memoryEnabled:!1}),this.modelParams$=this.modelParamsSubject.asObservable();let i=this.modelsConfig.getDefaultSelection("rag");i&&this.currentSelectionSubject.next(i)}getCurrentSelection(){return this.currentSelectionSubject.value}updateSelection(t){this.logger.debug("Global service updating selection to",t),this.currentSelectionSubject.next(t)}updateCurrentApp(t){this.logger.debug("Global service updating app to",t),this.currentAppSubject.next(t);let r=this.modelsConfig.getDefaultSelection(t);r&&this.updateSelection(r)}getCurrentApp(){return this.currentAppSubject.value}getSelectionForRequest(){let t=this.getCurrentSelection();return this.logger.debug("Getting selection for request",t),t||void 0}getRAGSelectionForRequest(){let t=this.getCurrentSelection();if(!(!t||!t.llm||!t.embed))return{llm:t.llm,embed:t.embed}}getModelsConfig(){return this.modelsConfig}updateMcpEnabled(t){this.logger.debug("Global service updating MCP enabled to",t),this.mcpEnabledSubject.next(t);let r=this.getCurrentApp();if(r==="chat"){let i=this.getFilteredDefaultSelection(r,t);i&&this.updateSelection(i)}}getMcpEnabled(){return this.mcpEnabledSubject.value}getFilteredModelTypes(t){let r=this.modelsConfig.getModelTypes(t);if(t==="chat"){let i=this.getMcpEnabled();return r.filter(s=>i?s==="MCP":s==="LLM")}return r}getFilteredDefaultSelection(t,r){let i=this.getFilteredModelTypes(t);if(i.length===0)return null;let s={};for(let o of i){let a=this.modelsConfig.getProviders(t,o);if(a.length>0){let c=a[0],l=this.modelsConfig.getModels(t,o,c);l.length>0&&(s[o.toLowerCase()]={provider:c,model:l[0]})}}return Object.keys(s).length>0?s:null}updateModelParams(t){this.logger.debug("Global service updating model params to",t),this.modelParamsSubject.next(t)}getModelParams(){return this.modelParamsSubject.value}getModelParamsForRequest(){let t=this.getModelParams();return this.logger.debug("Getting model params for request",t),t}getMemoryEnabled(){return this.modelParamsSubject.value.memoryEnabled}static{this.\u0275fac=function(r){return new(r||n)(Y(ob),Y(Kn))}}static{this.\u0275prov=Q({token:n,factory:n.\u0275fac,providedIn:"root"})}}return n})();var S3=(()=>{class n{constructor(t,r,i,s,o,a){this.firestore=t,this.storage=r,this.functions=i,this.auth=s,this.globalModelSelection=o,this.logger=a,this.embedChunks=co(this.functions,"embedChunks")}uploadPdf(t){return m(this,null,function*(){if(!this.auth.currentUser)throw new Error("User not authenticated");let r=this.auth.currentUser.uid,i=Date.now(),s=t.name.replace(/\s+/g,"_").replace(/[,;:'"!?()[\]{}]/g,"").replace(/_+/g,"_"),o=`${i}_${s}`,a=`documents/${r}/${o}`,c=oS(this.storage,a);yield aS(c,t);let l=yield sS(c),u=this.globalModelSelection.getCurrentSelection(),d=u?.embed?{provider:u.embed.provider,model:u.embed.model}:void 0,f={uid:r,filename:t.name,bucketPath:a,pageCount:0,status:"processing",createdAt:new Date,uploadUrl:l,embedModel:d};return(yield io(ir(this.firestore,"documents"),f)).id})}saveChunksWithEmbeddings(t,r){return m(this,null,function*(){if(!this.auth.currentUser)throw new Error("User not authenticated");let i=this.auth.currentUser.uid,s=64,o=ir(this.firestore,`documents/${t}/chunks`);for(let a=0;a<r.length;a+=s){let c=r.slice(a,a+s),l=c.map(u=>u.text);try{this.logger.debug(`Getting embeddings for batch ${Math.floor(a/s)+1}/${Math.ceil(r.length/s)}`);let u=this.globalModelSelection.getCurrentSelection(),d={texts:l};u?.embed&&(d.provider=u.embed.provider,d.model=u.embed.model);let{data:f}=yield this.embedChunks(d),p=c.map((y,v)=>m(this,null,function*(){let w=D(_({},y),{docId:t,uid:i,embedding:f.vectors[v]||[],embedModel:u?.embed?{provider:u.embed.provider,model:u.embed.model}:void 0});return io(o,w)}));yield Promise.all(p)}catch(u){throw this.logger.error("Error getting embeddings for batch",u),u}}})}updateDocumentStatus(t,r,i){return m(this,null,function*(){let s=so(this.firestore,`documents/${t}`),o={status:r};i!==void 0&&(o.pageCount=i),yield oo(s,o)})}getUserDocuments(){return m(this,null,function*(){if(!this.auth.currentUser)return[];let t=this.auth.currentUser.uid,r=mc(ir(this.firestore,"documents"),hu("uid","==",t),Uh("createdAt","desc"));return(yield sa(r)).docs.map(s=>{let o=s.data();return D(_({id:s.id},o),{createdAt:o.createdAt?.toDate?o.createdAt.toDate():new Date(o.createdAt)})})})}deleteDocument(t){return m(this,null,function*(){if(!this.auth.currentUser)throw new Error("User not authenticated");yield co(this.functions,"deleteDocument")({docId:t})})}uploadDocument(t){return m(this,null,function*(){if(!this.auth.currentUser)throw new Error("User not authenticated");if(!Au.includes(t.type))throw new Error(`Unsupported file type: ${t.type}`);let r=this.auth.currentUser.uid,i=Date.now(),s=t.name.replace(/\s+/g,"_").replace(/[,;:'"!?()[\]{}]/g,"").replace(/_+/g,"_"),o=`${i}_${s}`,a=`documents/${r}/${o}`,c=this.globalModelSelection.getCurrentSelection(),l=c?.embed?{provider:c.embed.provider,model:c.embed.model}:void 0,u={uid:r,filename:t.name,bucketPath:a,pageCount:0,status:"processing",createdAt:new Date,embedModel:l},d=yield io(ir(this.firestore,"documents"),u);this.logger.debug(`Created Firestore document ${d.id} before Storage upload`);let f=oS(this.storage,a);yield aS(f,t),this.logger.debug(`File uploaded to Storage: ${a}`);let p=yield sS(f);return yield oo(d,{uploadUrl:p}),d.id})}watchDocumentStatus(t){let r=new mt,i=so(this.firestore,`documents/${t}`),s=EV(i,o=>{if(o.exists()){let a=o.data();r.next(D(_({id:o.id},a),{createdAt:a.createdAt?.toDate?a.createdAt.toDate():new Date(a.createdAt)}))}},o=>{r.error(o)});return new Ue(o=>{let a=r.subscribe(o);return()=>{a.unsubscribe(),s()}})}generateEmbeddingsForChunks(t){return m(this,null,function*(){if(this.logger.debug(`generateEmbeddingsForChunks called for docId: ${t}`),!this.auth.currentUser)throw this.logger.error("User not authenticated"),new Error("User not authenticated");let r=this.auth.currentUser.uid;this.logger.debug(`User uid: ${r}`);let i=ir(this.firestore,`documents/${t}/chunks`);this.logger.debug(`Fetching chunks from: documents/${t}/chunks`);let s=yield sa(i);if(s.empty){this.logger.warn(`No chunks found for document ${t}`),yield this.updateDocumentStatus(t,"error");return}this.logger.debug(`Found ${s.size} chunks for document ${t}`);let o=s.docs.map(l=>_({id:l.id},l.data()));this.logger.debug(`Generating embeddings for ${o.length} chunks`);let a=this.globalModelSelection.getCurrentSelection();this.logger.debug("Model selection",a);let c=64;for(let l=0;l<o.length;l+=c){let u=o.slice(l,l+c),d=u.map(f=>f.text);try{this.logger.debug(`Getting embeddings for batch ${Math.floor(l/c)+1}/${Math.ceil(o.length/c)}`),this.logger.debug(`Batch has ${d.length} texts`);let f={texts:d};a?.embed&&(f.provider=a.embed.provider,f.model=a.embed.model),this.logger.debug("Calling embedChunks function with request",f);let{data:p}=yield this.embedChunks(f);this.logger.debug(`embedChunks returned ${p.vectors?.length||0} vectors`);let y=u.map((v,w)=>m(this,null,function*(){let E=so(this.firestore,`documents/${t}/chunks/${v.id}`),A={embedding:p.vectors[w]||[]};return a?.embed&&(A.embedModel={provider:a.embed.provider,model:a.embed.model}),oo(E,A)}));yield Promise.all(y)}catch(f){throw this.logger.error("Error getting embeddings for batch",f),f}}this.logger.debug("All batches processed, updating document status to completed"),yield this.updateDocumentStatus(t,"completed"),this.logger.debug(`Embeddings generated and status updated for document ${t}`)})}
339isSupported(t){return Au.includes(t)}static{this.\u0275fac=function(r){return new(r||n)(Y(ro),Y(gc),Y(ao),Y(Di),Y(Cs),Y(Kn))}}static{this.\u0275prov=Q({token:n,factory:n.\u0275fac,providedIn:"root"})}}return n})();var _a=(()=>{class n{constructor(t,r){this.promptLogging=t,this.logger=r,this.serversSubject=new gt([]),this.servers$=this.serversSubject.asObservable(),this.availableToolsSubject=new gt([]),this.availableTools$=this.availableToolsSubject.asObservable(),this.initializeDefaultServers()}initializeDefaultServers(){let t=[{id:"weather-local",name:"Weather Server",description:"Local weather and forecast data via OpenMeteo APIs",url:Rn.production?"https://us-central1-aiplayground-6e5be.cloudfunctions.net/mcpWeatherServer":"http://127.0.0.1:5001/aiplayground-6e5be/us-central1/mcpWeatherServer",type:"http",enabled:!0,status:"unknown"},{id:"yfinance-local",name:"Yahoo Finance Server",description:"Stock market data and financial metrics via Yahoo Finance APIs",url:Rn.production?"https://us-central1-aiplayground-6e5be.cloudfunctions.net/mcpYFinanceServer":"http://127.0.0.1:5001/aiplayground-6e5be/us-central1/mcpYFinanceServer",type:"http",enabled:!1,status:"unknown"},{id:"time-local",name:"Time Server",description:"Current time and timezone conversion utilities",url:Rn.production?"https://us-central1-aiplayground-6e5be.cloudfunctions.net/mcpTimeServer":"http://127.0.0.1:5001/aiplayground-6e5be/us-central1/mcpTimeServer",type:"http",enabled:!1,status:"unknown"},{id:"unit-converter-local",name:"Unit Converter Server",description:"Convert between various units (temperature, length, mass, volume, data)",url:Rn.production?"https://us-central1-aiplayground-6e5be.cloudfunctions.net/mcpUnitConverterServer":"http://127.0.0.1:5001/aiplayground-6e5be/us-central1/mcpUnitConverterServer",type:"http",enabled:!1,status:"unknown"},{id:"calculator-local",name:"Calculator Server",description:"Mathematical calculations, equation solving, statistics, and matrix operations",url:Rn.production?"https://us-central1-aiplayground-6e5be.cloudfunctions.net/mcpCalculatorServer":"http://127.0.0.1:5001/aiplayground-6e5be/us-central1/mcpCalculatorServer",type:"http",enabled:!1,status:"unknown"},{id:"currency-local",name:"Currency Converter Server",description:"Real-time currency conversion and exchange rates via Frankfurter API",url:Rn.production?"https://us-central1-aiplayground-6e5be.cloudfunctions.net/mcpCurrencyServer":"http://127.0.0.1:5001/aiplayground-6e5be/us-central1/mcpCurrencyServer",type:"http",enabled:!1,status:"unknown"}];this.serversSubject.next(t)}getServers(){return this.serversSubject.value}getEnabledServers(){return this.serversSubject.value.filter(t=>t.enabled)}getAvailableTools(){return this.availableToolsSubject.value}toggleServer(t,r){return m(this,null,function*(){let i=this.serversSubject.value.map(s=>s.id===t?D(_({},s),{enabled:r}):s);this.serversSubject.next(i),r&&(yield this.initializeServer(t)),yield this.updateAvailableTools()})}initializeServer(t){return m(this,null,function*(){let r=this.serversSubject.value,i=r.find(s=>s.id===t);if(!i)return this.logger.error("Server not found",t),!1;try{this.logger.info(`Initializing MCP server: ${i.name}`);let s=yield fetch(`${i.url}/initialize`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:1,method:"initialize"})});if(!s.ok)throw new Error(`Init failed: ${s.status}`);let o=yield fetch(`${i.url}/tools/list`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:2,method:"tools/list"})});if(!o.ok)throw new Error(`Tools list failed: ${o.status}`);let c=((yield o.json()).result?.tools||[]).map(u=>D(_({},u),{serverId:i.id})),l=r.map(u=>u.id===t?D(_({},u),{status:"online",tools:c,lastChecked:new Date}):u);return this.serversSubject.next(l),yield this.updateAvailableTools(),this.logger.info(`${i.name} initialized with ${c.length} tools`),!0}catch(s){this.logger.error(`Failed to initialize ${i.name}`,s);let o=r.map(a=>a.id===t?D(_({},a),{status:"error",lastChecked:new Date}):a);return this.serversSubject.next(o),!1}})}callTool(t,r){return m(this,null,function*(){let i=this.serversSubject.value.find(l=>l.id===t.serverId);if(!i)throw new Error(`Server not found: ${t.serverId}`);if(!i.enabled||i.status!=="online")throw new Error(`Server not available: ${i.name}`);let s=r||`mcp_${Date.now()}_${Math.random().toString(36).substring(2,11)}`,o="";this.promptLogging.isLoggingActive()&&(o=this.promptLogging.addPromptLog({type:"request",provider:"MCP Server",model:i.name,content:`Tool: ${t.toolName} 340Arguments: ${JSON.stringify(t.arguments,null,2)}`,timestamp:new Date,sessionContext:"mcp-tool-call",messageId:s,status:"pending",title:`Tool Call Request \xB7 ${t.toolName}`,metadata:{toolName:t.toolName,sequence:25}}));let a=yield fetch(`${i.url}/tools/call`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:Date.now(),params:{name:t.toolName,arguments:t.arguments}})});if(!a.ok)throw o&&this.promptLogging.updatePromptLog(o,{status:"error",content:`Tool: ${t.toolName} 341Arguments: ${JSON.stringify(t.arguments,null,2)} 342Error: ${a.status} ${a.statusText}`}),new Error(`Tool call failed: ${a.statusText}`);let c=yield a.json();if(c.error)throw o&&this.promptLogging.updatePromptLog(o,{status:"error",content:`Tool: ${t.toolName} 343Arguments: ${JSON.stringify(t.arguments,null,2)} 344Error: ${c.error.message}`}),new Error(`Tool error: ${c.error.message}`);return this.promptLogging.isLoggingActive()&&(o&&this.promptLogging.updatePromptLog(o,{status:"completed"}),this.promptLogging.addPromptLog({type:"response",provider:"MCP Server",model:i.name,content:JSON.stringify(c.result,null,2),timestamp:new Date,sessionContext:"mcp-tool-call",messageId:s,status:"completed",title:`Tool Call Response \xB7 ${t.toolName}`,metadata:{toolName:t.toolName,sequence:35}})),c.result})}updateAvailableTools(){return m(this,null,function*(){let t=this.getEnabledServers().filter(i=>i.status==="online"),r=[];for(let i of t)i.tools&&r.push(...i.tools);
344this.availableToolsSubject.next(r),this.logger.debug(`Updated available tools: ${r.length} tools from ${t.length} servers`)})}addCustomServer(t){return m(this,null,function*(){let r=D(_({},t),{id:`custom-${Date.now()}`,enabled:!1,status:"unknown"}),i=[...this.serversSubject.value,r];this.serversSubject.next(i)})}removeServer(t){return m(this,null,function*(){let r=this.serversSubject.value.filter(i=>i.id!==t);this.serversSubject.next(r),yield this.updateAvailableTools()})}refreshServerStatus(t){return m(this,null,function*(){let r=t?this.serversSubject.value.filter(i=>i.id===t):this.getEnabledServers();for(let i of r)yield this.initializeServer(i.id)})}static{this.\u0275fac=function(r){return new(r||n)(Y(Zr),Y(Kn))}}static{this.\u0275prov=Q({token:n,factory:n.\u0275fac,providedIn:"root"})}}return n})();var cb=(()=>{class n{constructor(t){this.mcpRegistry=t}callTool(t,r){return m(this,null,function*(){let s=this.mcpRegistry.getAvailableTools().find(a=>a.name===t.name);if(!s)throw new Error(`Tool not found: ${t.name}`);let o={serverId:s.serverId,toolName:t.name,arguments:t.arguments};return this.mcpRegistry.callTool(o,r)})}static{this.\u0275fac=function(r){return new(r||n)(Y(_a))}}static{this.\u0275prov=Q({token:n,factory:n.\u0275fac,providedIn:"root"})}}return n})();var zu=(()=>{class n{constructor(){this.cache=new Map}transformMarkdown(t){return m(this,null,function*(){if(!t)return t??"";let r=this.containsMath(t),i=this.containsSvg(t);if(!r&&!i)return t;let s=i?this.convertSvgCodeFences(t):t,o=this.extractSegments(s);if(!o.some(l=>l.type==="math"))return t;let a=yield this.loadMathJax(),c=[];for(let l of o){if(l.type==="text"){let f=this.convertSvgCodeFences(l.content);f=this.convertInlineSvgs(f),c.push(f);continue}let u=`${l.display?"block":"inline"}::${l.content}`,d=this.cache.get(u);d||(d=yield this.renderSegment(a,l.content,l.display),this.cache.set(u,d)),c.push(d)}return c.join("")})}convertInlineSvgs(t){let r=/(?:<\?xml[^>]*\?>\s*)?<svg[\s\S]*?<\/svg>/gi;return t.replace(r,i=>{let s=i.replace(/^[^<]*<\?xml[^>]*\?>\s*/i,"").trim();if(!s.startsWith("<svg"))return i;try{let o=this.svgToDataUri(s),a=s.match(/<title>([\s\S]*?)<\/title>/i),c=this.createAltText(a?a[1]:"Generated SVG graphic");return` 345<div class="svg-embedded-block"><img class="svg-embedded-image" src="${o}" alt="${c}"></div> 346`}catch(o){return console.warn("Failed to embed inline SVG, leaving original markup",{error:o}),i}})}convertSvgCodeFences(t){let r=/```svg\s+([\s\S]*?)```/gi;return t.replace(r,(i,s)=>
346{console.log("[MathRenderingService] Converting SVG fence");let o=s.trim();if(!o)return console.log("[MathRenderingService] Fence empty, skipping"),i;let a=o.replace(/^[^<]*<\?xml[^>]*\?>\s*/i,"");if(!a.trim().toLowerCase().startsWith("<svg"))return console.log("[MathRenderingService] Fence content not SVG, skipping"),i;try{let c=this.svgToDataUri(a.trim()),l=a.match(/<title>([\s\S]*?)<\/title>/i),u=this.createAltText(l?l[1]:"Generated SVG graphic");return console.log("[MathRenderingService] Fence converted successfully"),` 347<div class="svg-embedded-block"><img class="svg-embedded-image" src="${c}" alt="${u}"></div> 348`}catch(c){return console.warn("Failed to embed SVG code fence, leaving original content",{error:c}),i}})}containsMath(t){return/\$\$|\\\[|\\\(|\$(?=\S)/.test(t)}containsSvg(t){return/```svg|<svg[\s>]/i.test(t)}extractSegments(t){let r=[],i="",s=0,o=()=>{i&&(r.push({type:"text",content:i,display:!1}),i="")},a=t.length;for(;s<a;){if(t.startsWith("```",s)){let c=t.indexOf("```",s+3),l=c===-1?a:c+3;i+=t.slice(s,l),s=l;continue}if(t[s]==="`"){let c=t.indexOf("`",s+1);if(c===-1){i+=t.slice(s);break}i+=t.slice(s,c+1),s=c+1;continue}if(t.startsWith("$$",s)){let c=t.indexOf("$$",s+2);if(c!==-1){let l=t.slice(s+2,c);o(),r.push({type:"math",content:l.trim(),display:!0}),s=c+2;continue}}if(t.startsWith("\\[",s)){let c=t.indexOf("\\]",s+2);if(c!==-1){let l=t.slice(s+2,c);o(),r.push({type:"math",content:l.trim(),display:!0}),s=c+2;continue}}if(t.startsWith("\\(",s)){let c=t.indexOf("\\)",s+2);if(c!==-1){let l=t.slice(s+2,c);o(),r.push({type:"math",content:l.trim(),display:!1}),s=c+2;continue}}if(t[s]==="$"&&!this.isEscaped(t,s)&&!t.startsWith("$$",s)){let c=this.findInlineDollar(t,s+1);if(c!==-1){let l=t.slice(s+1,c);if(l.trim().length>0){o(),r.push({type:"math",content:l.trim(),display:!1}),s=c+1;continue}}}i+=t[s],s+=1}return i&&r.push({type:"text",content:i,display:!1}),r}isEscaped(t,r){let i=0,s=r-1;for(;s>=0&&t[s]==="\\";)i+=1,s-=1;return i%2===1}findInlineDollar(t,r){let i=r;for(;i<t.length;){let s=t[i];if(s==="$"&&!this.isEscaped(t,i))return i;if(s===` 349`)return-1;i+=1}return-1}renderSegment(t,r,i){return m(this,null,function*(){try{if(!t.tex2svgPromise)throw new Error("MathJax SVG renderer not available");let s=yield t.tex2svgPromise(r,{display:i}),a=this.extractSvgMarkup(s).replace(/\s+/g," ").trim(),c=this.applyMathColor(a),l=this.svgToDataUri(c),u=this.createAltText(r);return i?` 350<div class="math-render-block"><img class="math-render-image" src="${l}" alt="${u}"></div> 351`:`<span class="math-render-inline"><img class="math-render-inline-image" src="${l}" alt="${u}"></span>`}catch(s){return console.warn("Math rendering failed, falling back to raw expression",{expression:r,error:s}),i?` 352 353$$${r}$$ 354 355`:`$${r}$`}})}extractSvgMarkup(t){let i=(typeof window<"u"?window:void 0)?.MathJax?.startup?.adaptor;if(i)try{let s=i.firstChild(t);if(s&&i.kind(s)==="svg")return i.outerHTML(s)}catch(s){console.warn("MathJax adaptor failed to extract SVG element",s)}if(t?.querySelector){let s=t.querySelector("svg");if(s)return s.outerHTML}if(t&&typeof t.outerHTML=="string"&&t.outerHTML.trim().startsWith("<svg"))return t.outerHTML;throw new Error("Unable to obtain SVG markup from MathJax output")}svgToDataUri(t){if(typeof window>"u"||typeof btoa!="function")return`data:image/svg+xml;utf8,${encodeURIComponent(t)}`;try{return`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(t)))}`}catch(r){return console.warn("Failed to encode SVG as base64, falling back to UTF-8 data URI",r),`data:image/svg+xml;utf8,${encodeURIComponent(t)}`}}createAltText(t){return t.replace(/\s+/g," ").replace(/"/g,""").trim()}applyMathColor(t){if(/\bcolor\s*=|\bcolor\s*:/.test(t))return t;let i=t.match(/<svg[^>]*style=["']([^"']*)["']/i);if(i){let s=i[1],o=`color:#ffffff;${s}`;return t.replace(i[0],i[0].replace(s,o))}return t.replace("<svg",'<svg style="color:#ffffff;"')}loadMathJax(){if(typeof window>"u")return Promise.resolve({});let t=window.MathJax;return t&&t.tex2svgPromise?t.startup?.promise?t.startup.promise.then(()=>t):Promise.resolve(t):(this.mathJaxLoader||(this.mathJaxLoader=new Promise((r,i)=>{let s=window;s.MathJax||(s.MathJax={startup:{typeset:!1},svg:{fontCache:"none"},options:{enableMenu:!1},tex:{inlineMath:[["$","$"],["\\(","\\)"]],displayMath:[["$$","$$"],["\\[","\\]"]],packages:{"[+]":["noerrors","noundefined"]}}});let o="mathjax-svg-script",a=document.getElementById(o);if(a){a.addEventListener("load",()=>{let l=window.MathJax;l?.startup?.promise?l.startup.promise.then(()=>r(l)).catch(i):r(l??{})}),a.addEventListener("error",i);return}let c=document.createElement("script");c.id=o,c.type="text/javascript",c.async=!0,c.defer=!0,c.src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js",c.onload=()=>{let l=window.MathJax;l?.startup?.promise?l.startup.promise.then(()=>r(l)).catch(i):r(l??{})},c.onerror=i,document.head.appendChild(c)})),this.mathJaxLoader)}static{this.\u0275fac=function(r){return new(r||n)}}static{this.\u0275prov=Q({token:n,factory:n.\u0275fac,providedIn:"root"})}}return n})();var D3=(()=>{class n{constructor(t,r,i,s,o,a,c,l,u){this.firestore=t,this.functions=r,this.auth=i,this.mcpService=s,this.mcpRegistry=o,this.promptLogging=a,this.globalModelSelection=c,this.mathRenderer=l,this.logger=u,this.chatRag=co(this.functions,"chatRag"),this.generalChat=co(this.functions,"generalChat"),this.visionChat=co(this.functions,"visionChat"),this.mcpChat=co(this.functions,"mcpChat")}createSession(t,r){return m(this,null,function*(){if(!this.auth.currentUser)throw new Error("User not authenticated");let s={uid:this.auth.currentUser.uid,title:t||`Chat ${new Date().toLocaleStr
355ing()}`,createdAt:new Date,associatedDocuments:r||[]};return(yield io(ir(this.firestore,"sessions"),s)).id})}getUserSessions(){return m(this,null,function*(){if(!this.auth.currentUser)return[];let t=this.auth.currentUser.uid,r=mc(ir(this.firestore,"sessions"),hu("uid","==",t),Uh("createdAt","desc"));return(yield sa(r)).docs.map(s=>D(_({id:s.id},s.data()),{createdAt:s.data().createdAt.toDate()}))})}getSessionMessages(t){return m(this,null,function*(){let r=mc(ir(this.firestore,`sessions/${t}/messages`),Uh("createdAt","asc"));return(yield sa(r)).docs.map(s=>D(_({id:s.id},s.data()),{createdAt:s.data().createdAt.toDate()}))})}sendMessage(t,r,i,s,o){return m(this,null,function*(){if(!this.auth.currentUser)throw new Error("User not authenticated");let a={role:"user",content:r,createdAt:new Date};yield io(ir(this.firestore,`sessions/${t}/messages`),a);try{let c={sessionId:t,message:r,k:8,restrictDocId:i,enablePromptLogging:this.promptLogging.isLoggingActive()};s?(s.llm&&(c.llmProvider=s.llm.provider,c.llmModel=s.llm.model),s.embed&&(c.embedProvider=s.embed.provider,c.embedModel=s.embed.model),this.logger.debug("Chat service sending RAG request with models",{llmProvider:c.llmProvider,llmModel:c.llmModel,embedProvider:c.embedProvider,embedModel:c.embedModel})):this.logger.debug("Chat service: No model selection provided, using defaults");let l=this.globalModelSelection.getModelParamsForRequest();c.temperature=l.temperature,l.seed!==-1&&(c.seed=l.seed),o&&o.length>0&&(c.conversationHistory=o);let{data:u}=yield this.chatRag(c),f={role:"assistant",content:yield this.mathRenderer.transformMarkdown(u.answer),sources:u.sources,createdAt:new Date},p=yield io(ir(this.firestore,`sessions/${t}/messages`),f);if(this.promptLogging.isLoggingActive()&&u.promptData){let y=p.id;u.promptData.embedRequest&&this.logPromptPair(u.promptData.embedRequest,"request","rag",y),u.promptData.embedResponse&&this.logPromptPair(u.promptData.embedResponse,"response","rag",y),u.promptData.searchData&&this.logPromptEntry("response","RAG Search","Document Search",this.formatSearchData(u.promptData.searchData),"rag",y),u.promptData.llmRequest&&this.logPromptPair(u.promptData.llmRequest,"request","rag",y),u.promptData.llmResponse&&this.logPromptPair(u.promptData.llmResponse,"response","rag",y)}return _({id:p.id},f)}catch(c){this.logger.error("Error getting RAG response",c);let l="Sorry, I encountered an error processing your question. Please try again.";c&&typeof c=="object"&&"message"in c&&(l=c.message);let u={role:"assistant",content:l,createdAt:new Date},d=yield io(ir(this.firestore,`sessions/${t}/messages`),u);return _({id:d.id},u)}})}sendGeneralMessage(t,r,i){return m(this,null,function*(){if(!this.auth.currentUser)throw new Error("User not authenticated");try{let s={message:t,enablePromptLogging:this.promptLogging.isLoggingActive()};r&&r.llm?(s.llmProvider=r.llm.provider,s.llmModel=r.llm.model,this.logger.debug("Chat service sending general request with models",{llmProvider:s.llmProvider,llmModel:s.llmModel})):this.logger.debug("Chat service: No model selection provided for general chat, using defaults");let o=this.globalModelSelection.getModelParamsForRequest();s.temperature=o.temperature,o.seed!==-1&&(s.seed=o.seed),i&&i.length>0&&(s.conversationHistory=i);let{data:a}=yield this.generalChat(s),c=`general_${Date.now()}_${Math.random().toString(36).substr(2,9)}`;return this.promptLogging.isLoggingActive()&&a.promptData&&(a.promptData.llmRequest&&this.logPromptPair(a.promptData.llmRequest,"request","general",c),a.promptData.llmResponse&&this.logPromptPair(a.promptData.llmResponse,"response","general",c)),{id:c,role:"assistant",content:yield this.mathRenderer.transformMarkdown(a.answer),createdAt:new Date}}catch(s){this.logger.error("Error getting general chat response",s);let o="Sorry, I encountered an error processing your question. Please try again.";return s&&typeof s=="object"&&"message"in s&&(o=s.message),{role:"assistant",content:o,createdAt:new Date}}})}sendVisionMessage(t,r,i,s){return m(this,null,function*(){if(!this.auth.currentUser)throw new Error("User not authenticated");try{let o=yield this.fileToBase64(t),a={message:r,imageData:o,enablePromptLogging:this.promptLogging.isLoggingActive()};i&&i.vision?(a.visionProvider=i.vision.provider,a.visionModel=i.vision.model,this.logger.debug("Chat service sending vision request with models",{visionProvider:a.visionProvider,visionModel:a.visionModel})):this.logger.debug("Chat service: No model selection provided for vision, using defaults");let c=this.globalModelSelection.getModelParamsForRequest();a.temperature=c.temperature,c.seed!==-1&&(a.seed=c.seed),s&&s.length>0&&(a.conversationHistory=s);let{data:l}=yield this.visionChat(a),u=`vision_${Date.now()}_${Math.random().toString(36).substr(2,9)}`;return this.promptLogging.isLoggingActive()&&l.promptData&&(l.promptData.visionRequest&&this.logPromptPair(l.promptData.visionRequest,"request","vision",u),l.promptData.visionResponse&&this.logPromptPair(l.promptData.visionResponse,"response","vision",u)),{id:u,role:"assistant",content:yield this.mathRenderer.transformMarkdown(l.answer),createdAt:new Date}}catch(o){return this.logger.error("Error getting vision response",o),{role:"assistant",content:"Sorry, I encountered an error analyzing your image. Please try again.",createdAt:new Date}}})}fileToBase64(t){return new Promise((r,i)=>{let s=new FileReader;s.onload=()=>{let a=s.result.split(",")[1];r(a)},s.onerror=i,s.readAsDataURL(t)})}updateSessionDocuments(t,r){return m(this,null,function*(){let i=so(this.firestore,`sessions/${t}`);yield oo(i,{associatedDocuments:r})})}addDocumentToSession(t,r){return m(this,null,function*(){let i=so(this.firestore,`sessions/${t}`),s=yield sa(mc(ir(this.firestore,"sessions"),hu("__name__","==",t)));if(!s.empty){let a=s.docs[0].data().associatedDocuments||[];
355if(!a.includes(r)){let c=[...a,r];yield oo(i,{associatedDocuments:c})}}})}removeDocumentFromSession(t,r){return m(this,null,function*(){let i=so(this.firestore,`sessions/${t}`),s=yield sa(mc(ir(this.firestore,"sessions"),hu("__name__","==",t)));if(!s.empty){let c=(s.docs[0].data().associatedDocuments||[]).filter(l=>l!==r);yield oo(i,{associatedDocuments:c})}})}deleteSession(t){return m(this,null,function*(){if(!this.auth.currentUser)throw new Error("User not authenticated");yield co(this.functions,"deleteSession")({sessionId:t})})}updateSessionTitle(t,r){return m(this,null,function*(){let i=so(this.firestore,`sessions/${t}`);yield oo(i,{title:r})})}sendMcpMessage(t,r,i,s,o){return m(this,null,function*(){if(!this.auth.currentUser)throw new Error("User not authenticated");try{let a={message:t,enablePromptLogging:this.promptLogging.isLoggingActive()};if(i)a.toolResults=i;else{let d=this.mcpRegistry.getAvailableTools();a.tools=d,this.logger.debug("MCP Chat: Available tools for LLM",{count:d.length,names:d.map(f=>f.name)})}r&&r.llm&&(a.llmProvider=r.llm.provider,a.llmModel=r.llm.model,this.logger.debug("Chat service sending MCP request",{llmProvider:a.llmProvider,llmModel:a.llmModel,isFollowUp:!!i,toolCount:a.tools?.length||0}));let c=this.globalModelSelection.getModelParamsForRequest();a.temperature=c.temperature,c.seed!==-1&&(a.seed=c.seed),o&&o.length>0&&(a.conversationHistory=o);let{data:l}=yield this.mcpChat(a),u=s||`mcp_${Date.now()}_${Math.random().toString(36).substring(2,11)}`;if(this.promptLogging.isLoggingActive()&&l.promptData){let d=!!i,f=d?60:20,p=d?70:30;l.promptData.llmRequest&&this.logPromptPair(l.promptData.llmRequest,"request","mcp",u,{sequence:f}),l.promptData.llmResponse&&this.logPromptPair(l.promptData.llmResponse,"response","mcp",u,{sequence:p})}return{answer:yield this.mathRenderer.transformMarkdown(l.answer),toolCalls:l.toolCalls,messageId:u}}catch(a){throw this.logger.error("Error getting MCP chat response",a),a}})}logPromptEntry(t,r,i,s,o,a,c){this.promptLogging.addPromptLog(_({type:t,provider:r,model:i,content:s,timestamp:new Date,sessionContext:o,messageId:a},c?{metadata:c}:{}))}logPromptPair(t,r,i,s,o){this.logPromptEntry(r,t.provider,t.model,t.content,i,s,o)}formatSearchData(t){let{totalChunks:r,compatibleChunks:i,topChunks:s,contextLength:o,documentsUsed:a}=t,c=`\u{1F50D} **Document Search Results** 356 357`;return c+=`\u{1F4CA} **Search Summary:** 358`,c+=`\u2022 Total chunks found: ${r} 359`,c+=`\u2022 Compatible chunks: ${i} 360`,c+=`\u2022 Documents used: ${a} 361`,c+=`\u2022 Context length: ${o.toLocaleString()} characters 362 363`,c+=`\u{1F3AF} **Top Matches Used:** 364`,s.forEach((l,u)=>{let d=Math.round(l.score*100);c+=`${u+1}. Page ${l.page} (${d}% match) 365`,c+=` \u{1F4C4} "${l.preview}" 366 367`}),c}static{this.\u0275fac=function(r){return new(r||n)(Y(ro),Y(ao),Y(Di),Y(cb),Y(_a),Y(Zr),Y(Cs),Y(zu),Y(Kn))}}static{this.\u0275prov=Q({token:n,factory:n.\u0275fac,providedIn:"root"})}}return n})();var lb=(()=>{class n{constructor(t){this.auth=t,this.userSubject=new gt(null),this.user$=this.userSubject.asObservable(),bF(this.auth,r=>{this.userSubject.next(r)})}signInWithGoogle(){return m(this,null,function*(){try{let t=new IT;yield wF(this.auth,t)}catch(t){throw console.error("Error signing in with Google:",t),t}})}signOut(){return m(this,null,function*(){try{yield EF(this.auth)}catch(t){throw console.error("Error signing out:",t),t}})}getCurrentUser(){return this.auth.currentUser}isAuthenticated(){return!!this.auth.currentUser}static{this.\u0275fac=function(r){return new(r||n)(Y(Di))}}static{this.\u0275prov=Q({token:n,factory:n.\u0275fac,providedIn:"root"})}}return n})();var k3=(()=>{class n{constructor(){this.tasks=new Map,this.dependencies=new Map,this.taskResults=new Map}initializeGraph(t){this.tasks.clear(),this.dependencies.clear();for(let r of t)this.tasks.set(r.id,r),this.dependencies.set(r.id,new Set(r.dependencies))}createExecutionPlan(t){this.initializeGraph(t),this.taskResults.clear();let r=this.validateTaskPlan(t);if(!r.valid)throw new Error(`Invalid task plan: ${r.errors.join(", ")}`);if(this.hasCycleInDependencies(t))throw new Error("Circular dependencies detected in task plan");let i=this.getTopologicalOrder(t),s=this.createParallelGroups(t,i),o=0;for(let a of s){for(let c of a)c.executionOrder=o;o++}return{tasks:t,totalSteps:s.length,parallelGroups:s}}getTopologicalOrder(t){let r=new Map,i=new Map;for(let a of t)r.set(a.id,a.dependencies.length),i.set(a.id,[]);for(let a of t)for(let c of a.dependencies)i.has(c)||i.set(c,[]),i.get(c).push(a.id);let s=[],o=[];for(let[a,c]of r.entries())c===0&&s.push(a);for(;s.length>0;){let a=s.shift();o.push(a);let c=i.get(a)||[];for(let l of c){let u=(r.get(l)||0)-1;r.set(l,u),u===0&&s.push(l)}}return o}hasCycleInDependencies(t){let r=new Set,i=new Set,s=o=>
367{if(i.has(o))return!0;if(r.has(o))return!1;r.add(o),i.add(o);let a=this.tasks.get(o);if(a){for(let c of a.dependencies)if(s(c))return!0}return i.delete(o),!1};for(let o of t)if(!r.has(o.id)&&s(o.id))return!0;return!1}createParallelGroups(t,r){let i=[],s=new Set,o=new Map;for(let a of t)o.set(a.id,a);for(let a of r){let c=o.get(a);if(!c)continue;if(c.dependencies.every(u=>s.has(u))){let u=null;for(let d of i)if(d.every(p=>!this.hasDependency(c.id,p.id)&&!this.hasDependency(p.id,c.id))){u=d;break}u||(u=[],i.push(u)),u.push(c),s.add(a)}}return i}hasDependency(t,r){let i=new Set,s=o=>{if(i.has(o))return!1;i.add(o);let a=this.tasks.get(o);return a?a.dependencies.includes(r)?!0:a.dependencies.some(c=>s(c)):!1};return s(t)}getDependencyResults(t){let r=this.findTask(t);if(!r)return{};let i={};for(let s of r.dependencies)this.taskResults.has(s)&&(i[s]=this.taskResults.get(s));return i}setTaskResult(t,r){this.taskResults.set(t,r)}findTask(t){return this.tasks.get(t)||null}getExecutionVisualization(){let t=Array.from(this.tasks.values()).map((i,s)=>({id:i.id,task:i,x:s%5*120,y:Math.floor(s/5)*80,width:100,height:50})),r=[];for(let i of this.tasks.values())for(let s of i.dependencies)r.push({source:s,target:i.id,points:[]});return{nodes:t,edges:r}}validateTaskPlan(t){let r=[],i=new Set(t.map(o=>o.id));for(let o of t)for(let a of o.dependencies)i.has(a)||r.push(`Task ${o.id} depends on non-existent task ${a}`);let s=new Set;for(let o of t)s.has(o.id)&&r.push(`Duplicate task ID: ${o.id}`),s.add(o.id);for(let o of t)o.dependencies.includes(o.id)&&r.push(`Task ${o.id} has self-dependency`);return{valid:r.length===0,errors:r}}getCriticalPath(){if(this.tasks.size===0)return[];let t=new Set,r=[],i=(s,o)=>{if(t.has(s))return o;t.add(s);let a=[...o,s],c=this.tasks.get(s);if(!c||c.dependencies.length===0)return a;let l=a;for(let u of c.dependencies){let d=i(u,a);d.length>l.length&&(l=d)}return t.delete(s),l};for(let s of this.tasks.keys()){let o=i(s,[]);o.length>r.length&&(r=o)}return r}reset(){this.tasks.clear(),this.dependencies.clear(),this.taskResults.clear()}static{this.\u0275fac=function(r){return new(r||n)}}static{this.\u0275prov=Q({token:n,factory:n.\u0275fac,providedIn:"root"})}}return n})();var P3=(()=>{class n{constructor(){this.executionLog=[],this.taskLogs=new Map}startExecution(t){this.executionLog=[],this.taskLogs.clear(),this.executionStartTime=new Date,this.log({phase:"planning",type:"phase_start",data:{query:t,startTime:this.executionStartTime.toISOString()}})}logPhase(t,r){if(this.currentPhase&&this.phaseStartTime){let i=Date.now()-this.phaseStartTime.getTime();this.log({phase:this.currentPhase,type:"phase_complete",data:{phase:this.currentPhase,duration:i},duration:i})}this.currentPhase=t,this.phaseStartTime=new Date,this.log({phase:t,type:"phase_start",data:D(_({phase:t},r),{startTime:this.phaseStartTime.toISOString()})})}logTaskStart(t){let r={taskId:t.id,description:t.description,startTime:new Date,status:"executing"};this.taskLogs.set(t.id,r),this.log({phase:"execution",type:"task_start",taskId:t.id,data:{taskId:t.id,description:t.description,tools:t.tools,dependencies:t.dependencies}})}logTaskComplete(t,r){let i=this.taskLogs.get(t.id);i&&(i.endTime=new Date,i.duration=i.endTime.getTime()-i.startTime.getTime(),i.status="completed",i.result=r),this.log({phase:"execution",type:"task_complete",taskId:t.id,data:{taskId:t.id,result:r,duration:i?.duration},duration:i?.duration})}logTaskError(t,r){let i=this.taskLogs.get(t.id);i&&(i.endTime=new Date,i.duration=i.endTime.getTime()-i.startTime.getTime(),i.status="failed",i.error=r),this.log({phase:"execution",type:"task_error",taskId:t.id,data:{taskId:t.id,error:r?.message||r,duration:i?.duration},duration:i?.duration})}logError(t,r){this.log({phase:this.currentPhase||"execution",type:"error",data:{message:t,error:r?.message||r,stack:r?.stack}})}completeExecution(t){if(this.currentPhase&&this.phaseStartTime){let i=Date.now()-this.phaseStartTime.getTime();this.log({phase:this.currentPhase,type:"phase_complete",data:{phase:this.currentPhase,duration:i},duration:i})}let r=this.executionStartTime?Date.now()-this.executionStartTime.getTime():0;this.log({phase:"critic",type:"phase_complete",data:{totalDuration:r,totalTasks:this.taskLogs.size,completedTasks:Array.from(this.taskLogs.values()).filter(i=>i.status==="completed").length,failedTasks:Array.from(this.taskLogs.values()).filter(i=>i.status==="failed").length,success:t.success},duration:r})}log(t){let r=D(_({},t),{timestamp:new Date});this.executionLog.push(r),this.isProduction()||this.consoleLog(r)}consoleLog(t){let r=t.timestamp.toLocaleTimeString(),i=t.phase.toUpperCase(),s=t.type.toUpperCase();switch(t.type){case"phase_start":console.group(`\u{1F680} [${r}] ${i} PHASE STARTED`),console.log("Data:",t.data),console.groupEnd();break;case"phase_complete":console.group(`\u2705 [${r}] ${i} PHASE COMPLETED`),console.log("Duration:",t.duration?`${t.duration}ms`:"Unknown"),console.log("Data:",t.data),console.groupEnd();break;case"task_start":console.log(`\u26A1 [${r}] Task Started: ${t.taskId}`),console.log(" Description:",t.data.description),console.log(" Tools:",t.data.tools);break;case"task_complete":console.log(`\u2705 [${r}] Task Completed: ${t.taskId} (${t.duration}ms)`);break;case"task_error":console.error(`\u274C [${r}] Task Failed: ${t.taskId} (${t.duration}ms)`),console.error(" Error:",t.data.error);break;case"error":console.error(`\u{1F6A8} [${r}] ${i} ERROR:`,t.data.message),console.error(" Details:",t.data.error);break}}isProduction(){return typeof window<"u"&&window.location.hostname!=="localhost"}getExecutionLog(){return[...this.executionLog]}getTaskLogs(){return Array.from(this.taskLogs.values())}getExecutionSummary(){let t=this.executionStartTime?Date.now()-this.executionStartTime.getTime():0,r=Array.from(this.taskLogs.values()),i=this.calculatePhaseDurations();return{totalDuration:t,totalTasks:r.length,completedTasks:r.filter(s=>s.status==="completed").length,failedTasks:r.filter(s=>s.status==="failed").length,phases:i,averageTaskDuration:this.calculateAverageTaskDuration(r),longestTask:this.findLongestTask(r),executionLog:this.executionLog}}calculatePhaseDurations(){let t={},r=new Map;for(let i of this.executionLog)i.type==="phase_start"?r.set(i.phase,i.timestamp):i.type==="phase_complete"&&i.duration&&(t[i.phase]=i.duration);return t}calculateAverageTaskDuration(t){let r=t.filter(s=>s.duration);if(r.length===0)return 0;let i=r.reduce((s,o)=>s+(o.duration||0),0);return Math.round(i/r.length)}findLongestTask(t){return t.reduce((r,i)=>i.duration&&(!r||!r.duration||i.duration>r.duration)?i:r,null)}getFormattedPromptLogs(){return this.executionLog.map(t=>({timestamp:t.timestamp.toISOString(),phase:t.phase,type:t.type,taskId:t.taskId,data:t.data,duration:t.duration}))}clear(){this.executionLog=[],this.taskLogs.clear(),this.executionStartTime=void 0,this.currentPhase=void 0,this.phaseStartTime=void 0}static{this.\u0275fac=function(r){return new(r||n)}}static{this.\u0275prov=Q({token:n,factory:n.\u0275fac,providedIn:"root"})}}return n})();var M3=(()=>{class n{constructor(t,r,i,s,o,a){this.taskManager=t,this.logger=r,this.mcpRegistry=i,this.promptLogging=s,this.mathRenderer=o,this.appLogger=a,this.functionsUrl=Rn.production?"https://us-central1-aiplayground-6e5be.cloudfunctions.net":"http://127.0.0.1:5001/aiplayground-6e5be/us-central1",this.defaultMcpModel="meta-llama/llama-4-maverick:free"}logPhaseEvent(t){if(!this.promptLogging.isLoggingActive())return"";let r=_({},t.metadata||{});return t.sequence!==void 0&&(r.sequence=t.sequence),this.promptLogging.addPromptLog({type:t.type,provider:t.provider,model:t.model,content:t.content,timestamp:new Date,sessionContext:t.sessionContext,status:t.status,title:t.title,metadata:r})}processQuery(t,r,i){return m(this,null,function*(){return this.processQueryWithParams({query:t,sessionId:r,modelSelection:i})})}processQueryWithParams(t){return m(this,null,function*(){this.logger.startExecution(t.query),this.appLogger.debug("Multi-Agent Request Parameters",{temperature:t.temperature,seed:t.seed,enablePromptLogging:t.enablePromptLogging,modelSelection:t.modelSelection});try{let r=yield this.planningPhase(t.query,t.modelSelection,t.temperature,t.seed,t.enablePromptLogging);this.logger.logPhase("planning",{taskCount:r.tasks.length});let i=yield this.executionPhase(r,t.modelSelection,t.temperature,t.seed,t.enablePromptLogging);this.logger.logPhase("execution",{completedTasks:i.filter(l=>l.status==="completed").length});let s=yield this.verificationPhase(i,t.query,t.modelSelection,t.temperature,t.seed,t.enablePromptLogging);this.logger.logPhase("verification",s);let o;t.skipCriticPhase?(o=s.finalAnswer,this.logger.logPhase("critic",{skipped:!0,answerLength:o.length})):(o=yield this.criticPhase(s,t.query,t.modelSelection,t.temperature,t.seed,t.enablePromptLogging),this.logger.logPhase("critic",{answerLength:o.length}));let c={finalAnswer:yield this.mathRenderer.transformMarkdown(o),executionLog:this.logger.getExecutionLog(),tasks:i,success:!0};return this.logger.completeExecution(c),c}catch(r){return this.logger.logError("Multi-agent orchestration failed",r),{finalAnswer:"Sorry, I encountered an error while processing your request with multi-agent orchestration.",executionLog:this.logger.getExecutionLog(),tasks:[],success:!1}}})}planningPhase(t,r,i,s,o){return m(this,null,function*(){let a=this.mcpRegistry.getAvailableTools(),c={query:t,availableTools:a.map(w=>({name:w.name,description:w.description,serverId:w.serverId,inputSchema:w.inputSchema})),enablePromptLogging:o!==void 0?o:this.promptLogging.isLoggingActive(),modelSelection:r,temperature:i,seed:s},l=r?.llm?.model||this.defaultMcpModel,u={query:t.substring(0,500),toolCount:c.availableTools.length,tools:c.availableTools.map(w=>({name:w.name,serverId:w.serverId})),temperature:i,seed:s},d=this.logPhaseEvent({type:"request",title:"Planning Request",content:JSON.stringify(u,null,2),sessionContext:"multi-agent-planner",provider:"Multi-Agent Planner",model:l,status:"pending",metadata:{phase:"planning"},sequence:10});this.promptLogging.isLoggingActive()&&this.appLogger.debug("Multi-Agent Planning Phase",{query:t.substring(0,200)+"...",toolCount:a.length,tools:a.map(w=>w.name)});let f=yield fetch(`${this.functionsUrl}/multiAgentPlanner`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)});if(!f.ok)throw this.promptLogging.updatePromptLog(d,{status:"error",content:JSON.stringify(D(_({},u),{error:`${f.status} ${f.statusText}`}),null,2)}),new Error(`Planner failed: ${f.statusText}`);let p=yield f.json();if(this.promptLogging.updatePromptLog(d,{status:"completed"}),p.promptData&&(o!==void 0?o:this.promptLogging.isLoggingActive())){let w=`multiagent_planner_${Date.now()}_${Math.random().toString(36).substring(2,11)}`;p.promptData.llmRequest&&this.promptLogging.addPromptLog({type:"request",provider:p.promptData.llmRequest.provider,model:p.promptData.llmRequest.model,content:p.promptData.llmRequest.content,timestamp:new Date,sessionContext:"multi-agent-planner",messageId:w,status:"completed",title:"Planning LLM Request",metadata:{phase:"planning",sequence:20}}),p.promptData.llmResponse&&this.promptLogging.addPromptLog({type:"response",provider:p.promptData.llmResponse.provider,model:p.promptData.llmResponse.model,content:p.promptData.llmResponse.content,timestamp:new Date,sessionContext:"multi-agent-planner",messageId:w,status:"completed",title:"Planning LLM Response",metadata:{phase:"planning",sequence:30}})}this.logPhaseEvent({type:"response",title:"Planning Response",content:JSON.stringify({taskCount:p.tasks?.length||0,totalSteps:p.totalSteps,reasoning:p.reasoning,tasks:p.tasks},null,2),sessionContext:"multi-agent-planner",provider:"Multi-Agent Planner",model:l,status:"completed",metadata:{phase:"planning",taskCount:p.tasks?.length||0},sequence:40});let y=p.tasks.map((w,E)=>({id:w.id||`task_${E}`,description:w.description,dependencies:w.dependencies||[],tools:w.tools||[],status:"pending",systemRole:"executor",executionOrder:0}));return this.appLogger.debug("Planner generated tasks",y.map(w=>
367({id:w.id,description:w.description.substring(0,20)+"...",dependencies:w.dependencies,tools:w.tools}))),this.taskManager.createExecutionPlan(y)})}executionPhase(t,r,i,s,o){return m(this,null,function*(){let a=[...t.tasks],c=this.mcpRegistry.getAvailableTools();this.appLogger.debug("Cached tools for execution phase",{totalTools:c.length,toolNames:c.map(l=>l.name)});for(let l of t.parallelGroups){if(l.length===1){let d=l[0];try{let f=yield this.executeTask(d,r,i,s,o,c);d.status="completed",d.result=f}catch(f){d.status="failed",d.error=f.message||"Unknown error"}}else try{let d=yield this.executeMultipleTasks(l,r,i,s,o,c);l.forEach(f=>{d.taskResults[f.id]?(f.status="completed",f.result=d.taskResults[f.id],this.taskManager.setTaskResult(f.id,f.result)):(f.status="failed",f.error="No result returned for task")})}catch(d){l.forEach(f=>{f.status="failed",f.error=d.message||"Multi-task execution error"})}let u=l.filter(d=>d.status==="failed");if(u.length>0){this.logger.logError("Critical tasks failed",u),a.filter(f=>f.status==="pending").forEach(f=>{f.status="failed",f.error="Dependency task failed"});break}}return a})}executeTask(t,r,i,s,o,a){return m(this,null,function*(){this.logger.logTaskStart(t),t.status="executing";let c=r?.llm?.model||this.defaultMcpModel,l="",u={};try{let d=this.taskManager.getDependencyResults(t.id),p=(a?a.filter(E=>t.tools.includes(E.name)):[]).map(E=>({type:"function",function:{name:E.name,description:E.description,parameters:E.inputSchema}}));this.appLogger.debug(`Tools for task ${t.id}`,{requested:t.tools,available:p.map(E=>E.function.name),filtered:p.length});let y={task:{id:t.id,description:t.description,tools:t.tools,dependencyResults:d},enablePromptLogging:o!==void 0?o:this.promptLogging.isLoggingActive(),modelSelection:r,temperature:i,seed:s,preFilteredTools:p};u={taskId:t.id,description:t.description,tools:t.tools,dependencyResults:d,toolNames:p.map(E=>E.function.name),temperature:i,seed:s},l=this.logPhaseEvent({type:"request",title:`Task ${t.id} Execution Request`,content:JSON.stringify(u,null,2),sessionContext:`multi-agent-executor-${t.id}`,provider:"Task Executor",model:c,status:"pending",metadata:{phase:"execution",taskId:t.id},sequence:10}),this.promptLogging.isLoggingActive()&&this.appLogger.debug(`Multi-Agent Executing Task: ${t.id}`,{description:t.description,tools:t.tools,dependencyCount:Object.keys(d).length});let v=yield fetch(`${this.functionsUrl}/multiAgentExecutor`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(y)});if(!v.ok)throw l&&this.promptLogging.updatePromptLog(l,{status:"error",content:JSON.stringify(D(_({},u),{error:`${v.status} ${v.statusText}`}),null,2)}),new Error(`Executor failed: ${v.statusText}`);let w=yield v.json();if(l&&this.promptLogging.updatePromptLog(l,{status:"completed"}),w.promptData&&(o!==void 0?o:this.promptLogging.isLoggingActive())){let E=`multiagent_executor_${t.id}_${Date.now()}_${Math.random().toString(36).substring(2,11)}`;if(w.promptData.llmRequest&&this.promptLogging.addPromptLog({type:"request",provider:w.promptData.llmRequest.provider,model:w.promptData.llmRequest.model,content:w.promptData.llmRequest.content,timestamp:new Date,sessionContext:`multi-agent-executor-${t.id}`,messageId:E,status:"completed",title:`Task ${t.id} LLM Request`,metadata:{phase:"execution",taskId:t.id,sequence:20}}),w.promptData.llmResponse&&this.promptLogging.addPromptLog({type:"response",provider:w.promptData.llmResponse.provider,model:w.promptData.llmResponse.model,content:w.promptData.llmResponse.content,timestamp:new Date,sessionContext:`multi-agent-executor-${t.id}`,messageId:E,status:"completed",title:`Task ${t.id} LLM Response`,metadata:{phase:"execution",taskId:t.id,sequence:30}}),w.mcpPromptData&&Array.isArray(w.mcpPromptData)){this.appLogger.debug("Multi-Agent: Processing MCP prompt data",{taskId:t.id,mcpDataCount:w.mcpPromptData.length,messageId:E});for(let A of w.mcpPromptData)A.mcpRequest&&(this.appLogger.debug("Multi-Agent: Adding MCP Query log"),this.promptLogging.addPromptLog({type:"request",provider:"MCP Server",model:A.mcpRequest.server,content:`Tool: ${A.mcpRequest.toolName} 368Arguments: ${JSON.stringify(A.mcpRequest.arguments,null,2)}`,timestamp:new Date,sessionContext:"mcp-tool-call",messageId:E,status:"completed",title:`Tool Call Request \xB7 ${A.mcpRequest.toolName}`,metadata:{phase:"execution",taskId:t.id,sequence:25}})),A.mcpResponse&&(this.appLogger.debug("Multi-Agent: Adding MCP Response log"),this.promptLogging.addPromptLog({type:"response",provider:"MCP Server",model:A.mcpResponse.server,content:JSON.stringify(A.mcpResponse.result,null,2),timestamp:new Date,sessionContext:"mcp-tool-call",messageId:E,status:"completed",title:`Tool Call Response \xB7 ${A.mcpRequest?.toolName||"MCP Tool"}`,metadata:{phase:"execution",taskId:t.id,sequence:35}}))}else this.appLogger.debug("Multi-Agent: No MCP prompt data found for task",t.id)}else this.appLogger.debug("Multi-Agent: No prompt data found for task",t.id);return this.logger.logTaskComplete(t,w),this.logPhaseEvent({type:"response",title:`Task ${t.id} Execution Response`,content:JSON.stringify(w,null,2),sessionContext:`multi-agent-executor-${t.id}`,provider:"Task Executor",model:c,status:"completed",metadata:{phase:"execution",taskId:t.id},sequence:40}),this.taskManager.setTaskResult(t.id,w),w}catch(d){this.logger.logTaskError(t,d);let f=d instanceof Error?d.message:"Unknown error";throw l&&this.promptLogging.updatePromptLog(l,{status:"error",content:JSON.stringify(D(_({},u),{error:f}),null,2)}),d}})}executeMultipleTasks(t,r,i,s,o,a){return m(this,null,function*(){this.appLogger.debug(`Multi-task executing ${t.length} tasks`,t.map(A=>A.id));let c=r?.llm?.model||this.defaultMcpModel,l=t.map(A=>A.id),u="",d={},f=t.map(A=>({id:A.id,description:A.description,tools:A.tools,dependencyResults:this.taskManager.getDependencyResults(A.id)}
368)),p=Array.from(new Set(t.flatMap(A=>A.tools||[]))),v=(a?a.filter(A=>p.includes(A.name)):[]).map(A=>({type:"function",function:{name:A.name,description:A.description,parameters:A.inputSchema}}));this.appLogger.debug("Multi-task tools prepared",{allRequiredTools:p,availableToolsCount:v.length,toolNames:v.map(A=>A.function.name)});let w={tasks:f,enablePromptLogging:o!==void 0?o:this.promptLogging.isLoggingActive(),modelSelection:r,temperature:i,seed:s,preFilteredTools:v},E=l.slice(0,3).join(", ")+(l.length>3?", \u2026":"");d={taskIds:l,tools:p,temperature:i,seed:s},u=this.logPhaseEvent({type:"request",title:`Tasks ${E} Execution Request`,content:JSON.stringify(d,null,2),sessionContext:"multi-agent-multi-task-executor",provider:"Multi-task Executor",model:c,status:"pending",metadata:{phase:"execution",taskIds:l},sequence:10}),this.promptLogging.isLoggingActive()&&this.appLogger.debug("Multi-Agent Multi-Task Execution",{taskCount:t.length,taskIds:t.map(A=>A.id),toolCount:v.length});try{let A=yield fetch(`${this.functionsUrl}/multiAgentMultiTaskExecutor`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(w)});if(!A.ok)throw u&&this.promptLogging.updatePromptLog(u,{status:"error",content:JSON.stringify(D(_({},d),{error:`${A.status} ${A.statusText}`}),null,2)}),new Error(`Multi-task executor failed: ${A.statusText}`);let x=yield A.json();if(u&&this.promptLogging.updatePromptLog(u,{status:"completed"}),this.logger.logPhase("execution",{taskCount:t.length,success:x.success,toolCallsCount:x.toolCalls?.length||0}),x.promptData&&(o!==void 0?o:this.promptLogging.isLoggingActive())){let M=`multiagent_multitask_${t.map(O=>O.id).join("_")}_${Date.now()}_${Math.random().toString(36).substring(2,11)}`;if(x.promptData.llmRequest&&this.promptLogging.addPromptLog({type:"request",provider:x.promptData.llmRequest.provider,model:x.promptData.llmRequest.model,content:x.promptData.llmRequest.content,timestamp:new Date,sessionContext:"multi-agent-multi-task-executor",messageId:M,status:"completed",title:"Multi-task LLM Request",metadata:{phase:"execution",taskIds:l,sequence:20}}),x.promptData.llmResponse&&this.promptLogging.addPromptLog({type:"response",provider:x.promptData.llmResponse.provider,model:x.promptData.llmResponse.model,content:x.promptData.llmResponse.content,timestamp:new Date,sessionContext:"multi-agent-multi-task-executor",messageId:M,status:"completed",title:"Multi-task LLM Response",metadata:{phase:"execution",taskIds:l,sequence:30}}),x.mcpPromptData&&Array.isArray(x.mcpPromptData)){this.appLogger.debug("Multi-Agent Multi-Task: Processing MCP prompt data",{taskCount:t.length,mcpDataCount:x.mcpPromptData.length,messageId:M});for(let O of x.mcpPromptData)O.mcpRequest&&(this.appLogger.debug("Multi-Agent Multi-Task: Adding MCP Query log"),this.promptLogging.addPromptLog({type:"request",provider:"MCP Server",model:O.mcpRequest.server,content:`Tool: ${O.mcpRequest.toolName} 369Arguments: ${JSON.stringify(O.mcpRequest.arguments,null,2)}`,timestamp:new Date,sessionContext:"mcp-tool-call",messageId:M,status:"completed",title:`Tool Call Request \xB7 ${O.mcpRequest.toolName}`,metadata:{phase:"execution",taskIds:l,sequence:25}})),O.mcpResponse&&(this.appLogger.debug("Multi-Agent Multi-Task: Adding MCP Response log"),this.promptLogging.addPromptLog({type:"response",provider:"MCP Server",model:O.mcpResponse.server,content:JSON.stringify(O.mcpResponse.result,null,2),timestamp:new Date,sessionContext:"mcp-tool-call",messageId:M,status:"completed",title:`Tool Call Response \xB7 ${O.mcpRequest?.toolName||"MCP Tool"}`,metadata:{phase:"execution",taskIds:l,sequence:35}}))}else this.appLogger.debug("Multi-Agent Multi-Task: No MCP prompt data found")}return this.logPhaseEvent({type:"response",title:`Tasks ${E} Execution Response`,content:JSON.stringify(x,null,2),sessionContext:"multi-agent-multi-task-executor",provider:"Multi-task Executor",model:c,status:"completed",metadata:{phase:"execution",taskIds:l},sequence:40}),x}catch(A){let x=A instanceof Error?A.message:"Unknown error";throw u&&this.promptLogging.updatePromptLog(u,{status:"error",content:JSON.stringify(D(_({},d),{error:x}),null,2)}),A}})}verificationPhase(t,r,i,s,o,a){return m(this,null,function*(){let c=t.filter(y=>y.status==="completed"),l={originalQuery:r,tasks:c.map(y=>({id:y.id,description:y.description,result:y.result})),enablePromptLogging:a!==void 0?a:this.promptLogging.isLoggingActive(),modelSelection:i,temperature:s,seed:o},u=i?.llm?.model||this.defaultMcpModel,d={originalQuery:r.substring(0,500),taskCount:c.length,temperature:s,seed:o},f=this.logPhaseEvent({type:"request",title:"Verification Request",content:JSON.stringify(d,null,2),sessionContext:"multi-agent-verifier",provider:"Result Verifier",model:u,status:"pending",metadata:{phase:"verification"},sequence:10});this.promptLogging.isLoggingActive()&&this.appLogger.debug("Multi-Agent Verification Phase",{originalQuery:r.substring(0,200)+"...",completedTaskCount:c.length,taskIds:c.map(y=>y.id)});let p;try{let y=yield fetch(`${this.functionsUrl}/multiAgentVerifier`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)});if(!y.ok)throw f&&this.promptLogging.updatePromptLog(f,{status:"error",content:JSON.stringify(D(_({},d),{error:`${y.status} ${y.statusText}`}),null,2)}),new Error(`Verifier failed: ${y.statusText}`);p=yield y.json(),f&&this.promptLogging.updatePromptLog(f,{status:"completed"})}catch(y){let v=y instanceof Error?y.message:"Unknown error";throw f&&this.promptLogging.updatePromptLog(f,{status:"error",content:JSON.stringify(D(_({},d),{error:v}),null,2)}),y}if(p.promptData&&(a!==void 0?a:this.promptLogging.isLoggingActive())){let y=`multiagent_verifier_${Date.now()}_${Math.random().toString(36).substring(2,11)}`;p.promptData.llmRequest&&this.promptLogging.addPromptLog({type:"request",provider:p.promptData.llmRequest.provider,model:p.promptData.llmRequest.model,content:p.promptData.llmRequest.content,timestamp:new Date,sessionContext:"multi-agent-verifier",messageId:y,status:"completed",title:"Verification LLM Request",metadata:{phase:"verification",sequence:20}}),p.promptData.llmResponse&&this.promptLogging.addPromptLog({type:"response",provider:p.promptData.llmResponse.provider,model:p.promptData.llmResponse.model,content:p.promptData.llmResponse.content,timestamp:new Date,sessionContext:"multi-agent-verifier",messageId:y,status:"completed",title:"Verification LLM Response",metadata:{phase:"verification",sequence:30}})}return this.logPhaseEvent({type:"response",title:"Verification Response",content:JSON.stringify(p,null,2),sessionContext:"multi-agent-verifier",provider:"Result Verifier",model:u,status:"completed",metadata:{phase:"verification"},sequence:40}),p})}criticPhase(t,r,i,s,o,a){return m(this,null,function*(){let c={originalQuery:r,verification:t,taskResults:t.taskResults||[],enablePromptLogging:a!==void 0?a:this.promptLogging.isLoggingActive(),modelSelection:i,temperature:s,seed:o},l=i?.llm?.model||this.defaultMcpModel,u={originalQuery:r.substring(0,500),confidence:t.confidence,overallCorrect:t.overallCorrect,temperature:s,seed:o},d=this.logPhaseEvent({type:"request",title:"Critic Request",content:JSON.stringify(u,null,2),sessionContext:"multi-agent-critic",provider:"Response Critic",model:l,status:"pending",metadata:{phase:"critic"},sequence:10});this.promptLogging.isLoggingActive()&&this.appLogger.debug("Multi-Agent Critic Phase",{originalQuery:r.substring(0,200)+"...",verificationConfidence:t.confidence,overallCorrect:t.overallCorrect});let f;try{let p=yield fetch(`${this.functionsUrl}/multiAgentCritic`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)});if(!p.ok)throw d&&this.promptLogging.updatePromptLog(d,{status:"error",content:JSON.stringify(D(_({},u),{error:`${p.status} ${p.statusText}`}),null,2)}),new Error(`Critic failed: ${p.statusText}`);f=yield p.json(),d&&this.promptLogging.updatePromptLog(d,{status:"completed"})}catch(p){let y=p instanceof Error?p.message:"Unknown error";throw d&&this.promptLogging.updatePromptLog(d,{status:"error",content:JSON.stringify(D(_({},u),{error:y}),null,2)}),p}if(f.promptData&&(a!==void 0?a:this.promptLogging.isLoggingActive())){let p=`multiagent_critic_${Date.now()}_${Math.random().toString(36).substring(2,11)}`;f.promptData.llmRequest&&this.promptLogging.addPromptLog({type:"request",provider:f.promptData.llmRequest.provider,model:f.promptData.llmRequest.model,content:f.promptData.llmRequest.content,timestamp:new Date,sessionContext:"multi-agent-critic",messageId:p,status:"completed",title:"Critic LLM Request",metadata:{phase:"critic",sequence:20}}),f.promptData.llmResponse&&this.promptLogging.addPromptLog({type:"response",provider:f.promptData.llmResponse.provider,model:f.promptData.llmResponse.model,content:f.promptData.llmResponse.content,timestamp:new Date,sessionContext:"multi-agent-critic",messageId:p,status:"completed",title:"Critic LLM Response",metadata:{phase:"critic",sequence:30}})}return this.logPhaseEvent({type:"response",title:"Critic Response",content:JSON.stringify(f,null,2),sessionContext:"multi-agent-critic",provider:"Response Critic",model:l,status:"completed",metadata:{phase:"critic"},sequence:40}),f.finalAnswer||f.answer||"No answer generated"})}isAvailable(){return this.mcpRegistry.getAvailableTools().length>0}static{this.\u0275fac=function(r){return new(r||n)(Y(k3),Y(P3),Y(_a),Y(Zr),Y(zu),Y(Kn))}}static{this.\u0275prov=Q({token:n,factory:n.\u0275fac,providedIn:"root"})}}return n})();var N3=(()=>{class n{constructor(){}extractErrorMessage(t){return t&&typeof t=="object"&&"message"in t?t.message:"An unexpected error occurred. Please try again."}handleFirebaseError(t,r){let i=this.extractErrorMessage(t);return console.error(`Error in ${r.operation}:`,{error:t,context:r.details,userId:r.userId,timestamp:new Date().toISOString()}),i}createChatErrorMessage(t,r){let i=this.extractErrorMessage(t),s={RAG:"Sorry, there was an error processing your message. Please try again.",General:"Sorry, there was an error processing your message. Please try again.",Vision:"Sorry, there was an error analyzing your image. Please try again.",MCP:"Sorry, I encountered an error processing your message. Please try again."};return i&&!i.includes("internal")&&!i.includes("undefined")?i:s[r]}handleDocumentError(t,r){let i={upload:"Error processing file. Please try again.",delete:"Failed to delete document. Please try again.",process:"Error processing document. Please try again."};return console.error(`Document ${r} error:`,t),this.extractErrorMessage(t)||i[r]}handleSessionError(t,r){let i={create:"Error creating session. Please try again.",delete:"Failed to delete session. Please try again.",load:"Error loading session data. Please try again."};return console.error(`Session ${r} error:`,t),this.extractErrorMessage(t)||i[r]}static{this.\u0275fac=function(r){return new(r||n)}}static{this.\u0275prov=Q({token:n,factory:n.\u0275fac,providedIn:"root"})}}return n})();var O3=(()=>{class n{constructor(){}formatFileSize(t){if(t===0)return"0 Bytes";let r=1024,i=["Bytes","KB","MB","GB"],s=Math.floor(Math.log(t)/Math.log(r));return parseFloat((t/Math.pow(r,s)).toFixed(2))+" "+i[s]}abbreviateText(t,r){let i=t.trim().replace(/\s+/g," ");return i.length<=r?i:i.substring(0,r).trim()+"..."}validateFileType(t,r){return t.type===r||t.type.startsWith(r)}delay(t){return new Promise(r=>setTimeout(r,t))}sanitizeForLogging(t){if(!t||typeof t!="object")return t;let r=["password","token","key","secret","auth","api_key","apikey"],i=_({},t);for(let s of Object.keys(i)){let o=s.toLowerCase();r.some(a=>o.includes(a))&&(typeof i[s]=="string"&&i[s].length>10?i[s]=i[s].substring(0,10)+"...":i[s]="[REDACTED]")}return i}static{this.\u0275fac=function(r){return new(r||n)}}static{this.\u0275prov=Q({token:n,factory:n.\u0275fac,providedIn:"root"})}}return n})();var Zce=["ragMessagesContainer"],Jce=["generalMessagesContainer"],ele=["visionMessagesContainer"],tle=n=>({"shadow-sm bg-dark-primary-subtle !border-primary":n}),nle=()=>[],rle=()=>({hour:"2-digit",minute:"2-digit"}),ile=(n,e,t,r,i)=>({"shadow-sm bg-dark-primary-subtle !border-primary":n,"opacity-70":e,"!border-error bg-surface-hover":t,"border-l-[3px] !border-l-success":r,"border-l-[3px] !border-l-warning bg-warning-subtle":i}),sle=(n,e,t)=>({"bg-[#d4edda] text-[#155724]":n,"bg-[#fff3cd] text-[#856404]":e,"bg-[#f8d7da] text-[#721c24]":t}),ole=(n,e)=>({"text-green-600":n,"text-red-600":e}),ale=(n,e,t)=>({"shadow-lg !border-primary bg-primary-subtle scale-[1.02]":n,"shadow-md !border-success bg-surface-elevated":e,"min-h-0 p-4":t});function cle(n,e){n&1&&(F(0,"p",38),H(1,"PDF, Word, PowerPoint, Excel, HTML, Images"),L())}function lle(n,e){n&1&&(F(0,"p",39),H(1,"Create a session first to upload documents"),L())}function ule(n,e){if(n&1){let t=St();F(0,"div",31)(1,"div",32),H(2,"\u{1F4E4}"),L(),F(3,"h4",33),H(4,"Upload Document"),L(),me(5,cle,2,0,"p",34)(6,lle,2,0,"p",35),F(7,"input",36,0),_e("change",function(i){ge(t);let s=G(2);return ye(s.onFileSelect(i))}),L(),F(9,"button",37),_e("click",function(){ge(t);let i=Al(8),s=G(2);return ye(s.currentSession?i.click():null)}),H(10," Choose File "),L()()}if(n&2){let t=G(2);j(5),B("ngIf",t.currentSession),j(),B("ngIf",!t.currentSession),j(),B("accept",t.acceptedFileTypes)("disabled",!t.currentSession),j(2),B("disabled",!t.currentSession)}}function dle(n,e){if(n&1&&(F(0,"div",40),yt(1,"div",41),F(2,"p",42),H(3),L()()),n&2){let t=G(2);j(3),Zt(t.uploadProgress)}}function hle(n,e){n&1&&(F(0,"span"),H(1,"\u{1F5D1}\uFE0F"),L())}function fle(n,e){n&1&&(F(0,"span"),H(1,"\u23F3"),L())}function ple(n,e){if(n&1){let t=St();F(0,"div",43),_e("click",function(){let i=ge(t).$implicit,s=G(2);return ye(s.selectSession(i))}),F(1,"div",44)(2,"div",45),H(3),L(),F(4,"div",46),H(5),L()(),F(6,"div",47)(7,"button",48),_e("click",function(i){let s=ge(t).$implicit;return G(2).deleteSession(s),ye(i.stopPropagation())}),me(8,hle,2,0,"span",49)(9,fle,2,0,"span",49),L()()()}if(n&2){let t=e.$implicit,r=G(2);kr("active-session",(r.currentSession==null?null:r.currentSession.id)===t.id),B("ngClass",MN(9,tle,(r.currentSession==null?null:r.currentSession.id)===t.id)),j(3),Zt(t.title),j(2),jm("",t.createdAt.toLocaleDateString()," ",t.createdAt.toLocaleTimeString(lE(11,nle),lE(12,rle)),""),j(2),B("disabled",r.deletingSession===t.id),j(),B("ngIf",r.deletingSession!==t.id),j(),B("ngIf",r.deletingSession===t.id)}}function mle(n,e){n&1&&(F(0,"span"),H(1,"\u{1F4C4}"),L())}function gle(n,e){n&1&&(F(0,"span",60),H(1,"\u23F3"),L())}function yle(n,e){n&1&&(F(0,"span",60),H(1,"\u{1F504}"),L())}function _le(n,e){n&1&&(F(0,"span"),H(1,"\u274C"),L())}function vle(n,e){n&1&&(F(0,"span",64),H(1,"\u26A0\uFE0F"),L())}function ble(n,e){n&1&&(F(0,"span",65),H(1,"\u2705"),L())}function wle(n,e){if(n&1&&(F(0,"div",61)(1,"small"),H(2),L(),me(3,vle,2,0,"span",62)(4,ble,2,0,"span",63),L()),n&2){let t=G().$implicit,r=G(3);j(2),jm("",t.embedModel.provider,"/",t.embedModel.model,""),j(),B("ngIf",!r.isDocumentCompatible(t)),j(),B("ngIf",r.isDocumentCompatible(t))}}function Ele(n,e){n&1&&(F(0,"span"),H(1,"\u{1F5D1}\uFE0F"),L())}function Ile(n,e){n&1&&(F(0,"span"),H(1,"\u23F3"),L())}function Tle(n,e){if(n&1){let t=St();F(0,"div",52),_e("click",function(){let i=ge(t).$implicit,s=G(3);return ye(s.selectDocument(i))}),F(1,"div",53),me(2,mle,2,0,"span",49)(3,gle,2,0,"span",54)(4,yle,2,0,"span",54)(5,_le,2,0,"span",49),L(),F(6,"div",44)(7,"div",55),H(8),L(),F(9,"div",56),H(10),L(),me(11,wle,5,4,"div",57),L(),F(12,"div",58)(13,"button",59),_e("click",function(i){let s=ge(t).$implicit;return G(3).deleteDocument(s),ye(i.stopPropagation())}),me(14,Ele,2,0,"span",49)(15,Ile,2,0,"span",49),L()()()}if(n&2){let t=e.$implicit,r=G(3);B("ngClass",ON(12,ile,(r.selectedDocument==null?null:r.selectedDocument.id)===t.id,t.status==="processing",t.status==="error",r.isDocumentCompatible(t),!r.isDocumentCompatible(t))),j(2),B("ngIf",t.status==="completed"),j(),B("ngIf",t.status==="processing"),j(),B("ngIf",t.status==="chunks_ready"),j(),B("ngIf",t.status==="error"),j(3),Zt(t.filename),j(),B("ngClass",uE(18,sle,t.status==="completed",t.status==="processing",t.status==="error")),j(),Zt(t.status),j(),B("ngIf",t.embedModel),j(2),B("disabled",r.deleting===t.id),j(),B("ngIf",r.deleting!==t.id),j(),B("ngIf",r.deleting===t.id)}}function Ale(n,e){if(n&1&&(F(0,"div",50),me(1,Tle,
36916,22,"div",51),L()),n&2){let t=G(2);j(),B("ngForOf",t.getSessionDocuments())}}function Cle(n,e){n&1&&(F(0,"div",66)(1,"p"),H(2,"No documents in this session yet"),L(),F(3,"p")(4,"small"),H(5,"Upload a document above to get started"),L()()())}function Sle(n,e){n&1&&(F(0,"div",66)(1,"p"),H(2,"No session selected"),L(),F(3,"p")(4,"small"),H(5,"Create or select a session first"),L()()())}function xle(n,e){n&1&&(F(0,"span"),H(1," (\u26A0\uFE0F incompatible)"),L())}function Dle(n,e){if(n&1&&(F(0,"option",72),H(1),me(2,xle,2,0,"span",49),L()),n&2){let t=e.$implicit,r=G(3);B("ngValue",t)("disabled",t.status!=="completed"),j(),Ut(" ",t.filename," "),j(),B("ngIf",!r.isDocumentCompatible(t))}}function Rle(n,e){if(n&1){let t=St();F(0,"div",67)(1,"h4",68),H(2,"Filter by Document"),L(),F(3,"select",69),fn("ngModelChange",function(i){ge(t);let s=G(2);return wn(s.selectedDocument,i)||(s.selectedDocument=i),ye(i)}),F(4,"option",70),H(5,"All session documents"),L(),me(6,Dle,3,4,"option",71),L()()}if(n&2){let t=G(2);j(3),hn("ngModel",t.selectedDocument),j(),B("ngValue",null),j(2),B("ngForOf",t.getSessionDocuments())}}function kle(n,e){n&1&&(F(0,"span",85),H(1,"\u26A0\uFE0F"),L())}function Ple(n,e){if(n&1){let t=St();F(0,"span",82),H(1),me(2,kle,2,0,"span",83),F(3,"button",84),_e("click",function(){let i=ge(t).$implicit,s=G(4);return ye(s.removeDocumentFromCurrentSession(i))}),H(4,"\xD7"),L()()}if(n&2){let t=e.$implicit,r=G(4);B("ngClass",r.isDocumentByIdCompatible(t)?"bg-primary-subtle border-primary text-primary":"bg-warning-subtle border-warning text-warning"),j(),Ut(" \u{1F4C4} ",r.getDocumentName(t)," "),j(),B("ngIf",!r.isDocumentByIdCompatible(t))}}function Mle(n,e){if(n&1&&(F(0,"div")(1,"h4",79),H(2,"Active in this Session:"),L(),F(3,"div",80),me(4,Ple,5,3,"span",81),L()()),n&2){let t=G(3);j(4),B("ngForOf",t.currentSession.associatedDocuments)}}function Nle(n,e){if(n&1){let t=St();F(0,"div",88),_e("click",function(){let i=ge(t).$implicit,s=G(4);return ye(s.addDocumentToCurrentSession(i.id))}),F(1,"span",89),H(2),L(),F(3,"span",90),H(4,"+"),L()()}if(n&2){let t=e.$implicit;j(2),Zt(t.filename)}}function Ole(n,e){if(n&1&&(F(0,"div",86),me(1,Nle,5,1,"div",87),L()),n&2){let t=G(3);j(),B("ngForOf",t.getAvailableDocuments())}}function Lle(n,e){if(n&1&&(F(0,"div")(1,"span",91),H(2),L()()),n&2){let t=G(3);j(2),Ut("\u{1F4C4} ",t.selectedDocument.filename,"")}}function Fle(n,e){if(n&1){let t=St();F(0,"div",73)(1,"h2",74),H(2),L(),F(3,"div",75),me(4,Mle,5,1,"div",49),F(5,"div",76)(6,"button",77),_e("click",function(){ge(t);let i=G(2);return ye(i.showAddDocuments=!i.showAddDocuments)}),H(7),L(),me(8,Ole,2,1,"div",78),L(),me(9,Lle,3,1,"div",49),L()()}if(n&2){let t=G(2);j(2),Zt(t.currentSession.title),j(2),B("ngIf",t.currentSession.associatedDocuments&&t.currentSession.associatedDocuments.length>0),j(3),Ut(" ",t.showAddDocuments?"Hide":"Add"," Documents to Session "),j(),B("ngIf",t.showAddDocuments),j(),B("ngIf",t.selectedDocument)}}function Vle(n,e){if(n&1&&(F(0,"span",111),H(1),L()),n&2){let t=e.$implicit,r=G(2).$implicit;B("ngClass",r.role==="user"?"bg-white/20 border-white/10":"bg-gray-100 text-dark-text-subtle border-border-subtle"),j(),Ut(" ",t.label," ")}}function jle(n,e){if(n&1&&(F(0,"div",107)(1,"h5",108),H(2,"Sources:"),L(),F(3,"div",109),me(4,Vle,2,2,"span",110),L()()),n&2){let t=G().$implicit;B("ngClass",t.role==="user"?"border-t border-white/15":"border-t border-border"),j(4),B("ngForOf",t.sources)}}function $le(n,e){if(n&1&&yt(0,"app-prompt-message",113),n&2){let t=e.$implicit;B("entry",t)}}function Ule(n,e){if(n&1&&(Ba(0),me(1,$le,1,1,"app-prompt-message",112),Ha()),n&2){let t=G().$implicit,r=G(3);j(),B("ngForOf",r.getPromptLogsForMessage(t.id))("ngForTrackBy",r.trackByPromptId)}}function Ble(n,e){if(n&1&&(Ba(0),F(1,"div",101)(2,"div",102)(3,"div",103),yt(4,"markdown",104),L(),me(5,jle,5,2,"div",105),L(),F(6,"div",106),H(7),L()(),me(8,Ule,2,2,"ng-container",49),Ha()),n&2){let t=e.$implicit;j(),B("ngClass",t.role==="user"?"items-end":"items-start"),j(),B("ngClass",t.role==="user"?"text-white bg-gradient-to-br from-primary to-primary-light rounded-xl rounded-br-md":"bg-surface border border-border text-white rounded-xl rounded-bl-md"),j(2),B("data",t.content),j(),B("ngIf",t.sources&&t.sources.length>0),j(2),Ut(" ",t.createdAt.toLocaleTimeString()," "),j(),B("ngIf",t.role==="assistant"&&t.id)}}function Hle(n,e){n&1&&(F(0,"div",114)(1,"div",115)(2,"div",116),yt(3,"span",117)(4,"span",117)(5,"span",117),L()()())}function qle(n,e){n&1&&(F(0,"span"),H(1,"\u27A4"),L())}function zle(n,e){n&1&&(F(0,"span",60),H(1,"\u23F3"),L())}function Gle(n,e){n&1&&(F(0,"div",118),H(1," Upload some documents first to start chatting! "),L())}function Wle(n,e){if(n&1){let t=St();F(0,"div",92)(1,"div",93,1),me(3,Ble,9,6,"ng-container",94)(4,Hle,6,0,"div",95),L(),F(5,"div",96)(6,"div",97)(7,"textarea",98),fn("ngModelChange",function(i){ge(t);let s=G(2);return wn(s.messageInput,i)||(s.messageInput=i),ye(i)}),_e("keydown",function(i){ge(t);let s=G(2);return ye(s.onEnterKey(i))}),L(),F(8,"button",99),_e("click",function(){ge(t);let i=G(2);return ye(i.sendMessage())}),me(9,qle,2,0,"span",49)(10,zle,2,0,"span",54),L()(),me(11,Gle,2,0,"div",100),L()()}if(n&2){let t=G(2);j(3),B("ngForOf",t.messages),j(),B("ngIf",t.sending),j(3),hn("ngModel",t.messageInput),B("disabled",t.sending||t.documents.length===0),j(),B("disabled",!t.messageInput.trim()||t.sending||t.documents.length===0),j(),B("ngIf",!t.sending),j(),B("ngIf",t.sending),j(),B("ngIf",t.documents.length===0)}}function Kle(n,e){if(n&1){let t=St();F(0,"div",119)(1,"h3",120),H(2,"Welcome to RAG Chat! \u{1F916}"),L(),F(3,"p",121),H(4,"Create a new chat session to start asking questions about your documents."),L(),F(5,"button",122),_e("click",function(){ge(t);let i=G(2);return ye(i.createNewSession())}),H(6," Start New RAG Session "),L()()}}function Yle(n,e){if(n&1){let t=St();F(0,"div",9)(1,"div",10)(2,"aside",11)(3,"div",12)(4,"div",13),_e("dragover",function(i){ge(t);let s=G();return ye(s.currentSession?s.onDragOver(i):null)})("dragleave",function(i){ge(t);let s=G();return ye(s.currentSession?s.onDragLeave(i):null)})("drop",function(i){ge(t);let s=G();return ye(s.currentSession?s.onDrop(i):null)}),me(5,ule,11,5,"div",14)(6,dle,4,1,"div",15),L()(),F(7,"div",16)(8,"div",17)(9,"h3",18),H(10,"RAG Sessions"),L(),F(11,"button",19),_e("click",function(){ge(t);let i=G();return ye(i.createNewSession())}),H(12," + New "),L()(),F(13,"div",20),me(14,ple,10,13,"div",21),L()(),F(15,"div",22)(16,"h4",23),H(17),L(),me(18,Ale,2,1,"div",24)(19,Cle,6,0,"div",25)(20,Sle,6,0,"div",25),L(),me(2
3691,Rle,7,3,"div",26),L(),F(22,"main",27),me(23,Fle,10,5,"div",28)(24,Wle,12,8,"div",29)(25,Kle,7,0,"div",30),L()()()}if(n&2){let t=G();j(4),kr("drag-over",t.dragOver)("uploading",t.uploading)("disabled",!t.currentSession),j(),B("ngIf",!t.uploading),j(),B("ngIf",t.uploading),j(8),B("ngForOf",t.sessions),j(3),Ut("Session Documents (",t.getSessionDocuments().length,")"),j(),B("ngIf",t.getSessionDocuments().length>0),j(),B("ngIf",t.getSessionDocuments().length===0&&!t.uploading&&t.currentSession),j(),B("ngIf",!t.currentSession),j(),B("ngIf",t.getSessionDocuments().length>0),j(2),B("ngIf",t.currentSession),j(),B("ngIf",t.currentSession),j(),B("ngIf",!t.currentSession)}}function Xle(n,e){if(n&1){let t=St();F(0,"label",131)(1,"input",125),fn("ngModelChange",function(i){ge(t);let s=G(2);return wn(s.multiAgentEnabled,i)||(s.multiAgentEnabled=i),ye(i)}),_e("change",function(){ge(t);let i=G(2);return ye(i.onMultiAgentToggle())}),L(),yt(2,"span",126),H(3," Multi-Agent Orchestration (Beta) "),L()}if(n&2){let t=G(2);j(),hn("ngModel",t.multiAgentEnabled)}}function Qle(n,e){if(n&1){let t=St();F(0,"label",131)(1,"input",132),fn("ngModelChange",function(i){ge(t);let s=G(2);return wn(s.skipCriticPhase,i)||(s.skipCriticPhase=i),ye(i)}),L(),yt(2,"span",126),H(3," Skip Critic Phase (End at Verifier) "),L()}if(n&2){let t=G(2);j(),hn("ngModel",t.skipCriticPhase)}}function Zle(n,e){if(n&1){let t=St();F(0,"label",137)(1,"input",138),_e("change",function(i){let s=ge(t).$implicit,o=G(3);return ye(o.onServerToggle(s.id,i))}),L(),F(2,"span",139),H(3),L(),F(4,"span",140),H(5),L()()}if(n&2){let t=e.$implicit,r=G(3);B("title",t.description+(t.tools?" \u2022 "+t.tools.length+" tools: "+r.getToolNames(t.tools):"")),j(),B("checked",t.enabled),j(2),Zt(t.name),j(),B("ngClass",NN(5,ole,t.status==="online",t.status==="error"||t.status==="offline")),j(),Ut(" ",r.getStatusIcon(t.status)," ")}}function Jle(n,e){if(n&1&&(F(0,"div",133)(1,"h4",134),H(2),L(),F(3,"div",135),me(4,Zle,6,8,"label",136),L()()),n&2){let t=G(2);j(2),Ut("MCP Servers (",t.getTotalEnabledTools()," tools):"),j(2),B("ngForOf",t.mcpServers)}}function eue(n,e){if(n&1&&(F(0,"div",101)(1,"div",102)(2,"div",103),yt(3,"markdown",104),L()(),F(4,"div",106),H(5),L()()),n&2){let t=G().$implicit;B("ngClass",t.message.role==="user"?"items-end":"items-start"),j(),B("ngClass",t.message.role==="user"?"text-white bg-gradient-to-br from-primary to-primary-light rounded-xl rounded-br-md":"bg-surface border border-border text-white rounded-xl rounded-bl-md"),j(2),B("data",t.message.content),j(2),Ut(" ",t.message.createdAt.toLocaleTimeString()," ")}}function tue(n,e){if(n&1&&yt(0,"app-prompt-message",113),n&2){let t=G().$implicit;B("entry",t.prompt)}}function nue(n,e){if(n&1&&(Ba(0)(1,141),me(2,eue,6,4,"div",142)(3,tue,1,1,"app-prompt-message",143),Ha()()),n&2){let t=e.$implicit;j(),B("ngSwitch",t.kind),j(),B("ngSwitchCase","message"),j(),B("ngSwitchCase","prompt")}}function rue(n,e){n&1&&(F(0,"div",114)(1,"div",115)(2,"div",116),yt(3,"span",117)(4,"span",117)(5,"span",117),L()()())}function iue(n,e){n&1&&(F(0,"span"),H(1,"\u27A4"),L())}function sue(n,e){n&1&&(F(0,"span",60),H(1,"\u23F3"),L())}function oue(n,e){if(n&1){let t=St();F(0,"div",9)(1,"div",10)(2,"div",11)(3,"div",17)(4,"h3",18),H(5,"\u{1F4AC} Chat Settings"),L()(),F(6,"div",123)(7,"label",124)(8,"input",125),fn("ngModelChange",function(i){ge(t);let s=G();return wn(s.mcpEnabled,i)||(s.mcpEnabled=i),ye(i)}),_e("change",function(){ge(t);let i=G();return ye(i.onMcpToggle())}),L(),yt(9,"span",126),H(10," Enable MCP (Tool Calling) "),L(),me(11,Xle,4,1,"label",127)(12,Qle,4,1,"label",127)(13,Jle,5,2,"div",128),L()(),F(14,"div",27)(15,"div",73)(16,"h2",74),H(17,"General Chat"),L()(),F(18,"div",92)(19,"div",93,2),me(21,nue,4,3,"ng-container",129)(22,rue,6,0,"div",95),L(),F(23,"div",96)(24,"div",97)(25,"textarea",130),fn("ngModelChange",function(i){ge(t);let s=G();return wn(s.generalMessageInput,i)||(s.generalMessageInput=i),ye(i)}),_e("keydown",function(i){ge(t);let s=G();return ye(s.onGeneralEnterKey(i))}),L(),F(26,"button",99),_e("click",function(){ge(t);let i=G();return ye(i.sendGeneralMessage())}),me(27,iue,2,0,"span",49)(28,sue,2,0,"span",54),L()()()()()()()}if(n&2){let t=G();j(8),hn("ngModel",t.mcpEnabled),j(3),B("ngIf",t.mcpEnabled),j(),B("ngIf",t.mcpEnabled&&t.multiAgentEnabled),j(),B("ngIf",t.mcpEnabled),j(8),B("ngForOf",t.generalTimeline)("ngForTrackBy",t.trackTimelineEntry),j(),B("ngIf",t.sendingGeneral),j(3),hn("ngModel",t.generalMessageInput),B("disabled",t.sendingGeneral),j(),B("disabled",!t.generalMessageInput.trim()||t.sendingGeneral),j(),B("ngIf",!t.sendingGeneral),j(),B("ngIf",t.sendingGeneral)}}function aue(n,e){if(n&1){let t=St();F(0,"div",149)(1,"div",150),H(2,"\u{1F5BC}\uFE0F"),L(),F(3,"h4",151),H(4,"Upload Image"),L(),F(5,"p",152),H(6,"Drag & drop or click to select"),L(),F(7,"p",153),H(8,"Supports: JPG, PNG, GIF, WebP"),L(),F(9,"input",154,3),_e("change",function(i){ge(t);let s=G(2);return ye(s.onImageSelect(i))}),L(),F(11,"button",155),_e("click",function(){ge(t);let i=Al(10);return ye(i.click())}),H(12," Choose Image "),L()()}}function cue(n,e){if(n&1){let t=St();F(0,"div",156),yt(1,"img",157),F(2,"div",158)(3,"div",159),H(4),L(),F(5,"div",160),H(6),L()(),F(7,"button",77),_e("click",function(){ge(t);let i=G(2);return ye(i.clearSelectedImage())}),H(8," Remove "),L()()}if(n&2){let t=G(2);j(),B("src",t.selectedImage.url,z0)("alt",t.selectedImage.name),j(3),Zt(t.selectedImage.name),j(2),Zt(t.formatFileSize(t.selectedImage.size))}}function lue(n,e){n&1&&(F(0,"div",40),yt(1,"div",41),F(2,"p",42),H(3,"Processing image..."),L()())}function uue(n,e){n&1&&(F(0,"span"),H(1,"Analyze Image"),L())}function due(n,e){n&1&&(F(0,"span"),H(1,"Analyzing..."),L())}function hue(n,e){if(n&1){let t=St();F(0,"div",161)(1,"textarea",162),fn("ngModelChange",function(i){ge(t);let s=G(2);return wn(s.visionPrompt,i)||(s.visionPrompt=i),ye(i)}),L(),F(2,"button",163),_e("click",function(){ge(t);let i=G(2);return ye(i.analyzeImage())}),me(3,uue,2,0,"span",49)(4,due,2,0,"span",49),L()()}if(n&2){let t=G(2);j(),hn("ngModel",t.visionPrompt),j(),B("disabled",t.sendingVision||!t.selectedImage),j(),B("ngIf",!t.sendingVision),j(),B("ngIf",t.sendingVision)}}function fue(n,e){if(n&1&&(F(0,"div",170),yt(1,"img",171),L()),n&2){let t=G().$implicit;j(),B("src",t.image.url,z0)("alt",t.image.name)}}function pue(n,e){if(n&1&&(F(0,"div",103),yt(1,"markdown",104),L()),n&2){let t=G().$implicit;j(),B("data",t.content)}}function mue(n,e){if(n&1&&(F(0,"div",172)(1,"strong"),H(2,"Prompt:"),L(),H(3),L()),n&2){let t=G().$implicit;B("ngClass",t.role==="user"?"bg-white/10":"bg-gray-50 text-dark-text-secondary"),j(3),Ut(" ",t.prompt," ")}}function gue(n,e){if(n&1&&yt(0,"app-prompt-message",113),n&2){let t=e.$implicit;B("entry",t)}}function yue(n,e){if(n&1&&(Ba(0),me(1,gue,1,1,"app-prompt-message",112),Ha()),n&2){let t=G().$implicit,r=G(3);j(),B("ngForOf",r.getPromptLogsForMessage(t.id))("ngForTrackBy",r.trackByPromptId)}}function _ue(n,e){if(n&1&&(Ba(0),F(1,"div",101)(2,"div",166),me(3,fue,2,2,"div",167)(4,pue,2,1,"div",168)(
3695,mue,4,2,"div",169),L(),F(6,"div",106),H(7),L()(),me(8,yue,2,2,"ng-container",49),Ha()),n&2){let t=e.$implicit;j(),B("ngClass",t.role==="user"?"items-end":"items-start"),j(),B("ngClass",t.role==="user"?"text-white bg-gradient-to-br from-primary to-primary-light rounded-xl rounded-br-md":"bg-surface border border-border text-white rounded-xl rounded-bl-md"),j(),B("ngIf",t.image),j(),B("ngIf",t.content),j(),B("ngIf",t.prompt),j(2),Ut(" ",t.createdAt.toLocaleTimeString()," "),j(),B("ngIf",t.role==="assistant"&&t.id)}}function vue(n,e){n&1&&(F(0,"div",114)(1,"div",173)(2,"div",116),yt(3,"span",117)(4,"span",117)(5,"span",117),L()()())}function bue(n,e){if(n&1&&(F(0,"div",92)(1,"h4",164),H(2,"Analysis Results"),L(),F(3,"div",165,4),me(5,_ue,9,7,"ng-container",94)(6,vue,6,0,"div",95),L()()),n&2){let t=G(2);j(5),B("ngForOf",t.visionMessages),j(),B("ngIf",t.sendingVision)}}function wue(n,e){n&1&&(F(0,"div",119)(1,"h3",120),H(2,"Upload an image to get started! \u{1F4F8}"),L(),F(3,"p",121),H(4,"Select an image from the sidebar and ask questions about it."),L()())}function Eue(n,e){if(n&1){let t=St();F(0,"div",9)(1,"div",10)(2,"div",11)(3,"div",17)(4,"h3",18),H(5,"\u{1F441}\uFE0F Image Upload"),L()(),F(6,"div",144)(7,"div",145),_e("dragover",function(i){ge(t);let s=G();return ye(s.onVisionDragOver(i))})("dragleave",function(i){ge(t);let s=G();return ye(s.onVisionDragLeave(i))})("drop",function(i){ge(t);let s=G();return ye(s.onVisionDrop(i))}),me(8,aue,13,0,"div",146)(9,cue,9,4,"div",147)(10,lue,4,0,"div",15),L(),me(11,hue,5,4,"div",148),L()(),F(12,"div",27)(13,"div",73)(14,"h2",74),H(15,"Vision Analysis"),L()(),me(16,bue,7,2,"div",29)(17,wue,5,0,"div",30),L()()()}if(n&2){let t=G();j(7),B("ngClass",uE(7,ale,t.visionDragOver,t.visionUploading,t.selectedImage)),j(),B("ngIf",!t.selectedImage&&!t.visionUploading),j(),B("ngIf",t.selectedImage&&!t.visionUploading),j(),B("ngIf",t.visionUploading),j(),B("ngIf",t.selectedImage&&!t.visionUploading),j(5),B("ngIf",t.visionMessages.length>0),j(),B("ngIf",t.visionMessages.length===0)}}var L3=(()=>{class n{constructor(t,r,i,s,o,a,c,l,u,d,f,p,y){this.pdfProcessor=t,this.documentService=r,this.chatService=i,this.authService=s,this.globalModelSelection=o,this.mcpService=a,this.mcpRegistry=c,this.multiAgentOrchestrator=l,this.errorHandler=u,this.logger=d,this.utils=f,this.promptLogging=p,this.mathRenderer=y,this.documents=[],this.selectedDocument=null,this.uploading=!1,this.uploadProgress="",this.deleting=null,this.deletingSession=null,this.acceptedFileTypes=Wj,this.sessions=[],this.currentSession=null,this.messages=[],this.messageInput="",this.sending=!1,this.generalMessages=[],this.generalMessageInput="",this.sendingGeneral=!1,this.mcpEnabled=!1,this.multiAgentEnabled=!1,this.skipCriticPhase=!1,this.mcpServers=[],this.availableTools=[],this.activeTab="rag",this.dragOver=!1,this.showAddDocuments=!1,this.timeouts=[],this.destroy$=new mt,this.processingStuckDocuments=!1,this.promptLogs=[],this.generalTimeline=[],this.previousGeneralTimelineLength=0,this.selectedImage=null,this.visionDragOver=!1,this.visionUploading=!1,this.visionPrompt="",this.sendingVision=!1,this.visionMessages=[]}buildConversationHistory(t){if(!this.globalModelSelection.getMemoryEnabled())return;let r=t.filter(i=>i.role==="user"||i.role==="assistant").map(i=>({role:i.role,content:i.role==="user"&&i.prompt||i.content||""})).filter(i=>i.content.length>0);return r.length>0?r.slice(-$n.MEMORY.MAX_MESSAGES):void 0}scrollToBottom(t,r=!0){try{let i=t.nativeElement,s={top:i.scrollHeight,behavior:r?"smooth":"auto"};i.scrollTo(s)}catch{try{let s=t.nativeElement;s.scrollTop=s.scrollHeight}catch(s){this.logger.debug("Auto-scroll failed",s)}}}scrollToBottomAfterDelay(t,r=$n.TIMEOUTS.SCROLL_DELAY){let i=setTimeout(()=>{this.scrollToBottom(t)},r);this.timeouts.push(i)}ngOnInit(){this.loadUserData(),this.initializeMcpRegistry(),this.initializePromptLogging()}initializePromptLogging(){this.promptLogging.promptLogs$.pipe(pi(this.destroy$)).subscribe(t=>{this.promptLogs=t,this.updateGeneralTimeline("prompt")})}initializeMcpRegistry(){this.mcpRegistry.servers$.pipe(pi(this.destroy$)).subscribe(t=>{this.mcpServers=t}),this.mcpRegistry.availableTools$.pipe(pi(this.destroy$)).subscribe(t=>{this.availableTools=t})}loadUserData(){return m(this,null,function*(){try{this.documents=yield this.documentService.getUserDocuments(),this.sessions=yield this.chatService.getUserSessions(),this.sessions.length>0&&!this.currentSession&&(yield this.selectSession(this.sessions[0])),yield this.processStuckDocuments()}catch(t){this.logger.error("Error loading user data",t)}})}processStuckDocuments(){return m(this,null,function*(){if(this.processingStuckDocuments)return;let t=this.documents.filter(r=>r.status==="chunks_ready").slice();if(t.length!==0){this.processingStuckDocuments=!0,this.logger.info(`Found ${t.length} documents stuck in chunks_ready status`);try{for(let r of t)if(r.id){this.logger.debug(`Processing stuck document: ${r.id} (${r.filename})`);try{yield this.documentService.generateEmbeddingsForChunks(r.id),this.logger.debug(`Successfully generated embeddings for stuck document: ${r.id}`)}catch(i){this.logger.error("Error processing stuck document",{docId:r.id,error:i})}}this.documents=yield this.documentService.getUserDocuments()}finally{this.processingStuckDocuments=!1}}})}onDragOver(t){t.preventDefault(),this.dragOver=!0}onDragLeave(t){t.preventDefault(),this.dragOver=!1}onDrop(t){t.preventDefault(),this.dragOver=!1;let r=t.dataTransfer?.files;r&&r.length>0&&this.handleFile(r[0])}onFileSelect(t){let r=t.target;r.files&&r.files.length>0&&this.handleFile(r.files[0])}handleFile(t){return m(this,null,function*(){if(!Au.includes(t.type)){let r=Object.values($n.SUPPORTED_DOCUMENT_TYPES).map(i=>i.label).join(", ");alert(`Unsupported file type. Supported types: ${r}`);return}if(t.size>$n.FILE_SIZE.DOCUMENT_MAX_SIZE){alert(`File size must be less than ${$n.FILE_SIZE.DOCUMENT_MAX_SIZE/(1024*1024)}MB.`);return}this.uploading=!0,this.uploadProgress="Uploading file...";try{let r=yield this.documentService.uploadDocument(t);this.uploadProgress="Processing document (server-side)...",this.logger.debug(`Starting to watch document ${r} for status changes`);let i=this.documentService.watchDocumentStatus(r).subscribe({next:s=>m(this,null,function*(){if(this.logger.debug(`Received status update for ${r}`,{status:s.status,docData:s}),this.logger.info("Document status update",{docId:r,status:s.status}),s.status==="chunks_ready"){this.logger.debug("Document is chunks_ready, calling generateEmbeddingsForChunks"),this.uploadProgress=`Generating embeddings for ${s.chunkCount||"unknown"} chunks...`;try{this.logger.debug(`Calling generateEmbeddingsForChunks for ${r}`),yield this.documentService.generateEmbeddingsForChunks(r),this.logger.debug(`generateEmbeddingsForChunks completed for ${r}`)}catch(o){this.logger.error("Error in generateEmbeddingsForChunks",o),this.logger.error("Error generating embeddings",{error:o}),this.uploadProgress="Error generating embeddings",i.unsubscribe(),this.finishUpload()}}else if(s.status==="completed"){if(i.unsubscribe(),this.currentSession?.id&&
369(yield this.chatService.addDocumentToSession(this.currentSession.id,r),this.logger.info("Document associated with session",{docId:r,sessionId:this.currentSession.id}),this.currentSession.associatedDocuments||(this.currentSession.associatedDocuments=[]),this.currentSession.associatedDocuments.push(r)),this.uploadProgress="Complete!",yield this.loadUserData(),this.currentSession?.id){let o=this.sessions.find(a=>a.id===this.currentSession.id);o&&(this.currentSession=o)}this.finishUpload()}else s.status==="error"&&(i.unsubscribe(),this.uploadProgress=s.error||"Error processing document",this.finishUpload())}),error:s=>{this.logger.error("Error watching document status",{error:s}),this.uploadProgress="Error monitoring document processing",this.finishUpload()}})}catch(r){let i=this.errorHandler.handleDocumentError(r,"process");this.uploadProgress=i,this.finishUpload()}})}finishUpload(){this.uploading=!1;let t=setTimeout(()=>{this.uploadProgress=""},$n.TIMEOUTS.UPLOAD_COMPLETE_DISPLAY);this.timeouts.push(t)}selectDocument(t){this.selectedDocument=t}createNewSession(){return m(this,null,function*(){try{let t=yield this.chatService.createSession();yield this.loadUserData();let r=this.sessions.find(i=>i.id===t);r&&(yield this.selectSession(r))}catch(t){this.errorHandler.handleSessionError(t,"create")}})}selectSession(t){return m(this,null,function*(){this.currentSession=t;try{this.messages=yield this.chatService.getSessionMessages(t.id),this.messages.length>0&&this.scrollToBottomAfterDelay(this.ragMessagesContainer,$n.TIMEOUTS.SCROLL_DELAY_EXTENDED)}catch(r){this.logger.error("Error loading session messages",{sessionId:t.id,error:r})}})}sendMessage(){return m(this,null,function*(){if(!this.messageInput.trim()||!this.currentSession||this.sending)return;let t=this.messageInput.trim();this.messageInput="",this.sending=!0;let r={role:"user",content:t,createdAt:new Date};this.messages.push(r),this.scrollToBottomAfterDelay(this.ragMessagesContainer);try{let i=this.messages.length===1,s=this.messages.slice(0,-1),o=this.buildConversationHistory(s),a=yield this.chatService.sendMessage(this.currentSession.id,t,this.selectedDocument?.id,this.globalModelSelection.getSelectionForRequest(),o);if(i&&this.currentSession){let c=this.abbreviateTitle(t);yield this.chatService.updateSessionTitle(this.currentSession.id,c),this.currentSession.title=c;let l=this.sessions.findIndex(u=>u.id===this.currentSession.id);l!==-1&&(this.sessions[l].title=c)}this.messages.push(a),this.scrollToBottomAfterDelay(this.ragMessagesContainer)}catch(i){let s=this.errorHandler.createChatErrorMessage(i,"RAG");this.messages.push({role:"assistant",content:s,createdAt:new Date}),this.scrollToBottomAfterDelay(this.ragMessagesContainer)}finally{this.sending=!1}})}onEnterKey(t){t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),this.sendMessage())}sendGeneralMessage(){return m(this,null,function*(){if(!this.generalMessageInput.trim()||this.sendingGeneral)return;let t=this.generalMessageInput.trim();this.generalMessageInput="",this.sendingGeneral=!0;let r={role:"user",content:t,createdAt:new Date};this.generalMessages.push(r),this.updateGeneralTimeline("message"),this.scrollToBottomAfterDelay(this.generalMessagesContainer);try{if(this.mcpEnabled&&this.multiAgentEnabled)yield this.sendMultiAgentMessage(t);else if(this.mcpEnabled)yield this.sendMcpMessageWithSeparateResponses(t);else{let i=this.generalMessages.slice(0,-1),s=this.buildConversationHistory(i),o=yield this.chatService.sendGeneralMessage(t,this.globalModelSelection.getSelectionForRequest(),s);this.generalMessages.push(o),this.updateGeneralTimeline("message")}this.scrollToBottomAfterDelay(this.generalMessagesContainer)}catch(i){let s=this.errorHandler.createChatErrorMessage(i,"General");this.generalMessages.push({role:"assistant",content:s,createdAt:new Date}),this.updateGeneralTimeline("message"),this.scrollToBottomAfterDelay(this.generalMessagesContainer)}finally{this.sendingGeneral=!1}})}sendMcpMessage(t){return m(this,null,function*(){try{let r=`mcp_${Date.now()}_${Math.random().toString(36).substring(2,11)}`,i=this.globalModelSelection.getSelectionForRequest(),s=i;i&&i.mcp&&(s={llm:{provider:i.mcp.provider,model:i.mcp.model}},this.logger.debug("Using MCP provider for tool calling",s));let o=yield this.chatService.sendMcpMessage(t,s,void 0,r);if(o.toolCalls&&o.toolCalls.length>0){this.logger.debug("LLM requested tool calls",o.toolCalls);let a=[];for(let l of o.toolCalls)try{this.logger.debug("Executing tool call",l);let d=(yield this.mcpService.callTool(l,r)).content.map(f=>f.text).join(" ");a.push({toolName:l.name,arguments:l.arguments,result:d})}catch(u){this.logger.error("Tool call error",u),a.push({toolName:l.name,arguments:l.arguments,result:`Error: ${u}`})}let c=yield this.chatService.sendMcpMessage(t,s,a,r);return{id:r,role:"assistant",content:c.answer,createdAt:new Date}}return{id:r,role:"assistant",content:o.answer,createdAt:new Date}}catch(r){return{role:"assistant",content:this.errorHandler.createChatErrorMessage(r,"MCP"),createdAt:new Date}}})}sendMcpMessageWithSeparateResponses(t){return m(this,null,function*(){try{let r=`mcp_${Date.now()}_${Math.random().toString(36).substring(2,11)}`,i=this.globalModelSelection.getSelectionForRequest(),s=i;i&&i.mcp&&(s={llm:{provider:i.mcp.provider,model:i.mcp.model}},this.logger.debug("Using MCP provider for tool calling",s));let o=this.generalMessages.slice(0,-1),a=this.buildConversationHistory(o),c=r+"_reasoning",l=yield this.chatService.sendMcpMessage(t,s,void 0,c,a);if(l.toolCalls&&l.toolCalls.length>0){this.logger.debug("LLM requested tool calls",l.toolCalls),l.answer&&l.answer.trim()&&l.answer!=="I need to use some tools to answer your question."&&(this.generalMessages.push({id:c,role:"assistant",content:this.formatThinkingContent(l.answer),createdAt:new Date}),this.updateGeneralTimeline("message"),this.scrollToBottomAfterDelay(this.generalMessagesContainer));let u=[];for(let v of l.toolCalls)try{this.logger.debug("Executing tool call",v);let E=(yield this.mcpService.callTool(v,r)).content.map(A=>A.text).join(" ");u.push({toolName:v.name,arguments:v.arguments,result:E})}catch(w){this.logger.error("Tool call error",w),u.push({toolName:v.name,arguments:v.arguments,result:`Error: ${w}`})}let d=r+"_final",f=yield this.chatService.sendMcpMessage(t,s,u,d),p=this.formatAnswerContent(f.answer),y=yield this.mathRenderer.transformMarkdown(p);this.generalMessages.push({id:d,role:"assistant",content:y,createdAt:new Date}),this.updateGeneralTimeline("message"),this.updateMcpPromptLogs(d),this.scrollToBottomAfterDelay(this.generalMessagesContainer)}else{let u=this.formatAnswerContent(l.answer),d=yield this.mathRenderer.transformMarkdown(u);this.generalMessages.push({id:r,role:"assistant",content:d,createdAt:new Date}),this.updateGeneralTimeline("message"),this.updateMcpPromptLogs(r),this.scrollToBottomAfterDelay(this.generalMessagesContainer)}}catch(r){let i=this.errorHandler.createChatErrorMessage(r,"MCP");
369this.generalMessages.push({role:"assistant",content:i,createdAt:new Date}),this.updateGeneralTimeline("message"),this.scrollToBottomAfterDelay(this.generalMessagesContainer)}})}sendMultiAgentMessage(t){return m(this,null,function*(){this.sendingGeneral=!0;try{if(!this.multiAgentOrchestrator.isAvailable())throw new Error("Multi-agent orchestration requires MCP tools to be available");let r={role:"assistant",content:`\u{1F914} **Multi-Agent Processing** 370 371Analyzing your request and planning execution...`,createdAt:new Date};this.generalMessages.push(r),this.updateGeneralTimeline("message"),this.scrollToBottomAfterDelay(this.generalMessagesContainer);let i=this.globalModelSelection.getSelectionForRequest(),s=i;i&&i.mcp&&(s={llm:{provider:i.mcp.provider,model:i.mcp.model}},this.logger.debug("Using MCP provider for multi-agent orchestration",s));let o=this.globalModelSelection.getModelParamsForRequest(),a={query:t,modelSelection:s,temperature:o.temperature,seed:o.seed!==-1?o.seed:void 0,enablePromptLogging:this.promptLogging.isLoggingActive(),skipCriticPhase:this.skipCriticPhase};this.logger.debug("Multi-agent orchestration request parameters:",{temperature:a.temperature,seed:a.seed,enablePromptLogging:a.enablePromptLogging,model:s?.llm});let c=yield this.multiAgentOrchestrator.processQueryWithParams(a);if(c.success){let l=`multiagent_${Date.now()}_${Math.random().toString(36).substring(2,11)}`,u=this.formatAnswerContent(c.finalAnswer),d=yield this.mathRenderer.transformMarkdown(u),f=this.generalMessages.length-1;this.generalMessages[f]={id:l,role:"assistant",content:d,createdAt:new Date},this.updateGeneralTimeline("message"),this.updateMultiAgentPromptLogs(l),c.executionLog.length>0&&this.logger.debug("Multi-Agent Orchestration Log",{query:t,tasks:c.tasks,executionLog:c.executionLog,finalAnswer:c.finalAnswer})}else{let l=c.finalAnswer||"Multi-agent orchestration failed",u=this.generalMessages.length-1;this.generalMessages[u]={role:"assistant",content:`\u274C **Multi-Agent Error** 372 373${l}`,createdAt:new Date},this.updateGeneralTimeline("message")}this.scrollToBottomAfterDelay(this.generalMessagesContainer)}catch(r){let i=this.errorHandler.createChatErrorMessage(r,"General"),s=this.generalMessages.length-1;this.generalMessages[s]={role:"assistant",content:`\u274C **Multi-Agent Error** 374 375${i}`,createdAt:new Date},this.updateGeneralTimeline("message"),this.scrollToBottomAfterDelay(this.generalMessagesContainer)}finally{this.sendingGeneral=!1}})}onGeneralEnterKey(t){t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),this.sendGeneralMessage())}setActiveTab(t){this.activeTab=t;let r="rag";t==="chat"?r="chat":t==="vision"&&(r="vision"),this.globalModelSelection.updateCurrentApp(r)}onVisionDragOver(t){t.preventDefault(),this.visionDragOver=!0}onVisionDragLeave(t){t.preventDefault(),this.visionDragOver=!1}onVisionDrop(t){t.preventDefault(),this.visionDragOver=!1;let r=t.dataTransfer?.files;r&&r.length>0&&this.handleImageFile(r[0])}onImageSelect(t){let r=t.target;r.files&&r.files.length>0&&this.handleImageFile(r.files[0])}handleImageFile(t){if(!t.type.startsWith($n.FILE_TYPES.IMAGE_PREFIX)){alert("Please select an image file.");return}if(t.size>$n.FILE_SIZE.IMAGE_MAX_SIZE){alert(`Image size must be less than ${$n.FILE_SIZE.IMAGE_MAX_SIZE/(1024*1024)}MB.`);return}let r=new FileReader;r.onload=i=>{this.selectedImage={url:i.target?.result,name:t.name,size:t.size,file:t}},r.readAsDataURL(t)}clearSelectedImage(){this.selectedImage=null,this.visionPrompt=""}formatFileSize(t){if(t===0)return"0 Bytes";let r=1024,i=["Bytes","KB","MB","GB"],s=Math.floor(Math.log(t)/Math.log(r));return parseFloat((t/Math.pow(r,s)).toFixed(2))+" "+i[s]}analyzeImage(){return m(this,null,function*(){if(!this.selectedImage||this.sendingVision)return;this.sendingVision=!0;let t=this.visionPrompt.trim()||"Please analyze this image and describe what you see.",r={role:"user",image:{url:this.selectedImage.url,name:this.selectedImage.name},prompt:t,createdAt:new Date};this.visionMessages.push(r),this.scrollToBottomAfterDelay(this.visionMessagesContainer);try{let i=this.visionMessages.slice(0,-1),s=this.buildConversationHistory(i),o=yield this.chatService.sendVisionMessage(this.selectedImage.file,t,this.globalModelSelection.getSelectionForRequest(),s),a={id:o.id,role:"assistant",content:o.content,createdAt:new Date};this.visionMessages.push(a),this.scrollToBottomAfterDelay(this.visionMessagesContainer),this.visionPrompt=""}catch(i){let s=this.errorHandler.createChatErrorMessage(i,"Vision");this.visionMessages.push({role:"assistant",content:s,createdAt:new Date}),this.scrollToBottomAfterDelay(this.visionMessagesContainer)}finally{this.sendingVision=!1}})}deleteDocument(t){return m(this,null,function*(){if(!(!t.id||this.deleting||!confirm(`Are you sure you want to delete "${t.filename}"? This will remove the document and all its associated data permanently.`))){this.deleting=t.id;try{yield this.documentService.deleteDocument(t.id),this.documents=this.documents.filter(i=>i.id!==t.id),this.selectedDocument?.id===t.id&&(this.selectedDocument=null),yield this.loadUserData()}catch(i){let s=this.errorHandler.handleDocumentError(i,"delete");alert(s)}finally{this.deleting=null}}})}getDocumentName(t){let r=this.documents.find(i=>i.id===t);
375return r?r.filename:"Unknown Document"}getAvailableDocuments(){if(!this.currentSession)return[];let t=this.currentSession.associatedDocuments||[];return this.documents.filter(r=>r.status==="completed"&&!t.includes(r.id))}addDocumentToCurrentSession(t){return m(this,null,function*(){if(this.currentSession?.id)try{yield this.chatService.addDocumentToSession(this.currentSession.id,t),this.currentSession.associatedDocuments||(this.currentSession.associatedDocuments=[]),this.currentSession.associatedDocuments.push(t),yield this.loadUserData()}catch(r){this.logger.error("Error adding document to session",{sessionId:this.currentSession.id,docId:t,error:r}),alert("Failed to add document to session. Please try again.")}})}removeDocumentFromCurrentSession(t){return m(this,null,function*(){if(this.currentSession?.id)try{yield this.chatService.removeDocumentFromSession(this.currentSession.id,t),this.currentSession.associatedDocuments&&(this.currentSession.associatedDocuments=this.currentSession.associatedDocuments.filter(r=>r!==t)),yield this.loadUserData()}catch(r){this.logger.error("Error removing document from session",{sessionId:this.currentSession.id,docId:t,error:r}),alert("Failed to remove document from session. Please try again.")}})}getSessionDocuments(){if(!this.currentSession)return[];let t=this.currentSession.associatedDocuments||[];return this.documents.filter(r=>t.includes(r.id))}isDocumentCompatible(t){if(!t.embedModel)return!0;let i=this.globalModelSelection.getCurrentSelection()?.embed;return i?t.embedModel.provider===i.provider&&t.embedModel.model===i.model:!0}getDocumentById(t){return this.documents.find(r=>r.id===t)||null}isDocumentByIdCompatible(t){let r=this.getDocumentById(t);return r?this.isDocumentCompatible(r):!1}deleteSession(t){return m(this,null,function*(){if(!(!t.id||this.deletingSession||!confirm(`Are you sure you want to delete "${t.title}"? This will also delete all associated documents and messages permanently.`))){this.deletingSession=t.id;try{yield this.chatService.deleteSession(t.id),this.sessions=this.sessions.filter(i=>i.id!==t.id),this.currentSession?.id===t.id&&(this.currentSession=null,this.messages=[],this.selectedDocument=null),yield this.loadUserData()}catch(i){let s=this.errorHandler.handleSessionError(i,"delete");alert(s)}finally{this.deletingSession=null}}})}abbreviateTitle(t){return this.utils.abbreviateText(t,$n.UI.MAX_TITLE_LENGTH)}onMcpToggle(){return m(this,null,function*(){if(this.logger.info("MCP toggled",{enabled:this.mcpEnabled}),this.globalModelSelection.updateMcpEnabled(this.mcpEnabled),this.mcpEnabled||(this.multiAgentEnabled=!1),this.mcpEnabled)try{let t=this.mcpRegistry.getEnabledServers();this.logger.info("Initializing MCP servers",{serverNames:t.map(i=>i.name)});for(let i of t)yield this.mcpRegistry.initializeServer(i.id);let r=this.mcpRegistry.getAvailableTools();this.logger.info("MCP initialization complete",{toolCount:r.length,toolNames:r.map(i=>i.name)})}catch(t){this.logger.error("Failed to initialize MCP",t),this.mcpEnabled=!1,this.globalModelSelection.updateMcpEnabled(!1),alert("Failed to connect to MCP servers. Please check server availability.")}})}onMultiAgentToggle(){this.logger.info("Multi-Agent toggled",{enabled:this.multiAgentEnabled})}onServerToggle(t,r){return m(this,null,function*(){let i=r.target,s=i.checked;try{yield this.mcpRegistry.toggleServer(t,s),this.logger.info("MCP server toggled",{serverId:t,enabled:s})}catch(o){this.logger.error("Error toggling MCP server",{serverId:t,enabled:s,error:o}),i.checked=!s}})}getStatusText(t){switch(t){case"online":return"\u2705 Online";case"offline":return"\u2B55 Offline";case"error":return"\u274C Error";default:return"\u26AA Unknown"}}getStatusIcon(t){switch(t){case"online":return"\u2705";case"offline":return"\u2B55";case"error":return"\u274C";default:return"\u26AA"}}getToolNames(t){return t.map(r=>r.name).join(", ")}getTotalEnabledTools(){return this.availableTools.length}getEnabledServersCount(){return this.mcpServers.filter(t=>t.enabled&&t.status==="online").length}getPromptLogsForContext(t){return this.promptLogs.filter(r=>r.sessionContext===t)}getPromptLogsForMessage(t){return this.promptLogs.filter(r=>r.messageId===t)}trackByPromptId(t,r){return r.id}formatAnswerContent(t){return this.formatPrefixedContent("\u2705 **Answer:**",t)}formatThinkingContent(t){return this.formatPrefixedContent("\u{1F914} **Thinking:**",t)}formatPrefixedContent(t,r){return[/^#{1,6}\s/,/^-\s/,/^\*\s/,/^\+\s/,/^\d+\.\s/,/^>\s/,/^```/,/^`/,/^\|.*\|/,/^---/,/^\*\*/,/^_/].some(o=>o.test(r.trim()))?`${t} 376 377${r}`:`${t} ${r}`}updateMultiAgentPromptLogs(t){let r=new Date(Date.now()-12e4),i=this.promptLogs.filter(s=>s.timestamp>r&&(s.sessionContext?.startsWith("multi-agent")||s.sessionContext==="mcp-tool-call"));
377i.forEach(s=>{this.promptLogging.updatePromptLogMessageId(s.id,t)}),this.logger.debug(`Updated ${i.length} multi-agent and MCP prompt logs with message ID: ${t}`)}updateGeneralTimeline(t="message"){let r=this.promptLogs.filter(o=>this.isGeneralPromptLog(o)),i=[...this.generalMessages.map(o=>({kind:"message",timestamp:o.createdAt,message:o})),...r.map(o=>({kind:"prompt",timestamp:o.timestamp,prompt:o}))];i.sort((o,a)=>{let c=o.timestamp.getTime()-a.timestamp.getTime();if(c!==0)return c;let l=this.getTimelineSequence(o),u=this.getTimelineSequence(a);return l!==u?l-u:o.kind==="prompt"&&a.kind==="prompt"&&o.prompt&&a.prompt?o.prompt.id.localeCompare(a.prompt.id):0});let s=i.length>this.previousGeneralTimelineLength;this.generalTimeline=i,this.previousGeneralTimelineLength=i.length,t==="prompt"&&s&&this.activeTab==="chat"&&this.generalMessagesContainer&&this.scrollToBottomAfterDelay(this.generalMessagesContainer)}isGeneralPromptLog(t){let r=t.sessionContext||"";return r==="general"||r==="mcp"||r==="mcp-tool-call"?!0:r.startsWith("multi-agent")}getTimelineSequence(t){if(t.kind==="prompt"){let r=t.prompt?.metadata?.sequence;return typeof r=="number"?r:500}return 0}trackTimelineEntry(t,r){if(r.kind==="prompt")return r.prompt?.id||`prompt_${t}`;let i=r.message;return i?.id?i.id:i?`message_${i.createdAt.getTime()}_${t}`:`message_${t}`}updateMcpPromptLogs(t){let r=new Date(Date.now()-3e4),i=this.promptLogs.filter(s=>s.timestamp>r&&s.sessionContext==="mcp-tool-call");i.forEach(s=>{this.promptLogging.updatePromptLogMessageId(s.id,t)}),this.logger.debug(`Updated ${i.length} MCP prompt logs with message ID: ${t}`)}ngOnDestroy(){this.destroy$.next(),this.destroy$.complete(),this.timeouts.forEach(t=>{clearTimeout(t)}),this.timeouts=[]}static{this.\u0275fac=function(r){return new(r||n)(oe(w3),oe(S3),oe(D3),oe(lb),oe(Cs),oe(cb),oe(_a),oe(M3),oe(N3),oe(Kn),oe(O3),oe(Zr),oe(zu))}}static{this.\u0275cmp=xr({type:n,selectors:[["app-dashboard"]],viewQuery:function(r,i){if(r&1&&(Vm(Zce,5),Vm(Jce,5),Vm(ele,5)),r&2){let s;Pd(s=Md())&&(i.ragMessagesContainer=s.first),Pd(s=Md())&&(i.generalMessagesContainer=s.first),Pd(s=Md())&&(i.visionMessagesContainer=s.first)}},standalone:!0,features:[Pr],decls:11,vars:10,consts:[["fileInput",""],["ragMessagesContainer",""],["generalMessagesContainer",""],["imageInput",""],["visionMessagesContainer",""],[1,"flex","flex-col","h-[calc(100vh-120px)]","bg-dark-bg","max-md:h-[calc(100vh-100px)]"],[1,"tab-nav","flex","relative","overflow-x-auto","bg-surface","border-b","border-border","px-6","max-[480px]:px-3"],[1,"tab-btn","relative","border-none","bg-transparent","cursor-pointer","font-sans","text-sm","font-medium","whitespace-nowrap","flex","items-center","py-4","px-6","text-dark-text-secondary","rounded-t-md","transition-all","duration-150","gap-2","hover:text-white","hover:bg-gray-50","max-[480px]:py-3","max-[480px]:px-4","max-[480px]:text-[0.8125rem]",3,"click"],["class","flex-1 overflow-hidden bg-dark-bg",4,"ngIf"],[1,"flex-1","overflow-hidden","bg-dark-bg"],[1,"flex","h-full","gap-1","max-md:flex-col"],[1,"flex","flex-col","overflow-hidden","shadow-sm","w-[360px]","bg-surface","border-r","border-border","max-lg:w-72","max-md:w-full","max-md:border-r-0","max-md:h-[200px]","max-md:border-b","max-md:border-border"],[1,"p-1","border-b","border-border"],[1,"upload-area","text-center","cursor-pointer","border-2","border-dashed","border-border","rounded-md","py-3","px-2","transition-all","duration-200","bg-surface-elevated","relative","overflow-hidden",3,"dragover","dragleave","drop"],["class","max-w-sm mx-auto relative z-10",4,"ngIf"],["class","flex flex-col items-center relative z-10 gap-4",4,"ngIf"],[1,"flex","flex-col","overflow-hidden","flex-[0.4]","border-b","border-border"],[1,"flex","justify-between","items-center","p-3","border-b","border-border","bg-surface"],[1,"font-semibold","m-0","text-[0.79rem]","text-white"],[1,"btn","btn-small","btn-primary",3,"click"],[1,"flex-1","overflow-y-auto","p-2"],["class",`group flex items-center justify-between cursor-pointer p-3 rounded-md mb-1 378 transition-all duration-150 border border-transparent gap-1 379 hover:bg-gray-50 hover:border-border-subtle hover:translate-x-0.5`,3,"active-session","ngClass","click",4,"ngFor","ngForOf"],[1,"flex","flex-col","overflow-hidden","p-[0.7rem]","border-b","border-border","flex-[0.8]"],[1,"flex-shrink-0","m-0","mb-2","text-[0.63rem]","text-white"],["class","document-list flex flex-col flex-1 overflow-y-auto gap-[0.35rem] pr-[0.4rem]",4,"ngIf"],["class","text-center text-sm p-4 text-dark-text-secondary",4,"ngIf"],["class","p-6 border-t border-border",4,"ngIf"],[1,"flex-1","flex","flex-col","overflow-hidden","bg-surface","rounded-tl-lg","max-md:rounded-none"],["class","flex justify-between items-center p-4 border-b border-border bg-surface backdrop-blur-[10px]",4,"ngIf"],["class","flex-1 flex flex-col overflow-hidden",4,"ngIf"],["class","flex-1 flex flex-col items-center justify-center text-center p-8 bg-dark-bg",4,"ngIf"],[1,"max-w-sm","mx-auto","relative","z-10"],[1,"text-[0.9rem]","mb-1","opacity-80","transition-all","duration-200"],[1,"font-semibold","text-white","mb-0","mt-0","text-[0.58rem]"],["class","text-dark-text-secondary mb-2 mt-0 text-[0.52rem]",4,"ngIf"],["class","italic text-dark-text-secondary mb-2 mt-0 text-[0.52rem]",4,"ngIf"],["type","file",2,"display","none",3,"change","accept","disabled"],[1,"btn","btn-primary","btn-small","text-[0.6rem]","py-1","px-2",3,"click","disabled"],[1,"text-dark-text-secondary","mb-2","mt-0","text-[0.52rem]"],[1,"italic","text-dark-text-secondary","mb-2","mt-0","text-[0.52rem]"],[1,"flex","flex-col","items-center","relative","z-10","gap-4"],[1,"w-10","h-10","rounded-full","animate-spin","border-[3px]","border-gray-200","border-t-[3px]","border-t-primary"],[1,"font-medium","text-white"],[1,"group","flex","items-center","justify-between","cursor-pointer","p-3","rounded-md","mb-1","transition-all","duration-150","border","border-transparent","gap-1","hover:bg-gray-50","hover:border-border-subtle","hover:translate-x-0.5",3,"click","ngClass"],[1,"flex-1","min-w-0"],[1,"font-medium","text-white","mb-0","overflow-hidden","whitespace-nowrap","text-ellipsis","text-[0.61rem]"],[1,"font-normal","text-[0.525rem]","text-dark-text-subtle"],[1,"flex-shrink-0"],["title","Delete session",1,"btn","btn-small","btn-danger","opacity-0","group-hover:opacity-100","py-[0.2rem]","px-[0.4rem]","text-[0.7rem]","transition-opacity","duration-150",3,"click","disabled"],[4,"ngIf"],[1,"document-list","flex","flex-col","flex-1","overflow-y-auto","gap-[0.35rem]","pr-[0.4rem]"],["class",`document-item flex items-center cursor-pointer relative overflow-hidden gap-2 p-2 380 rounded-md transition-all duration-150 border border-transparent 381 hover:shadow-sm hover:bg-gray-50 hover:border-border`,3,"ngClass","click",4,"ngFor","ngForOf"],[1,"document-item","flex","items-center","cursor-pointer","relative","overflow-hidden","gap-2","p-2","rounded-md","transition-all","duration-150","border","border-transparent","hover:shadow-sm","hover:bg-gray-50","hover:border-border",3,"click","ngClass"],[1,"flex-shrink-0","text-[1rem]"],["class","animate-pulse-slow",4,"ngIf"],[1,"font-medium","text-[0.56rem]","text-white","overflow-hidden","whitespace-nowrap","text-ellipsis"],[1,"font-medium","capitalize","inline-block","text-[0.7rem]","py-[0.1rem]","px-[0.4rem]","rounded-lg","mt-1",3,"ngClass"],["class","flex items-center text-dark-text-secondary text-[0.65rem] mt-1",4,"ngIf"],[1,"flex-shrink-0","flex","items-center","gap-2"],["title","Delete document",1,"btn","btn-small","btn-danger",3,"click","disabled"],[1,"animate-pulse-slow"],[1,"flex","items-center","text-dark-text-secondary","text-[0.65rem]","mt-1"],["class","text-sm ml-2","title","Incompatible embedding model",4,"ngIf"],["class","text-sm ml-2","title","Compatible embedding model",4,"ngIf"],["title","Incompatible embedding model",1,"text-sm","ml-2"],["title","Compatible embedding model",1,"text-sm","ml-2"],[1,"text-center","text-sm","p-4","text-dark-text-secondary"],[1,"p-6","border-t","border-border"],[1,"text-white","m-0","mb-3","text-[0.9rem]"],[1,"w-full","text-sm","p-2","border","border-border","rounded","bg-surface","text-white",3,"ngModelChange","ngModel"],[3,"ngValue"],[3,"ngValue","disabled",4,"ngFor","ngForOf"],[3,"ngValue","disabled"],[1,"flex","justify-between","items-center","p-4","border-b","border-border","bg-surface","backdrop-blur-[10px]"],[1,"font-semibold","tracking-tight","m-0","text-[0.96rem]","text-white"],[1,"flex","flex-col","gap-3","mt-2"],[1,"relative"],[1,"btn","btn-small","btn-secondary",3,"click"],["class",`absolute left-0 right-0 top-full overflow-y-auto shadow-lg bg-surface border border-border 382 rounded-md z-10 max-h-[200px] mt-1`,4,"ngIf"],[1,"text-sm","uppercase","tracking-wider","m-0","mb-2","text-dark-text-secondary"],[1,"flex","flex-wrap","gap-2"],["class","inline-flex items-center text-xs gap-1 py-1 px-2 rounded-sm border",3,"ngClass",4,"ngFor","ngForOf"],[1,"inline-flex","items-center","text-xs","gap-1","py-1","px-2","rounded-sm","border",3,"ngClass"],["class","text-sm text-warning","title","Incompatible embedding model",4,"ngIf"],["title","Remove from session",1,"flex","items-center","justify-center","bg-transparent","border-none","cursor-pointer","font-bold","rounded-full","text-error","text-[0.9rem]","p-0","ml-1","w-4","h-4","transition-colors","duration-150","hover:text-white","hover:bg-error",3,"click"],["title","Incompatible embedding model",1,"text-sm","text-warning"],[1,"absolute","left-0","right-0","top-full","overflow-y-auto","shadow-lg","bg-surface","border","border-border","rounded-md","z-10","max-h-[200px]","mt-1"],["class",`flex items-center justify-between cursor-pointer py-2 px-3 transition-colors duration-150 383 hover:bg-surface-hover`,3,"click",4,"ngFor","ngForOf"],[1,"flex","items-center","justify-between","cursor-pointer","py-2","px-3","transition-colors","duration-150","hover:bg-surface-hover",3,"click"],[1,"flex-1","text-sm","text-white"],[1,"flex","items-center","justify-center","font-bold","text-primary","text-[1.2rem]","w-5","h-5"],[1,"flex","items-center","text-xs","font-medium","bg-primary-subtle","text-primary-dark","py-1","px-3","rounded-sm","border","border-primary","gap-1"],[1,"flex-1","flex","flex-col","overflow-hidden"],[1,"flex-1","overflow-y-auto","scroll-smooth","p-4","bg-dark-bg","max-[480px]:p-4"],[4,"ngFor","ngForOf"],["class","flex flex-col items-start animate-fade-in-up mb-4",4,"ngIf"],[1,"shadow-sm","p-4","bg-surface","border-t","border-border","backdrop-blur-[10px]","shadow-[0_-4px_6px_-1px_rgba(0,0,0,0.05)]"],[1,"flex","items-end","max-w-3xl","mx-auto","gap-3","max-[480px]:gap-2"],["placeholder","Ask a question about your documents...","rows","2",1,"flex-1","font-sans","text-base","resize-y","py-2","px-3","border","border-border","rounded-xl","min-h-[32px]","max-h-[84px]","bg-surface","text-white","transition-all","duration-150","placeholder:text-dark-text-subtle","focus:outline-none","focus:-translate-y-
383px","focus:border-primary","focus:shadow-[0_0_0_3px_rgba(0,102,204,0.1)]",3,"ngModelChange","keydown","ngModel","disabled"],[1,"send-btn","flex","items-center","justify-center","border-none","rounded-full","cursor-pointer","text-white","shadow-sm","p-2","bg-gradient-to-br","from-primary","to-primary-light","transition-all","duration-150","w-8","h-8","hover:enabled:shadow-md","hover:enabled:bg-gradient-to-br","hover:enabled:from-primary-dark","hover:enabled:to-primary","hover:enabled:-translate-y-0.5","hover:enabled:scale-105","disabled:cursor-not-allowed","disabled:shadow-none","disabled:bg-gray-300",3,"click","disabled"],["class","text-center text-sm mt-2 text-dark-text-secondary",4,"ngIf"],[1,"flex","flex-col","animate-fade-in-up","mb-4",3,"ngClass"],[1,"max-w-[70%]","relative","shadow-sm","p-3","backdrop-blur-[10px]","max-md:max-w-[85%]","max-[480px]:max-w-[90%]",3,"ngClass"],[1,"leading-snug","whitespace-pre-wrap","text-base","break-words"],[3,"data"],["class","mt-3 pt-3",3,"ngClass",4,"ngIf"],[1,"opacity-70","text-[0.7rem]","text-dark-text-subtle","mt-2"],[1,"mt-3","pt-3",3,"ngClass"],[1,"font-semibold","uppercase","tracking-wider","opacity-80","m-0","mb-1","text-[0.525rem]"],[1,"flex","flex-wrap","gap-1"],["class","font-medium py-1 px-2 rounded-sm text-[0.48rem] border backdrop-blur-[4px]",3,"ngClass",4,"ngFor","ngForOf"],[1,"font-medium","py-1","px-2","rounded-sm","text-[0.48rem]","border","backdrop-blur-[4px]",3,"ngClass"],[3,"entry",4,"ngFor","ngForOf","ngForTrackBy"],[3,"entry"],[1,"flex","flex-col","items-start","animate-fade-in-up","mb-4"],[1,"max-w-[70%]","relative","shadow-sm","p-3","backdrop-blur-[10px]","bg-surface","border","border-border","text-white","rounded-xl","rounded-bl-md"],[1,"typing-indicator","flex","items-center","gap-1"],[1,"w-2","h-2","rounded-full","bg-primary"],[1,"text-center","text-sm","mt-2","text-dark-text-secondary"],[1,"flex-1","flex","flex-col","items-center","justify-center","text-center","p-8","bg-dark-bg"],[1,"font-semibold","mb-3","text-white","text-[1.05rem]"],[1,"max-w-xs","leading-normal","text-dark-text-secondary","mb-5","text-[0.74rem]"],[1,"btn","btn-primary",3,"click"],[1,"p-3","border-b","border-border","bg-transparent"],[1,"flex","items-center","cursor-pointer","font-medium","text-white"],["type","checkbox",1,"w-4","h-4","mr-2",3,"ngModelChange","change","ngModel"],[1,"checkmark"],["class","flex items-center cursor-pointer font-medium text-white mt-2",4,"ngIf"],["class","mt-4 border-t border-border pt-3",4,"ngIf"],[4,"ngFor","ngForOf","ngForTrackBy"],["placeholder","Ask me anything...","rows","2",1,"flex-1","font-sans","text-base","resize-y","py-2","px-3","border","border-border","rounded-xl","min-h-[32px]","max-h-[84px]","bg-surface","text-white","transition-all","duration-150","placeholder:text-dark-text-subtle","focus:outline-none","focus:-translate-y-px","focus:border-primary","focus:shadow-[0_0_0_3px_rgba(0,102,204,0.1)]",3,"ngModelChange","keydown","ngModel","disabled"],[1,"flex","items-center","cursor-pointer","font-medium","text-white","mt-2"],["type","checkbox",1,"w-4","h-4","mr-2",3,"ngModelChange","ngModel"],[1,"mt-4","border-t","border-border","pt-3"],[1,"text-sm","font-semibold","m-0","mb-3","text-white"],[1,"flex","flex-wrap","gap-2","mt-2"],["class",`flex items-center cursor-pointer text-sm whitespace-nowrap gap-1 py-1 px-2 384 bg-surface border border-border rounded-sm hover:bg-surface-hover`,3,"title",4,"ngFor","ngForOf"],[1,"flex","items-center","cursor-pointer","text-sm","whitespace-nowrap","gap-1","py-1","px-2","bg-surface","border","border-border","rounded-sm","hover:bg-surface-hover",3,"title"],["type","checkbox",3,"change","checked"],[1,"font-medium"],[1,"text-xs",3,"ngClass"],[3,"ngSwitch"],["class","flex flex-col animate-fade-in-up mb-4",3,"ngClass",4,"ngSwitchCase"],[3,"entry",4,"ngSwitchCase"],[1,"p-3","border-b","border-border"],[1,"text-center","cursor-pointer","relative","flex","items-center","justify-center","border-2","border-dashed","border-border","rounded-md","p-2","transition-all","duration-200","bg-surface-elevated","min-h-[100px]",3,"dragover","dragleave","drop","ngClass"],["class","max-w-sm",4,"ngIf"],["class","flex flex-col items-center w-full gap-3",4,"ngIf"],["class","flex flex-col mt-3 gap-3 p-2 border-t border-border bg-dark-bg",4,"ngIf"],[1,"max-w-sm"],[1,"opacity-80","text-[2.1rem]","mb-3"],[1,"font-semibold","mb-1","text-white","text-[0.95rem]"],[1,"text-dark-text-secondary","mb-1","text-[0.61rem]"],[1,"italic","opacity-70","text-[0.525rem]","mb-3"],["type","file","accept","image/*",2,"display","none",3,"change"],[1,"btn","btn-primary","btn-small",3,"click"],[1,"flex","flex-col","items-center","w-full","gap-3"],[1,"max-w-full","rounded-md","shadow-md","object-contain","max-h-[140px]","w-auto","h-auto",3,"src","alt"],[1,"text-center"],[1,"font-medium","text-white","text-[0.63rem]","mb-1"],[1,"text-dark-text-secondary","text-[0.56rem]"],[1,"flex","flex-col","mt-3","gap-3","p-2","border-t","border-border","bg-dark-bg"],["placeholder","What would you like to know about this image? (Optional - leave blank for general analysis)","rows","3",1,"w-full","font-sans","text-base","resize-y","p-3","border","border-border","rounded-md","min-h-[56px]","max-h-[84px]","bg-surface","text-white","transition-all","duration-150","placeholder:text-dark-text-subtle","focus:outline-none","focus:border-primary","focus:shadow-[0_0_0_3px_rgba(0,102,204,0.1)]",3,"ngModelChange","ngModel"],[1,"btn","btn-primary",3,"click","disabled"],[1,"font-semibold","m-0","mb-3","text-white","text-[0.79rem]","pb-1","border-b","border-border","px-4","pt-3"],[1,"flex-1","overflow-y-auto","p-3","bg-dark-bg","rounded-md","border","border-border","mx-3","mb-3"],[1,"max-w-[85%]","shadow-sm","p-3","backdrop-blur-[10px]","max-md:max-w-[90%]",3,"ngClass"],["class","mb-2",4,"ngIf"],["class","leading-snug whitespace-pre-wrap text-base break-words",4,"ngIf"],["class","mb-1 p-1 rounded-sm text-[0.57rem]",3,"ngClass",4,"ngIf"],[1,"mb-2"],[1,"rounded-sm","shadow-sm","object-contain","max-w-[105px]","max-h-[105px]","w-auto","h-auto","max-md:max-w-[120px]","max-md:max-h-[120px]",3,"src","alt"],[1,"mb-1","p-1","rounded-sm","text-[0.57rem]",3,"ngClass"],[1,"max-w-[85%]","shadow-sm","p-3","backdrop-blur-[10px]","bg-surface","border","border-border","text-white","rounded-xl","rounded-bl-md"]],template:function(r,i){r&1&&(F(0,"div",5)(1,"nav",6)(2,"button",7),_e("click",function(){return i.setActiveTab("rag")}),H(3),L(),F(4,"button",7),_e("click",function(){return i.setActiveTab("chat")}),H(5," \u{1F4AC} Chat & MCP (Model Context Protocol) "),L(),F(6,"button",7),_e("click",function(){return i.setActiveTab("vision")}),H(7," \u{1F441}\uFE0F Vision "),L()(),me(8,Yle,26,17,"div",8)(9,oue,29,12,"div",8)(10,Eue,18,11,"div",8),L()),r&2&&(j(2),kr("active",i.activeTab==="rag"),j(),Ut(" \u{1F50D} RAG (Retrieval-Augmented Generation) (",i.documents.length,") "),j(),kr("active",i.activeTab==="chat"),j(2),kr("active",i.activeTab==="vision"),j(2),B("ngIf",i.activeTab==="rag"),j(),B("ngIf",i.activeTab==="chat"),j(),B("ngIf",i.activeTab==="vision"))},dependencies:[Ai,Gm,Wm,xl,TE,JN,Iu,n_,r_,bu,Xh,Eu,wu,bc,Ej,wj,Gj],styles:['.tab-nav[_ngcontent-%COMP%]{scrollbar-width:none}.tab-nav[_ngcontent-%COMP%]::-webkit-scrollbar{display:none}.tab-btn[_ngcontent-%COMP%]:before{position:absolute;bottom:0;left:0;right:0;content:"";height:2px;background:#06c;
384transform:scaleX(0);transition:transform .15s ease}.tab-btn.active[_ngcontent-%COMP%]{font-weight:600;color:#06c;background:#111}.tab-btn.active[_ngcontent-%COMP%]:before{transform:scaleX(1)}.upload-area[_ngcontent-%COMP%]:before{position:absolute;inset:0;opacity:0;content:"";background:linear-gradient(135deg,#06c,#00b4a6);transition:opacity .2s ease}.upload-area.drag-over[_ngcontent-%COMP%]{--tw-shadow: 0 10px 15px -3px rgba(0, 0, 0, .1), 0 4px 6px -2px rgba(0, 0, 0, .05);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -2px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow);border-color:#06c;background:#0066cc26;transform:scale(1.02)}.upload-area.drag-over[_ngcontent-%COMP%]:before{opacity:.05}.upload-area.uploading[_ngcontent-%COMP%]{--tw-shadow: 0 4px 6px -1px rgba(0, 0, 0, .1), 0 2px 4px -1px rgba(0, 0, 0, .06);--tw-shadow-colored: 0 4px 6px -1px var(--tw-shadow-color), 0 2px 4px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-sha
384dow);border-color:#10b981;background:#111}.upload-area.disabled[_ngcontent-%COMP%]{cursor:not-allowed;opacity:.6;background:#f9fafb}.upload-area.disabled[_ngcontent-%COMP%] .upload-content[_ngcontent-%COMP%]{pointer-events:none}.document-item[_ngcontent-%COMP%]:before{position:absolute;left:0;top:0;bottom:0;content:"";width:3px;background:#06c;transform:scaleY(0);transition:transform .15s ease}.document-item.selected[_ngcontent-%COMP%]:before{transform:scaleY(1)}.document-list[_ngcontent-%COMP%]{scrollbar-width:thin;scrollbar-color:rgba(0,102,204,.3) rgba(0,0,0,.1)}.document-list[_ngcontent-%COMP%]::-webkit-scrollbar{width:.5rem}.document-list[_ngcontent-%COMP%]::-webkit-scrollbar-track{border-radius:.25rem;background:#0000000d;margin:2px}.document-list[_ngcontent-%COMP%]::-webkit-scrollbar-thumb{border-radius:.25rem;background:#0066cc4d;border:1px solid rgba(0,102,204,.1)}.document-list[_ngcontent-%COMP%]::-webkit-scrollbar-thumb:hover{background:#0066cc80;border-color:#06c3}.document-list[_ngcontent-%COMP%]::-webkit-scrollbar-thumb:active{background:#06c}.typing-indicator[_ngcontent-%COMP%] span[_ngcontent-%COMP%]{animation:_ngcontent-%COMP%_typing 1.4s infinite}.typing-indicator[_ngcontent-%COMP%] span[_ngcontent-%COMP%]:nth-child(2){animation-delay:.2s}.typing-indicator[_ngcontent-%COMP%] span[_ngcontent-%COMP%]:nth-child(3){animation-delay:.4s}@keyframes _ngcontent-%COMP%_typing{0%,60%,to{opacity:.3}30%{opacity:1}}.btn-small[_ngcontent-%COMP%]{font-size:.75rem;line-height:1rem;padding:.5rem 1rem;gap:.25rem}.btn-danger[_ngcontent-%COMP%]{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1));background:#ef4444;border:1px solid #EF4444}.btn-danger[_ngcontent-%COMP%]:hover:not(:disabled){background:#dc2626;border-color:#dc2626}.btn-danger[_ngcontent-%COMP%]:disabled{cursor:not-allowed;opacity:.6}']})}}return n})();var F3=[{path:"",component:L3},{path:"**",redirectTo:""}];function Iue(n){let e=n.replace(/<script[\s\S]*?<\/script>/gi,"");return e=e.replace(/\s+on\w+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi,""),e=e.replace(/(href|xlink:href|src)\s*=\s*(?:"javascript:[^"]*"|'javascript:[^']*')/gi,'$1=""'),e=e.replace(/<foreignObject[\s\S]*?<\/foreignObject>/gi,""),e=e.replace(/<use[^>]+href\s*=\s*(?:"https?:[^"]*"|'https?:[^']*')[^>]*\/?>/gi,""),e}function Tue(){let n=new Qr,e=n.code?.bind(n);return n.code=(t,r,i)=>{if((r||"").trim().toLowerCase()==="svg"){let o=t.trim();if(!o.toLowerCase().startsWith("<svg"))return e?e(t,r,i??!1)??"":t;try{let a=Iue(o),c=Aue(a),l=a.match(/<title>([\s\S]*?)<\/title>/i),u=Cue(l?l[1]:"Generated SVG graphic");return` 385<div class="svg-embedded-block"><img class="svg-embedded-image" src="${c}" alt="${u}"></div> 386`}catch{return e?e(t,r,i??!1)??"":t}}return e?e(t,r,i??!1)??"":t},{renderer:n}}function Aue(n){if(typeof window>"u"||typeof btoa!="function")return`data:image/svg+xml;utf8,${encodeURIComponent(n)}`;try{let e=new TextEncoder().encode(n),t=Array.from(e,i=>String.fromCharCode(i)).join("");return`data:image/svg+xml;base64,${btoa(t)}`}catch{return`data:image/svg+xml;utf8,${encodeURIComponent(n)}`}}function Cue(n){return n.replace(/\s+/g," ").replace(/"/g,""").trim()}var V3={providers:[eL(F3),uO(),bS(),{provide:vS,useFactory:Tue},SL(()=>xL(Rn.firebase)),yF(()=>{let n=vF();if(Rn.useEmulator)try{_F(n,"http://localhost:9099")}catch(e){console.warn("Auth emulator connection failed:",e)}return n}),vV(()=>{let n=wV();return Rn.useEmulator&&bV(n,"localhost",8080),n}),XV(()=>{let n=ZV();return Rn.useEmulator&&QV(n,"localhost",9199),n}),oj(()=>{let n=cj();if(Rn.useEmulator)try{aj(n,"localhost",5001)}catch(e){console.warn("Functions emulator connection failed, might already be connected:",e)}return n})]};function Sue(n,e){if(n&1&&(F(0,"option",8),H(1),L()),n&2){let t=e.$implicit;B("value",t),j(),Ut(" ",t," ")}}function xue(n,e){if(n&1&&(F(0,"option",8),H(1),L()),n&2){let t=e.$implicit,r=G(2);B("value",t),j(),Ut(" ",r.getShortModelName(t)," ")}}function Due(n,e){if(n&1){let t=St();F(0,"div",4)(1,"label",5),H(2),L(),F(3,"select",6),fn("ngModelChange",function(i){let s=ge(t).$implicit,o=G();return wn(o.selection[s.toLowerCase()].provider,i)||(o.selection[s.toLowerCase()].provider=i),ye(i)}),_e("ngModelChange",function(){let i=ge(t).$implicit,s=G();return ye(s.onProviderChange(i))}),me(4,Sue,2,2,"option",7),L(),F(5,"select",6),fn("ngModelChange",function(i){let s=ge(t).$implicit,o=G();return wn(o.selection[s.toLowerCase()].model,i)||(o.selection[s.toLowerCase()].model=i),ye(i)}),_e("ngModelChange",function(){ge(t);let i=G();return ye(i.onSelectionChange())}),me(6,xue,2,2,"option",7),L()()}if(n&2){let t=e.$implicit,r=G();j(2),Ut(" ",r.getDisplayName(t),": "),j(),hn("ngModel",r.selection[t.toLowerCase()].provider),j(),B("ngForOf",r.getProviders(t)),j(),hn("ngModel",r.selection[t.toLowerCase()].model),j(),B("ngForOf",r.getAvailableModels(t))}}var j3=(()=>{class n{constructor(t,r){this.modelsConfig=t,this.globalModelSelection=r,this.appName="rag",this.showCurrentSelection=!0,this.selectionChange=new $t,this.selection={},this.modelTypes=[]}ngOnInit(){this.initializeComponent(),this.subscribeToMcpChanges()}ngOnChanges(t){t.appName&&this.initializeComponent()}ngOnDestroy(){this.mcpSubscription&&this.mcpSubscription.unsubscribe()}initializeComponent(){this.modelTypes=this.globalModelSelection.getFilteredModelTypes(this.appName),this.resetToDefaults()}subscribeToMcpChanges(){this.mcpSubscription=this.globalModelSelection.mcpEnabled$.subscribe(()=>{this.appName==="chat"&&(this.modelTypes=this.globalModelSelection.getFilteredModelTypes(this.appName),this.resetToDefaults())})}getDisplayName(t){return t.toLowerCase()}getProviders(t){return this.modelsConfig.getProviders(this.appName,t)}getAvailableModels(t){let r=this.selection[t.toLowerCase()]?.provider;return r?this.modelsConfig.getModels(this.appName,t,r):[]}resetToDefaults(){let t=this.modelsConfig.getDefaultSelection(this.appName);t&&(this.selection=_({},t),this.onSelectionChange())}onProviderChange(t){let r=t.toLowerCase(),i=this.getAvailableModels(t);i.length>0&&(this.selection[r].model=i[0]),this.onSelectionChange()}onSelectionChange(){this.selectionChange.emit(_({},this.selection))}getShortModelName(t){let r=t.split("/");return r[r.length-1]||t}static{this.\u0275fac=function(r){return new(r||n)(oe(ob),oe(Cs))}}static{this.\u0275cmp=xr({type:n,selectors:[["app-dynamic-model-selector"]],inputs:{appName:"appName",showCurrentSelection:"showCurrentSelection"},outputs:{selectionChange:"selectionChange"},standalone:!0,features:[Ei,Pr],decls:5,vars:1,consts:[[1,"rounded-lg","px-5","py-4","shadow-sm","border","border-border","bg-surface","backdrop-blur-sm","transition-all","duration-150","hover:shadow-md","hover:border-primary"],[1,"flex","items-center","flex-nowrap","w-full","gap-4","max-lg:flex-wrap","max-lg:gap-3","max-md:flex-col","max-md:items-stretch","max-md:gap-3"],["class",`flex items-center flex-1 gap-2 min-w-[200px] 387 max-lg:min-w-[180px] max-md:min-w-0`,4,"ngFor","ngForOf"],["t
387itle","Reset to Defaults",1,"flex","items-center","justify-center","cursor-pointer","text-base","leading-none","flex-shrink-0","bg-surface","border","border-border","text-dark-text-secondary","py-2","px-3","rounded-md","w-8","h-8","transition-all","duration-150","hover:rotate-180","hover:bg-surface-hover","hover:border-primary","hover:text-primary","focus:outline-none","focus:shadow-[0_0_0_2px_rgba(0,102,204,0.2)]","max-md:self-center","max-md:w-8","max-md:py-2","max-md:px-3",3,"click"],[1,"flex","items-center","flex-1","gap-2","min-w-[200px]","max-lg:min-w-[180px]","max-md:min-w-0"],[1,"text-xs","font-semibold","uppercase","tracking-wider","flex-shrink-0","min-w-[45px]","text-dark-text-secondary","max-md:min-w-[50px]"],[1,"model-select","flex-1","font-sans","appearance-none","py-2","px-3","border","border-border","rounded-md","text-[0.8125rem]","bg-surface-elevated","text-white","min-w-[120px]","transition-all","duration-150","pr-7","shadow-[inset_0_1px_3px_rgba(0,0,0,0.2)]","hover:border-primary","hover:bg-surface-elevated","hover:shadow-[inset_0_1px_3px_rgba(0,0,0,0.3)]","focus:outline-none","focus:border-primary","focus:shadow-[0_0_0_3px_rgba(0,102,204,0.3)]","focus:bg-surface-elevated","max-md:min-w-0",3,"ngModelChange","ngModel"],[3,"value",4,"ngFor","ngForOf"],[3,"value"]],template:function(r,i){r&1&&(F(0,"div",0)(1,"div",1),me(2,Due,7,5,"div",2),F(3,"button",3),_e("click",function(){return i.resetToDefaults()}),H(4," \u27F2 "),L()()()),r&2&&(j(2),B("ngForOf",i.modelTypes))},dependencies:[Ai,Wm,Iu,n_,r_,Eu,wu,bc],styles:[`.model-select[_ngcontent-%COMP%]{background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%23b3b3b3' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");background-position:right .5rem center;background-repeat:no-repeat;background-size:1rem}select[_ngcontent-%COMP%] option[_ngcontent-%COMP%]{border-style:none;background:#1a1a1a;color:#fff;padding:.5rem}select[_ngcontent-%COMP%] option[_ngcontent-%COMP%]:checked{background:#06c;color:#fff}select[_ngcontent-%COMP%] option[_ngcontent-%COMP%]:hover{background:#222;color:#fff}`]})}}return n})();function Rue(n,e){if(n&1){let t=St();F(0,"div",19)(1,"div",20)(2,"div",21)(3,"label",22),H(4," Temp: "),F(5,"div",23)(6,"input",24),fn("ngModelChange",function(i){ge(t);let s=G();return wn(s.temperature,i)||(s.temperature=i),ye(i)}),_e("change",function(){ge(t);let i=G();return ye(i.onTemperatureChange())}),L(),F(7,"input",25),fn("ngModelChange",function(i){ge(t);let s=G();return wn(s.temperature,i)||(s.temperature=i),ye(i)}),_e("change",function(){ge(t);let i=G();return ye(i.onTemperatureChange())}),L()()()(),F(8,"div",21)(9,"label",26),H(10," Seed: "),F(11,"input",27),fn("ngModelChange",function(i){ge(t);let s=G();return wn(s.seed,i)||(s.seed=i),ye(i)}),_e("change",function(){ge(t);let i=G();return ye(i.onSeedChange())}),L()(),F(12,"label",28)(13,"input",29),fn("ngModelChange",function(i){ge(t);let s=G();return wn(s.memoryEnabled,i)||(s.memoryEnabled=i),ye(i)}),_e("change",function(){ge(t);let i=G();return ye(i.onMemoryToggle())}),L(),yt(14,"span",30),H(15," Memory "),L(),F(16,"label",31)(17,"input",29),fn("ngModelChange",function(i){ge(t);let s=G();return wn(s.showPrompts,i)||(s.showPrompts=i),ye(i)}),_e("change",function(){ge(t);let i=G();return ye(i.onShowPromptsToggle())}),L(),yt(18,"span",30),H(19," Show Prompts "),L()()(),F(20,"div",32)(21,"app-dynamic-model-selector",33),_e("selectionChange",function(i){ge(t);let s=G();return ye(s.onGlobalModelSelectionChange(i))}),L()()()}if(n&2){let t=G();j(6),hn("ngModel",t.temperature),j(),hn("ngModel",t.temperature),j(4),hn("ngModel",t.seed),j(2),hn("ngModel",t.memoryEnabled),j(4),hn("ngModel",t.showPrompts),j(4),B("appName",t.currentAppName)("showCurrentSelection",!1)}}function kue(n,e){if(n&1){let t=St();F(0,"div",34)(1,"div",35),yt(2,"div",36),F(3,"span",37),H(4),L()(),F(5,"button",38),_e("click",function(){ge(t);let i=G();return ye(i.signOut())}),H(6,"Sign Out"),L()()}if(n&2){let t=e.ngIf;j(4),Zt(t.displayName||t.email)}}function Pue(n,e){n&1&&(F(0,"div",41),yt(1,"div",42),F(2,"span",37),H(3,"Connecting..."),L()())}function Mue(n,e){if(n&1){let t=St();F(0,"button",43),_e("click",function(){ge(t);let i=G(2);return ye(i.signInWithGoogle())}),H(1," Sign in with Google "),L()}}function Nue(n,e){if(n&1&&(F(0,"div",34),me(1,Pue,4,0,"div",39)(2,Mue,2,0,"button",40),L()),n&2){let t=G();j(),B("ngIf",t.loading),j(),B("ngIf",!t.loading)}}function Oue(n,e){n&1&&(F(0,"main",44),yt(1,"router-outlet"),L())}function Lue(n,e){n&1&&(F(0,"span"),H(1,"Sign in with Google"),L())}function Fue(n,e){n&1&&(F(0,"span",41),yt(1,"div",42),H(2," Signing in... "),L())}function Vue(n,e){if(n&1){let t=St();F(0,"div",45)(1,"div",46)(2,"div",47),V0(),F(3,"svg",48),yt(4,"rect",49)(5,"path",50)(6,"circle",51)(7,"circle",52),L()(),j0(),F(8,"h2",53),H(9,"Welcome to AI Playground"),L(),F(10,"p",54),H(11," Start exploring RAG, MCP, Vision and more with open(and closed-) source large language models. Please do not share sensitive data. The Google sign-in acts as a captcha mechanism to prevent abuse, I'm not storing any personal data. Please sign in with your Google account to continue. "),L(),F(12,"button",55),_e("click",function(){ge(t);let i=G();return ye(i.signInWithGoogle())}),me(13,Lue,2,0,"span",56)(14,Fue,3,0,"span",39),L()()()}if(n&2){let t=G();j(12),B("disabled",t.loading),j(),B("ngIf",!t.loading),j(),B("ngIf",t.loading)}}var $3=(()=>{class n{constructor(t,r,i,s,o){this.authService=t,this.globalModelSelection=r,this.router=i,this.promptLogging=s,this.logger=o,this.title="AI Playground",this.loading=!1,this.currentAppName="rag",this.showPrompts=!1,this.memoryEnabled=!1,this.temperature=.7,this.seed=-1,this.destroy$=new mt,this.user$=this.authService.user$}ngOnInit(){this.globalModelSelection.currentApp$.pipe(pi(this.destroy$)).subscribe(t=>{this.currentAppName=t}),this.globalModelSelection.updateModelParams({temperature:this.temperature,seed:this.seed,memoryEnabled:this.memoryEnabled})}signInWithGoogle(){return m(this,null,function*(){this.loading=!0;try{yield this.authService.signInWithGoogle()}catch(t){this.logger.error("Failed to sign in with Google",t)}finally{this.loading=!1}})}signOut(){return m(this,null,function*(){try{yield this.authService.signOut()}catch(t){this.logger.error("Failed to sign out",t)}})}onGlobalModelSelectionChange(t){this.logger.debug("App component received model selection change",t),this.globalModelSelection.updateSelection(t)}onShowPromptsToggle(){this.promptLogging.enableLogging(this.showPrompts)}onMemoryToggle(){this.globalModelSelection.updateModelParams({temperature:this.temperature,seed:this.seed,memoryEnabled:this.memoryEnabled})}onTemperatureChange(){this.temperature=Math.max(0,Math.min(1,this.temperature)),this.globalModelSelection.updateModelParams({temperature:this.temperature,seed:this.seed,memoryEnabled:this.memoryEnabled})}onSeedChange(){this.seed===-1||(this.seed=Math.max(-1,Math.min(2147483647,Math.floor(this.seed||-1)))),this.globalModelSelection.updateModelParams({temperature:this.temperature,seed:this.seed,memoryEnabled:this.memoryEnabled})}ngOnDestroy(){this.destroy$.next(),this.destroy$.complete()}static{this.\u0275fac=function(r){return new(r||n)(oe(lb),oe(Cs),oe(bg),oe(Zr),oe(Kn))}}static{this.\u0275cmp=xr({type:n,selectors:[["app-root"]],standalone:!0,features:[Pr],decls:27,vars:12,consts:[["signInButton",""],["authRequired",""],[1,"min-h-screen","flex","flex-col","bg-dark-bg"],[1,"relative","shadow-sm","bg-surface","border-b","border-border","z-[100]"],[1,"flex","items-center","justify-between","w-full","p-4","px-6","gap-6","max-lg:px-4","max-lg:gap-4","max-md:flex-col","max-md:items-stretch","max-md:gap-4","max-[480px]:p-3"],[1,"flex","items-center","flex-shrink-0","order-1","gap-3","max-md:justify-center"],[1,"flex","items-center","justify-center","text-primary"],["width","32","height","32","viewBox","0 0 32 32","fill","none","xmlns","http://www.w3.org/2000/svg"],["width","32","height","32","rx","8","fill","currentColor","opacity","0.1"],["d","M8 12h16M8 16h16M8 20h10","stroke","currentColor","stroke-width","2","stroke-linecap","round"],["cx","20","cy","20","r","3","stroke","currentColor","stroke-width","2","fill","none"],[1,"text-2xl","font-bold","m-0","tracking-tight","text-white","max-[480px]:text-xl"],[1,"flex","flex-col","order-2","gap-1","max-md:flex-row","max-md:justify-center","max-md:gap-4"],["href","https://www.vanguardsignals.com","target","_blank","rel","noopener noreferrer",1,"no-underline","text-[0.8125rem]","font-medium","text-dark-text-secondary","transition-all","duration-150","py-1","px-2","rounded-sm","hover:no-underline","hover:text-primary","hover:bg-surface-hover"],["href","https://github.com/ugubser/AIPlayground/blob/main/instructions.md","target","_blank","rel","noopener noreferrer",1,"no-underline","text-[0.8125rem]","font-medium","text-dark-text-secondary","transition-all","duration-150","py-1","px-2","rounded-sm","hover:no-underline","hover:text-primary","hover:bg-surface-hover"],["class",`flex-1 flex items-center justify-center order-3 mx-6 gap-4 388 max-lg:mx-4 max-md:mx-0`,4,"ngIf"],[1,"flex-shrink-0","order-4","ml-auto","max-md:self-end","max-md:ml-0"],["class","flex items-center gap-4",4,"ngIf","ngIfElse"],["class","flex-1 relative bg-dark-bg",4,"ngIf","ngIfElse"],[1,"flex-1","flex","items-center","justify-center","order-3","mx-6","gap-4","max-lg:mx-4","max-md:mx-0"],[1,"flex","flex-col","flex-shrink-0","gap-1","max-md:gap-2"],[1,"flex","items-center","gap-4","max-md:flex-col","max-md:items-stretch","max-md:gap-2"],["title","Controls randomness of responses. 0 = deterministic, 1 = very random. Lower values (0.1-0.3) for focused tasks, higher values (0.7-0.9) for creative tasks.",1,"flex","items-center","text-[0.8125rem]","font-medium","cursor-pointer","select-none","whitespace-nowrap","gap-2","text-dark-text-secondary","max-md:justify-between"],[1,"flex","items-center","gap-2","max-md:flex-1","max-md:justify-end"],["type","range","min","0","max","1","step","0.1",1,"temp-slider","w-16","h-5","appearance-none","rounded-full","outline-none","cursor-pointer","bg-gray-200","opacity-70","transition-opacity","duration-150","hover:opacity-100","max-md:w-20",3,"ngModelChange","change","ngModel"],["type","number","min","0","max","1","step","0.1",1,"w-12","text-xs","text-center","py-1","px-2","border","border-border","rounded-sm","bg-surface","text-white","transition-all","duration-150","focus:outline-none","focus:border-primary","focus:shadow-[0_0_0_1px_#0066CC]",3,"ngModelChange","change","ngModel"],["title","Random seed for reproducible responses. Set to -1 for random seed, or any positive number for deterministic output. Same seed + same input = identical response.",1,"flex","items-center","text-[0.8125rem]","font-medium","cursor-pointer","select-none","whitespace-nowrap","gap-2","text-dark-text-secondary","max-md:justify-between"],["type","number","placeholder","-1 (random)",1,"seed-input","w-20","text-xs","text-center","py-1","px-2","border","border-border","rounded-sm","bg-surface","text-white","transition-all","duration-150","focus:outline-none","focus:border-primary","focus:shadow-[0_0_0_1px_#0066CC]",3,"ngModelChange","change","ngModel"],["title","Enable conversation memory. When on, previous messages are sent to the LLM for multi-turn context.",1,"dark-checkbox","flex","items-center","text-[0.8125rem]","font-medium","cursor-pointer","select-none","gap-2","text-dark-text-secondary"],["type","checkbox",3,"ngModelChange","change","ngModel"],[1,"checkmark"],[1,"dark-checkbox","flex","items-center","text-[0.8125rem]","font-medium","cursor-pointer","select-none","gap-2","text-dark-text-secondary"],[1,"w-full","max-w-3xl","max-lg:max-w-xl","max-md:max-w-none"],[3,"selectionChange","appName","showCurrentSelection"],[1,"flex","items-center","gap-4"],[1,"flex","items-center","gap-2","py-2","px-4","bg-gray-50","rounded-md","border","border-border-subtle"],[1,"rounded-full","w-2","h-2","bg-success","shadow-[0_0_0_2px_#111111]"],[1,"text-sm","font-medium","text-dark-text-secondary"],[1,"btn","btn-ghost",3,"click"],["class","flex items-center gap-2",4,"ngIf"],["class","btn btn-primary",3,"click",4,"ngIf"],[1,"flex","items-center","gap-2"],[1,"w-4","h-4","rounded-full","animate-spin","border-2","border-gray-200","border-t-2","border-t-primary"],[1,"btn","btn-primary",3,"click"],[1,"flex-1","relative","bg-dark-bg"],[1,"flex","items-center","justify-center","min-h-[calc(100vh-120px)]","p-8","bg-dark-bg","max-md:p-4","max-[480px]:p-2"],[1,"max-w-md","text-center","shadow-lg","py-12","px-8","bg-surface","rounded-2xl","border","border-border","max-md:py-8","max-md:px-6","max-md:m-4","max-[480px]:py-6","max-[480px]:px-4","max-[480px]:m-2"],[1,"flex","items-center","justify-center","mx-auto","mb-6"],["width","64","height","64","viewBox","0 0 64 64","fill","none","xmlns","http://www.w3.org/2000/svg"],["width","64","height","64","rx","16","fill","var(--color-primary)","opacity","0.1"],["d","M20 28h24M20 32h24M20 36h16","stroke","var(--color-primary)","stroke-width","2","stroke-linecap","round"],["cx","40","cy","36","r","6","stroke","var(--color-primary)","stroke-width","2","fill","none"],["cx","40","cy","36","r","2","fill","var(--color-primary)"],[1,"text-3xl","font-bold","tracking-tight","text-white","mb-4","max-md:text-2xl","max-[480px]:text-xl"],[1,"text-lg","leading-relaxed","text-dark-text-secondary","mb-8","max-md:text-base"],[1,"btn","btn-primary","btn-lg",3,"click","disabled"],[4,"ngIf"]],template:function(r,i){if(r&1&&(F(0,"div",2)(1,"header",3)(2,"div",4)(3,"div",5)(4,"div",6),V0(),F(5,"svg",7),yt(6,"rect",8)(7,"path",9)(8,"circle",10),L()(),j0(),F(9,"h1",11),H(10),L()(),F(11,"div",12)(12,"a",13),H(13,"Contact"),L(),F(14,"a",14),H(15,"Instructions"),L()(),me(16,Rue,22,7,"div",15),Yi(17,"async"),F(18,"div",16),me(19,kue,7,1,"div",17),Yi(20,"async"),me(21,Nue,3,2,"ng-template",null,0,hE),L()()(),me(23,Oue,2,0,"main",18),Yi(24,"async"),me(25,Vue,15,3,"
388ng-template",null,1,hE),L()),r&2){let s=Al(22),o=Al(26);j(10),Zt(i.title),j(6),B("ngIf",Xi(17,6,i.user$)),j(3),B("ngIf",Xi(20,8,i.user$))("ngIfElse",s),j(4),B("ngIf",Xi(24,10,i.user$))("ngIfElse",o)}},dependencies:[Ai,xl,Km,Iu,bu,SS,xS,Xh,wu,RS,DS,bc,vI,j3],styles:['.temp-slider[_ngcontent-%COMP%]::-webkit-slider-thumb{height:1rem;width:1rem;cursor:pointer;appearance:none;border-radius:9999px;background:#06c;border:2px solid #111111;box-shadow:0 1px 3px #0003}.temp-slider[_ngcontent-%COMP%]::-moz-range-thumb{height:1rem;width:1rem;cursor:pointer;border-radius:9999px;background:#06c;border:2px solid #111111;box-shadow:0 1px 3px #0003}.seed-input[_ngcontent-%COMP%]::placeholder{color:gray;font-size:.7rem}.dark-checkbox[_ngcontent-%COMP%] input[type=checkbox][_ngcontent-%COMP%]{position:relative;height:.875rem;width:.875rem;cursor:pointer;appearance:none;border-radius:.375rem;border:2px solid #333333;background:#111;transition:all .15s ease}.dark-checkbox[_ngcontent-%COMP%] input[type=checkbox][_ngcontent-%COMP%]:checked{background:#06c;border-color:#06c}.dark-checkbox[_ngcontent-%COMP%] input[type=checkbox][_ngcontent-%COMP%]:checked:after{position:absolute;font-weight:700;--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1));content:"\\2713";top:-2px;left:1px;font-size:10px}.dark-checkbox[_ngcontent-%COMP%]:hover input[type=checkbox][_ngcontent-%COMP%]{border-color:#06c}']})}}return n})();_O($3,V3).catch(n=>console.error(n));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.