@recombine-ai/bosun 0.8.1 → 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/bin/bosun.js +8 -8
  2. package/build/client/_app/immutable/chunks/{Dh6pXF8g.js → 2QZUjt52.js} +1 -1
  3. package/build/client/_app/immutable/chunks/2QZUjt52.js.br +0 -0
  4. package/build/client/_app/immutable/chunks/2QZUjt52.js.gz +0 -0
  5. package/build/client/_app/immutable/chunks/{CxPv-oiS.js → BU7aeYn4.js} +1 -1
  6. package/build/client/_app/immutable/chunks/BU7aeYn4.js.br +0 -0
  7. package/build/client/_app/immutable/chunks/BU7aeYn4.js.gz +0 -0
  8. package/build/client/_app/immutable/chunks/CYF48L9_.js +1 -0
  9. package/build/client/_app/immutable/chunks/CYF48L9_.js.br +0 -0
  10. package/build/client/_app/immutable/chunks/CYF48L9_.js.gz +0 -0
  11. package/build/client/_app/immutable/chunks/CnRh8Bgk.js +33 -0
  12. package/build/client/_app/immutable/chunks/CnRh8Bgk.js.br +0 -0
  13. package/build/client/_app/immutable/chunks/CnRh8Bgk.js.gz +0 -0
  14. package/build/client/_app/immutable/chunks/{DVRARyIt.js → aFZ7RY4i.js} +1 -1
  15. package/build/client/_app/immutable/chunks/aFZ7RY4i.js.br +0 -0
  16. package/build/client/_app/immutable/chunks/aFZ7RY4i.js.gz +0 -0
  17. package/build/client/_app/immutable/entry/{app.kqya_3wW.js → app.CBFo0y_h.js} +2 -2
  18. package/build/client/_app/immutable/entry/app.CBFo0y_h.js.br +0 -0
  19. package/build/client/_app/immutable/entry/app.CBFo0y_h.js.gz +0 -0
  20. package/build/client/_app/immutable/entry/start.B7Oj0YZC.js +1 -0
  21. package/build/client/_app/immutable/entry/start.B7Oj0YZC.js.br +2 -0
  22. package/build/client/_app/immutable/entry/start.B7Oj0YZC.js.gz +0 -0
  23. package/build/client/_app/immutable/nodes/{0.B4vchAZW.js → 0.BS46Erbu.js} +1 -1
  24. package/build/client/_app/immutable/nodes/0.BS46Erbu.js.br +0 -0
  25. package/build/client/_app/immutable/nodes/0.BS46Erbu.js.gz +0 -0
  26. package/build/client/_app/immutable/nodes/{1.D89p5MLr.js → 1.BkQc4vam.js} +1 -1
  27. package/build/client/_app/immutable/nodes/1.BkQc4vam.js.br +0 -0
  28. package/build/client/_app/immutable/nodes/1.BkQc4vam.js.gz +0 -0
  29. package/build/client/_app/immutable/nodes/{10.g2cd4u2L.js → 10.CNlp77FZ.js} +3 -3
  30. package/build/client/_app/immutable/nodes/10.CNlp77FZ.js.br +0 -0
  31. package/build/client/_app/immutable/nodes/10.CNlp77FZ.js.gz +0 -0
  32. package/build/client/_app/immutable/nodes/{17.CnJ8FTVP.js → 17.C7bkiGOl.js} +2 -1
  33. package/build/client/_app/immutable/nodes/17.C7bkiGOl.js.br +0 -0
  34. package/build/client/_app/immutable/nodes/17.C7bkiGOl.js.gz +0 -0
  35. package/build/client/_app/immutable/nodes/{18.3pGVrUEj.js → 18.CjBHM2ng.js} +1 -1
  36. package/build/client/_app/immutable/nodes/18.CjBHM2ng.js.br +0 -0
  37. package/build/client/_app/immutable/nodes/18.CjBHM2ng.js.gz +0 -0
  38. package/build/client/_app/immutable/nodes/2.CAYQyVDJ.js +35 -0
  39. package/build/client/_app/immutable/nodes/2.CAYQyVDJ.js.br +0 -0
  40. package/build/client/_app/immutable/nodes/2.CAYQyVDJ.js.gz +0 -0
  41. package/build/client/_app/immutable/nodes/{3.B1yzPx7W.js → 3.CoWzFM8T.js} +1 -1
  42. package/build/client/_app/immutable/nodes/3.CoWzFM8T.js.br +0 -0
  43. package/build/client/_app/immutable/nodes/3.CoWzFM8T.js.gz +0 -0
  44. package/build/client/_app/immutable/nodes/{4.CwDLOk2q.js → 4.BC-cU8Pp.js} +1 -1
  45. package/build/client/_app/immutable/nodes/4.BC-cU8Pp.js.br +0 -0
  46. package/build/client/_app/immutable/nodes/4.BC-cU8Pp.js.gz +0 -0
  47. package/build/client/_app/immutable/nodes/{6.DDdh0S1M.js → 6.D4x8Wh9M.js} +1 -1
  48. package/build/client/_app/immutable/nodes/6.D4x8Wh9M.js.br +0 -0
  49. package/build/client/_app/immutable/nodes/6.D4x8Wh9M.js.gz +0 -0
  50. package/build/client/_app/immutable/nodes/{8.BAyrbFTp.js → 8.CaESldgZ.js} +1 -1
  51. package/build/client/_app/immutable/nodes/8.CaESldgZ.js.br +0 -0
  52. package/build/client/_app/immutable/nodes/8.CaESldgZ.js.gz +0 -0
  53. package/build/client/_app/immutable/nodes/{9.B48tsnid.js → 9.BwiEOYkX.js} +1 -1
  54. package/build/client/_app/immutable/nodes/9.BwiEOYkX.js.br +0 -0
  55. package/build/client/_app/immutable/nodes/9.BwiEOYkX.js.gz +0 -0
  56. package/build/client/_app/version.json +1 -1
  57. package/build/client/_app/version.json.br +0 -0
  58. package/build/client/_app/version.json.gz +0 -0
  59. package/build/server/chunks/{0-BZI5aLbi.js → 0-6QwqOuSN.js} +2 -2
  60. package/build/server/chunks/{0-BZI5aLbi.js.map → 0-6QwqOuSN.js.map} +1 -1
  61. package/build/server/chunks/{1-BDM6hGDr.js → 1-BqEYCSqb.js} +2 -2
  62. package/build/server/chunks/{1-BDM6hGDr.js.map → 1-BqEYCSqb.js.map} +1 -1
  63. package/build/server/chunks/{10-CNmZTwOX.js → 10-BWSo2Lz2.js} +3 -3
  64. package/build/server/chunks/{10-CNmZTwOX.js.map → 10-BWSo2Lz2.js.map} +1 -1
  65. package/build/server/chunks/{17-DNQu2gqY.js → 17-C5jRC6rL.js} +2 -2
  66. package/build/server/chunks/{17-DNQu2gqY.js.map → 17-C5jRC6rL.js.map} +1 -1
  67. package/build/server/chunks/{18-DD7kH25_.js → 18-BzERVoaR.js} +2 -2
  68. package/build/server/chunks/{18-DD7kH25_.js.map → 18-BzERVoaR.js.map} +1 -1
  69. package/build/server/chunks/{2-B4l1dmbw.js → 2-DTdewCMV.js} +3 -3
  70. package/build/server/chunks/{2-B4l1dmbw.js.map → 2-DTdewCMV.js.map} +1 -1
  71. package/build/server/chunks/{3-DLMV7RDW.js → 3-Xnzo0PPo.js} +2 -2
  72. package/build/server/chunks/{3-DLMV7RDW.js.map → 3-Xnzo0PPo.js.map} +1 -1
  73. package/build/server/chunks/{4-D8lI6JPX.js → 4-BKFeDeOj.js} +2 -2
  74. package/build/server/chunks/{4-D8lI6JPX.js.map → 4-BKFeDeOj.js.map} +1 -1
  75. package/build/server/chunks/{6-il0E4l2K.js → 6-CYC178cM.js} +2 -2
  76. package/build/server/chunks/{6-il0E4l2K.js.map → 6-CYC178cM.js.map} +1 -1
  77. package/build/server/chunks/{8-DVq9JSHT.js → 8-msXmgb8C.js} +2 -2
  78. package/build/server/chunks/{8-DVq9JSHT.js.map → 8-msXmgb8C.js.map} +1 -1
  79. package/build/server/chunks/{9-Drdc8JKo.js → 9-COYHphb5.js} +2 -2
  80. package/build/server/chunks/{9-Drdc8JKo.js.map → 9-COYHphb5.js.map} +1 -1
  81. package/build/server/chunks/{ContextEditor-DwSmZH0Y.js → ContextEditor-CsiHhmH8.js} +30 -2
  82. package/build/server/chunks/ContextEditor-CsiHhmH8.js.map +1 -0
  83. package/build/server/chunks/{_layout.svelte-CKG7wCHp.js → _layout.svelte-CqwbWo_W.js} +4 -2
  84. package/build/server/chunks/_layout.svelte-CqwbWo_W.js.map +1 -0
  85. package/build/server/chunks/{_page.svelte-ByAHE72E.js → _page.svelte-DASkT6Tk.js} +3 -2
  86. package/build/server/chunks/_page.svelte-DASkT6Tk.js.map +1 -0
  87. package/build/server/index.js +1 -1
  88. package/build/server/index.js.map +1 -1
  89. package/build/server/manifest.js +12 -12
  90. package/build/server/manifest.js.map +1 -1
  91. package/package.json +16 -3
  92. package/src/backend/traces/latency-recordings.ts +2 -4
  93. package/build/client/_app/immutable/chunks/CxPv-oiS.js.br +0 -0
  94. package/build/client/_app/immutable/chunks/CxPv-oiS.js.gz +0 -0
  95. package/build/client/_app/immutable/chunks/DQzkcGy8.js +0 -1
  96. package/build/client/_app/immutable/chunks/DQzkcGy8.js.br +0 -0
  97. package/build/client/_app/immutable/chunks/DQzkcGy8.js.gz +0 -0
  98. package/build/client/_app/immutable/chunks/DVRARyIt.js.br +0 -0
  99. package/build/client/_app/immutable/chunks/DVRARyIt.js.gz +0 -0
  100. package/build/client/_app/immutable/chunks/Dh5nRfGH.js +0 -33
  101. package/build/client/_app/immutable/chunks/Dh5nRfGH.js.br +0 -0
  102. package/build/client/_app/immutable/chunks/Dh5nRfGH.js.gz +0 -0
  103. package/build/client/_app/immutable/chunks/Dh6pXF8g.js.br +0 -0
  104. package/build/client/_app/immutable/chunks/Dh6pXF8g.js.gz +0 -0
  105. package/build/client/_app/immutable/entry/app.kqya_3wW.js.br +0 -0
  106. package/build/client/_app/immutable/entry/app.kqya_3wW.js.gz +0 -0
  107. package/build/client/_app/immutable/entry/start.DDtVt-Kd.js +0 -1
  108. package/build/client/_app/immutable/entry/start.DDtVt-Kd.js.br +0 -0
  109. package/build/client/_app/immutable/entry/start.DDtVt-Kd.js.gz +0 -0
  110. package/build/client/_app/immutable/nodes/0.B4vchAZW.js.br +0 -0
  111. package/build/client/_app/immutable/nodes/0.B4vchAZW.js.gz +0 -0
  112. package/build/client/_app/immutable/nodes/1.D89p5MLr.js.br +0 -0
  113. package/build/client/_app/immutable/nodes/1.D89p5MLr.js.gz +0 -0
  114. package/build/client/_app/immutable/nodes/10.g2cd4u2L.js.br +0 -0
  115. package/build/client/_app/immutable/nodes/10.g2cd4u2L.js.gz +0 -0
  116. package/build/client/_app/immutable/nodes/17.CnJ8FTVP.js.br +0 -0
  117. package/build/client/_app/immutable/nodes/17.CnJ8FTVP.js.gz +0 -0
  118. package/build/client/_app/immutable/nodes/18.3pGVrUEj.js.br +0 -0
  119. package/build/client/_app/immutable/nodes/18.3pGVrUEj.js.gz +0 -0
  120. package/build/client/_app/immutable/nodes/2.Cvzapyls.js +0 -35
  121. package/build/client/_app/immutable/nodes/2.Cvzapyls.js.br +0 -0
  122. package/build/client/_app/immutable/nodes/2.Cvzapyls.js.gz +0 -0
  123. package/build/client/_app/immutable/nodes/3.B1yzPx7W.js.br +0 -0
  124. package/build/client/_app/immutable/nodes/3.B1yzPx7W.js.gz +0 -0
  125. package/build/client/_app/immutable/nodes/4.CwDLOk2q.js.br +0 -0
  126. package/build/client/_app/immutable/nodes/4.CwDLOk2q.js.gz +0 -0
  127. package/build/client/_app/immutable/nodes/6.DDdh0S1M.js.br +0 -0
  128. package/build/client/_app/immutable/nodes/6.DDdh0S1M.js.gz +0 -0
  129. package/build/client/_app/immutable/nodes/8.BAyrbFTp.js.br +0 -0
  130. package/build/client/_app/immutable/nodes/8.BAyrbFTp.js.gz +0 -0
  131. package/build/client/_app/immutable/nodes/9.B48tsnid.js.br +0 -0
  132. package/build/client/_app/immutable/nodes/9.B48tsnid.js.gz +0 -0
  133. package/build/server/chunks/ContextEditor-DwSmZH0Y.js.map +0 -1
  134. package/build/server/chunks/_layout.svelte-CKG7wCHp.js.map +0 -1
  135. package/build/server/chunks/_page.svelte-ByAHE72E.js.map +0 -1
