tressi
Version:
Deterministic load testing for API performance validation.
3 lines • 86.1 kB
JavaScript
import{a as Ne,b as Wi,c as Ui,d as Yi,e as Zi,f as hn}from"./chunk-4NUIGNTM.js";import{a as et}from"./chunk-3VRQ5HW3.js";import{a as nt}from"./chunk-NPEBJWNR.js";import{a as ji,b as $i,c as zi,d as Qi}from"./chunk-6LEULM43.js";import{a as Xi}from"./chunk-2ZUXPUVI.js";import{a as Ii,b as Gi}from"./chunk-ELI7JHGH.js";import"./chunk-2NHEPAC5.js";import"./chunk-5PTWAMZ6.js";import{c as qi,d as Bn,e as Vi,f as Oi,g as Hi}from"./chunk-RQPLME55.js";import"./chunk-2IBU6HRE.js";import{a as ke,b as ne}from"./chunk-OVBUA5RI.js";import{c as Fi,g as Bi,n as Ki,v as Ji,x as Pi}from"./chunk-BEQIQLT5.js";import{$ as T,$a as U,Bb as M,Bc as Fn,Db as h,Ka as d,Kb as Di,Lb as Ai,Mb as kn,Nb as wi,O as H,Ob as Nn,Pb as Ti,Qb as c,R as ln,Rb as xi,Sb as J,Ta as Si,Tb as Se,U as sn,Ub as Me,Vb as Ee,W as w,Wa as z,Wb as pn,Xa as W,Yb as Ln,_ as xn,_b as Ri,a as Tn,aa as x,ba as We,bb as cn,da as dn,db as Mi,eb as Ei,ec as P,fc as C,gb as Rn,gc as De,hc as ki,jc as re,ka as B,kc as q,lb as N,ma as pe,mb as L,mc as Ni,na as vi,nb as mn,ob as Y,pb as K,qa as un,qb as I,rb as f,sa as _i,sb as s,tb as o,u as bi,ub as D,uc as Li,zb as Z}from"./chunk-W6IDPYNF.js";import"./chunk-PTIQXOVT.js";import"./chunk-ZPCMWKEN.js";import{a as S,b as R,c as gi,e as Ci}from"./chunk-I4MTPUBM.js";var it=gi((Kn,In)=>{"use strict";(function(i,e){typeof Kn=="object"&&typeof In<"u"?In.exports=e():typeof define=="function"&&define.amd?define(e):(i=typeof globalThis<"u"?globalThis:i||self).dayjs=e()})(Kn,function(){"use strict";var i=1e3,e=6e4,n=36e5,t="millisecond",a="second",r="minute",l="hour",y="day",E="week",A="month",j="quarter",ae="year",se="date",ge="Invalid Date",Ve=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,Oe=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,He={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(b){var p=["th","st","nd","rd"],u=b%100;return"["+b+(p[(u-20)%10]||p[u]||p[0])+"]"}},je=function(b,p,u){var g=String(b);return!g||g.length>=p?b:""+Array(p+1-g.length).join(u)+b},Ce={s:je,z:function(b){var p=-b.utcOffset(),u=Math.abs(p),g=Math.floor(u/60),m=u%60;return(p<=0?"+":"-")+je(g,2,"0")+":"+je(m,2,"0")},m:function b(p,u){if(p.date()<u.date())return-b(u,p);var g=12*(u.year()-p.year())+(u.month()-p.month()),m=p.clone().add(g,A),v=u-m<0,_=p.clone().add(g+(v?-1:1),A);return+(-(g+(u-m)/(v?m-_:_-m))||0)},a:function(b){return b<0?Math.ceil(b)||0:Math.floor(b)},p:function(b){return{M:A,y:ae,w:E,d:y,D:se,h:l,m:r,s:a,ms:t,Q:j}[b]||String(b||"").toLowerCase().replace(/s$/,"")},u:function(b){return b===void 0}},Q="en",X={};X[Q]=He;var xe="$isDayjsObject",be=function(b){return b instanceof rn||!(!b||!b[xe])},an=function b(p,u,g){var m;if(!p)return Q;if(typeof p=="string"){var v=p.toLowerCase();X[v]&&(m=v),u&&(X[v]=u,m=v);var _=p.split("-");if(!m&&_.length>1)return b(_[0])}else{var F=p.name;X[F]=p,m=F}return!g&&m&&(Q=m),m||!g&&Q},V=function(b,p){if(be(b))return b.clone();var u=typeof p=="object"?p:{};return u.date=b,u.args=arguments,new rn(u)},k=Ce;k.l=an,k.i=be,k.w=function(b,p){return V(b,{locale:p.$L,utc:p.$u,x:p.$x,$offset:p.$offset})};var rn=(function(){function b(u){this.$L=an(u.locale,null,!0),this.parse(u),this.$x=this.$x||u.x||{},this[xe]=!0}var p=b.prototype;return p.parse=function(u){this.$d=(function(g){var m=g.date,v=g.utc;if(m===null)return new Date(NaN);if(k.u(m))return new Date;if(m instanceof Date)return new Date(m);if(typeof m=="string"&&!/Z$/i.test(m)){var _=m.match(Ve);if(_){var F=_[2]-1||0,G=(_[7]||"0").substring(0,3);return v?new Date(Date.UTC(_[1],F,_[3]||1,_[4]||0,_[5]||0,_[6]||0,G)):new Date(_[1],F,_[3]||1,_[4]||0,_[5]||0,_[6]||0,G)}}return new Date(m)})(u),this.init()},p.init=function(){var u=this.$d;this.$y=u.getFullYear(),this.$M=u.getMonth(),this.$D=u.getDate(),this.$W=u.getDay(),this.$H=u.getHours(),this.$m=u.getMinutes(),this.$s=u.getSeconds(),this.$ms=u.getMilliseconds()},p.$utils=function(){return k},p.isValid=function(){return this.$d.toString()!==ge},p.isSame=function(u,g){var m=V(u);return this.startOf(g)<=m&&m<=this.endOf(g)},p.isAfter=function(u,g){return V(u)<this.startOf(g)},p.isBefore=function(u,g){return this.endOf(g)<V(u)},p.$g=function(u,g,m){return k.u(u)?this[g]:this.set(m,u)},p.unix=function(){return Math.floor(this.valueOf()/1e3)},p.valueOf=function(){return this.$d.getTime()},p.startOf=function(u,g){var m=this,v=!!k.u(g)||g,_=k.p(u),F=function(_e,ee){var me=k.w(m.$u?Date.UTC(m.$y,ee,_e):new Date(m.$y,ee,_e),m);return v?me:me.endOf(y)},G=function(_e,ee){return k.w(m.toDate()[_e].apply(m.toDate("s"),(v?[0,0,0,0]:[23,59,59,999]).slice(ee)),m)},O=this.$W,$=this.$M,te=this.$D,Re="set"+(this.$u?"UTC":"");switch(_){case ae:return v?F(1,0):F(31,11);case A:return v?F(1,$):F(0,$+1);case E:var ve=this.$locale().weekStart||0,$e=(O<ve?O+7:O)-ve;return F(v?te-$e:te+(6-$e),$);case y:case se:return G(Re+"Hours",0);case l:return G(Re+"Minutes",1);case r:return G(Re+"Seconds",2);case a:return G(Re+"Milliseconds",3);default:return this.clone()}},p.endOf=function(u){return this.startOf(u,!1)},p.$set=function(u,g){var m,v=k.p(u),_="set"+(this.$u?"UTC":""),F=(m={},m[y]=_+"Date",m[se]=_+"Date",m[A]=_+"Month",m[ae]=_+"FullYear",m[l]=_+"Hours",m[r]=_+"Minutes",m[a]=_+"Seconds",m[t]=_+"Milliseconds",m)[v],G=v===y?this.$D+(g-this.$W):g;if(v===A||v===ae){var O=this.clone().set(se,1);O.$d[F](G),O.init(),this.$d=O.set(se,Math.min(this.$D,O.daysInMonth())).$d}else F&&this.$d[F](G);return this.init(),this},p.set=function(u,g){return this.clone().$set(u,g)},p.get=function(u){return this[k.p(u)]()},p.add=function(u,g){var m,v=this;u=Number(u);var _=k.p(g),F=function($){var te=V(v);return k.w(te.date(te.date()+Math.round($*u)),v)};if(_===A)return this.set(A,this.$M+u);if(_===ae)return this.set(ae,this.$y+u);if(_===y)return F(1);if(_===E)return F(7);var G=(m={},m[r]=e,m[l]=n,m[a]=i,m)[_]||1,O=this.$d.getTime()+u*G;return k.w(O,this)},p.subtract=function(u,g){return this.add(-1*u,g)},p.format=function(u){var g=this,m=this.$locale();if(!this.isValid())return m.invalidDate||ge;var v=u||"YYYY-MM-DDTHH:mm:ssZ",_=k.z(this),F=this.$H,G=this.$m,O=this.$M,$=m.weekdays,te=m.months,Re=m.meridiem,ve=function(ee,me,ze,on){return ee&&(ee[me]||ee(g,v))||ze[me].slice(0,on)},$e=function(ee){return k.s(F%12||12,ee,"0")},_e=Re||function(ee,me,ze){var on=ee<12?"AM":"PM";return ze?on.toLowerCase():on};return v.replace(Oe,function(ee,me){return me||(function(ze){switch(ze){case"YY":return String(g.$y).slice(-2);case"YYYY":return k.s(g.$y,4,"0");case"M":return O+1;case"MM":return k.s(O+1,2,"0");case"MMM":return ve(m.monthsShort,O,te,3);case"MMMM":return ve(te,O);case"D":return g.$D;case"DD":return k.s(g.$D,2,"0");case"d":return String(g.$W);case"dd":return ve(m.weekdaysMin,g.$W,$,2);case"ddd":return ve(m.weekdaysShort,g.$W,$,3);case"dddd":return $[g.$W];case"H":return String(F);case"HH":return k.s(F,2,"0");case"h":return $e(1);case"hh":return $e(2);case"a":return _e(F,G,!0);case"A":return _e(F,G,!1);case"m":return String(G);case"mm":return k.s(G,2,"0");case"s":return String(g.$s);case"ss":return k.s(g.$s,2,"0");case"SSS":return k.s(g.$ms,3,"0");case"Z":return _}return null})(ee)||_.replace(":","")})},p.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},p.diff=function(u,g,m){var v,_=this,F=k.p(g),G=V(u),O=(G.utcOffset()-this.utcOffset())*e,$=this-G,te=function(){return k.m(_,G)};switch(F){case ae:v=te()/12;break;case A:v=te();break;case j:v=te()/3;break;case E:v=($-O)/6048e5;break;case y:v=($-O)/864e5;break;case l:v=$/n;break;case r:v=$/e;break;case a:v=$/i;break;default:v=$}return m?v:k.a(v)},p.daysInMonth=function(){return this.endOf(A).$D},p.$locale=function(){return X[this.$L]},p.locale=function(u,g){if(!u)return this.$L;var m=this.clone(),v=an(u,g,!0);return v&&(m.$L=v),m},p.clone=function(){return k.w(this.$d,this)},p.toDate=function(){return new Date(this.valueOf())},p.toJSON=function(){return this.isValid()?this.toISOString():null},p.toISOString=function(){return this.$d.toISOString()},p.toString=function(){return this.$d.toUTCString()},b})(),yi=rn.prototype;return V.prototype=yi,[["$ms",t],["$s",a],["$m",r],["$H",l],["$W",y],["$M",A],["$y",ae],["$D",se]].forEach(function(b){yi[b[1]]=function(p){return this.$g(p,b[0],b[1])}}),V.extend=function(b,p){return b.$i||(b(p,rn,V),b.$i=!0),V},V.locale=an,V.isDayjs=be,V.unix=function(b){return V(1e3*b)},V.en=X[Q],V.Ls=X,V.p={},V})});var tt=gi((Jn,Pn)=>{"use strict";(function(i,e){typeof Jn=="object"&&typeof Pn<"u"?Pn.exports=e():typeof define=="function"&&define.amd?define(e):(i=typeof globalThis<"u"?globalThis:i||self).dayjs_plugin_relativeTime=e()})(Jn,function(){"use strict";return function(i,e,n){i=i||{};var t=e.prototype,a={future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"};function r(y,E,A,j){return t.fromToBase(y,E,A,j)}n.en.relativeTime=a,t.fromToBase=function(y,E,A,j,ae){for(var se,ge,Ve,Oe=A.$locale().relativeTime||a,He=i.thresholds||[{l:"s",r:44,d:"second"},{l:"m",r:89},{l:"mm",r:44,d:"minute"},{l:"h",r:89},{l:"hh",r:21,d:"hour"},{l:"d",r:35},{l:"dd",r:25,d:"day"},{l:"M",r:45},{l:"MM",r:10,d:"month"},{l:"y",r:17},{l:"yy",d:"year"}],je=He.length,Ce=0;Ce<je;Ce+=1){var Q=He[Ce];Q.d&&(se=j?n(y).diff(A,Q.d,!0):A.diff(y,Q.d,!0));var X=(i.rounding||Math.round)(Math.abs(se));if(Ve=se>0,X<=Q.r||!Q.r){X<=1&&Ce>0&&(Q=He[Ce-1]);var xe=Oe[Q.l];ae&&(X=ae(""+X)),ge=typeof xe=="string"?xe.replace("%d",X):xe(X,E,Q.l,Ve);break}}if(E)return ge;var be=Ve?Oe.future:Oe.past;return typeof be=="function"?be(ge):be.replace("%s",ge)},t.to=function(y,E){return r(y,E,this,!0)},t.from=function(y,E){return r(y,E,this)};var l=function(y){return y.$u?n.utc():n()};t.toNow=function(y){return this.to(l(this),y)},t.fromNow=function(y){return this.from(l(this),y)}}})});var Gn=Ci(it()),at=Ci(tt());Gn.default.extend(at.default);var Le=class i{getRelativeTimeString(e){return(0,Gn.default)(e).fromNow()}static \u0275fac=function(n){return new(n||i)};static \u0275prov=ln({token:i,factory:i.\u0275fac,providedIn:"root"})};var fn=class i{config=q.required();async export(){try{let{config:e,epochUpdatedAt:n,epochCreatedAt:t,name:a}=this.config(),r=JSON.stringify(e,null,2),l=new Blob([r],{type:"application/json"}),y=URL.createObjectURL(l),E=document.createElement("a");E.href=y;let A=n||t||Date.now();E.download=`tressi-${this.toSlug(a)}-${A}.json`,document.body.appendChild(E),E.click(),E.remove(),URL.revokeObjectURL(y)}catch{}}toSlug(e){return e.toLowerCase().trim().replaceAll(/[^\w\s-]/g,"").replaceAll(/[\s_-]+/g,"-").replaceAll(/^(-+|-+)$/g,"")}static \u0275fac=function(n){return new(n||i)};static \u0275cmp=U({type:i,selectors:[["app-export-config-button"]],inputs:{config:[1,"config"]},decls:1,vars:4,consts:[[3,"click","onKeyDown","color","ghost","icon","title"]],template:function(n,t){n&1&&(s(0,"app-button",0),M("click",function(){return t.export()})("onKeyDown",function(){return t.export()}),o()),n&2&&f("color","info")("ghost",!0)("icon","file_save")("title","Export")},dependencies:[ne],encapsulation:2})};var Nt=(i,e,n,t,a)=>({"text-success":i,"text-warning":e,"text-info":n,"text-accent":t,"text-error":a}),Lt=(i,e)=>e.url;function Ft(i,e){if(i&1&&(s(0,"div",4)(1,"div",19)(2,"span",20),c(3),o(),s(4,"span",21),c(5),o()(),s(6,"div",22),D(7,"span",23),o()()),i&2){let n=e.$implicit;d(2),Ti(Ri(6,Nt,n.method==="GET",n.method==="POST",n.method==="PUT",n.method==="PATCH",n.method==="DELETE")),d(),J(" ",n.method," "),d(),f("title",n.url),d(),J(" ",n.url," "),d(2),f("appFormatRps",n.rps)}}function Bt(i,e){if(i&1&&(s(0,"div",5),c(1," +"),D(2,"span",10),c(3," more "),o()),i&2){let n=h();d(2),f("appFormatNumber",n.input().config.requests.length-3)}}var yn=class i{input=q.required();edit=re();duplicate=re();delete=re();navigate=re();timeService=w(Le);collapsed=B(!0);toggleCollapsed(e){if(!document.startViewTransition){this.collapsed.set(e);return}document.startViewTransition(()=>{this.collapsed.set(e)})}hasPayload(e){return!!(e.payload&&(Array.isArray(e.payload)?e.payload.length>0:Object.keys(e.payload).length>0))}getEffectiveRampUpDuration(){let e=this.input().config.options.rampUpDurationSec||0,n=Math.max(...this.input().config.requests.map(t=>t.rampUpDurationSec||0));return Math.max(e,n)}getTotalEndpoints(){return this.input().config.requests.length}getTotalRPS(){return this.input().config.requests.reduce((e,n)=>e+(n.rps||0),0)}getEffectiveEarlyExitStatus(){let e=this.input().config.options.workerEarlyExit.enabled,n=this.input().config.requests.some(t=>t.earlyExit.enabled);return e||n}static \u0275fac=function(n){return new(n||i)};static \u0275cmp=U({type:i,selectors:[["app-config-card"]],inputs:{input:[1,"input"]},outputs:{edit:"edit",duplicate:"duplicate",delete:"delete",navigate:"navigate"},decls:43,vars:27,consts:[["data-e2e","config-card",3,"collapsedChange","title","subtitle","collapsed"],[1,"border-neutral","mt-4","space-y-3","border-t","pt-4"],[1,"text-base-content/70","mb-2","text-sm","font-semibold"],[1,"space-y-2"],[1,"bg-base-300/50","flex","items-center","justify-between","rounded-xl","p-2"],[1,"text-base-content/60","text-center","text-sm"],[1,"grid","grid-cols-3","place-items-center","gap-4"],[1,"text-base-content/70","mb-1","text-sm","font-semibold"],[1,"text-sm",3,"appFormatDuration"],[1,"text-sm"],[3,"appFormatNumber"],[1,"text-sm",3,"appFormatNumber"],[1,"text-sm",3,"appFormatRps"],[1,"border-neutral","mt-4","flex","justify-end","gap-2","border-t","pt-4"],[3,"click","onKeyDown","ghost","icon","title"],[3,"config"],[3,"click","onKeyDown","color","ghost","title","icon"],[3,"click","onKeyDown","color","ghost","icon","title"],["data-e2e","use-config-btn",3,"click","onKeyDown","color","ghost","title","icon"],[1,"flex","min-w-0","items-center","gap-2"],[1,"font-mono","text-xs","font-semibold","uppercase"],[1,"truncate","text-sm",3,"title"],[1,"flex","items-center","gap-1"],[1,"text-base-content/60","text-xs",3,"appFormatRps"]],template:function(n,t){n&1&&(s(0,"app-collapsible-card",0),M("collapsedChange",function(r){return t.toggleCollapsed(r)}),s(1,"div",1)(2,"div")(3,"h4",2),c(4,"Requests"),o(),s(5,"div",3),K(6,Ft,8,12,"div",4,Lt),N(8,Bt,4,1,"div",5),o()(),s(9,"div",6)(10,"div")(11,"h4",7),c(12,"Duration"),o(),D(13,"p",8),o(),s(14,"div")(15,"h4",7),c(16,"Threads"),o(),s(17,"p",9),D(18,"span",10),c(19),o()(),s(20,"div")(21,"h4",7),c(22,"Ramp Up"),o(),D(23,"p",8),o(),s(24,"div")(25,"h4",7),c(26,"Early Exit"),o(),s(27,"p",9),c(28),o()(),s(29,"div")(30,"h4",7),c(31,"Endpoints"),o(),D(32,"p",11),o(),s(33,"div")(34,"h4",7),c(35,"Total RPS"),o(),D(36,"p",12),o()()(),s(37,"div",13)(38,"app-button",14),M("click",function(){return t.duplicate.emit(t.input())})("onKeyDown",function(){return t.duplicate.emit(t.input())}),o(),D(39,"app-export-config-button",15),s(40,"app-button",16),M("click",function(){return t.delete.emit(t.input())})("onKeyDown",function(){return t.delete.emit(t.input())}),o(),s(41,"app-button",17),M("click",function(){return t.edit.emit(t.input())})("onKeyDown",function(){return t.edit.emit(t.input())}),o(),s(42,"app-button",18),M("click",function(){return t.navigate.emit(t.input())})("onKeyDown",function(){return t.navigate.emit(t.input())}),o()()()),n&2&&(f("title",t.input().name)("subtitle","Updated: "+t.timeService.getRelativeTimeString(t.input().epochUpdatedAt??0))("collapsed",t.collapsed()),d(6),I(t.input().config.requests.slice(0,3)),d(2),L(t.input().config.requests.length>3?8:-1),d(5),f("appFormatDuration",t.input().config.options.durationSec),d(5),f("appFormatNumber",t.input().config.options.threads),d(),J(" thread",t.input().config.options.threads!==1?"s":""," "),d(4),f("appFormatDuration",t.getEffectiveRampUpDuration()),d(5),J(" ",t.getEffectiveEarlyExitStatus()?"Enabled":"Disabled"," "),d(4),f("appFormatNumber",t.getTotalEndpoints()),d(4),f("appFormatRps",t.getTotalRPS()),d(2),f("ghost",!0)("icon","copy_all")("title","Copy"),d(),f("config",t.input()),d(),f("color","error")("ghost",!0)("title","Delete")("icon","delete"),d(),f("color","success")("ghost",!0)("icon","edit_square")("title","Edit"),d(),f("color","primary")("ghost",!0)("title","Use")("icon","dynamic_form"))},dependencies:[fn,ne,$i,zi,ji,Ne],encapsulation:2,changeDetection:0})};var qn=0;function Kt(){return qn}function he(i,e){return(...n)=>{try{return qn=e,i(...n)}finally{qn=0}}}function It(i){return!i}function rt(i){return i}function ue(i){return Array.isArray(i)}function Fe(i){return(typeof i=="object"||typeof i=="function")&&i!=null}var fe=Symbol(),Sn=Symbol(),Ye=class{predicates;fns=[];constructor(e){this.predicates=e}push(e){this.fns.push(ot(this.predicates,e))}mergeIn(e){let n=this.predicates?e.fns.map(t=>ot(this.predicates,t)):e.fns;this.fns.push(...n)}},Cn=class extends Ye{get defaultValue(){return!1}compute(e){return this.fns.some(n=>{let t=n(e);return t&&t!==Sn})}},Be=class i extends Ye{ignore;static ignoreNull(e){return new i(e,n=>n===null)}constructor(e,n){super(e),this.ignore=n}get defaultValue(){return[]}compute(e){return this.fns.reduce((n,t)=>{let a=t(e);return a===void 0||a===Sn?n:ue(a)?[...n,...this.ignore?a.filter(r=>!this.ignore(r)):a]:this.ignore&&this.ignore(a)?n:[...n,a]},[])}},Vn=class extends Be{constructor(e){super(e,void 0)}},On=class extends Ye{key;get defaultValue(){return this.key.reducer.getInitial()}constructor(e,n){super(e),this.key=n}compute(e){if(this.fns.length===0)return this.key.reducer.getInitial();let n=this.key.reducer.getInitial();for(let t=0;t<this.fns.length;t++){let a=this.fns[t](e);a!==Sn&&(n=this.key.reducer.reduce(n,a))}return n}};function ot(i,e){return i.length===0?e:n=>{for(let t of i){let a=n.stateOf(t.path),r=P(a.structure.pathKeys).length-t.depth;for(let l=0;l<r;l++)a=a.structure.parent;if(!t.fn(a.context))return Sn}return e(n)}}var Ke=class{predicates;hidden;disabledReasons;readonly;syncErrors;syncTreeErrors;asyncErrors;metadata=new Map;constructor(e){this.predicates=e,this.hidden=new Cn(e),this.disabledReasons=new Vn(e),this.readonly=new Cn(e),this.syncErrors=Be.ignoreNull(e),this.syncTreeErrors=Be.ignoreNull(e),this.asyncErrors=Be.ignoreNull(e)}hasMetadata(e){return this.metadata.has(e)}getMetadataKeys(){return this.metadata.keys()}getMetadata(e){return this.metadata.has(e)||this.metadata.set(e,new On(this.predicates,e)),this.metadata.get(e)}mergeIn(e){this.hidden.mergeIn(e.hidden),this.disabledReasons.mergeIn(e.disabledReasons),this.readonly.mergeIn(e.readonly),this.syncErrors.mergeIn(e.syncErrors),this.syncTreeErrors.mergeIn(e.syncTreeErrors),this.asyncErrors.mergeIn(e.asyncErrors);for(let n of e.getMetadataKeys()){let t=e.metadata.get(n);this.getMetadata(n).mergeIn(t)}}},bn=class{depth;constructor(e){this.depth=e}build(){return new vn(this,[],0)}},Ie=class i extends bn{constructor(e){super(e)}current;all=[];addHiddenRule(e){this.getCurrent().addHiddenRule(e)}addDisabledReasonRule(e){this.getCurrent().addDisabledReasonRule(e)}addReadonlyRule(e){this.getCurrent().addReadonlyRule(e)}addSyncErrorRule(e){this.getCurrent().addSyncErrorRule(e)}addSyncTreeErrorRule(e){this.getCurrent().addSyncTreeErrorRule(e)}addAsyncErrorRule(e){this.getCurrent().addAsyncErrorRule(e)}addMetadataRule(e,n){this.getCurrent().addMetadataRule(e,n)}getChild(e){if(e===fe){let n=this.getCurrent().children;n.size>(n.has(fe)?1:0)&&(this.current=void 0)}return this.getCurrent().getChild(e)}hasLogic(e){return this===e?!0:this.all.some(({builder:n})=>n.hasLogic(e))}mergeIn(e,n){n?this.all.push({builder:e,predicate:{fn:he(n.fn,this.depth),path:n.path}}):this.all.push({builder:e}),this.current=void 0}getCurrent(){return this.current===void 0&&(this.current=new Ze(this.depth),this.all.push({builder:this.current})),this.current}static newRoot(){return new i(0)}},Ze=class extends bn{logic=new Ke([]);children=new Map;constructor(e){super(e)}addHiddenRule(e){this.logic.hidden.push(he(e,this.depth))}addDisabledReasonRule(e){this.logic.disabledReasons.push(he(e,this.depth))}addReadonlyRule(e){this.logic.readonly.push(he(e,this.depth))}addSyncErrorRule(e){this.logic.syncErrors.push(he(e,this.depth))}addSyncTreeErrorRule(e){this.logic.syncTreeErrors.push(he(e,this.depth))}addAsyncErrorRule(e){this.logic.asyncErrors.push(he(e,this.depth))}addMetadataRule(e,n){this.logic.getMetadata(e).push(he(n,this.depth))}getChild(e){return this.children.has(e)||this.children.set(e,new Ie(this.depth+1)),this.children.get(e)}hasLogic(e){return this===e}},vn=class i{builder;predicates;depth;logic;constructor(e,n,t){this.builder=e,this.predicates=n,this.depth=t,this.logic=e?Jt(e,n,t):new Ke([])}getChild(e){let n=this.builder?dt(this.builder,e):[];if(n.length===0)return new i(void 0,[],this.depth+1);if(n.length===1){let{builder:t,predicates:a}=n[0];return new i(t,[...this.predicates,...a.map(r=>jn(r,this.depth))],this.depth+1)}else{let t=n.map(({builder:a,predicates:r})=>new i(a,[...this.predicates,...r.map(l=>jn(l,this.depth))],this.depth+1));return new Hn(t)}}hasLogic(e){return this.builder?.hasLogic(e)??!1}},Hn=class i{all;logic;constructor(e){this.all=e,this.logic=new Ke([]);for(let n of e)this.logic.mergeIn(n.logic)}getChild(e){return new i(this.all.flatMap(n=>n.getChild(e)))}hasLogic(e){return this.all.some(n=>n.hasLogic(e))}};function dt(i,e){if(i instanceof Ie)return i.all.flatMap(({builder:n,predicate:t})=>{let a=dt(n,e);return t?a.map(({builder:r,predicates:l})=>({builder:r,predicates:[...l,t]})):a});if(i instanceof Ze)return[...e!==fe&&i.children.has(fe)?[{builder:i.getChild(fe),predicates:[]}]:[],...i.children.has(e)?[{builder:i.getChild(e),predicates:[]}]:[]];throw new H(1909,!1)}function Jt(i,e,n){let t=new Ke(e);if(i instanceof Ie){let a=i.all.map(({builder:r,predicate:l})=>new vn(r,l?[...e,jn(l,n)]:e,n));for(let r of a)t.mergeIn(r.logic)}else if(i instanceof Ze)t.mergeIn(i.logic);else throw new H(1909,!1);return t}function jn(i,e){return R(S({},i),{depth:e})}var ut=Symbol("PATH"),ie=class i{keys;parent;keyInParent;root;children=new Map;fieldPathProxy=new Proxy(this,Pt);logicBuilder;constructor(e,n,t,a){this.keys=e,this.parent=t,this.keyInParent=a,this.root=n??this,t||(this.logicBuilder=Ie.newRoot())}get builder(){return this.logicBuilder?this.logicBuilder:this.parent.builder.getChild(this.keyInParent)}getChild(e){return this.children.has(e)||this.children.set(e,new i([...this.keys,e],this.root,this,e)),this.children.get(e)}mergeIn(e,n){let t=e.compile();this.builder.mergeIn(t.builder,n)}static unwrapFieldPath(e){return e[ut]}static newRoot(){return new i([],void 0,void 0,void 0)}},Pt={get(i,e){return e===ut?i:i.getChild(e).fieldPathProxy}},gn,Ue=new Map,Qe=class i{schemaFn;constructor(e){this.schemaFn=e}compile(){if(Ue.has(this))return Ue.get(this);let e=ie.newRoot();Ue.set(this,e);let n=gn;try{gn=e,this.schemaFn(e.fieldPathProxy)}finally{gn=n}return e}static create(e){return e instanceof i?e:new i(e)}static rootCompile(e){try{return Ue.clear(),e===void 0?ie.newRoot():e instanceof i?e.compile():new i(e).compile()}finally{Ue.clear()}}};function Gt(i){return i instanceof Qe||typeof i=="function"}function we(i){if(gn!==ie.unwrapFieldPath(i).root)throw new H(1908,!1)}function nn(i,e,n){return we(i),ie.unwrapFieldPath(i).builder.addMetadataRule(e,n),e}var ce={list(){return{reduce:(i,e)=>e===void 0?i:[...i,e],getInitial:()=>[]}},min(){return{reduce:(i,e)=>i===void 0||e===void 0?i??e:Math.min(i,e),getInitial:()=>{}}},max(){return{reduce:(i,e)=>i===void 0||e===void 0?i??e:Math.max(i,e),getInitial:()=>{}}},or(){return{reduce:(i,e)=>i||e,getInitial:()=>!1}},and(){return{reduce:(i,e)=>i&&e,getInitial:()=>!0}},override:qt};function qt(i){return{reduce:(e,n)=>n,getInitial:()=>i?.()}}var Xe=class{reducer;create;brand;constructor(e,n){this.reducer=e,this.create=n}};function de(i){return new Xe(i??ce.override())}function ct(i,e){return new Xe(e??ce.override(),i)}var ti=de(ce.or()),mt=de(ce.max()),pt=de(ce.min()),ht=de(ce.max()),ft=de(ce.min()),yt=de(ce.list());function Vt(i){return i.errors().length>0?"invalid":i.pending()?"unknown":"valid"}var $n=class{node;constructor(e){this.node=e}rawSyncTreeErrors=C(()=>this.shouldSkipValidation()?[]:[...this.node.logicNode.logic.syncTreeErrors.compute(this.node.context),...this.node.structure.parent?.validationState.rawSyncTreeErrors()??[]]);syncErrors=C(()=>this.shouldSkipValidation()?[]:[...this.node.logicNode.logic.syncErrors.compute(this.node.context),...this.syncTreeErrors(),...Ot(this.node.submitState.submissionErrors())]);syncValid=C(()=>this.shouldSkipValidation()?!0:this.node.structure.reduceChildren(this.syncErrors().length===0,(e,n)=>n&&e.validationState.syncValid(),It));syncTreeErrors=C(()=>this.rawSyncTreeErrors().filter(e=>e.fieldTree===this.node.fieldTree));rawAsyncErrors=C(()=>this.shouldSkipValidation()?[]:[...this.node.logicNode.logic.asyncErrors.compute(this.node.context),...this.node.structure.parent?.validationState.rawAsyncErrors()??[]]);asyncErrors=C(()=>this.shouldSkipValidation()?[]:this.rawAsyncErrors().filter(e=>e==="pending"||e.fieldTree===this.node.fieldTree));parseErrors=C(()=>this.node.formFieldBindings().flatMap(e=>e.parseErrors()));errors=C(()=>[...this.parseErrors(),...this.syncErrors(),...this.asyncErrors().filter(e=>e!=="pending")]);errorSummary=C(()=>{let e=this.node.structure.reduceChildren(this.errors(),(n,t)=>[...t,...n.errorSummary()]);return P(()=>e.sort(Ht)),e});pending=C(()=>this.node.structure.reduceChildren(this.asyncErrors().includes("pending"),(e,n)=>n||e.validationState.asyncErrors().includes("pending")));status=C(()=>{if(this.shouldSkipValidation())return"valid";let e=Vt(this);return this.node.structure.reduceChildren(e,(n,t)=>t==="invalid"||n.validationState.status()==="invalid"?"invalid":t==="unknown"||n.validationState.status()==="unknown"?"unknown":"valid",n=>n==="invalid")});valid=C(()=>this.status()==="valid");invalid=C(()=>this.status()==="invalid");shouldSkipValidation=C(()=>this.node.hidden()||this.node.disabled()||this.node.readonly())};function Ot(i){return i===void 0?[]:ue(i)?i:[i]}function Je(i,e){if(ue(i))for(let n of i)n.fieldTree??=e;else i&&(i.fieldTree??=e);return i}function lt(i){return i.formField?i.formField.element:i.fieldTree().formFieldBindings().reduce((e,n)=>!e||!n.element?e??n.element:e.compareDocumentPosition(n.element)&Node.DOCUMENT_POSITION_PRECEDING?n.element:e,void 0)}function Ht(i,e){let n=lt(i),t=lt(e);return n===t?0:n===void 0||t===void 0?n===void 0?1:-1:n.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_PRECEDING?1:-1}var zn=de(),Wn=class{node;cache=new WeakMap;constructor(e){this.node=e}resolve(e){if(!this.cache.has(e)){let n=C(()=>{let t=ie.unwrapFieldPath(e),a=this.node,r=Kt();for(;r>0||!a.structure.logic.hasLogic(t.root.builder);)if(r--,a=a.structure.parent,a===void 0)throw new H(1900,!1);for(let l of t.keys)if(a=a.structure.getChild(l),a===void 0)throw new H(1901,!1);return a.fieldTree});this.cache.set(e,n)}return this.cache.get(e)()}get fieldTree(){return this.node.fieldProxy}get state(){return this.node}get value(){return this.node.structure.value}get key(){return this.node.structure.keyInParent}get pathKeys(){return this.node.structure.pathKeys}index=C(()=>{let e=this.key();if(!ue(P(this.node.structure.parent.value)))throw new H(1906,!1);return Number(e)});fieldTreeOf=e=>this.resolve(e);stateOf=e=>this.resolve(e)();valueOf=e=>{let n=this.resolve(e)().value();if(n instanceof Zi)throw new H(1907,!1);return n}},Un=class{node;metadata=new Map;constructor(e){this.node=e;for(let n of this.node.logicNode.logic.getMetadataKeys())if(n.create){let t=this.node.logicNode.logic.getMetadata(n),a=P(()=>xn(this.node.structure.injector,()=>n.create(C(()=>t.compute(this.node.context)))));this.metadata.set(n,a)}}get(e){if(this.has(e)&&!this.metadata.has(e)){if(e.create)throw new H(1912,!1);let n=this.node.logicNode.logic.getMetadata(e);this.metadata.set(e,C(()=>n.compute(this.node.context)))}return this.metadata.get(e)}has(e){return this.node.logicNode.logic.hasMetadata(e)}},jt={get(i,e,n){let t=i(),a=t.structure.getChild(e);if(a!==void 0)return a.fieldTree;let r=P(t.value);if(ue(r)){if(e==="length")return t.value().length;if(e===Symbol.iterator)return()=>(t.value(),Array.prototype[Symbol.iterator].apply(t.fieldTree))}if(Fe(r)&&e===Symbol.iterator)return function*(){for(let l in n)yield[l,n[l]]}},getOwnPropertyDescriptor(i,e){let n=P(i().value),t=Reflect.getOwnPropertyDescriptor(n,e);return t&&!t.configurable&&(t.configurable=!0),t},ownKeys(i){let e=P(i().value);return typeof e=="object"&&e!==null?Reflect.ownKeys(e):[]}};function $t(i,e){let n=C(()=>i()[e()]);return n[Tn]=i[Tn],n.set=t=>{i.update(a=>zt(a,t,e()))},n.update=t=>{n.set(t(P(n)))},n.asReadonly=()=>n,n}function zt(i,e,n){if(ue(i)){let t=[...i];return t[n]=e,t}else return R(S({},i),{[n]:e})}var _n=class{logic;node;createChildNode;identitySymbol=Symbol();_injector=void 0;get injector(){return this._injector??=We.create({providers:[],parent:this.fieldManager.injector}),this._injector}constructor(e,n,t){this.logic=e,this.node=n,this.createChildNode=t}children(){let e=this.childrenMap();return e===void 0?[]:Array.from(e.byPropertyKey.values()).map(n=>P(n.reader))}getChild(e){let n=e.toString(),t=P(this.childrenMap)?.byPropertyKey.get(n)?.reader;return t||(t=this.createReader(n)),t()}reduceChildren(e,n,t){let a=this.childrenMap();if(!a)return e;let r=e;for(let l of a.byPropertyKey.values()){if(t?.(r))break;r=n(P(l.reader),r)}return r}destroy(){this.injector.destroy()}createKeyInParent(e,n,t){if(e.kind==="root")return gt;if(n===void 0){let a=t;return C(()=>{if(this.parent.structure.getChild(a)!==this.node)throw new H(1902,!1);return a})}else{let a=t;return C(()=>{let r=this.parent.structure.value();if(!ue(r))throw new H(1903,!1);let l=r[a];if(Fe(l)&&l.hasOwnProperty(this.parent.structure.identitySymbol)&&l[this.parent.structure.identitySymbol]===n)return a;for(let y=0;y<r.length;y++){let E=r[y];if(Fe(E)&&E.hasOwnProperty(this.parent.structure.identitySymbol)&&E[this.parent.structure.identitySymbol]===n)return a=y.toString()}throw new H(1904,!1)})}}createChildrenMap(){return De({source:this.value,computation:(e,n)=>{if(!Fe(e))return;let t=n?.value??{byPropertyKey:new Map},a,r=ue(e);t!==void 0&&(r?a=Ut(t,e,this.identitySymbol):a=Yt(t,e));for(let l of Object.keys(e)){let y,E=e[l];if(E===void 0){t.byPropertyKey.has(l)&&(a??=S({},t),a.byPropertyKey.delete(l));continue}r&&Fe(E)&&!ue(E)&&(y=E[this.identitySymbol]??=Symbol(""));let A;y&&(t.byTrackingKey?.has(y)||(a??=S({},t),a.byTrackingKey??=new Map,a.byTrackingKey.set(y,this.createChildNode(l,y,r))),A=(a??t).byTrackingKey.get(y));let j=t.byPropertyKey.get(l);j===void 0?(a??=S({},t),a.byPropertyKey.set(l,{reader:this.createReader(l),node:A??this.createChildNode(l,y,r)})):A&&A!==j.node&&(a??=S({},t),j.node=A)}return a??t}})}createReader(e){return C(()=>this.childrenMap()?.byPropertyKey.get(e)?.node)}},Yn=class extends _n{fieldManager;value;get parent(){}get root(){return this.node}get pathKeys(){return Wt}get keyInParent(){return gt}childrenMap;constructor(e,n,t,a,r){super(n,e,r),this.fieldManager=t,this.value=a,this.childrenMap=this.createChildrenMap()}},Zn=class extends _n{logic;parent;root;pathKeys;keyInParent;value;childrenMap;get fieldManager(){return this.root.structure.fieldManager}constructor(e,n,t,a,r,l){super(n,e,l),this.logic=n,this.parent=t,this.root=this.parent.structure.root,this.keyInParent=this.createKeyInParent({kind:"child",parent:t,pathNode:void 0,logic:n,initialKeyInParent:r,identityInParent:a,fieldAdapter:void 0},a,r),this.pathKeys=C(()=>[...t.structure.pathKeys(),this.keyInParent()]),this.value=$t(this.parent.structure.value,this.keyInParent),this.childrenMap=this.createChildrenMap(),this.fieldManager.structures.add(this)}};var Wt=C(()=>[]),gt=C(()=>{throw new H(1905,!1)});function Ut(i,e,n){let t,a=new Set(i.byPropertyKey.keys()),r=new Set(i.byTrackingKey?.keys());for(let l=0;l<e.length;l++){let y=e[l];a.delete(l.toString()),Fe(y)&&y.hasOwnProperty(n)&&r.delete(y[n])}if(a.size>0){t??=S({},i);for(let l of a)t.byPropertyKey.delete(l)}if(r.size>0){t??=S({},i);for(let l of r)t.byTrackingKey?.delete(l)}return t}function Yt(i,e){let n;for(let t of i.byPropertyKey.keys())e.hasOwnProperty(t)||(n??=S({},i),n.byPropertyKey.delete(t));return n}var Qn=class{node;selfSubmitting=B(!1);submissionErrors;constructor(e){this.node=e,this.submissionErrors=De({source:this.node.structure.value,computation:()=>[]})}submitting=C(()=>this.selfSubmitting()||(this.node.structure.parent?.submitting()??!1))},en=class{structure;validationState;metadataState;nodeState;submitState;fieldAdapter;controlValue;_context=void 0;get context(){return this._context??=new Wn(this)}fieldProxy=new Proxy(()=>this,jt);pathNode;constructor(e){this.pathNode=e.pathNode,this.fieldAdapter=e.fieldAdapter,this.structure=this.fieldAdapter.createStructure(this,e),this.validationState=this.fieldAdapter.createValidationState(this,e),this.nodeState=this.fieldAdapter.createNodeState(this,e),this.metadataState=new Un(this),this.submitState=new Qn(this),this.controlValue=this.controlValueSignal()}focusBoundControl(e){this.getBindingForFocus()?.focus(e)}getBindingForFocus(){let e=this.formFieldBindings().filter(n=>n.focus!==void 0).reduce(st,void 0);return e||this.structure.children().map(n=>n.getBindingForFocus()).reduce(st,void 0)}pendingSync=De({source:()=>this.value(),computation:(e,n)=>{n?.value?.abort()}});get fieldTree(){return this.fieldProxy}get logicNode(){return this.structure.logic}get value(){return this.structure.value}get keyInParent(){return this.structure.keyInParent}get errors(){return this.validationState.errors}get parseErrors(){return this.validationState.parseErrors}get errorSummary(){return this.validationState.errorSummary}get pending(){return this.validationState.pending}get valid(){return this.validationState.valid}get invalid(){return this.validationState.invalid}get dirty(){return this.nodeState.dirty}get touched(){return this.nodeState.touched}get disabled(){return this.nodeState.disabled}get disabledReasons(){return this.nodeState.disabledReasons}get hidden(){return this.nodeState.hidden}get readonly(){return this.nodeState.readonly}get formFieldBindings(){return this.nodeState.formFieldBindings}get submitting(){return this.submitState.submitting}get name(){return this.nodeState.name}get max(){return this.metadata(pt)}get maxLength(){return this.metadata(ft)}get min(){return this.metadata(mt)}get minLength(){return this.metadata(ht)}get pattern(){return this.metadata(yt)??Zt}get required(){return this.metadata(ti)??Qt}metadata(e){return this.metadataState.get(e)}hasMetadata(e){return this.metadataState.has(e)}markAsTouched(){P(()=>{this.nodeState.markAsTouched(),this.flushSync()})}markAsDirty(){this.nodeState.markAsDirty()}markAsPristine(){this.nodeState.markAsPristine()}markAsUntouched(){this.nodeState.markAsUntouched()}reset(e){P(()=>this._reset(e))}_reset(e){e!==void 0&&this.value.set(e),this.nodeState.markAsUntouched(),this.nodeState.markAsPristine();for(let n of this.structure.children())n._reset()}controlValueSignal(){let e=De(this.value),{set:n,update:t}=e;return e.set=a=>{n(a),this.markAsDirty(),this.debounceSync()},e.update=a=>{t(a),this.markAsDirty(),this.debounceSync()},e}sync(){this.value.set(this.controlValue())}flushSync(){let e=this.pendingSync();e&&!e.signal.aborted&&(e.abort(),this.sync())}async debounceSync(){let e=P(()=>(this.pendingSync()?.abort(),this.nodeState.debouncer()));if(e){let n=new AbortController,t=e(n.signal);if(t&&(this.pendingSync.set(n),await t,n.signal.aborted))return}this.sync()}static newRoot(e,n,t,a){return a.newRoot(e,n,t,a)}createStructure(e){return e.kind==="root"?new Yn(this,e.logic,e.fieldManager,e.value,this.newChild.bind(this)):new Zn(this,e.logic,e.parent,e.identityInParent,e.initialKeyInParent,this.newChild.bind(this))}newChild(e,n,t){let a,r;return t?(a=this.pathNode.getChild(fe),r=this.structure.logic.getChild(fe)):(a=this.pathNode.getChild(e),r=this.structure.logic.getChild(e)),this.fieldAdapter.newChild({kind:"child",parent:this,pathNode:a,logic:r,initialKeyInParent:e,identityInParent:n,fieldAdapter:this.fieldAdapter})}},Zt=C(()=>[]),Qt=C(()=>!1);function st(i,e){return i?e&&i.element.compareDocumentPosition(e.element)&Node.DOCUMENT_POSITION_PRECEDING?e:i:e}var Xn=class{node;selfTouched=B(!1);selfDirty=B(!1);markAsTouched(){this.selfTouched.set(!0)}markAsDirty(){this.selfDirty.set(!0)}markAsPristine(){this.selfDirty.set(!1)}markAsUntouched(){this.selfTouched.set(!1)}formFieldBindings=B([]);constructor(e){this.node=e}dirty=C(()=>{let e=this.selfDirty()&&!this.isNonInteractive();return this.node.structure.reduceChildren(e,(n,t)=>t||n.nodeState.dirty(),rt)});touched=C(()=>{let e=this.selfTouched()&&!this.isNonInteractive();return this.node.structure.reduceChildren(e,(n,t)=>t||n.nodeState.touched(),rt)});disabledReasons=C(()=>[...this.node.structure.parent?.nodeState.disabledReasons()??[],...this.node.logicNode.logic.disabledReasons.compute(this.node.context)]);disabled=C(()=>!!this.disabledReasons().length);readonly=C(()=>(this.node.structure.parent?.nodeState.readonly()||this.node.logicNode.logic.readonly.compute(this.node.context))??!1);hidden=C(()=>(this.node.structure.parent?.nodeState.hidden()||this.node.logicNode.logic.hidden.compute(this.node.context))??!1);name=C(()=>{let e=this.node.structure.parent;return e?`${e.name()}.${this.node.structure.keyInParent()}`:this.node.structure.fieldManager.rootName});debouncer=C(()=>{if(this.node.logicNode.logic.hasMetadata(zn)){let n=this.node.logicNode.logic.getMetadata(zn).compute(this.node.context);if(n)return t=>n(this.node.context,t)}return this.node.structure.parent?.nodeState.debouncer?.()});isNonInteractive=C(()=>this.hidden()||this.disabled()||this.readonly())},ei=class{newRoot(e,n,t,a){return new en({kind:"root",fieldManager:e,value:n,pathNode:t,logic:t.builder.build(),fieldAdapter:a})}newChild(e){return new en(e)}createNodeState(e){return new Xn(e)}createValidationState(e){return new $n(e)}createStructure(e,n){return e.createStructure(n)}},ni=class{injector;rootName;submitOptions;constructor(e,n,t){this.injector=e,this.rootName=n??`${this.injector.get(_i)}.form${Xt++}`,this.submitOptions=t}structures=new Set;createFieldManagementEffect(e){pe(()=>{let n=new Set;this.markStructuresLive(e,n);for(let t of this.structures)n.has(t)||(this.structures.delete(t),P(()=>t.destroy()))},{injector:this.injector})}markStructuresLive(e,n){n.add(e);for(let t of e.children())this.markStructuresLive(t.structure,n)}},Xt=0;function ea(i){let e,n,t;return i.length===3?[e,n,t]=i:i.length===2?Gt(i[1])?[e,n]=i:[e,t]=i:[e]=i,[e,n,t]}function ai(...i){let[e,n,t]=ea(i),a=t?.injector??w(We),r=xn(a,()=>Qe.rootCompile(n)),l=new ni(a,t?.name,t?.submission),y=t?.adapter??new ei,E=en.newRoot(l,e,r,y);return l.createFieldManagementEffect(E.structure),E.fieldTree}function ri(i,e){we(i);let n=ie.unwrapFieldPath(i).getChild(fe).fieldPathProxy;Ct(n,e)}function Ct(i,e){we(i),ie.unwrapFieldPath(i).mergeIn(Qe.create(e))}var ii=class{kind="compat";control;fieldTree;context;message;constructor({context:e,kind:n,control:t}){this.context=e,this.kind=n,this.control=t}};function bt(i){if(i.length===0)return null;let e={};for(let n of i)e[n.kind]=n instanceof ii?n.context:n;return e}var na=new sn("");function vt(i,e){return i instanceof Function?i(e):i}function ia(i){return typeof i=="number"?isNaN(i):i===""||i===!1||i==null}function _t(i){return i===void 0?[]:Array.isArray(i)?i:[i]}function ta(i,e){we(i),ie.unwrapFieldPath(i).builder.addSyncErrorRule(t=>Je(e(t),t.fieldTree))}function aa(i){return new oi(i)}var tn=class{__brand=void 0;kind="";fieldTree;message;constructor(e){e&&Object.assign(this,e)}},oi=class extends tn{kind="required"};var li=class extends tn{kind="parse"};function ci(i,e){let n=nn(i,de(),t=>e?.when?e.when(t):!0);nn(i,ti,({state:t})=>t.metadata(n)()),ta(i,t=>{if(t.state.metadata(n)()&&ia(t.value()))return e?.error?vt(e.error,t):aa({message:vt(e?.message,t)})})}function ra(i,e){we(i);let n=ie.unwrapFieldPath(i),t=ct(e.factory);nn(i,t,a=>{let l=a.stateOf(i).validationState;if(!(l.shouldSkipValidation()||!l.syncValid()))return e.params(a)}),n.builder.addAsyncErrorRule(a=>{let r=a.state.metadata(t),l;switch(r.status()){case"idle":return;case"loading":case"reloading":return"pending";case"resolved":case"local":return r.hasValue()?(l=e.onSuccess(r.value(),a),Je(l,a.fieldTree)):void 0;case"error":return l=e.onError(r.error(),a),Je(l,a.fieldTree)}})}function oa(i,e){we(i),ie.unwrapFieldPath(i).builder.addSyncTreeErrorRule(t=>Je(e(t),t.fieldTree))}function Et(i,e){let n=nn(i,de(),t=>{let a=typeof e=="function"?e(t):e;return a?a["~standard"].validate(t.value()):void 0});oa(i,({state:t,fieldTreeOf:a})=>{let r=t.metadata(n)();return!r||Rn(r)?[]:r?.issues?.map(l=>St(a(i),l))??[]}),ra(i,{params:({state:t})=>{let a=t.metadata(n)();return a&&Rn(a)?a:void 0},factory:t=>ki({params:t,loader:async({params:a})=>(await a)?.issues??[]}),onSuccess:(t,{fieldTreeOf:a})=>t.map(r=>St(a(i),r)),onError:()=>{}})}function la(i,e){return new si(i,e)}function St(i,e){let n=i;for(let t of e.path??[]){let a=typeof t=="object"?t.key:t;n=n[a]}return Je(la(e,{message:e.message}),n)}var si=class extends tn{issue;kind="standardSchema";constructor(e,n){super(n),this.issue=e}};var sa=new sn("");function da(i,e,n){let t=De({source:i,computation:()=>[]}),a=r=>{let l=n(r);t.set(_t(l.error)),l.value!==void 0&&e(l.value),t.set(_t(l.error))};return{errors:t.asReadonly(),setRawValue:a}}var di=class{field;constructor(e){this.field=e}control=this;get value(){return this.field().value()}get valid(){return this.field().valid()}get invalid(){return this.field().invalid()}get pending(){return this.field().pending()}get disabled(){return this.field().disabled()}get enabled(){return!this.field().disabled()}get errors(){return bt(this.field().errors())}get pristine(){return!this.field().dirty()}get dirty(){return this.field().dirty()}get touched(){return this.field().touched()}get untouched(){return!this.field().touched()}get status(){if(this.field().disabled())return"DISABLED";if(this.field().valid())return"VALID";if(this.field().invalid())return"INVALID";if(this.field().pending())return"PENDING";throw new H(1910,!1)}valueAccessor=null;hasValidator(e){return e===Ui.required?this.field().required():!1}updateValueAndValidity(){}},ui={disabled:"disabled",disabledReasons:"disabledReasons",dirty:"dirty",errors:"errors",hidden:"hidden",invalid:"invalid",max:"max",maxLength:"maxLength",min:"min",minLength:"minLength",name:"name",pattern:"pattern",pending:"pending",readonly:"readonly",required:"required",touched:"touched"},ua=(()=>{let i={};for(let e of Object.keys(ui))i[ui[e]]=e;return i})();function mi(i,e){let n=ua[e];return i[n]?.()}var pi=Object.values(ui);function Mn(){return{}}function Te(i,e,n){return i[e]!==n?(i[e]=n,!0):!1}function ca(i){return i.tagName==="INPUT"||i.tagName==="SELECT"||i.tagName==="TEXTAREA"}function ma(i){if(i.tagName!=="INPUT")return!1;let e=i.type;return e==="date"||e==="datetime-local"||e==="month"||e==="number"||e==="range"||e==="time"||e==="week"}function pa(i){return i.tagName==="INPUT"||i.tagName==="TEXTAREA"}function ha(i,e){let n;if(i.validity.badInput)return{error:new li};switch(i.type){case"checkbox":return{value:i.checked};case"number":case"range":case"datetime-local":if(n=P(e),typeof n=="number"||n===null)return{value:i.value===""?null:i.valueAsNumber};break;case"date":case"month":case"time":case"week":if(n=P(e),n===null||n instanceof Date)return{value:i.valueAsDate};if(typeof n=="number")return{value:i.valueAsNumber};break}return{value:i.value}}function fa(i,e){switch(i.type){case"checkbox":i.checked=e;return;case"radio":i.checked=e===i.value;return;case"number":case"range":case"datetime-local":if(typeof e=="number"){Mt(i,e);return}else if(e===null){i.value="";return}break;case"date":case"month":case"time":case"week":if(e===null||e instanceof Date){i.valueAsDate=e;return}else if(typeof e=="number"){Mt(i,e);return}}i.value=e}function Mt(i,e){isNaN(e)?i.value="":i.valueAsNumber=e}function hi(i,e,n,t){switch(n){case"name":i.setAttribute(e,n,t);break;case"disabled":case"readonly":case"required":t?i.setAttribute(e,n,""):i.removeAttribute(e,n);break;case"max":case"min":case"minLength":case"maxLength":t!==void 0?i.setAttribute(e,n,t.toString()):i.removeAttribute(e,n);break}}function ya(i,e){i.listenToCustomControlModel(t=>e.state().controlValue.set(t)),i.listenToCustomControlOutput("touchedChange",()=>e.state().markAsTouched()),e.registerAsBinding(i.customControl);let n=Mn();return()=>{let t=e.state(),a=t.controlValue();Te(n,"controlValue",a)&&i.setCustomControlModelInput(a);for(let r of pi){let l;r==="errors"?l=e.errors():l=mi(t,r),Te(n,r,l)&&(i.setInputOnDirectives(r,l),e.elementAcceptsNativeProperty(r)&&!i.customControlHasInput(r)&&hi(e.renderer,e.nativeFormElement,r,l))}}}function ga(i,e){e.controlValueAccessor.registerOnChange(t=>e.state().controlValue.set(t)),e.controlValueAccessor.registerOnTouched(()=>e.state().markAsTouched()),e.registerAsBinding();let n=Mn();return()=>{let t=e.state(),a=t.value();Te(n,"controlValue",a)&&P(()=>e.controlValueAccessor.writeValue(a));for(let r of pi){let l=mi(t,r);if(Te(n,r,l)){let y=i.setInputOnDirectives(r,l);r==="disabled"&&e.controlValueAccessor.setDisabledState?P(()=>e.controlValueAccessor.setDisabledState(l)):!y&&e.elementAcceptsNativeProperty(r)&&hi(e.renderer,e.nativeFormElement,r,l)}}}}function Ca(i,e,n){if(typeof MutationObserver!="function")return;let t=new MutationObserver(a=>{a.some(r=>ba(r))&&e()});t.observe(i,{attributes:!0,attributeFilter:["value"],characterData:!0,childList:!0,subtree:!0}),n.onDestroy(()=>t.disconnect())}function ba(i){if(i.type==="childList"||i.type==="characterData"){if(i.target instanceof Comment)return!1;for(let e of i.addedNodes)if(!(e instanceof Comment))return!0;for(let e of i.removedNodes)if(!(e instanceof Comment))return!0;return!1}return i.type==="attributes"&&i.target instanceof HTMLOptionElement}function va(i,e,n){let t=!1,a=e.nativeFormElement,r=da(()=>e.state().value(),y=>e.state().controlValue.set(y),()=>ha(a,e.state().value));n.set(r.errors),i.listenToDom("input",()=>r.setRawValue(void 0)),i.listenToDom("blur",()=>e.state().markAsTouched()),e.registerAsBinding(),a.tagName==="SELECT"&&Ca(a,()=>{t&&(a.value=e.state().controlValue())},e.destroyRef);let l=Mn();return()=>{let y=e.state(),E=y.controlValue();Te(l,"controlValue",E)&&fa(a,E);for(let A of pi){let j=mi(y,A);Te(l,A,j)&&(i.setInputOnDirectives(A,j),e.elementAcceptsNativeProperty(A)&&hi(e.renderer,a,A,j))}t=!0}}var _a=Symbol(),Sa=new sn(""),Pe=(()=>{class i{field=q.required({alias:"formField"});renderer=w(Si);destroyRef=w(dn);state=C(()=>this.field()());injector=w(We);element=w(un).nativeElement;elementIsNativeFormElement=ca(this.element);elementAcceptsNumericValues=ma(this.element);elementAcceptsTextualValues=pa(this.element);nativeFormElement=this.elementIsNativeFormElement?this.element:void 0;focuser=n=>this.element.focus(n);controlValueAccessors=w(Wi,{optional:!0,self:!0});config=w(na,{optional:!0});parseErrorsSource=B(void 0);_interopNgControl;get interopNgControl(){return this._interopNgControl??=new di(this.state)}parseErrors=C(()=>this.parseErrorsSource()?.().map(n=>R(S({},n),{fieldTree:P(this.state).fieldTree,formField:this}))??[]);errors=C(()=>this.state().errors().filter(n=>!n.formField||n.formField===this));isFieldBinding=!1;get controlValueAccessor(){return this.controlValueAccessors?.[0]??this.interopNgControl?.valueAccessor??void 0}installClassBindingEffect(){let n=Object.entries(this.config?.classes??{}).map(([a,r])=>[a,C(()=>r(this))]);if(n.length===0)return;let t=Mn();Li({write:()=>{for(let[a,r]of n){let l=r();Te(t,a,l)&&(l?this.renderer.addClass(this.element,a):this.renderer.removeClass(this.element,a))}}},{injector:this.injector})}focus(n){this.focuser(n)}registerAsBinding(n){if(this.isFieldBinding)throw new H(1913,!1);this.isFieldBinding=!0,this.installClassBindingEffect(),n?.focus&&(this.focuser=t=>n.focus(t)),pe(t=>{let a=this.state();a.nodeState.formFieldBindings.update(r=>[...r,this]),t(()=>{a.nodeState.formFieldBindings.update(r=>r.filter(l=>l!==this))})},{injector:this.injector})}[_a];\u0275ngControlCreate(n){if(!n.hasPassThrough)if(this.controlValueAccessor)this.\u0275ngControlUpdate=ga(n,this);else if(n.customControl)this.\u0275ngControlUpdate=ya(n,this);else if(this.elementIsNativeFormElement)this.\u0275ngControlUpdate=va(n,this,this.parseErrorsSource);else throw new H(1914,!1)}\u0275ngControlUpdate;elementAcceptsNativeProperty(n){if(!this.elementIsNativeFormElement)return!1;switch(n){case"min":case"max":return this.elementAcceptsNumericValues;case"minLength":case"maxLength":return this.elementAcceptsTextualValues;case"disabled":case"required":case"readonly":case"name":return!0;default:return!1}}static \u0275fac=function(t){return new(t||i)};static \u0275dir=cn({type:i,selectors:[["","formField",""]],inputs:{field:[1,"formField","field"]},exportAs:["formField"],features:[pn([{provide:Sa,useExisting:i},{provide:Yi,useFactory:()=>w(i).interopNgControl},{provide:sa,useFactory:()=>w(i).parseErrorsSource}]),Mi("formField")]})}return i})();var Dt=i=>{i=1831565813+(i|=0)|0;let e=Math.imul(i^i>>>15,1|i);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296},fi=class{constructor(e){this.dictionaries=void 0,this.length=void 0,this.separator=void 0,this.style=void 0,this.seed=void 0;let{length:n,separator:t,dictionaries:a,style:r,seed:l}=e;this.dictionaries=a,this.separator=t,this.length=n,this.style=r,this.seed=l}generate(){if(!this.dictionaries)throw new Error('Cannot find any dictionary. Please provide at least one, or leave the "dictionary" field empty in the config object');if(this.length<=0)throw new Error("Invalid length provided");if(this.length>this.dictionaries.length)throw new Error(`The length cannot be bigger than the number of dictionaries.
Length provided: ${this.length}. Number of dictionaries provided: ${this.dictionaries.length}`);let e=this.seed;return this.dictionaries.slice(0,this.length).reduce((n,t)=>{let a;e?(a=(l=>{if(typeof l=="string"){let y=l.split("").map(A=>A.charCodeAt(0)).reduce((A,j)=>A+j,1),E=Math.floor(Number(y));return Dt(E)}return Dt(l)})(e),e=4294967296*a):a=Math.random();let r=t[Math.floor(a*t.length)]||"";if(this.style==="lowerCase")r=r.toLowerCase();else if(this.style==="capital"){let[l,...y]=r.split("");r=l.toUpperCase()+y.join("")}else this.style==="upperCase"&&(r=r.toUpperCase());return n?`${n}${this.separator}${r}`:`${r}`},"")}},At={separator:"_",dictionaries:[]},wt=i=>{let e=[...i&&i.dictionaries||At.dictionaries],n=R(S(S({},At),i),{length:i&&i.length||e.length,dictionaries:e});if(!i||!i.dictionaries||!i.dictionaries.length)throw new Error('A "dictionaries" array must be provided. This is a breaking change introduced starting from Unique Name Generator v4. Read more about the breaking change here: https://github.com/andreasonny83/unique-names-generator#migration-guide');return new fi(n).generate()};var Tt=["aardvark","aardwolf","albatross","alligator","alpaca","amphibian","anaconda","angelfish","anglerfish","ant","anteater","antelope","antlion","ape","aphid","armadillo","asp","baboon","badger","bandicoot","barnacle","barracuda","basilisk","bass","bat","bear","beaver","bedbug","bee","beetle","bird","bison","blackbird","boa","boar","bobcat","bobolink","bonobo","booby","bovid","bug","butterfly","buzzard","camel","canid","canidae","capybara","cardinal","caribou","carp","cat","caterpillar","catfish","catshark","cattle","centipede","cephalopod","chameleon","cheetah","chickadee","chicken","chimpanzee","chinchilla","chipmunk","cicada","clam","clownfish","cobra","cockroach","cod","condor","constrictor","coral","cougar","cow","coyote","crab","crane","crawdad","crayfish","cricket","crocodile","crow","cuckoo","damselfly","deer","dingo","dinosaur","dog","dolphin","donkey","dormouse","dove","dragon","dragonfly","duck","eagle","earthworm","earwig","echidna","eel","egret","elephant","elk","emu","ermine","falcon","felidae","ferret","finch","firefly","fish","flamingo","flea","fly","flyingfish","fowl","fox","frog","galliform","gamefowl","gayal","gazelle","gecko","gerbil","gibbon","giraffe","goat","goldfish","goose","gopher","gorilla","grasshopper","grouse","guan","guanaco","guineafowl","gull","guppy","haddock","halibut","hamster","hare","harrier","hawk","hedgehog","heron","herring","hippopotamus","hookworm","hornet","horse","hoverfly","hummingbird","hyena","iguana","impala","jackal","jaguar","jay","jellyfish","junglefowl","kangaroo","kingfisher","kite","kiwi","koala","koi","krill","ladybug","lamprey","landfowl","lark","leech","lemming","lemur","leopard","leopon","limpet","lion","lizard","llama","lobster","locust","loon","louse","lungfish","lynx","macaw","mackerel","magpie","mammal","manatee","mandrill","marlin","marmoset","marmot","marsupial","marten","mastodon","meadowlark","meerkat","mink","minnow","mite","mockingbird","mole","mollusk","mongoose","monkey","moose","mosquito","moth","mouse","mule","muskox","narwhal","newt","nightingale","ocelot","octopus","opossum","orangutan","orca","ostrich","otter","owl","ox","panda","panther","parakeet","parrot","parrotfish","partridge","peacock","peafowl","pelican","penguin","perch","pheasant","pig","pigeon","pike","pinniped","piranha","planarian","platypus","pony","porcupine","porpoise","possum","prawn","primate","ptarmigan","puffin","puma","python","quail","quelea","quokka","rabbit","raccoon","rat","rattlesnake","raven","reindeer","reptile","rhinoceros","roadrunner","rodent","rook","rooster","roundworm","sailfish","salamander","salmon","sawfish","scallop","scorpion","seahorse","shark","sheep","shrew","shrimp","silkworm","silverfish","skink","skunk","sloth","slug","smelt","snail","snake","snipe","sole","sparrow","spider","spoonbill","squid","squirrel","starfish","stingray","stoat","stork","sturgeon","swallow","swan","swift","swordfish","swordtail","tahr","takin","tapir","tarantula","tarsier","termite","tern","thrush","tick","tiger","tiglon","toad","tortoise","toucan","trout","tuna","turkey","turtle","tyrannosaurus","unicorn","urial","vicuna","viper","vole","vulture","wallaby","walrus","warbler","wasp","weasel","whale","whippet","whitefish","wildcat","wildebeest","wildfowl","wolf","wolverine","wombat","woodpecker","worm","wren","xerinae","yak","zebra"],xt=["amaranth","amber","amethyst","apricot","aqua","aquamarine","azure","beige","black","blue","blush","bronze","brown","chocolate","coffee","copper","coral","crimson","cyan","emerald","fuchsia","gold","gray","green","harlequin","indigo","ivory","jade","lavender","lime","magenta","maroon","moccasin","olive","orange","peach","pink","plum","purple","red","rose","salmon","sapphire","scarlet","silver","tan","teal","tomato","turquoise","violet","white","yellow"];var Ge=class i{_config={dictionaries:[xt,Tt],length:2,separator:" ",style:"capital"};generate(){return wt(this._config)}static \u0275fac=function(n){return new(n||i)};static \u0275prov=ln({token:i,factory:i.\u0275fac,providedIn:"root"})};function Ma(i){ci(i.url,{message:"URL is required"})}var le=class{_nameService=w(Ge);model=B(this._createEmptyConfig());form=ai(this.model,e=>{ci(e.name),e.config.requests&&ri(e.config.requests,Ma),e.config&&Et(e.config,Vi)});isFormValid=C(()=>this.form().valid());activeTab=B("general");loadConfig(e){e===null?this.model.set(this._createEmptyConfig()):this.model.set(e)}reset(){this.model.set(this._createEmptyConfig()),this.form().reset(),this.activeTab.set("general")}submit(){return this.model()}setActiveTab(e){this.activeTab.set(e)}onJsonTextAreaChange(){this.model.update(e=>S({},e))}addRequest(){this.model.update(e=>R(S({},e),{config:R(S({},e.config),{requests:[...e.config.requests??[],S({},Bn)]})}))}removeRequest(e){this.model.update(n=>R(S({},n),{config:R(S({},n.config),{requests:n.config.requests?.filter((t,a)=>a!==e)??[]})}))}addGlobalExitStatusCode(){this.model.update(e=>R(S({},e),{config:R(S({},e.config),{options:R(S({},e.config.options),{workerEarlyExit:R(S({},e.config.options?.workerEarlyExit),{exitStatusCodes:[...e.config.options?.workerEarlyExit?.exitStatusCodes??[],500]})})})}))}removeGlobalExitStatusCode(e){this.model.update(n=>R(S({},n),{config:R(S({},n.config),{options:R(S({},n.config.options),{workerEarlyExit:R(S({},n.config.options?.workerEarlyExit),{exitStatusCodes:n.config.options?.workerEarlyExit?.exitStatusCodes?.filter((t,a)=>a!==e)??[]})})})}))}addRequestExitStatusCode(e){this.model.update(n=>{let t=[...n.config.requests??[]];if(t[e]?.earlyExit){let a=t[e].earlyExit?.exitStatusCodes??[];t[e]=R(S({},t[e]),{earlyExit:R(S({},t[e].earlyExit),{exitStatusCodes:[...a,500]})})}return R(S({},n),{config:R(S({},n.config),{requests:t})})})}removeRequestExitStatusCode(e,n){this.model.update(t=>{let a=[...t.config.requests??[]];if(a[e]?.earlyExit?.exitStatusCodes){let r=a[e].earlyExit.exitStatusCodes;a[e]=R(S({},a[e]),{earlyExit:R(S({},a[e].earlyExit),{exitStatusCodes:r.filter((l,y)=>y!==n)})})}return R(S({},t),{config:R(S({},t.config),{requests:a})})})}_createEmptyConfig(){let e=Oi;return e.requests=[S({},Bn)],{config:e,name:this._nameService.generate()}}};var ye=class i{_elementRef=w(un);_destroyRef=w(dn);constructor(){bi(this._elementRef.nativeElement,"wheel",{passive:!1}).pipe(Ji(this._destroyRef)).subscribe(e=>e.preventDefault())}static \u0275fac=function(n){return new(n||i)};static \u0275dir=cn({type:i,selectors:[["","appPreventNumberScroll",""]]})};function Ea(i,e){if(i&1&&c(0),i&2){let n=e.$implicit;J(" ",n.message," ")}}function Da(i,e){if(i&1&&(s(0,"p",11),K(1,Ea,1,1,null,null,Y),o()),i&2){let n=h(2);d(),I(n.form().errorRateThreshold().errors())}}function Aa(i,e){if(i&1&&c(0),i&2){let n=e.$implicit;J(" ",n.message," ")}}function wa(i,e){if(i&1&&(s(0,"p",11),K(1,Aa,1,1,null,null,Y),o()),i&2){let n=h(2);d(),I(n.form().monitoringWindowSeconds().errors())}}function Ta(i,e){if(i&1&&c(0),i&2){let n=e.$implicit;J(" ",n.message," ")}}function xa(i,e){if(i&1&&(s(0,"p",11),K(1,Ta,1,1,null,null,Y),o()),i&2){let n=h().$index,t=h(2);d(),I(t.form().exitStatusCodes[n]().errors())}}function Ra(i,e){if(i&1){let n=Z();s(0,"fieldset",7)(1,"div",17),D(2,"input",18),z(),s(3,"app-button",15),M("click",function(){let a=T(n).$index,r=h(2);return x(r.removeExitStatusCode(a))})("onKeyDown",function(){let a=T(n).$index,r=h(2);return x(r.removeExitStatusCode(a))}),o()(),N(4,xa,3,0,"p",11),o()}if(i&2){let n=e.$index,t=h(2);d(2),f("formField",t.form().exitStatusCodes[n]),W(),d(),f("color","error")("icon","delete")("title","Remove Code"),d(),L(t.form().exitStatusCodes[n]().touched()&&t.form().exitStatusCodes[n]().invalid()?4:-1)}}function ka(i,e){if(i&1){let n=Z();s(0,"div",5)(1,"div",6)(2,"fieldset",7)(3,"legend",8),c(4," Error Rate Threshold "),o(),D(5,"input",9),z(),s(6,"p",10),c(7,"Range: 1 - 100"),o(),N(8,Da,3,0,"p",11),o(),s(9,"fieldset",7)(10,"legend",8),c(11," Monitoring Window "),o(),D(12,"input",12),z(),s(13,"p",10),c(14,"Duration to monitor for errors (seconds)"),o(),N(15,wa,3,0,"p",11),o()(),s(16,"div")(17,"div",13)(18,"label",14),c(19,"Exit Status Codes"),o(),s(20,"app-button",15),M("click",function(){T(n);let a=h();return x(a.addExitStatusCode())})("onKeyDown",function(){T(n);let a=h();return x(a.addExitStatusCode())}),o()(),s(21,"div",16),K(22,Ra,5,5,"fieldset",7,mn),o()()()}if(i&2){let n=h();d(5),f("formField",n.form().errorRateThreshold),W(),d(3),L(n.form().errorRateThreshold().touched()&&n.form().errorRateThreshold().invalid()?8:-1),d(4),f("formField",n.form().monitoringWindowSeconds),W(),d(3),L(n.form().monitoringWindowSeconds().touched()&&n.form().monitoringWindowSeconds().invalid()?15:-1),d(5),f("color","primary")("icon","add")("title","Add Code"),d(2),I(n.getExitStatusCodes())}}var qe=class i{_service=w(le);form=q.required();model=q.required();requestIndex=q(void 0);isEnabled(){return this.model()?.enabled??!1}getExitStatusCodes(){return this.model()?.exitStatusCodes??[]}addExitStatusCode(){let e=this.requestIndex();if(e!==void 0){this._service.addRequestExitStatusCode(e);return}this._service.addGlobalExitStatusCode()}removeExitStatusCode(e){let n=this.requestIndex();if(n===void 0){this._service.removeGlobalExitStatusCode(e);return}this._service.removeRequestExitStatusCode(n,e)}static \u0275fac=function(n){return new(n||i)};static \u0275cmp=U({type:i,selectors:[["app-early-exit-config"]],inputs:{form:[1,"form"],model:[1,"model"],requestIndex:[1,"requestIndex"]},decls:7,vars:2,consts:[[1,"space-y-4"],[1,"form-control"],[1,"label","cursor-pointer"],[1,"label-text","mr-1","font-medium"],["type","checkbox",1,"checkbox","checkbox-primary","checkbox-sm",3,"formField"],[1,"mt-4","space-y-4"],[1,"grid","grid-cols-1","gap-4","md:grid-cols-2"],[1,"fieldset"],[1,"fieldset-legend","text-xs","font-bold","uppercase","opacity-70"],["type","number","placeholder","1 - 100","step","1","appPreventNumberScroll","",1,"input","outline-none!",3,"formField"],[1,"label","ml-2","py-0","text-xs","opacity-60"],[1,"label","text-error","ml-2"],["type","number","placeholder","Monitoring duration in seconds","step","1","appPreventNumberScroll","",1,"input","outline-none!",3,"formField"],[1,"mb-2","flex","items-center","justify-between"],["for","exit-status-code-input",1,"label-text","font-medium"],[3,"click","onKeyDown","color","icon","title"],[1,"space-y-2"],[1,"flex","items-center","gap-2"],["id","exit-status-code-input","type","number","placeholder","HTTP status code","appPreventNumberScroll","",1,"input","outline-none!",3,"formField"]],template:function(n,t){n&1&&(s(0,"div",0)(1,"div",1)(2,"label",2)(3,"span",3),c(4,"Enable"),o(),D(5,"input",4),z(),o()(),N(6,ka,24,7,"div",5),o()),n&2&&(d(5),f("formField",t.form().enabled),W(),d(),L(t.isEnabled()?6:-1))},dependencies:[ne,Pe,ye],encapsulation:2})};function Na(i,e){if(i&1&&c(0),i&2){let n=e.$implicit;J(" ",n.message," ")}}function La(i,e){if(i&1&&(s(0,"p",7),K(1,Na,1,1,null,null,Y),o()),i&2){let n=h();d(),I(n.form().name().errors())}}function Fa(i,e){if(i&1&&c(0),i&2){let n=e.$implicit;J(" ",n.message," ")}}function Ba(i,e){if(i&1&&(s(0,"p",7),K(1,Fa,1,1,null,null,Y),o()),i&2){let n=h();d(),I(n.form().config.options.durationSec().errors())}}function Ka(i,e){if(i&1&&c(0),i&2){let n=e.$implicit;J(" ",n.message," ")}}function Ia(i,e){if(i&1&&(s(0,"p",12),K(1,Ka,1,1,null,null,Y),o()),i&2){let n=h();d(),I(n.form().config.options.rampUpDurationSec().errors())}}function Ja(i,e){if(i&1&&c(0),i&2){let n=e.$implicit;J(" ",n.message," ")}}function Pa(i,e){if(i&1&&(s(0,"p",7),K(1,Ja,1,1,null,null,Y),o()),i&2){let n=h();d(),I(n.form().config.options.headers().errors())}}function Ga(i,e){if(i&1&&c(0),i&2){let n=e.$implicit;J(" ",n.message," ")}}function qa(i,e){if(i&1&&(s(0,"p",7),K(1,Ga,1,1,null,null,Y),o()),i&2){let n=h();d(),I(n.form().config.options.threads().errors())}}function Va(i,e){if(i&1&&c(0),i&2){let n=e.$implicit;J(" ",n.message," ")}}function Oa(i,e){if(i&1&&(s(0,"p",7),K(1,Va,1,1,null,null,Y),o()),i&2){let n=h();d(),I(n.form().config.options.workerMemoryLimit().errors())}}var En=class i{_service=w(le);form=q.required();model=q.required();engineSettingsCollapsed=B(!0);globalDefaultsCollapsed=B(!0);onJsonTextareaValueChange(){this._service.onJsonTextAreaChange()}addExitStatusCode(){this._service.addGlobalExitStatusCode()}removeExitStatusCode(e){this._service.removeGlobalExitStatusCode(e)}static \u0275fac=function(n){return new(n||i)};static \u0275cmp=U({type:i,selectors:[["app-general-config"]],inputs:{form:[1,"form"],model:[1,"model"]},decls:58,vars:17,consts:[[1,"space-y-4"],[1,"bg-base-200","border-base-300","rounded-xl","border","p-4"],[1,"grid","grid-cols-1","gap-4","md:grid-cols-2"],[1,"fieldset"],[1,"fieldset-legend","text-xs","font-bold","uppercase","opacity-70"],["id","config-name","type","text","placeholder","Enter configuration name","data-e2e","config-name-input",1,"input","outline-none!",3,"formField"],[1,"label","ml-2","py-0","text-xs","opacity-60"],[1,"label","text-error","ml-2","py-0","text-xs"],["type","number","placeholder","Total test duration","data-e2e","config-duration-input","appPreventNumberScroll","",1,"input","outline-none!",3,"formField"],[1,"mb-4"],["title","Global Defaults","icon","lan",3,"collapsedChange","collapsed"],["type","number","placeholder","Time to reach target RPS","appPreventNumberScroll","",1,"input","outline-none!",3,"formField"],[1,"label","text-error","ml-2","py-0","text-xs","text-wrap"],["placeholder",'{"User-Agent": "Tressi", "Accept": "application/json"}',3,"valueChange","value","rows"],[1,"label","ml-2","py-0","text-xs","text-wrap","opacity-60"],[1,"text-md","mb-4","flex","items-center","gap-2","font-semibold"],["name","warning"],[3,"form","model"],["title","Engine Settings","icon","tune",3,"collapsedChange","collapsed"],["type","number","placeholder","Auto-detect","appPreventNumberScroll","",1,"input","outline-none!",3,"formField"],["type","number","placeholder","Memory per worker thread","appPreventNumberScroll","",1,"input","outline-none!",3,"formField"]],template:function(n,t){n&1&&(s(0,"div",0)(1,"div",1)(2,"div",2)(3,"fieldset",3)(4,"legend",4),c(5,"Name"),o(),D(6,"input",5),z(),s(7,"p",6),c(8,"Display name for this test"),o(),N(9,La,3,0,"p",7),o(),s(10,"fieldset",3)(11,"legend",4),c(12,"Duration"),o(),D(13,"input",8),z(),s(14,"p",6),c(15,"In seconds"),o(),N(16,Ba,3,0,"p",7),o()()(),s(17,"div",9)(18,"app-collapsible-card",10),Ee("collapsedChange",function(r){return Me(t.globalDefaultsCollapsed,r)||(t.globalDefaultsCollapsed=r),r}),s(19,"div",0)(20,"fieldset",3)(21,"legend",4),c(22," Ramp Up Time "),o(),D(23,"input",11),z(),s(24,"p",6),c(25," In seconds; used if request level ramp up is not set "),o(),N(26,Ia,3,0,"p",12),o(),s(27,"fieldset",3)(28,"legend",4),c(29," Global Headers "),o(),s(30,"app-json-textarea",13),Ee("valueChange",function(r){return Me(t.model().config.options.headers,r)||(t.model().config.options.headers=r),r}),M("valueChange",function(){return t.onJsonTextareaValueChange()}),o(),s(31,"p",14),c(32," Merged with request level headers (request headers take precedence) "),o(),N(33,Pa,3,0,"p",7),o(),s(34,"div")(35,"h3",15),D(36,"app-icon",16),c(37," Early Exit "),o(),D(38,"app-early-exit-config",17),s(39,"p",14),c(40,"Applies to all requests"),o()()()()(),s(41,"div")(42,"app-collapsible-card",18),Ee("collapsedChange",function(r){return Me(t.engineSettingsCollapsed,r)||(t.engineSettingsCollapsed=r),r}),s(43,"div",2)(44,"fieldset",3)(45,"legend",4),c(46," Worker Threads "),o(),D(47,"input",19),z(),s(48,"p",6),c(49,"Limited by available system cores"),o(),N(50,qa,3,0,"p",7),o(),s(51,"fieldset",3)(52,"legend",4),c(53," Worker Memory Limit "),o(),D(54,"input",20),z(),s(55,"p",6),c(56,"In MB; memory per worker thread"),o(),N(57,Oa,3,0,"p",7),o()()()()()),n&2&&(d(6),f("formField",t.form().name),W(),d(3),L(t.form().name().touched()&&t.form().name().invalid()?9:-1),d(4),f("formField",t.form().config.options.durationSec),W(),d(3),L(t.form().config.options.durationSec().touched()&&t.form().config.options.durationSec().invalid()?16:-1),d(2),Se("collapsed",t.globalDefaultsCollapsed),d(5),f("formField",t.form().config.options.rampUpDurationSec),W(),d(3),L(t.form().config.options.rampUpDurationSec().touched()&&t.form().config.options.rampUpDurationSec().invalid()?26:-1),d(4),Se("value",t.model().config.options.headers),f("rows",3),d(3),L(t.form().config.options.headers().touched()&&t.form().config.options.headers().invalid()?33:-1),d(5),f("form",t.form().config.options.workerEarlyExit)("model",t.model().config.options.workerEarlyExit),d(4),Se("collapsed",t.engineSettingsCollapsed),d(5),f("formField",t.form().config.options.threads),W(),d(3),L(t.form().config.options.threads().touched()&&t.form().config.options.threads().invalid()?50:-1),d(4),f("formField",t.form().config.options.workerMemoryLimit),W(),d(3),L(t.form().config.options.workerMemoryLimit().touched()&&t.form().config.options.workerMemoryLimit().invalid()?57:-1))},dependencies:[ke,qe,hn,Ne,Pe,ye],encapsulation:2})};var Ha=["urlInput"];function ja(i,e){if(i&1){let n=Z();s(0,"app-button",26),M("click",function(){T(n);let a=h().$index,r=h();return x(r.removeRequest(a))})("onKeyDown",function(){T(n);let a=h().$index,r=h();return x(r.removeRequest(a))}),o()}if(i&2){let n=h(2);f("color","error")("disabled",n.model().config.requests.length===1)("icon","delete")("title","Remove Request")}}function $a(i,e){if(i&1&&(s(0,"option",14),c(1),o()),i&2){let n=e.$implicit;f("value",n),d(),xi(n)}}function za(i,e){if(i&1&&c(0),i&2){let n=e.$implicit;J(" ",n.message," ")}}function Wa(i,e){if(i&1&&(s(0,"p",15),K(1,za,1,1,null,null,Y),o()),i&2){let n=h().$index,t=h();d(),I(t.form().config.requests[n].url().errors())}}function Ua(i,e){if(i&1&&c(0),i&2){let n=e.$implicit;J(" ",n.message," ")}}function Ya(i,e){if(i&1&&(s(0,"p",15),K(1,Ua,1,1,null,null,Y),o()),i&2){let n=h().$index,t=h();d(),I(t.form().config.requests[n].rps().errors())}}function Za(i,e){if(i&1&&c(0),i&2){let n=e.$implicit;J(" ",n.message," ")}}function Qa(i,e){if(i&1&&(s(0,"p",15),K(1,Za,1,1,null,null,Y),o()),i&2){let n=h().$index,t=h();d(),I(t.form().config.requests[n].rampUpDurationSec().errors())}}function Xa(i,e){if(i&1){let n=Z();s(0,"fieldset",9)(1,"legend",10),c(2," Payload (JSON) "),o(),s(3,"app-json-textarea",27),Ee("valueChange",function(a){T(n);let r=h().$index,l=h();return Me(l.model().config.requests[r].payload,a)||(l.model().config.requests[r].payload=a),x(a)}),M("valueChange",function(){T(n);let a=h(2);return x(a.onJsonTextareaValueChange())}),o()()}if(i&2){let n=h().$index,t=h();d(3),Se("value",t.model().config.requests[n].payload),f("rows",4)}}function er(i,e){if(i&1){let n=Z();s(0,"app-collapsible-card",7),M("collapsedChange",function(){let a=T(n).$index,r=h();return x(r.toggleRequest(a))}),Ei(1,ja,1,4,"ng-template"),s(2,"div",8)(3,"fieldset",9)(4,"legend",10),c(5,"URL"),o(),s(6,"div",11),D(7,"input",12,0),z(),s(9,"select",13),K(10,$a,2,2,"option",14,Y),o(),z(),o(),N(12,Wa,3,0,"p",15),o(),s(13,"fieldset",16)(14,"legend",10),c(15,"Target"),o(),D(16,"input",17),z(),s(17,"p",18),c(18,"Requests per second"),o(),N(19,Ya,3,0,"p",15),o(),s(20,"fieldset",16)(21,"legend",10),c(22," Ramp Up Time "),o(),D(23,"input",19),z(),s(24,"p",18),c(25,"In seconds"),o(),N(26,Qa,3,0,"p",15),o(),s(27,"fieldset",9)(28,"legend",10),c(29," Headers "),o(),s(30,"app-json-textarea",20),Ee("valueChange",function(a){let r=T(n).$index,l=h();return Me(l.model().config.requests[r].headers,a)||(l.model().config.requests[r].headers=a),x(a)}),M("valueChange",function(){T(n);let a=h();return x(a.onJsonTextareaValueChange())}),o(),s(31,"p",21),c(32," Merged with global headers; request headers take precedence "),o()(),N(33,Xa,4,2,"fieldset",9),s(34,"div",22)(35,"h4",23),D(36,"app-icon",24),c(37," Early Exit Configuration "),o(),D(38,"app-early-exit-config",25),s(39,"p",21),c(40," Overrides global configuration "),o()()()()}if(i&2){let n=e.$implicit,t=e.$index,a=h();f("title",n.url!==""?`${n.method} ${n.url}`:"Empty Request")("collapsed",!a.isRequestExpanded(t)),d(7),f("formField",a.form().config.requests[t].url),W(),d(2),f("formField",a.form().config.requests[t].method),W(),d(),I(a.httpMethods),d(2),L(a.form().config.requests[t].url().touched()&&a.form().config.requests[t].url().invalid()?12:-1),d(4),f("formField",a.form().config.requests[t].rps),W(),d(3),L(a.form().config.requests[t].rps().touched()&&a.form().config.requests[t].rps().invalid()?19:-1),d(4),f("formField",a.form().config.requests[t].rampUpDurationSec),W(),d(3),L(a.form().config.requests[t].rampUpDurationSec().touched()&&a.form().config.requests[t].rampUpDurationSec().invalid()?26:-1),d(4),Se("value",a.model().config.requests[t].headers),f("rows",3),d(3),L(a.supportsRequestBody(a.model().config.requests[t].method||"GET")?33:-1),d(5),f("form",a.form().config.requests[t].earlyExit)("model",a.model().config.requests[t].earlyExit)("requestIndex",t)}}var Dn=class i{_service=w(le);form=q.required();model=q.required();expandedRequests=new Set;_requestCount=B(0);_urlInputs=Ni("urlInput");ngAfterViewInit(){this._focusLastUrlInput()}ngOnChanges(e){let n=this.model().config.requests?.length||0,t=this._requestCount();if(n>t){for(let a=0;a<n-1;a++)this.expandedRequests.add(a);this.expandedRequests.delete(n-1),this._requestCount.set(n),setTimeout(()=>this._focusLastUrlInput(),0)}else n<t&&this._requestCount.set(n)}onUrlInputChange(){this._requestCount.set(this.model().config.requests?.length||0)}toggleRequest(e){this.expandedRequests.has(e)?this.expandedRequests.delete(e):this.expandedRequests.add(e)}isRequestExpanded(e){let n=this.model().config.requests?.length||0;return e===n-1&&this.expandedRequests.has(e)===!1?!0:!this.expandedRequests.has(e)}onJsonTextareaValueChange(){this._service.onJsonTextAreaChange()}addRequest(){this._service.addRequest()}removeRequest(e){this._service.removeRequest(e)}addRequestExitStatusCode(e){this._service.addRequestExitStatusCode(e)}removeRequestExitStatusCode(e,n){this._service.removeRequestExitStatusCode(e,n)}httpMethods=qi;supportsRequestBody(e){return["POST","PUT","PATCH"].includes(e.toUpperCase())}_focusLastUrlInput(){let n=this._urlInputs()?.at(-1);n&&n.nativeElement.focus()}static \u0275fac=function(n){return new(n||i)};static \u0275cmp=U({type:i,selectors:[["app-requests-config"]],viewQuery:function(n,t){n&1&&Di(t._urlInputs,Ha,5),n&2&&Ai()},inputs:{form:[1,"form"],model:[1,"model"]},features:[vi],decls:10,vars:3,consts:[["urlInput",""],[1,"space-y-6"],[1,"mb-4","flex","items-center","justify-between"],[1,"flex","items-center","gap-2","text-lg","font-semibold"],["name","send",1,"h-5","w-5"],["data-e2e","add-endpoint-btn",3,"click","onKeyDown","color","icon","title"],[1,"mb-4","block",3,"title","collapsed"],[1,"mb-4","block",3,"collapsedChange","title","collapsed"],[1,"grid","grid-cols-1","gap-4","md:grid-cols-2"],[1,"fieldset","md:col-span-2"],[1,"fieldset-legend","text-xs","font-bold","uppercase","opacity-70"],[1,"flex","gap-2"],["type","url","placeholder","https://api.example.com/endpoint","data-e2e","endpoint-url-input",1,"input","flex-1","outline-none!",3,"formField"],[1,"select","select-bordered","w-24",3,"formField"],[3,"value"],[1,"label","text-error","ml-2"],[1,"fieldset"],["type","number","placeholder","Requests per second","appPreventNumberScroll","",1,"input","outline-none!",3,"formField"],[1,"label","ml-2","py-0","text-xs","opacity-60"],["type","number","placeholder","Time to reach target RPS","appPreventNumberScroll","",1,"input","outline-none!",3,"formField"],["placeholder",'{"Content-Type": "application/json", "Authorization": "Bearer token"}',3,"valueChange","value","rows"],[1,"label","ml-2","py-0","text-xs","text-wrap","opacity-60"],[1,"md:col-span-2"],[1,"text-md","mb-3","flex","items-center","gap-2","font-semibold"],["name","warning"],[3,"form","model","requestIndex"],[3,"click","onKeyDown","color","disabled","icon","title"],["placeholder",'{"key": "value", "array": [1, 2, 3]}',3,"valueChange","value","rows"]],template:function(n,t){n&1&&(s(0,"div",1)(1,"div")(2,"div")(3,"div",2)(4,"h3",3),D(5,"app-icon",4),c(6," All Requests "),o(),s(7,"app-button",5),M("click",function(){return t.addRequest()})("onKeyDown",function(){return t.addRequest()}),o()(),K(8,er,41,15,"app-collapsible-card",6,mn),o()()()),n&2&&(d(7),f("color","primary")("icon","add")("title","Add Request"),d(),I(t.model().config.requests))},dependencies:[ke,hn,qe,ne,Ne,Pe,ye],encapsulation:2})};var Rt=i=>({"text-base-content/60":i});function nr(i,e){if(i&1&&D(0,"app-general-config",13),i&2){let n=h();f("form",n.form)("model",n.model())}}function ir(i,e){if(i&1&&D(0,"app-requests-config",13),i&2){let n=h();f("form",n.form)("model",n.model())}}var An=class i{_service=w(le);input=q(null);output=re();closed=re();model=this._service.model;form=this._service.form;isFormValid=this._service.isFormValid;activeTab=this._service.activeTab;constructor(){pe(()=>{this._service.loadConfig(this.input())})}onSubmit(e){e.preventDefault(),this.output.emit(this._service.submit())}onCancel(e){e.preventDefault(),this._service.reset(),this.closed.emit()}setActiveTab(e){this._service.setActiveTab(e)}static \u0275fac=function(n){return new(n||i)};static \u0275cmp=U({type:i,selectors:[["app-config-form"]],inputs:{input:[1,"input"]},outputs:{output:"output",closed:"closed"},features:[pn([le])],decls:17,vars:33,consts:[[1,"-mt-12","mb-4"],[1,"flex","justify-end","gap-3"],[3,"click","color","ghost","title","icon"],[1,"flex","items-center","gap-2"],["data-e2e","save-config-btn",3,"click","color","title","icon","type","disabled"],[1,"space-y-4",3,"submit"],[1,"border-neutral","border-b"],[1,"-mt-4","flex","items-center","justify-around"],["type","button","data-e2e","general-tab",1,"flex","w-full","cursor-pointer","items-center","justify-center","gap-2","border-b-2","px-2","py-4","text-sm","font-medium","transition-colors",3,"click","ngClass"],["name","tune"],["type","button","data-e2e","requests-tab",1,"flex","w-full","cursor-pointer","items-center","justify-center","gap-2","border-b-2","px-1","py-4","text-sm","font-medium","transition-colors",3,"click","ngClass"],["name","send"],[1,"space-y-6"],[3,"form","model"]],template:function(n,t){n&1&&(s(0,"div",0)(1,"div",1)(2,"app-button",2),M("click",function(r){return t.onCancel(r)}),o(),s(3,"div",3)(4,"app-button",4),M("click",function(r){return t.onSubmit(r)}),o()()()(),s(5,"form",5),M("submit",function(r){return t.onSubmit(r)}),s(6,"div",6)(7,"nav",7)(8,"button",8),M("click",function(){return t.setActiveTab("general")}),D(9,"app-icon",9),c(10," General "),o(),s(11,"button",10),M("click",function(){return t.setActiveTab("requests")}),D(12,"app-icon",11),c(13," Requests "),o()()(),s(14,"div",12),N(15,nr,1,2,"app-general-config",13),N(16,ir,1,2,"app-requests-config",13),o()()),n&2&&(d(2),f("color","error")("ghost",!0)("title","Cancel")("icon","close"),d(2),f("color","success")("title","Save")("icon","check")("type","submit")("disabled",!t.isFormValid()),d(4),Nn("border-primary",t.activeTab()==="general")("text-primary",t.activeTab()==="general")("border-transparent",t.activeTab()!=="general")("hover:text-base-content",t.activeTab()!=="general"),f("ngClass",Ln(29,Rt,t.activeTab()!=="general")),d(3),Nn("border-primary",t.activeTab()==="requests")("text-primary",t.activeTab()==="requests")("border-transparent",t.activeTab()!=="requests")("hover:text-base-content",t.activeTab()!=="requests"),f("ngClass",Ln(31,Rt,t.activeTab()!=="requests")),d(4),L(t.activeTab()==="general"?15:-1),d(),L(t.activeTab()==="requests"?16:-1))},dependencies:[Bi,Fi,ke,En,Dn,ne],encapsulation:2})};var wn=class i{_nameService=w(Ge);configImported=re();importError=re();async onFileSelected(e){let n=e.target,t=n.files?.[0];if(t)try{let a=await t.text(),r=JSON.parse(a),l=Hi(r);if(!l.success){this.importError.emit("Invalid configuration file");return}let y={config:l.data,name:this._generateNameFromFile(t.name)};this.configImported.emit(y)}catch(a){this.importError.emit(a instanceof SyntaxError?"Invalid JSON file format":"Failed to read configuration file")}finally{n.value=""}}_generateNameFromFile(e){let n=e.replace(/\.(json)$/i,"").replace(/^(tressi|config)[-_]/i,"").replace(/[-_](\d+|[a-f0-9]{8,})$/i,"").replaceAll("-"," ").replaceAll("_"," ").replaceAll(/ {2,}/g," ").trim();return n.length===0?this._nameService.generate():n.replaceAll(/\b\w/g,t=>t.toUpperCase())}triggerFileInput(e){e.click()}static \u0275fac=function(n){return new(n||i)};static \u0275cmp=U({type:i,selectors:[["app-import-config-button"]],outputs:{configImported:"configImported",importError:"importError"},decls:3,vars:3,consts:[["fileInput",""],["type","file","accept",".json,application/json",1,"hidden",3,"change"],[3,"click","onKeyDown","color","title","icon"]],template:function(n,t){if(n&1){let a=Z();s(0,"input",1,0),M("change",function(l){return t.onFileSelected(l)}),o(),s(2,"app-button",2),M("click",function(){T(a);let l=kn(1);return x(t.triggerFileInput(l))})("onKeyDown",function(){T(a);let l=kn(1);return x(t.triggerFileInput(l))}),o()}n&2&&(d(2),f("color","secondary")("title","Import")("icon","upload_file"))},dependencies:[ne],encapsulation:2})};var tr=(i,e)=>e.id;function ar(i,e){if(i&1){let n=Z();D(0,"app-theme-switcher"),s(1,"app-import-config-button",5),M("configImported",function(a){T(n);let r=h();return x(r.onConfigImported(a))})("importError",function(a){T(n);let r=h();return x(r.onImportError(a))}),o()}}function rr(i,e){if(i&1){let n=Z();s(0,"app-button",6),M("click",function(){T(n);let a=h();return x(a.startCreate())})("onKeyDown",function(){T(n);let a=h();return x(a.startCreate())}),o(),s(1,"app-button",7),M("click",function(){T(n);let a=h();return x(a.appRouter.toHome())})("onKeyDown",function(){T(n);let a=h();return x(a.appRouter.toHome())}),o()}i&2&&(f("color","primary")("title","Create")("icon","post_add"),d(),f("color","info")("title","Dashboard")("icon","browse_activity"))}function or(i,e){if(i&1){let n=Z();s(0,"div",11)(1,"app-config-card",13),M("edit",function(a){T(n);let r=h(2);return x(r.startEdit(a))})("duplicate",function(a){T(n);let r=h(2);return x(r.startDuplicate(a))})("delete",function(a){T(n);let r=h(2);return x(r.showDeleteConfirm(a))})("navigate",function(a){T(n);let r=h(2);return x(r.appRouter.toDashboard(a.id))}),o()()}if(i&2){let n=e.$implicit;d(),wi("view-transition-name","card-"+n.id),f("input",n)}}function lr(i,e){if(i&1){let n=Z();s(0,"div",12)(1,"div",14)(2,"p",15),c(3,"No configurations found"),o(),s(4,"app-button",16),M("click",function(){T(n);let a=h(2);return x(a.startCreate())})("onKeyDown",function(){T(n);let a=h(2);return x(a.startCreate())}),o()()()}i&2&&(d(4),f("color","primary")("icon","add")("title","Create"))}function sr(i,e){if(i&1){let n=Z();s(0,"div",8)(1,"app-search-bar",9),M("queryChange",function(a){T(n);let r=h();return x(r.onSearchQueryChange(a))}),o()(),s(2,"div",10),K(3,or,2,3,"div",11,tr),o(),N(5,lr,5,3,"div",12)}if(i&2){let n=h();d(),f("query",n.searchQuery()),d(2),I(n.filteredConfigs()),d(2),L(n.hasNoConfigs()?5:-1)}}function dr(i,e){if(i&1){let n=Z();s(0,"div",3)(1,"div",17)(2,"h2",18),c(3),o(),s(4,"app-config-form",19),M("output",function(a){T(n);let r=h();return x(r.onConfigSaved(a))})("closed",function(){T(n);let a=h();return x(a.cancelEdit())}),o()()()}if(i&2){let n,t=h();d(3),J(" ",(n=t.currentConfig())!=null&&n.id?"Edit Existing":"Create New"," "),d(),f("input",t.currentConfig())}}var kt=class i{_configService=w(Gi);_toastService=w(Ii);_router=w(Ki);appRouter=w(Pi);timeService=w(Le);configs=q();configsSignal=B([]);showDeleteModal=B(!1);configToDelete=B(null);currentConfig=B(null);showForm=B(!1);searchQuery=B("");filteredConfigs=C(()=>{let e=this.configsSignal();if(!e)return[];let n=this.searchQuery().toLowerCase().trim();return n?e.filter(t=>t.name.toLowerCase().includes(n)?!0:t.config.requests.some(a=>a.url.toLowerCase().includes(n))):e});hasNoConfigs=C(()=>{let e=this.configsSignal();return!e||e.length===0});constructor(){pe(()=>{let e=this.configs();e!==void 0&&this.configsSignal.set(e)})}ngOnInit(){this._router.url.includes("/create")&&this.startCreate()}startCreate(){this.currentConfig.set(null),this.showForm.set(!0),this.appRouter.updateUrl(Fn.CONFIGS_CREATE)}startEdit(e){this.currentConfig.set(e),this.showForm.set(!0)}startDuplicate(e){let n=`${e.name} - Copy`,t=R(S({},e),{epochCreatedAt:Date.now(),epochUpdatedAt:Date.now(),id:"",name:n});this.currentConfig.set(t),this.showForm.set(!0)}showDeleteConfirm(e){this.configToDelete.set(e),this.showDeleteModal.set(!0)}cancelDelete(){this.showDeleteModal.set(!1),this.configToDelete.set(null)}async deleteConfig(){let e=this.configToDelete();e&&(await this._configService.deleteConfig(e.id),this.showDeleteModal.set(!1),this.configToDelete.set(null),this.configsSignal.update(n=>n.filter(t=>t.id!==e.id)))}async onConfigSaved(e){let n=await this._configService.saveConfig(e);this.configsSignal.update(t=>{let a=t.findIndex(r=>r.id===n.id);if(a>=0){let r=[...t];return r[a]=n,r}else return[...t,n]}),this.cancelEdit()}cancelEdit(){this.currentConfig.set(null),this.showForm.set(!1),this.appRouter.updateUrl(Fn.CONFIGS)}getConfigToDeleteName(){let e=this.configToDelete();return e&&"error"in e?"error":e?.name||"this configuration"}onSearchQueryChange(e){this.searchQuery.set(e)}onConfigImported(e){this.currentConfig.set({config:e.config,epochCreatedAt:Date.now(),epochUpdatedAt:Date.now(),id:"",name:e.name}),this.showForm.set(!0)}onImportError(e){this._toastService.show(e,"error")}dismissToast(){this._toastService.dismiss()}static \u0275fac=function(n){return new(n||i)};static \u0275cmp=U({type:i,selectors:[["app-configs"]],inputs:{configs:[1,"configs"]},decls:8,vars:7,consts:[[1,"p-12"],["data-e2e","configs-header"],[1,"px-8"],[1,"mx-auto","max-w-5xl"],[3,"confirmed","closed","isOpen","id","itemLabel"],[3,"configImported","importError"],["data-e2e","create-config-btn",3,"click","onKeyDown","color","title","icon"],[3,"click","onKeyDown","color","title","icon"],[1,"mb-6","flex","justify-start"],[3,"queryChange","query"],[1,"columns-1","gap-4","space-y-4","md:columns-2"],[1,"break-inside-avoid"],[1,"border-base-content/10","bg-base-300","mx-auto","rounded-xl","border-2","p-8"],[3,"edit","duplicate","delete","navigate","input"],[1,"text-center"],[1,"text-base-content/70","mb-4","text-lg"],["data-e2e","create-config-btn",3,"click","onKeyDown","color","icon","title"],[1,"border-base-content/10","bg-base-300","rounded-xl","border-2","p-6"],[1,"mb-4","text-xl","font-semibold"],[3,"output","closed","input"]],template:function(n,t){if(n&1&&(s(0,"div",0)(1,"app-header",1),N(2,ar,2,0),N(3,rr,2,6),o(),s(4,"div",2),N(5,sr,6,2),N(6,dr,5,2,"div",3),o(),s(7,"app-delete-confirmation-modal",4),M("confirmed",function(){return t.deleteConfig()})("closed",function(){return t.cancelDelete()}),o()()),n&2){let a;d(2),L(t.showForm()?-1:2),d(),L(!t.hasNoConfigs()&&!t.showForm()?3:-1),d(2),L(t.showForm()?-1:5),d(),L(t.showForm()?6:-1),d(),f("isOpen",t.showDeleteModal())("id",((a=t.configToDelete())==null?null:a.id)||"")("itemLabel","Configuration")}},dependencies:[nt,An,Xi,yn,et,Qi,wn,ne],encapsulation:2,changeDetection:0})};export{kt as ConfigsComponent};