@@ -1,35 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["../chunks/DLQqXQ6R.js","../chunks/C1FmrZbK.js","../assets/editor.BMIWPGx3.css"])))=>i.map(i=>d[i]);
2
- var tn=Object.defineProperty;var nn=(M,N,v)=>N in M?tn(M,N,{enumerable:!0,configurable:!0,writable:!0,value:v}):M[N]=v;var Oe=(M,N,v)=>nn(M,typeof N!="symbol"?N+"":N,v);import"../chunks/CWj6FrbW.js";import{o as Pt,b as Vt,s as Ie,a as rn}from"../chunks/CB3MYTwM.js";import{p as gt,h as I,i as De,l as Se,k as He,f as me,d as se,r as re,b as oe,c as yt,e as Rt,s as ye,n as je,t as Ke,u as Be,g as $e,q as tt,a as Pe,_ as on,br as sn,j as It}from"../chunks/BRMnbBOX.js";import{i as Ce}from"../chunks/BFchB-2I.js";import{k as an,M as ln}from"../chunks/CJHvtD7r.js";import{e as ct,i as At}from"../chunks/D_iTaAhh.js";import{r as Wt,d as cn}from"../chunks/3HVf2z3Q.js";import{s as un}from"../chunks/DMtzEpj5.js";import{a as fn}from"../chunks/DAyj7AJo.js";import{P as mt,g as $t,s as pn}from"../chunks/Bk5z628g.js";import{B as wt}from"../chunks/C8-d_pGN.js";import{d as Ft,e as hn,f as dn,g as vn,D as mn}from"../chunks/DJH8-Pxb.js";import{I as gn}from"../chunks/Bb9ZigkD.js";import{T as Ct,a as st}from"../chunks/C1rQHXql.js";import{C as yn,P as Bt}from"../chunks/Dh5nRfGH.js";import{g as vt,r as _n}from"../chunks/DQzkcGy8.js";import{p as qe}from"../chunks/Dh6pXF8g.js";import{t as ut}from"../chunks/BEJ5fU19.js";import{_ as Ht}from"../chunks/C1FmrZbK.js";import{b as Gt}from"../chunks/CmatTLDp.js";import{e as qt,a as zt,c as xn}from"../chunks/CxPv-oiS.js";import{p as Lt}from"../chunks/DCT4VKzQ.js";import{A as bn}from"../chunks/BiBGf8wR.js";import{g as wn}from"../chunks/BmJonxL2.js";import"../chunks/B7r4ghJg.js";import{i as En}from"../chunks/rHISuZrQ.js";import{c as Mt,a as kn}from"../chunks/C3cmQ-ZQ.js";var On=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Sn(M){return M&&M.__esModule&&Object.prototype.hasOwnProperty.call(M,"default")?M.default:M}const Tn=globalThis.__sveltekit_msl5l.env;class Ln{constructor(N){Oe(this,"ws",null);Oe(this,"openHandler",null);Oe(this,"closeHandler",null);Oe(this,"errorHandler",null);Oe(this,"messageHandler",null);Oe(this,"retries",0);Oe(this,"maxRetries",5);Oe(this,"retryDelay",500);Oe(this,"retryTimeout",null);Oe(this,"isOpen",!1);Oe(this,"isDestroyed",!1);Oe(this,"agentsLoaded",!1);Oe(this,"init",()=>{if(!this.isOpen){this.agentsLoaded=!1,console.log(`Initializing websocket connection with [${this.wsUrl}]`);try{this.ws=new WebSocket(this.wsUrl)}catch{this.retryConnect();return}this.isDestroyed=!1,this.ws.onmessage=N=>{var T,w,y,E,f,r,g,O;const v=JSON.parse(N.data);v.channel==="error"?(T=this.errorHandler)==null||T.call(this,v.message):v.channel==="app-events"?(console.log("MSG:",v.event.type),v.event.type==="agents-loaded"&&(this.agentsLoaded=!0)):v.channel==="log"?console.log(`MSG: log [${v.message.severity}]`,v.message.message):v.channel==="api-call-trace"?console.log("MSG: api-call-trace",(w=v.trace)==null?void 0:w.operationName,(y=v.trace)==null?void 0:y.method,(E=v.trace)==null?void 0:E.path):v.channel==="conversational-trace"&&console.log("MSG: conversational-trace",(f=v.trace)==null?void 0:f.eventName,(r=v.trace)==null?void 0:r.role,(g=v.trace)==null?void 0:g.medium),(O=this.messageHandler)==null||O.call(this,v)},this.ws.onerror=N=>{var v;console.error("Websocket error:",N),(v=this.ws)==null||v.close(),this.retryConnect()},this.ws.onclose=()=>{console.log("Websocket closed"),this.isOpen=!1,this.retryConnect()},this.ws.onopen=()=>{var N;this.retries=0,this.isOpen=!0,this.retryTimeout&&clearTimeout(this.retryTimeout),(N=this.openHandler)==null||N.call(this),console.log("Websocket connected")}}});Oe(this,"destroy",()=>{var N;this.isDestroyed=!0,(N=this.ws)==null||N.close()});Oe(this,"onOpen",N=>{this.openHandler=N,this.isOpen&&N()});Oe(this,"onClose",N=>{this.closeHandler=N,this.isOpen||N()});Oe(this,"onError",N=>{this.errorHandler=N});Oe(this,"onMessage",N=>{this.messageHandler=N});Oe(this,"sendMessage",N=>{var v;N.channel,(v=this.ws)==null||v.send(JSON.stringify(N))});Oe(this,"isReady",()=>this.isOpen&&this.agentsLoaded);Oe(this,"retryConnect",()=>{var N,v;this.isDestroyed||(!this.isOpen&&this.retries<this.maxRetries?(this.retries++,this.init(),this.retryTimeout=setTimeout(this.retryConnect,this.retryDelay)):((N=this.errorHandler)==null||N.call(this,"WebSocket Error, please reload the browser"),(v=this.closeHandler)==null||v.call(this)))});this.wsUrl=N}}const An=Tn.PUBLIC_WS_HOST??"ws://localhost:8080",ot=new Ln(An);var Cn=me('<div class="flex h-full flex-col"><div class="h-full w-full"></div></div>');function Nn(M,N){gt(N,!0);let v=De(null),T=null,w=[],y=!1,E;Pt(async()=>{if(!E)return;qt();const f=await Ht(()=>import("../chunks/DLQqXQ6R.js").then(r=>r.e),__vite__mapDeps([0,1,2]),import.meta.url);y||(zt(f),Se(v,f.editor.create(E,{value:N.schema??"",language:"typescript",theme:"bosun-dark",lineNumbers:"off",automaticLayout:!0,minimap:{enabled:!1},matchBrackets:"never",bracketPairColorization:{enabled:!1},guides:{highlightActiveBracketPair:!1,bracketPairs:!1,bracketPairsHorizontal:!1},occurrencesHighlight:"off",selectionHighlight:!1,unicodeHighlight:{ambiguousCharacters:!1,nonBasicASCII:!1,invisibleCharacters:!1,includeStrings:!1,includeComments:!1},autoClosingQuotes:"never"}),!0),T=I(v).getModel(),w.push(I(v).onDidChangeModelContent(()=>{if(!I(v))return;const r=I(v).getValue();r!==N.schema&&N.onChange(r)})))}),Vt(()=>{y=!0;for(const r of w)try{r.dispose()}catch{}w=[];const f=T;T=null;try{if(I(v)){try{I(v).setModel(null)}catch{}I(v).dispose()}}finally{Se(v,null)}try{f==null||f.dispose()}catch{}}),He(()=>{if(!I(v))return;const f=N.schema??"";I(v).getValue()!==f&&I(v).setValue(f)}),mt(M,{get class(){return`overflow-hidden ${N.class??""}`},children:(f,r)=>{var g=Cn(),O=se(g);Gt(O,j=>E=j,()=>E),re(g),oe(f,g)}}),yt()}function Pn(M,N){return M.languages.registerCompletionItemProvider("markdown",{triggerCharacters:[" ","."],provideCompletionItems:(v,T)=>{const w=v.getValueInRange({startLineNumber:T.lineNumber,startColumn:1,endLineNumber:T.lineNumber,endColumn:T.column}),y=w.match(/\{%\s*(if|elif|for)\s+([^%]*)$/),E=w.match(/\{\{\s*([^}]*)$/);if(y||E){let r="";y?r=y[2].trim():E&&(r=E[1].trim());const{keys:g,lastPartLength:O}=Rn(N,r);return{suggestions:g.map(U=>({label:U,kind:M.languages.CompletionItemKind.Variable,insertText:U,range:{startLineNumber:T.lineNumber,endLineNumber:T.lineNumber,startColumn:T.column-O,endColumn:T.column}}))}}const f=w.match(/\{%\s*([^%]*)$/);if(f){const r=f[1].trim();return{suggestions:Nt(["if","elif","else","endif","for","endfor"],r).map((O,j)=>({label:O,kind:M.languages.CompletionItemKind.Keyword,insertText:O,sortText:String(j).padStart(2,"0"),range:{startLineNumber:T.lineNumber,endLineNumber:T.lineNumber,startColumn:T.column-r.length,endColumn:T.column}}))}}return{suggestions:[]}}})}function Rn(M,N){let v=M,T=[],w=0;if(N==="")T=Object.keys(M??{}),w=0;else if(N.includes(".")){const y=N.split("."),E=y.pop()||"";w=E.length;for(const f of y)if(v&&typeof v=="object"&&f in v)v=v[f];else{v=null;break}v&&typeof v=="object"&&(T=Nt(Object.keys(v),E))}else w=N.length,T=Nt(Object.keys(M??{}),N);return{keys:T,lastPartLength:w}}function Nt(M,N){return N?M.map((v,T)=>({value:v,index:T,match:In(v,N)})).filter(v=>v.match!==null).sort((v,T)=>v.match.kindRank!==T.match.kindRank?v.match.kindRank-T.match.kindRank:v.match.span!==T.match.span?v.match.span-T.match.span:v.match.gapCount!==T.match.gapCount?v.match.gapCount-T.match.gapCount:v.match.start!==T.match.start?v.match.start-T.match.start:v.index-T.index).map(v=>v.value):M}function In(M,N){const v=M.toLowerCase(),T=N.toLowerCase();if(!T)return null;if(v.startsWith(T))return{kindRank:0,start:0,span:T.length,gapCount:0};const w=v.indexOf(T);if(w!==-1)return{kindRank:Kn(M,w,T.length),start:w,span:T.length,gapCount:0};const y=Fn(v,T);return y?{kindRank:4,start:y.start,span:y.span,gapCount:y.gapCount}:null}function Fn(M,N){if(!M||!N)return null;let v=null,T=0;for(;T<M.length;){let w=T,y=0;for(;w<M.length&&y<N.length;)M[w]===N[y]&&(y+=1),w+=1;if(y!==N.length)break;const E=new Array(N.length);let f=w-1;for(let O=N.length-1;O>=0;O--){for(;f>=0&&M[f]!==N[O];)f-=1;if(f<0)return v;E[O]=f,f-=1}let r=0;for(let O=1;O<E.length;O++)r+=E[O]-E[O-1]-1;const g={start:E[0],span:E[E.length-1]-E[0]+1,gapCount:r};(!v||g.span<v.span||g.span===v.span&&g.gapCount<v.gapCount||g.span===v.span&&g.gapCount===v.gapCount&&g.start<v.start)&&(v=g),T=E[0]+1}return v}function Bn(M,N){return N<=0?!0:/[\s._-]/.test(M[N-1]??"")}function Mn(M,N){return N>=M.length?!0:/[\s._-]/.test(M[N]??"")}function Kn(M,N,v){const T=Bn(M,N),w=Mn(M,N+v);return T&&w?1:T?2:3}var Qt={exports:{}};/*! Browser bundle of nunjucks 3.2.4 */(function(M,N){(function(T,w){M.exports=w()})(typeof self<"u"?self:On,function(){return function(v){var T={};function w(y){if(T[y])return T[y].exports;var E=T[y]={i:y,l:!1,exports:{}};return v[y].call(E.exports,E,E.exports,w),E.l=!0,E.exports}return w.m=v,w.c=T,w.d=function(y,E,f){w.o(y,E)||Object.defineProperty(y,E,{configurable:!1,enumerable:!0,get:f})},w.n=function(y){var E=y&&y.__esModule?function(){return y.default}:function(){return y};return w.d(E,"a",E),E},w.o=function(y,E){return Object.prototype.hasOwnProperty.call(y,E)},w.p="",w(w.s=11)}([function(v,g,w){var y=Array.prototype,E=Object.prototype,f={"&":"&amp;",'"':"&quot;","'":"&#39;","<":"&lt;",">":"&gt;","\\":"&#92;"},r=/[&"'<>\\]/g,g=v.exports={};function O(m,L){return E.hasOwnProperty.call(m,L)}g.hasOwnProp=O;function j(m){return f[m]}function U(m,L,K){if(K.Update||(K=new g.TemplateError(K)),K.Update(m),!L){var D=K;K=new Error(D.message),K.name=D.name}return K}g._prettifyError=U;function F(m,L,K){var D,z;m instanceof Error&&(z=m,m=z.name+": "+z.message),Object.setPrototypeOf?(D=new Error(m),Object.setPrototypeOf(D,F.prototype)):(D=this,Object.defineProperty(D,"message",{enumerable:!1,writable:!0,value:m})),Object.defineProperty(D,"name",{value:"Template render error"}),Error.captureStackTrace&&Error.captureStackTrace(D,this.constructor);var le;if(z){var X=Object.getOwnPropertyDescriptor(z,"stack");le=X&&(X.get||function(){return X.value}),le||(le=function(){return z.stack})}else{var fe=new Error(m).stack;le=function(){return fe}}return Object.defineProperty(D,"stack",{get:function(){return le.call(D)}}),Object.defineProperty(D,"cause",{value:z}),D.lineno=L,D.colno=K,D.firstUpdate=!0,D.Update=function(J){var Z="("+(J||"unknown path")+")";return this.firstUpdate&&(this.lineno&&this.colno?Z+=" [Line "+this.lineno+", Column "+this.colno+"]":this.lineno&&(Z+=" [Line "+this.lineno+"]")),Z+=`
3
- `,this.firstUpdate&&(Z+=" "),this.message=Z+(this.message||""),this.firstUpdate=!1,this},D}Object.setPrototypeOf?Object.setPrototypeOf(F.prototype,Error.prototype):F.prototype=Object.create(Error.prototype,{constructor:{value:F}}),g.TemplateError=F;function k(m){return m.replace(r,j)}g.escape=k;function P(m){return E.toString.call(m)==="[object Function]"}g.isFunction=P;function e(m){return E.toString.call(m)==="[object Array]"}g.isArray=e;function n(m){return E.toString.call(m)==="[object String]"}g.isString=n;function i(m){return E.toString.call(m)==="[object Object]"}g.isObject=i;function d(m){return m?typeof m=="string"?m.split("."):[m]:[]}function u(m){var L=d(m);return function(D){for(var z=D,le=0;le<L.length;le++){var X=L[le];if(O(z,X))z=z[X];else return}return z}}g.getAttrGetter=u;function h(m,L,K){for(var D={},z=P(L)?L:u(L),le=0;le<m.length;le++){var X=m[le],fe=z(X,le);if(fe===void 0&&K===!0)throw new TypeError('groupby: attribute "'+L+'" resolved to undefined');(D[fe]||(D[fe]=[])).push(X)}return D}g.groupBy=h;function t(m){return Array.prototype.slice.call(m)}g.toArray=t;function o(m){var L=[];if(!m)return L;for(var K=m.length,D=t(arguments).slice(1),z=-1;++z<K;)b(D,m[z])===-1&&L.push(m[z]);return L}g.without=o;function l(m,L){for(var K="",D=0;D<L;D++)K+=m;return K}g.repeat=l;function s(m,L,K){if(m!=null){if(y.forEach&&m.forEach===y.forEach)m.forEach(L,K);else if(m.length===+m.length)for(var D=0,z=m.length;D<z;D++)L.call(K,m[D],D,m)}}g.each=s;function a(m,L){var K=[];if(m==null)return K;if(y.map&&m.map===y.map)return m.map(L);for(var D=0;D<m.length;D++)K[K.length]=L(m[D],D);return m.length===+m.length&&(K.length=m.length),K}g.map=a;function p(m,L,K){var D=-1;function z(){D++,D<m.length?L(m[D],D,z,K):K()}z()}g.asyncIter=p;function c(m,L,K){var D=C(m||{}),z=D.length,le=-1;function X(){le++;var fe=D[le];le<z?L(fe,m[fe],le,z,X):K()}X()}g.asyncFor=c;function b(m,L,K){return Array.prototype.indexOf.call(m||[],L,K)}g.indexOf=b;function C(m){var L=[];for(var K in m)O(m,K)&&L.push(K);return L}g.keys=C;function A(m){return C(m).map(function(L){return[L,m[L]]})}g._entries=A;function R(m){return C(m).map(function(L){return m[L]})}g._values=R;function V(m,L){return m=m||{},C(L).forEach(function(K){m[K]=L[K]}),m}g._assign=g.extend=V;function _(m,L){if(e(L)||n(L))return L.indexOf(m)!==-1;if(i(L))return m in L;throw new Error('Cannot use "in" operator to search for "'+m+'" in unexpected types.')}g.inOperator=_},function(v,T,w){function y(n,i){for(var d=0;d<i.length;d++){var u=i[d];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(n,f(u.key),u)}}function E(n,i,d){return i&&y(n.prototype,i),Object.defineProperty(n,"prototype",{writable:!1}),n}function f(n){var i=r(n,"string");return typeof i=="symbol"?i:String(i)}function r(n,i){if(typeof n!="object"||n===null)return n;var d=n[Symbol.toPrimitive];if(d!==void 0){var u=d.call(n,i);if(typeof u!="object")return u;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}function g(n,i){n.prototype=Object.create(i.prototype),n.prototype.constructor=n,O(n,i)}function O(n,i){return O=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(u,h){return u.__proto__=h,u},O(n,i)}var j=w(16),U=w(0);function F(n,i){return typeof n!="function"||typeof i!="function"?i:function(){var u=this.parent;this.parent=n;var h=i.apply(this,arguments);return this.parent=u,h}}function k(n,i,d){d=d||{},U.keys(d).forEach(function(h){d[h]=F(n.prototype[h],d[h])});var u=function(h){g(t,h);function t(){return h.apply(this,arguments)||this}return E(t,[{key:"typename",get:function(){return i}}]),t}(n);return U._assign(u.prototype,d),u}var P=function(){function n(){this.init.apply(this,arguments)}var i=n.prototype;return i.init=function(){},n.extend=function(u,h){return typeof u=="object"&&(h=u,u="anonymous"),k(this,u,h)},E(n,[{key:"typename",get:function(){return this.constructor.name}}]),n}(),e=function(n){g(i,n);function i(){var u,h;return h=n.call(this)||this,(u=h).init.apply(u,arguments),h}var d=i.prototype;return d.init=function(){},i.extend=function(h,t){return typeof h=="object"&&(t=h,h="anonymous"),k(this,h,t)},E(i,[{key:"typename",get:function(){return this.constructor.name}}]),i}(j);v.exports={Obj:P,EmitterObj:e}},function(v,T,w){var y=w(0),E=Array.from,f=typeof Symbol=="function"&&Symbol.iterator&&typeof E=="function",r=function(){function a(c,b){this.variables=Object.create(null),this.parent=c,this.topLevel=!1,this.isolateWrites=b}var p=a.prototype;return p.set=function(b,C,A){var R=b.split("."),V=this.variables,_=this;if(A&&(_=this.resolve(R[0],!0))){_.set(b,C);return}for(var m=0;m<R.length-1;m++){var L=R[m];V[L]||(V[L]={}),V=V[L]}V[R[R.length-1]]=C},p.get=function(b){var C=this.variables[b];return C!==void 0?C:null},p.lookup=function(b){var C=this.parent,A=this.variables[b];return A!==void 0?A:C&&C.lookup(b)},p.resolve=function(b,C){var A=C&&this.isolateWrites?void 0:this.parent,R=this.variables[b];return R!==void 0?this:A&&A.resolve(b)},p.push=function(b){return new a(this,b)},p.pop=function(){return this.parent},a}();function g(a,p,c){return function(){for(var C=arguments.length,A=new Array(C),R=0;R<C;R++)A[R]=arguments[R];var V=F(A),_,m=U(A);if(V>a.length)_=A.slice(0,a.length),A.slice(_.length,V).forEach(function(D,z){z<p.length&&(m[p[z]]=D)}),_.push(m);else if(V<a.length){_=A.slice(0,V);for(var L=V;L<a.length;L++){var K=a[L];_.push(m[K]),delete m[K]}_.push(m)}else _=A;return c.apply(this,_)}}function O(a){return a.__keywords=!0,a}function j(a){return a&&Object.prototype.hasOwnProperty.call(a,"__keywords")}function U(a){var p=a.length;if(p){var c=a[p-1];if(j(c))return c}return{}}function F(a){var p=a.length;if(p===0)return 0;var c=a[p-1];return j(c)?p-1:p}function k(a){if(typeof a!="string")return a;this.val=a,this.length=a.length}k.prototype=Object.create(String.prototype,{length:{writable:!0,configurable:!0,value:0}}),k.prototype.valueOf=function(){return this.val},k.prototype.toString=function(){return this.val};function P(a,p){return a instanceof k?new k(p):p.toString()}function e(a){var p=typeof a;return p==="string"?new k(a):p!=="function"?a:function(b){var C=a.apply(this,arguments);return typeof C=="string"?new k(C):C}}function n(a,p){return a=a??"",p&&!(a instanceof k)&&(a=y.escape(a.toString())),a}function i(a,p,c){if(a==null)throw new y.TemplateError("attempted to output null or undefined value",p+1,c+1);return a}function d(a,p){if(a!=null)return typeof a[p]=="function"?function(){for(var c=arguments.length,b=new Array(c),C=0;C<c;C++)b[C]=arguments[C];return a[p].apply(a,b)}:a[p]}function u(a,p,c,b){if(a){if(typeof a!="function")throw new Error("Unable to call `"+p+"`, which is not a function")}else throw new Error("Unable to call `"+p+"`, which is undefined or falsey");return a.apply(c,b)}function h(a,p,c){var b=p.lookup(c);return b!==void 0?b:a.lookup(c)}function t(a,p,c){return a.lineno?a:new y.TemplateError(a,p,c)}function o(a,p,c,b){if(y.isArray(a)){var C=a.length;y.asyncIter(a,function(R,V,_){switch(p){case 1:c(R,V,C,_);break;case 2:c(R[0],R[1],V,C,_);break;case 3:c(R[0],R[1],R[2],V,C,_);break;default:R.push(V,C,_),c.apply(this,R)}},b)}else y.asyncFor(a,function(R,V,_,m,L){c(R,V,_,m,L)},b)}function l(a,p,c,b){var C=0,A,R;function V(z,le){C++,R[z]=le,C===A&&b(null,R.join(""))}if(y.isArray(a))if(A=a.length,R=new Array(A),A===0)b(null,"");else for(var _=0;_<a.length;_++){var m=a[_];switch(p){case 1:c(m,_,A,V);break;case 2:c(m[0],m[1],_,A,V);break;case 3:c(m[0],m[1],m[2],_,A,V);break;default:m.push(_,A,V),c.apply(this,m)}}else{var L=y.keys(a||{});if(A=L.length,R=new Array(A),A===0)b(null,"");else for(var K=0;K<L.length;K++){var D=L[K];c(D,a[D],K,A,V)}}}function s(a){return typeof a!="object"||a===null||y.isArray(a)?a:f&&Symbol.iterator in a?E(a):a}v.exports={Frame:r,makeMacro:g,makeKeywordArgs:O,numArgs:F,suppressValue:n,ensureDefined:i,memberLookup:d,contextOrFrameLookup:h,callWrap:u,handleError:t,isArray:y.isArray,keys:y.keys,SafeString:k,copySafeness:P,markSafe:e,asyncEach:o,asyncAll:l,inOperator:y.inOperator,fromIterator:s}},function(v,T,w){function y(te,ne){for(var ge=0;ge<ne.length;ge++){var he=ne[ge];he.enumerable=he.enumerable||!1,he.configurable=!0,"value"in he&&(he.writable=!0),Object.defineProperty(te,f(he.key),he)}}function E(te,ne,ge){return ne&&y(te.prototype,ne),Object.defineProperty(te,"prototype",{writable:!1}),te}function f(te){var ne=r(te,"string");return typeof ne=="symbol"?ne:String(ne)}function r(te,ne){if(typeof te!="object"||te===null)return te;var ge=te[Symbol.toPrimitive];if(ge!==void 0){var he=ge.call(te,ne);if(typeof he!="object")return he;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(te)}function g(te,ne){te.prototype=Object.create(ne.prototype),te.prototype.constructor=te,O(te,ne)}function O(te,ne){return O=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(he,_e){return he.__proto__=_e,he},O(te,ne)}var j=w(1),U=j.Obj;function F(te,ne,ge){te instanceof ne&&ge.push(te),te instanceof k&&te.findAll(ne,ge)}var k=function(te){g(ne,te);function ne(){return te.apply(this,arguments)||this}var ge=ne.prototype;return ge.init=function(_e,ke){for(var Re=arguments,We=this,Qe=arguments.length,Ot=new Array(Qe>2?Qe-2:0),nt=2;nt<Qe;nt++)Ot[nt-2]=arguments[nt];this.lineno=_e,this.colno=ke,this.fields.forEach(function(St,Tt){var dt=Re[Tt+2];dt===void 0&&(dt=null),We[St]=dt})},ge.findAll=function(_e,ke){var Re=this;return ke=ke||[],this instanceof e?this.children.forEach(function(We){return F(We,_e,ke)}):this.fields.forEach(function(We){return F(Re[We],_e,ke)}),ke},ge.iterFields=function(_e){var ke=this;this.fields.forEach(function(Re){_e(ke[Re],Re)})},ne}(U),P=function(te){g(ne,te);function ne(){return te.apply(this,arguments)||this}return E(ne,[{key:"typename",get:function(){return"Value"}},{key:"fields",get:function(){return["value"]}}]),ne}(k),e=function(te){g(ne,te);function ne(){return te.apply(this,arguments)||this}var ge=ne.prototype;return ge.init=function(_e,ke,Re){te.prototype.init.call(this,_e,ke,Re||[])},ge.addChild=function(_e){this.children.push(_e)},E(ne,[{key:"typename",get:function(){return"NodeList"}},{key:"fields",get:function(){return["children"]}}]),ne}(k),n=e.extend("Root"),i=P.extend("Literal"),d=P.extend("Symbol"),u=e.extend("Group"),h=e.extend("Array"),t=k.extend("Pair",{fields:["key","value"]}),o=e.extend("Dict"),l=k.extend("LookupVal",{fields:["target","val"]}),s=k.extend("If",{fields:["cond","body","else_"]}),a=s.extend("IfAsync"),p=k.extend("InlineIf",{fields:["cond","body","else_"]}),c=k.extend("For",{fields:["arr","name","body","else_"]}),b=c.extend("AsyncEach"),C=c.extend("AsyncAll"),A=k.extend("Macro",{fields:["name","args","body"]}),R=A.extend("Caller"),V=k.extend("Import",{fields:["template","target","withContext"]}),_=function(te){g(ne,te);function ne(){return te.apply(this,arguments)||this}var ge=ne.prototype;return ge.init=function(_e,ke,Re,We,Qe){te.prototype.init.call(this,_e,ke,Re,We||new e,Qe)},E(ne,[{key:"typename",get:function(){return"FromImport"}},{key:"fields",get:function(){return["template","names","withContext"]}}]),ne}(k),m=k.extend("FunCall",{fields:["name","args"]}),L=m.extend("Filter"),K=L.extend("FilterAsync",{fields:["name","args","symbol"]}),D=o.extend("KeywordArgs"),z=k.extend("Block",{fields:["name","body"]}),le=k.extend("Super",{fields:["blockName","symbol"]}),X=k.extend("TemplateRef",{fields:["template"]}),fe=X.extend("Extends"),Ee=k.extend("Include",{fields:["template","ignoreMissing"]}),J=k.extend("Set",{fields:["targets","value"]}),Z=k.extend("Switch",{fields:["expr","cases","default"]}),H=k.extend("Case",{fields:["cond","body"]}),Y=e.extend("Output"),Q=k.extend("Capture",{fields:["body"]}),ue=i.extend("TemplateData"),pe=k.extend("UnaryOp",{fields:["target"]}),de=k.extend("BinOp",{fields:["left","right"]}),Te=de.extend("In"),x=de.extend("Is"),B=de.extend("Or"),G=de.extend("And"),$=pe.extend("Not"),ee=de.extend("Add"),ie=de.extend("Concat"),ve=de.extend("Sub"),ce=de.extend("Mul"),xe=de.extend("Div"),Fe=de.extend("FloorDiv"),Me=de.extend("Mod"),Ve=de.extend("Pow"),ft=pe.extend("Neg"),pt=pe.extend("Pos"),Et=k.extend("Compare",{fields:["expr","ops"]}),_t=k.extend("CompareOperand",{fields:["expr","type"]}),ht=k.extend("CallExtension",{init:function(ne,ge,he,_e){this.parent(),this.extName=ne.__name||ne,this.prop=ge,this.args=he||new e,this.contentArgs=_e||[],this.autoescape=ne.autoescape},fields:["extName","prop","args","contentArgs"]}),kt=ht.extend("CallExtensionAsync");function ze(te,ne,ge){var he=te.split(`
4
- `);he.forEach(function(_e,ke){_e&&(ge&&ke>0||!ge)&&process.stdout.write(" ".repeat(ne));var Re=ke===he.length-1?"":`
5
- `;process.stdout.write(""+_e+Re)})}function et(te,ne){if(ne=ne||0,ze(te.typename+": ",ne),te instanceof e)ze(`
6
- `),te.children.forEach(function(_e){et(_e,ne+2)});else if(te instanceof ht)ze(te.extName+"."+te.prop+`
7
- `),te.args&&et(te.args,ne+2),te.contentArgs&&te.contentArgs.forEach(function(_e){et(_e,ne+2)});else{var ge=[],he=null;te.iterFields(function(_e,ke){_e instanceof k?ge.push([ke,_e]):(he=he||{},he[ke]=_e)}),he?ze(JSON.stringify(he,null,2)+`
8
- `,null,!0):ze(`
9
- `),ge.forEach(function(_e){var ke=_e[0],Re=_e[1];ze("["+ke+"] =>",ne+2),et(Re,ne+4)})}}v.exports={Node:k,Root:n,NodeList:e,Value:P,Literal:i,Symbol:d,Group:u,Array:h,Pair:t,Dict:o,Output:Y,Capture:Q,TemplateData:ue,If:s,IfAsync:a,InlineIf:p,For:c,AsyncEach:b,AsyncAll:C,Macro:A,Caller:R,Import:V,FromImport:_,FunCall:m,Filter:L,FilterAsync:K,KeywordArgs:D,Block:z,Super:le,Extends:fe,Include:Ee,Set:J,Switch:Z,Case:H,LookupVal:l,BinOp:de,In:Te,Is:x,Or:B,And:G,Not:$,Add:ee,Concat:ie,Sub:ve,Mul:ce,Div:xe,FloorDiv:Fe,Mod:Me,Pow:Ve,Neg:ft,Pos:pt,Compare:Et,CompareOperand:_t,CallExtension:ht,CallExtensionAsync:kt,printNodes:et}},function(v,T){},function(v,T,w){function y(i,d){i.prototype=Object.create(d.prototype),i.prototype.constructor=i,E(i,d)}function E(i,d){return E=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(h,t){return h.__proto__=t,h},E(i,d)}var f=w(8),r=w(17),g=w(3),O=w(0),j=O.TemplateError,U=w(2),F=U.Frame,k=w(1),P=k.Obj,e={"==":"==","===":"===","!=":"!=","!==":"!==","<":"<",">":">","<=":"<=",">=":">="},n=function(i){y(d,i);function d(){return i.apply(this,arguments)||this}var u=d.prototype;return u.init=function(t,o){this.templateName=t,this.codebuf=[],this.lastId=0,this.buffer=null,this.bufferStack=[],this._scopeClosers="",this.inBlock=!1,this.throwOnUndefined=o},u.fail=function(t,o,l){throw o!==void 0&&(o+=1),l!==void 0&&(l+=1),new j(t,o,l)},u._pushBuffer=function(){var t=this._tmpid();return this.bufferStack.push(this.buffer),this.buffer=t,this._emit("var "+this.buffer+' = "";'),t},u._popBuffer=function(){this.buffer=this.bufferStack.pop()},u._emit=function(t){this.codebuf.push(t)},u._emitLine=function(t){this._emit(t+`
10
- `)},u._emitLines=function(){for(var t=this,o=arguments.length,l=new Array(o),s=0;s<o;s++)l[s]=arguments[s];l.forEach(function(a){return t._emitLine(a)})},u._emitFuncBegin=function(t,o){this.buffer="output",this._scopeClosers="",this._emitLine("function "+o+"(env, context, frame, runtime, cb) {"),this._emitLine("var lineno = "+t.lineno+";"),this._emitLine("var colno = "+t.colno+";"),this._emitLine("var "+this.buffer+' = "";'),this._emitLine("try {")},u._emitFuncEnd=function(t){t||this._emitLine("cb(null, "+this.buffer+");"),this._closeScopeLevels(),this._emitLine("} catch (e) {"),this._emitLine(" cb(runtime.handleError(e, lineno, colno));"),this._emitLine("}"),this._emitLine("}"),this.buffer=null},u._addScopeLevel=function(){this._scopeClosers+="})"},u._closeScopeLevels=function(){this._emitLine(this._scopeClosers+";"),this._scopeClosers=""},u._withScopedSyntax=function(t){var o=this._scopeClosers;this._scopeClosers="",t.call(this),this._closeScopeLevels(),this._scopeClosers=o},u._makeCallback=function(t){var o=this._tmpid();return"function("+o+(t?","+t:"")+`) {
11
- if(`+o+") { cb("+o+"); return; }"},u._tmpid=function(){return this.lastId++,"t_"+this.lastId},u._templateName=function(){return this.templateName==null?"undefined":JSON.stringify(this.templateName)},u._compileChildren=function(t,o){var l=this;t.children.forEach(function(s){l.compile(s,o)})},u._compileAggregate=function(t,o,l,s){var a=this;l&&this._emit(l),t.children.forEach(function(p,c){c>0&&a._emit(","),a.compile(p,o)}),s&&this._emit(s)},u._compileExpression=function(t,o){this.assertType(t,g.Literal,g.Symbol,g.Group,g.Array,g.Dict,g.FunCall,g.Caller,g.Filter,g.LookupVal,g.Compare,g.InlineIf,g.In,g.Is,g.And,g.Or,g.Not,g.Add,g.Concat,g.Sub,g.Mul,g.Div,g.FloorDiv,g.Mod,g.Pow,g.Neg,g.Pos,g.Compare,g.NodeList),this.compile(t,o)},u.assertType=function(t){for(var o=arguments.length,l=new Array(o>1?o-1:0),s=1;s<o;s++)l[s-1]=arguments[s];l.some(function(a){return t instanceof a})||this.fail("assertType: invalid type: "+t.typename,t.lineno,t.colno)},u.compileCallExtension=function(t,o,l){var s=this,a=t.args,p=t.contentArgs,c=typeof t.autoescape=="boolean"?t.autoescape:!0;if(l||this._emit(this.buffer+" += runtime.suppressValue("),this._emit('env.getExtension("'+t.extName+'")["'+t.prop+'"]('),this._emit("context"),(a||p)&&this._emit(","),a&&(a instanceof g.NodeList||this.fail("compileCallExtension: arguments must be a NodeList, use `parser.parseSignature`"),a.children.forEach(function(C,A){s._compileExpression(C,o),(A!==a.children.length-1||p.length)&&s._emit(",")})),p.length&&p.forEach(function(C,A){if(A>0&&s._emit(","),C){s._emitLine("function(cb) {"),s._emitLine("if(!cb) { cb = function(err) { if(err) { throw err; }}}");var R=s._pushBuffer();s._withScopedSyntax(function(){s.compile(C,o),s._emitLine("cb(null, "+R+");")}),s._popBuffer(),s._emitLine("return "+R+";"),s._emitLine("}")}else s._emit("null")}),l){var b=this._tmpid();this._emitLine(", "+this._makeCallback(b)),this._emitLine(this.buffer+" += runtime.suppressValue("+b+", "+c+" && env.opts.autoescape);"),this._addScopeLevel()}else this._emit(")"),this._emit(", "+c+` && env.opts.autoescape);
12
- `)},u.compileCallExtensionAsync=function(t,o){this.compileCallExtension(t,o,!0)},u.compileNodeList=function(t,o){this._compileChildren(t,o)},u.compileLiteral=function(t){if(typeof t.value=="string"){var o=t.value.replace(/\\/g,"\\\\");o=o.replace(/"/g,'\\"'),o=o.replace(/\n/g,"\\n"),o=o.replace(/\r/g,"\\r"),o=o.replace(/\t/g,"\\t"),o=o.replace(/\u2028/g,"\\u2028"),this._emit('"'+o+'"')}else t.value===null?this._emit("null"):this._emit(t.value.toString())},u.compileSymbol=function(t,o){var l=t.value,s=o.lookup(l);s?this._emit(s):this._emit('runtime.contextOrFrameLookup(context, frame, "'+l+'")')},u.compileGroup=function(t,o){this._compileAggregate(t,o,"(",")")},u.compileArray=function(t,o){this._compileAggregate(t,o,"[","]")},u.compileDict=function(t,o){this._compileAggregate(t,o,"{","}")},u.compilePair=function(t,o){var l=t.key,s=t.value;l instanceof g.Symbol?l=new g.Literal(l.lineno,l.colno,l.value):l instanceof g.Literal&&typeof l.value=="string"||this.fail("compilePair: Dict keys must be strings or names",l.lineno,l.colno),this.compile(l,o),this._emit(": "),this._compileExpression(s,o)},u.compileInlineIf=function(t,o){this._emit("("),this.compile(t.cond,o),this._emit("?"),this.compile(t.body,o),this._emit(":"),t.else_!==null?this.compile(t.else_,o):this._emit('""'),this._emit(")")},u.compileIn=function(t,o){this._emit("runtime.inOperator("),this.compile(t.left,o),this._emit(","),this.compile(t.right,o),this._emit(")")},u.compileIs=function(t,o){var l=t.right.name?t.right.name.value:t.right.value;this._emit('env.getTest("'+l+'").call(context, '),this.compile(t.left,o),t.right.args&&(this._emit(","),this.compile(t.right.args,o)),this._emit(") === true")},u._binOpEmitter=function(t,o,l){this.compile(t.left,o),this._emit(l),this.compile(t.right,o)},u.compileOr=function(t,o){return this._binOpEmitter(t,o," || ")},u.compileAnd=function(t,o){return this._binOpEmitter(t,o," && ")},u.compileAdd=function(t,o){return this._binOpEmitter(t,o," + ")},u.compileConcat=function(t,o){return this._binOpEmitter(t,o,' + "" + ')},u.compileSub=function(t,o){return this._binOpEmitter(t,o," - ")},u.compileMul=function(t,o){return this._binOpEmitter(t,o," * ")},u.compileDiv=function(t,o){return this._binOpEmitter(t,o," / ")},u.compileMod=function(t,o){return this._binOpEmitter(t,o," % ")},u.compileNot=function(t,o){this._emit("!"),this.compile(t.target,o)},u.compileFloorDiv=function(t,o){this._emit("Math.floor("),this.compile(t.left,o),this._emit(" / "),this.compile(t.right,o),this._emit(")")},u.compilePow=function(t,o){this._emit("Math.pow("),this.compile(t.left,o),this._emit(", "),this.compile(t.right,o),this._emit(")")},u.compileNeg=function(t,o){this._emit("-"),this.compile(t.target,o)},u.compilePos=function(t,o){this._emit("+"),this.compile(t.target,o)},u.compileCompare=function(t,o){var l=this;this.compile(t.expr,o),t.ops.forEach(function(s){l._emit(" "+e[s.type]+" "),l.compile(s.expr,o)})},u.compileLookupVal=function(t,o){this._emit("runtime.memberLookup(("),this._compileExpression(t.target,o),this._emit("),"),this._compileExpression(t.val,o),this._emit(")")},u._getNodeName=function(t){switch(t.typename){case"Symbol":return t.value;case"FunCall":return"the return value of ("+this._getNodeName(t.name)+")";case"LookupVal":return this._getNodeName(t.target)+'["'+this._getNodeName(t.val)+'"]';case"Literal":return t.value.toString();default:return"--expression--"}},u.compileFunCall=function(t,o){this._emit("(lineno = "+t.lineno+", colno = "+t.colno+", "),this._emit("runtime.callWrap("),this._compileExpression(t.name,o),this._emit(', "'+this._getNodeName(t.name).replace(/"/g,'\\"')+'", context, '),this._compileAggregate(t.args,o,"[","])"),this._emit(")")},u.compileFilter=function(t,o){var l=t.name;this.assertType(l,g.Symbol),this._emit('env.getFilter("'+l.value+'").call(context, '),this._compileAggregate(t.args,o),this._emit(")")},u.compileFilterAsync=function(t,o){var l=t.name,s=t.symbol.value;this.assertType(l,g.Symbol),o.set(s,s),this._emit('env.getFilter("'+l.value+'").call(context, '),this._compileAggregate(t.args,o),this._emitLine(", "+this._makeCallback(s)),this._addScopeLevel()},u.compileKeywordArgs=function(t,o){this._emit("runtime.makeKeywordArgs("),this.compileDict(t,o),this._emit(")")},u.compileSet=function(t,o){var l=this,s=[];t.targets.forEach(function(a){var p=a.value,c=o.lookup(p);c==null&&(c=l._tmpid(),l._emitLine("var "+c+";")),s.push(c)}),t.value?(this._emit(s.join(" = ")+" = "),this._compileExpression(t.value,o),this._emitLine(";")):(this._emit(s.join(" = ")+" = "),this.compile(t.body,o),this._emitLine(";")),t.targets.forEach(function(a,p){var c=s[p],b=a.value;l._emitLine('frame.set("'+b+'", '+c+", true);"),l._emitLine("if(frame.topLevel) {"),l._emitLine('context.setVariable("'+b+'", '+c+");"),l._emitLine("}"),b.charAt(0)!=="_"&&(l._emitLine("if(frame.topLevel) {"),l._emitLine('context.addExport("'+b+'", '+c+");"),l._emitLine("}"))})},u.compileSwitch=function(t,o){var l=this;this._emit("switch ("),this.compile(t.expr,o),this._emit(") {"),t.cases.forEach(function(s,a){l._emit("case "),l.compile(s.cond,o),l._emit(": "),l.compile(s.body,o),s.body.children.length&&l._emitLine("break;")}),t.default&&(this._emit("default:"),this.compile(t.default,o)),this._emit("}")},u.compileIf=function(t,o,l){var s=this;this._emit("if("),this._compileExpression(t.cond,o),this._emitLine(") {"),this._withScopedSyntax(function(){s.compile(t.body,o),l&&s._emit("cb()")}),t.else_?(this._emitLine(`}
13
- else {`),this._withScopedSyntax(function(){s.compile(t.else_,o),l&&s._emit("cb()")})):l&&(this._emitLine(`}
14
- else {`),this._emit("cb()")),this._emitLine("}")},u.compileIfAsync=function(t,o){this._emit("(function(cb) {"),this.compileIf(t,o,!0),this._emit("})("+this._makeCallback()),this._addScopeLevel()},u._emitLoopBindings=function(t,o,l,s){var a=this,p=[{name:"index",val:l+" + 1"},{name:"index0",val:l},{name:"revindex",val:s+" - "+l},{name:"revindex0",val:s+" - "+l+" - 1"},{name:"first",val:l+" === 0"},{name:"last",val:l+" === "+s+" - 1"},{name:"length",val:s}];p.forEach(function(c){a._emitLine('frame.set("loop.'+c.name+'", '+c.val+");")})},u.compileFor=function(t,o){var l=this,s=this._tmpid(),a=this._tmpid(),p=this._tmpid();if(o=o.push(),this._emitLine("frame = frame.push();"),this._emit("var "+p+" = "),this._compileExpression(t.arr,o),this._emitLine(";"),this._emit("if("+p+") {"),this._emitLine(p+" = runtime.fromIterator("+p+");"),t.name instanceof g.Array){this._emitLine("var "+s+";"),this._emitLine("if(runtime.isArray("+p+")) {"),this._emitLine("var "+a+" = "+p+".length;"),this._emitLine("for("+s+"=0; "+s+" < "+p+".length; "+s+"++) {"),t.name.children.forEach(function(_,m){var L=l._tmpid();l._emitLine("var "+L+" = "+p+"["+s+"]["+m+"];"),l._emitLine('frame.set("'+_+'", '+p+"["+s+"]["+m+"]);"),o.set(t.name.children[m].value,L)}),this._emitLoopBindings(t,p,s,a),this._withScopedSyntax(function(){l.compile(t.body,o)}),this._emitLine("}"),this._emitLine("} else {");var c=t.name.children,b=c[0],C=c[1],A=this._tmpid(),R=this._tmpid();o.set(b.value,A),o.set(C.value,R),this._emitLine(s+" = -1;"),this._emitLine("var "+a+" = runtime.keys("+p+").length;"),this._emitLine("for(var "+A+" in "+p+") {"),this._emitLine(s+"++;"),this._emitLine("var "+R+" = "+p+"["+A+"];"),this._emitLine('frame.set("'+b.value+'", '+A+");"),this._emitLine('frame.set("'+C.value+'", '+R+");"),this._emitLoopBindings(t,p,s,a),this._withScopedSyntax(function(){l.compile(t.body,o)}),this._emitLine("}"),this._emitLine("}")}else{var V=this._tmpid();o.set(t.name.value,V),this._emitLine("var "+a+" = "+p+".length;"),this._emitLine("for(var "+s+"=0; "+s+" < "+p+".length; "+s+"++) {"),this._emitLine("var "+V+" = "+p+"["+s+"];"),this._emitLine('frame.set("'+t.name.value+'", '+V+");"),this._emitLoopBindings(t,p,s,a),this._withScopedSyntax(function(){l.compile(t.body,o)}),this._emitLine("}")}this._emitLine("}"),t.else_&&(this._emitLine("if (!"+a+") {"),this.compile(t.else_,o),this._emitLine("}")),this._emitLine("frame = frame.pop();")},u._compileAsyncLoop=function(t,o,l){var s=this,a=this._tmpid(),p=this._tmpid(),c=this._tmpid(),b=l?"asyncAll":"asyncEach";if(o=o.push(),this._emitLine("frame = frame.push();"),this._emit("var "+c+" = runtime.fromIterator("),this._compileExpression(t.arr,o),this._emitLine(");"),t.name instanceof g.Array){var C=t.name.children.length;this._emit("runtime."+b+"("+c+", "+C+", function("),t.name.children.forEach(function(V){s._emit(V.value+",")}),this._emit(a+","+p+",next) {"),t.name.children.forEach(function(V){var _=V.value;o.set(_,_),s._emitLine('frame.set("'+_+'", '+_+");")})}else{var A=t.name.value;this._emitLine("runtime."+b+"("+c+", 1, function("+A+", "+a+", "+p+",next) {"),this._emitLine('frame.set("'+A+'", '+A+");"),o.set(A,A)}this._emitLoopBindings(t,c,a,p),this._withScopedSyntax(function(){var V;l&&(V=s._pushBuffer()),s.compile(t.body,o),s._emitLine("next("+a+(V?","+V:"")+");"),l&&s._popBuffer()});var R=this._tmpid();this._emitLine("}, "+this._makeCallback(R)),this._addScopeLevel(),l&&this._emitLine(this.buffer+" += "+R+";"),t.else_&&(this._emitLine("if (!"+c+".length) {"),this.compile(t.else_,o),this._emitLine("}")),this._emitLine("frame = frame.pop();")},u.compileAsyncEach=function(t,o){this._compileAsyncLoop(t,o)},u.compileAsyncAll=function(t,o){this._compileAsyncLoop(t,o,!0)},u._compileMacro=function(t,o){var l=this,s=[],a=null,p="macro_"+this._tmpid(),c=o!==void 0;t.args.children.forEach(function(_,m){m===t.args.children.length-1&&_ instanceof g.Dict?a=_:(l.assertType(_,g.Symbol),s.push(_))});var b=[].concat(s.map(function(_){return"l_"+_.value}),["kwargs"]),C=s.map(function(_){return'"'+_.value+'"'}),A=(a&&a.children||[]).map(function(_){return'"'+_.key.value+'"'}),R;c?R=o.push(!0):R=new F,this._emitLines("var "+p+" = runtime.makeMacro(","["+C.join(", ")+"], ","["+A.join(", ")+"], ","function ("+b.join(", ")+") {","var callerFrame = frame;","frame = "+(c?"frame.push(true);":"new runtime.Frame();"),"kwargs = kwargs || {};",'if (Object.prototype.hasOwnProperty.call(kwargs, "caller")) {','frame.set("caller", kwargs.caller); }'),s.forEach(function(_){l._emitLine('frame.set("'+_.value+'", l_'+_.value+");"),R.set(_.value,"l_"+_.value)}),a&&a.children.forEach(function(_){var m=_.key.value;l._emit('frame.set("'+m+'", '),l._emit('Object.prototype.hasOwnProperty.call(kwargs, "'+m+'")'),l._emit(' ? kwargs["'+m+'"] : '),l._compileExpression(_.value,R),l._emit(");")});var V=this._pushBuffer();return this._withScopedSyntax(function(){l.compile(t.body,R)}),this._emitLine("frame = "+(c?"frame.pop();":"callerFrame;")),this._emitLine("return new runtime.SafeString("+V+");"),this._emitLine("});"),this._popBuffer(),p},u.compileMacro=function(t,o){var l=this._compileMacro(t),s=t.name.value;o.set(s,l),o.parent?this._emitLine('frame.set("'+s+'", '+l+");"):(t.name.value.charAt(0)!=="_"&&this._emitLine('context.addExport("'+s+'");'),this._emitLine('context.setVariable("'+s+'", '+l+");"))},u.compileCaller=function(t,o){this._emit("(function (){");var l=this._compileMacro(t,o);this._emit("return "+l+";})()")},u._compileGetTemplate=function(t,o,l,s){var a=this._tmpid(),p=this._templateName(),c=this._makeCallback(a),b=l?"true":"false",C=s?"true":"false";return this._emit("env.getTemplate("),this._compileExpression(t.template,o),this._emitLine(", "+b+", "+p+", "+C+", "+c),a},u.compileImport=function(t,o){var l=t.target.value,s=this._compileGetTemplate(t,o,!1,!1);this._addScopeLevel(),this._emitLine(s+".getExported("+(t.withContext?"context.getVariables(), frame, ":"")+this._makeCallback(s)),this._addScopeLevel(),o.set(l,s),o.parent?this._emitLine('frame.set("'+l+'", '+s+");"):this._emitLine('context.setVariable("'+l+'", '+s+");")},u.compileFromImport=function(t,o){var l=this,s=this._compileGetTemplate(t,o,!1,!1);this._addScopeLevel(),this._emitLine(s+".getExported("+(t.withContext?"context.getVariables(), frame, ":"")+this._makeCallback(s)),this._addScopeLevel(),t.names.children.forEach(function(a){var p,c,b=l._tmpid();a instanceof g.Pair?(p=a.key.value,c=a.value.value):(p=a.value,c=p),l._emitLine("if(Object.prototype.hasOwnProperty.call("+s+', "'+p+'")) {'),l._emitLine("var "+b+" = "+s+"."+p+";"),l._emitLine("} else {"),l._emitLine(`cb(new Error("cannot import '`+p+`'")); return;`),l._emitLine("}"),o.set(c,b),o.parent?l._emitLine('frame.set("'+c+'", '+b+");"):l._emitLine('context.setVariable("'+c+'", '+b+");")})},u.compileBlock=function(t){var o=this._tmpid();this.inBlock||this._emit('(parentTemplate ? function(e, c, f, r, cb) { cb(""); } : '),this._emit('context.getBlock("'+t.name.value+'")'),this.inBlock||this._emit(")"),this._emitLine("(env, context, frame, runtime, "+this._makeCallback(o)),this._emitLine(this.buffer+" += "+o+";"),this._addScopeLevel()},u.compileSuper=function(t,o){var l=t.blockName.value,s=t.symbol.value,a=this._makeCallback(s);this._emitLine('context.getSuper(env, "'+l+'", b_'+l+", frame, runtime, "+a),this._emitLine(s+" = runtime.markSafe("+s+");"),this._addScopeLevel(),o.set(s,s)},u.compileExtends=function(t,o){var l=this._tmpid(),s=this._compileGetTemplate(t,o,!0,!1);this._emitLine("parentTemplate = "+s),this._emitLine("for(var "+l+" in parentTemplate.blocks) {"),this._emitLine("context.addBlock("+l+", parentTemplate.blocks["+l+"]);"),this._emitLine("}"),this._addScopeLevel()},u.compileInclude=function(t,o){this._emitLine("var tasks = [];"),this._emitLine("tasks.push("),this._emitLine("function(callback) {");var l=this._compileGetTemplate(t,o,!1,t.ignoreMissing);this._emitLine("callback(null,"+l+");});"),this._emitLine("});");var s=this._tmpid();this._emitLine("tasks.push("),this._emitLine("function(template, callback){"),this._emitLine("template.render(context.getVariables(), frame, "+this._makeCallback(s)),this._emitLine("callback(null,"+s+");});"),this._emitLine("});"),this._emitLine("tasks.push("),this._emitLine("function(result, callback){"),this._emitLine(this.buffer+" += result;"),this._emitLine("callback(null);"),this._emitLine("});"),this._emitLine("env.waterfall(tasks, function(){"),this._addScopeLevel()},u.compileTemplateData=function(t,o){this.compileLiteral(t,o)},u.compileCapture=function(t,o){var l=this,s=this.buffer;this.buffer="output",this._emitLine("(function() {"),this._emitLine('var output = "";'),this._withScopedSyntax(function(){l.compile(t.body,o)}),this._emitLine("return output;"),this._emitLine("})()"),this.buffer=s},u.compileOutput=function(t,o){var l=this,s=t.children;s.forEach(function(a){a instanceof g.TemplateData?a.value&&(l._emit(l.buffer+" += "),l.compileLiteral(a,o),l._emitLine(";")):(l._emit(l.buffer+" += runtime.suppressValue("),l.throwOnUndefined&&l._emit("runtime.ensureDefined("),l.compile(a,o),l.throwOnUndefined&&l._emit(","+t.lineno+","+t.colno+")"),l._emit(`, env.opts.autoescape);
15
- `))})},u.compileRoot=function(t,o){var l=this;o&&this.fail("compileRoot: root node can't have frame"),o=new F,this._emitFuncBegin(t,"root"),this._emitLine("var parentTemplate = null;"),this._compileChildren(t,o),this._emitLine("if(parentTemplate) {"),this._emitLine("parentTemplate.rootRenderFunc(env, context, frame, runtime, cb);"),this._emitLine("} else {"),this._emitLine("cb(null, "+this.buffer+");"),this._emitLine("}"),this._emitFuncEnd(!0),this.inBlock=!0;var s=[],a=t.findAll(g.Block);a.forEach(function(p,c){var b=p.name.value;if(s.indexOf(b)!==-1)throw new Error('Block "'+b+'" defined more than once.');s.push(b),l._emitFuncBegin(p,"b_"+b);var C=new F;l._emitLine("var frame = frame.push(true);"),l.compile(p.body,C),l._emitFuncEnd()}),this._emitLine("return {"),a.forEach(function(p,c){var b="b_"+p.name.value;l._emitLine(b+": "+b+",")}),this._emitLine(`root: root
16
- };`)},u.compile=function(t,o){var l=this["compile"+t.typename];l?l.call(this,t,o):this.fail("compile: Cannot compile node: "+t.typename,t.lineno,t.colno)},u.getCode=function(){return this.codebuf.join("")},d}(P);v.exports={compile:function(d,u,h,t,o){o===void 0&&(o={});var l=new n(t,o.throwOnUndefined),s=(h||[]).map(function(p){return p.preprocess}).filter(function(p){return!!p}),a=s.reduce(function(p,c){return c(p)},d);return l.compile(r.transform(f.parse(a,h,o),u,t)),l.getCode()},Compiler:n}},function(v,T,w){function y(O,j){O.prototype=Object.create(j.prototype),O.prototype.constructor=O,E(O,j)}function E(O,j){return E=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(F,k){return F.__proto__=k,F},E(O,j)}var f=w(4),r=w(1),g=r.EmitterObj;v.exports=function(O){y(j,O);function j(){return O.apply(this,arguments)||this}var U=j.prototype;return U.resolve=function(k,P){return f.resolve(f.dirname(k),P)},U.isRelative=function(k){return k.indexOf("./")===0||k.indexOf("../")===0},j}(g)},function(v,T,w){function y(C,A){C.prototype=Object.create(A.prototype),C.prototype.constructor=C,E(C,A)}function E(C,A){return E=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(V,_){return V.__proto__=_,V},E(C,A)}var f=w(12),r=w(15),g=w(0),O=w(5),j=w(18),U=w(10),F=U.FileSystemLoader,k=U.WebLoader,P=U.PrecompiledLoader,e=w(20),n=w(21),i=w(1),d=i.Obj,u=i.EmitterObj,h=w(2),t=h.handleError,o=h.Frame,l=w(22);function s(C,A,R){f(function(){C(A,R)})}var a={type:"code",obj:{root:function(A,R,V,_,m){try{m(null,"")}catch(L){m(t(L,null,null))}}}},p=function(C){y(A,C);function A(){return C.apply(this,arguments)||this}var R=A.prototype;return R.init=function(_,m){var L=this;m=this.opts=m||{},this.opts.dev=!!m.dev,this.opts.autoescape=m.autoescape!=null?m.autoescape:!0,this.opts.throwOnUndefined=!!m.throwOnUndefined,this.opts.trimBlocks=!!m.trimBlocks,this.opts.lstripBlocks=!!m.lstripBlocks,this.loaders=[],_?this.loaders=g.isArray(_)?_:[_]:F?this.loaders=[new F("views")]:k&&(this.loaders=[new k("/views")]),typeof window<"u"&&window.nunjucksPrecompiled&&this.loaders.unshift(new P(window.nunjucksPrecompiled)),this._initLoaders(),this.globals=n(),this.filters={},this.tests={},this.asyncFilters=[],this.extensions={},this.extensionsList=[],g._entries(j).forEach(function(K){var D=K[0],z=K[1];return L.addFilter(D,z)}),g._entries(e).forEach(function(K){var D=K[0],z=K[1];return L.addTest(D,z)})},R._initLoaders=function(){var _=this;this.loaders.forEach(function(m){m.cache={},typeof m.on=="function"&&(m.on("update",function(L,K){m.cache[L]=null,_.emit("update",L,K,m)}),m.on("load",function(L,K){_.emit("load",L,K,m)}))})},R.invalidateCache=function(){this.loaders.forEach(function(_){_.cache={}})},R.addExtension=function(_,m){return m.__name=_,this.extensions[_]=m,this.extensionsList.push(m),this},R.removeExtension=function(_){var m=this.getExtension(_);m&&(this.extensionsList=g.without(this.extensionsList,m),delete this.extensions[_])},R.getExtension=function(_){return this.extensions[_]},R.hasExtension=function(_){return!!this.extensions[_]},R.addGlobal=function(_,m){return this.globals[_]=m,this},R.getGlobal=function(_){if(typeof this.globals[_]>"u")throw new Error("global not found: "+_);return this.globals[_]},R.addFilter=function(_,m,L){var K=m;return L&&this.asyncFilters.push(_),this.filters[_]=K,this},R.getFilter=function(_){if(!this.filters[_])throw new Error("filter not found: "+_);return this.filters[_]},R.addTest=function(_,m){return this.tests[_]=m,this},R.getTest=function(_){if(!this.tests[_])throw new Error("test not found: "+_);return this.tests[_]},R.resolveTemplate=function(_,m,L){var K=_.isRelative&&m?_.isRelative(L):!1;return K&&_.resolve?_.resolve(m,L):L},R.getTemplate=function(_,m,L,K,D){var z=this,le=this,X=null;if(_&&_.raw&&(_=_.raw),g.isFunction(L)&&(D=L,L=null,m=m||!1),g.isFunction(m)&&(D=m,m=!1),_ instanceof b)X=_;else{if(typeof _!="string")throw new Error("template names must be a string: "+_);for(var fe=0;fe<this.loaders.length;fe++){var Ee=this.loaders[fe];if(X=Ee.cache[this.resolveTemplate(Ee,L,_)],X)break}}if(X)if(m&&X.compile(),D){D(null,X);return}else return X;var J,Z=function(Y,Q){if(!Q&&!Y&&!K&&(Y=new Error("template not found: "+_)),Y)if(D){D(Y);return}else throw Y;var ue;Q?(ue=new b(Q.src,z,Q.path,m),Q.noCache||(Q.loader.cache[_]=ue)):ue=new b(a,z,"",m),D?D(null,ue):J=ue};return g.asyncIter(this.loaders,function(H,Y,Q,ue){function pe(de,Te){de?ue(de):Te?(Te.loader=H,ue(null,Te)):Q()}_=le.resolveTemplate(H,L,_),H.async?H.getSource(_,pe):pe(null,H.getSource(_))},Z),J},R.express=function(_){return l(this,_)},R.render=function(_,m,L){g.isFunction(m)&&(L=m,m=null);var K=null;return this.getTemplate(_,function(D,z){if(D&&L)s(L,D);else{if(D)throw D;K=z.render(m,L)}}),K},R.renderString=function(_,m,L,K){g.isFunction(L)&&(K=L,L={}),L=L||{};var D=new b(_,this,L.path);return D.render(m,K)},R.waterfall=function(_,m,L){return r(_,m,L)},A}(u),c=function(C){y(A,C);function A(){return C.apply(this,arguments)||this}var R=A.prototype;return R.init=function(_,m,L){var K=this;this.env=L||new p,this.ctx=g.extend({},_),this.blocks={},this.exported=[],g.keys(m).forEach(function(D){K.addBlock(D,m[D])})},R.lookup=function(_){return _ in this.env.globals&&!(_ in this.ctx)?this.env.globals[_]:this.ctx[_]},R.setVariable=function(_,m){this.ctx[_]=m},R.getVariables=function(){return this.ctx},R.addBlock=function(_,m){return this.blocks[_]=this.blocks[_]||[],this.blocks[_].push(m),this},R.getBlock=function(_){if(!this.blocks[_])throw new Error('unknown block "'+_+'"');return this.blocks[_][0]},R.getSuper=function(_,m,L,K,D,z){var le=g.indexOf(this.blocks[m]||[],L),X=this.blocks[m][le+1],fe=this;if(le===-1||!X)throw new Error('no super block available for "'+m+'"');X(_,fe,K,D,z)},R.addExport=function(_){this.exported.push(_)},R.getExported=function(){var _=this,m={};return this.exported.forEach(function(L){m[L]=_.ctx[L]}),m},A}(d),b=function(C){y(A,C);function A(){return C.apply(this,arguments)||this}var R=A.prototype;return R.init=function(_,m,L,K){if(this.env=m||new p,g.isObject(_))switch(_.type){case"code":this.tmplProps=_.obj;break;case"string":this.tmplStr=_.obj;break;default:throw new Error("Unexpected template object type "+_.type+"; expected 'code', or 'string'")}else if(g.isString(_))this.tmplStr=_;else throw new Error("src must be a string or an object describing the source");if(this.path=L,K)try{this._compile()}catch(D){throw g._prettifyError(this.path,this.env.opts.dev,D)}else this.compiled=!1},R.render=function(_,m,L){var K=this;typeof _=="function"?(L=_,_={}):typeof m=="function"&&(L=m,m=null);var D=!m;try{this.compile()}catch(J){var z=g._prettifyError(this.path,this.env.opts.dev,J);if(L)return s(L,z);throw z}var le=new c(_||{},this.blocks,this.env),X=m?m.push(!0):new o;X.topLevel=!0;var fe=null,Ee=!1;return this.rootRenderFunc(this.env,le,X,h,function(J,Z){if(!(Ee&&L&&typeof Z<"u"))if(J&&(J=g._prettifyError(K.path,K.env.opts.dev,J),Ee=!0),L)D?s(L,J,Z):L(J,Z);else{if(J)throw J;fe=Z}}),fe},R.getExported=function(_,m,L){typeof _=="function"&&(L=_,_={}),typeof m=="function"&&(L=m,m=null);try{this.compile()}catch(z){if(L)return L(z);throw z}var K=m?m.push():new o;K.topLevel=!0;var D=new c(_||{},this.blocks,this.env);this.rootRenderFunc(this.env,D,K,h,function(z){z?L(z,null):L(null,D.getExported())})},R.compile=function(){this.compiled||this._compile()},R._compile=function(){var _;if(this.tmplProps)_=this.tmplProps;else{var m=O.compile(this.tmplStr,this.env.asyncFilters,this.env.extensionsList,this.path,this.env.opts),L=new Function(m);_=L()}this.blocks=this._getBlocks(_),this.rootRenderFunc=_.root,this.compiled=!0},R._getBlocks=function(_){var m={};return g.keys(_).forEach(function(L){L.slice(0,2)==="b_"&&(m[L.slice(2)]=_[L])}),m},A}(d);v.exports={Environment:p,Template:b}},function(v,T,w){function y(U,F){U.prototype=Object.create(F.prototype),U.prototype.constructor=U,E(U,F)}function E(U,F){return E=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(P,e){return P.__proto__=e,P},E(U,F)}var f=w(9),r=w(3),g=w(1).Obj,O=w(0),j=function(U){y(F,U);function F(){return U.apply(this,arguments)||this}var k=F.prototype;return k.init=function(e){this.tokens=e,this.peeked=null,this.breakOnBlocks=null,this.dropLeadingWhitespace=!1,this.extensions=[]},k.nextToken=function(e){var n;if(this.peeked)if(!e&&this.peeked.type===f.TOKEN_WHITESPACE)this.peeked=null;else return n=this.peeked,this.peeked=null,n;if(n=this.tokens.nextToken(),!e)for(;n&&n.type===f.TOKEN_WHITESPACE;)n=this.tokens.nextToken();return n},k.peekToken=function(){return this.peeked=this.peeked||this.nextToken(),this.peeked},k.pushToken=function(e){if(this.peeked)throw new Error("pushToken: can only push one token on between reads");this.peeked=e},k.error=function(e,n,i){if(n===void 0||i===void 0){var d=this.peekToken()||{};n=d.lineno,i=d.colno}return n!==void 0&&(n+=1),i!==void 0&&(i+=1),new O.TemplateError(e,n,i)},k.fail=function(e,n,i){throw this.error(e,n,i)},k.skip=function(e){var n=this.nextToken();return!n||n.type!==e?(this.pushToken(n),!1):!0},k.expect=function(e){var n=this.nextToken();return n.type!==e&&this.fail("expected "+e+", got "+n.type,n.lineno,n.colno),n},k.skipValue=function(e,n){var i=this.nextToken();return!i||i.type!==e||i.value!==n?(this.pushToken(i),!1):!0},k.skipSymbol=function(e){return this.skipValue(f.TOKEN_SYMBOL,e)},k.advanceAfterBlockEnd=function(e){var n;return e||(n=this.peekToken(),n||this.fail("unexpected end of file"),n.type!==f.TOKEN_SYMBOL&&this.fail("advanceAfterBlockEnd: expected symbol token or explicit name to be passed"),e=this.nextToken().value),n=this.nextToken(),n&&n.type===f.TOKEN_BLOCK_END?n.value.charAt(0)==="-"&&(this.dropLeadingWhitespace=!0):this.fail("expected block end in "+e+" statement"),n},k.advanceAfterVariableEnd=function(){var e=this.nextToken();e&&e.type===f.TOKEN_VARIABLE_END?this.dropLeadingWhitespace=e.value.charAt(e.value.length-this.tokens.tags.VARIABLE_END.length-1)==="-":(this.pushToken(e),this.fail("expected variable end"))},k.parseFor=function(){var e=this.peekToken(),n,i;this.skipSymbol("for")?(n=new r.For(e.lineno,e.colno),i="endfor"):this.skipSymbol("asyncEach")?(n=new r.AsyncEach(e.lineno,e.colno),i="endeach"):this.skipSymbol("asyncAll")?(n=new r.AsyncAll(e.lineno,e.colno),i="endall"):this.fail("parseFor: expected for{Async}",e.lineno,e.colno),n.name=this.parsePrimary(),n.name instanceof r.Symbol||this.fail("parseFor: variable name expected for loop");var d=this.peekToken().type;if(d===f.TOKEN_COMMA){var u=n.name;for(n.name=new r.Array(u.lineno,u.colno),n.name.addChild(u);this.skip(f.TOKEN_COMMA);){var h=this.parsePrimary();n.name.addChild(h)}}return this.skipSymbol("in")||this.fail('parseFor: expected "in" keyword for loop',e.lineno,e.colno),n.arr=this.parseExpression(),this.advanceAfterBlockEnd(e.value),n.body=this.parseUntilBlocks(i,"else"),this.skipSymbol("else")&&(this.advanceAfterBlockEnd("else"),n.else_=this.parseUntilBlocks(i)),this.advanceAfterBlockEnd(),n},k.parseMacro=function(){var e=this.peekToken();this.skipSymbol("macro")||this.fail("expected macro");var n=this.parsePrimary(!0),i=this.parseSignature(),d=new r.Macro(e.lineno,e.colno,n,i);return this.advanceAfterBlockEnd(e.value),d.body=this.parseUntilBlocks("endmacro"),this.advanceAfterBlockEnd(),d},k.parseCall=function(){var e=this.peekToken();this.skipSymbol("call")||this.fail("expected call");var n=this.parseSignature(!0)||new r.NodeList,i=this.parsePrimary();this.advanceAfterBlockEnd(e.value);var d=this.parseUntilBlocks("endcall");this.advanceAfterBlockEnd();var u=new r.Symbol(e.lineno,e.colno,"caller"),h=new r.Caller(e.lineno,e.colno,u,n,d),t=i.args.children;t[t.length-1]instanceof r.KeywordArgs||t.push(new r.KeywordArgs);var o=t[t.length-1];return o.addChild(new r.Pair(e.lineno,e.colno,u,h)),new r.Output(e.lineno,e.colno,[i])},k.parseWithContext=function(){var e=this.peekToken(),n=null;return this.skipSymbol("with")?n=!0:this.skipSymbol("without")&&(n=!1),n!==null&&(this.skipSymbol("context")||this.fail("parseFrom: expected context after with/without",e.lineno,e.colno)),n},k.parseImport=function(){var e=this.peekToken();this.skipSymbol("import")||this.fail("parseImport: expected import",e.lineno,e.colno);var n=this.parseExpression();this.skipSymbol("as")||this.fail('parseImport: expected "as" keyword',e.lineno,e.colno);var i=this.parseExpression(),d=this.parseWithContext(),u=new r.Import(e.lineno,e.colno,n,i,d);return this.advanceAfterBlockEnd(e.value),u},k.parseFrom=function(){var e=this.peekToken();this.skipSymbol("from")||this.fail("parseFrom: expected from");var n=this.parseExpression();this.skipSymbol("import")||this.fail("parseFrom: expected import",e.lineno,e.colno);for(var i=new r.NodeList,d;;){var u=this.peekToken();if(u.type===f.TOKEN_BLOCK_END){i.children.length||this.fail("parseFrom: Expected at least one import name",e.lineno,e.colno),u.value.charAt(0)==="-"&&(this.dropLeadingWhitespace=!0),this.nextToken();break}i.children.length>0&&!this.skip(f.TOKEN_COMMA)&&this.fail("parseFrom: expected comma",e.lineno,e.colno);var h=this.parsePrimary();if(h.value.charAt(0)==="_"&&this.fail("parseFrom: names starting with an underscore cannot be imported",h.lineno,h.colno),this.skipSymbol("as")){var t=this.parsePrimary();i.addChild(new r.Pair(h.lineno,h.colno,h,t))}else i.addChild(h);d=this.parseWithContext()}return new r.FromImport(e.lineno,e.colno,n,i,d)},k.parseBlock=function(){var e=this.peekToken();this.skipSymbol("block")||this.fail("parseBlock: expected block",e.lineno,e.colno);var n=new r.Block(e.lineno,e.colno);n.name=this.parsePrimary(),n.name instanceof r.Symbol||this.fail("parseBlock: variable name expected",e.lineno,e.colno),this.advanceAfterBlockEnd(e.value),n.body=this.parseUntilBlocks("endblock"),this.skipSymbol("endblock"),this.skipSymbol(n.name.value);var i=this.peekToken();return i||this.fail("parseBlock: expected endblock, got end of file"),this.advanceAfterBlockEnd(i.value),n},k.parseExtends=function(){var e="extends",n=this.peekToken();this.skipSymbol(e)||this.fail("parseTemplateRef: expected "+e);var i=new r.Extends(n.lineno,n.colno);return i.template=this.parseExpression(),this.advanceAfterBlockEnd(n.value),i},k.parseInclude=function(){var e="include",n=this.peekToken();this.skipSymbol(e)||this.fail("parseInclude: expected "+e);var i=new r.Include(n.lineno,n.colno);return i.template=this.parseExpression(),this.skipSymbol("ignore")&&this.skipSymbol("missing")&&(i.ignoreMissing=!0),this.advanceAfterBlockEnd(n.value),i},k.parseIf=function(){var e=this.peekToken(),n;this.skipSymbol("if")||this.skipSymbol("elif")||this.skipSymbol("elseif")?n=new r.If(e.lineno,e.colno):this.skipSymbol("ifAsync")?n=new r.IfAsync(e.lineno,e.colno):this.fail("parseIf: expected if, elif, or elseif",e.lineno,e.colno),n.cond=this.parseExpression(),this.advanceAfterBlockEnd(e.value),n.body=this.parseUntilBlocks("elif","elseif","else","endif");var i=this.peekToken();switch(i&&i.value){case"elseif":case"elif":n.else_=this.parseIf();break;case"else":this.advanceAfterBlockEnd(),n.else_=this.parseUntilBlocks("endif"),this.advanceAfterBlockEnd();break;case"endif":n.else_=null,this.advanceAfterBlockEnd();break;default:this.fail("parseIf: expected elif, else, or endif, got end of file")}return n},k.parseSet=function(){var e=this.peekToken();this.skipSymbol("set")||this.fail("parseSet: expected set",e.lineno,e.colno);for(var n=new r.Set(e.lineno,e.colno,[]),i;(i=this.parsePrimary())&&(n.targets.push(i),!!this.skip(f.TOKEN_COMMA)););return this.skipValue(f.TOKEN_OPERATOR,"=")?(n.value=this.parseExpression(),this.advanceAfterBlockEnd(e.value)):this.skip(f.TOKEN_BLOCK_END)?(n.body=new r.Capture(e.lineno,e.colno,this.parseUntilBlocks("endset")),n.value=null,this.advanceAfterBlockEnd()):this.fail("parseSet: expected = or block end in set tag",e.lineno,e.colno),n},k.parseSwitch=function(){var e="switch",n="endswitch",i="case",d="default",u=this.peekToken();!this.skipSymbol(e)&&!this.skipSymbol(i)&&!this.skipSymbol(d)&&this.fail('parseSwitch: expected "switch," "case" or "default"',u.lineno,u.colno);var h=this.parseExpression();this.advanceAfterBlockEnd(e),this.parseUntilBlocks(i,d,n);var t=this.peekToken(),o=[],l;do{this.skipSymbol(i);var s=this.parseExpression();this.advanceAfterBlockEnd(e);var a=this.parseUntilBlocks(i,d,n);o.push(new r.Case(t.line,t.col,s,a)),t=this.peekToken()}while(t&&t.value===i);switch(t.value){case d:this.advanceAfterBlockEnd(),l=this.parseUntilBlocks(n),this.advanceAfterBlockEnd();break;case n:this.advanceAfterBlockEnd();break;default:this.fail('parseSwitch: expected "case," "default" or "endswitch," got EOF.')}return new r.Switch(u.lineno,u.colno,h,o,l)},k.parseStatement=function(){var e=this.peekToken(),n;if(e.type!==f.TOKEN_SYMBOL&&this.fail("tag name expected",e.lineno,e.colno),this.breakOnBlocks&&O.indexOf(this.breakOnBlocks,e.value)!==-1)return null;switch(e.value){case"raw":return this.parseRaw();case"verbatim":return this.parseRaw("verbatim");case"if":case"ifAsync":return this.parseIf();case"for":case"asyncEach":case"asyncAll":return this.parseFor();case"block":return this.parseBlock();case"extends":return this.parseExtends();case"include":return this.parseInclude();case"set":return this.parseSet();case"macro":return this.parseMacro();case"call":return this.parseCall();case"import":return this.parseImport();case"from":return this.parseFrom();case"filter":return this.parseFilterStatement();case"switch":return this.parseSwitch();default:if(this.extensions.length)for(var i=0;i<this.extensions.length;i++){var d=this.extensions[i];if(O.indexOf(d.tags||[],e.value)!==-1)return d.parse(this,r,f)}this.fail("unknown block tag: "+e.value,e.lineno,e.colno)}return n},k.parseRaw=function(e){e=e||"raw";for(var n="end"+e,i=new RegExp("([\\s\\S]*?){%\\s*("+e+"|"+n+")\\s*(?=%})%}"),d=1,u="",h=null,t=this.advanceAfterBlockEnd();(h=this.tokens._extractRegex(i))&&d>0;){var o=h[0],l=h[1],s=h[2];s===e?d+=1:s===n&&(d-=1),d===0?(u+=l,this.tokens.backN(o.length-l.length)):u+=o}return new r.Output(t.lineno,t.colno,[new r.TemplateData(t.lineno,t.colno,u)])},k.parsePostfix=function(e){for(var n,i=this.peekToken();i;){if(i.type===f.TOKEN_LEFT_PAREN)e=new r.FunCall(i.lineno,i.colno,e,this.parseSignature());else if(i.type===f.TOKEN_LEFT_BRACKET)n=this.parseAggregate(),n.children.length>1&&this.fail("invalid index"),e=new r.LookupVal(i.lineno,i.colno,e,n.children[0]);else if(i.type===f.TOKEN_OPERATOR&&i.value==="."){this.nextToken();var d=this.nextToken();d.type!==f.TOKEN_SYMBOL&&this.fail("expected name as lookup value, got "+d.value,d.lineno,d.colno),n=new r.Literal(d.lineno,d.colno,d.value),e=new r.LookupVal(i.lineno,i.colno,e,n)}else break;i=this.peekToken()}return e},k.parseExpression=function(){var e=this.parseInlineIf();return e},k.parseInlineIf=function(){var e=this.parseOr();if(this.skipSymbol("if")){var n=this.parseOr(),i=e;e=new r.InlineIf(e.lineno,e.colno),e.body=i,e.cond=n,this.skipSymbol("else")?e.else_=this.parseOr():e.else_=null}return e},k.parseOr=function(){for(var e=this.parseAnd();this.skipSymbol("or");){var n=this.parseAnd();e=new r.Or(e.lineno,e.colno,e,n)}return e},k.parseAnd=function(){for(var e=this.parseNot();this.skipSymbol("and");){var n=this.parseNot();e=new r.And(e.lineno,e.colno,e,n)}return e},k.parseNot=function(){var e=this.peekToken();return this.skipSymbol("not")?new r.Not(e.lineno,e.colno,this.parseNot()):this.parseIn()},k.parseIn=function(){for(var e=this.parseIs();;){var n=this.nextToken();if(!n)break;var i=n.type===f.TOKEN_SYMBOL&&n.value==="not";if(i||this.pushToken(n),this.skipSymbol("in")){var d=this.parseIs();e=new r.In(e.lineno,e.colno,e,d),i&&(e=new r.Not(e.lineno,e.colno,e))}else{i&&this.pushToken(n);break}}return e},k.parseIs=function(){var e=this.parseCompare();if(this.skipSymbol("is")){var n=this.skipSymbol("not"),i=this.parseCompare();e=new r.Is(e.lineno,e.colno,e,i),n&&(e=new r.Not(e.lineno,e.colno,e))}return e},k.parseCompare=function(){for(var e=["==","===","!=","!==","<",">","<=",">="],n=this.parseConcat(),i=[];;){var d=this.nextToken();if(d)if(e.indexOf(d.value)!==-1)i.push(new r.CompareOperand(d.lineno,d.colno,this.parseConcat(),d.value));else{this.pushToken(d);break}else break}return i.length?new r.Compare(i[0].lineno,i[0].colno,n,i):n},k.parseConcat=function(){for(var e=this.parseAdd();this.skipValue(f.TOKEN_TILDE,"~");){var n=this.parseAdd();e=new r.Concat(e.lineno,e.colno,e,n)}return e},k.parseAdd=function(){for(var e=this.parseSub();this.skipValue(f.TOKEN_OPERATOR,"+");){var n=this.parseSub();e=new r.Add(e.lineno,e.colno,e,n)}return e},k.parseSub=function(){for(var e=this.parseMul();this.skipValue(f.TOKEN_OPERATOR,"-");){var n=this.parseMul();e=new r.Sub(e.lineno,e.colno,e,n)}return e},k.parseMul=function(){for(var e=this.parseDiv();this.skipValue(f.TOKEN_OPERATOR,"*");){var n=this.parseDiv();e=new r.Mul(e.lineno,e.colno,e,n)}return e},k.parseDiv=function(){for(var e=this.parseFloorDiv();this.skipValue(f.TOKEN_OPERATOR,"/");){var n=this.parseFloorDiv();e=new r.Div(e.lineno,e.colno,e,n)}return e},k.parseFloorDiv=function(){for(var e=this.parseMod();this.skipValue(f.TOKEN_OPERATOR,"//");){var n=this.parseMod();e=new r.FloorDiv(e.lineno,e.colno,e,n)}return e},k.parseMod=function(){for(var e=this.parsePow();this.skipValue(f.TOKEN_OPERATOR,"%");){var n=this.parsePow();e=new r.Mod(e.lineno,e.colno,e,n)}return e},k.parsePow=function(){for(var e=this.parseUnary();this.skipValue(f.TOKEN_OPERATOR,"**");){var n=this.parseUnary();e=new r.Pow(e.lineno,e.colno,e,n)}return e},k.parseUnary=function(e){var n=this.peekToken(),i;return this.skipValue(f.TOKEN_OPERATOR,"-")?i=new r.Neg(n.lineno,n.colno,this.parseUnary(!0)):this.skipValue(f.TOKEN_OPERATOR,"+")?i=new r.Pos(n.lineno,n.colno,this.parseUnary(!0)):i=this.parsePrimary(),e||(i=this.parseFilter(i)),i},k.parsePrimary=function(e){var n=this.nextToken(),i,d=null;if(n?n.type===f.TOKEN_STRING?i=n.value:n.type===f.TOKEN_INT?i=parseInt(n.value,10):n.type===f.TOKEN_FLOAT?i=parseFloat(n.value):n.type===f.TOKEN_BOOLEAN?n.value==="true"?i=!0:n.value==="false"?i=!1:this.fail("invalid boolean: "+n.value,n.lineno,n.colno):n.type===f.TOKEN_NONE?i=null:n.type===f.TOKEN_REGEX&&(i=new RegExp(n.value.body,n.value.flags)):this.fail("expected expression, got end of file"),i!==void 0?d=new r.Literal(n.lineno,n.colno,i):n.type===f.TOKEN_SYMBOL?d=new r.Symbol(n.lineno,n.colno,n.value):(this.pushToken(n),d=this.parseAggregate()),e||(d=this.parsePostfix(d)),d)return d;throw this.error("unexpected token: "+n.value,n.lineno,n.colno)},k.parseFilterName=function(){for(var e=this.expect(f.TOKEN_SYMBOL),n=e.value;this.skipValue(f.TOKEN_OPERATOR,".");)n+="."+this.expect(f.TOKEN_SYMBOL).value;return new r.Symbol(e.lineno,e.colno,n)},k.parseFilterArgs=function(e){if(this.peekToken().type===f.TOKEN_LEFT_PAREN){var n=this.parsePostfix(e);return n.args.children}return[]},k.parseFilter=function(e){for(;this.skip(f.TOKEN_PIPE);){var n=this.parseFilterName();e=new r.Filter(n.lineno,n.colno,n,new r.NodeList(n.lineno,n.colno,[e].concat(this.parseFilterArgs(e))))}return e},k.parseFilterStatement=function(){var e=this.peekToken();this.skipSymbol("filter")||this.fail("parseFilterStatement: expected filter");var n=this.parseFilterName(),i=this.parseFilterArgs(n);this.advanceAfterBlockEnd(e.value);var d=new r.Capture(n.lineno,n.colno,this.parseUntilBlocks("endfilter"));this.advanceAfterBlockEnd();var u=new r.Filter(n.lineno,n.colno,n,new r.NodeList(n.lineno,n.colno,[d].concat(i)));return new r.Output(n.lineno,n.colno,[u])},k.parseAggregate=function(){var e=this.nextToken(),n;switch(e.type){case f.TOKEN_LEFT_PAREN:n=new r.Group(e.lineno,e.colno);break;case f.TOKEN_LEFT_BRACKET:n=new r.Array(e.lineno,e.colno);break;case f.TOKEN_LEFT_CURLY:n=new r.Dict(e.lineno,e.colno);break;default:return null}for(;;){var i=this.peekToken().type;if(i===f.TOKEN_RIGHT_PAREN||i===f.TOKEN_RIGHT_BRACKET||i===f.TOKEN_RIGHT_CURLY){this.nextToken();break}if(n.children.length>0&&(this.skip(f.TOKEN_COMMA)||this.fail("parseAggregate: expected comma after expression",e.lineno,e.colno)),n instanceof r.Dict){var d=this.parsePrimary();this.skip(f.TOKEN_COLON)||this.fail("parseAggregate: expected colon after dict key",e.lineno,e.colno);var u=this.parseExpression();n.addChild(new r.Pair(d.lineno,d.colno,d,u))}else{var h=this.parseExpression();n.addChild(h)}}return n},k.parseSignature=function(e,n){var i=this.peekToken();if(!n&&i.type!==f.TOKEN_LEFT_PAREN){if(e)return null;this.fail("expected arguments",i.lineno,i.colno)}i.type===f.TOKEN_LEFT_PAREN&&(i=this.nextToken());for(var d=new r.NodeList(i.lineno,i.colno),u=new r.KeywordArgs(i.lineno,i.colno),h=!1;;){if(i=this.peekToken(),!n&&i.type===f.TOKEN_RIGHT_PAREN){this.nextToken();break}else if(n&&i.type===f.TOKEN_BLOCK_END)break;if(h&&!this.skip(f.TOKEN_COMMA))this.fail("parseSignature: expected comma after expression",i.lineno,i.colno);else{var t=this.parseExpression();this.skipValue(f.TOKEN_OPERATOR,"=")?u.addChild(new r.Pair(t.lineno,t.colno,t,this.parseExpression())):d.addChild(t)}h=!0}return u.children.length&&d.addChild(u),d},k.parseUntilBlocks=function(){for(var e=this.breakOnBlocks,n=arguments.length,i=new Array(n),d=0;d<n;d++)i[d]=arguments[d];this.breakOnBlocks=i;var u=this.parse();return this.breakOnBlocks=e,u},k.parseNodes=function(){for(var e,n=[];e=this.nextToken();)if(e.type===f.TOKEN_DATA){var i=e.value,d=this.peekToken(),u=d&&d.value;this.dropLeadingWhitespace&&(i=i.replace(/^\s*/,""),this.dropLeadingWhitespace=!1),d&&(d.type===f.TOKEN_BLOCK_START&&u.charAt(u.length-1)==="-"||d.type===f.TOKEN_VARIABLE_START&&u.charAt(this.tokens.tags.VARIABLE_START.length)==="-"||d.type===f.TOKEN_COMMENT&&u.charAt(this.tokens.tags.COMMENT_START.length)==="-")&&(i=i.replace(/\s*$/,"")),n.push(new r.Output(e.lineno,e.colno,[new r.TemplateData(e.lineno,e.colno,i)]))}else if(e.type===f.TOKEN_BLOCK_START){this.dropLeadingWhitespace=!1;var h=this.parseStatement();if(!h)break;n.push(h)}else if(e.type===f.TOKEN_VARIABLE_START){var t=this.parseExpression();this.dropLeadingWhitespace=!1,this.advanceAfterVariableEnd(),n.push(new r.Output(e.lineno,e.colno,[t]))}else e.type===f.TOKEN_COMMENT?this.dropLeadingWhitespace=e.value.charAt(e.value.length-this.tokens.tags.COMMENT_END.length-1)==="-":this.fail("Unexpected token at top-level: "+e.type,e.lineno,e.colno);return n},k.parse=function(){return new r.NodeList(0,0,this.parseNodes())},k.parseAsRoot=function(){return new r.Root(0,0,this.parseNodes())},F}(g);v.exports={parse:function(F,k,P){var e=new j(f.lex(F,P));return k!==void 0&&(e.extensions=k),e.parseAsRoot()},Parser:j}},function(v,T,w){var y=w(0),E=`
17
- \r `,f="()[]{}%*-+~/#,:|.<>=!",r="0123456789",g="{%",O="%}",j="{{",U="}}",F="{#",k="#}",P="string",e="whitespace",n="data",i="block-start",d="block-end",u="variable-start",h="variable-end",t="comment",o="left-paren",l="right-paren",s="left-bracket",a="right-bracket",p="left-curly",c="right-curly",b="operator",C="comma",A="colon",R="tilde",V="pipe",_="int",m="float",L="boolean",K="none",D="symbol",z="special",le="regex";function X(Ee,J,Z,H){return{type:Ee,value:J,lineno:Z,colno:H}}var fe=function(){function Ee(Z,H){this.str=Z,this.index=0,this.len=Z.length,this.lineno=0,this.colno=0,this.in_code=!1,H=H||{};var Y=H.tags||{};this.tags={BLOCK_START:Y.blockStart||g,BLOCK_END:Y.blockEnd||O,VARIABLE_START:Y.variableStart||j,VARIABLE_END:Y.variableEnd||U,COMMENT_START:Y.commentStart||F,COMMENT_END:Y.commentEnd||k},this.trimBlocks=!!H.trimBlocks,this.lstripBlocks=!!H.lstripBlocks}var J=Ee.prototype;return J.nextToken=function(){var H=this.lineno,Y=this.colno,Q;if(this.in_code){var ue=this.current();if(this.isFinished())return null;if(ue==='"'||ue==="'")return X(P,this._parseString(ue),H,Y);if(Q=this._extract(E))return X(e,Q,H,Y);if((Q=this._extractString(this.tags.BLOCK_END))||(Q=this._extractString("-"+this.tags.BLOCK_END)))return this.in_code=!1,this.trimBlocks&&(ue=this.current(),ue===`
18
- `?this.forward():ue==="\r"&&(this.forward(),ue=this.current(),ue===`
19
- `?this.forward():this.back())),X(d,Q,H,Y);if((Q=this._extractString(this.tags.VARIABLE_END))||(Q=this._extractString("-"+this.tags.VARIABLE_END)))return this.in_code=!1,X(h,Q,H,Y);if(ue==="r"&&this.str.charAt(this.index+1)==="/"){this.forwardN(2);for(var pe="";!this.isFinished();)if(this.current()==="/"&&this.previous()!=="\\"){this.forward();break}else pe+=this.current(),this.forward();for(var de=["g","i","m","y"],Te="";!this.isFinished();){var x=de.indexOf(this.current())!==-1;if(x)Te+=this.current(),this.forward();else break}return X(le,{body:pe,flags:Te},H,Y)}else if(f.indexOf(ue)!==-1){this.forward();var B=["==","===","!=","!==","<=",">=","//","**"],G=ue+this.current(),$;switch(y.indexOf(B,G)!==-1&&(this.forward(),ue=G,y.indexOf(B,G+this.current())!==-1&&(ue=G+this.current(),this.forward())),ue){case"(":$=o;break;case")":$=l;break;case"[":$=s;break;case"]":$=a;break;case"{":$=p;break;case"}":$=c;break;case",":$=C;break;case":":$=A;break;case"~":$=R;break;case"|":$=V;break;default:$=b}return X($,ue,H,Y)}else if(Q=this._extractUntil(E+f),Q.match(/^[-+]?[0-9]+$/))if(this.current()==="."){this.forward();var ee=this._extract(r);return X(m,Q+"."+ee,H,Y)}else return X(_,Q,H,Y);else{if(Q.match(/^(true|false)$/))return X(L,Q,H,Y);if(Q==="none")return X(K,Q,H,Y);if(Q==="null")return X(K,Q,H,Y);if(Q)return X(D,Q,H,Y);throw new Error("Unexpected value while parsing: "+Q)}}else{var ie=this.tags.BLOCK_START.charAt(0)+this.tags.VARIABLE_START.charAt(0)+this.tags.COMMENT_START.charAt(0)+this.tags.COMMENT_END.charAt(0);if(this.isFinished())return null;if((Q=this._extractString(this.tags.BLOCK_START+"-"))||(Q=this._extractString(this.tags.BLOCK_START)))return this.in_code=!0,X(i,Q,H,Y);if((Q=this._extractString(this.tags.VARIABLE_START+"-"))||(Q=this._extractString(this.tags.VARIABLE_START)))return this.in_code=!0,X(u,Q,H,Y);Q="";var ve,ce=!1;for(this._matches(this.tags.COMMENT_START)&&(ce=!0,Q=this._extractString(this.tags.COMMENT_START));(ve=this._extractUntil(ie))!==null;)if(Q+=ve,(this._matches(this.tags.BLOCK_START)||this._matches(this.tags.VARIABLE_START)||this._matches(this.tags.COMMENT_START))&&!ce){if(this.lstripBlocks&&this._matches(this.tags.BLOCK_START)&&this.colno>0&&this.colno<=Q.length){var xe=Q.slice(-this.colno);if(/^\s+$/.test(xe)&&(Q=Q.slice(0,-this.colno),!Q.length))return this.nextToken()}break}else if(this._matches(this.tags.COMMENT_END)){if(!ce)throw new Error("unexpected end of comment");Q+=this._extractString(this.tags.COMMENT_END);break}else Q+=this.current(),this.forward();if(ve===null&&ce)throw new Error("expected end of comment, got end of file");return X(ce?t:n,Q,H,Y)}},J._parseString=function(H){this.forward();for(var Y="";!this.isFinished()&&this.current()!==H;){var Q=this.current();if(Q==="\\"){switch(this.forward(),this.current()){case"n":Y+=`
20
- `;break;case"t":Y+=" ";break;case"r":Y+="\r";break;default:Y+=this.current()}this.forward()}else Y+=Q,this.forward()}return this.forward(),Y},J._matches=function(H){if(this.index+H.length>this.len)return null;var Y=this.str.slice(this.index,this.index+H.length);return Y===H},J._extractString=function(H){return this._matches(H)?(this.forwardN(H.length),H):null},J._extractUntil=function(H){return this._extractMatching(!0,H||"")},J._extract=function(H){return this._extractMatching(!1,H)},J._extractMatching=function(H,Y){if(this.isFinished())return null;var Q=Y.indexOf(this.current());if(H&&Q===-1||!H&&Q!==-1){var ue=this.current();this.forward();for(var pe=Y.indexOf(this.current());(H&&pe===-1||!H&&pe!==-1)&&!this.isFinished();)ue+=this.current(),this.forward(),pe=Y.indexOf(this.current());return ue}return""},J._extractRegex=function(H){var Y=this.currentStr().match(H);return Y?(this.forwardN(Y[0].length),Y):null},J.isFinished=function(){return this.index>=this.len},J.forwardN=function(H){for(var Y=0;Y<H;Y++)this.forward()},J.forward=function(){this.index++,this.previous()===`
21
- `?(this.lineno++,this.colno=0):this.colno++},J.backN=function(H){for(var Y=0;Y<H;Y++)this.back()},J.back=function(){if(this.index--,this.current()===`
22
- `){this.lineno--;var H=this.src.lastIndexOf(`
23
- `,this.index-1);H===-1?this.colno=this.index:this.colno=this.index-H}else this.colno--},J.current=function(){return this.isFinished()?"":this.str.charAt(this.index)},J.currentStr=function(){return this.isFinished()?"":this.str.substr(this.index)},J.previous=function(){return this.str.charAt(this.index-1)},Ee}();v.exports={lex:function(J,Z){return new fe(J,Z)},TOKEN_STRING:P,TOKEN_WHITESPACE:e,TOKEN_DATA:n,TOKEN_BLOCK_START:i,TOKEN_BLOCK_END:d,TOKEN_VARIABLE_START:u,TOKEN_VARIABLE_END:h,TOKEN_COMMENT:t,TOKEN_LEFT_PAREN:o,TOKEN_RIGHT_PAREN:l,TOKEN_LEFT_BRACKET:s,TOKEN_RIGHT_BRACKET:a,TOKEN_LEFT_CURLY:p,TOKEN_RIGHT_CURLY:c,TOKEN_OPERATOR:b,TOKEN_COMMA:C,TOKEN_COLON:A,TOKEN_TILDE:R,TOKEN_PIPE:V,TOKEN_INT:_,TOKEN_FLOAT:m,TOKEN_BOOLEAN:L,TOKEN_NONE:K,TOKEN_SYMBOL:D,TOKEN_SPECIAL:z,TOKEN_REGEX:le}},function(v,T,w){function y(j,U){j.prototype=Object.create(U.prototype),j.prototype.constructor=j,E(j,U)}function E(j,U){return E=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(k,P){return k.__proto__=P,k},E(j,U)}var f=w(6),r=w(19),g=r.PrecompiledLoader,O=function(j){y(U,j);function U(k,P){var e;return e=j.call(this)||this,e.baseURL=k||".",P=P||{},e.useCache=!!P.useCache,e.async=!!P.async,e}var F=U.prototype;return F.resolve=function(P,e){throw new Error("relative templates not support in the browser yet")},F.getSource=function(P,e){var n=this,i=this.useCache,d;return this.fetch(this.baseURL+"/"+P,function(u,h){if(u)if(e)e(u.content);else if(u.status===404)d=null;else throw u.content;else d={src:h,path:P,noCache:!i},n.emit("load",P,d),e&&e(null,d)}),d},F.fetch=function(P,e){if(typeof window>"u")throw new Error("WebLoader can only by used in a browser");var n=new XMLHttpRequest,i=!0;n.onreadystatechange=function(){n.readyState===4&&i&&(i=!1,n.status===0||n.status===200?e(null,n.responseText):e({status:n.status,content:n.responseText}))},P+=(P.indexOf("?")===-1?"?":"&")+"s="+new Date().getTime(),n.open("GET",P,this.async),n.send()},U}(f);v.exports={WebLoader:O,PrecompiledLoader:g}},function(v,T,w){var y=w(0),E=w(7),f=E.Environment,r=E.Template,g=w(6),O=w(10),j=w(23),U=w(5),F=w(8),k=w(9),P=w(2),e=w(3),n=w(25),i;function d(u,h){h=h||{},y.isObject(u)&&(h=u,u=null);var t;return O.FileSystemLoader?t=new O.FileSystemLoader(u,{watch:h.watch,noCache:h.noCache}):O.WebLoader&&(t=new O.WebLoader(u,{useCache:h.web&&h.web.useCache,async:h.web&&h.web.async})),i=new f(t,h),h&&h.express&&i.express(h.express),i}v.exports={Environment:f,Template:r,Loader:g,FileSystemLoader:O.FileSystemLoader,NodeResolveLoader:O.NodeResolveLoader,PrecompiledLoader:O.PrecompiledLoader,WebLoader:O.WebLoader,compiler:U,parser:F,lexer:k,runtime:P,lib:y,nodes:e,installJinjaCompat:n,configure:d,reset:function(){i=void 0},compile:function(h,t,o,l){return i||d(),new r(h,t,o,l)},render:function(h,t,o){return i||d(),i.render(h,t,o)},renderString:function(h,t,o){return i||d(),i.renderString(h,t,o)},precompile:j?j.precompile:void 0,precompileString:j?j.precompileString:void 0}},function(v,T,w){var y=w(13),E=[],f=[],r=y.makeRequestCallFromTimer(g);function g(){if(f.length)throw f.shift()}v.exports=O;function O(U){var F;E.length?F=E.pop():F=new j,F.task=U,y(F)}function j(){this.task=null}j.prototype.call=function(){try{this.task.call()}catch(U){O.onerror?O.onerror(U):(f.push(U),r())}finally{this.task=null,E[E.length]=this}}},function(v,T,w){(function(y){v.exports=E;function E(e){f.length||r(),f[f.length]=e}var f=[],r,g=0,O=1024;function j(){for(;g<f.length;){var e=g;if(g=g+1,f[e].call(),g>O){for(var n=0,i=f.length-g;n<i;n++)f[n]=f[n+g];f.length-=g,g=0}}f.length=0,g=0}var U=typeof y<"u"?y:self,F=U.MutationObserver||U.WebKitMutationObserver;typeof F=="function"?r=k(j):r=P(j),E.requestFlush=r;function k(e){var n=1,i=new F(e),d=document.createTextNode("");return i.observe(d,{characterData:!0}),function(){n=-n,d.data=n}}function P(e){return function(){var i=setTimeout(u,0),d=setInterval(u,50);function u(){clearTimeout(i),clearInterval(d),e()}}}E.makeRequestCallFromTimer=P}).call(T,w(14))},function(v,T){var w;w=function(){return this}();try{w=w||Function("return this")()||(0,eval)("this")}catch{typeof window=="object"&&(w=window)}v.exports=w},function(v,T,w){var y,E;(function(f){var r=function(){var F=Array.prototype.slice.call(arguments);typeof F[0]=="function"&&F[0].apply(null,F.splice(1))},g=function(F){typeof setImmediate=="function"?setImmediate(F):typeof process<"u"&&process.nextTick?process.nextTick(F):setTimeout(F,0)},O=function(F){var k=function(P){var e=function(){return F.length&&F[P].apply(null,arguments),e.next()};return e.next=function(){return P<F.length-1?k(P+1):null},e};return k(0)},j=Array.isArray||function(F){return Object.prototype.toString.call(F)==="[object Array]"},U=function(F,k,P){var e=P?g:r;if(k=k||function(){},!j(F)){var n=new Error("First argument to waterfall must be an array of functions");return k(n)}if(!F.length)return k();var i=function(d){return function(u){if(u)k.apply(null,arguments),k=function(){};else{var h=Array.prototype.slice.call(arguments,1),t=d.next();t?h.push(i(t)):h.push(k),e(function(){d.apply(null,h)})}}};i(O(F))()};y=[],E=(function(){return U}).apply(T,y),E!==void 0&&(v.exports=E)})()},function(v,T,w){var y=typeof Reflect=="object"?Reflect:null,E=y&&typeof y.apply=="function"?y.apply:function(a,p,c){return Function.prototype.apply.call(a,p,c)},f;y&&typeof y.ownKeys=="function"?f=y.ownKeys:Object.getOwnPropertySymbols?f=function(a){return Object.getOwnPropertyNames(a).concat(Object.getOwnPropertySymbols(a))}:f=function(a){return Object.getOwnPropertyNames(a)};function r(s){console&&console.warn&&console.warn(s)}var g=Number.isNaN||function(a){return a!==a};function O(){O.init.call(this)}v.exports=O,v.exports.once=t,O.EventEmitter=O,O.prototype._events=void 0,O.prototype._eventsCount=0,O.prototype._maxListeners=void 0;var j=10;function U(s){if(typeof s!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof s)}Object.defineProperty(O,"defaultMaxListeners",{enumerable:!0,get:function(){return j},set:function(s){if(typeof s!="number"||s<0||g(s))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+s+".");j=s}}),O.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},O.prototype.setMaxListeners=function(a){if(typeof a!="number"||a<0||g(a))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+a+".");return this._maxListeners=a,this};function F(s){return s._maxListeners===void 0?O.defaultMaxListeners:s._maxListeners}O.prototype.getMaxListeners=function(){return F(this)},O.prototype.emit=function(a){for(var p=[],c=1;c<arguments.length;c++)p.push(arguments[c]);var b=a==="error",C=this._events;if(C!==void 0)b=b&&C.error===void 0;else if(!b)return!1;if(b){var A;if(p.length>0&&(A=p[0]),A instanceof Error)throw A;var R=new Error("Unhandled error."+(A?" ("+A.message+")":""));throw R.context=A,R}var V=C[a];if(V===void 0)return!1;if(typeof V=="function")E(V,this,p);else for(var _=V.length,m=d(V,_),c=0;c<_;++c)E(m[c],this,p);return!0};function k(s,a,p,c){var b,C,A;if(U(p),C=s._events,C===void 0?(C=s._events=Object.create(null),s._eventsCount=0):(C.newListener!==void 0&&(s.emit("newListener",a,p.listener?p.listener:p),C=s._events),A=C[a]),A===void 0)A=C[a]=p,++s._eventsCount;else if(typeof A=="function"?A=C[a]=c?[p,A]:[A,p]:c?A.unshift(p):A.push(p),b=F(s),b>0&&A.length>b&&!A.warned){A.warned=!0;var R=new Error("Possible EventEmitter memory leak detected. "+A.length+" "+String(a)+" listeners added. Use emitter.setMaxListeners() to increase limit");R.name="MaxListenersExceededWarning",R.emitter=s,R.type=a,R.count=A.length,r(R)}return s}O.prototype.addListener=function(a,p){return k(this,a,p,!1)},O.prototype.on=O.prototype.addListener,O.prototype.prependListener=function(a,p){return k(this,a,p,!0)};function P(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function e(s,a,p){var c={fired:!1,wrapFn:void 0,target:s,type:a,listener:p},b=P.bind(c);return b.listener=p,c.wrapFn=b,b}O.prototype.once=function(a,p){return U(p),this.on(a,e(this,a,p)),this},O.prototype.prependOnceListener=function(a,p){return U(p),this.prependListener(a,e(this,a,p)),this},O.prototype.removeListener=function(a,p){var c,b,C,A,R;if(U(p),b=this._events,b===void 0)return this;if(c=b[a],c===void 0)return this;if(c===p||c.listener===p)--this._eventsCount===0?this._events=Object.create(null):(delete b[a],b.removeListener&&this.emit("removeListener",a,c.listener||p));else if(typeof c!="function"){for(C=-1,A=c.length-1;A>=0;A--)if(c[A]===p||c[A].listener===p){R=c[A].listener,C=A;break}if(C<0)return this;C===0?c.shift():u(c,C),c.length===1&&(b[a]=c[0]),b.removeListener!==void 0&&this.emit("removeListener",a,R||p)}return this},O.prototype.off=O.prototype.removeListener,O.prototype.removeAllListeners=function(a){var p,c,b;if(c=this._events,c===void 0)return this;if(c.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):c[a]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete c[a]),this;if(arguments.length===0){var C=Object.keys(c),A;for(b=0;b<C.length;++b)A=C[b],A!=="removeListener"&&this.removeAllListeners(A);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(p=c[a],typeof p=="function")this.removeListener(a,p);else if(p!==void 0)for(b=p.length-1;b>=0;b--)this.removeListener(a,p[b]);return this};function n(s,a,p){var c=s._events;if(c===void 0)return[];var b=c[a];return b===void 0?[]:typeof b=="function"?p?[b.listener||b]:[b]:p?h(b):d(b,b.length)}O.prototype.listeners=function(a){return n(this,a,!0)},O.prototype.rawListeners=function(a){return n(this,a,!1)},O.listenerCount=function(s,a){return typeof s.listenerCount=="function"?s.listenerCount(a):i.call(s,a)},O.prototype.listenerCount=i;function i(s){var a=this._events;if(a!==void 0){var p=a[s];if(typeof p=="function")return 1;if(p!==void 0)return p.length}return 0}O.prototype.eventNames=function(){return this._eventsCount>0?f(this._events):[]};function d(s,a){for(var p=new Array(a),c=0;c<a;++c)p[c]=s[c];return p}function u(s,a){for(;a+1<s.length;a++)s[a]=s[a+1];s.pop()}function h(s){for(var a=new Array(s.length),p=0;p<a.length;++p)a[p]=s[p].listener||s[p];return a}function t(s,a){return new Promise(function(p,c){function b(A){s.removeListener(a,C),c(A)}function C(){typeof s.removeListener=="function"&&s.removeListener("error",b),p([].slice.call(arguments))}l(s,a,C,{once:!0}),a!=="error"&&o(s,b,{once:!0})})}function o(s,a,p){typeof s.on=="function"&&l(s,"error",a,p)}function l(s,a,p,c){if(typeof s.on=="function")c.once?s.once(a,p):s.on(a,p);else if(typeof s.addEventListener=="function")s.addEventListener(a,function b(C){c.once&&s.removeEventListener(a,b),p(C)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof s)}},function(v,T,w){var y=w(3),E=w(0),f=0;function r(){return"hole_"+f++}function g(i,d){for(var u=null,h=0;h<i.length;h++){var t=d(i[h]);t!==i[h]&&(u||(u=i.slice()),u[h]=t)}return u||i}function O(i,d,u){if(!(i instanceof y.Node))return i;if(!u){var h=d(i);if(h&&h!==i)return h}if(i instanceof y.NodeList){var t=g(i.children,function(p){return O(p,d,u)});t!==i.children&&(i=new y[i.typename](i.lineno,i.colno,t))}else if(i instanceof y.CallExtension){var o=O(i.args,d,u),l=g(i.contentArgs,function(p){return O(p,d,u)});(o!==i.args||l!==i.contentArgs)&&(i=new y[i.typename](i.extName,i.prop,o,l))}else{var s=i.fields.map(function(p){return i[p]}),a=g(s,function(p){return O(p,d,u)});a!==s&&(i=new y[i.typename](i.lineno,i.colno),a.forEach(function(p,c){i[i.fields[c]]=p}))}return u&&d(i)||i}function j(i,d){return O(i,d,!0)}function U(i,d,u){var h=[],t=j(u?i[u]:i,function(o){var l;return o instanceof y.Block?o:((o instanceof y.Filter&&E.indexOf(d,o.name.value)!==-1||o instanceof y.CallExtensionAsync)&&(l=new y.Symbol(o.lineno,o.colno,r()),h.push(new y.FilterAsync(o.lineno,o.colno,o.name,o.args,l))),l)});return u?i[u]=t:i=t,h.length?(h.push(i),new y.NodeList(i.lineno,i.colno,h)):i}function F(i,d){return j(i,function(u){return u instanceof y.Output?U(u,d):u instanceof y.Set?U(u,d,"value"):u instanceof y.For?U(u,d,"arr"):u instanceof y.If?U(u,d,"cond"):u instanceof y.CallExtension?U(u,d,"args"):void 0})}function k(i){return O(i,function(d){if(d instanceof y.Block){var u=!1,h=r();d.body=O(d.body,function(t){if(t instanceof y.FunCall&&t.name.value==="super")return u=!0,new y.Symbol(t.lineno,t.colno,h)}),u&&d.body.children.unshift(new y.Super(0,0,d.name,new y.Symbol(0,0,h)))}})}function P(i){return j(i,function(d){if(!(!(d instanceof y.If)&&!(d instanceof y.For))){var u=!1;if(O(d,function(h){if(h instanceof y.FilterAsync||h instanceof y.IfAsync||h instanceof y.AsyncEach||h instanceof y.AsyncAll||h instanceof y.CallExtensionAsync)return u=!0,h}),u){if(d instanceof y.If)return new y.IfAsync(d.lineno,d.colno,d.cond,d.body,d.else_);if(d instanceof y.For&&!(d instanceof y.AsyncAll))return new y.AsyncEach(d.lineno,d.colno,d.arr,d.name,d.body,d.else_)}}})}function e(i,d){return P(k(F(i,d)))}function n(i,d){return e(i,d||[])}v.exports={transform:n}},function(v,f,w){var y=w(0),E=w(2),f=v.exports={};function r(x,B){return x==null||x===!1?B:x}f.abs=Math.abs;function g(x){return x!==x}function O(x,B,G){var $,ee=[],ie=[];for($=0;$<x.length;$++)$%B===0&&ie.length&&(ee.push(ie),ie=[]),ie.push(x[$]);if(ie.length){if(G)for($=ie.length;$<B;$++)ie.push(G);ee.push(ie)}return ee}f.batch=O;function j(x){x=r(x,"");var B=x.toLowerCase();return E.copySafeness(x,B.charAt(0).toUpperCase()+B.slice(1))}f.capitalize=j;function U(x,B){if(x=r(x,""),B=B||80,x.length>=B)return x;var G=B-x.length,$=y.repeat(" ",G/2-G%2),ee=y.repeat(" ",G/2);return E.copySafeness(x,$+x+ee)}f.center=U;function F(x,B,G){return G?x||B:x!==void 0?x:B}f.default=F;function k(x,B,G){if(!y.isObject(x))throw new y.TemplateError("dictsort filter: val must be an object");var $=[];for(var ee in x)$.push([ee,x[ee]]);var ie;if(G===void 0||G==="key")ie=0;else if(G==="value")ie=1;else throw new y.TemplateError("dictsort filter: You can only sort by either key or value");return $.sort(function(ve,ce){var xe=ve[ie],Fe=ce[ie];return B||(y.isString(xe)&&(xe=xe.toUpperCase()),y.isString(Fe)&&(Fe=Fe.toUpperCase())),xe>Fe?1:xe===Fe?0:-1}),$}f.dictsort=k;function P(x,B){return JSON.stringify(x,null,B)}f.dump=P;function e(x){return x instanceof E.SafeString?x:(x=x??"",E.markSafe(y.escape(x.toString())))}f.escape=e;function n(x){return x instanceof E.SafeString?x:(x=x??"",E.markSafe(x.toString()))}f.safe=n;function i(x){return x[0]}f.first=i;function d(x){return x=x??"",E.markSafe(y.escape(x.toString()))}f.forceescape=d;function u(x,B){return y.groupBy(x,B,this.env.opts.throwOnUndefined)}f.groupby=u;function h(x,B,G){if(x=r(x,""),x==="")return"";B=B||4;var $=x.split(`
24
- `),ee=y.repeat(" ",B),ie=$.map(function(ve,ce){return ce===0&&!G?ve:""+ee+ve}).join(`
25
- `);return E.copySafeness(x,ie)}f.indent=h;function t(x,B,G){return B=B||"",G&&(x=y.map(x,function($){return $[G]})),x.join(B)}f.join=t;function o(x){return x[x.length-1]}f.last=o;function l(x){var B=r(x,"");return B!==void 0?typeof Map=="function"&&B instanceof Map||typeof Set=="function"&&B instanceof Set?B.size:y.isObject(B)&&!(B instanceof E.SafeString)?y.keys(B).length:B.length:0}f.length=l;function s(x){if(y.isString(x))return x.split("");if(y.isObject(x))return y._entries(x||{}).map(function(B){var G=B[0],$=B[1];return{key:G,value:$}});if(y.isArray(x))return x;throw new y.TemplateError("list filter: type not iterable")}f.list=s;function a(x){return x=r(x,""),x.toLowerCase()}f.lower=a;function p(x){return x==null?"":E.copySafeness(x,x.replace(/\r\n|\n/g,`<br />
26
- `))}f.nl2br=p;function c(x){return x[Math.floor(Math.random()*x.length)]}f.random=c;function b(x){function B(G,$,ee){$===void 0&&($="truthy");var ie=this,ve=ie.env.getTest($);return y.toArray(G).filter(function(xe){return ve.call(ie,xe,ee)===x})}return B}f.reject=b(!1);function C(x,B){return x.filter(function(G){return!G[B]})}f.rejectattr=C,f.select=b(!0);function A(x,B){return x.filter(function(G){return!!G[B]})}f.selectattr=A;function R(x,B,G,$){var ee=x;if(B instanceof RegExp)return x.replace(B,G);typeof $>"u"&&($=-1);var ie="";if(typeof B=="number")B=""+B;else if(typeof B!="string")return x;if(typeof x=="number"&&(x=""+x),typeof x!="string"&&!(x instanceof E.SafeString))return x;if(B==="")return ie=G+x.split("").join(G)+G,E.copySafeness(x,ie);var ve=x.indexOf(B);if($===0||ve===-1)return x;for(var ce=0,xe=0;ve>-1&&($===-1||xe<$);)ie+=x.substring(ce,ve)+G,ce=ve+B.length,xe++,ve=x.indexOf(B,ce);return ce<x.length&&(ie+=x.substring(ce)),E.copySafeness(ee,ie)}f.replace=R;function V(x){var B;return y.isString(x)?B=s(x):B=y.map(x,function(G){return G}),B.reverse(),y.isString(x)?E.copySafeness(x,B.join("")):B}f.reverse=V;function _(x,B,G){B=B||0;var $=Math.pow(10,B),ee;return G==="ceil"?ee=Math.ceil:G==="floor"?ee=Math.floor:ee=Math.round,ee(x*$)/$}f.round=_;function m(x,B,G){for(var $=Math.floor(x.length/B),ee=x.length%B,ie=[],ve=0,ce=0;ce<B;ce++){var xe=ve+ce*$;ce<ee&&ve++;var Fe=ve+(ce+1)*$,Me=x.slice(xe,Fe);G&&ce>=ee&&Me.push(G),ie.push(Me)}return ie}f.slice=m;function L(x,B,G){return G===void 0&&(G=0),B&&(x=y.map(x,function($){return $[B]})),G+x.reduce(function($,ee){return $+ee},0)}f.sum=L,f.sort=E.makeMacro(["value","reverse","case_sensitive","attribute"],[],function(B,G,$,ee){var ie=this,ve=y.map(B,function(xe){return xe}),ce=y.getAttrGetter(ee);return ve.sort(function(xe,Fe){var Me=ee?ce(xe):xe,Ve=ee?ce(Fe):Fe;if(ie.env.opts.throwOnUndefined&&ee&&(Me===void 0||Ve===void 0))throw new TypeError('sort: attribute "'+ee+'" resolved to undefined');return!$&&y.isString(Me)&&y.isString(Ve)&&(Me=Me.toLowerCase(),Ve=Ve.toLowerCase()),Me<Ve?G?1:-1:Me>Ve?G?-1:1:0}),ve});function K(x){return E.copySafeness(x,x)}f.string=K;function D(x,B){x=r(x,"");var G=/<\/?([a-z][a-z0-9]*)\b[^>]*>|<!--[\s\S]*?-->/gi,$=le(x.replace(G,"")),ee="";return B?ee=$.replace(/^ +| +$/gm,"").replace(/ +/g," ").replace(/(\r\n)/g,`
27
- `).replace(/\n\n\n+/g,`
28
-
29
- `):ee=$.replace(/\s+/gi," "),E.copySafeness(x,ee)}f.striptags=D;function z(x){x=r(x,"");var B=x.split(" ").map(function(G){return j(G)});return E.copySafeness(x,B.join(" "))}f.title=z;function le(x){return E.copySafeness(x,x.replace(/^\s*|\s*$/g,""))}f.trim=le;function X(x,B,G,$){var ee=x;if(x=r(x,""),B=B||255,x.length<=B)return x;if(G)x=x.substring(0,B);else{var ie=x.lastIndexOf(" ",B);ie===-1&&(ie=B),x=x.substring(0,ie)}return x+=$??"...",E.copySafeness(ee,x)}f.truncate=X;function fe(x){return x=r(x,""),x.toUpperCase()}f.upper=fe;function Ee(x){var B=encodeURIComponent;if(y.isString(x))return B(x);var G=y.isArray(x)?x:y._entries(x);return G.map(function($){var ee=$[0],ie=$[1];return B(ee)+"="+B(ie)}).join("&")}f.urlencode=Ee;var J=/^(?:\(|<|&lt;)?(.*?)(?:\.|,|\)|\n|&gt;)?$/,Z=/^[\w.!#$%&'*+\-\/=?\^`{|}~]+@[a-z\d\-]+(\.[a-z\d\-]+)+$/i,H=/^https?:\/\/.*$/,Y=/^www\./,Q=/\.(?:org|net|com)(?:\:|\/|$)/;function ue(x,B,G){g(B)&&(B=1/0);var $=G===!0?' rel="nofollow"':"",ee=x.split(/(\s+)/).filter(function(ie){return ie&&ie.length}).map(function(ie){var ve=ie.match(J),ce=ve?ve[1]:ie,xe=ce.substr(0,B);return H.test(ce)?'<a href="'+ce+'"'+$+">"+xe+"</a>":Y.test(ce)?'<a href="http://'+ce+'"'+$+">"+xe+"</a>":Z.test(ce)?'<a href="mailto:'+ce+'">'+ce+"</a>":Q.test(ce)?'<a href="http://'+ce+'"'+$+">"+xe+"</a>":ie});return ee.join("")}f.urlize=ue;function pe(x){x=r(x,"");var B=x?x.match(/\w+/g):null;return B?B.length:null}f.wordcount=pe;function de(x,B){var G=parseFloat(x);return g(G)?B:G}f.float=de;var Te=E.makeMacro(["value","default","base"],[],function(B,G,$){$===void 0&&($=10);var ee=parseInt(B,$);return g(ee)?G:ee});f.int=Te,f.d=f.default,f.e=f.escape},function(v,T,w){function y(g,O){g.prototype=Object.create(O.prototype),g.prototype.constructor=g,E(g,O)}function E(g,O){return E=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(U,F){return U.__proto__=F,U},E(g,O)}var f=w(6),r=function(g){y(O,g);function O(U){var F;return F=g.call(this)||this,F.precompiled=U||{},F}var j=O.prototype;return j.getSource=function(F){return this.precompiled[F]?{src:{type:"code",obj:this.precompiled[F]},path:F}:null},O}(f);v.exports={PrecompiledLoader:r}},function(v,T,w){var y=w(2).SafeString;function E(c){return typeof c=="function"}T.callable=E;function f(c){return c!==void 0}T.defined=f;function r(c,b){return c%b===0}T.divisibleby=r;function g(c){return c instanceof y}T.escaped=g;function O(c,b){return c===b}T.equalto=O,T.eq=T.equalto,T.sameas=T.equalto;function j(c){return c%2===0}T.even=j;function U(c){return!c}T.falsy=U;function F(c,b){return c>=b}T.ge=F;function k(c,b){return c>b}T.greaterthan=k,T.gt=T.greaterthan;function P(c,b){return c<=b}T.le=P;function e(c,b){return c<b}T.lessthan=e,T.lt=T.lessthan;function n(c){return c.toLowerCase()===c}T.lower=n;function i(c,b){return c!==b}T.ne=i;function d(c){return c===null}T.null=d;function u(c){return typeof c=="number"}T.number=u;function h(c){return c%2===1}T.odd=h;function t(c){return typeof c=="string"}T.string=t;function o(c){return!!c}T.truthy=o;function l(c){return c===void 0}T.undefined=l;function s(c){return c.toUpperCase()===c}T.upper=s;function a(c){return typeof Symbol<"u"?!!c[Symbol.iterator]:Array.isArray(c)||typeof c=="string"}T.iterable=a;function p(c){var b=c!=null&&typeof c=="object"&&!Array.isArray(c);return Set?b&&!(c instanceof Set):b}T.mapping=p},function(v,T,w){function y(r){var g=-1;return{current:null,reset:function(){g=-1,this.current=null},next:function(){return g++,g>=r.length&&(g=0),this.current=r[g],this.current}}}function E(r){r=r||",";var g=!0;return function(){var O=g?"":r;return g=!1,O}}function f(){return{range:function(g,O,j){typeof O>"u"?(O=g,g=0,j=1):j||(j=1);var U=[];if(j>0)for(var F=g;F<O;F+=j)U.push(F);else for(var k=g;k>O;k+=j)U.push(k);return U},cycler:function(){return y(Array.prototype.slice.call(arguments))},joiner:function(g){return E(g)}}}v.exports=f},function(v,T,w){var y=w(4);v.exports=function(f,r){function g(O,j){if(this.name=O,this.path=O,this.defaultEngine=j.defaultEngine,this.ext=y.extname(O),!this.ext&&!this.defaultEngine)throw new Error("No default engine was specified and no extension was provided.");this.ext||(this.name+=this.ext=(this.defaultEngine[0]!=="."?".":"")+this.defaultEngine)}return g.prototype.render=function(j,U){f.render(this.name,j,U)},r.set("view",g),r.set("nunjucksEnv",f),f}},function(v,T,w){var y=w(4),E=w(4),f=w(0),r=f._prettifyError,g=w(5),O=w(7),j=O.Environment,U=w(24);function F(n,i){return Array.isArray(i)?i.some(function(d){return n.match(d)}):!1}function k(n,i){i=i||{},i.isString=!0;var d=i.env||new j([]),u=i.wrapper||U;if(!i.name)throw new Error('the "name" option is required when compiling a string');return u([e(n,i.name,d)],i)}function P(n,i){i=i||{};var d=i.env||new j([]),u=i.wrapper||U;if(i.isString)return k(n,i);var h=y.existsSync(n)&&y.statSync(n),t=[],o=[];function l(p){y.readdirSync(p).forEach(function(c){var b=E.join(p,c),C=b.substr(E.join(n,"/").length),A=y.statSync(b);A&&A.isDirectory()?(C+="/",F(C,i.exclude)||l(b)):F(C,i.include)&&o.push(b)})}if(h.isFile())t.push(e(y.readFileSync(n,"utf-8"),i.name||n,d));else if(h.isDirectory()){l(n);for(var s=0;s<o.length;s++){var a=o[s].replace(E.join(n,"/"),"");try{t.push(e(y.readFileSync(o[s],"utf-8"),a,d))}catch(p){if(i.force)console.error(p);else throw p}}}return u(t,i)}function e(n,i,d){d=d||new j([]);var u=d.asyncFilters,h=d.extensionsList,t;i=i.replace(/\\/g,"/");try{t=g.compile(n,u,h,i,d.opts)}catch(o){throw r(i,!1,o)}return{name:i,template:t}}v.exports={precompile:P,precompileString:k}},function(v,T,w){function y(E,f){var r="";f=f||{};for(var g=0;g<E.length;g++){var O=JSON.stringify(E[g].name),j=E[g].template;r+="(function() {(window.nunjucksPrecompiled = window.nunjucksPrecompiled || {})["+O+`] = (function() {
30
- `+j+`
31
- })();
32
- `,f.asFunction&&(r+="return function(ctx, cb) { return nunjucks.render("+O+`, ctx, cb); }
33
- `),r+=`})();
34
- `}return r}v.exports=y},function(v,T,w){function y(){var E=this.runtime,f=this.lib,r=this.compiler.Compiler,g=this.parser.Parser,O=this.nodes,j=this.lexer,U=E.contextOrFrameLookup,F=E.memberLookup,k,P;r&&(k=r.prototype.assertType),g&&(P=g.prototype.parseAggregate);function e(){E.contextOrFrameLookup=U,E.memberLookup=F,r&&(r.prototype.assertType=k),g&&(g.prototype.parseAggregate=P)}E.contextOrFrameLookup=function(l,s,a){var p=U.apply(this,arguments);if(p!==void 0)return p;switch(a){case"True":return!0;case"False":return!1;case"None":return null;default:return}};function n(o){return{index:o.index,lineno:o.lineno,colno:o.colno}}if(O&&r&&g){var i=O.Node.extend("Slice",{fields:["start","stop","step"],init:function(l,s,a,p,c){a=a||new O.Literal(l,s,null),p=p||new O.Literal(l,s,null),c=c||new O.Literal(l,s,1),this.parent(l,s,a,p,c)}});r.prototype.assertType=function(l){l instanceof i||k.apply(this,arguments)},r.prototype.compileSlice=function(l,s){this._emit("("),this._compileExpression(l.start,s),this._emit("),("),this._compileExpression(l.stop,s),this._emit("),("),this._compileExpression(l.step,s),this._emit(")")},g.prototype.parseAggregate=function(){var l=this,s=n(this.tokens);s.colno--,s.index--;try{return P.apply(this)}catch(V){var a=n(this.tokens),p=function(){return f._assign(l.tokens,a),V};f._assign(this.tokens,s),this.peeked=!1;var c=this.peekToken();if(c.type!==j.TOKEN_LEFT_BRACKET)throw p();this.nextToken();for(var b=new i(c.lineno,c.colno),C=!1,A=0;A<=b.fields.length&&!this.skip(j.TOKEN_RIGHT_BRACKET);A++){if(A===b.fields.length)if(C)this.fail("parseSlice: too many slice components",c.lineno,c.colno);else break;if(this.skip(j.TOKEN_COLON))C=!0;else{var R=b.fields[A];b[R]=this.parseExpression(),C=this.skip(j.TOKEN_COLON)||C}}if(!C)throw p();return new O.Array(c.lineno,c.colno,[b])}}}function d(o,l,s,a){o=o||[],l===null&&(l=a<0?o.length-1:0),s===null?s=a<0?-1:o.length:s<0&&(s+=o.length),l<0&&(l+=o.length);for(var p=[],c=l;!(c<0||c>o.length||a>0&&c>=s||a<0&&c<=s);c+=a)p.push(E.memberLookup(o,c));return p}function u(o,l){return Object.prototype.hasOwnProperty.call(o,l)}var h={pop:function(l){if(l===void 0)return this.pop();if(l>=this.length||l<0)throw new Error("KeyError");return this.splice(l,1)},append:function(l){return this.push(l)},remove:function(l){for(var s=0;s<this.length;s++)if(this[s]===l)return this.splice(s,1);throw new Error("ValueError")},count:function(l){for(var s=0,a=0;a<this.length;a++)this[a]===l&&s++;return s},index:function(l){var s;if((s=this.indexOf(l))===-1)throw new Error("ValueError");return s},find:function(l){return this.indexOf(l)},insert:function(l,s){return this.splice(l,0,s)}},t={items:function(){return f._entries(this)},values:function(){return f._values(this)},keys:function(){return f.keys(this)},get:function(l,s){var a=this[l];return a===void 0&&(a=s),a},has_key:function(l){return u(this,l)},pop:function(l,s){var a=this[l];if(a===void 0&&s!==void 0)a=s;else{if(a===void 0)throw new Error("KeyError");delete this[l]}return a},popitem:function(){var l=f.keys(this);if(!l.length)throw new Error("KeyError");var s=l[0],a=this[s];return delete this[s],[s,a]},setdefault:function(l,s){return s===void 0&&(s=null),l in this||(this[l]=s),this[l]},update:function(l){return f._assign(this,l),null}};return t.iteritems=t.items,t.itervalues=t.values,t.iterkeys=t.keys,E.memberLookup=function(l,s,a){return arguments.length===4?d.apply(this,arguments):(l=l||{},f.isArray(l)&&u(h,s)?h[s].bind(l):f.isObject(l)&&u(t,s)?t[s].bind(l):F.apply(this,arguments))},e}v.exports=y}])})})(Qt);var jn=Qt.exports;const Kt=Sn(jn);var Dn=(M,N)=>N(M.currentTarget.checked),Un=me('<label class="absolute right-6 top-1 z-10 inline-flex cursor-pointer items-center gap-2 bg-transparent text-rc-gray-100 focus:outline-none focus:ring-0"><input type="checkbox" class="checkbox svelte-1br1z62"/> <span>Preview</span></label>'),Vn=me('<div class="flex justify-end"><!></div>'),Wn=me('<div class="prompt-editor flex h-full flex-col"><div class="relative flex-1"><div class="h-full w-full"></div> <!></div> <!></div>');function $n(M,N){gt(N,!0);let v=De(null),T,w=Lt(N,"readOnly",3,!1),y=Lt(N,"showPreviewToggle",3,!0),E=Lt(N,"preview",3,null),f=!1,r=null,g=null,O=!1,j=null,U=[],F=null,k=null,P=0;const e=24;let n=De(!1);const i=Be(()=>E()!==null?E():I(n));function d(c,b){const C=c.getLayoutInfo(),A=Number((C==null?void 0:C.contentWidth)??0);if(!Number.isFinite(A)||A<=0)return 80;const R=c.getOption(b.editor.EditorOption.fontInfo),V=Number(R==null?void 0:R.typicalHalfwidthCharacterWidth)||Number(R==null?void 0:R.typicalFullwidthCharacterWidth)||7;if(!Number.isFinite(V)||V<=0)return 80;const _=Math.floor((A-e)/V);return Math.max(20,_)}function u(){!I(v)||!g||k==null&&(k=requestAnimationFrame(()=>{if(k=null,!I(v)||!g)return;const c=d(I(v),g);c!==P&&(P=c,I(v).updateOptions({wordWrap:"bounded",wordWrapColumn:c}))}))}Pt(()=>{if(!T)return;qt();let c=!1;return Ht(()=>import("../chunks/DLQqXQ6R.js").then(b=>b.e),__vite__mapDeps([0,1,2]),import.meta.url).then(b=>{if(c)return;g=b,zt(b),Se(v,b.editor.create(T,{value:"",language:"markdown",theme:"bosun-dark",lineNumbers:"off",fontSize:14,fontFamily:'ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"',automaticLayout:!0,minimap:{enabled:!1},wordBasedSuggestions:"off",wordWrap:"bounded",wordWrapColumn:120,wrappingStrategy:"advanced",matchBrackets:"never",bracketPairColorization:{enabled:!0},guides:{highlightActiveBracketPair:!1,bracketPairs:!1,bracketPairsHorizontal:!1},occurrencesHighlight:"off",selectionHighlight:!1,unicodeHighlight:{ambiguousCharacters:!1,nonBasicASCII:!1,invisibleCharacters:!1,includeStrings:!1,includeComments:!1},autoClosingQuotes:"never",padding:{top:32},readOnly:w()}),!0),j=I(v).getModel(),u(),U.push(I(v).onDidLayoutChange(()=>u())),ut.agents.context.query({agentId:N.agentId}).then(A=>{c||(F==null||F.dispose(),F=Pn(b,A))}),r=xn(b,I(v));const C=N.initialPrompt??"";if(f=!0,I(v).setValue(C),f=!1,requestAnimationFrame(()=>{r==null||r.update()}),U.push(I(v).onDidChangeModelContent(()=>{if(I(v)&&(r==null||r.update(),!f))try{const A=I(v).getValue();N.onPromptChanged(A)}catch(A){console.error("Error updating prompt",A)}})),O=!0,N.onEditorReady)try{N.onEditorReady(I(v),b)}catch(A){console.error("PromptEditor onEditorReady error",A)}}).catch(b=>{console.error("Error initializing Monaco editor:",b)}),()=>{c=!0,k!=null&&cancelAnimationFrame(k),k=null;try{F==null||F.dispose()}catch{}F=null;for(const C of U)try{C.dispose()}catch{}U=[],r==null||r.dispose(),r=null;const b=j;if(j=null,I(v)){try{I(v).setModel(null)}catch{}I(v).dispose(),Se(v,null)}try{b==null||b.dispose()}catch{}}}),He(()=>{!I(v)||!O||I(v).updateOptions({readOnly:w()})});function h(c,b){return Kt.configure({autoescape:!1,trimBlocks:!0,lstripBlocks:!0}),Kt.renderString(c,b||{})}let t="",o=0;function l(c){var b;if(E()!==null){(b=N.onPreviewChange)==null||b.call(N,c);return}Se(n,c,!0)}function s(){if(o+=1,!!I(v)){f=!0;try{t&&(I(v).setValue(t),t=""),I(v).updateOptions({readOnly:w()})}finally{f=!1}}}async function a(){if(!I(v)||w())return;t=I(v).getValue();const c=o+=1;let b=null;try{b=await ut.agents.context.query({agentId:N.agentId})}catch(A){console.error("Failed to load agent context for preview:",A),b=null}if(c!==o||!I(v)||!I(i))return;const C=h(t,b||{});f=!0;try{I(v).setValue(C),I(v).updateOptions({readOnly:!0})}finally{f=!1}}let p=De(!1);He(()=>{if(!I(v)||!O)return;const c=!!I(i)&&!w();c!==I(p)&&(Se(p,c,!0),c?a():s())}),mt(M,{get class(){return`relative overflow-hidden ${N.class??""}`},children:(c,b)=>{var C=Wn(),A=se(C),R=se(A);Gt(R,K=>T=K,()=>T);var V=ye(R,2);{var _=K=>{var D=Un(),z=se(D);Wt(z),z.__change=[Dn,l],je(2),re(D),Ke(()=>cn(z,I(i))),oe(K,D)};Ce(V,K=>{y()&&!w()&&K(_)})}re(A);var m=ye(A,2);{var L=K=>{var D=Vn(),z=se(D);wt(z,{variant:"secondary",get onclick(){return N.onSchemaClick},class:"absolute bottom-2 right-6 !font-medium",children:(le,X)=>{je();var fe=$e("Schema");oe(le,fe)},$$slots:{default:!0}}),re(D),oe(K,D)};Ce(m,K=>{N.showSchemaButton&&N.onSchemaClick&&K(L)})}re(C),oe(c,C)}}),yt()}Rt(["change"]);var Hn=me("<!> <!>",1),Gn=me('<div class="flex h-full items-center justify-center text-sm text-rc-gray-300">Loading</div>'),qn=me('<pre class="whitespace-pre-wrap font-mono text-xs text-rc-gray-200"> </pre>'),zn=me('<div class="flex h-full flex-col gap-3"><div class="text-sm text-red-400"> </div></div>'),Qn=me('<pre class="whitespace-pre-wrap font-mono text-xs text-rc-gray-200"> </pre>'),Yn=me('<div class="text-red-400">Error</div>'),Jn=me('<div class="rounded-md border border-rc-gray-700 bg-rc-gray-900/40 px-3 py-2"><div class="flex items-center justify-between text-xs text-rc-gray-400"><div> </div> <!></div> <div class="whitespace-pre-wrap break-words text-sm text-rc-gray-100"> </div></div>'),Xn=me('<div class="mb-4"><div class="mb-2 text-xs font-semibold text-rc-gray-400">Why this response</div> <div class="flex flex-col gap-2"></div></div>'),Zn=(M,N,v)=>N.focusQuote(I(v).quote),er=me('<button type="button" class="rounded-md border border-rc-gray-700 bg-rc-gray-900/40 px-3 py-2 text-left hover:border-rc-gray-500"><div class="flex items-center justify-between text-xs text-rc-gray-400"><div> </div> <div> </div></div> <div class="whitespace-pre-wrap break-words text-sm text-rc-gray-100"> </div></button>'),tr=me('<div class="flex flex-col gap-2"></div>'),nr=me('<div class="text-sm text-rc-gray-300">No quotes returned.</div>'),rr=me('<div class="mb-3 text-sm font-semibold text-rc-gray-100"> </div> <!> <!>',1),ir=(M,N,v)=>N.focusQuote(v),or=me('<button type="button" class="rounded-md border border-rc-gray-700 bg-rc-gray-900/40 px-3 py-2 text-left hover:border-rc-gray-500"><div class="whitespace-pre-wrap break-words text-sm text-rc-gray-100"> </div></button>'),sr=me('<div class="mt-3 flex flex-col gap-2"></div>'),ar=me('<div class="rounded-md border border-rc-gray-700 bg-rc-gray-900/40 p-3"><div class="flex items-start justify-between gap-3"><div class="text-xs font-semibold text-rc-gray-400"></div> <div class="text-xs text-rc-gray-500"> </div></div> <div class="mt-1 whitespace-pre-wrap break-words text-sm text-rc-gray-100"> </div> <!></div>'),lr=me('<div class="flex flex-col gap-3"></div>'),cr=me('<div class="text-sm text-rc-gray-300">No issues found.</div>'),ur=me('<div class="mb-3 text-sm font-semibold text-rc-gray-100"> </div> <!>',1),fr=me('<div class="border-b border-rc-gray-700 px-2 py-1"><!></div> <div class="min-h-0 flex-1 overflow-auto p-3"><!></div>',1);function pr(M,N){gt(N,!0);const{state:v,actions:T}=$t();let w=De("results"),y=De(null);He(()=>{var O;const g=((O=v.edit.popover)==null?void 0:O.requestId)??null;g!==I(y)&&(Se(y,g,!0),Se(w,"results"))});var E=tt(),f=Pe(E);{var r=g=>{const O=Be(()=>v.edit.popover);var j=fr(),U=Pe(j),F=se(U);Ct(F,{get value(){return I(w)},ariaLabel:"Popover tabs",onChange:({value:i})=>Se(w,i,!0),children:(i,d)=>{var u=Hn(),h=Pe(u);st(h,{value:"results",children:(o,l)=>{je();var s=$e("Results");oe(o,s)},$$slots:{default:!0}});var t=ye(h,2);st(t,{value:"raw",children:(o,l)=>{je();var s=$e("Raw");oe(o,s)},$$slots:{default:!0}}),oe(i,u)},$$slots:{default:!0}}),re(U);var k=ye(U,2),P=se(k);{var e=i=>{var d=Gn();oe(i,d)},n=i=>{var d=tt(),u=Pe(d);{var h=o=>{var l=tt(),s=Pe(l);{var a=c=>{const b=Be(()=>{var R;return typeof((R=I(O).data)==null?void 0:R.raw)=="string"?I(O).data.raw:I(O).error});var C=qn(),A=se(C,!0);re(C),Ke(()=>Ie(A,I(b)||"—")),oe(c,C)},p=c=>{var b=zn(),C=se(b),A=se(C,!0);re(C),re(b),Ke(()=>Ie(A,I(O).error)),oe(c,b)};Ce(s,c=>{I(w)==="raw"?c(a):c(p,!1)})}oe(o,l)},t=o=>{const l=Be(()=>I(O).data);var s=tt(),a=Pe(s);{var p=b=>{var C=Qn(),A=se(C,!0);re(C),Ke(()=>{var R;return Ie(A,typeof((R=I(l))==null?void 0:R.raw)=="string"?I(l).raw:"—")}),oe(b,C)},c=b=>{var C=tt(),A=Pe(C);{var R=_=>{const m=Be(()=>{var J;return typeof((J=I(l))==null?void 0:J.parallelCalls)=="number"&&Number.isFinite(I(l).parallelCalls)?I(l).parallelCalls:10});var L=rr(),K=Pe(L),D=se(K,!0);re(K);var z=ye(K,2);{var le=J=>{var Z=Xn(),H=ye(se(Z),2);ct(H,23,()=>I(l).rationales,(Y,Q)=>Y.attempt??Q,(Y,Q,ue)=>{var pe=Jn(),de=se(pe),Te=se(de),x=se(Te);re(Te);var B=ye(Te,2);{var G=ie=>{var ve=Yn();oe(ie,ve)};Ce(B,ie=>{I(Q).status==="error"&&ie(G)})}re(de);var $=ye(de,2),ee=se($,!0);re($),re(pe),Ke(()=>{Ie(x,`Analysis ${I(Q).attempt??I(ue)+1??""}`),Ie(ee,I(Q).text)}),oe(Y,pe)}),re(H),re(Z),oe(J,Z)};Ce(z,J=>{var Z;Array.isArray((Z=I(l))==null?void 0:Z.rationales)&&I(l).rationales.length>0&&J(le)})}var X=ye(z,2);{var fe=J=>{var Z=tr();ct(Z,23,()=>I(l).quotes,H=>H.quote,(H,Y,Q)=>{var ue=er();ue.__click=[Zn,T,Y];var pe=se(ue),de=se(pe),Te=se(de);re(de);var x=ye(de,2),B=se(x);re(x),re(pe);var G=ye(pe,2),$=se(G,!0);re(G),re(ue),Ke(()=>{Ie(Te,`Quote ${I(Q)+1}`),Ie(B,`x${I(Y).count??""}/${I(m)??""}`),Ie($,I(Y).quote)}),oe(H,ue)}),re(Z),oe(J,Z)},Ee=J=>{var Z=nr();oe(J,Z)};Ce(X,J=>{var Z;Array.isArray((Z=I(l))==null?void 0:Z.quotes)&&I(l).quotes.length>0?J(fe):J(Ee,!1)})}Ke(()=>{var J;return Ie(D,((J=I(l))==null?void 0:J.title)??"Analysis")}),oe(_,L)},V=_=>{var m=ur(),L=Pe(m),K=se(L,!0);re(L);var D=ye(L,2);{var z=X=>{var fe=lr();ct(fe,21,()=>I(l).issues,At,(Ee,J,Z)=>{var H=ar(),Y=se(H),Q=se(Y);Q.textContent=`Issue ${Z+1}`;var ue=ye(Q,2),pe=se(ue,!0);re(ue),re(Y);var de=ye(Y,2),Te=se(de,!0);re(de);var x=ye(de,2);{var B=G=>{var $=sr();ct($,20,()=>I(J).contradictingQuotes,ee=>ee,(ee,ie)=>{var ve=or();ve.__click=[ir,T,ie];var ce=se(ve),xe=se(ce,!0);re(ce),re(ve),Ke(()=>Ie(xe,ie)),oe(ee,ve)}),re($),oe(G,$)};Ce(x,G=>{I(J).contradictingQuotes&&I(J).contradictingQuotes.length>0&&G(B)})}re(H),Ke(()=>{Ie(pe,I(J).type),Ie(Te,I(J).reason)}),oe(Ee,H)}),re(fe),oe(X,fe)},le=X=>{var fe=cr();oe(X,fe)};Ce(D,X=>{var fe;Array.isArray((fe=I(l))==null?void 0:fe.issues)&&I(l).issues.length>0?X(z):X(le,!1)})}Ke(()=>{var X;return Ie(K,((X=I(l))==null?void 0:X.title)??"Prompt issues")}),oe(_,m)};Ce(A,_=>{I(O).kind==="analyze"?_(R):_(V,!1)},!0)}oe(b,C)};Ce(a,b=>{I(w)==="raw"?b(p):b(c,!1)})}oe(o,s)};Ce(u,o=>{I(O).status==="error"?o(h):o(t,!1)},!0)}oe(i,d)};Ce(P,i=>{I(O).status==="loading"?i(e):i(n,!1)})}re(k),oe(g,j)};Ce(f,g=>{v.edit.popover&&g(r)})}oe(M,E),yt()}Rt(["click"]);var hr=me('<div class="min-h-0 flex-1 overflow-hidden p-3"><!></div>');function dr(M,N){gt(N,!1);const v=$t(),T=on(v.state),w=v.actions;function y(r){sn(T,I(T).context=r),w.sendAppEvent({type:"context-updated",context:r})}En();var E=hr(),f=se(E);yn(f,{class:"h-full min-h-0 border-thin border-rc-gray-650 shadow-inner-white-soft backdrop-blur-3xl focus:outline-none focus:ring-0",get context(){return I(T).context},onContextChanged:y,suppressErrors:!0}),re(E),oe(M,E),yt()}function vr(M){try{return decodeURIComponent(M)}catch{return M}}function Yt(M){var y;const v=(((y=String(M||"").split("?")[0])==null?void 0:y.split("#")[0])??"").split("/").filter(Boolean);if(v[0]!=="edit")return{agentId:null,tab:null};if(v.length===1)return{agentId:null,tab:null};const T=vr(v[1]??""),w=v[2]??null;return w?w==="roleplay"?{agentId:T,tab:"roleplay"}:w==="tests"?{agentId:T,tab:"tests"}:w==="configure"?{agentId:T,tab:"configure"}:{agentId:T,tab:null}:{agentId:T,tab:"roleplay"}}function mr(M){return{tab:Yt(M.pathname).tab??"roleplay",popover:null,highlights:null,requestSeq:0}}function gr(M,N){const T=Yt(N.pathname).tab??"roleplay";return{...M,tab:T,popover:null,highlights:null}}function yr(M,N){const v=M.requestSeq+1;return{...M,requestSeq:v,popover:{kind:N.kind,status:"loading",requestId:v},highlights:null}}function _r(M,N){return!M.popover||M.popover.requestId!==N.requestId?M:{...M,popover:{...M.popover,status:"ready",data:N.data,error:void 0}}}function xr(M,N){return!M.popover||M.popover.requestId!==N.requestId?M:{...M,popover:{...M.popover,status:"error",error:String(N.error||"Unknown error"),data:N.data}}}function br(M){return{...M,popover:null,highlights:null}}function wr(M,N){return{...M,highlights:{quotes:N??[],focusQuote:null,focusNonce:0}}}function Er(M,N){const v=String(N||"");if(!v)return M;const T=M.highlights??{quotes:[],focusQuote:null,focusNonce:0};return{...M,highlights:{...T,focusQuote:v,focusNonce:(T.focusNonce??0)+1}}}function kr(M,N){const v=String(M??""),T=Or(N),w=Ut(v);for(const y of T){const E=jt(v,y);if(E.length>0)return E;const f=Dt(v,y);if(f.length>0)return f;const r=Ut(y);if(w!==v||r!==y){const g=jt(w,r);if(g.length>0)return g;const O=Dt(w,r);if(O.length>0)return O}}return[]}function jt(M,N){const v=String(N??"");if(!v)return[];const T=[];let w=0;for(;w<=M.length-v.length;){const y=M.indexOf(v,w);if(y===-1)break;T.push({start:y,end:y+v.length}),w=y+1}return T}function Dt(M,N){const v=String(N??"");if(!v.trim())return[];const T=Sr(v).replace(/\s+/g,"\\s+");let w;try{w=new RegExp(`(?=(${T}))`,"gu")}catch{return[]}const y=[];let E;for(;(E=w.exec(M))!==null;){const f=E.index,r=E[1]??"",g=f+r.length;g>f&&y.push({start:f,end:g}),w.lastIndex===f&&(w.lastIndex+=1)}return y}function Or(M){const N=String(M??""),v=N.trim(),T=new Set;for(const E of[N,v])E&&T.add(E);const w=v.replace(/^[-*•]\s+/,"");w&&w!==v&&T.add(w);const y=v.replace(/^(?:\(?\d+\)?[.)]|[a-zA-Z][.)])\s+/,"");return y&&y!==v&&T.add(y),[...T].filter(E=>E.trim().length>0)}function Ut(M){return String(M??"").replace(/\r/g,`
35
- `).replace(/[\u00A0\u2007\u202F\u2009\u200A\u200B\uFEFF]/g," ").replace(/[\u201C\u201D\u201E\u00AB\u00BB]/g,'"').replace(/[\u2018\u2019]/g,"'").replace(/[\u2013\u2014]/g,"-")}function Sr(M){return M.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Tr(M,N){const v=M.createDecorationsCollection(),T=M.createDecorationsCollection();let w=null,y=new Map,E=new Map,f=0;function r(){y=new Map,E=new Map,f=0}function g(e,n,i){return Number.isNaN(e)?n:Math.max(n,Math.min(i,e))}function O(e){const n=g(e,1,10);return`rgba(220, 38, 38, ${g(.22+n*.06,.28,.82)})`}function j(e,n){const i=String(e??"");if(!i)return[];const d=y.get(i);if(d)return d;const u=kr(n,i);return y.set(i,u),u}function U(e){const n=M.getModel();if(!n)return;const i=n.getValue()??"",d=[],u=[...e||[]].sort((h,t)=>(h.count||0)-(t.count||0));for(const h of u){const t=String(h.quote||"");if(!t)continue;const o=g(Number(h.count||0),1,10),l=O(o),s=j(t,i);for(const a of s){const p=n.getPositionAt(a.start),c=n.getPositionAt(a.end);d.push({range:new N.Range(p.lineNumber,p.column,c.lineNumber,c.column),options:{inlineClassName:`analysis-quote analysis-quote-l${o}`,overviewRuler:{color:l,position:N.editor.OverviewRulerLane.Center}}})}}v.set(d)}function F(e){const n=M.getModel();if(!n)return;const i=n.getValue()??"",d=j(e,i);if(d.length===0)return;const h=((E.get(e)??-1)+1)%d.length;E.set(e,h);const t=d[h],o=n.getPositionAt(t.start),l=n.getPositionAt(t.end),s=new N.Range(o.lineNumber,o.column,l.lineNumber,l.column);T.set([{range:s,options:{inlineClassName:"analysis-quote-focus"}}]),M.setSelection(s),M.revealRangeInCenter(s,N.editor.ScrollType.Smooth),M.focus()}function k(e){if(w=e,!w){v.clear(),T.clear(),r();return}U(w.quotes||[]),w.focusQuote&&w.focusNonce!==f?(f=w.focusNonce,F(w.focusQuote)):w.focusQuote||T.clear()}const P=M.onDidChangeModelContent(()=>{w&&(y=new Map,T.clear(),U(w.quotes||[]))});return{setHighlights:k,dispose:()=>{try{P.dispose(),v.clear(),T.clear()}finally{w=null,r()}}}}var Lr=me("<!> <!>",1),Ar=me('<span class="truncate"> </span> <!>',1),Cr=me('<div class="mt-1 overflow-hidden rounded-lg border border-rc-gray-110 bg-rc-gray-930 shadow-inner-white-soft backdrop-blur-2xl" role="listbox" aria-label="Region"></div>'),Nr=me('<span class="text-sm text-rc-gray-300">Region</span> <div><!> <!></div>',1),Pr=me('<div class="p-2 text-rc-gray-400">Connecting…</div>'),Rr=me('<div class="p-2 text-rc-gray-400">No steps</div>'),Ir=(M,N,v)=>N(I(v).name),Fr=me('<button><span class="block truncate"> </span></button>'),Br=me('<div class="rc-scroll min-h-0 flex-1 overflow-auto p-2"><!></div>'),Mr=me("<!> <!> <!>",1),Kr=me('<div class="border-b border-rc-gray-700 p-2"><!></div> <div class="min-h-0 flex-1"><!></div> <!> <!>',1),jr=me('<div class="flex h-screen"><!> <div class="flex h-full min-w-0 flex-1 flex-col bg-rc-gray-980 pb-3 pr-4 pt-2"><nav class="flex flex-none items-center bg-rc-gray-980"><div class="flex w-1/3 justify-start"></div> <div class="flex w-1/3 justify-center"><!></div> <div class="flex w-1/3 items-center justify-end gap-2 pr-2"><!></div></nav> <div class="flex-1 overflow-hidden"><div class="grid h-full w-full grid-cols-[minmax(140px,2fr)_minmax(0,10fr)_minmax(0,11fr)]"><!> <div class="flex h-full min-w-0 flex-col"><div class="flex h-14 flex-none items-center justify-between gap-3 border-b border-rc-gray-700 p-2"><div class="min-w-0"><div class="truncate font-semibold text-rc-gray-100"> </div></div> <div class="flex items-center gap-3"><label class="inline-flex items-center gap-2 text-rc-gray-300"><input type="checkbox" aria-label="Preview rendered prompt" class="h-4 w-4 appearance-none rounded border border-rc-gray-300 bg-rc-gray-600 !accent-rc-gray-600 outline-none ring-0 checked:border-rc-gray-200 checked:bg-rc-gray-600 hover:border-rc-gray-200 hover:bg-rc-gray-600 focus:outline-none focus:ring-0 active:border-rc-gray-200 active:bg-rc-gray-600 disabled:cursor-not-allowed disabled:opacity-50"/> <span>Preview</span></label> <!></div></div> <div class="min-h-0 flex-1"><!></div></div> <!></div></div></div></div> <!>',1);function di(M,N){gt(N,!0);const{onError:v}=wn();let T=De(It([]));const w=S=>{try{return S?decodeURIComponent(S):""}catch{return S||""}},y=S=>encodeURIComponent(S);function E(S){return w(S).trim().replace(/^\/+|\/+$/g,"")}const f=Be(()=>E(N.params.agent)),r=It({agentId:E(N.params.agent),region:null,availableRegions:[],defaultRegion:null,agentType:void 0,wsLoaded:!1,chatReady:!1,steps:[],currentStep:null,promptDrafts:{},context:null,promptContext:null,agentStates:[],currentState:null,contextPopoverOpen:!1,edit:mr({pathname:qe.url.pathname})});let g=null,O=null,j;const U="region-dropdown";let F=De(!1),k=De(null);He(()=>{const S=r.availableRegions,W=r.region;(!S.length||!W||!S.includes(W))&&Se(F,!1)});function P(S,W){if(typeof window>"u")return;const q=new URL(window.location.href);W===null?q.searchParams.delete(S):q.searchParams.set(S,W),_n(q.toString(),{})}function e(S){ot.sendMessage({channel:"app-events",event:S})}function n(S){S!=null&&S.name&&r.promptDrafts[S.name]===void 0&&(r.promptDrafts[S.name]=S.prompt??"")}const i=Be(()=>{var S;return((S=r.currentStep)==null?void 0:S.name)??null}),d=Be(()=>{const S=I(i);if(!S)return"";const W=r.promptDrafts[S];return typeof W=="string"?W:""});let u=null,h=null,t=Promise.resolve();const o=800;function l(){u&&(clearTimeout(u),u=null)}async function s(S,W,q){try{await ut.agents.savePrompt.mutate({agentId:S,step:W,prompt:q})}catch(ae){console.error("Failed to save prompt",ae);const be=r.promptDrafts[W];throw r.agentId===S&&be===q&&(h={stepName:W,prompt:q}),ae}}function a(S,W,q){const ae=t.catch(()=>{}).then(()=>s(S,W,q));return t=ae.catch(()=>{}),ae}async function p(){if(!h)return;const S=r.agentId.trim();if(!S)return;const{stepName:W,prompt:q}=h;l(),h=null,await a(S,W,q)}function c(S,W){h={stepName:S,prompt:W},l(),u=setTimeout(()=>{u=null,p()},o)}He(()=>{r.wsLoaded&&p()});async function b(S){try{const W=await ut.regionConfig.meta.query({agent:S});if(!W){r.availableRegions=[],r.defaultRegion=null,r.region=null,P("region",null);return}if(r.availableRegions=W.availableRegions,r.defaultRegion=W.defaultRegion??null,!Array.isArray(W.availableRegions)||W.availableRegions.length===0){r.region=null,P("region",null);return}const q=(qe.url.searchParams.get("region")||"").trim()||null,ae=q&&W.availableRegions.includes(q)&&q||W.defaultRegion&&W.availableRegions.includes(W.defaultRegion)&&W.defaultRegion||W.availableRegions[0]||null;r.region=ae,P("region",ae)}catch(W){console.error("Failed to load region config meta",W),r.availableRegions=[],r.defaultRegion=null,r.region=null,P("region",null)}}He(()=>{const S=I(f);S&&S!==O&&(O=S,b(S))});function C(S){p(),H();const W=r.steps.find(q=>q.name===S)||null;r.currentStep=W,W?(n(W),P("step",W.name),e({type:"step-selected",step:W.name})):P("step",null)}function A(S){const W=I(i);W&&(r.promptDrafts[W]=S,c(W,S))}const R=Be(()=>{var S;return((S=r.currentStep)==null?void 0:S.schema)??null}),V=Be(()=>!!I(R)&&I(R).trim().length>0);let _=De(!1);function m(){I(R)&&Se(_,!0)}function L({value:S}){if(S===r.edit.tab)return;p(),H();const W=qe.url.searchParams.get("step"),q=qe.url.searchParams.get("region"),ae=`/edit/${y(r.agentId)}/${S}`,be=new URLSearchParams;W&&be.set("step",W),q&&be.set("region",q);const we=be.size?`${ae}?${be.toString()}`:ae;vt(we)}const K=Be(()=>{const S=qe.url.pathname.split("/")[1];return S==="traces"?"view":S});function D({value:S}){if(S!==I(K)){if(p(),H(),S==="edit")return vt("/edit");if(S==="view")return vt(`/view?agent=${y(r.agentId)}`);vt("/"+S)}}function z(S){var W;return r.contextPopoverOpen=!1,r.edit=yr(r.edit,{kind:S}),((W=r.edit.popover)==null?void 0:W.requestId)??0}function le(S,W){r.edit=_r(r.edit,{requestId:S,data:W})}function X(S,W,q){r.edit=xr(r.edit,{requestId:S,error:W,data:q})}function fe(){r.edit=br(r.edit)}function Ee(){fe(),r.contextPopoverOpen=!0}function J(){r.contextPopoverOpen=!1}function Z(){r.contextPopoverOpen?J():Ee()}function H(){fe(),J()}function Y(S){return S==="analyze"?"Analyze":"Find issues"}function Q(S){r.edit=wr(r.edit,S)}function ue(S){r.edit=Er(r.edit,S)}let pe=null,de=De(!1),Te=null;He(()=>{var W;const S=((W=r.currentStep)==null?void 0:W.name)??null;S!==Te&&(Te=S,Se(de,!1))});function x(S,W){pe==null||pe.dispose(),pe=Tr(S,W),pe.setHighlights(r.edit.highlights)}He(()=>{const S=r.edit.highlights;pe==null||pe.setHighlights(S)});let B=De("");He(()=>{const S=qe.url.toString();S!==I(B)&&(Se(B,S,!0),r.edit=gr(r.edit,{pathname:qe.url.pathname}),r.contextPopoverOpen=!1)});function G(S,W,q){return Math.max(W,Math.min(q,S))}function $(S){const W=new Map;for(const q of S||[])for(const ae of q.contradictingQuotes||[]){const be=String(ae||"").trim();be&&W.set(be,(W.get(be)||0)+1)}return[...W.entries()].map(([q,ae])=>({quote:q,count:G(ae,1,10)})).sort((q,ae)=>ae.count-q.count||q.quote.localeCompare(ae.quote))}let ee=De(!1);async function ie(){var W;if(I(ee)||!r.currentStep)return;Se(ee,!0);const S=z("findIssues");try{const q=await ut.tests.findPromptIssues.mutate({agent:r.agentId,step:r.currentStep.name,prompt:I(d)}),ae=$(q.issues||[]);if(((W=r.edit.popover)==null?void 0:W.requestId)!==S)return;Q(ae);let be=null;try{be=JSON.stringify(q.raw,null,2)}catch{be=null}le(S,{title:`Prompt issues — ${r.currentStep.name}`,issues:q.issues,raw:be})}catch(q){console.error(q);const ae=typeof(q==null?void 0:q.message)=="string"?q.message:(()=>{try{return JSON.stringify(q)}catch{return String(q)}})();X(S,ae||"Failed to find issues in this prompt",{title:`Prompt issues failed — ${r.currentStep.name}`,raw:ae})}finally{Se(ee,!1)}}function ve(S){p(),H();const W=qe.url.searchParams.get("step"),q=qe.url.searchParams.get("region"),ae=`/edit/${y(S)}/${r.edit.tab}`,be=new URLSearchParams;W&&be.set("step",W),q&&be.set("region",q);const we=be.size?`${ae}?${be.toString()}`:ae;vt(we)}function ce(S){!S||S===r.region||(p(),r.region=S,P("region",S))}pn({state:r,actions:{openPopover:z,setPopoverReady:le,setPopoverError:X,closePopover:fe,setHighlightQuotes:Q,focusQuote:ue,openContextPopover:Ee,closeContextPopover:J,toggleContextPopover:Z,sendAppEvent:e,sendChatMessage:S=>{if(!r.wsLoaded||!r.chatReady){console.warn("[roleplay] Ignoring chat message while websocket session is reconnecting");return}ot.sendMessage({channel:"chat",message:S})},flushPromptSave:p,selectState:S=>{p(),H(),j=S,r.currentState=S,Ft(),Mt(),e({type:"select-agent",agent:r.agentId,state:S,region:r.region})},hangup(){e({type:"hangup",agentId:r.agentId,region:r.region})}}}),Pt(async()=>{try{Se(T,await ut.agents.list.query(),!0)}catch(S){console.error("Failed to load agents",S)}ot.onClose(()=>{r.wsLoaded=!1,r.chatReady=!1,r.context=null,r.promptContext=null,r.agentStates=[],r.currentState=null,r.contextPopoverOpen=!1,g=null}),ot.onError(S=>v(S)),ot.onMessage(S=>{if(S.channel==="app-events"){if(S.event.type==="agents-loaded"){r.wsLoaded=!0;return}if(S.event.type==="context-updated"){r.context=S.event.context,S.event.promptContext&&(r.promptContext=S.event.promptContext);return}if(S.event.type==="update-states"){const W=r.agentStates.length;r.agentStates=S.event.states;const q=r.agentStates.length>0?r.agentStates[r.agentStates.length-1].id:null;j!==void 0?r.currentState=j:(r.currentState===null&&W===0&&q||r.agentStates.length>W)&&(r.currentState=q),j=void 0;return}if(S.event.type==="agent-selected"){r.steps=S.event.agent.steps,r.agentType=S.event.agent.type;const W={};for(const Le of r.steps){const Ae=r.promptDrafts[Le.name];W[Le.name]=typeof Ae=="string"?Ae:Le.prompt??""}r.promptDrafts=W;const q=(qe.url.searchParams.get("step")||"").trim()||null,ae=q?r.steps.find(Le=>Le.name===q)??null:null,be=r.steps.find(Le=>Le.name.toLowerCase()==="main")??r.steps[0]??null,we=ae??be;r.currentStep=we,we?(n(we),we.name!==q&&P("step",we.name),e({type:"step-selected",step:we.name}),p()):P("step",null);return}return}if(S.channel==="log"){kn(S.message);return}if(S.channel==="step-trace"){hn(S.trace);return}if(S.channel==="api-call-trace"){dn(S.trace);return}if(S.channel==="conversational-trace"){vn(S.trace);return}if(S.channel==="error"){v(S.message);return}}),ot.init(),r.wsLoaded=ot.isReady()}),Vt(()=>{p(),l(),pe==null||pe.dispose(),pe=null}),He(()=>{const S=I(f);if(S!==r.agentId&&(p(),h=null,l(),r.chatReady=!1,r.promptDrafts={},r.steps=[],r.currentStep=null),r.agentId=S,!r.wsLoaded){r.chatReady=!1;return}if(!r.agentId){r.chatReady=!1;return}if(r.availableRegions.length>0&&!r.region){r.chatReady=!1;return}const W=`${r.agentId}::${r.region??""}`;g!==W&&(g=W,Ft(),Mt(),H(),r.currentState=null,r.agentStates=[],r.context=null,r.promptContext=null,p(),j=void 0,r.chatReady=!1,e({type:"select-agent",agent:r.agentId,region:r.region}),r.chatReady=!0)});var xe=jr(),Fe=Pe(xe),Me=se(Fe);bn(Me,{className:"flex-none",get agents(){return I(T)},get currentAgent(){return r.agentId},onAgentClick:ve});var Ve=ye(Me,2),ft=se(Ve),pt=ye(se(ft),2),Et=se(pt);Ct(Et,{get value(){return I(K)},ariaLabel:"Top tabs",onChange:D,children:(S,W)=>{var q=Lr(),ae=Pe(q);st(ae,{value:"edit",children:(we,Le)=>{je();var Ae=$e("Edit");oe(we,Ae)},$$slots:{default:!0}});var be=ye(ae,2);st(be,{value:"view",children:(we,Le)=>{je();var Ae=$e("View");oe(we,Ae)},$$slots:{default:!0}}),oe(S,q)},$$slots:{default:!0}}),re(pt);var _t=ye(pt,2),ht=se(_t);{var kt=S=>{var W=Nr(),q=ye(Pe(W),2),ae=se(q);wt(ae,{variant:"secondary",size:"small",get"aria-expanded"(){return I(F)},"aria-haspopup":"listbox","aria-controls":U,onclick:we=>{we.stopPropagation(),Se(F,!I(F))},class:"flex w-32 items-center justify-between gap-1 !px-3 !py-1",get el(){return I(k)},set el(we){Se(k,we,!0)},children:(we,Le)=>{var Ae=Ar(),Ye=Pe(Ae),Ge=se(Ye,!0);re(Ye);var rt=ye(Ye,2);{let Ne=Be(()=>"size-5 text-rc-gray-400 transition-transform duration-200 "+(I(F)?"rotate-180":""));gn(rt,{name:"chevron-down",get class(){return I(Ne)}})}Ke(()=>Ie(Ge,r.region)),oe(we,Ae)},$$slots:{default:!0}});var be=ye(ae,2);mn(be,{id:U,get open(){return I(F)},onClose:()=>Se(F,!1),get anchorEl(){return I(k)},placement:"bottom-end",offset:[0,1],children:Le=>{var Ae=Cr();ct(Ae,21,()=>r.availableRegions,At,(Ye,Ge)=>{{let rt=Be(()=>I(Ge)===r.region),Ne=Be(()=>`w-full rounded-none py-2 pr-3 text-left backdrop-blur-2xl hover:bg-rc-gray-700 focus:bg-rc-gray-400 ${I(Ge)===r.region?"bg-rc-gray-800 text-rc-gray-100":"text-rc-gray-200"}`);wt(Ye,{variant:"ghost",size:"small",role:"option",get"aria-selected"(){return I(rt)},onclick:Ue=>{Ue.stopPropagation(),Se(F,!1),ce(I(Ge))},get class(){return I(Ne)},children:(Ue,Je)=>{je();var Xe=$e();Ke(()=>Ie(Xe,I(Ge))),oe(Ue,Xe)},$$slots:{default:!0}})}}),re(Ae),oe(Le,Ae)},$$slots:{default:!0}}),re(q),oe(S,W)};Ce(ht,S=>{r.availableRegions.length>0&&r.region&&S(kt)})}re(_t),re(ft);var ze=ye(ft,2),et=se(ze),te=se(et);mt(te,{class:"flex h-full min-w-0 flex-col !rounded-none p-0",children:(S,W)=>{var q=Br(),ae=se(q);{var be=Le=>{var Ae=Pr();oe(Le,Ae)},we=Le=>{var Ae=tt(),Ye=Pe(Ae);{var Ge=Ne=>{var Ue=Rr();oe(Ne,Ue)},rt=Ne=>{var Ue=tt(),Je=Pe(Ue);ct(Je,17,()=>r.steps,At,(Xe,at)=>{var it=Fr();it.__click=[Ir,C,at];var xt=se(it),Ze=se(xt,!0);re(xt),re(it),Ke(()=>{var lt;un(it,1,`my-1 w-full rounded-lg px-3 py-2 text-left text-rc-gray-200 hover:bg-rc-gray-700 ${I(at).name===((lt=r.currentStep)==null?void 0:lt.name)?"bg-rc-gray-600":"bg-transparent"}`),Ie(Ze,I(at).name)}),oe(Xe,it)}),oe(Ne,Ue)};Ce(Ye,Ne=>{r.steps.length===0?Ne(Ge):Ne(rt,!1)},!0)}oe(Le,Ae)};Ce(ae,Le=>{r.wsLoaded?Le(we,!1):Le(be)})}re(q),oe(S,q)}});var ne=ye(te,2),ge=se(ne),he=se(ge),_e=se(he),ke=se(_e,!0);re(_e),re(he);var Re=ye(he,2),We=se(Re),Qe=se(We);Wt(Qe),je(2),re(We);var Ot=ye(We,2);{let S=Be(()=>!r.currentStep||I(ee));wt(Ot,{variant:"secondary",get disabled(){return I(S)},onclick:ie,children:(W,q)=>{je();var ae=$e("Find issues");oe(W,ae)},$$slots:{default:!0}})}re(Re),re(ge);var nt=ye(ge,2),St=se(nt);{var Tt=S=>{var W=tt(),q=Pe(W);an(q,()=>r.currentStep.name,ae=>{$n(ae,{class:"h-full min-w-0 border-thin border-rc-gray-650 bg-rc-gray-800 shadow-inner-white-soft backdrop-blur-3xl focus:outline-none focus:ring-0",get initialPrompt(){return I(d)},get agentId(){return r.agentId},onPromptChanged:A,get showSchemaButton(){return I(V)},onSchemaClick:m,showPreviewToggle:!1,get preview(){return I(de)},onEditorReady:x})}),oe(S,W)},dt=S=>{mt(S,{class:"flex h-full min-w-0 items-center justify-center !rounded-none p-4 text-sm text-rc-gray-400",children:(W,q)=>{je();var ae=$e("Select a step to edit its prompt");oe(W,ae)}})};Ce(St,S=>{r.currentStep?S(Tt):S(dt,!1)})}re(nt),re(ne);var Jt=ye(ne,2);mt(Jt,{class:"relative flex h-full min-w-0 flex-col overflow-hidden !rounded-none p-0",children:(S,W)=>{var q=Kr(),ae=Pe(q),be=se(ae);Ct(be,{get value(){return r.edit.tab},ariaLabel:"Mode tabs",onChange:L,children:(Ne,Ue)=>{var Je=Mr(),Xe=Pe(Je);st(Xe,{value:"roleplay",children:(Ze,lt)=>{je();var bt=$e("Roleplay");oe(Ze,bt)},$$slots:{default:!0}});var at=ye(Xe,2);st(at,{value:"tests",children:(Ze,lt)=>{je();var bt=$e("Tests");oe(Ze,bt)},$$slots:{default:!0}});var it=ye(at,2);{var xt=Ze=>{st(Ze,{value:"configure",children:(lt,bt)=>{je();var en=$e("Configure");oe(lt,en)},$$slots:{default:!0}})};Ce(it,Ze=>{r.defaultRegion!==null&&Ze(xt)})}oe(Ne,Je)},$$slots:{default:!0}}),re(ae);var we=ye(ae,2),Le=se(we);rn(Le,()=>N.children),re(we);var Ae=ye(we,2);{var Ye=Ne=>{{const Ue=Xe=>{pr(Xe,{})};let Je=Be(()=>Y(r.edit.popover.kind));Bt(Ne,{get title(){return I(Je)},onClose:fe,children:Ue})}};Ce(Ae,Ne=>{r.edit.popover&&Ne(Ye)})}var Ge=ye(Ae,2);{var rt=Ne=>{Bt(Ne,{title:"Edit context",onClose:J,children:Je=>{dr(Je,{})}})};Ce(Ge,Ne=>{r.contextPopoverOpen&&Ne(rt)})}oe(S,q)}}),re(et),re(ze),re(Ve),re(Fe);var Xt=ye(Fe,2);{var Zt=S=>{ln(S,{title:"Schema",class:"!w-[80vw] !max-w-5xl",get open(){return I(_)},set open(q){Se(_,q,!0)},children:q=>{Nn(q,{class:"h-[70vh] min-w-0",get schema(){return I(R)},onChange:console.log})},$$slots:{default:!0}})};Ce(Xt,S=>{I(R)&&S(Zt)})}Ke(()=>{var S;Ie(ke,((S=r.currentStep)==null?void 0:S.name)??"Prompt"),Qe.disabled=!r.currentStep}),fn(Qe,()=>I(de),S=>Se(de,S)),oe(M,xe),yt()}Rt(["click"]);export{di as component};
@@ -1 +0,0 @@
1
- {"version":3,"file":"ContextEditor-DwSmZH0Y.js","sources":["../../../.svelte-kit/adapter-node/chunks/ContextEditor.js"],"sourcesContent":["import { s as stringify } from \"./index2.js\";\nimport \"js-yaml\";\nimport { P as Panel } from \"./edit-workspace-context.js\";\nimport { o as onDestroy } from \"./index-server.js\";\nfunction ContextEditor($$renderer, $$props) {\n $$renderer.component(($$renderer2) => {\n let editor = null;\n let model = null;\n let editorDisposables = [];\n let {\n context,\n onContextChanged,\n class: className,\n suppressErrors = false,\n defaultFormat = \"yaml\",\n hideHeader = false\n } = $$props;\n onDestroy(() => {\n for (const d of editorDisposables) {\n try {\n d.dispose();\n } catch {\n }\n }\n editorDisposables = [];\n const toDisposeModel = model;\n model = null;\n try {\n if (editor) {\n try {\n editor.setModel(null);\n } catch {\n }\n editor.dispose();\n }\n } finally {\n editor = null;\n }\n try {\n toDisposeModel?.dispose();\n } catch {\n }\n });\n Panel($$renderer2, {\n class: `min-h-0 overflow-hidden ${stringify(\n // Keep model language in sync without recreating the editor\n // Update value only when actual text differs to avoid caret jumps\n // If the next canonical text equals the last user-emitted serialization,\n // skip setting the value to preserve caret/selection.\n className\n )}`,\n children: ($$renderer3) => {\n $$renderer3.push(`<div class=\"h-full min-h-0 w-full\"></div>`);\n },\n $$slots: { default: true }\n });\n });\n}\nexport {\n ContextEditor as C\n};\n"],"names":[],"mappings":";;;;;AAIA,SAAS,aAAa,CAAC,UAAU,EAAE,OAAO,EAAE;AAC5C,EAAE,UAAU,CAAC,SAAS,CAAC,CAAC,WAAW,KAAK;AACxC,IAAI,IAAI,MAAM,GAAG,IAAI;AACrB,IAAI,IAAI,KAAK,GAAG,IAAI;AACpB,IAAI,IAAI,iBAAiB,GAAG,EAAE;AAC9B,IAAI,IAAI;AACR,MAAM,OAAO;AACb,MAAM,gBAAgB;AACtB,MAAM,KAAK,EAAE,SAAS;AACtB,MAAM,cAAc,GAAG,KAAK;AAC5B,MAAM,aAAa,GAAG,MAAM;AAC5B,MAAM,UAAU,GAAG;AACnB,KAAK,GAAG,OAAO;AACf,IAAI,SAAS,CAAC,MAAM;AACpB,MAAM,KAAK,MAAM,CAAC,IAAI,iBAAiB,EAAE;AACzC,QAAQ,IAAI;AACZ,UAAU,CAAC,CAAC,OAAO,EAAE;AACrB,QAAQ,CAAC,CAAC,MAAM;AAChB,QAAQ;AACR,MAAM;AACN,MAAM,iBAAiB,GAAG,EAAE;AAC5B,MAAM,MAAM,cAAc,GAAG,KAAK;AAClC,MAAM,KAAK,GAAG,IAAI;AAClB,MAAM,IAAI;AACV,QAAQ,IAAI,MAAM,EAAE;AACpB,UAAU,IAAI;AACd,YAAY,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;AACjC,UAAU,CAAC,CAAC,MAAM;AAClB,UAAU;AACV,UAAU,MAAM,CAAC,OAAO,EAAE;AAC1B,QAAQ;AACR,MAAM,CAAC,SAAS;AAChB,QAAQ,MAAM,GAAG,IAAI;AACrB,MAAM;AACN,MAAM,IAAI;AACV,QAAQ,cAAc,EAAE,OAAO,EAAE;AACjC,MAAM,CAAC,CAAC,MAAM;AACd,MAAM;AACN,IAAI,CAAC,CAAC;AACN,IAAI,KAAK,CAAC,WAAW,EAAE;AACvB,MAAM,KAAK,EAAE,CAAC,wBAAwB,EAAE,SAAS;AACjD;AACA;AACA;AACA;AACA,QAAQ;AACR,OAAO,CAAC,CAAC;AACT,MAAM,QAAQ,EAAE,CAAC,WAAW,KAAK;AACjC,QAAQ,WAAW,CAAC,IAAI,CAAC,CAAC,yCAAyC,CAAC,CAAC;AACrE,MAAM,CAEF,CAAC,CAAC;AACN,EAAE,CAAC,CAAC;AACJ;;;;"}