@tung-engineering/agent-platform-web-sdk 0.0.56 → 0.0.58

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.
package/dist/web-sdk.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var Su=Object.defineProperty;var Tu=(e,t,n)=>t in e?Su(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var re=(e,t,n)=>Tu(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Eu=`
1
+ "use strict";var vu=Object.defineProperty;var yu=(e,t,n)=>t in e?vu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ie=(e,t,n)=>yu(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const wu=`
2
2
  /* ── Agent Platform SDK — namespaced styles ────────────────────────────── */
3
3
 
4
4
  /* Reset Popover API UA defaults so top-layer-promoted elements keep our own
@@ -96,6 +96,17 @@
96
96
  background: oklch(95% 0.035 50);
97
97
  }
98
98
 
99
+ .ap-sdk-picker-cursor__btn--cancel {
100
+ background: transparent;
101
+ border-color: rgba(255, 255, 255, 0.28);
102
+ opacity: 0.85;
103
+ }
104
+
105
+ .ap-sdk-picker-cursor__btn--cancel:hover {
106
+ background: rgba(255, 255, 255, 0.12);
107
+ opacity: 1;
108
+ }
109
+
99
110
  /* Floating bar shown while recorder.ts is capturing a workflow */
100
111
  .ap-sdk-recorder-bar {
101
112
  position: fixed;
@@ -259,10 +270,16 @@
259
270
  color: oklch(47% 0.13 40);
260
271
  }
261
272
 
262
- .ap-sdk-panel__btn--select-parent {
273
+ .ap-sdk-panel__pick-actions {
274
+ display: flex;
275
+ gap: 8px;
263
276
  margin: 0 16px 10px;
264
- flex: 0 0 auto;
265
- width: calc(100% - 32px);
277
+ }
278
+
279
+ .ap-sdk-panel__btn--select-parent,
280
+ .ap-sdk-panel__btn--reselect {
281
+ flex: 1 1 0;
282
+ width: auto;
266
283
  font-size: 12px;
267
284
  padding: 6px 10px;
268
285
  }
@@ -1325,119 +1342,119 @@ button.ap-sdk-list-item__link {
1325
1342
  border-right: 2px solid #d1d5db;
1326
1343
  border-bottom: 2px solid #d1d5db;
1327
1344
  }
1328
- `;let Es=!1;function jr(){if(Es)return;const e=document.createElement("style");e.setAttribute("data-ap-sdk","1"),e.textContent=Eu,document.head.appendChild(e),Es=!0}function ko(e){if(e===document.body)return"body";const t=[];let n=e;for(;n&&n!==document.body;){if(n.id){t.unshift(`#${CSS.escape(n.id)}`);break}let r=n.tagName.toLowerCase();const o=n.parentElement;if(o){const s=Array.from(o.children).filter(c=>c.tagName===n.tagName);if(s.length>1){const c=s.indexOf(n)+1;r+=`:nth-of-type(${c})`}}t.unshift(r),n=n.parentElement}return t.join(" > ")||e.tagName.toLowerCase()}function Lo(e,t=200){const n=(e.textContent??"").replace(/\s+/g," ").trim();return n.length>t?n.slice(0,t)+"…":n}const Au=["role","type","name","href","src","alt","title","for","placeholder","data-testid"];function _o(e){const t=e.tagName.toLowerCase(),n=e.id?`#${e.id}`:"",r=e.classList.length?"."+Array.from(e.classList).join("."):"",o=[],s=new Set,c=u=>{if(s.has(u)||o.length>=8)return;const d=e.getAttribute(u);if(!d)return;s.add(u);const p=d.length>80?d.slice(0,80)+"…":d;o.push(`[${u}="${p}"]`)};for(const u of Array.from(e.attributes))u.name.startsWith("aria-")&&c(u.name);for(const u of Au)c(u);return`${t}${n}${r}${o.join("")}`}function Cu(e,t=80){const n=Array.from(e.childNodes).filter(r=>r.nodeType===Node.TEXT_NODE).map(r=>(r.textContent??"").trim()).filter(Boolean).join(" ");return n.length>t?n.slice(0,t)+"…":n}function Pu(e,t=5,n=10){function r(o,s){const c=_o(o),u=" ".repeat(s),d=Array.from(o.children).slice(0,n);if(s>=t||d.length===0){const p=Cu(o);return p?`${u}${c} "${p}"`:`${u}${c}`}return[`${u}${c}`,...d.map(p=>r(p,s+1))].join(`
1329
- `)}return r(e,0)}const Ru='section, article, aside, nav, main, header, footer, form, fieldset, dialog, [role="region"], [role="navigation"], [role="main"], [role="complementary"], [role="banner"], [role="contentinfo"], [role="form"], [role="search"], [role="dialog"]',Lu={fieldset:"legend",table:"caption",figure:"figcaption",details:"summary"};function io(e,t){const n=e.replace(/\s+/g," ").trim();return n.length>t?n.slice(0,t)+"…":n}function zu(e){const t=e.querySelectorAll('h1, h2, h3, h4, h5, h6, [role="heading"]');for(const n of Array.from(t)){let r=n.parentElement;for(;r&&r!==e&&!r.matches(Ru);)r=r.parentElement;if(r===e){const o=(n.textContent??"").trim();if(o)return o}}return""}function Iu(e,t=80){var c,u,d;const n=Lu[e.tagName.toLowerCase()];if(n){const p=(u=(c=e.querySelector(n))==null?void 0:c.textContent)==null?void 0:u.trim();if(p)return io(p,t)}const r=zu(e);if(r)return io(r,t);const o=(d=e.getAttribute("aria-label"))==null?void 0:d.trim();if(o)return io(o,t);const s=e.getAttribute("aria-labelledby");if(s){const p=s.split(/\s+/).map(h=>{var b,m;return((m=(b=document.getElementById(h))==null?void 0:b.textContent)==null?void 0:m.trim())??""}).filter(Boolean).join(" ");if(p)return io(p,t)}return""}function $u(e,t=6){const n=[],r=new Set;let o=e;for(;o&&o!==document.body&&n.length<t;){const s=o===e?"":Iu(o),c=s&&!r.has(s)?`${_o(o)} ["${s}"]`:_o(o);s&&r.add(s),n.unshift(c),o=o.parentElement}return n.join(" > ")||_o(e)}function Pa(e,t){return e.length>t?e.slice(0,t)+"… (truncated)":e}function kr(e){var r;const t=document.querySelector(e);return((r=t==null?void 0:t.content)==null?void 0:r.trim())||void 0}function Ra(){const e=t=>{try{return t()}catch{return}};return{description:e(()=>kr('meta[name="description"]')),canonicalUrl:e(()=>{var t;return((t=document.querySelector('link[rel="canonical"]'))==null?void 0:t.href)||void 0}),lang:e(()=>document.documentElement.lang||void 0),ogTitle:e(()=>kr('meta[property="og:title"]')),ogDescription:e(()=>kr('meta[property="og:description"]')),ogType:e(()=>kr('meta[property="og:type"]')),ogSiteName:e(()=>kr('meta[property="og:site_name"]')),viewportWidth:e(()=>window.innerWidth),viewportHeight:e(()=>window.innerHeight),scrollX:e(()=>Math.round(window.scrollX)),scrollY:e(()=>Math.round(window.scrollY)),selectionText:e(()=>{var n;const t=(n=window.getSelection())==null?void 0:n.toString().trim();return t?Pa(t,1e3):void 0}),capturedAt:new Date().toISOString()}}function Nu(e){const t=[];let n=e;for(;n&&t.length<6;){let r=n.tagName.toLowerCase();n.id?r+=`#${n.id}`:n.classList.length&&(r+=`.${Array.from(n.classList).slice(0,2).join(".")}`),t.unshift(r),n=n.parentElement}return t.join(" > ")}function Ou(e){const t=e.getAttribute("role")||void 0,n=e.getAttribute("aria-label")||void 0;let r;const o=e.closest("section, article, main, nav, aside, header, footer, [role]");if(o){const s=o.querySelector("h1, h2, h3, h4, h5, h6"),c=o.getAttribute("aria-label")||((s==null?void 0:s.textContent)||"").trim(),u=o.tagName.toLowerCase();r=c?`${u}: ${Pa(c,120)}`:u}return{elementRole:t,elementAriaLabel:n,enclosingSection:r}}function Du(e,t){const n=[e.trim(),"",`Page: ${t.pageTitle} (${t.pageUrl})`];return t.description&&n.push(`Description: ${t.description}`),t.selectionText&&n.push(`Selection: ${t.selectionText}`),t.elementText&&n.push(`Selected element: ${t.elementText}`),t.elementRole&&n.push(` Role: ${t.elementRole}`),t.elementAriaLabel&&n.push(` ARIA label: ${t.elementAriaLabel}`),t.enclosingSection&&n.push(`Section: ${t.enclosingSection}`),t.ancestry&&n.push(`Ancestry: ${t.ancestry}`),t.cssSelector&&n.push(`Selector: ${t.cssSelector}`),n.join(`
1330
- `)}const Vn=new Set;let Fn=null,zo=!1,yi=!1;function Mu(e){if(e.getAttribute("aria-modal")==="false")return!1;const t=getComputedStyle(e);return t.display!=="none"&&t.visibility!=="hidden"}function Uu(){const e=document.querySelectorAll("dialog[open]");for(let n=0;n<e.length;n++)try{if(e[n].matches(":modal"))return!0}catch{}const t=document.querySelectorAll('[role="dialog"], [role="alertdialog"]');for(let n=0;n<t.length;n++){const r=t[n];if(!(Vn.has(r)||r.hasAttribute("data-ap-sdk"))&&r.isConnected&&Mu(r))return!0}return!1}function La(){const e=Uu(),t=e&&!yi;yi=e;for(const n of Vn){n.hasAttribute("inert")&&n.removeAttribute("inert"),n.getAttribute("aria-hidden")==="true"&&n.removeAttribute("aria-hidden");const r=n.contains(document.activeElement);if(n.matches(":popover-open")){if(t&&!r){try{n.hidePopover()}catch{}try{n.showPopover()}catch{}}}else try{n.showPopover()}catch{}}}function As(e){if(!(e instanceof Node))return!1;for(const t of Vn)if(t===e||t.contains(e))return!0;return!1}function Bn(e){(As(e.target)||"relatedTarget"in e&&As(e.relatedTarget))&&e.stopPropagation()}function ju(){zo||(window.addEventListener("focusin",Bn,!0),window.addEventListener("focusout",Bn,!0),window.addEventListener("pointerdown",Bn,!0),zo=!0),!Fn&&(Fn=new MutationObserver(e=>{e.some(n=>n.type==="childList"||n.attributeName==="open"&&n.target.tagName==="DIALOG"||n.attributeName==="inert"||n.attributeName==="aria-hidden"||n.attributeName==="role")&&La()}),Fn.observe(document.documentElement,{attributes:!0,attributeFilter:["open","inert","aria-hidden","role"],childList:!0,subtree:!0}))}function Ut(e){"showPopover"in e&&(e.setAttribute("popover","manual"),Vn.add(e),ju(),La())}function jt(e){if(Vn.delete(e),Vn.size===0&&(Fn&&(Fn.disconnect(),Fn=null),zo&&(window.removeEventListener("focusin",Bn,!0),window.removeEventListener("focusout",Bn,!0),window.removeEventListener("pointerdown",Bn,!0),zo=!1),yi=!1),"hidePopover"in e)try{e.hidePopover()}catch{}}function $i(e="ap-sdk-highlight"){const t=document.createElement("div");return t.className=e,t.setAttribute("data-ap-sdk","1"),t.style.display="none",document.body.appendChild(t),Ut(t),{el:t,update:s=>{const c=s.getBoundingClientRect();t.style.top=`${c.top}px`,t.style.left=`${c.left}px`,t.style.width=`${c.width}px`,t.style.height=`${c.height}px`,t.style.display="block"},hide:()=>{t.style.display="none"},destroy:()=>{jt(t),t.remove()}}}const Zu="🎯 Click any element to capture";let Kt=null,Le=null,Ye=null;function Lr(e){return e instanceof Element?e.closest("[data-ap-sdk]")!==null||e.closest(".ap-sdk-panel")!==null||e.closest(".ap-sdk-highlight")!==null||e.closest(".ap-sdk-picker-cursor")!==null:!1}function qu(){var e;return(((e=window.matchMedia)==null?void 0:e.call(window,"(pointer: coarse)").matches)??!1)||"ontouchstart"in window}function Cs(e){Kt==null||Kt.update(e)}function za(e){const t=Ra(),n=Nu(e),r=Ou(e);let o;try{o=e.outerHTML.slice(0,4e3)}catch{}return{pageUrl:window.location.href,pageTitle:document.title,elementText:Lo(e),cssSelector:ko(e),innerTree:Pu(e),outerTree:$u(e),elementOuterHtml:o,ancestry:n,...r,...t}}function Ps(e,t){Ye&&Ye();const n=qu();Kt=$i(),Le=document.createElement("div"),Le.className="ap-sdk-picker-cursor",Le.setAttribute("data-ap-sdk","1"),Le.textContent=n?"Tap any element to preview":Zu,document.body.appendChild(Le),Ut(Le);let r=null,o=null;const s=h=>{Ye==null||Ye(),e(za(h),h)},c=h=>{if(o=h,Cs(h),!Le)return;Le.classList.add("ap-sdk-picker-cursor--confirm"),Le.innerHTML="";const b=document.createElement("span");b.className="ap-sdk-picker-cursor__label",b.textContent=`<${h.tagName.toLowerCase()}>`;const m=document.createElement("button");m.type="button",m.className="ap-sdk-picker-cursor__btn",m.textContent="⬆ Parent",m.setAttribute("data-ap-sdk","1"),m.addEventListener("click",w=>{w.preventDefault(),w.stopPropagation(),o!=null&&o.parentElement&&c(o.parentElement)});const _=document.createElement("button");_.type="button",_.className="ap-sdk-picker-cursor__btn ap-sdk-picker-cursor__btn--primary",_.textContent="✓ Select",_.setAttribute("data-ap-sdk","1"),_.addEventListener("click",w=>{w.preventDefault(),w.stopPropagation(),o&&s(o)}),Le.appendChild(b),Le.appendChild(m),Le.appendChild(_)},u=h=>{Lr(h.target)||(r=h.target,Cs(r))},d=h=>{if(Lr(h.target))return;h.preventDefault(),h.stopImmediatePropagation();const b=h.target??r;if(b){if(n){c(b);return}s(b)}},p=h=>{h.key==="Escape"&&(Ye==null||Ye(),t())};n||document.addEventListener("mouseover",u,{capture:!0}),document.addEventListener("click",d,{capture:!0}),document.addEventListener("keydown",p,{capture:!0}),Ye=()=>{n||document.removeEventListener("mouseover",u,{capture:!0}),document.removeEventListener("click",d,{capture:!0}),document.removeEventListener("keydown",p,{capture:!0}),Le&&jt(Le),Le==null||Le.remove(),Kt==null||Kt.destroy(),Kt=null,Le=null,o=null,Ye=null}}function Ni(){Ye==null||Ye()}function Gn(){return Ye!==null}function v(e,t,n){function r(u,d){if(u._zod||Object.defineProperty(u,"_zod",{value:{def:d,constr:c,traits:new Set},enumerable:!1}),u._zod.traits.has(e))return;u._zod.traits.add(e),t(u,d);const p=c.prototype,h=Object.keys(p);for(let b=0;b<h.length;b++){const m=h[b];m in u||(u[m]=p[m].bind(u))}}const o=(n==null?void 0:n.Parent)??Object;class s extends o{}Object.defineProperty(s,"name",{value:e});function c(u){var d;const p=n!=null&&n.Parent?new s:this;r(p,u),(d=p._zod).deferred??(d.deferred=[]);for(const h of p._zod.deferred)h();return p}return Object.defineProperty(c,"init",{value:r}),Object.defineProperty(c,Symbol.hasInstance,{value:u=>{var d,p;return n!=null&&n.Parent&&u instanceof n.Parent?!0:(p=(d=u==null?void 0:u._zod)==null?void 0:d.traits)==null?void 0:p.has(e)}}),Object.defineProperty(c,"name",{value:e}),c}class Wn extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Ia extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const $a={};function en(e){return $a}function Na(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,o])=>t.indexOf(+r)===-1).map(([r,o])=>o)}function wi(e,t){return typeof t=="bigint"?t.toString():t}function Jo(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Oi(e){return e==null}function Di(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Hu(e,t){const n=(e.toString().split(".")[1]||"").length,r=t.toString();let o=(r.split(".")[1]||"").length;if(o===0&&/\d?e-\d?/.test(r)){const d=r.match(/\d?e-(\d?)/);d!=null&&d[1]&&(o=Number.parseInt(d[1]))}const s=n>o?n:o,c=Number.parseInt(e.toFixed(s).replace(".","")),u=Number.parseInt(t.toFixed(s).replace(".",""));return c%u/10**s}const Rs=Symbol("evaluating");function Q(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Rs)return r===void 0&&(r=Rs,r=n()),r},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function Tn(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function nn(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function Ls(e){return JSON.stringify(e)}function Fu(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Oa="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Dr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Bu=Jo(()=>{var e;if(typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)!=null&&e.includes("Cloudflare")))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function Yn(e){if(Dr(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(Dr(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Da(e){return Yn(e)?{...e}:Array.isArray(e)?[...e]:e}const Gu=new Set(["string","number","symbol"]);function Kn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function rn(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n!=null&&n.parent)&&(r._zod.parent=e),r}function D(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if((t==null?void 0:t.message)!==void 0){if((t==null?void 0:t.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Wu(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const Ju={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Xu(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const s=nn(e._zod.def,{get shape(){const c={};for(const u in t){if(!(u in n.shape))throw new Error(`Unrecognized key: "${u}"`);t[u]&&(c[u]=n.shape[u])}return Tn(this,"shape",c),c},checks:[]});return rn(e,s)}function Vu(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const s=nn(e._zod.def,{get shape(){const c={...e._zod.def.shape};for(const u in t){if(!(u in n.shape))throw new Error(`Unrecognized key: "${u}"`);t[u]&&delete c[u]}return Tn(this,"shape",c),c},checks:[]});return rn(e,s)}function Yu(e,t){if(!Yn(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const s=e._zod.def.shape;for(const c in t)if(Object.getOwnPropertyDescriptor(s,c)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const o=nn(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t};return Tn(this,"shape",s),s}});return rn(e,o)}function Ku(e,t){if(!Yn(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=nn(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return Tn(this,"shape",r),r}});return rn(e,n)}function Qu(e,t){const n=nn(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return Tn(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return rn(e,n)}function ed(e,t,n){const o=t._zod.def.checks;if(o&&o.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const c=nn(t._zod.def,{get shape(){const u=t._zod.def.shape,d={...u};if(n)for(const p in n){if(!(p in u))throw new Error(`Unrecognized key: "${p}"`);n[p]&&(d[p]=e?new e({type:"optional",innerType:u[p]}):u[p])}else for(const p in u)d[p]=e?new e({type:"optional",innerType:u[p]}):u[p];return Tn(this,"shape",d),d},checks:[]});return rn(t,c)}function td(e,t,n){const r=nn(t._zod.def,{get shape(){const o=t._zod.def.shape,s={...o};if(n)for(const c in n){if(!(c in s))throw new Error(`Unrecognized key: "${c}"`);n[c]&&(s[c]=new e({type:"nonoptional",innerType:o[c]}))}else for(const c in o)s[c]=new e({type:"nonoptional",innerType:o[c]});return Tn(this,"shape",s),s}});return rn(t,r)}function jn(e,t=0){var n;if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(((n=e.issues[r])==null?void 0:n.continue)!==!0)return!0;return!1}function Zn(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function so(e){return typeof e=="string"?e:e==null?void 0:e.message}function tn(e,t,n){var o,s,c,u,d,p;const r={...e,path:e.path??[]};if(!e.message){const h=so((c=(s=(o=e.inst)==null?void 0:o._zod.def)==null?void 0:s.error)==null?void 0:c.call(s,e))??so((u=t==null?void 0:t.error)==null?void 0:u.call(t,e))??so((d=n.customError)==null?void 0:d.call(n,e))??so((p=n.localeError)==null?void 0:p.call(n,e))??"Invalid input";r.message=h}return delete r.inst,delete r.continue,t!=null&&t.reportInput||delete r.input,r}function Mi(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Mr(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const Ma=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,wi,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Ua=v("$ZodError",Ma),ja=v("$ZodError",Ma,{Parent:Error});function nd(e,t=n=>n.message){const n={},r=[];for(const o of e.issues)o.path.length>0?(n[o.path[0]]=n[o.path[0]]||[],n[o.path[0]].push(t(o))):r.push(t(o));return{formErrors:r,fieldErrors:n}}function rd(e,t=n=>n.message){const n={_errors:[]},r=o=>{for(const s of o.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(c=>r({issues:c}));else if(s.code==="invalid_key")r({issues:s.issues});else if(s.code==="invalid_element")r({issues:s.issues});else if(s.path.length===0)n._errors.push(t(s));else{let c=n,u=0;for(;u<s.path.length;){const d=s.path[u];u===s.path.length-1?(c[d]=c[d]||{_errors:[]},c[d]._errors.push(t(s))):c[d]=c[d]||{_errors:[]},c=c[d],u++}}};return r(e),n}const Ui=e=>(t,n,r,o)=>{const s=r?Object.assign(r,{async:!1}):{async:!1},c=t._zod.run({value:n,issues:[]},s);if(c instanceof Promise)throw new Wn;if(c.issues.length){const u=new((o==null?void 0:o.Err)??e)(c.issues.map(d=>tn(d,s,en())));throw Oa(u,o==null?void 0:o.callee),u}return c.value},ji=e=>async(t,n,r,o)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let c=t._zod.run({value:n,issues:[]},s);if(c instanceof Promise&&(c=await c),c.issues.length){const u=new((o==null?void 0:o.Err)??e)(c.issues.map(d=>tn(d,s,en())));throw Oa(u,o==null?void 0:o.callee),u}return c.value},Xo=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},o);if(s instanceof Promise)throw new Wn;return s.issues.length?{success:!1,error:new(e??Ua)(s.issues.map(c=>tn(c,o,en())))}:{success:!0,data:s.value}},od=Xo(ja),Vo=e=>async(t,n,r)=>{const o=r?Object.assign(r,{async:!0}):{async:!0};let s=t._zod.run({value:n,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(c=>tn(c,o,en())))}:{success:!0,data:s.value}},id=Vo(ja),sd=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Ui(e)(t,n,o)},ad=e=>(t,n,r)=>Ui(e)(t,n,r),cd=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return ji(e)(t,n,o)},ld=e=>async(t,n,r)=>ji(e)(t,n,r),ud=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Xo(e)(t,n,o)},dd=e=>(t,n,r)=>Xo(e)(t,n,r),pd=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Vo(e)(t,n,o)},hd=e=>async(t,n,r)=>Vo(e)(t,n,r),fd=/^[cC][^\s-]{8,}$/,gd=/^[0-9a-z]+$/,md=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,bd=/^[0-9a-vA-V]{20}$/,kd=/^[A-Za-z0-9]{27}$/,_d=/^[a-zA-Z0-9_-]{21}$/,vd=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,yd=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,zs=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,wd=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,xd="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Sd(){return new RegExp(xd,"u")}const Td=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Ed=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Ad=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Cd=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Pd=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Za=/^[A-Za-z0-9_-]*$/,Rd=/^\+[1-9]\d{6,14}$/,qa="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",Ld=new RegExp(`^${qa}$`);function Ha(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function zd(e){return new RegExp(`^${Ha(e)}$`)}function Id(e){const t=Ha({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${qa}T(?:${r})$`)}const $d=e=>{const t=e?`[\\s\\S]{${(e==null?void 0:e.minimum)??0},${(e==null?void 0:e.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Nd=/^-?\d+$/,Fa=/^-?\d+(?:\.\d+)?$/,Od=/^(?:true|false)$/i,Dd=/^[^A-Z]*$/,Md=/^[^a-z]*$/,et=v("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Ba={number:"number",bigint:"bigint",object:"date"},Ga=v("$ZodCheckLessThan",(e,t)=>{et.init(e,t);const n=Ba[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,s=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<s&&(t.inclusive?o.maximum=t.value:o.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Wa=v("$ZodCheckGreaterThan",(e,t)=>{et.init(e,t);const n=Ba[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,s=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>s&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Ud=v("$ZodCheckMultipleOf",(e,t)=>{et.init(e,t),e._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):Hu(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),jd=v("$ZodCheckNumberFormat",(e,t)=>{var c;et.init(e,t),t.format=t.format||"float64";const n=(c=t.format)==null?void 0:c.includes("int"),r=n?"int":"number",[o,s]=Ju[t.format];e._zod.onattach.push(u=>{const d=u._zod.bag;d.format=t.format,d.minimum=o,d.maximum=s,n&&(d.pattern=Nd)}),e._zod.check=u=>{const d=u.value;if(n){if(!Number.isInteger(d)){u.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:d,inst:e});return}if(!Number.isSafeInteger(d)){d>0?u.issues.push({input:d,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}):u.issues.push({input:d,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}d<o&&u.issues.push({origin:"number",input:d,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),d>s&&u.issues.push({origin:"number",input:d,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}}),Zd=v("$ZodCheckMaxLength",(e,t)=>{var n;et.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!Oi(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const o=r.value;if(o.length<=t.maximum)return;const c=Mi(o);r.issues.push({origin:c,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),qd=v("$ZodCheckMinLength",(e,t)=>{var n;et.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!Oi(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const o=r.value;if(o.length>=t.minimum)return;const c=Mi(o);r.issues.push({origin:c,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Hd=v("$ZodCheckLengthEquals",(e,t)=>{var n;et.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!Oi(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=r=>{const o=r.value,s=o.length;if(s===t.length)return;const c=Mi(o),u=s>t.length;r.issues.push({origin:c,...u?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),Yo=v("$ZodCheckStringFormat",(e,t)=>{var n,r;et.init(e,t),e._zod.onattach.push(o=>{const s=o._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Fd=v("$ZodCheckRegex",(e,t)=>{Yo.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Bd=v("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Dd),Yo.init(e,t)}),Gd=v("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Md),Yo.init(e,t)}),Wd=v("$ZodCheckIncludes",(e,t)=>{et.init(e,t);const n=Kn(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(o=>{const s=o._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),Jd=v("$ZodCheckStartsWith",(e,t)=>{et.init(e,t);const n=new RegExp(`^${Kn(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),Xd=v("$ZodCheckEndsWith",(e,t)=>{et.init(e,t);const n=new RegExp(`.*${Kn(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),Vd=v("$ZodCheckOverwrite",(e,t)=>{et.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class Yd{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
1331
- `).filter(c=>c),o=Math.min(...r.map(c=>c.length-c.trimStart().length)),s=r.map(c=>c.slice(o)).map(c=>" ".repeat(this.indent*2)+c);for(const c of s)this.content.push(c)}compile(){const t=Function,n=this==null?void 0:this.args,o=[...((this==null?void 0:this.content)??[""]).map(s=>` ${s}`)];return new t(...n,o.join(`
1332
- `))}}const Kd={major:4,minor:3,patch:5},he=v("$ZodType",(e,t)=>{var o;var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Kd;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const s of r)for(const c of s._zod.onattach)c(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),(o=e._zod.deferred)==null||o.push(()=>{e._zod.run=e._zod.parse});else{const s=(u,d,p)=>{let h=jn(u),b;for(const m of d){if(m._zod.def.when){if(!m._zod.def.when(u))continue}else if(h)continue;const _=u.issues.length,w=m._zod.check(u);if(w instanceof Promise&&(p==null?void 0:p.async)===!1)throw new Wn;if(b||w instanceof Promise)b=(b??Promise.resolve()).then(async()=>{await w,u.issues.length!==_&&(h||(h=jn(u,_)))});else{if(u.issues.length===_)continue;h||(h=jn(u,_))}}return b?b.then(()=>u):u},c=(u,d,p)=>{if(jn(u))return u.aborted=!0,u;const h=s(d,r,p);if(h instanceof Promise){if(p.async===!1)throw new Wn;return h.then(b=>e._zod.parse(b,p))}return e._zod.parse(h,p)};e._zod.run=(u,d)=>{if(d.skipChecks)return e._zod.parse(u,d);if(d.direction==="backward"){const h=e._zod.parse({value:u.value,issues:[]},{...d,skipChecks:!0});return h instanceof Promise?h.then(b=>c(b,u,d)):c(h,u,d)}const p=e._zod.parse(u,d);if(p instanceof Promise){if(d.async===!1)throw new Wn;return p.then(h=>s(h,r,d))}return s(p,r,d)}}Q(e,"~standard",()=>({validate:s=>{var c;try{const u=od(e,s);return u.success?{value:u.data}:{issues:(c=u.error)==null?void 0:c.issues}}catch{return id(e,s).then(d=>{var p;return d.success?{value:d.data}:{issues:(p=d.error)==null?void 0:p.issues}})}},vendor:"zod",version:1}))}),Zi=v("$ZodString",(e,t)=>{var n;he.init(e,t),e._zod.pattern=[...((n=e==null?void 0:e._zod.bag)==null?void 0:n.patterns)??[]].pop()??$d(e._zod.bag),e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),fe=v("$ZodStringFormat",(e,t)=>{Yo.init(e,t),Zi.init(e,t)}),Qd=v("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=yd),fe.init(e,t)}),ep=v("$ZodUUID",(e,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=zs(r))}else t.pattern??(t.pattern=zs());fe.init(e,t)}),tp=v("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=wd),fe.init(e,t)}),np=v("$ZodURL",(e,t)=>{fe.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),o=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=o.href:n.value=r;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),rp=v("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Sd()),fe.init(e,t)}),op=v("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=_d),fe.init(e,t)}),ip=v("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=fd),fe.init(e,t)}),sp=v("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=gd),fe.init(e,t)}),ap=v("$ZodULID",(e,t)=>{t.pattern??(t.pattern=md),fe.init(e,t)}),cp=v("$ZodXID",(e,t)=>{t.pattern??(t.pattern=bd),fe.init(e,t)}),lp=v("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=kd),fe.init(e,t)}),up=v("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Id(t)),fe.init(e,t)}),dp=v("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Ld),fe.init(e,t)}),pp=v("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=zd(t)),fe.init(e,t)}),hp=v("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=vd),fe.init(e,t)}),fp=v("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Td),fe.init(e,t),e._zod.bag.format="ipv4"}),gp=v("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Ed),fe.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),mp=v("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Ad),fe.init(e,t)}),bp=v("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Cd),fe.init(e,t),e._zod.check=n=>{const r=n.value.split("/");try{if(r.length!==2)throw new Error;const[o,s]=r;if(!s)throw new Error;const c=Number(s);if(`${c}`!==s)throw new Error;if(c<0||c>128)throw new Error;new URL(`http://[${o}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function Ja(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const kp=v("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Pd),fe.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Ja(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function _p(e){if(!Za.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Ja(n)}const vp=v("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Za),fe.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{_p(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),yp=v("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Rd),fe.init(e,t)});function wp(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const o=JSON.parse(atob(r));return!("typ"in o&&(o==null?void 0:o.typ)!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}const xp=v("$ZodJWT",(e,t)=>{fe.init(e,t),e._zod.check=n=>{wp(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),Xa=v("$ZodNumber",(e,t)=>{he.init(e,t),e._zod.pattern=e._zod.bag.pattern??Fa,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const o=n.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return n;const s=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...s?{received:s}:{}}),n}}),Sp=v("$ZodNumberFormat",(e,t)=>{jd.init(e,t),Xa.init(e,t)}),Tp=v("$ZodBoolean",(e,t)=>{he.init(e,t),e._zod.pattern=Od,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}const o=n.value;return typeof o=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}}),Ep=v("$ZodAny",(e,t)=>{he.init(e,t),e._zod.parse=n=>n}),Ap=v("$ZodUnknown",(e,t)=>{he.init(e,t),e._zod.parse=n=>n}),Cp=v("$ZodNever",(e,t)=>{he.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function Is(e,t,n){e.issues.length&&t.issues.push(...Zn(n,e.issues)),t.value[n]=e.value}const Pp=v("$ZodArray",(e,t)=>{he.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!Array.isArray(o))return n.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),n;n.value=Array(o.length);const s=[];for(let c=0;c<o.length;c++){const u=o[c],d=t.element._zod.run({value:u,issues:[]},r);d instanceof Promise?s.push(d.then(p=>Is(p,n,c))):Is(d,n,c)}return s.length?Promise.all(s).then(()=>n):n}});function Io(e,t,n,r,o){if(e.issues.length){if(o&&!(n in r))return;t.issues.push(...Zn(n,e.issues))}e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function Va(e){var r,o,s,c;const t=Object.keys(e.shape);for(const u of t)if(!((c=(s=(o=(r=e.shape)==null?void 0:r[u])==null?void 0:o._zod)==null?void 0:s.traits)!=null&&c.has("$ZodType")))throw new Error(`Invalid element at key "${u}": expected a Zod schema`);const n=Wu(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Ya(e,t,n,r,o,s){const c=[],u=o.keySet,d=o.catchall._zod,p=d.def.type,h=d.optout==="optional";for(const b in t){if(u.has(b))continue;if(p==="never"){c.push(b);continue}const m=d.run({value:t[b],issues:[]},r);m instanceof Promise?e.push(m.then(_=>Io(_,n,b,t,h))):Io(m,n,b,t,h)}return c.length&&n.issues.push({code:"unrecognized_keys",keys:c,input:t,inst:s}),e.length?Promise.all(e).then(()=>n):n}const Rp=v("$ZodObject",(e,t)=>{he.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!(n!=null&&n.get)){const u=t.shape;Object.defineProperty(t,"shape",{get:()=>{const d={...u};return Object.defineProperty(t,"shape",{value:d}),d}})}const r=Jo(()=>Va(t));Q(e._zod,"propValues",()=>{const u=t.shape,d={};for(const p in u){const h=u[p]._zod;if(h.values){d[p]??(d[p]=new Set);for(const b of h.values)d[p].add(b)}}return d});const o=Dr,s=t.catchall;let c;e._zod.parse=(u,d)=>{c??(c=r.value);const p=u.value;if(!o(p))return u.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),u;u.value={};const h=[],b=c.shape;for(const m of c.keys){const _=b[m],w=_._zod.optout==="optional",P=_._zod.run({value:p[m],issues:[]},d);P instanceof Promise?h.push(P.then(N=>Io(N,u,m,p,w))):Io(P,u,m,p,w)}return s?Ya(h,p,u,d,r.value,e):h.length?Promise.all(h).then(()=>u):u}}),Lp=v("$ZodObjectJIT",(e,t)=>{Rp.init(e,t);const n=e._zod.parse,r=Jo(()=>Va(t)),o=m=>{var x;const _=new Yd(["shape","payload","ctx"]),w=r.value,P=S=>{const C=Ls(S);return`shape[${C}]._zod.run({ value: input[${C}], issues: [] }, ctx)`};_.write("const input = payload.value;");const N=Object.create(null);let te=0;for(const S of w.keys)N[S]=`key_${te++}`;_.write("const newResult = {};");for(const S of w.keys){const C=N[S],M=Ls(S),se=m[S],ve=((x=se==null?void 0:se._zod)==null?void 0:x.optout)==="optional";_.write(`const ${C} = ${P(S)};`),ve?_.write(`
1333
- if (${C}.issues.length) {
1334
- if (${M} in input) {
1335
- payload.issues = payload.issues.concat(${C}.issues.map(iss => ({
1345
+ `;let xs=!1;function Dr(){if(xs)return;const e=document.createElement("style");e.setAttribute("data-ap-sdk","1"),e.textContent=wu,document.head.appendChild(e),xs=!0}function go(e){if(e===document.body)return"body";const t=[];let n=e;for(;n&&n!==document.body;){if(n.id){t.unshift(`#${CSS.escape(n.id)}`);break}let r=n.tagName.toLowerCase();const o=n.parentElement;if(o){const s=Array.from(o.children).filter(a=>a.tagName===n.tagName);if(s.length>1){const a=s.indexOf(n)+1;r+=`:nth-of-type(${a})`}}t.unshift(r),n=n.parentElement}return t.join(" > ")||e.tagName.toLowerCase()}function Ao(e,t=200){const n=(e.textContent??"").replace(/\s+/g," ").trim();return n.length>t?n.slice(0,t)+"…":n}const xu=["role","type","name","href","src","alt","title","for","placeholder","data-testid"];function mo(e){const t=e.tagName.toLowerCase(),n=e.id?`#${e.id}`:"",r=e.classList.length?"."+Array.from(e.classList).join("."):"",o=[],s=new Set,a=u=>{if(s.has(u)||o.length>=8)return;const d=e.getAttribute(u);if(!d)return;s.add(u);const h=d.length>80?d.slice(0,80)+"…":d;o.push(`[${u}="${h}"]`)};for(const u of Array.from(e.attributes))u.name.startsWith("aria-")&&a(u.name);for(const u of xu)a(u);return`${t}${n}${r}${o.join("")}`}function Su(e,t=80){const n=Array.from(e.childNodes).filter(r=>r.nodeType===Node.TEXT_NODE).map(r=>(r.textContent??"").trim()).filter(Boolean).join(" ");return n.length>t?n.slice(0,t)+"…":n}function Tu(e,t=5,n=10){function r(o,s){const a=mo(o),u=" ".repeat(s),d=Array.from(o.children).slice(0,n);if(s>=t||d.length===0){const h=Su(o);return h?`${u}${a} "${h}"`:`${u}${a}`}return[`${u}${a}`,...d.map(h=>r(h,s+1))].join(`
1346
+ `)}return r(e,0)}const Eu='section, article, aside, nav, main, header, footer, form, fieldset, dialog, [role="region"], [role="navigation"], [role="main"], [role="complementary"], [role="banner"], [role="contentinfo"], [role="form"], [role="search"], [role="dialog"]',Au={fieldset:"legend",table:"caption",figure:"figcaption",details:"summary"};function no(e,t){const n=e.replace(/\s+/g," ").trim();return n.length>t?n.slice(0,t)+"…":n}function Cu(e){const t=e.querySelectorAll('h1, h2, h3, h4, h5, h6, [role="heading"]');for(const n of Array.from(t)){let r=n.parentElement;for(;r&&r!==e&&!r.matches(Eu);)r=r.parentElement;if(r===e){const o=(n.textContent??"").trim();if(o)return o}}return""}function Pu(e,t=80){var a,u,d;const n=Au[e.tagName.toLowerCase()];if(n){const h=(u=(a=e.querySelector(n))==null?void 0:a.textContent)==null?void 0:u.trim();if(h)return no(h,t)}const r=Cu(e);if(r)return no(r,t);const o=(d=e.getAttribute("aria-label"))==null?void 0:d.trim();if(o)return no(o,t);const s=e.getAttribute("aria-labelledby");if(s){const h=s.split(/\s+/).map(p=>{var b,m;return((m=(b=document.getElementById(p))==null?void 0:b.textContent)==null?void 0:m.trim())??""}).filter(Boolean).join(" ");if(h)return no(h,t)}return""}function Ru(e,t=6){const n=[],r=new Set;let o=e;for(;o&&o!==document.body&&n.length<t;){const s=o===e?"":Pu(o),a=s&&!r.has(s)?`${mo(o)} ["${s}"]`:mo(o);s&&r.add(s),n.unshift(a),o=o.parentElement}return n.join(" > ")||mo(e)}function Ta(e,t){return e.length>t?e.slice(0,t)+"… (truncated)":e}function br(e){var r;const t=document.querySelector(e);return((r=t==null?void 0:t.content)==null?void 0:r.trim())||void 0}function Ea(){const e=t=>{try{return t()}catch{return}};return{description:e(()=>br('meta[name="description"]')),canonicalUrl:e(()=>{var t;return((t=document.querySelector('link[rel="canonical"]'))==null?void 0:t.href)||void 0}),lang:e(()=>document.documentElement.lang||void 0),ogTitle:e(()=>br('meta[property="og:title"]')),ogDescription:e(()=>br('meta[property="og:description"]')),ogType:e(()=>br('meta[property="og:type"]')),ogSiteName:e(()=>br('meta[property="og:site_name"]')),viewportWidth:e(()=>window.innerWidth),viewportHeight:e(()=>window.innerHeight),scrollX:e(()=>Math.round(window.scrollX)),scrollY:e(()=>Math.round(window.scrollY)),selectionText:e(()=>{var n;const t=(n=window.getSelection())==null?void 0:n.toString().trim();return t?Ta(t,1e3):void 0}),capturedAt:new Date().toISOString()}}function Lu(e){const t=[];let n=e;for(;n&&t.length<6;){let r=n.tagName.toLowerCase();n.id?r+=`#${n.id}`:n.classList.length&&(r+=`.${Array.from(n.classList).slice(0,2).join(".")}`),t.unshift(r),n=n.parentElement}return t.join(" > ")}function zu(e){const t=e.getAttribute("role")||void 0,n=e.getAttribute("aria-label")||void 0;let r;const o=e.closest("section, article, main, nav, aside, header, footer, [role]");if(o){const s=o.querySelector("h1, h2, h3, h4, h5, h6"),a=o.getAttribute("aria-label")||((s==null?void 0:s.textContent)||"").trim(),u=o.tagName.toLowerCase();r=a?`${u}: ${Ta(a,120)}`:u}return{elementRole:t,elementAriaLabel:n,enclosingSection:r}}function Iu(e,t){const n=[e.trim(),"",`Page: ${t.pageTitle} (${t.pageUrl})`];return t.description&&n.push(`Description: ${t.description}`),t.selectionText&&n.push(`Selection: ${t.selectionText}`),t.elementText&&n.push(`Selected element: ${t.elementText}`),t.elementRole&&n.push(` Role: ${t.elementRole}`),t.elementAriaLabel&&n.push(` ARIA label: ${t.elementAriaLabel}`),t.enclosingSection&&n.push(`Section: ${t.enclosingSection}`),t.ancestry&&n.push(`Ancestry: ${t.ancestry}`),t.cssSelector&&n.push(`Selector: ${t.cssSelector}`),n.join(`
1347
+ `)}const Vn=new Set;let Fn=null,Co=!1,ki=!1;function $u(e){if(e.getAttribute("aria-modal")==="false")return!1;const t=getComputedStyle(e);return t.display!=="none"&&t.visibility!=="hidden"}function Nu(){const e=document.querySelectorAll("dialog[open]");for(let n=0;n<e.length;n++)try{if(e[n].matches(":modal"))return!0}catch{}const t=document.querySelectorAll('[role="dialog"], [role="alertdialog"]');for(let n=0;n<t.length;n++){const r=t[n];if(!(Vn.has(r)||r.hasAttribute("data-ap-sdk"))&&r.isConnected&&$u(r))return!0}return!1}function Aa(){const e=Nu(),t=e&&!ki;ki=e;for(const n of Vn){n.hasAttribute("inert")&&n.removeAttribute("inert"),n.getAttribute("aria-hidden")==="true"&&n.removeAttribute("aria-hidden");const r=n.contains(document.activeElement);if(n.matches(":popover-open")){if(t&&!r){try{n.hidePopover()}catch{}try{n.showPopover()}catch{}}}else try{n.showPopover()}catch{}}}function Ss(e){if(!(e instanceof Node))return!1;for(const t of Vn)if(t===e||t.contains(e))return!0;return!1}function Bn(e){(Ss(e.target)||"relatedTarget"in e&&Ss(e.relatedTarget))&&e.stopPropagation()}function Ou(){Co||(window.addEventListener("focusin",Bn,!0),window.addEventListener("focusout",Bn,!0),window.addEventListener("pointerdown",Bn,!0),Co=!0),!Fn&&(Fn=new MutationObserver(e=>{e.some(n=>n.type==="childList"||n.attributeName==="open"&&n.target.tagName==="DIALOG"||n.attributeName==="inert"||n.attributeName==="aria-hidden"||n.attributeName==="role")&&Aa()}),Fn.observe(document.documentElement,{attributes:!0,attributeFilter:["open","inert","aria-hidden","role"],childList:!0,subtree:!0}))}function qt(e){"showPopover"in e&&(e.setAttribute("popover","manual"),Vn.add(e),Ou(),Aa())}function Ht(e){if(Vn.delete(e),Vn.size===0&&(Fn&&(Fn.disconnect(),Fn=null),Co&&(window.removeEventListener("focusin",Bn,!0),window.removeEventListener("focusout",Bn,!0),window.removeEventListener("pointerdown",Bn,!0),Co=!1),ki=!1),"hidePopover"in e)try{e.hidePopover()}catch{}}function zi(e="ap-sdk-highlight"){const t=document.createElement("div");return t.className=e,t.setAttribute("data-ap-sdk","1"),t.style.display="none",document.body.appendChild(t),qt(t),{el:t,update:s=>{const a=s.getBoundingClientRect();t.style.top=`${a.top}px`,t.style.left=`${a.left}px`,t.style.width=`${a.width}px`,t.style.height=`${a.height}px`,t.style.display="block"},hide:()=>{t.style.display="none"},destroy:()=>{Ht(t),t.remove()}}}const Du="🎯 Click any element to capture";let tn=null,ze=null,Oe=null;function Cr(e){return e instanceof Element?e.closest("[data-ap-sdk]")!==null||e.closest(".ap-sdk-panel")!==null||e.closest(".ap-sdk-highlight")!==null||e.closest(".ap-sdk-picker-cursor")!==null:!1}function Mu(){var e;return(((e=window.matchMedia)==null?void 0:e.call(window,"(pointer: coarse)").matches)??!1)||"ontouchstart"in window}function Ts(e){tn==null||tn.update(e)}function Ca(e){const t=Ea(),n=Lu(e),r=zu(e);let o;try{o=e.outerHTML.slice(0,4e3)}catch{}return{pageUrl:window.location.href,pageTitle:document.title,elementText:Ao(e),cssSelector:go(e),innerTree:Tu(e),outerTree:Ru(e),elementOuterHtml:o,ancestry:n,...r,...t}}function si(e,t){Oe&&Oe();const n=Mu();tn=zi(),ze=document.createElement("div"),ze.className="ap-sdk-picker-cursor",ze.setAttribute("data-ap-sdk","1"),ze.textContent=n?"Tap any element to preview":Du,document.body.appendChild(ze),qt(ze);let r=null,o=null;const s=p=>{Oe==null||Oe(),e(Ca(p),p)},a=p=>{if(o=p,Ts(p),!ze)return;ze.classList.add("ap-sdk-picker-cursor--confirm"),ze.innerHTML="";const b=document.createElement("span");b.className="ap-sdk-picker-cursor__label",b.textContent=`<${p.tagName.toLowerCase()}>`;const m=document.createElement("button");m.type="button",m.className="ap-sdk-picker-cursor__btn ap-sdk-picker-cursor__btn--cancel",m.textContent="✕ Cancel",m.setAttribute("data-ap-sdk","1"),m.setAttribute("aria-label","Cancel picking"),m.addEventListener("click",C=>{C.preventDefault(),C.stopPropagation(),Oe==null||Oe(),t()});const _=document.createElement("button");_.type="button",_.className="ap-sdk-picker-cursor__btn",_.textContent="⬆ Parent",_.setAttribute("data-ap-sdk","1"),_.addEventListener("click",C=>{C.preventDefault(),C.stopPropagation(),o!=null&&o.parentElement&&a(o.parentElement)});const w=document.createElement("button");w.type="button",w.className="ap-sdk-picker-cursor__btn ap-sdk-picker-cursor__btn--primary",w.textContent="✓ Select",w.setAttribute("data-ap-sdk","1"),w.addEventListener("click",C=>{C.preventDefault(),C.stopPropagation(),o&&s(o)}),ze.appendChild(b),ze.appendChild(m),ze.appendChild(_),ze.appendChild(w)},u=p=>{Cr(p.target)||(r=p.target,Ts(r))},d=p=>{if(Cr(p.target))return;p.preventDefault(),p.stopImmediatePropagation();const b=p.target??r;if(b){if(n){a(b);return}s(b)}},h=p=>{p.key==="Escape"&&(Oe==null||Oe(),t())};n||document.addEventListener("mouseover",u,{capture:!0}),document.addEventListener("click",d,{capture:!0}),document.addEventListener("keydown",h,{capture:!0}),Oe=()=>{n||document.removeEventListener("mouseover",u,{capture:!0}),document.removeEventListener("click",d,{capture:!0}),document.removeEventListener("keydown",h,{capture:!0}),ze&&Ht(ze),ze==null||ze.remove(),tn==null||tn.destroy(),tn=null,ze=null,o=null,Oe=null}}function Ii(){Oe==null||Oe()}function Gn(){return Oe!==null}function v(e,t,n){function r(u,d){if(u._zod||Object.defineProperty(u,"_zod",{value:{def:d,constr:a,traits:new Set},enumerable:!1}),u._zod.traits.has(e))return;u._zod.traits.add(e),t(u,d);const h=a.prototype,p=Object.keys(h);for(let b=0;b<p.length;b++){const m=p[b];m in u||(u[m]=h[m].bind(u))}}const o=(n==null?void 0:n.Parent)??Object;class s extends o{}Object.defineProperty(s,"name",{value:e});function a(u){var d;const h=n!=null&&n.Parent?new s:this;r(h,u),(d=h._zod).deferred??(d.deferred=[]);for(const p of h._zod.deferred)p();return h}return Object.defineProperty(a,"init",{value:r}),Object.defineProperty(a,Symbol.hasInstance,{value:u=>{var d,h;return n!=null&&n.Parent&&u instanceof n.Parent?!0:(h=(d=u==null?void 0:u._zod)==null?void 0:d.traits)==null?void 0:h.has(e)}}),Object.defineProperty(a,"name",{value:e}),a}class Wn extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Pa extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const Ra={};function nn(e){return Ra}function La(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,o])=>t.indexOf(+r)===-1).map(([r,o])=>o)}function _i(e,t){return typeof t=="bigint"?t.toString():t}function Fo(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function $i(e){return e==null}function Ni(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Uu(e,t){const n=(e.toString().split(".")[1]||"").length,r=t.toString();let o=(r.split(".")[1]||"").length;if(o===0&&/\d?e-\d?/.test(r)){const d=r.match(/\d?e-(\d?)/);d!=null&&d[1]&&(o=Number.parseInt(d[1]))}const s=n>o?n:o,a=Number.parseInt(e.toFixed(s).replace(".","")),u=Number.parseInt(t.toFixed(s).replace(".",""));return a%u/10**s}const Es=Symbol("evaluating");function Q(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Es)return r===void 0&&(r=Es,r=n()),r},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function En(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function on(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function As(e){return JSON.stringify(e)}function ju(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const za="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function $r(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Zu=Fo(()=>{var e;if(typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)!=null&&e.includes("Cloudflare")))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function Yn(e){if($r(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!($r(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Ia(e){return Yn(e)?{...e}:Array.isArray(e)?[...e]:e}const qu=new Set(["string","number","symbol"]);function Kn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function sn(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n!=null&&n.parent)&&(r._zod.parent=e),r}function O(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if((t==null?void 0:t.message)!==void 0){if((t==null?void 0:t.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Hu(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const Fu={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Bu(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const s=on(e._zod.def,{get shape(){const a={};for(const u in t){if(!(u in n.shape))throw new Error(`Unrecognized key: "${u}"`);t[u]&&(a[u]=n.shape[u])}return En(this,"shape",a),a},checks:[]});return sn(e,s)}function Gu(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const s=on(e._zod.def,{get shape(){const a={...e._zod.def.shape};for(const u in t){if(!(u in n.shape))throw new Error(`Unrecognized key: "${u}"`);t[u]&&delete a[u]}return En(this,"shape",a),a},checks:[]});return sn(e,s)}function Wu(e,t){if(!Yn(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const s=e._zod.def.shape;for(const a in t)if(Object.getOwnPropertyDescriptor(s,a)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const o=on(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t};return En(this,"shape",s),s}});return sn(e,o)}function Ju(e,t){if(!Yn(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=on(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return En(this,"shape",r),r}});return sn(e,n)}function Xu(e,t){const n=on(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return En(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return sn(e,n)}function Vu(e,t,n){const o=t._zod.def.checks;if(o&&o.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const a=on(t._zod.def,{get shape(){const u=t._zod.def.shape,d={...u};if(n)for(const h in n){if(!(h in u))throw new Error(`Unrecognized key: "${h}"`);n[h]&&(d[h]=e?new e({type:"optional",innerType:u[h]}):u[h])}else for(const h in u)d[h]=e?new e({type:"optional",innerType:u[h]}):u[h];return En(this,"shape",d),d},checks:[]});return sn(t,a)}function Yu(e,t,n){const r=on(t._zod.def,{get shape(){const o=t._zod.def.shape,s={...o};if(n)for(const a in n){if(!(a in s))throw new Error(`Unrecognized key: "${a}"`);n[a]&&(s[a]=new e({type:"nonoptional",innerType:o[a]}))}else for(const a in o)s[a]=new e({type:"nonoptional",innerType:o[a]});return En(this,"shape",s),s}});return sn(t,r)}function jn(e,t=0){var n;if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(((n=e.issues[r])==null?void 0:n.continue)!==!0)return!0;return!1}function Zn(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function ro(e){return typeof e=="string"?e:e==null?void 0:e.message}function rn(e,t,n){var o,s,a,u,d,h;const r={...e,path:e.path??[]};if(!e.message){const p=ro((a=(s=(o=e.inst)==null?void 0:o._zod.def)==null?void 0:s.error)==null?void 0:a.call(s,e))??ro((u=t==null?void 0:t.error)==null?void 0:u.call(t,e))??ro((d=n.customError)==null?void 0:d.call(n,e))??ro((h=n.localeError)==null?void 0:h.call(n,e))??"Invalid input";r.message=p}return delete r.inst,delete r.continue,t!=null&&t.reportInput||delete r.input,r}function Oi(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Nr(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const $a=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,_i,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Na=v("$ZodError",$a),Oa=v("$ZodError",$a,{Parent:Error});function Ku(e,t=n=>n.message){const n={},r=[];for(const o of e.issues)o.path.length>0?(n[o.path[0]]=n[o.path[0]]||[],n[o.path[0]].push(t(o))):r.push(t(o));return{formErrors:r,fieldErrors:n}}function Qu(e,t=n=>n.message){const n={_errors:[]},r=o=>{for(const s of o.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(a=>r({issues:a}));else if(s.code==="invalid_key")r({issues:s.issues});else if(s.code==="invalid_element")r({issues:s.issues});else if(s.path.length===0)n._errors.push(t(s));else{let a=n,u=0;for(;u<s.path.length;){const d=s.path[u];u===s.path.length-1?(a[d]=a[d]||{_errors:[]},a[d]._errors.push(t(s))):a[d]=a[d]||{_errors:[]},a=a[d],u++}}};return r(e),n}const Di=e=>(t,n,r,o)=>{const s=r?Object.assign(r,{async:!1}):{async:!1},a=t._zod.run({value:n,issues:[]},s);if(a instanceof Promise)throw new Wn;if(a.issues.length){const u=new((o==null?void 0:o.Err)??e)(a.issues.map(d=>rn(d,s,nn())));throw za(u,o==null?void 0:o.callee),u}return a.value},Mi=e=>async(t,n,r,o)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let a=t._zod.run({value:n,issues:[]},s);if(a instanceof Promise&&(a=await a),a.issues.length){const u=new((o==null?void 0:o.Err)??e)(a.issues.map(d=>rn(d,s,nn())));throw za(u,o==null?void 0:o.callee),u}return a.value},Bo=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},o);if(s instanceof Promise)throw new Wn;return s.issues.length?{success:!1,error:new(e??Na)(s.issues.map(a=>rn(a,o,nn())))}:{success:!0,data:s.value}},ed=Bo(Oa),Go=e=>async(t,n,r)=>{const o=r?Object.assign(r,{async:!0}):{async:!0};let s=t._zod.run({value:n,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(a=>rn(a,o,nn())))}:{success:!0,data:s.value}},td=Go(Oa),nd=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Di(e)(t,n,o)},rd=e=>(t,n,r)=>Di(e)(t,n,r),od=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Mi(e)(t,n,o)},id=e=>async(t,n,r)=>Mi(e)(t,n,r),sd=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Bo(e)(t,n,o)},ad=e=>(t,n,r)=>Bo(e)(t,n,r),cd=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Go(e)(t,n,o)},ld=e=>async(t,n,r)=>Go(e)(t,n,r),ud=/^[cC][^\s-]{8,}$/,dd=/^[0-9a-z]+$/,pd=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,hd=/^[0-9a-vA-V]{20}$/,fd=/^[A-Za-z0-9]{27}$/,gd=/^[a-zA-Z0-9_-]{21}$/,md=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,bd=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Cs=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,kd=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,_d="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function vd(){return new RegExp(_d,"u")}const yd=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,wd=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,xd=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Sd=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Td=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Da=/^[A-Za-z0-9_-]*$/,Ed=/^\+[1-9]\d{6,14}$/,Ma="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",Ad=new RegExp(`^${Ma}$`);function Ua(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Cd(e){return new RegExp(`^${Ua(e)}$`)}function Pd(e){const t=Ua({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${Ma}T(?:${r})$`)}const Rd=e=>{const t=e?`[\\s\\S]{${(e==null?void 0:e.minimum)??0},${(e==null?void 0:e.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Ld=/^-?\d+$/,ja=/^-?\d+(?:\.\d+)?$/,zd=/^(?:true|false)$/i,Id=/^[^A-Z]*$/,$d=/^[^a-z]*$/,et=v("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Za={number:"number",bigint:"bigint",object:"date"},qa=v("$ZodCheckLessThan",(e,t)=>{et.init(e,t);const n=Za[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,s=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<s&&(t.inclusive?o.maximum=t.value:o.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Ha=v("$ZodCheckGreaterThan",(e,t)=>{et.init(e,t);const n=Za[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,s=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>s&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Nd=v("$ZodCheckMultipleOf",(e,t)=>{et.init(e,t),e._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):Uu(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Od=v("$ZodCheckNumberFormat",(e,t)=>{var a;et.init(e,t),t.format=t.format||"float64";const n=(a=t.format)==null?void 0:a.includes("int"),r=n?"int":"number",[o,s]=Fu[t.format];e._zod.onattach.push(u=>{const d=u._zod.bag;d.format=t.format,d.minimum=o,d.maximum=s,n&&(d.pattern=Ld)}),e._zod.check=u=>{const d=u.value;if(n){if(!Number.isInteger(d)){u.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:d,inst:e});return}if(!Number.isSafeInteger(d)){d>0?u.issues.push({input:d,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}):u.issues.push({input:d,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}d<o&&u.issues.push({origin:"number",input:d,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),d>s&&u.issues.push({origin:"number",input:d,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}}),Dd=v("$ZodCheckMaxLength",(e,t)=>{var n;et.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!$i(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const o=r.value;if(o.length<=t.maximum)return;const a=Oi(o);r.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Md=v("$ZodCheckMinLength",(e,t)=>{var n;et.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!$i(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const o=r.value;if(o.length>=t.minimum)return;const a=Oi(o);r.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Ud=v("$ZodCheckLengthEquals",(e,t)=>{var n;et.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!$i(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=r=>{const o=r.value,s=o.length;if(s===t.length)return;const a=Oi(o),u=s>t.length;r.issues.push({origin:a,...u?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),Wo=v("$ZodCheckStringFormat",(e,t)=>{var n,r;et.init(e,t),e._zod.onattach.push(o=>{const s=o._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),jd=v("$ZodCheckRegex",(e,t)=>{Wo.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Zd=v("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Id),Wo.init(e,t)}),qd=v("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=$d),Wo.init(e,t)}),Hd=v("$ZodCheckIncludes",(e,t)=>{et.init(e,t);const n=Kn(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(o=>{const s=o._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),Fd=v("$ZodCheckStartsWith",(e,t)=>{et.init(e,t);const n=new RegExp(`^${Kn(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),Bd=v("$ZodCheckEndsWith",(e,t)=>{et.init(e,t);const n=new RegExp(`.*${Kn(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),Gd=v("$ZodCheckOverwrite",(e,t)=>{et.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class Wd{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
1348
+ `).filter(a=>a),o=Math.min(...r.map(a=>a.length-a.trimStart().length)),s=r.map(a=>a.slice(o)).map(a=>" ".repeat(this.indent*2)+a);for(const a of s)this.content.push(a)}compile(){const t=Function,n=this==null?void 0:this.args,o=[...((this==null?void 0:this.content)??[""]).map(s=>` ${s}`)];return new t(...n,o.join(`
1349
+ `))}}const Jd={major:4,minor:3,patch:5},ge=v("$ZodType",(e,t)=>{var o;var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Jd;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const s of r)for(const a of s._zod.onattach)a(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),(o=e._zod.deferred)==null||o.push(()=>{e._zod.run=e._zod.parse});else{const s=(u,d,h)=>{let p=jn(u),b;for(const m of d){if(m._zod.def.when){if(!m._zod.def.when(u))continue}else if(p)continue;const _=u.issues.length,w=m._zod.check(u);if(w instanceof Promise&&(h==null?void 0:h.async)===!1)throw new Wn;if(b||w instanceof Promise)b=(b??Promise.resolve()).then(async()=>{await w,u.issues.length!==_&&(p||(p=jn(u,_)))});else{if(u.issues.length===_)continue;p||(p=jn(u,_))}}return b?b.then(()=>u):u},a=(u,d,h)=>{if(jn(u))return u.aborted=!0,u;const p=s(d,r,h);if(p instanceof Promise){if(h.async===!1)throw new Wn;return p.then(b=>e._zod.parse(b,h))}return e._zod.parse(p,h)};e._zod.run=(u,d)=>{if(d.skipChecks)return e._zod.parse(u,d);if(d.direction==="backward"){const p=e._zod.parse({value:u.value,issues:[]},{...d,skipChecks:!0});return p instanceof Promise?p.then(b=>a(b,u,d)):a(p,u,d)}const h=e._zod.parse(u,d);if(h instanceof Promise){if(d.async===!1)throw new Wn;return h.then(p=>s(p,r,d))}return s(h,r,d)}}Q(e,"~standard",()=>({validate:s=>{var a;try{const u=ed(e,s);return u.success?{value:u.data}:{issues:(a=u.error)==null?void 0:a.issues}}catch{return td(e,s).then(d=>{var h;return d.success?{value:d.data}:{issues:(h=d.error)==null?void 0:h.issues}})}},vendor:"zod",version:1}))}),Ui=v("$ZodString",(e,t)=>{var n;ge.init(e,t),e._zod.pattern=[...((n=e==null?void 0:e._zod.bag)==null?void 0:n.patterns)??[]].pop()??Rd(e._zod.bag),e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),me=v("$ZodStringFormat",(e,t)=>{Wo.init(e,t),Ui.init(e,t)}),Xd=v("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=bd),me.init(e,t)}),Vd=v("$ZodUUID",(e,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Cs(r))}else t.pattern??(t.pattern=Cs());me.init(e,t)}),Yd=v("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=kd),me.init(e,t)}),Kd=v("$ZodURL",(e,t)=>{me.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),o=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=o.href:n.value=r;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),Qd=v("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=vd()),me.init(e,t)}),ep=v("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=gd),me.init(e,t)}),tp=v("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=ud),me.init(e,t)}),np=v("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=dd),me.init(e,t)}),rp=v("$ZodULID",(e,t)=>{t.pattern??(t.pattern=pd),me.init(e,t)}),op=v("$ZodXID",(e,t)=>{t.pattern??(t.pattern=hd),me.init(e,t)}),ip=v("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=fd),me.init(e,t)}),sp=v("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Pd(t)),me.init(e,t)}),ap=v("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Ad),me.init(e,t)}),cp=v("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Cd(t)),me.init(e,t)}),lp=v("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=md),me.init(e,t)}),up=v("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=yd),me.init(e,t),e._zod.bag.format="ipv4"}),dp=v("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=wd),me.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),pp=v("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=xd),me.init(e,t)}),hp=v("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Sd),me.init(e,t),e._zod.check=n=>{const r=n.value.split("/");try{if(r.length!==2)throw new Error;const[o,s]=r;if(!s)throw new Error;const a=Number(s);if(`${a}`!==s)throw new Error;if(a<0||a>128)throw new Error;new URL(`http://[${o}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function Fa(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const fp=v("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Td),me.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Fa(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function gp(e){if(!Da.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Fa(n)}const mp=v("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Da),me.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{gp(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),bp=v("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Ed),me.init(e,t)});function kp(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const o=JSON.parse(atob(r));return!("typ"in o&&(o==null?void 0:o.typ)!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}const _p=v("$ZodJWT",(e,t)=>{me.init(e,t),e._zod.check=n=>{kp(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),Ba=v("$ZodNumber",(e,t)=>{ge.init(e,t),e._zod.pattern=e._zod.bag.pattern??ja,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const o=n.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return n;const s=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...s?{received:s}:{}}),n}}),vp=v("$ZodNumberFormat",(e,t)=>{Od.init(e,t),Ba.init(e,t)}),yp=v("$ZodBoolean",(e,t)=>{ge.init(e,t),e._zod.pattern=zd,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}const o=n.value;return typeof o=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}}),wp=v("$ZodAny",(e,t)=>{ge.init(e,t),e._zod.parse=n=>n}),xp=v("$ZodUnknown",(e,t)=>{ge.init(e,t),e._zod.parse=n=>n}),Sp=v("$ZodNever",(e,t)=>{ge.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function Ps(e,t,n){e.issues.length&&t.issues.push(...Zn(n,e.issues)),t.value[n]=e.value}const Tp=v("$ZodArray",(e,t)=>{ge.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!Array.isArray(o))return n.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),n;n.value=Array(o.length);const s=[];for(let a=0;a<o.length;a++){const u=o[a],d=t.element._zod.run({value:u,issues:[]},r);d instanceof Promise?s.push(d.then(h=>Ps(h,n,a))):Ps(d,n,a)}return s.length?Promise.all(s).then(()=>n):n}});function Po(e,t,n,r,o){if(e.issues.length){if(o&&!(n in r))return;t.issues.push(...Zn(n,e.issues))}e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function Ga(e){var r,o,s,a;const t=Object.keys(e.shape);for(const u of t)if(!((a=(s=(o=(r=e.shape)==null?void 0:r[u])==null?void 0:o._zod)==null?void 0:s.traits)!=null&&a.has("$ZodType")))throw new Error(`Invalid element at key "${u}": expected a Zod schema`);const n=Hu(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Wa(e,t,n,r,o,s){const a=[],u=o.keySet,d=o.catchall._zod,h=d.def.type,p=d.optout==="optional";for(const b in t){if(u.has(b))continue;if(h==="never"){a.push(b);continue}const m=d.run({value:t[b],issues:[]},r);m instanceof Promise?e.push(m.then(_=>Po(_,n,b,t,p))):Po(m,n,b,t,p)}return a.length&&n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:s}),e.length?Promise.all(e).then(()=>n):n}const Ep=v("$ZodObject",(e,t)=>{ge.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!(n!=null&&n.get)){const u=t.shape;Object.defineProperty(t,"shape",{get:()=>{const d={...u};return Object.defineProperty(t,"shape",{value:d}),d}})}const r=Fo(()=>Ga(t));Q(e._zod,"propValues",()=>{const u=t.shape,d={};for(const h in u){const p=u[h]._zod;if(p.values){d[h]??(d[h]=new Set);for(const b of p.values)d[h].add(b)}}return d});const o=$r,s=t.catchall;let a;e._zod.parse=(u,d)=>{a??(a=r.value);const h=u.value;if(!o(h))return u.issues.push({expected:"object",code:"invalid_type",input:h,inst:e}),u;u.value={};const p=[],b=a.shape;for(const m of a.keys){const _=b[m],w=_._zod.optout==="optional",C=_._zod.run({value:h[m],issues:[]},d);C instanceof Promise?p.push(C.then(M=>Po(M,u,m,h,w))):Po(C,u,m,h,w)}return s?Wa(p,h,u,d,r.value,e):p.length?Promise.all(p).then(()=>u):u}}),Ap=v("$ZodObjectJIT",(e,t)=>{Ep.init(e,t);const n=e._zod.parse,r=Fo(()=>Ga(t)),o=m=>{var T;const _=new Wd(["shape","payload","ctx"]),w=r.value,C=x=>{const R=As(x);return`shape[${R}]._zod.run({ value: input[${R}], issues: [] }, ctx)`};_.write("const input = payload.value;");const M=Object.create(null);let W=0;for(const x of w.keys)M[x]=`key_${W++}`;_.write("const newResult = {};");for(const x of w.keys){const R=M[x],D=As(x),de=m[x],_e=((T=de==null?void 0:de._zod)==null?void 0:T.optout)==="optional";_.write(`const ${R} = ${C(x)};`),_e?_.write(`
1350
+ if (${R}.issues.length) {
1351
+ if (${D} in input) {
1352
+ payload.issues = payload.issues.concat(${R}.issues.map(iss => ({
1336
1353
  ...iss,
1337
- path: iss.path ? [${M}, ...iss.path] : [${M}]
1354
+ path: iss.path ? [${D}, ...iss.path] : [${D}]
1338
1355
  })));
1339
1356
  }
1340
1357
  }
1341
1358
 
1342
- if (${C}.value === undefined) {
1343
- if (${M} in input) {
1344
- newResult[${M}] = undefined;
1359
+ if (${R}.value === undefined) {
1360
+ if (${D} in input) {
1361
+ newResult[${D}] = undefined;
1345
1362
  }
1346
1363
  } else {
1347
- newResult[${M}] = ${C}.value;
1364
+ newResult[${D}] = ${R}.value;
1348
1365
  }
1349
1366
 
1350
1367
  `):_.write(`
1351
- if (${C}.issues.length) {
1352
- payload.issues = payload.issues.concat(${C}.issues.map(iss => ({
1368
+ if (${R}.issues.length) {
1369
+ payload.issues = payload.issues.concat(${R}.issues.map(iss => ({
1353
1370
  ...iss,
1354
- path: iss.path ? [${M}, ...iss.path] : [${M}]
1371
+ path: iss.path ? [${D}, ...iss.path] : [${D}]
1355
1372
  })));
1356
1373
  }
1357
1374
 
1358
- if (${C}.value === undefined) {
1359
- if (${M} in input) {
1360
- newResult[${M}] = undefined;
1375
+ if (${R}.value === undefined) {
1376
+ if (${D} in input) {
1377
+ newResult[${D}] = undefined;
1361
1378
  }
1362
1379
  } else {
1363
- newResult[${M}] = ${C}.value;
1380
+ newResult[${D}] = ${R}.value;
1364
1381
  }
1365
1382
 
1366
- `)}_.write("payload.value = newResult;"),_.write("return payload;");const R=_.compile();return(S,C)=>R(m,S,C)};let s;const c=Dr,u=!$a.jitless,p=u&&Bu.value,h=t.catchall;let b;e._zod.parse=(m,_)=>{b??(b=r.value);const w=m.value;return c(w)?u&&p&&(_==null?void 0:_.async)===!1&&_.jitless!==!0?(s||(s=o(t.shape)),m=s(m,_),h?Ya([],w,m,_,b,e):m):n(m,_):(m.issues.push({expected:"object",code:"invalid_type",input:w,inst:e}),m)}});function $s(e,t,n,r){for(const s of e)if(s.issues.length===0)return t.value=s.value,t;const o=e.filter(s=>!jn(s));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(s=>s.issues.map(c=>tn(c,r,en())))}),t)}const Ka=v("$ZodUnion",(e,t)=>{he.init(e,t),Q(e._zod,"optin",()=>t.options.some(o=>o._zod.optin==="optional")?"optional":void 0),Q(e._zod,"optout",()=>t.options.some(o=>o._zod.optout==="optional")?"optional":void 0),Q(e._zod,"values",()=>{if(t.options.every(o=>o._zod.values))return new Set(t.options.flatMap(o=>Array.from(o._zod.values)))}),Q(e._zod,"pattern",()=>{if(t.options.every(o=>o._zod.pattern)){const o=t.options.map(s=>s._zod.pattern);return new RegExp(`^(${o.map(s=>Di(s.source)).join("|")})$`)}});const n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(o,s)=>{if(n)return r(o,s);let c=!1;const u=[];for(const d of t.options){const p=d._zod.run({value:o.value,issues:[]},s);if(p instanceof Promise)u.push(p),c=!0;else{if(p.issues.length===0)return p;u.push(p)}}return c?Promise.all(u).then(d=>$s(d,o,e,s)):$s(u,o,e,s)}}),zp=v("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Ka.init(e,t);const n=e._zod.parse;Q(e._zod,"propValues",()=>{const o={};for(const s of t.options){const c=s._zod.propValues;if(!c||Object.keys(c).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(const[u,d]of Object.entries(c)){o[u]||(o[u]=new Set);for(const p of d)o[u].add(p)}}return o});const r=Jo(()=>{var c;const o=t.options,s=new Map;for(const u of o){const d=(c=u._zod.propValues)==null?void 0:c[t.discriminator];if(!d||d.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(u)}"`);for(const p of d){if(s.has(p))throw new Error(`Duplicate discriminator value "${String(p)}"`);s.set(p,u)}}return s});e._zod.parse=(o,s)=>{const c=o.value;if(!Dr(c))return o.issues.push({code:"invalid_type",expected:"object",input:c,inst:e}),o;const u=r.value.get(c==null?void 0:c[t.discriminator]);return u?u._zod.run(o,s):t.unionFallback?n(o,s):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:c,path:[t.discriminator],inst:e}),o)}}),Ip=v("$ZodIntersection",(e,t)=>{he.init(e,t),e._zod.parse=(n,r)=>{const o=n.value,s=t.left._zod.run({value:o,issues:[]},r),c=t.right._zod.run({value:o,issues:[]},r);return s instanceof Promise||c instanceof Promise?Promise.all([s,c]).then(([d,p])=>Ns(n,d,p)):Ns(n,s,c)}});function xi(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Yn(e)&&Yn(t)){const n=Object.keys(t),r=Object.keys(e).filter(s=>n.indexOf(s)!==-1),o={...e,...t};for(const s of r){const c=xi(e[s],t[s]);if(!c.valid)return{valid:!1,mergeErrorPath:[s,...c.mergeErrorPath]};o[s]=c.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const o=e[r],s=t[r],c=xi(o,s);if(!c.valid)return{valid:!1,mergeErrorPath:[r,...c.mergeErrorPath]};n.push(c.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Ns(e,t,n){const r=new Map;let o;for(const u of t.issues)if(u.code==="unrecognized_keys"){o??(o=u);for(const d of u.keys)r.has(d)||r.set(d,{}),r.get(d).l=!0}else e.issues.push(u);for(const u of n.issues)if(u.code==="unrecognized_keys")for(const d of u.keys)r.has(d)||r.set(d,{}),r.get(d).r=!0;else e.issues.push(u);const s=[...r].filter(([,u])=>u.l&&u.r).map(([u])=>u);if(s.length&&o&&e.issues.push({...o,keys:s}),jn(e))return e;const c=xi(t.value,n.value);if(!c.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`);return e.value=c.data,e}const $p=v("$ZodRecord",(e,t)=>{he.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!Yn(o))return n.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),n;const s=[],c=t.keyType._zod.values;if(c){n.value={};const u=new Set;for(const p of c)if(typeof p=="string"||typeof p=="number"||typeof p=="symbol"){u.add(typeof p=="number"?p.toString():p);const h=t.valueType._zod.run({value:o[p],issues:[]},r);h instanceof Promise?s.push(h.then(b=>{b.issues.length&&n.issues.push(...Zn(p,b.issues)),n.value[p]=b.value})):(h.issues.length&&n.issues.push(...Zn(p,h.issues)),n.value[p]=h.value)}let d;for(const p in o)u.has(p)||(d=d??[],d.push(p));d&&d.length>0&&n.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:d})}else{n.value={};for(const u of Reflect.ownKeys(o)){if(u==="__proto__")continue;let d=t.keyType._zod.run({value:u,issues:[]},r);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof u=="string"&&Fa.test(u)&&d.issues.length&&d.issues.some(b=>b.code==="invalid_type"&&b.expected==="number")){const b=t.keyType._zod.run({value:Number(u),issues:[]},r);if(b instanceof Promise)throw new Error("Async schemas not supported in object keys currently");b.issues.length===0&&(d=b)}if(d.issues.length){t.mode==="loose"?n.value[u]=o[u]:n.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map(b=>tn(b,r,en())),input:u,path:[u],inst:e});continue}const h=t.valueType._zod.run({value:o[u],issues:[]},r);h instanceof Promise?s.push(h.then(b=>{b.issues.length&&n.issues.push(...Zn(u,b.issues)),n.value[d.value]=b.value})):(h.issues.length&&n.issues.push(...Zn(u,h.issues)),n.value[d.value]=h.value)}}return s.length?Promise.all(s).then(()=>n):n}}),Np=v("$ZodEnum",(e,t)=>{he.init(e,t);const n=Na(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(o=>Gu.has(typeof o)).map(o=>typeof o=="string"?Kn(o):o.toString()).join("|")})$`),e._zod.parse=(o,s)=>{const c=o.value;return r.has(c)||o.issues.push({code:"invalid_value",values:n,input:c,inst:e}),o}}),Op=v("$ZodLiteral",(e,t)=>{if(he.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?Kn(r):r?Kn(r.toString()):String(r)).join("|")})$`),e._zod.parse=(r,o)=>{const s=r.value;return n.has(s)||r.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),r}}),Dp=v("$ZodTransform",(e,t)=>{he.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Ia(e.constructor.name);const o=t.transform(n.value,n);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then(c=>(n.value=c,n));if(o instanceof Promise)throw new Wn;return n.value=o,n}});function Os(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const Qa=v("$ZodOptional",(e,t)=>{he.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Q(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Q(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Di(n.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(t.innerType._zod.optin==="optional"){const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>Os(s,n.value)):Os(o,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),Mp=v("$ZodExactOptional",(e,t)=>{Qa.init(e,t),Q(e._zod,"values",()=>t.innerType._zod.values),Q(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),Up=v("$ZodNullable",(e,t)=>{he.init(e,t),Q(e._zod,"optin",()=>t.innerType._zod.optin),Q(e._zod,"optout",()=>t.innerType._zod.optout),Q(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Di(n.source)}|null)$`):void 0}),Q(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),jp=v("$ZodDefault",(e,t)=>{he.init(e,t),e._zod.optin="optional",Q(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>Ds(s,t)):Ds(o,t)}});function Ds(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Zp=v("$ZodPrefault",(e,t)=>{he.init(e,t),e._zod.optin="optional",Q(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),qp=v("$ZodNonOptional",(e,t)=>{he.init(e,t),Q(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>Ms(s,e)):Ms(o,e)}});function Ms(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const Hp=v("$ZodCatch",(e,t)=>{he.init(e,t),Q(e._zod,"optin",()=>t.innerType._zod.optin),Q(e._zod,"optout",()=>t.innerType._zod.optout),Q(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>(n.value=s.value,s.issues.length&&(n.value=t.catchValue({...n,error:{issues:s.issues.map(c=>tn(c,r,en()))},input:n.value}),n.issues=[]),n)):(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(s=>tn(s,r,en()))},input:n.value}),n.issues=[]),n)}}),Fp=v("$ZodPipe",(e,t)=>{he.init(e,t),Q(e._zod,"values",()=>t.in._zod.values),Q(e._zod,"optin",()=>t.in._zod.optin),Q(e._zod,"optout",()=>t.out._zod.optout),Q(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const s=t.out._zod.run(n,r);return s instanceof Promise?s.then(c=>ao(c,t.in,r)):ao(s,t.in,r)}const o=t.in._zod.run(n,r);return o instanceof Promise?o.then(s=>ao(s,t.out,r)):ao(o,t.out,r)}});function ao(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const Bp=v("$ZodReadonly",(e,t)=>{he.init(e,t),Q(e._zod,"propValues",()=>t.innerType._zod.propValues),Q(e._zod,"values",()=>t.innerType._zod.values),Q(e._zod,"optin",()=>{var n,r;return(r=(n=t.innerType)==null?void 0:n._zod)==null?void 0:r.optin}),Q(e._zod,"optout",()=>{var n,r;return(r=(n=t.innerType)==null?void 0:n._zod)==null?void 0:r.optout}),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(Us):Us(o)}});function Us(e){return e.value=Object.freeze(e.value),e}const Gp=v("$ZodCustom",(e,t)=>{et.init(e,t),he.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then(s=>js(s,n,r,e));js(o,n,r,e)}});function js(e,t,n,r){if(!e){const o={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(o.params=r._zod.def.params),t.issues.push(Mr(o))}}var Zs;class Wp{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const r=n[0];return this._map.set(t,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const r={...this.get(n)??{}};delete r.id;const o={...r,...this._map.get(t)};return Object.keys(o).length?o:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function Jp(){return new Wp}(Zs=globalThis).__zod_globalRegistry??(Zs.__zod_globalRegistry=Jp());const Er=globalThis.__zod_globalRegistry;function Xp(e,t){return new e({type:"string",...D(t)})}function Vp(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...D(t)})}function qs(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...D(t)})}function Yp(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...D(t)})}function Kp(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...D(t)})}function Qp(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...D(t)})}function eh(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...D(t)})}function th(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...D(t)})}function nh(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...D(t)})}function rh(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...D(t)})}function oh(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...D(t)})}function ih(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...D(t)})}function sh(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...D(t)})}function ah(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...D(t)})}function ch(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...D(t)})}function lh(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...D(t)})}function uh(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...D(t)})}function dh(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...D(t)})}function ph(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...D(t)})}function hh(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...D(t)})}function fh(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...D(t)})}function gh(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...D(t)})}function mh(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...D(t)})}function bh(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...D(t)})}function kh(e,t){return new e({type:"string",format:"date",check:"string_format",...D(t)})}function _h(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...D(t)})}function vh(e,t){return new e({type:"string",format:"duration",check:"string_format",...D(t)})}function yh(e,t){return new e({type:"number",checks:[],...D(t)})}function wh(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...D(t)})}function xh(e,t){return new e({type:"boolean",...D(t)})}function Sh(e){return new e({type:"any"})}function Th(e){return new e({type:"unknown"})}function Eh(e,t){return new e({type:"never",...D(t)})}function Hs(e,t){return new Ga({check:"less_than",...D(t),value:e,inclusive:!1})}function ui(e,t){return new Ga({check:"less_than",...D(t),value:e,inclusive:!0})}function Fs(e,t){return new Wa({check:"greater_than",...D(t),value:e,inclusive:!1})}function di(e,t){return new Wa({check:"greater_than",...D(t),value:e,inclusive:!0})}function Bs(e,t){return new Ud({check:"multiple_of",...D(t),value:e})}function ec(e,t){return new Zd({check:"max_length",...D(t),maximum:e})}function $o(e,t){return new qd({check:"min_length",...D(t),minimum:e})}function tc(e,t){return new Hd({check:"length_equals",...D(t),length:e})}function Ah(e,t){return new Fd({check:"string_format",format:"regex",...D(t),pattern:e})}function Ch(e){return new Bd({check:"string_format",format:"lowercase",...D(e)})}function Ph(e){return new Gd({check:"string_format",format:"uppercase",...D(e)})}function Rh(e,t){return new Wd({check:"string_format",format:"includes",...D(t),includes:e})}function Lh(e,t){return new Jd({check:"string_format",format:"starts_with",...D(t),prefix:e})}function zh(e,t){return new Xd({check:"string_format",format:"ends_with",...D(t),suffix:e})}function nr(e){return new Vd({check:"overwrite",tx:e})}function Ih(e){return nr(t=>t.normalize(e))}function $h(){return nr(e=>e.trim())}function Nh(){return nr(e=>e.toLowerCase())}function Oh(){return nr(e=>e.toUpperCase())}function Dh(){return nr(e=>Fu(e))}function Mh(e,t,n){return new e({type:"array",element:t,...D(n)})}function Uh(e,t,n){return new e({type:"custom",check:"custom",fn:t,...D(n)})}function jh(e){const t=Zh(n=>(n.addIssue=r=>{if(typeof r=="string")n.issues.push(Mr(r,n.value,t._zod.def));else{const o=r;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=t),o.continue??(o.continue=!t._zod.def.abort),n.issues.push(Mr(o))}},e(n.value,n)));return t}function Zh(e,t){const n=new et({check:"custom",...D(t)});return n._zod.check=e,n}function nc(e){let t=(e==null?void 0:e.target)??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:(e==null?void 0:e.metadata)??Er,target:t,unrepresentable:(e==null?void 0:e.unrepresentable)??"throw",override:(e==null?void 0:e.override)??(()=>{}),io:(e==null?void 0:e.io)??"output",counter:0,seen:new Map,cycles:(e==null?void 0:e.cycles)??"ref",reused:(e==null?void 0:e.reused)??"inline",external:(e==null?void 0:e.external)??void 0}}function Ee(e,t,n={path:[],schemaPath:[]}){var h,b;var r;const o=e._zod.def,s=t.seen.get(e);if(s)return s.count++,n.schemaPath.includes(e)&&(s.cycle=n.path),s.schema;const c={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,c);const u=(b=(h=e._zod).toJSONSchema)==null?void 0:b.call(h);if(u)c.schema=u;else{const m={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,c.schema,m);else{const w=c.schema,P=t.processors[o.type];if(!P)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);P(e,t,w,m)}const _=e._zod.parent;_&&(c.ref||(c.ref=_),Ee(_,t,m),t.seen.get(_).isParent=!0)}const d=t.metadataRegistry.get(e);return d&&Object.assign(c.schema,d),t.io==="input"&&Fe(e)&&(delete c.schema.examples,delete c.schema.default),t.io==="input"&&c.schema._prefault&&((r=c.schema).default??(r.default=c.schema._prefault)),delete c.schema._prefault,t.seen.get(e).schema}function rc(e,t){var c,u,d,p;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const h of e.seen.entries()){const b=(c=e.metadataRegistry.get(h[0]))==null?void 0:c.id;if(b){const m=r.get(b);if(m&&m!==h[0])throw new Error(`Duplicate schema id "${b}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(b,h[0])}}const o=h=>{var P;const b=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const N=(P=e.external.registry.get(h[0]))==null?void 0:P.id,te=e.external.uri??(x=>x);if(N)return{ref:te(N)};const R=h[1].defId??h[1].schema.id??`schema${e.counter++}`;return h[1].defId=R,{defId:R,ref:`${te("__shared")}#/${b}/${R}`}}if(h[1]===n)return{ref:"#"};const _=`#/${b}/`,w=h[1].schema.id??`__schema${e.counter++}`;return{defId:w,ref:_+w}},s=h=>{if(h[1].schema.$ref)return;const b=h[1],{ref:m,defId:_}=o(h);b.def={...b.schema},_&&(b.defId=_);const w=b.schema;for(const P in w)delete w[P];w.$ref=m};if(e.cycles==="throw")for(const h of e.seen.entries()){const b=h[1];if(b.cycle)throw new Error(`Cycle detected: #/${(u=b.cycle)==null?void 0:u.join("/")}/<root>
1383
+ `)}_.write("payload.value = newResult;"),_.write("return payload;");const P=_.compile();return(x,R)=>P(m,x,R)};let s;const a=$r,u=!Ra.jitless,h=u&&Zu.value,p=t.catchall;let b;e._zod.parse=(m,_)=>{b??(b=r.value);const w=m.value;return a(w)?u&&h&&(_==null?void 0:_.async)===!1&&_.jitless!==!0?(s||(s=o(t.shape)),m=s(m,_),p?Wa([],w,m,_,b,e):m):n(m,_):(m.issues.push({expected:"object",code:"invalid_type",input:w,inst:e}),m)}});function Rs(e,t,n,r){for(const s of e)if(s.issues.length===0)return t.value=s.value,t;const o=e.filter(s=>!jn(s));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(s=>s.issues.map(a=>rn(a,r,nn())))}),t)}const Ja=v("$ZodUnion",(e,t)=>{ge.init(e,t),Q(e._zod,"optin",()=>t.options.some(o=>o._zod.optin==="optional")?"optional":void 0),Q(e._zod,"optout",()=>t.options.some(o=>o._zod.optout==="optional")?"optional":void 0),Q(e._zod,"values",()=>{if(t.options.every(o=>o._zod.values))return new Set(t.options.flatMap(o=>Array.from(o._zod.values)))}),Q(e._zod,"pattern",()=>{if(t.options.every(o=>o._zod.pattern)){const o=t.options.map(s=>s._zod.pattern);return new RegExp(`^(${o.map(s=>Ni(s.source)).join("|")})$`)}});const n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(o,s)=>{if(n)return r(o,s);let a=!1;const u=[];for(const d of t.options){const h=d._zod.run({value:o.value,issues:[]},s);if(h instanceof Promise)u.push(h),a=!0;else{if(h.issues.length===0)return h;u.push(h)}}return a?Promise.all(u).then(d=>Rs(d,o,e,s)):Rs(u,o,e,s)}}),Cp=v("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Ja.init(e,t);const n=e._zod.parse;Q(e._zod,"propValues",()=>{const o={};for(const s of t.options){const a=s._zod.propValues;if(!a||Object.keys(a).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(const[u,d]of Object.entries(a)){o[u]||(o[u]=new Set);for(const h of d)o[u].add(h)}}return o});const r=Fo(()=>{var a;const o=t.options,s=new Map;for(const u of o){const d=(a=u._zod.propValues)==null?void 0:a[t.discriminator];if(!d||d.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(u)}"`);for(const h of d){if(s.has(h))throw new Error(`Duplicate discriminator value "${String(h)}"`);s.set(h,u)}}return s});e._zod.parse=(o,s)=>{const a=o.value;if(!$r(a))return o.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),o;const u=r.value.get(a==null?void 0:a[t.discriminator]);return u?u._zod.run(o,s):t.unionFallback?n(o,s):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:a,path:[t.discriminator],inst:e}),o)}}),Pp=v("$ZodIntersection",(e,t)=>{ge.init(e,t),e._zod.parse=(n,r)=>{const o=n.value,s=t.left._zod.run({value:o,issues:[]},r),a=t.right._zod.run({value:o,issues:[]},r);return s instanceof Promise||a instanceof Promise?Promise.all([s,a]).then(([d,h])=>Ls(n,d,h)):Ls(n,s,a)}});function vi(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Yn(e)&&Yn(t)){const n=Object.keys(t),r=Object.keys(e).filter(s=>n.indexOf(s)!==-1),o={...e,...t};for(const s of r){const a=vi(e[s],t[s]);if(!a.valid)return{valid:!1,mergeErrorPath:[s,...a.mergeErrorPath]};o[s]=a.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const o=e[r],s=t[r],a=vi(o,s);if(!a.valid)return{valid:!1,mergeErrorPath:[r,...a.mergeErrorPath]};n.push(a.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Ls(e,t,n){const r=new Map;let o;for(const u of t.issues)if(u.code==="unrecognized_keys"){o??(o=u);for(const d of u.keys)r.has(d)||r.set(d,{}),r.get(d).l=!0}else e.issues.push(u);for(const u of n.issues)if(u.code==="unrecognized_keys")for(const d of u.keys)r.has(d)||r.set(d,{}),r.get(d).r=!0;else e.issues.push(u);const s=[...r].filter(([,u])=>u.l&&u.r).map(([u])=>u);if(s.length&&o&&e.issues.push({...o,keys:s}),jn(e))return e;const a=vi(t.value,n.value);if(!a.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(a.mergeErrorPath)}`);return e.value=a.data,e}const Rp=v("$ZodRecord",(e,t)=>{ge.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!Yn(o))return n.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),n;const s=[],a=t.keyType._zod.values;if(a){n.value={};const u=new Set;for(const h of a)if(typeof h=="string"||typeof h=="number"||typeof h=="symbol"){u.add(typeof h=="number"?h.toString():h);const p=t.valueType._zod.run({value:o[h],issues:[]},r);p instanceof Promise?s.push(p.then(b=>{b.issues.length&&n.issues.push(...Zn(h,b.issues)),n.value[h]=b.value})):(p.issues.length&&n.issues.push(...Zn(h,p.issues)),n.value[h]=p.value)}let d;for(const h in o)u.has(h)||(d=d??[],d.push(h));d&&d.length>0&&n.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:d})}else{n.value={};for(const u of Reflect.ownKeys(o)){if(u==="__proto__")continue;let d=t.keyType._zod.run({value:u,issues:[]},r);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof u=="string"&&ja.test(u)&&d.issues.length&&d.issues.some(b=>b.code==="invalid_type"&&b.expected==="number")){const b=t.keyType._zod.run({value:Number(u),issues:[]},r);if(b instanceof Promise)throw new Error("Async schemas not supported in object keys currently");b.issues.length===0&&(d=b)}if(d.issues.length){t.mode==="loose"?n.value[u]=o[u]:n.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map(b=>rn(b,r,nn())),input:u,path:[u],inst:e});continue}const p=t.valueType._zod.run({value:o[u],issues:[]},r);p instanceof Promise?s.push(p.then(b=>{b.issues.length&&n.issues.push(...Zn(u,b.issues)),n.value[d.value]=b.value})):(p.issues.length&&n.issues.push(...Zn(u,p.issues)),n.value[d.value]=p.value)}}return s.length?Promise.all(s).then(()=>n):n}}),Lp=v("$ZodEnum",(e,t)=>{ge.init(e,t);const n=La(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(o=>qu.has(typeof o)).map(o=>typeof o=="string"?Kn(o):o.toString()).join("|")})$`),e._zod.parse=(o,s)=>{const a=o.value;return r.has(a)||o.issues.push({code:"invalid_value",values:n,input:a,inst:e}),o}}),zp=v("$ZodLiteral",(e,t)=>{if(ge.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?Kn(r):r?Kn(r.toString()):String(r)).join("|")})$`),e._zod.parse=(r,o)=>{const s=r.value;return n.has(s)||r.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),r}}),Ip=v("$ZodTransform",(e,t)=>{ge.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Pa(e.constructor.name);const o=t.transform(n.value,n);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then(a=>(n.value=a,n));if(o instanceof Promise)throw new Wn;return n.value=o,n}});function zs(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const Xa=v("$ZodOptional",(e,t)=>{ge.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Q(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Q(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Ni(n.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(t.innerType._zod.optin==="optional"){const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>zs(s,n.value)):zs(o,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),$p=v("$ZodExactOptional",(e,t)=>{Xa.init(e,t),Q(e._zod,"values",()=>t.innerType._zod.values),Q(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),Np=v("$ZodNullable",(e,t)=>{ge.init(e,t),Q(e._zod,"optin",()=>t.innerType._zod.optin),Q(e._zod,"optout",()=>t.innerType._zod.optout),Q(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Ni(n.source)}|null)$`):void 0}),Q(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),Op=v("$ZodDefault",(e,t)=>{ge.init(e,t),e._zod.optin="optional",Q(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>Is(s,t)):Is(o,t)}});function Is(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Dp=v("$ZodPrefault",(e,t)=>{ge.init(e,t),e._zod.optin="optional",Q(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),Mp=v("$ZodNonOptional",(e,t)=>{ge.init(e,t),Q(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>$s(s,e)):$s(o,e)}});function $s(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const Up=v("$ZodCatch",(e,t)=>{ge.init(e,t),Q(e._zod,"optin",()=>t.innerType._zod.optin),Q(e._zod,"optout",()=>t.innerType._zod.optout),Q(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>(n.value=s.value,s.issues.length&&(n.value=t.catchValue({...n,error:{issues:s.issues.map(a=>rn(a,r,nn()))},input:n.value}),n.issues=[]),n)):(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(s=>rn(s,r,nn()))},input:n.value}),n.issues=[]),n)}}),jp=v("$ZodPipe",(e,t)=>{ge.init(e,t),Q(e._zod,"values",()=>t.in._zod.values),Q(e._zod,"optin",()=>t.in._zod.optin),Q(e._zod,"optout",()=>t.out._zod.optout),Q(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const s=t.out._zod.run(n,r);return s instanceof Promise?s.then(a=>oo(a,t.in,r)):oo(s,t.in,r)}const o=t.in._zod.run(n,r);return o instanceof Promise?o.then(s=>oo(s,t.out,r)):oo(o,t.out,r)}});function oo(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const Zp=v("$ZodReadonly",(e,t)=>{ge.init(e,t),Q(e._zod,"propValues",()=>t.innerType._zod.propValues),Q(e._zod,"values",()=>t.innerType._zod.values),Q(e._zod,"optin",()=>{var n,r;return(r=(n=t.innerType)==null?void 0:n._zod)==null?void 0:r.optin}),Q(e._zod,"optout",()=>{var n,r;return(r=(n=t.innerType)==null?void 0:n._zod)==null?void 0:r.optout}),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(Ns):Ns(o)}});function Ns(e){return e.value=Object.freeze(e.value),e}const qp=v("$ZodCustom",(e,t)=>{et.init(e,t),ge.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then(s=>Os(s,n,r,e));Os(o,n,r,e)}});function Os(e,t,n,r){if(!e){const o={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(o.params=r._zod.def.params),t.issues.push(Nr(o))}}var Ds;class Hp{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const r=n[0];return this._map.set(t,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const r={...this.get(n)??{}};delete r.id;const o={...r,...this._map.get(t)};return Object.keys(o).length?o:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function Fp(){return new Hp}(Ds=globalThis).__zod_globalRegistry??(Ds.__zod_globalRegistry=Fp());const Er=globalThis.__zod_globalRegistry;function Bp(e,t){return new e({type:"string",...O(t)})}function Gp(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...O(t)})}function Ms(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...O(t)})}function Wp(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...O(t)})}function Jp(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...O(t)})}function Xp(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...O(t)})}function Vp(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...O(t)})}function Yp(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...O(t)})}function Kp(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...O(t)})}function Qp(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...O(t)})}function eh(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...O(t)})}function th(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...O(t)})}function nh(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...O(t)})}function rh(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...O(t)})}function oh(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...O(t)})}function ih(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...O(t)})}function sh(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...O(t)})}function ah(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...O(t)})}function ch(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...O(t)})}function lh(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...O(t)})}function uh(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...O(t)})}function dh(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...O(t)})}function ph(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...O(t)})}function hh(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...O(t)})}function fh(e,t){return new e({type:"string",format:"date",check:"string_format",...O(t)})}function gh(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...O(t)})}function mh(e,t){return new e({type:"string",format:"duration",check:"string_format",...O(t)})}function bh(e,t){return new e({type:"number",checks:[],...O(t)})}function kh(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...O(t)})}function _h(e,t){return new e({type:"boolean",...O(t)})}function vh(e){return new e({type:"any"})}function yh(e){return new e({type:"unknown"})}function wh(e,t){return new e({type:"never",...O(t)})}function Us(e,t){return new qa({check:"less_than",...O(t),value:e,inclusive:!1})}function ai(e,t){return new qa({check:"less_than",...O(t),value:e,inclusive:!0})}function js(e,t){return new Ha({check:"greater_than",...O(t),value:e,inclusive:!1})}function ci(e,t){return new Ha({check:"greater_than",...O(t),value:e,inclusive:!0})}function Zs(e,t){return new Nd({check:"multiple_of",...O(t),value:e})}function Va(e,t){return new Dd({check:"max_length",...O(t),maximum:e})}function Ro(e,t){return new Md({check:"min_length",...O(t),minimum:e})}function Ya(e,t){return new Ud({check:"length_equals",...O(t),length:e})}function xh(e,t){return new jd({check:"string_format",format:"regex",...O(t),pattern:e})}function Sh(e){return new Zd({check:"string_format",format:"lowercase",...O(e)})}function Th(e){return new qd({check:"string_format",format:"uppercase",...O(e)})}function Eh(e,t){return new Hd({check:"string_format",format:"includes",...O(t),includes:e})}function Ah(e,t){return new Fd({check:"string_format",format:"starts_with",...O(t),prefix:e})}function Ch(e,t){return new Bd({check:"string_format",format:"ends_with",...O(t),suffix:e})}function nr(e){return new Gd({check:"overwrite",tx:e})}function Ph(e){return nr(t=>t.normalize(e))}function Rh(){return nr(e=>e.trim())}function Lh(){return nr(e=>e.toLowerCase())}function zh(){return nr(e=>e.toUpperCase())}function Ih(){return nr(e=>ju(e))}function $h(e,t,n){return new e({type:"array",element:t,...O(n)})}function Nh(e,t,n){return new e({type:"custom",check:"custom",fn:t,...O(n)})}function Oh(e){const t=Dh(n=>(n.addIssue=r=>{if(typeof r=="string")n.issues.push(Nr(r,n.value,t._zod.def));else{const o=r;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=t),o.continue??(o.continue=!t._zod.def.abort),n.issues.push(Nr(o))}},e(n.value,n)));return t}function Dh(e,t){const n=new et({check:"custom",...O(t)});return n._zod.check=e,n}function Ka(e){let t=(e==null?void 0:e.target)??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:(e==null?void 0:e.metadata)??Er,target:t,unrepresentable:(e==null?void 0:e.unrepresentable)??"throw",override:(e==null?void 0:e.override)??(()=>{}),io:(e==null?void 0:e.io)??"output",counter:0,seen:new Map,cycles:(e==null?void 0:e.cycles)??"ref",reused:(e==null?void 0:e.reused)??"inline",external:(e==null?void 0:e.external)??void 0}}function Te(e,t,n={path:[],schemaPath:[]}){var p,b;var r;const o=e._zod.def,s=t.seen.get(e);if(s)return s.count++,n.schemaPath.includes(e)&&(s.cycle=n.path),s.schema;const a={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,a);const u=(b=(p=e._zod).toJSONSchema)==null?void 0:b.call(p);if(u)a.schema=u;else{const m={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,a.schema,m);else{const w=a.schema,C=t.processors[o.type];if(!C)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);C(e,t,w,m)}const _=e._zod.parent;_&&(a.ref||(a.ref=_),Te(_,t,m),t.seen.get(_).isParent=!0)}const d=t.metadataRegistry.get(e);return d&&Object.assign(a.schema,d),t.io==="input"&&Ge(e)&&(delete a.schema.examples,delete a.schema.default),t.io==="input"&&a.schema._prefault&&((r=a.schema).default??(r.default=a.schema._prefault)),delete a.schema._prefault,t.seen.get(e).schema}function Qa(e,t){var a,u,d,h;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const p of e.seen.entries()){const b=(a=e.metadataRegistry.get(p[0]))==null?void 0:a.id;if(b){const m=r.get(b);if(m&&m!==p[0])throw new Error(`Duplicate schema id "${b}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(b,p[0])}}const o=p=>{var C;const b=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const M=(C=e.external.registry.get(p[0]))==null?void 0:C.id,W=e.external.uri??(T=>T);if(M)return{ref:W(M)};const P=p[1].defId??p[1].schema.id??`schema${e.counter++}`;return p[1].defId=P,{defId:P,ref:`${W("__shared")}#/${b}/${P}`}}if(p[1]===n)return{ref:"#"};const _=`#/${b}/`,w=p[1].schema.id??`__schema${e.counter++}`;return{defId:w,ref:_+w}},s=p=>{if(p[1].schema.$ref)return;const b=p[1],{ref:m,defId:_}=o(p);b.def={...b.schema},_&&(b.defId=_);const w=b.schema;for(const C in w)delete w[C];w.$ref=m};if(e.cycles==="throw")for(const p of e.seen.entries()){const b=p[1];if(b.cycle)throw new Error(`Cycle detected: #/${(u=b.cycle)==null?void 0:u.join("/")}/<root>
1367
1384
 
1368
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const h of e.seen.entries()){const b=h[1];if(t===h[0]){s(h);continue}if(e.external){const _=(d=e.external.registry.get(h[0]))==null?void 0:d.id;if(t!==h[0]&&_){s(h);continue}}if((p=e.metadataRegistry.get(h[0]))==null?void 0:p.id){s(h);continue}if(b.cycle){s(h);continue}if(b.count>1&&e.reused==="ref"){s(h);continue}}}function oc(e,t){var c,u,d;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=p=>{const h=e.seen.get(p);if(h.ref===null)return;const b=h.def??h.schema,m={...b},_=h.ref;if(h.ref=null,_){r(_);const P=e.seen.get(_),N=P.schema;if(N.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(b.allOf=b.allOf??[],b.allOf.push(N)):Object.assign(b,N),Object.assign(b,m),p._zod.parent===_)for(const R in b)R==="$ref"||R==="allOf"||R in m||delete b[R];if(N.$ref)for(const R in b)R==="$ref"||R==="allOf"||R in P.def&&JSON.stringify(b[R])===JSON.stringify(P.def[R])&&delete b[R]}const w=p._zod.parent;if(w&&w!==_){r(w);const P=e.seen.get(w);if(P!=null&&P.schema.$ref&&(b.$ref=P.schema.$ref,P.def))for(const N in b)N==="$ref"||N==="allOf"||N in P.def&&JSON.stringify(b[N])===JSON.stringify(P.def[N])&&delete b[N]}e.override({zodSchema:p,jsonSchema:b,path:h.path??[]})};for(const p of[...e.seen.entries()].reverse())r(p[0]);const o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":e.target,(c=e.external)!=null&&c.uri){const p=(u=e.external.registry.get(t))==null?void 0:u.id;if(!p)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(p)}Object.assign(o,n.def??n.schema);const s=((d=e.external)==null?void 0:d.defs)??{};for(const p of e.seen.entries()){const h=p[1];h.def&&h.defId&&(s[h.defId]=h.def)}e.external||Object.keys(s).length>0&&(e.target==="draft-2020-12"?o.$defs=s:o.definitions=s);try{const p=JSON.parse(JSON.stringify(o));return Object.defineProperty(p,"~standard",{value:{...t["~standard"],jsonSchema:{input:No(t,"input",e.processors),output:No(t,"output",e.processors)}},enumerable:!1,writable:!1}),p}catch{throw new Error("Error converting schema to JSON.")}}function Fe(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return Fe(r.element,n);if(r.type==="set")return Fe(r.valueType,n);if(r.type==="lazy")return Fe(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return Fe(r.innerType,n);if(r.type==="intersection")return Fe(r.left,n)||Fe(r.right,n);if(r.type==="record"||r.type==="map")return Fe(r.keyType,n)||Fe(r.valueType,n);if(r.type==="pipe")return Fe(r.in,n)||Fe(r.out,n);if(r.type==="object"){for(const o in r.shape)if(Fe(r.shape[o],n))return!0;return!1}if(r.type==="union"){for(const o of r.options)if(Fe(o,n))return!0;return!1}if(r.type==="tuple"){for(const o of r.items)if(Fe(o,n))return!0;return!!(r.rest&&Fe(r.rest,n))}return!1}const qh=(e,t={})=>n=>{const r=nc({...n,processors:t});return Ee(e,r),rc(r,e),oc(r,e)},No=(e,t,n={})=>r=>{const{libraryOptions:o,target:s}=r??{},c=nc({...o??{},target:s,io:t,processors:n});return Ee(e,c),rc(c,e),oc(c,e)},Hh={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Fh=(e,t,n,r)=>{const o=n;o.type="string";const{minimum:s,maximum:c,format:u,patterns:d,contentEncoding:p}=e._zod.bag;if(typeof s=="number"&&(o.minLength=s),typeof c=="number"&&(o.maxLength=c),u&&(o.format=Hh[u]??u,o.format===""&&delete o.format,u==="time"&&delete o.format),p&&(o.contentEncoding=p),d&&d.size>0){const h=[...d];h.length===1?o.pattern=h[0].source:h.length>1&&(o.allOf=[...h.map(b=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:b.source}))])}},Bh=(e,t,n,r)=>{const o=n,{minimum:s,maximum:c,format:u,multipleOf:d,exclusiveMaximum:p,exclusiveMinimum:h}=e._zod.bag;typeof u=="string"&&u.includes("int")?o.type="integer":o.type="number",typeof h=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(o.minimum=h,o.exclusiveMinimum=!0):o.exclusiveMinimum=h),typeof s=="number"&&(o.minimum=s,typeof h=="number"&&t.target!=="draft-04"&&(h>=s?delete o.minimum:delete o.exclusiveMinimum)),typeof p=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(o.maximum=p,o.exclusiveMaximum=!0):o.exclusiveMaximum=p),typeof c=="number"&&(o.maximum=c,typeof p=="number"&&t.target!=="draft-04"&&(p<=c?delete o.maximum:delete o.exclusiveMaximum)),typeof d=="number"&&(o.multipleOf=d)},Gh=(e,t,n,r)=>{n.type="boolean"},Wh=(e,t,n,r)=>{n.not={}},Jh=(e,t,n,r)=>{},Xh=(e,t,n,r)=>{},Vh=(e,t,n,r)=>{const o=e._zod.def,s=Na(o.entries);s.every(c=>typeof c=="number")&&(n.type="number"),s.every(c=>typeof c=="string")&&(n.type="string"),n.enum=s},Yh=(e,t,n,r)=>{const o=e._zod.def,s=[];for(const c of o.values)if(c===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof c=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");s.push(Number(c))}else s.push(c);if(s.length!==0)if(s.length===1){const c=s[0];n.type=c===null?"null":typeof c,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[c]:n.const=c}else s.every(c=>typeof c=="number")&&(n.type="number"),s.every(c=>typeof c=="string")&&(n.type="string"),s.every(c=>typeof c=="boolean")&&(n.type="boolean"),s.every(c=>c===null)&&(n.type="null"),n.enum=s},Kh=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},Qh=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},ef=(e,t,n,r)=>{const o=n,s=e._zod.def,{minimum:c,maximum:u}=e._zod.bag;typeof c=="number"&&(o.minItems=c),typeof u=="number"&&(o.maxItems=u),o.type="array",o.items=Ee(s.element,t,{...r,path:[...r.path,"items"]})},tf=(e,t,n,r)=>{var p;const o=n,s=e._zod.def;o.type="object",o.properties={};const c=s.shape;for(const h in c)o.properties[h]=Ee(c[h],t,{...r,path:[...r.path,"properties",h]});const u=new Set(Object.keys(c)),d=new Set([...u].filter(h=>{const b=s.shape[h]._zod;return t.io==="input"?b.optin===void 0:b.optout===void 0}));d.size>0&&(o.required=Array.from(d)),((p=s.catchall)==null?void 0:p._zod.def.type)==="never"?o.additionalProperties=!1:s.catchall?s.catchall&&(o.additionalProperties=Ee(s.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},nf=(e,t,n,r)=>{const o=e._zod.def,s=o.inclusive===!1,c=o.options.map((u,d)=>Ee(u,t,{...r,path:[...r.path,s?"oneOf":"anyOf",d]}));s?n.oneOf=c:n.anyOf=c},rf=(e,t,n,r)=>{const o=e._zod.def,s=Ee(o.left,t,{...r,path:[...r.path,"allOf",0]}),c=Ee(o.right,t,{...r,path:[...r.path,"allOf",1]}),u=p=>"allOf"in p&&Object.keys(p).length===1,d=[...u(s)?s.allOf:[s],...u(c)?c.allOf:[c]];n.allOf=d},of=(e,t,n,r)=>{const o=n,s=e._zod.def;o.type="object";const c=s.keyType,u=c._zod.bag,d=u==null?void 0:u.patterns;if(s.mode==="loose"&&d&&d.size>0){const h=Ee(s.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});o.patternProperties={};for(const b of d)o.patternProperties[b.source]=h}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(o.propertyNames=Ee(s.keyType,t,{...r,path:[...r.path,"propertyNames"]})),o.additionalProperties=Ee(s.valueType,t,{...r,path:[...r.path,"additionalProperties"]});const p=c._zod.values;if(p){const h=[...p].filter(b=>typeof b=="string"||typeof b=="number");h.length>0&&(o.required=h)}},sf=(e,t,n,r)=>{const o=e._zod.def,s=Ee(o.innerType,t,r),c=t.seen.get(e);t.target==="openapi-3.0"?(c.ref=o.innerType,n.nullable=!0):n.anyOf=[s,{type:"null"}]},af=(e,t,n,r)=>{const o=e._zod.def;Ee(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType},cf=(e,t,n,r)=>{const o=e._zod.def;Ee(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType,n.default=JSON.parse(JSON.stringify(o.defaultValue))},lf=(e,t,n,r)=>{const o=e._zod.def;Ee(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},uf=(e,t,n,r)=>{const o=e._zod.def;Ee(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType;let c;try{c=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=c},df=(e,t,n,r)=>{const o=e._zod.def,s=t.io==="input"?o.in._zod.def.type==="transform"?o.out:o.in:o.out;Ee(s,t,r);const c=t.seen.get(e);c.ref=s},pf=(e,t,n,r)=>{const o=e._zod.def;Ee(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType,n.readOnly=!0},ic=(e,t,n,r)=>{const o=e._zod.def;Ee(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType},hf=v("ZodISODateTime",(e,t)=>{up.init(e,t),_e.init(e,t)});function ff(e){return bh(hf,e)}const gf=v("ZodISODate",(e,t)=>{dp.init(e,t),_e.init(e,t)});function mf(e){return kh(gf,e)}const bf=v("ZodISOTime",(e,t)=>{pp.init(e,t),_e.init(e,t)});function kf(e){return _h(bf,e)}const _f=v("ZodISODuration",(e,t)=>{hp.init(e,t),_e.init(e,t)});function vf(e){return vh(_f,e)}const yf=(e,t)=>{Ua.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>rd(e,n)},flatten:{value:n=>nd(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,wi,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,wi,2)}},isEmpty:{get(){return e.issues.length===0}}})},lt=v("ZodError",yf,{Parent:Error}),wf=Ui(lt),xf=ji(lt),Sf=Xo(lt),Tf=Vo(lt),Ef=sd(lt),Af=ad(lt),Cf=cd(lt),Pf=ld(lt),Rf=ud(lt),Lf=dd(lt),zf=pd(lt),If=hd(lt),ge=v("ZodType",(e,t)=>(he.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:No(e,"input"),output:No(e,"output")}}),e.toJSONSchema=qh(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(nn(t,{checks:[...t.checks??[],...n.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0}),e.with=e.check,e.clone=(n,r)=>rn(e,n,r),e.brand=()=>e,e.register=(n,r)=>(n.add(e,r),e),e.parse=(n,r)=>wf(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>Sf(e,n,r),e.parseAsync=async(n,r)=>xf(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>Tf(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>Ef(e,n,r),e.decode=(n,r)=>Af(e,n,r),e.encodeAsync=async(n,r)=>Cf(e,n,r),e.decodeAsync=async(n,r)=>Pf(e,n,r),e.safeEncode=(n,r)=>Rf(e,n,r),e.safeDecode=(n,r)=>Lf(e,n,r),e.safeEncodeAsync=async(n,r)=>zf(e,n,r),e.safeDecodeAsync=async(n,r)=>If(e,n,r),e.refine=(n,r)=>e.check(Cg(n,r)),e.superRefine=n=>e.check(Pg(n)),e.overwrite=n=>e.check(nr(n)),e.optional=()=>Xs(e),e.exactOptional=()=>gg(e),e.nullable=()=>Vs(e),e.nullish=()=>Xs(Vs(e)),e.nonoptional=n=>yg(e,n),e.array=()=>xt(e),e.or=n=>sg([e,n]),e.and=n=>lg(e,n),e.transform=n=>Ys(e,hg(n)),e.default=n=>kg(e,n),e.prefault=n=>vg(e,n),e.catch=n=>xg(e,n),e.pipe=n=>Ys(e,n),e.readonly=()=>Eg(e),e.describe=n=>{const r=e.clone();return Er.add(r,{description:n}),r},Object.defineProperty(e,"description",{get(){var n;return(n=Er.get(e))==null?void 0:n.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return Er.get(e);const r=e.clone();return Er.add(r,n[0]),r},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),sc=v("_ZodString",(e,t)=>{Zi.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,o,s)=>Fh(e,r,o);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...r)=>e.check(Ah(...r)),e.includes=(...r)=>e.check(Rh(...r)),e.startsWith=(...r)=>e.check(Lh(...r)),e.endsWith=(...r)=>e.check(zh(...r)),e.min=(...r)=>e.check($o(...r)),e.max=(...r)=>e.check(ec(...r)),e.length=(...r)=>e.check(tc(...r)),e.nonempty=(...r)=>e.check($o(1,...r)),e.lowercase=r=>e.check(Ch(r)),e.uppercase=r=>e.check(Ph(r)),e.trim=()=>e.check($h()),e.normalize=(...r)=>e.check(Ih(...r)),e.toLowerCase=()=>e.check(Nh()),e.toUpperCase=()=>e.check(Oh()),e.slugify=()=>e.check(Dh())}),$f=v("ZodString",(e,t)=>{Zi.init(e,t),sc.init(e,t),e.email=n=>e.check(Vp(Nf,n)),e.url=n=>e.check(th(Of,n)),e.jwt=n=>e.check(mh(Yf,n)),e.emoji=n=>e.check(nh(Df,n)),e.guid=n=>e.check(qs(Gs,n)),e.uuid=n=>e.check(Yp(co,n)),e.uuidv4=n=>e.check(Kp(co,n)),e.uuidv6=n=>e.check(Qp(co,n)),e.uuidv7=n=>e.check(eh(co,n)),e.nanoid=n=>e.check(rh(Mf,n)),e.guid=n=>e.check(qs(Gs,n)),e.cuid=n=>e.check(oh(Uf,n)),e.cuid2=n=>e.check(ih(jf,n)),e.ulid=n=>e.check(sh(Zf,n)),e.base64=n=>e.check(hh(Jf,n)),e.base64url=n=>e.check(fh(Xf,n)),e.xid=n=>e.check(ah(qf,n)),e.ksuid=n=>e.check(ch(Hf,n)),e.ipv4=n=>e.check(lh(Ff,n)),e.ipv6=n=>e.check(uh(Bf,n)),e.cidrv4=n=>e.check(dh(Gf,n)),e.cidrv6=n=>e.check(ph(Wf,n)),e.e164=n=>e.check(gh(Vf,n)),e.datetime=n=>e.check(ff(n)),e.date=n=>e.check(mf(n)),e.time=n=>e.check(kf(n)),e.duration=n=>e.check(vf(n))});function A(e){return Xp($f,e)}const _e=v("ZodStringFormat",(e,t)=>{fe.init(e,t),sc.init(e,t)}),Nf=v("ZodEmail",(e,t)=>{tp.init(e,t),_e.init(e,t)}),Gs=v("ZodGUID",(e,t)=>{Qd.init(e,t),_e.init(e,t)}),co=v("ZodUUID",(e,t)=>{ep.init(e,t),_e.init(e,t)}),Of=v("ZodURL",(e,t)=>{np.init(e,t),_e.init(e,t)}),Df=v("ZodEmoji",(e,t)=>{rp.init(e,t),_e.init(e,t)}),Mf=v("ZodNanoID",(e,t)=>{op.init(e,t),_e.init(e,t)}),Uf=v("ZodCUID",(e,t)=>{ip.init(e,t),_e.init(e,t)}),jf=v("ZodCUID2",(e,t)=>{sp.init(e,t),_e.init(e,t)}),Zf=v("ZodULID",(e,t)=>{ap.init(e,t),_e.init(e,t)}),qf=v("ZodXID",(e,t)=>{cp.init(e,t),_e.init(e,t)}),Hf=v("ZodKSUID",(e,t)=>{lp.init(e,t),_e.init(e,t)}),Ff=v("ZodIPv4",(e,t)=>{fp.init(e,t),_e.init(e,t)}),Bf=v("ZodIPv6",(e,t)=>{gp.init(e,t),_e.init(e,t)}),Gf=v("ZodCIDRv4",(e,t)=>{mp.init(e,t),_e.init(e,t)}),Wf=v("ZodCIDRv6",(e,t)=>{bp.init(e,t),_e.init(e,t)}),Jf=v("ZodBase64",(e,t)=>{kp.init(e,t),_e.init(e,t)}),Xf=v("ZodBase64URL",(e,t)=>{vp.init(e,t),_e.init(e,t)}),Vf=v("ZodE164",(e,t)=>{yp.init(e,t),_e.init(e,t)}),Yf=v("ZodJWT",(e,t)=>{xp.init(e,t),_e.init(e,t)}),ac=v("ZodNumber",(e,t)=>{Xa.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,o,s)=>Bh(e,r,o),e.gt=(r,o)=>e.check(Fs(r,o)),e.gte=(r,o)=>e.check(di(r,o)),e.min=(r,o)=>e.check(di(r,o)),e.lt=(r,o)=>e.check(Hs(r,o)),e.lte=(r,o)=>e.check(ui(r,o)),e.max=(r,o)=>e.check(ui(r,o)),e.int=r=>e.check(Ws(r)),e.safe=r=>e.check(Ws(r)),e.positive=r=>e.check(Fs(0,r)),e.nonnegative=r=>e.check(di(0,r)),e.negative=r=>e.check(Hs(0,r)),e.nonpositive=r=>e.check(ui(0,r)),e.multipleOf=(r,o)=>e.check(Bs(r,o)),e.step=(r,o)=>e.check(Bs(r,o)),e.finite=()=>e;const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function At(e){return yh(ac,e)}const Kf=v("ZodNumberFormat",(e,t)=>{Sp.init(e,t),ac.init(e,t)});function Ws(e){return wh(Kf,e)}const Qf=v("ZodBoolean",(e,t)=>{Tp.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Gh(e,n,r)});function de(e){return xh(Qf,e)}const eg=v("ZodAny",(e,t)=>{Ep.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Jh()});function cc(){return Sh(eg)}const tg=v("ZodUnknown",(e,t)=>{Ap.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Xh()});function Js(){return Th(tg)}const ng=v("ZodNever",(e,t)=>{Cp.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Wh(e,n,r)});function rg(e){return Eh(ng,e)}const og=v("ZodArray",(e,t)=>{Pp.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ef(e,n,r,o),e.element=t.element,e.min=(n,r)=>e.check($o(n,r)),e.nonempty=n=>e.check($o(1,n)),e.max=(n,r)=>e.check(ec(n,r)),e.length=(n,r)=>e.check(tc(n,r)),e.unwrap=()=>e.element});function xt(e,t){return Mh(og,e,t)}const ig=v("ZodObject",(e,t)=>{Lp.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>tf(e,n,r,o),Q(e,"shape",()=>t.shape),e.keyof=()=>st(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Js()}),e.loose=()=>e.clone({...e._zod.def,catchall:Js()}),e.strict=()=>e.clone({...e._zod.def,catchall:rg()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>Yu(e,n),e.safeExtend=n=>Ku(e,n),e.merge=n=>Qu(e,n),e.pick=n=>Xu(e,n),e.omit=n=>Vu(e,n),e.partial=(...n)=>ed(dc,e,n[0]),e.required=(...n)=>td(pc,e,n[0])});function ue(e,t){const n={type:"object",shape:e??{},...D(t)};return new ig(n)}const lc=v("ZodUnion",(e,t)=>{Ka.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>nf(e,n,r,o),e.options=t.options});function sg(e,t){return new lc({type:"union",options:e,...D(t)})}const ag=v("ZodDiscriminatedUnion",(e,t)=>{lc.init(e,t),zp.init(e,t)});function uc(e,t,n){return new ag({type:"union",options:t,discriminator:e,...D(n)})}const cg=v("ZodIntersection",(e,t)=>{Ip.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>rf(e,n,r,o)});function lg(e,t){return new cg({type:"intersection",left:e,right:t})}const ug=v("ZodRecord",(e,t)=>{$p.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>of(e,n,r,o),e.keyType=t.keyType,e.valueType=t.valueType});function St(e,t,n){return new ug({type:"record",keyType:e,valueType:t,...D(n)})}const Si=v("ZodEnum",(e,t)=>{Np.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,o,s)=>Vh(e,r,o),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(r,o)=>{const s={};for(const c of r)if(n.has(c))s[c]=t.entries[c];else throw new Error(`Key ${c} not found in enum`);return new Si({...t,checks:[],...D(o),entries:s})},e.exclude=(r,o)=>{const s={...t.entries};for(const c of r)if(n.has(c))delete s[c];else throw new Error(`Key ${c} not found in enum`);return new Si({...t,checks:[],...D(o),entries:s})}});function st(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new Si({type:"enum",entries:n,...D(t)})}const dg=v("ZodLiteral",(e,t)=>{Op.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Yh(e,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function it(e,t){return new dg({type:"literal",values:Array.isArray(e)?e:[e],...D(t)})}const pg=v("ZodTransform",(e,t)=>{Dp.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Qh(e,n),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Ia(e.constructor.name);n.addIssue=s=>{if(typeof s=="string")n.issues.push(Mr(s,n.value,t));else{const c=s;c.fatal&&(c.continue=!1),c.code??(c.code="custom"),c.input??(c.input=n.value),c.inst??(c.inst=e),n.issues.push(Mr(c))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(s=>(n.value=s,n)):(n.value=o,n)}});function hg(e){return new pg({type:"transform",transform:e})}const dc=v("ZodOptional",(e,t)=>{Qa.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ic(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Xs(e){return new dc({type:"optional",innerType:e})}const fg=v("ZodExactOptional",(e,t)=>{Mp.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ic(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function gg(e){return new fg({type:"optional",innerType:e})}const mg=v("ZodNullable",(e,t)=>{Up.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>sf(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Vs(e){return new mg({type:"nullable",innerType:e})}const bg=v("ZodDefault",(e,t)=>{jp.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>cf(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function kg(e,t){return new bg({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Da(t)}})}const _g=v("ZodPrefault",(e,t)=>{Zp.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>lf(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function vg(e,t){return new _g({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Da(t)}})}const pc=v("ZodNonOptional",(e,t)=>{qp.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>af(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function yg(e,t){return new pc({type:"nonoptional",innerType:e,...D(t)})}const wg=v("ZodCatch",(e,t)=>{Hp.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>uf(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function xg(e,t){return new wg({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const Sg=v("ZodPipe",(e,t)=>{Fp.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>df(e,n,r,o),e.in=t.in,e.out=t.out});function Ys(e,t){return new Sg({type:"pipe",in:e,out:t})}const Tg=v("ZodReadonly",(e,t)=>{Bp.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>pf(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Eg(e){return new Tg({type:"readonly",innerType:e})}const Ag=v("ZodCustom",(e,t)=>{Gp.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Kh(e,n)});function Cg(e,t={}){return Uh(Ag,e,t)}function Pg(e){return jh(e)}const Rg=ue({name:A().min(1).max(100).optional(),command:A().min(1).max(500),args:xt(A()).optional(),failOnError:de().default(!0).optional(),timeout:At().int().min(1e3).max(3e5).default(3e4).optional(),workingDirectory:A().optional(),env:St(A(),A()).optional(),runOnBackground:de().optional()});ue({name:A(),command:A(),success:de(),exitCode:At().optional(),stdout:A().optional(),stderr:A().optional(),error:A().optional(),duration:At(),failOnError:de()});const gn=ue({path:A(),extraCommands:xt(Rg).optional(),id:A().uuid().optional(),rotationKey:A().optional(),usageStatus:st(["free","in_use"]).optional()}),Lg=uc("operation",[gn.extend({operation:it("create"),content:A().optional(),contentPath:A().optional(),encoding:st(["utf-8","base64"]).optional()}),gn.extend({operation:it("merge"),data:St(A(),cc()),mergeStrategy:st(["deep","shallow"]).optional(),arrayMergeStrategy:st(["concat","replace"]).optional()}),gn.extend({operation:it("modify"),content:A().optional(),contentPath:A().optional(),createIfMissing:de().optional()}),gn.extend({operation:it("delete"),ignoreIfMissing:de().optional()}),gn.extend({operation:it("createDirectory"),contentPath:A().optional(),mode:At().optional(),ignoreIfExists:de().optional()}),gn.extend({operation:it("download"),url:A().url(),headers:St(A(),A()).optional(),timeout:At().min(1e3).max(3e5).optional()}),gn.extend({operation:it("gitClone"),gitUrl:A(),gitSecretKey:A().optional(),sourceBranch:A().optional(),targetBranch:A().optional()})]);var xe=(e=>(e.PENDING="pending",e.ASSIGNED="assigned",e.IN_PROGRESS="in_progress",e.WAITING_FOR_INPUT="waiting_for_input",e.WAITING_FOR_PLAN_APPROVAL="waiting_for_plan_approval",e.PLAN_APPROVED="plan_approved",e.PLAN_REJECTED="plan_rejected",e.COMPLETED="completed",e.FAILED="failed",e.CANCELLED="cancelled",e.RESULT_REJECTED="result_rejected",e))(xe||{});const zg=ue({type:st(["json","file","regex"]).describe("Extraction method"),source:A().describe("Source to extract from (file path or stdout/stderr)"),schema:ue({}).passthrough().optional().describe("JSON schema for validation"),pattern:A().optional().describe("Regex pattern for extraction")}),Ig=ue({type:st(["issue_update","bulk_issue_update","notification","webhook"]).describe("Hook type"),config:cc().describe("Hook-specific configuration")});ue({command:A().optional().describe("Legacy — unused in SDK mode"),args:xt(A()).optional().describe("Legacy — unused in SDK mode"),env:St(A(),A()).optional().describe("Environment variables"),workingDirectory:A().optional().describe("Working directory for command execution"),fileOperations:xt(Lg).optional().describe("File operations to perform during setup"),gitUrl:A().optional().describe("Git repository URL (populated from project)"),gitPrivateKey:A().optional().describe("Git SSH private key (populated from project)"),gitCommitMessage:A().optional().describe("Commit message for git operations"),resultExtraction:zg.optional().describe("Schema for extracting result data"),postExecutionHooks:xt(Ig).optional().describe("Hooks to run after task completion"),executionMode:st(["claudeAgentSdk","openaiAgentSdk","opencodeSdk","cursorSdk","codexSdk"]).optional().default("claudeAgentSdk").describe("Execution mode (default: claudeAgentSdk)"),executionPlan:uc("executionMode",[ue({executionMode:it("claudeAgentSdk"),promptText:A(),sdkOptions:ue({model:A(),permissionMode:st(["plan","acceptEdits","bypassPermissions","ask"]),settingSources:xt(A()),allowDangerouslySkipPermissions:de(),persistSession:de(),streamSdkEvents:de().optional(),allowedTools:xt(A()).optional(),settings:ue({enabledPlugins:St(A(),de())}),env:St(A(),A()).optional()}),resume:ue({sessionId:A().optional(),continue:de()}).optional()}),ue({executionMode:it("opencodeSdk"),promptText:A(),sdkOptions:ue({provider:A(),model:A(),env:St(A(),A()).optional()}),resume:ue({sessionId:A().optional(),continue:de()}).optional()}),ue({executionMode:it("openaiAgentSdk"),promptText:A(),sdkOptions:ue({model:A(),env:St(A(),A()).optional()}),resume:ue({sessionId:A().optional(),continue:de()}).optional()}),ue({executionMode:it("codexSdk"),promptText:A(),sdkOptions:ue({model:A().optional(),sandboxMode:st(["read-only","workspace-write","danger-full-access"]).optional(),approvalPolicy:st(["never","on-request","on-failure","untrusted"]).optional(),env:St(A(),A()).optional()}),resume:ue({sessionId:A().optional(),continue:de()}).optional()}),ue({executionMode:it("cursorSdk"),promptText:A(),sdkOptions:ue({model:A(),env:St(A(),A()).optional()}),resume:ue({sessionId:A().optional(),continue:de()}).optional()})]).optional().describe("Backend-built prompt + resolved SDK options for this phase"),planEnabled:de().optional().default(!1).describe("Enable planning phase (computed at runtime for agent)"),planContent:A().optional().describe("Final approved plan content"),planApproved:de().optional().describe("Plan approval status"),planApprovedAt:A().optional().describe("ISO timestamp of approval"),planRejected:de().optional().describe("Plan rejection flag"),planRejectionFeedback:A().optional().describe("User rejection feedback"),rejectedPlanContent:A().optional().describe("Previously rejected plan content"),planCompletedAt:A().optional().describe("ISO timestamp when plan was generated"),planRejectedAt:A().optional().describe("ISO timestamp when plan was rejected"),resultRejectionFeedback:A().optional().describe("User feedback when rejecting the result (most recent)"),resultRejectedAt:A().optional().describe("ISO timestamp when result was rejected (most recent)"),resultRejectionHistory:xt(ue({feedback:A(),rejectedAt:A()})).optional().describe("All rejection messages in chronological order"),notificationChannelPlanMessageId:At().optional(),notificationChannelPlanMessageSentAt:A().optional(),notificationChannelCompletedMessageId:At().optional(),notificationChannelFailedMessageId:At().optional(),streamSdkEvents:de().optional().describe("Stream SDK messages (thinking, tool calls, etc.) as sdk_event chunks"),originalTaskSummary:A().optional().describe("Summary from the original task run (passed to retry for historical context)"),planWasApproved:de().optional().describe("True when planApproved was cleared for rePlan=true retry — indicates the plan had been approved before"),planComments:xt(ue({id:A(),selectedText:A(),startOffset:At(),endOffset:At(),commentText:A(),createdAt:A()})).optional().describe("Inline review comments attached to the plan"),hasAiConfigSecrets:de().optional().describe("True when AI Config has secret-backed env vars; agent must fetch resolved values via /tasks/:id/resolve-secrets"),hasCredentials:de().optional().describe("True when the task has credentials attached; agent must fetch resolved values via /tasks/:id/resolve-credentials"),mcpServersMode:st(["all","ignoreExistingMcpServers"]).optional().describe("MCP server strategy for this run; 'ignoreExistingMcpServers' overrides the existing .mcp.json with only the template's configured servers plus the agent-platform server"),enableBrowserTools:de().optional().describe("When true, the MCP server registers browser_interact and browser_get_context (browser_automate tasks only)")});xe.PENDING+"",xe.CANCELLED,xe.ASSIGNED+"",xe.CANCELLED,xe.IN_PROGRESS+"",xe.CANCELLED,xe.FAILED,xe.WAITING_FOR_INPUT+"",xe.CANCELLED,xe.WAITING_FOR_PLAN_APPROVAL+"",xe.CANCELLED,xe.PLAN_APPROVED+"",xe.CANCELLED,xe.PLAN_REJECTED+"",xe.CANCELLED,xe.COMPLETED+"",xe.RESULT_REJECTED+"",xe.CANCELLED,xe.FAILED+"",xe.CANCELLED+"";const hc="browser_capture",$g="browser_automate";async function je(e,t,n,r){const s=`${e.backendUrl.replace(/\/+$/,"")}/api${n}`,c=await fetch(s,{method:t,headers:{"Content-Type":"application/json",Authorization:`Bearer ${e.token}`},body:r!==void 0?JSON.stringify(r):void 0});if(!c.ok){const u=await c.json().catch(()=>({message:`HTTP ${c.status}`}));throw new Error(u.message||u.error||`HTTP ${c.status}`)}return c.json()}async function fc(e,t){return je(e,"GET",`/projects/by-key/${encodeURIComponent(t)}`)}async function Ti(e,t,n,r,o,s,c=hc,u){var d,p,h,b,m,_;return je(e,"POST","/tasks",{type:c,title:s||n.slice(0,120)||r.pageTitle||"Browser capture",titleInstruction:u??n,projectId:t,autoAssign:!0,...o!=null&&o.claudeTemplateId?{claudeTemplateId:o.claudeTemplateId}:{},...(o==null?void 0:o.quickMode)!==void 0?{quickMode:o.quickMode}:{},...(o==null?void 0:o.modelOverride)!=null?{modelOverride:o.modelOverride}:{},...(o==null?void 0:o.claudeProfileId)!=null?{claudeProfileId:o.claudeProfileId}:{},...(o==null?void 0:o.effort)!=null?{effort:o.effort}:{},...(o==null?void 0:o.executionMode)!=null?{executionMode:o.executionMode}:{},...(d=o==null?void 0:o.selectedPluginIds)!=null&&d.length?{selectedPluginIds:o.selectedPluginIds}:{},...(p=o==null?void 0:o.selectedSkillIds)!=null&&p.length?{selectedSkillIds:o.selectedSkillIds}:{},...(h=o==null?void 0:o.selectedPluginSkillIds)!=null&&h.length?{selectedPluginSkillIds:o.selectedPluginSkillIds}:{},...(b=o==null?void 0:o.selectedMcpServerIds)!=null&&b.length?{selectedMcpServerIds:o.selectedMcpServerIds}:{},...(m=o==null?void 0:o.selectedSlashCommandIds)!=null&&m.length?{selectedSlashCommandIds:o.selectedSlashCommandIds}:{},...(_=o==null?void 0:o.selectedRemoteContextProviderIds)!=null&&_.length?{selectedRemoteContextProviderIds:o.selectedRemoteContextProviderIds}:{},metadata:{type:c,note:n,source:"web-sdk",pageUrl:r.pageUrl,pageTitle:r.pageTitle,elementText:r.elementText,cssSelector:r.cssSelector,elementOuterHtml:r.elementOuterHtml,ancestry:r.ancestry,elementRole:r.elementRole,elementAriaLabel:r.elementAriaLabel,enclosingSection:r.enclosingSection,description:r.description,canonicalUrl:r.canonicalUrl,lang:r.lang,ogTitle:r.ogTitle,ogDescription:r.ogDescription,ogType:r.ogType,ogSiteName:r.ogSiteName,viewportWidth:r.viewportWidth,viewportHeight:r.viewportHeight,scrollX:r.scrollX,scrollY:r.scrollY,selectionText:r.selectionText,capturedAt:r.capturedAt,interactionSteps:r.interactionSteps}})}async function Ks(e,t,n,r,o,s,c){return Ti(e,t,n,r,o,s,$g,c)}async function Qs(e,t,n,r){return je(e,"POST","/planning-sessions",{projectId:t,instruction:n,quickMode:(r==null?void 0:r.quickMode)??!1,...r!=null&&r.claudeTemplateId?{claudeTemplateId:r.claudeTemplateId}:{}})}async function Ng(e,t){const n=t?`?projectId=${encodeURIComponent(t)}`:"";return je(e,"GET",`/claude-templates${n}`)}async function gc(e,t){return je(e,"GET",`/tasks/${t}`)}async function Og(e,t){return je(e,"GET",`/planning-sessions/${t}`)}async function Dg(e){return je(e,"GET","/projects")}async function Mg(e,t){return je(e,"GET",`/tasks/${t}/browser-commands/pending`)}async function Ug(e,t,n,r,o){return je(e,"POST",`/tasks/${t}/browser-commands/${n}/result`,{status:r,message:o})}async function jg(e,t){return je(e,"GET",`/tasks/${t}/chunks`)}async function Zg(e,t,n){return je(e,"POST",`/tasks/${t}/instructions`,{content:n})}async function qg(e,t){return je(e,"POST",`/tasks/${t}/cancel`)}async function Hg(e,t){return je(e,"POST",`/tasks/${t}/approve-result`)}async function Fg(e,t,n){return je(e,"POST",`/tasks/${t}/reject-result`,{feedback:n})}async function Oo(e,t){return je(e,"GET",`/tasks/${t}/interactions?filter=unanswered`)}async function mc(e,t,n,r){return je(e,"POST",`/tasks/${t}/interactions/${n}/answer`,{answer:r})}const bc=/^cc-|current-password|new-password/i,Bg=/token|secret|password|apikey|auth/i,pi="[redacted]";function Gg(e){if(e instanceof HTMLInputElement&&e.type==="password")return!0;const t=e.getAttribute("autocomplete");return!!t&&bc.test(t)}function Wg(e){const t=[e,...Array.from(e.querySelectorAll("*"))];for(const n of t){n instanceof HTMLInputElement&&n.type==="password"&&n.setAttribute("value",pi);const r=n.getAttribute("autocomplete");r&&bc.test(r)&&n.setAttribute("value",pi);for(const o of Array.from(n.attributes))Bg.test(o.name)&&n.setAttribute(o.name,pi)}}function Jg(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var kc={exports:{}};/*!
1385
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const p of e.seen.entries()){const b=p[1];if(t===p[0]){s(p);continue}if(e.external){const _=(d=e.external.registry.get(p[0]))==null?void 0:d.id;if(t!==p[0]&&_){s(p);continue}}if((h=e.metadataRegistry.get(p[0]))==null?void 0:h.id){s(p);continue}if(b.cycle){s(p);continue}if(b.count>1&&e.reused==="ref"){s(p);continue}}}function ec(e,t){var a,u,d;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=h=>{const p=e.seen.get(h);if(p.ref===null)return;const b=p.def??p.schema,m={...b},_=p.ref;if(p.ref=null,_){r(_);const C=e.seen.get(_),M=C.schema;if(M.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(b.allOf=b.allOf??[],b.allOf.push(M)):Object.assign(b,M),Object.assign(b,m),h._zod.parent===_)for(const P in b)P==="$ref"||P==="allOf"||P in m||delete b[P];if(M.$ref)for(const P in b)P==="$ref"||P==="allOf"||P in C.def&&JSON.stringify(b[P])===JSON.stringify(C.def[P])&&delete b[P]}const w=h._zod.parent;if(w&&w!==_){r(w);const C=e.seen.get(w);if(C!=null&&C.schema.$ref&&(b.$ref=C.schema.$ref,C.def))for(const M in b)M==="$ref"||M==="allOf"||M in C.def&&JSON.stringify(b[M])===JSON.stringify(C.def[M])&&delete b[M]}e.override({zodSchema:h,jsonSchema:b,path:p.path??[]})};for(const h of[...e.seen.entries()].reverse())r(h[0]);const o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":e.target,(a=e.external)!=null&&a.uri){const h=(u=e.external.registry.get(t))==null?void 0:u.id;if(!h)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(h)}Object.assign(o,n.def??n.schema);const s=((d=e.external)==null?void 0:d.defs)??{};for(const h of e.seen.entries()){const p=h[1];p.def&&p.defId&&(s[p.defId]=p.def)}e.external||Object.keys(s).length>0&&(e.target==="draft-2020-12"?o.$defs=s:o.definitions=s);try{const h=JSON.parse(JSON.stringify(o));return Object.defineProperty(h,"~standard",{value:{...t["~standard"],jsonSchema:{input:Lo(t,"input",e.processors),output:Lo(t,"output",e.processors)}},enumerable:!1,writable:!1}),h}catch{throw new Error("Error converting schema to JSON.")}}function Ge(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return Ge(r.element,n);if(r.type==="set")return Ge(r.valueType,n);if(r.type==="lazy")return Ge(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return Ge(r.innerType,n);if(r.type==="intersection")return Ge(r.left,n)||Ge(r.right,n);if(r.type==="record"||r.type==="map")return Ge(r.keyType,n)||Ge(r.valueType,n);if(r.type==="pipe")return Ge(r.in,n)||Ge(r.out,n);if(r.type==="object"){for(const o in r.shape)if(Ge(r.shape[o],n))return!0;return!1}if(r.type==="union"){for(const o of r.options)if(Ge(o,n))return!0;return!1}if(r.type==="tuple"){for(const o of r.items)if(Ge(o,n))return!0;return!!(r.rest&&Ge(r.rest,n))}return!1}const Mh=(e,t={})=>n=>{const r=Ka({...n,processors:t});return Te(e,r),Qa(r,e),ec(r,e)},Lo=(e,t,n={})=>r=>{const{libraryOptions:o,target:s}=r??{},a=Ka({...o??{},target:s,io:t,processors:n});return Te(e,a),Qa(a,e),ec(a,e)},Uh={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},jh=(e,t,n,r)=>{const o=n;o.type="string";const{minimum:s,maximum:a,format:u,patterns:d,contentEncoding:h}=e._zod.bag;if(typeof s=="number"&&(o.minLength=s),typeof a=="number"&&(o.maxLength=a),u&&(o.format=Uh[u]??u,o.format===""&&delete o.format,u==="time"&&delete o.format),h&&(o.contentEncoding=h),d&&d.size>0){const p=[...d];p.length===1?o.pattern=p[0].source:p.length>1&&(o.allOf=[...p.map(b=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:b.source}))])}},Zh=(e,t,n,r)=>{const o=n,{minimum:s,maximum:a,format:u,multipleOf:d,exclusiveMaximum:h,exclusiveMinimum:p}=e._zod.bag;typeof u=="string"&&u.includes("int")?o.type="integer":o.type="number",typeof p=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(o.minimum=p,o.exclusiveMinimum=!0):o.exclusiveMinimum=p),typeof s=="number"&&(o.minimum=s,typeof p=="number"&&t.target!=="draft-04"&&(p>=s?delete o.minimum:delete o.exclusiveMinimum)),typeof h=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(o.maximum=h,o.exclusiveMaximum=!0):o.exclusiveMaximum=h),typeof a=="number"&&(o.maximum=a,typeof h=="number"&&t.target!=="draft-04"&&(h<=a?delete o.maximum:delete o.exclusiveMaximum)),typeof d=="number"&&(o.multipleOf=d)},qh=(e,t,n,r)=>{n.type="boolean"},Hh=(e,t,n,r)=>{n.not={}},Fh=(e,t,n,r)=>{},Bh=(e,t,n,r)=>{},Gh=(e,t,n,r)=>{const o=e._zod.def,s=La(o.entries);s.every(a=>typeof a=="number")&&(n.type="number"),s.every(a=>typeof a=="string")&&(n.type="string"),n.enum=s},Wh=(e,t,n,r)=>{const o=e._zod.def,s=[];for(const a of o.values)if(a===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof a=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");s.push(Number(a))}else s.push(a);if(s.length!==0)if(s.length===1){const a=s[0];n.type=a===null?"null":typeof a,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[a]:n.const=a}else s.every(a=>typeof a=="number")&&(n.type="number"),s.every(a=>typeof a=="string")&&(n.type="string"),s.every(a=>typeof a=="boolean")&&(n.type="boolean"),s.every(a=>a===null)&&(n.type="null"),n.enum=s},Jh=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},Xh=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Vh=(e,t,n,r)=>{const o=n,s=e._zod.def,{minimum:a,maximum:u}=e._zod.bag;typeof a=="number"&&(o.minItems=a),typeof u=="number"&&(o.maxItems=u),o.type="array",o.items=Te(s.element,t,{...r,path:[...r.path,"items"]})},Yh=(e,t,n,r)=>{var h;const o=n,s=e._zod.def;o.type="object",o.properties={};const a=s.shape;for(const p in a)o.properties[p]=Te(a[p],t,{...r,path:[...r.path,"properties",p]});const u=new Set(Object.keys(a)),d=new Set([...u].filter(p=>{const b=s.shape[p]._zod;return t.io==="input"?b.optin===void 0:b.optout===void 0}));d.size>0&&(o.required=Array.from(d)),((h=s.catchall)==null?void 0:h._zod.def.type)==="never"?o.additionalProperties=!1:s.catchall?s.catchall&&(o.additionalProperties=Te(s.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},Kh=(e,t,n,r)=>{const o=e._zod.def,s=o.inclusive===!1,a=o.options.map((u,d)=>Te(u,t,{...r,path:[...r.path,s?"oneOf":"anyOf",d]}));s?n.oneOf=a:n.anyOf=a},Qh=(e,t,n,r)=>{const o=e._zod.def,s=Te(o.left,t,{...r,path:[...r.path,"allOf",0]}),a=Te(o.right,t,{...r,path:[...r.path,"allOf",1]}),u=h=>"allOf"in h&&Object.keys(h).length===1,d=[...u(s)?s.allOf:[s],...u(a)?a.allOf:[a]];n.allOf=d},ef=(e,t,n,r)=>{const o=n,s=e._zod.def;o.type="object";const a=s.keyType,u=a._zod.bag,d=u==null?void 0:u.patterns;if(s.mode==="loose"&&d&&d.size>0){const p=Te(s.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});o.patternProperties={};for(const b of d)o.patternProperties[b.source]=p}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(o.propertyNames=Te(s.keyType,t,{...r,path:[...r.path,"propertyNames"]})),o.additionalProperties=Te(s.valueType,t,{...r,path:[...r.path,"additionalProperties"]});const h=a._zod.values;if(h){const p=[...h].filter(b=>typeof b=="string"||typeof b=="number");p.length>0&&(o.required=p)}},tf=(e,t,n,r)=>{const o=e._zod.def,s=Te(o.innerType,t,r),a=t.seen.get(e);t.target==="openapi-3.0"?(a.ref=o.innerType,n.nullable=!0):n.anyOf=[s,{type:"null"}]},nf=(e,t,n,r)=>{const o=e._zod.def;Te(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType},rf=(e,t,n,r)=>{const o=e._zod.def;Te(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType,n.default=JSON.parse(JSON.stringify(o.defaultValue))},of=(e,t,n,r)=>{const o=e._zod.def;Te(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},sf=(e,t,n,r)=>{const o=e._zod.def;Te(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType;let a;try{a=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=a},af=(e,t,n,r)=>{const o=e._zod.def,s=t.io==="input"?o.in._zod.def.type==="transform"?o.out:o.in:o.out;Te(s,t,r);const a=t.seen.get(e);a.ref=s},cf=(e,t,n,r)=>{const o=e._zod.def;Te(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType,n.readOnly=!0},tc=(e,t,n,r)=>{const o=e._zod.def;Te(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType},lf=v("ZodISODateTime",(e,t)=>{sp.init(e,t),ke.init(e,t)});function uf(e){return hh(lf,e)}const df=v("ZodISODate",(e,t)=>{ap.init(e,t),ke.init(e,t)});function pf(e){return fh(df,e)}const hf=v("ZodISOTime",(e,t)=>{cp.init(e,t),ke.init(e,t)});function ff(e){return gh(hf,e)}const gf=v("ZodISODuration",(e,t)=>{lp.init(e,t),ke.init(e,t)});function mf(e){return mh(gf,e)}const bf=(e,t)=>{Na.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>Qu(e,n)},flatten:{value:n=>Ku(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,_i,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,_i,2)}},isEmpty:{get(){return e.issues.length===0}}})},dt=v("ZodError",bf,{Parent:Error}),kf=Di(dt),_f=Mi(dt),vf=Bo(dt),yf=Go(dt),wf=nd(dt),xf=rd(dt),Sf=od(dt),Tf=id(dt),Ef=sd(dt),Af=ad(dt),Cf=cd(dt),Pf=ld(dt),be=v("ZodType",(e,t)=>(ge.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Lo(e,"input"),output:Lo(e,"output")}}),e.toJSONSchema=Mh(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(on(t,{checks:[...t.checks??[],...n.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0}),e.with=e.check,e.clone=(n,r)=>sn(e,n,r),e.brand=()=>e,e.register=(n,r)=>(n.add(e,r),e),e.parse=(n,r)=>kf(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>vf(e,n,r),e.parseAsync=async(n,r)=>_f(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>yf(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>wf(e,n,r),e.decode=(n,r)=>xf(e,n,r),e.encodeAsync=async(n,r)=>Sf(e,n,r),e.decodeAsync=async(n,r)=>Tf(e,n,r),e.safeEncode=(n,r)=>Ef(e,n,r),e.safeDecode=(n,r)=>Af(e,n,r),e.safeEncodeAsync=async(n,r)=>Cf(e,n,r),e.safeDecodeAsync=async(n,r)=>Pf(e,n,r),e.refine=(n,r)=>e.check(Sg(n,r)),e.superRefine=n=>e.check(Tg(n)),e.overwrite=n=>e.check(nr(n)),e.optional=()=>Bs(e),e.exactOptional=()=>dg(e),e.nullable=()=>Gs(e),e.nullish=()=>Bs(Gs(e)),e.nonoptional=n=>bg(e,n),e.array=()=>Et(e),e.or=n=>ng([e,n]),e.and=n=>ig(e,n),e.transform=n=>Ws(e,lg(n)),e.default=n=>fg(e,n),e.prefault=n=>mg(e,n),e.catch=n=>_g(e,n),e.pipe=n=>Ws(e,n),e.readonly=()=>wg(e),e.describe=n=>{const r=e.clone();return Er.add(r,{description:n}),r},Object.defineProperty(e,"description",{get(){var n;return(n=Er.get(e))==null?void 0:n.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return Er.get(e);const r=e.clone();return Er.add(r,n[0]),r},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),nc=v("_ZodString",(e,t)=>{Ui.init(e,t),be.init(e,t),e._zod.processJSONSchema=(r,o,s)=>jh(e,r,o);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...r)=>e.check(xh(...r)),e.includes=(...r)=>e.check(Eh(...r)),e.startsWith=(...r)=>e.check(Ah(...r)),e.endsWith=(...r)=>e.check(Ch(...r)),e.min=(...r)=>e.check(Ro(...r)),e.max=(...r)=>e.check(Va(...r)),e.length=(...r)=>e.check(Ya(...r)),e.nonempty=(...r)=>e.check(Ro(1,...r)),e.lowercase=r=>e.check(Sh(r)),e.uppercase=r=>e.check(Th(r)),e.trim=()=>e.check(Rh()),e.normalize=(...r)=>e.check(Ph(...r)),e.toLowerCase=()=>e.check(Lh()),e.toUpperCase=()=>e.check(zh()),e.slugify=()=>e.check(Ih())}),Rf=v("ZodString",(e,t)=>{Ui.init(e,t),nc.init(e,t),e.email=n=>e.check(Gp(Lf,n)),e.url=n=>e.check(Yp(zf,n)),e.jwt=n=>e.check(ph(Wf,n)),e.emoji=n=>e.check(Kp(If,n)),e.guid=n=>e.check(Ms(qs,n)),e.uuid=n=>e.check(Wp(io,n)),e.uuidv4=n=>e.check(Jp(io,n)),e.uuidv6=n=>e.check(Xp(io,n)),e.uuidv7=n=>e.check(Vp(io,n)),e.nanoid=n=>e.check(Qp($f,n)),e.guid=n=>e.check(Ms(qs,n)),e.cuid=n=>e.check(eh(Nf,n)),e.cuid2=n=>e.check(th(Of,n)),e.ulid=n=>e.check(nh(Df,n)),e.base64=n=>e.check(lh(Ff,n)),e.base64url=n=>e.check(uh(Bf,n)),e.xid=n=>e.check(rh(Mf,n)),e.ksuid=n=>e.check(oh(Uf,n)),e.ipv4=n=>e.check(ih(jf,n)),e.ipv6=n=>e.check(sh(Zf,n)),e.cidrv4=n=>e.check(ah(qf,n)),e.cidrv6=n=>e.check(ch(Hf,n)),e.e164=n=>e.check(dh(Gf,n)),e.datetime=n=>e.check(uf(n)),e.date=n=>e.check(pf(n)),e.time=n=>e.check(ff(n)),e.duration=n=>e.check(mf(n))});function A(e){return Bp(Rf,e)}const ke=v("ZodStringFormat",(e,t)=>{me.init(e,t),nc.init(e,t)}),Lf=v("ZodEmail",(e,t)=>{Yd.init(e,t),ke.init(e,t)}),qs=v("ZodGUID",(e,t)=>{Xd.init(e,t),ke.init(e,t)}),io=v("ZodUUID",(e,t)=>{Vd.init(e,t),ke.init(e,t)}),zf=v("ZodURL",(e,t)=>{Kd.init(e,t),ke.init(e,t)}),If=v("ZodEmoji",(e,t)=>{Qd.init(e,t),ke.init(e,t)}),$f=v("ZodNanoID",(e,t)=>{ep.init(e,t),ke.init(e,t)}),Nf=v("ZodCUID",(e,t)=>{tp.init(e,t),ke.init(e,t)}),Of=v("ZodCUID2",(e,t)=>{np.init(e,t),ke.init(e,t)}),Df=v("ZodULID",(e,t)=>{rp.init(e,t),ke.init(e,t)}),Mf=v("ZodXID",(e,t)=>{op.init(e,t),ke.init(e,t)}),Uf=v("ZodKSUID",(e,t)=>{ip.init(e,t),ke.init(e,t)}),jf=v("ZodIPv4",(e,t)=>{up.init(e,t),ke.init(e,t)}),Zf=v("ZodIPv6",(e,t)=>{dp.init(e,t),ke.init(e,t)}),qf=v("ZodCIDRv4",(e,t)=>{pp.init(e,t),ke.init(e,t)}),Hf=v("ZodCIDRv6",(e,t)=>{hp.init(e,t),ke.init(e,t)}),Ff=v("ZodBase64",(e,t)=>{fp.init(e,t),ke.init(e,t)}),Bf=v("ZodBase64URL",(e,t)=>{mp.init(e,t),ke.init(e,t)}),Gf=v("ZodE164",(e,t)=>{bp.init(e,t),ke.init(e,t)}),Wf=v("ZodJWT",(e,t)=>{_p.init(e,t),ke.init(e,t)}),rc=v("ZodNumber",(e,t)=>{Ba.init(e,t),be.init(e,t),e._zod.processJSONSchema=(r,o,s)=>Zh(e,r,o),e.gt=(r,o)=>e.check(js(r,o)),e.gte=(r,o)=>e.check(ci(r,o)),e.min=(r,o)=>e.check(ci(r,o)),e.lt=(r,o)=>e.check(Us(r,o)),e.lte=(r,o)=>e.check(ai(r,o)),e.max=(r,o)=>e.check(ai(r,o)),e.int=r=>e.check(Hs(r)),e.safe=r=>e.check(Hs(r)),e.positive=r=>e.check(js(0,r)),e.nonnegative=r=>e.check(ci(0,r)),e.negative=r=>e.check(Us(0,r)),e.nonpositive=r=>e.check(ai(0,r)),e.multipleOf=(r,o)=>e.check(Zs(r,o)),e.step=(r,o)=>e.check(Zs(r,o)),e.finite=()=>e;const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function Rt(e){return bh(rc,e)}const Jf=v("ZodNumberFormat",(e,t)=>{vp.init(e,t),rc.init(e,t)});function Hs(e){return kh(Jf,e)}const Xf=v("ZodBoolean",(e,t)=>{yp.init(e,t),be.init(e,t),e._zod.processJSONSchema=(n,r,o)=>qh(e,n,r)});function he(e){return _h(Xf,e)}const Vf=v("ZodAny",(e,t)=>{wp.init(e,t),be.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Fh()});function oc(){return vh(Vf)}const Yf=v("ZodUnknown",(e,t)=>{xp.init(e,t),be.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Bh()});function Fs(){return yh(Yf)}const Kf=v("ZodNever",(e,t)=>{Sp.init(e,t),be.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Hh(e,n,r)});function Qf(e){return wh(Kf,e)}const eg=v("ZodArray",(e,t)=>{Tp.init(e,t),be.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Vh(e,n,r,o),e.element=t.element,e.min=(n,r)=>e.check(Ro(n,r)),e.nonempty=n=>e.check(Ro(1,n)),e.max=(n,r)=>e.check(Va(n,r)),e.length=(n,r)=>e.check(Ya(n,r)),e.unwrap=()=>e.element});function Et(e,t){return $h(eg,e,t)}const tg=v("ZodObject",(e,t)=>{Ap.init(e,t),be.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Yh(e,n,r,o),Q(e,"shape",()=>t.shape),e.keyof=()=>ct(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Fs()}),e.loose=()=>e.clone({...e._zod.def,catchall:Fs()}),e.strict=()=>e.clone({...e._zod.def,catchall:Qf()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>Wu(e,n),e.safeExtend=n=>Ju(e,n),e.merge=n=>Xu(e,n),e.pick=n=>Bu(e,n),e.omit=n=>Gu(e,n),e.partial=(...n)=>Vu(ac,e,n[0]),e.required=(...n)=>Yu(cc,e,n[0])});function pe(e,t){const n={type:"object",shape:e??{},...O(t)};return new tg(n)}const ic=v("ZodUnion",(e,t)=>{Ja.init(e,t),be.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Kh(e,n,r,o),e.options=t.options});function ng(e,t){return new ic({type:"union",options:e,...O(t)})}const rg=v("ZodDiscriminatedUnion",(e,t)=>{ic.init(e,t),Cp.init(e,t)});function sc(e,t,n){return new rg({type:"union",options:t,discriminator:e,...O(n)})}const og=v("ZodIntersection",(e,t)=>{Pp.init(e,t),be.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Qh(e,n,r,o)});function ig(e,t){return new og({type:"intersection",left:e,right:t})}const sg=v("ZodRecord",(e,t)=>{Rp.init(e,t),be.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ef(e,n,r,o),e.keyType=t.keyType,e.valueType=t.valueType});function At(e,t,n){return new sg({type:"record",keyType:e,valueType:t,...O(n)})}const yi=v("ZodEnum",(e,t)=>{Lp.init(e,t),be.init(e,t),e._zod.processJSONSchema=(r,o,s)=>Gh(e,r,o),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(r,o)=>{const s={};for(const a of r)if(n.has(a))s[a]=t.entries[a];else throw new Error(`Key ${a} not found in enum`);return new yi({...t,checks:[],...O(o),entries:s})},e.exclude=(r,o)=>{const s={...t.entries};for(const a of r)if(n.has(a))delete s[a];else throw new Error(`Key ${a} not found in enum`);return new yi({...t,checks:[],...O(o),entries:s})}});function ct(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new yi({type:"enum",entries:n,...O(t)})}const ag=v("ZodLiteral",(e,t)=>{zp.init(e,t),be.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Wh(e,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function at(e,t){return new ag({type:"literal",values:Array.isArray(e)?e:[e],...O(t)})}const cg=v("ZodTransform",(e,t)=>{Ip.init(e,t),be.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Xh(e,n),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Pa(e.constructor.name);n.addIssue=s=>{if(typeof s=="string")n.issues.push(Nr(s,n.value,t));else{const a=s;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),a.input??(a.input=n.value),a.inst??(a.inst=e),n.issues.push(Nr(a))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(s=>(n.value=s,n)):(n.value=o,n)}});function lg(e){return new cg({type:"transform",transform:e})}const ac=v("ZodOptional",(e,t)=>{Xa.init(e,t),be.init(e,t),e._zod.processJSONSchema=(n,r,o)=>tc(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Bs(e){return new ac({type:"optional",innerType:e})}const ug=v("ZodExactOptional",(e,t)=>{$p.init(e,t),be.init(e,t),e._zod.processJSONSchema=(n,r,o)=>tc(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function dg(e){return new ug({type:"optional",innerType:e})}const pg=v("ZodNullable",(e,t)=>{Np.init(e,t),be.init(e,t),e._zod.processJSONSchema=(n,r,o)=>tf(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Gs(e){return new pg({type:"nullable",innerType:e})}const hg=v("ZodDefault",(e,t)=>{Op.init(e,t),be.init(e,t),e._zod.processJSONSchema=(n,r,o)=>rf(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function fg(e,t){return new hg({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Ia(t)}})}const gg=v("ZodPrefault",(e,t)=>{Dp.init(e,t),be.init(e,t),e._zod.processJSONSchema=(n,r,o)=>of(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function mg(e,t){return new gg({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Ia(t)}})}const cc=v("ZodNonOptional",(e,t)=>{Mp.init(e,t),be.init(e,t),e._zod.processJSONSchema=(n,r,o)=>nf(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function bg(e,t){return new cc({type:"nonoptional",innerType:e,...O(t)})}const kg=v("ZodCatch",(e,t)=>{Up.init(e,t),be.init(e,t),e._zod.processJSONSchema=(n,r,o)=>sf(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function _g(e,t){return new kg({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const vg=v("ZodPipe",(e,t)=>{jp.init(e,t),be.init(e,t),e._zod.processJSONSchema=(n,r,o)=>af(e,n,r,o),e.in=t.in,e.out=t.out});function Ws(e,t){return new vg({type:"pipe",in:e,out:t})}const yg=v("ZodReadonly",(e,t)=>{Zp.init(e,t),be.init(e,t),e._zod.processJSONSchema=(n,r,o)=>cf(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function wg(e){return new yg({type:"readonly",innerType:e})}const xg=v("ZodCustom",(e,t)=>{qp.init(e,t),be.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Jh(e,n)});function Sg(e,t={}){return Nh(xg,e,t)}function Tg(e){return Oh(e)}const Eg=pe({name:A().min(1).max(100).optional(),command:A().min(1).max(500),args:Et(A()).optional(),failOnError:he().default(!0).optional(),timeout:Rt().int().min(1e3).max(3e5).default(3e4).optional(),workingDirectory:A().optional(),env:At(A(),A()).optional(),runOnBackground:he().optional()});pe({name:A(),command:A(),success:he(),exitCode:Rt().optional(),stdout:A().optional(),stderr:A().optional(),error:A().optional(),duration:Rt(),failOnError:he()});const gn=pe({path:A(),extraCommands:Et(Eg).optional(),id:A().uuid().optional(),rotationKey:A().optional(),usageStatus:ct(["free","in_use"]).optional()}),Ag=sc("operation",[gn.extend({operation:at("create"),content:A().optional(),contentPath:A().optional(),encoding:ct(["utf-8","base64"]).optional()}),gn.extend({operation:at("merge"),data:At(A(),oc()),mergeStrategy:ct(["deep","shallow"]).optional(),arrayMergeStrategy:ct(["concat","replace"]).optional()}),gn.extend({operation:at("modify"),content:A().optional(),contentPath:A().optional(),createIfMissing:he().optional()}),gn.extend({operation:at("delete"),ignoreIfMissing:he().optional()}),gn.extend({operation:at("createDirectory"),contentPath:A().optional(),mode:Rt().optional(),ignoreIfExists:he().optional()}),gn.extend({operation:at("download"),url:A().url(),headers:At(A(),A()).optional(),timeout:Rt().min(1e3).max(3e5).optional()}),gn.extend({operation:at("gitClone"),gitUrl:A(),gitSecretKey:A().optional(),sourceBranch:A().optional(),targetBranch:A().optional()})]);var ye=(e=>(e.PENDING="pending",e.ASSIGNED="assigned",e.IN_PROGRESS="in_progress",e.WAITING_FOR_INPUT="waiting_for_input",e.WAITING_FOR_PLAN_APPROVAL="waiting_for_plan_approval",e.PLAN_APPROVED="plan_approved",e.PLAN_REJECTED="plan_rejected",e.COMPLETED="completed",e.FAILED="failed",e.CANCELLED="cancelled",e.RESULT_REJECTED="result_rejected",e))(ye||{});const Cg=pe({type:ct(["json","file","regex"]).describe("Extraction method"),source:A().describe("Source to extract from (file path or stdout/stderr)"),schema:pe({}).passthrough().optional().describe("JSON schema for validation"),pattern:A().optional().describe("Regex pattern for extraction")}),Pg=pe({type:ct(["issue_update","bulk_issue_update","notification","webhook"]).describe("Hook type"),config:oc().describe("Hook-specific configuration")});pe({command:A().optional().describe("Legacy — unused in SDK mode"),args:Et(A()).optional().describe("Legacy — unused in SDK mode"),env:At(A(),A()).optional().describe("Environment variables"),workingDirectory:A().optional().describe("Working directory for command execution"),fileOperations:Et(Ag).optional().describe("File operations to perform during setup"),gitUrl:A().optional().describe("Git repository URL (populated from project)"),gitPrivateKey:A().optional().describe("Git SSH private key (populated from project)"),gitCommitMessage:A().optional().describe("Commit message for git operations"),resultExtraction:Cg.optional().describe("Schema for extracting result data"),postExecutionHooks:Et(Pg).optional().describe("Hooks to run after task completion"),executionMode:ct(["claudeAgentSdk","openaiAgentSdk","opencodeSdk","cursorSdk","codexSdk"]).optional().default("claudeAgentSdk").describe("Execution mode (default: claudeAgentSdk)"),executionPlan:sc("executionMode",[pe({executionMode:at("claudeAgentSdk"),promptText:A(),sdkOptions:pe({model:A(),permissionMode:ct(["plan","acceptEdits","bypassPermissions","ask"]),settingSources:Et(A()),allowDangerouslySkipPermissions:he(),persistSession:he(),streamSdkEvents:he().optional(),allowedTools:Et(A()).optional(),settings:pe({enabledPlugins:At(A(),he())}),env:At(A(),A()).optional()}),resume:pe({sessionId:A().optional(),continue:he()}).optional()}),pe({executionMode:at("opencodeSdk"),promptText:A(),sdkOptions:pe({provider:A(),model:A(),env:At(A(),A()).optional()}),resume:pe({sessionId:A().optional(),continue:he()}).optional()}),pe({executionMode:at("openaiAgentSdk"),promptText:A(),sdkOptions:pe({model:A(),env:At(A(),A()).optional()}),resume:pe({sessionId:A().optional(),continue:he()}).optional()}),pe({executionMode:at("codexSdk"),promptText:A(),sdkOptions:pe({model:A().optional(),sandboxMode:ct(["read-only","workspace-write","danger-full-access"]).optional(),approvalPolicy:ct(["never","on-request","on-failure","untrusted"]).optional(),env:At(A(),A()).optional()}),resume:pe({sessionId:A().optional(),continue:he()}).optional()}),pe({executionMode:at("cursorSdk"),promptText:A(),sdkOptions:pe({model:A(),env:At(A(),A()).optional()}),resume:pe({sessionId:A().optional(),continue:he()}).optional()})]).optional().describe("Backend-built prompt + resolved SDK options for this phase"),planEnabled:he().optional().default(!1).describe("Enable planning phase (computed at runtime for agent)"),planContent:A().optional().describe("Final approved plan content"),planApproved:he().optional().describe("Plan approval status"),planApprovedAt:A().optional().describe("ISO timestamp of approval"),planRejected:he().optional().describe("Plan rejection flag"),planRejectionFeedback:A().optional().describe("User rejection feedback"),rejectedPlanContent:A().optional().describe("Previously rejected plan content"),planCompletedAt:A().optional().describe("ISO timestamp when plan was generated"),planRejectedAt:A().optional().describe("ISO timestamp when plan was rejected"),resultRejectionFeedback:A().optional().describe("User feedback when rejecting the result (most recent)"),resultRejectedAt:A().optional().describe("ISO timestamp when result was rejected (most recent)"),resultRejectionHistory:Et(pe({feedback:A(),rejectedAt:A()})).optional().describe("All rejection messages in chronological order"),notificationChannelPlanMessageId:Rt().optional(),notificationChannelPlanMessageSentAt:A().optional(),notificationChannelCompletedMessageId:Rt().optional(),notificationChannelFailedMessageId:Rt().optional(),streamSdkEvents:he().optional().describe("Stream SDK messages (thinking, tool calls, etc.) as sdk_event chunks"),originalTaskSummary:A().optional().describe("Summary from the original task run (passed to retry for historical context)"),planWasApproved:he().optional().describe("True when planApproved was cleared for rePlan=true retry — indicates the plan had been approved before"),planComments:Et(pe({id:A(),selectedText:A(),startOffset:Rt(),endOffset:Rt(),commentText:A(),createdAt:A()})).optional().describe("Inline review comments attached to the plan"),hasAiConfigSecrets:he().optional().describe("True when AI Config has secret-backed env vars; agent must fetch resolved values via /tasks/:id/resolve-secrets"),hasCredentials:he().optional().describe("True when the task has credentials attached; agent must fetch resolved values via /tasks/:id/resolve-credentials"),mcpServersMode:ct(["all","ignoreExistingMcpServers"]).optional().describe("MCP server strategy for this run; 'ignoreExistingMcpServers' overrides the existing .mcp.json with only the template's configured servers plus the agent-platform server"),enableBrowserTools:he().optional().describe("When true, the MCP server registers browser_interact and browser_get_context (browser_automate tasks only)")});ye.PENDING+"",ye.CANCELLED,ye.ASSIGNED+"",ye.CANCELLED,ye.IN_PROGRESS+"",ye.CANCELLED,ye.FAILED,ye.WAITING_FOR_INPUT+"",ye.CANCELLED,ye.WAITING_FOR_PLAN_APPROVAL+"",ye.CANCELLED,ye.PLAN_APPROVED+"",ye.CANCELLED,ye.PLAN_REJECTED+"",ye.CANCELLED,ye.COMPLETED+"",ye.RESULT_REJECTED+"",ye.CANCELLED,ye.FAILED+"",ye.CANCELLED+"";const lc="browser_capture",Rg="browser_automate";async function Ze(e,t,n,r){const s=`${e.backendUrl.replace(/\/+$/,"")}/api${n}`,a=await fetch(s,{method:t,headers:{"Content-Type":"application/json",Authorization:`Bearer ${e.token}`},body:r!==void 0?JSON.stringify(r):void 0});if(!a.ok){const u=await a.json().catch(()=>({message:`HTTP ${a.status}`}));throw new Error(u.message||u.error||`HTTP ${a.status}`)}return a.json()}async function uc(e,t){return Ze(e,"GET",`/projects/by-key/${encodeURIComponent(t)}`)}async function wi(e,t,n,r,o,s,a=lc,u){var d,h,p,b,m,_;return Ze(e,"POST","/tasks",{type:a,title:s||n.slice(0,120)||r.pageTitle||"Browser capture",titleInstruction:u??n,projectId:t,autoAssign:!0,...o!=null&&o.claudeTemplateId?{claudeTemplateId:o.claudeTemplateId}:{},...(o==null?void 0:o.quickMode)!==void 0?{quickMode:o.quickMode}:{},...(o==null?void 0:o.modelOverride)!=null?{modelOverride:o.modelOverride}:{},...(o==null?void 0:o.claudeProfileId)!=null?{claudeProfileId:o.claudeProfileId}:{},...(o==null?void 0:o.effort)!=null?{effort:o.effort}:{},...(o==null?void 0:o.executionMode)!=null?{executionMode:o.executionMode}:{},...(d=o==null?void 0:o.selectedPluginIds)!=null&&d.length?{selectedPluginIds:o.selectedPluginIds}:{},...(h=o==null?void 0:o.selectedSkillIds)!=null&&h.length?{selectedSkillIds:o.selectedSkillIds}:{},...(p=o==null?void 0:o.selectedPluginSkillIds)!=null&&p.length?{selectedPluginSkillIds:o.selectedPluginSkillIds}:{},...(b=o==null?void 0:o.selectedMcpServerIds)!=null&&b.length?{selectedMcpServerIds:o.selectedMcpServerIds}:{},...(m=o==null?void 0:o.selectedSlashCommandIds)!=null&&m.length?{selectedSlashCommandIds:o.selectedSlashCommandIds}:{},...(_=o==null?void 0:o.selectedRemoteContextProviderIds)!=null&&_.length?{selectedRemoteContextProviderIds:o.selectedRemoteContextProviderIds}:{},metadata:{type:a,note:n,source:"web-sdk",pageUrl:r.pageUrl,pageTitle:r.pageTitle,elementText:r.elementText,cssSelector:r.cssSelector,elementOuterHtml:r.elementOuterHtml,ancestry:r.ancestry,elementRole:r.elementRole,elementAriaLabel:r.elementAriaLabel,enclosingSection:r.enclosingSection,description:r.description,canonicalUrl:r.canonicalUrl,lang:r.lang,ogTitle:r.ogTitle,ogDescription:r.ogDescription,ogType:r.ogType,ogSiteName:r.ogSiteName,viewportWidth:r.viewportWidth,viewportHeight:r.viewportHeight,scrollX:r.scrollX,scrollY:r.scrollY,selectionText:r.selectionText,capturedAt:r.capturedAt,interactionSteps:r.interactionSteps}})}async function Js(e,t,n,r,o,s,a){return wi(e,t,n,r,o,s,Rg,a)}async function Xs(e,t,n,r){return Ze(e,"POST","/planning-sessions",{projectId:t,instruction:n,quickMode:(r==null?void 0:r.quickMode)??!1,...r!=null&&r.claudeTemplateId?{claudeTemplateId:r.claudeTemplateId}:{}})}async function Lg(e,t){const n=t?`?projectId=${encodeURIComponent(t)}`:"";return Ze(e,"GET",`/claude-templates${n}`)}async function dc(e,t){return Ze(e,"GET",`/tasks/${t}`)}async function zg(e,t){return Ze(e,"GET",`/planning-sessions/${t}`)}async function Ig(e){return Ze(e,"GET","/projects")}async function $g(e,t){return Ze(e,"GET",`/tasks/${t}/browser-commands/pending`)}async function Ng(e,t,n,r,o){return Ze(e,"POST",`/tasks/${t}/browser-commands/${n}/result`,{status:r,message:o})}async function Og(e,t){return Ze(e,"GET",`/tasks/${t}/chunks`)}async function Dg(e,t,n){return Ze(e,"POST",`/tasks/${t}/instructions`,{content:n})}async function Mg(e,t){return Ze(e,"POST",`/tasks/${t}/cancel`)}async function Ug(e,t){return Ze(e,"POST",`/tasks/${t}/approve-result`)}async function jg(e,t,n){return Ze(e,"POST",`/tasks/${t}/reject-result`,{feedback:n})}async function zo(e,t){return Ze(e,"GET",`/tasks/${t}/interactions?filter=unanswered`)}async function pc(e,t,n,r){return Ze(e,"POST",`/tasks/${t}/interactions/${n}/answer`,{answer:r})}const hc=/^cc-|current-password|new-password/i,Zg=/token|secret|password|apikey|auth/i,li="[redacted]";function qg(e){if(e instanceof HTMLInputElement&&e.type==="password")return!0;const t=e.getAttribute("autocomplete");return!!t&&hc.test(t)}function Hg(e){const t=[e,...Array.from(e.querySelectorAll("*"))];for(const n of t){n instanceof HTMLInputElement&&n.type==="password"&&n.setAttribute("value",li);const r=n.getAttribute("autocomplete");r&&hc.test(r)&&n.setAttribute("value",li);for(const o of Array.from(n.attributes))Zg.test(o.name)&&n.setAttribute(o.name,li)}}function Fg(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var fc={exports:{}};/*!
1369
1386
  * Pusher JavaScript Library v8.5.0
1370
1387
  * https://pusher.com/
1371
1388
  *
1372
1389
  * Copyright 2020, Pusher
1373
1390
  * Released under the MIT licence.
1374
- */(function(e,t){(function(r,o){e.exports=o()})(self,()=>(()=>{var n={594(c,u){var d=this&&this.__extends||function(){var R=function(x,S){return R=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(C,M){C.__proto__=M}||function(C,M){for(var se in M)M.hasOwnProperty(se)&&(C[se]=M[se])},R(x,S)};return function(x,S){R(x,S);function C(){this.constructor=x}x.prototype=S===null?Object.create(S):(C.prototype=S.prototype,new C)}}();Object.defineProperty(u,"__esModule",{value:!0});var p=256,h=function(){function R(x){x===void 0&&(x="="),this._paddingCharacter=x}return R.prototype.encodedLength=function(x){return this._paddingCharacter?(x+2)/3*4|0:(x*8+5)/6|0},R.prototype.encode=function(x){for(var S="",C=0;C<x.length-2;C+=3){var M=x[C]<<16|x[C+1]<<8|x[C+2];S+=this._encodeByte(M>>>3*6&63),S+=this._encodeByte(M>>>2*6&63),S+=this._encodeByte(M>>>1*6&63),S+=this._encodeByte(M>>>0*6&63)}var se=x.length-C;if(se>0){var M=x[C]<<16|(se===2?x[C+1]<<8:0);S+=this._encodeByte(M>>>3*6&63),S+=this._encodeByte(M>>>2*6&63),se===2?S+=this._encodeByte(M>>>1*6&63):S+=this._paddingCharacter||"",S+=this._paddingCharacter||""}return S},R.prototype.maxDecodedLength=function(x){return this._paddingCharacter?x/4*3|0:(x*6+7)/8|0},R.prototype.decodedLength=function(x){return this.maxDecodedLength(x.length-this._getPaddingLength(x))},R.prototype.decode=function(x){if(x.length===0)return new Uint8Array(0);for(var S=this._getPaddingLength(x),C=x.length-S,M=new Uint8Array(this.maxDecodedLength(C)),se=0,ve=0,ze=0,Xe=0,Y=0,me=0,Ve=0;ve<C-4;ve+=4)Xe=this._decodeChar(x.charCodeAt(ve+0)),Y=this._decodeChar(x.charCodeAt(ve+1)),me=this._decodeChar(x.charCodeAt(ve+2)),Ve=this._decodeChar(x.charCodeAt(ve+3)),M[se++]=Xe<<2|Y>>>4,M[se++]=Y<<4|me>>>2,M[se++]=me<<6|Ve,ze|=Xe&p,ze|=Y&p,ze|=me&p,ze|=Ve&p;if(ve<C-1&&(Xe=this._decodeChar(x.charCodeAt(ve)),Y=this._decodeChar(x.charCodeAt(ve+1)),M[se++]=Xe<<2|Y>>>4,ze|=Xe&p,ze|=Y&p),ve<C-2&&(me=this._decodeChar(x.charCodeAt(ve+2)),M[se++]=Y<<4|me>>>2,ze|=me&p),ve<C-3&&(Ve=this._decodeChar(x.charCodeAt(ve+3)),M[se++]=me<<6|Ve,ze|=Ve&p),ze!==0)throw new Error("Base64Coder: incorrect characters for decoding");return M},R.prototype._encodeByte=function(x){var S=x;return S+=65,S+=25-x>>>8&6,S+=51-x>>>8&-75,S+=61-x>>>8&-15,S+=62-x>>>8&3,String.fromCharCode(S)},R.prototype._decodeChar=function(x){var S=p;return S+=(42-x&x-44)>>>8&-p+x-43+62,S+=(46-x&x-48)>>>8&-p+x-47+63,S+=(47-x&x-58)>>>8&-p+x-48+52,S+=(64-x&x-91)>>>8&-p+x-65+0,S+=(96-x&x-123)>>>8&-p+x-97+26,S},R.prototype._getPaddingLength=function(x){var S=0;if(this._paddingCharacter){for(var C=x.length-1;C>=0&&x[C]===this._paddingCharacter;C--)S++;if(x.length<4||S>2)throw new Error("Base64Coder: incorrect padding")}return S},R}();u.Coder=h;var b=new h;function m(R){return b.encode(R)}u.encode=m;function _(R){return b.decode(R)}u.decode=_;var w=function(R){d(x,R);function x(){return R!==null&&R.apply(this,arguments)||this}return x.prototype._encodeByte=function(S){var C=S;return C+=65,C+=25-S>>>8&6,C+=51-S>>>8&-75,C+=61-S>>>8&-13,C+=62-S>>>8&49,String.fromCharCode(C)},x.prototype._decodeChar=function(S){var C=p;return C+=(44-S&S-46)>>>8&-p+S-45+62,C+=(94-S&S-96)>>>8&-p+S-95+63,C+=(47-S&S-58)>>>8&-p+S-48+52,C+=(64-S&S-91)>>>8&-p+S-65+0,C+=(96-S&S-123)>>>8&-p+S-97+26,C},x}(h);u.URLSafeCoder=w;var P=new w;function N(R){return P.encode(R)}u.encodeURLSafe=N;function te(R){return P.decode(R)}u.decodeURLSafe=te,u.encodedLength=function(R){return b.encodedLength(R)},u.maxDecodedLength=function(R){return b.maxDecodedLength(R)},u.decodedLength=function(R){return b.decodedLength(R)}},978(c,u){var d="utf8: invalid source encoding";function p(h){for(var b=[],m=0;m<h.length;m++){var _=h[m];if(_&128){var w=void 0;if(_<224){if(m>=h.length)throw new Error(d);var P=h[++m];if((P&192)!==128)throw new Error(d);_=(_&31)<<6|P&63,w=128}else if(_<240){if(m>=h.length-1)throw new Error(d);var P=h[++m],N=h[++m];if((P&192)!==128||(N&192)!==128)throw new Error(d);_=(_&15)<<12|(P&63)<<6|N&63,w=2048}else if(_<248){if(m>=h.length-2)throw new Error(d);var P=h[++m],N=h[++m],te=h[++m];if((P&192)!==128||(N&192)!==128||(te&192)!==128)throw new Error(d);_=(_&15)<<18|(P&63)<<12|(N&63)<<6|te&63,w=65536}else throw new Error(d);if(_<w||_>=55296&&_<=57343)throw new Error(d);if(_>=65536){if(_>1114111)throw new Error(d);_-=65536,b.push(String.fromCharCode(55296|_>>10)),_=56320|_&1023}}b.push(String.fromCharCode(_))}return b.join("")}u.D4=p},721(c,u,d){c.exports=d(207).default},207(c,u,d){d.d(u,{default:()=>ro});class p{constructor(i,a){this.lastId=0,this.prefix=i,this.name=a}create(i){this.lastId++;var a=this.lastId,f=this.prefix+a,g=this.name+"["+a+"]",y=!1,E=function(){y||(i.apply(null,arguments),y=!0)};return this[a]=E,{number:a,id:f,name:g,callback:E}}remove(i){delete this[i.number]}}var h=new p("_pusher_script_","Pusher.ScriptReceivers"),b={VERSION:"8.5.0",PROTOCOL:7,wsPort:80,wssPort:443,wsPath:"",httpHost:"sockjs.pusher.com",httpPort:80,httpsPort:443,httpPath:"/pusher",stats_host:"stats.pusher.com",authEndpoint:"/pusher/auth",authTransport:"ajax",activityTimeout:12e4,pongTimeout:3e4,unavailableTimeout:1e4,userAuthentication:{endpoint:"/pusher/user-auth",transport:"ajax"},channelAuthorization:{endpoint:"/pusher/auth",transport:"ajax"},cdn_http:"http://js.pusher.com",cdn_https:"https://js.pusher.com",dependency_suffix:""};const m=b;class _{constructor(i){this.options=i,this.receivers=i.receivers||h,this.loading={}}load(i,a,f){var g=this;if(g.loading[i]&&g.loading[i].length>0)g.loading[i].push(f);else{g.loading[i]=[f];var y=H.createScriptRequest(g.getPath(i,a)),E=g.receivers.create(function($){if(g.receivers.remove(E),g.loading[i]){var q=g.loading[i];delete g.loading[i];for(var V=function(Se){Se||y.cleanup()},ee=0;ee<q.length;ee++)q[ee]($,V)}});y.send(E)}}getRoot(i){var a,f=H.getDocument().location.protocol;return i&&i.useTLS||f==="https:"?a=this.options.cdn_https:a=this.options.cdn_http,a.replace(/\/*$/,"")+"/"+this.options.version}getPath(i,a){return this.getRoot(a)+"/"+i+this.options.suffix+".js"}}var w=new p("_pusher_dependencies","Pusher.DependenciesReceivers"),P=new _({cdn_http:m.cdn_http,cdn_https:m.cdn_https,version:m.VERSION,suffix:m.dependency_suffix,receivers:w});const N={baseUrl:"https://pusher.com",urls:{authenticationEndpoint:{path:"/docs/channels/server_api/authenticating_users"},authorizationEndpoint:{path:"/docs/channels/server_api/authorizing-users/"},javascriptQuickStart:{path:"/docs/javascript_quick_start"},triggeringClientEvents:{path:"/docs/client_api_guide/client_events#trigger-events"},encryptedChannelSupport:{fullUrl:"https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support"}}},R={buildLogSuffix:function(l){const i="See:",a=N.urls[l];if(!a)return"";let f;return a.fullUrl?f=a.fullUrl:a.path&&(f=N.baseUrl+a.path),f?`${i} ${f}`:""}};var x;(function(l){l.UserAuthentication="user-authentication",l.ChannelAuthorization="channel-authorization"})(x||(x={}));class S extends Error{constructor(i){super(i),Object.setPrototypeOf(this,new.target.prototype)}}class C extends Error{constructor(i){super(i),Object.setPrototypeOf(this,new.target.prototype)}}class M extends Error{constructor(i){super(i),Object.setPrototypeOf(this,new.target.prototype)}}class se extends Error{constructor(i){super(i),Object.setPrototypeOf(this,new.target.prototype)}}class ve extends Error{constructor(i){super(i),Object.setPrototypeOf(this,new.target.prototype)}}class ze extends Error{constructor(i){super(i),Object.setPrototypeOf(this,new.target.prototype)}}class Xe extends Error{constructor(i){super(i),Object.setPrototypeOf(this,new.target.prototype)}}class Y extends Error{constructor(i){super(i),Object.setPrototypeOf(this,new.target.prototype)}}class me extends Error{constructor(i,a){super(a),this.status=i,Object.setPrototypeOf(this,new.target.prototype)}}const qt=function(l,i,a,f,g){const y=H.createXHR();y.open("POST",a.endpoint,!0),y.setRequestHeader("Content-Type","application/x-www-form-urlencoded");for(var E in a.headers)y.setRequestHeader(E,a.headers[E]);if(a.headersProvider!=null){let $=a.headersProvider();for(var E in $)y.setRequestHeader(E,$[E])}return y.onreadystatechange=function(){if(y.readyState===4)if(y.status===200){let $,q=!1;try{$=JSON.parse(y.responseText),q=!0}catch{g(new me(200,`JSON returned from ${f.toString()} endpoint was invalid, yet status code was 200. Data was: ${y.responseText}`),null)}q&&g(null,$)}else{let $="";switch(f){case x.UserAuthentication:$=R.buildLogSuffix("authenticationEndpoint");break;case x.ChannelAuthorization:$=`Clients must be authorized to join private or presence channels. ${R.buildLogSuffix("authorizationEndpoint")}`;break}g(new me(y.status,`Unable to retrieve auth string from ${f.toString()} endpoint - received status: ${y.status} from ${a.endpoint}. ${$}`),null)}},y.send(i),y};function Z(l){return be(_t(l))}var X=String.fromCharCode,Ie="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Oe=function(l){var i=l.charCodeAt(0);return i<128?l:i<2048?X(192|i>>>6)+X(128|i&63):X(224|i>>>12&15)+X(128|i>>>6&63)+X(128|i&63)},_t=function(l){return l.replace(/[^\x00-\x7F]/g,Oe)},nt=function(l){var i=[0,2,1][l.length%3],a=l.charCodeAt(0)<<16|(l.length>1?l.charCodeAt(1):0)<<8|(l.length>2?l.charCodeAt(2):0),f=[Ie.charAt(a>>>18),Ie.charAt(a>>>12&63),i>=2?"=":Ie.charAt(a>>>6&63),i>=1?"=":Ie.charAt(a&63)];return f.join("")},be=window.btoa||function(l){return l.replace(/[\s\S]{1,3}/g,nt)};class on{constructor(i,a,f,g){this.clear=a,this.timer=i(()=>{this.timer&&(this.timer=g(this.timer))},f)}isRunning(){return this.timer!==null}ensureAborted(){this.timer&&(this.clear(this.timer),this.timer=null)}}const W=on;function Ce(l){window.clearTimeout(l)}function J(l){window.clearInterval(l)}class ke extends W{constructor(i,a){super(setTimeout,Ce,i,function(f){return a(),null})}}class sn extends W{constructor(i,a){super(setInterval,J,i,function(f){return a(),f})}}var Pe={now(){return Date.now?Date.now():new Date().valueOf()},defer(l){return new ke(0,l)},method(l,...i){var a=Array.prototype.slice.call(arguments,1);return function(f){return f[l].apply(f,a.concat(arguments))}}};const ae=Pe;function we(l,...i){for(var a=0;a<i.length;a++){var f=i[a];for(var g in f)f[g]&&f[g].constructor&&f[g].constructor===Object?l[g]=we(l[g]||{},f[g]):l[g]=f[g]}return l}function Pt(){for(var l=["Pusher"],i=0;i<arguments.length;i++)typeof arguments[i]=="string"?l.push(arguments[i]):l.push(Ze(arguments[i]));return l.join(" : ")}function ir(l,i){var a=Array.prototype.indexOf;if(l===null)return-1;if(a&&l.indexOf===a)return l.indexOf(i);for(var f=0,g=l.length;f<g;f++)if(l[f]===i)return f;return-1}function De(l,i){for(var a in l)Object.prototype.hasOwnProperty.call(l,a)&&i(l[a],a,l)}function an(l){var i=[];return De(l,function(a,f){i.push(f)}),i}function Rt(l){var i=[];return De(l,function(a){i.push(a)}),i}function Lt(l,i,a){for(var f=0;f<l.length;f++)i.call(a||window,l[f],f,l)}function An(l,i){for(var a=[],f=0;f<l.length;f++)a.push(i(l[f],f,l,a));return a}function Ht(l,i){var a={};return De(l,function(f,g){a[g]=i(f)}),a}function cn(l,i){i=i||function(g){return!!g};for(var a=[],f=0;f<l.length;f++)i(l[f],f,l,a)&&a.push(l[f]);return a}function ln(l,i){var a={};return De(l,function(f,g){(i&&i(f,g,l,a)||f)&&(a[g]=f)}),a}function Hr(l){var i=[];return De(l,function(a,f){i.push([f,a])}),i}function sr(l,i){for(var a=0;a<l.length;a++)if(i(l[a],a,l))return!0;return!1}function Qo(l,i){for(var a=0;a<l.length;a++)if(!i(l[a],a,l))return!1;return!0}function ar(l){return Ht(l,function(i){return typeof i=="object"&&(i=Ze(i)),encodeURIComponent(Z(i.toString()))})}function un(l){var i=ln(l,function(f){return f!==void 0}),a=An(Hr(ar(i)),ae.method("join","=")).join("&");return a}function Ft(l){var i=[],a=[];return function f(g,y){var E,$,q;switch(typeof g){case"object":if(!g)return null;for(E=0;E<i.length;E+=1)if(i[E]===g)return{$ref:a[E]};if(i.push(g),a.push(y),Object.prototype.toString.apply(g)==="[object Array]")for(q=[],E=0;E<g.length;E+=1)q[E]=f(g[E],y+"["+E+"]");else{q={};for($ in g)Object.prototype.hasOwnProperty.call(g,$)&&(q[$]=f(g[$],y+"["+JSON.stringify($)+"]"))}return q;case"number":case"string":case"boolean":return g}}(l,"$")}function Ze(l){try{return JSON.stringify(l)}catch{return JSON.stringify(Ft(l))}}class cr{constructor(){this.globalLog=i=>{window.console&&window.console.log&&window.console.log(i)}}debug(...i){this.log(this.globalLog,i)}warn(...i){this.log(this.globalLogWarn,i)}error(...i){this.log(this.globalLogError,i)}globalLogWarn(i){window.console&&window.console.warn?window.console.warn(i):this.globalLog(i)}globalLogError(i){window.console&&window.console.error?window.console.error(i):this.globalLogWarn(i)}log(i,...a){var f=Pt.apply(this,arguments);ro.log?ro.log(f):ro.logToConsole&&i.bind(this)(f)}}const ce=new cr;var Fr=function(l,i,a,f,g){(a.headers!==void 0||a.headersProvider!=null)&&ce.warn(`To send headers with the ${f.toString()} request, you must use AJAX, rather than JSONP.`);var y=l.nextAuthCallbackID.toString();l.nextAuthCallbackID++;var E=l.getDocument(),$=E.createElement("script");l.auth_callbacks[y]=function(ee){g(null,ee)};var q="Pusher.auth_callbacks['"+y+"']";$.src=a.endpoint+"?callback="+encodeURIComponent(q)+"&"+i;var V=E.getElementsByTagName("head")[0]||E.documentElement;V.insertBefore($,V.firstChild)};const lr=Fr;class Br{constructor(i){this.src=i}send(i){var a=this,f="Error loading "+a.src;a.script=document.createElement("script"),a.script.id=i.id,a.script.src=a.src,a.script.type="text/javascript",a.script.charset="UTF-8",a.script.addEventListener?(a.script.onerror=function(){i.callback(f)},a.script.onload=function(){i.callback(null)}):a.script.onreadystatechange=function(){(a.script.readyState==="loaded"||a.script.readyState==="complete")&&i.callback(null)},a.script.async===void 0&&document.attachEvent&&/opera/i.test(navigator.userAgent)?(a.errorScript=document.createElement("script"),a.errorScript.id=i.id+"_error",a.errorScript.text=i.name+"('"+f+"');",a.script.async=a.errorScript.async=!1):a.script.async=!0;var g=document.getElementsByTagName("head")[0];g.insertBefore(a.script,g.firstChild),a.errorScript&&g.insertBefore(a.errorScript,a.script.nextSibling)}cleanup(){this.script&&(this.script.onload=this.script.onerror=null,this.script.onreadystatechange=null),this.script&&this.script.parentNode&&this.script.parentNode.removeChild(this.script),this.errorScript&&this.errorScript.parentNode&&this.errorScript.parentNode.removeChild(this.errorScript),this.script=null,this.errorScript=null}}class Cn{constructor(i,a){this.url=i,this.data=a}send(i){if(!this.request){var a=un(this.data),f=this.url+"/"+i.number+"?"+a;this.request=H.createScriptRequest(f),this.request.send(i)}}cleanup(){this.request&&this.request.cleanup()}}var Pn=function(l,i){return function(a,f){var g="http"+(i?"s":"")+"://",y=g+(l.host||l.options.host)+l.options.path,E=H.createJSONPRequest(y,a),$=H.ScriptReceivers.create(function(q,V){h.remove($),E.cleanup(),V&&V.host&&(l.host=V.host),f&&f(q,V)});E.send($)}},ut={name:"jsonp",getAgent:Pn};const Bt=ut;function dn(l,i,a){var f=l+(i.useTLS?"s":""),g=i.useTLS?i.hostTLS:i.hostNonTLS;return f+"://"+g+a}function pn(l,i){var a="/app/"+l,f="?protocol="+m.PROTOCOL+"&client=js&version="+m.VERSION+(i?"&"+i:"");return a+f}var ei={getInitial:function(l,i){var a=(i.httpPath||"")+pn(l,"flash=false");return dn("ws",i,a)}},Rn={getInitial:function(l,i){var a=(i.httpPath||"/pusher")+pn(l);return dn("http",i,a)}},Ln={getInitial:function(l,i){return dn("http",i,i.httpPath||"/pusher")},getPath:function(l,i){return pn(l)}};class ti{constructor(){this._callbacks={}}get(i){return this._callbacks[zt(i)]}add(i,a,f){var g=zt(i);this._callbacks[g]=this._callbacks[g]||[],this._callbacks[g].push({fn:a,context:f})}remove(i,a,f){if(!i&&!a&&!f){this._callbacks={};return}var g=i?[zt(i)]:an(this._callbacks);a||f?this.removeCallback(g,a,f):this.removeAllCallbacks(g)}removeCallback(i,a,f){Lt(i,function(g){this._callbacks[g]=cn(this._callbacks[g]||[],function(y){return a&&a!==y.fn||f&&f!==y.context}),this._callbacks[g].length===0&&delete this._callbacks[g]},this)}removeAllCallbacks(i){Lt(i,function(a){delete this._callbacks[a]},this)}}function zt(l){return"_"+l}class dt{constructor(i){this.callbacks=new ti,this.global_callbacks=[],this.failThrough=i}bind(i,a,f){return this.callbacks.add(i,a,f),this}bind_global(i){return this.global_callbacks.push(i),this}unbind(i,a,f){return this.callbacks.remove(i,a,f),this}unbind_global(i){return i?(this.global_callbacks=cn(this.global_callbacks||[],a=>a!==i),this):(this.global_callbacks=[],this)}unbind_all(){return this.unbind(),this.unbind_global(),this}emit(i,a,f){for(var g=0;g<this.global_callbacks.length;g++)this.global_callbacks[g](i,a);var y=this.callbacks.get(i),E=[];if(f?E.push(a,f):a&&E.push(a),y&&y.length>0)for(var g=0;g<y.length;g++)y[g].fn.apply(y[g].context||window,E);else this.failThrough&&this.failThrough(i,a);return this}}class ni extends dt{constructor(i,a,f,g,y){super(),this.initialize=H.transportConnectionInitializer,this.hooks=i,this.name=a,this.priority=f,this.key=g,this.options=y,this.state="new",this.timeline=y.timeline,this.activityTimeout=y.activityTimeout,this.id=this.timeline.generateUniqueID()}handlesActivityChecks(){return!!this.hooks.handlesActivityChecks}supportsPing(){return!!this.hooks.supportsPing}connect(){if(this.socket||this.state!=="initialized")return!1;var i=this.hooks.urls.getInitial(this.key,this.options);try{this.socket=this.hooks.getSocket(i,this.options)}catch(a){return ae.defer(()=>{this.onError(a),this.changeState("closed")}),!1}return this.bindListeners(),ce.debug("Connecting",{transport:this.name,url:i}),this.changeState("connecting"),!0}close(){return this.socket?(this.socket.close(),!0):!1}send(i){return this.state==="open"?(ae.defer(()=>{this.socket&&this.socket.send(i)}),!0):!1}ping(){this.state==="open"&&this.supportsPing()&&this.socket.ping()}onOpen(){this.hooks.beforeOpen&&this.hooks.beforeOpen(this.socket,this.hooks.urls.getPath(this.key,this.options)),this.changeState("open"),this.socket.onopen=void 0}onError(i){this.emit("error",{type:"WebSocketError",error:i}),this.timeline.error(this.buildTimelineMessage({error:i.toString()}))}onClose(i){i?this.changeState("closed",{code:i.code,reason:i.reason,wasClean:i.wasClean}):this.changeState("closed"),this.unbindListeners(),this.socket=void 0}onMessage(i){this.emit("message",i)}onActivity(){this.emit("activity")}bindListeners(){this.socket.onopen=()=>{this.onOpen()},this.socket.onerror=i=>{this.onError(i)},this.socket.onclose=i=>{this.onClose(i)},this.socket.onmessage=i=>{this.onMessage(i)},this.supportsPing()&&(this.socket.onactivity=()=>{this.onActivity()})}unbindListeners(){this.socket&&(this.socket.onopen=void 0,this.socket.onerror=void 0,this.socket.onclose=void 0,this.socket.onmessage=void 0,this.supportsPing()&&(this.socket.onactivity=void 0))}changeState(i,a){this.state=i,this.timeline.info(this.buildTimelineMessage({state:i,params:a})),this.emit(i,a)}buildTimelineMessage(i){return we({cid:this.id},i)}}class le{constructor(i){this.hooks=i}isSupported(i){return this.hooks.isSupported(i)}createConnection(i,a,f,g){return new ni(this.hooks,i,a,f,g)}}var Gt=new le({urls:ei,handlesActivityChecks:!1,supportsPing:!1,isInitialized:function(){return!!H.getWebSocketAPI()},isSupported:function(){return!!H.getWebSocketAPI()},getSocket:function(l){return H.createWebSocket(l)}}),Gr={urls:Rn,handlesActivityChecks:!1,supportsPing:!0,isInitialized:function(){return!0}},ur=we({getSocket:function(l){return H.HTTPFactory.createStreamingSocket(l)}},Gr),zn=we({getSocket:function(l){return H.HTTPFactory.createPollingSocket(l)}},Gr),dr={isSupported:function(){return H.isXHRSupported()}},Wr=new le(we({},ur,dr)),ri=new le(we({},zn,dr)),rt={ws:Gt,xhr_streaming:Wr,xhr_polling:ri};const ot=rt;var Jr=new le({file:"sockjs",urls:Ln,handlesActivityChecks:!0,supportsPing:!1,isSupported:function(){return!0},isInitialized:function(){return window.SockJS!==void 0},getSocket:function(l,i){return new window.SockJS(l,null,{js_path:P.getPath("sockjs",{useTLS:i.useTLS}),ignore_null_origin:i.ignoreNullOrigin})},beforeOpen:function(l,i){l.send(JSON.stringify({path:i}))}}),pr={isSupported:function(l){var i=H.isXDRSupported(l.useTLS);return i}},hr=new le(we({},ur,pr)),Xr=new le(we({},zn,pr));ot.xdr_streaming=hr,ot.xdr_polling=Xr,ot.sockjs=Jr;const pt=ot;class Vr extends dt{constructor(){super();var i=this;window.addEventListener!==void 0&&(window.addEventListener("online",function(){i.emit("online")},!1),window.addEventListener("offline",function(){i.emit("offline")},!1))}isOnline(){return window.navigator.onLine===void 0?!0:window.navigator.onLine}}var Yr=new Vr;class Kr{constructor(i,a,f){this.manager=i,this.transport=a,this.minPingDelay=f.minPingDelay,this.maxPingDelay=f.maxPingDelay,this.pingDelay=void 0}createConnection(i,a,f,g){g=we({},g,{activityTimeout:this.pingDelay});var y=this.transport.createConnection(i,a,f,g),E=null,$=function(){y.unbind("open",$),y.bind("closed",q),E=ae.now()},q=V=>{if(y.unbind("closed",q),V.code===1002||V.code===1003)this.manager.reportDeath();else if(!V.wasClean&&E){var ee=ae.now()-E;ee<2*this.maxPingDelay&&(this.manager.reportDeath(),this.pingDelay=Math.max(ee/2,this.minPingDelay))}};return y.bind("open",$),y}isSupported(i){return this.manager.isAlive()&&this.transport.isSupported(i)}}const fr={decodeMessage:function(l){try{var i=JSON.parse(l.data),a=i.data;if(typeof a=="string")try{a=JSON.parse(i.data)}catch{}var f={event:i.event,channel:i.channel,data:a};return i.user_id&&(f.user_id=i.user_id),f}catch(g){throw{type:"MessageParseError",error:g,data:l.data}}},encodeMessage:function(l){return JSON.stringify(l)},processHandshake:function(l){var i=fr.decodeMessage(l);if(i.event==="pusher:connection_established"){if(!i.data.activity_timeout)throw"No activity timeout specified in handshake";return{action:"connected",id:i.data.socket_id,activityTimeout:i.data.activity_timeout*1e3}}else{if(i.event==="pusher:error")return{action:this.getCloseAction(i.data),error:this.getCloseError(i.data)};throw"Invalid handshake"}},getCloseAction:function(l){return l.code<4e3?l.code>=1002&&l.code<=1004?"backoff":null:l.code===4e3?"tls_only":l.code<4100?"refused":l.code<4200?"backoff":l.code<4300?"retry":"refused"},getCloseError:function(l){return l.code!==1e3&&l.code!==1001?{type:"PusherError",data:{code:l.code,message:l.reason||l.message}}:null}},It=fr;class O extends dt{constructor(i,a){super(),this.id=i,this.transport=a,this.activityTimeout=a.activityTimeout,this.bindListeners()}handlesActivityChecks(){return this.transport.handlesActivityChecks()}send(i){return this.transport.send(i)}send_event(i,a,f){var g={event:i,data:a};return f&&(g.channel=f),ce.debug("Event sent",g),this.send(It.encodeMessage(g))}ping(){this.transport.supportsPing()?this.transport.ping():this.send_event("pusher:ping",{})}close(){this.transport.close()}bindListeners(){var i={message:f=>{var g;try{g=It.decodeMessage(f)}catch(y){this.emit("error",{type:"MessageParseError",error:y,data:f.data})}if(g!==void 0){switch(ce.debug("Event recd",g),g.event){case"pusher:error":this.emit("error",{type:"PusherError",data:g.data});break;case"pusher:ping":this.emit("ping");break;case"pusher:pong":this.emit("pong");break}this.emit("message",g)}},activity:()=>{this.emit("activity")},error:f=>{this.emit("error",f)},closed:f=>{a(),f&&f.code&&this.handleCloseEvent(f),this.transport=null,this.emit("closed")}},a=()=>{De(i,(f,g)=>{this.transport.unbind(g,f)})};De(i,(f,g)=>{this.transport.bind(g,f)})}handleCloseEvent(i){var a=It.getCloseAction(i),f=It.getCloseError(i);f&&this.emit("error",f),a&&this.emit(a,{action:a,error:f})}}class k{constructor(i,a){this.transport=i,this.callback=a,this.bindListeners()}close(){this.unbindListeners(),this.transport.close()}bindListeners(){this.onMessage=i=>{this.unbindListeners();var a;try{a=It.processHandshake(i)}catch(f){this.finish("error",{error:f}),this.transport.close();return}a.action==="connected"?this.finish("connected",{connection:new O(a.id,this.transport),activityTimeout:a.activityTimeout}):(this.finish(a.action,{error:a.error}),this.transport.close())},this.onClosed=i=>{this.unbindListeners();var a=It.getCloseAction(i)||"backoff",f=It.getCloseError(i);this.finish(a,{error:f})},this.transport.bind("message",this.onMessage),this.transport.bind("closed",this.onClosed)}unbindListeners(){this.transport.unbind("message",this.onMessage),this.transport.unbind("closed",this.onClosed)}finish(i,a){this.callback(we({transport:this.transport,action:i},a))}}class T{constructor(i,a){this.timeline=i,this.options=a||{}}send(i,a){this.timeline.isEmpty()||this.timeline.send(H.TimelineTransport.getAgent(this,i),a)}}class L extends dt{constructor(i,a){super(function(f,g){ce.debug("No callbacks on "+i+" for "+f)}),this.name=i,this.pusher=a,this.subscribed=!1,this.subscriptionPending=!1,this.subscriptionCancelled=!1}authorize(i,a){return a(null,{auth:""})}trigger(i,a){if(i.indexOf("client-")!==0)throw new S("Event '"+i+"' does not start with 'client-'");if(!this.subscribed){var f=R.buildLogSuffix("triggeringClientEvents");ce.warn(`Client event triggered before channel 'subscription_succeeded' event . ${f}`)}return this.pusher.send_event(i,a,this.name)}disconnect(){this.subscribed=!1,this.subscriptionPending=!1}handleEvent(i){var a=i.event,f=i.data;if(a==="pusher_internal:subscription_succeeded")this.handleSubscriptionSucceededEvent(i);else if(a==="pusher_internal:subscription_count")this.handleSubscriptionCountEvent(i);else if(a.indexOf("pusher_internal:")!==0){var g={};this.emit(a,f,g)}}handleSubscriptionSucceededEvent(i){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):this.emit("pusher:subscription_succeeded",i.data)}handleSubscriptionCountEvent(i){i.data.subscription_count&&(this.subscriptionCount=i.data.subscription_count),this.emit("pusher:subscription_count",i.data)}subscribe(){this.subscribed||(this.subscriptionPending=!0,this.subscriptionCancelled=!1,this.authorize(this.pusher.connection.socket_id,(i,a)=>{i?(this.subscriptionPending=!1,ce.error(i.toString()),this.emit("pusher:subscription_error",Object.assign({},{type:"AuthError",error:i.message},i instanceof me?{status:i.status}:{}))):this.pusher.send_event("pusher:subscribe",{auth:a.auth,channel_data:a.channel_data,channel:this.name})}))}unsubscribe(){this.subscribed=!1,this.pusher.send_event("pusher:unsubscribe",{channel:this.name})}cancelSubscription(){this.subscriptionCancelled=!0}reinstateSubscription(){this.subscriptionCancelled=!1}}class ne extends L{authorize(i,a){return this.pusher.config.channelAuthorizer({channelName:this.name,socketId:i},a)}}class Re{constructor(){this.reset()}get(i){return Object.prototype.hasOwnProperty.call(this.members,i)?{id:i,info:this.members[i]}:null}each(i){De(this.members,(a,f)=>{i(this.get(f))})}setMyID(i){this.myID=i}onSubscription(i){this.members=i.presence.hash,this.count=i.presence.count,this.me=this.get(this.myID)}addMember(i){return this.get(i.user_id)===null&&this.count++,this.members[i.user_id]=i.user_info,this.get(i.user_id)}removeMember(i){var a=this.get(i.user_id);return a&&(delete this.members[i.user_id],this.count--),a}reset(){this.members={},this.count=0,this.myID=null,this.me=null}}var ye=function(l,i,a,f){function g(y){return y instanceof a?y:new a(function(E){E(y)})}return new(a||(a=Promise))(function(y,E){function $(ee){try{V(f.next(ee))}catch(Se){E(Se)}}function q(ee){try{V(f.throw(ee))}catch(Se){E(Se)}}function V(ee){ee.done?y(ee.value):g(ee.value).then($,q)}V((f=f.apply(l,i||[])).next())})};class Me extends ne{constructor(i,a){super(i,a),this.members=new Re}authorize(i,a){super.authorize(i,(f,g)=>ye(this,void 0,void 0,function*(){if(!f)if(g=g,g.channel_data!=null){var y=JSON.parse(g.channel_data);this.members.setMyID(y.user_id)}else if(yield this.pusher.user.signinDonePromise,this.pusher.user.user_data!=null)this.members.setMyID(this.pusher.user.user_data.id);else{let E=R.buildLogSuffix("authorizationEndpoint");ce.error(`Invalid auth response for channel '${this.name}', expected 'channel_data' field. ${E}, or the user should be signed in.`),a("Invalid auth response");return}a(f,g)}))}handleEvent(i){var a=i.event;if(a.indexOf("pusher_internal:")===0)this.handleInternalEvent(i);else{var f=i.data,g={};i.user_id&&(g.user_id=i.user_id),this.emit(a,f,g)}}handleInternalEvent(i){var a=i.event,f=i.data;switch(a){case"pusher_internal:subscription_succeeded":this.handleSubscriptionSucceededEvent(i);break;case"pusher_internal:subscription_count":this.handleSubscriptionCountEvent(i);break;case"pusher_internal:member_added":var g=this.members.addMember(f);this.emit("pusher:member_added",g);break;case"pusher_internal:member_removed":var y=this.members.removeMember(f);y&&this.emit("pusher:member_removed",y);break}}handleSubscriptionSucceededEvent(i){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):(this.members.onSubscription(i.data),this.emit("pusher:subscription_succeeded",this.members))}disconnect(){this.members.reset(),super.disconnect()}}var ht=d(978),vt=d(594);class gr extends ne{constructor(i,a,f){super(i,a),this.key=null,this.nacl=f}authorize(i,a){super.authorize(i,(f,g)=>{if(f){a(f,g);return}let y=g.shared_secret;if(!y){a(new Error(`No shared_secret key in auth payload for encrypted channel: ${this.name}`),null);return}this.key=(0,vt.decode)(y),delete g.shared_secret,a(null,g)})}trigger(i,a){throw new ze("Client events are not currently supported for encrypted channels")}handleEvent(i){var a=i.event,f=i.data;if(a.indexOf("pusher_internal:")===0||a.indexOf("pusher:")===0){super.handleEvent(i);return}this.handleEncryptedEvent(a,f)}handleEncryptedEvent(i,a){if(!this.key){ce.debug("Received encrypted event before key has been retrieved from the authEndpoint");return}if(!a.ciphertext||!a.nonce){ce.error("Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: "+a);return}let f=(0,vt.decode)(a.ciphertext);if(f.length<this.nacl.secretbox.overheadLength){ce.error(`Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${f.length}`);return}let g=(0,vt.decode)(a.nonce);if(g.length<this.nacl.secretbox.nonceLength){ce.error(`Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${g.length}`);return}let y=this.nacl.secretbox.open(f,g,this.key);if(y===null){ce.debug("Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint..."),this.authorize(this.pusher.connection.socket_id,(E,$)=>{if(E){ce.error(`Failed to make a request to the authEndpoint: ${$}. Unable to fetch new key, so dropping encrypted event`);return}if(y=this.nacl.secretbox.open(f,g,this.key),y===null){ce.error("Failed to decrypt event with new key. Dropping encrypted event");return}this.emit(i,this.getDataToEmit(y))});return}this.emit(i,this.getDataToEmit(y))}getDataToEmit(i){let a=(0,ht.D4)(i);try{return JSON.parse(a)}catch{return a}}}class Ae extends dt{constructor(i,a){super(),this.state="initialized",this.connection=null,this.key=i,this.options=a,this.timeline=this.options.timeline,this.usingTLS=this.options.useTLS,this.errorCallbacks=this.buildErrorCallbacks(),this.connectionCallbacks=this.buildConnectionCallbacks(this.errorCallbacks),this.handshakeCallbacks=this.buildHandshakeCallbacks(this.errorCallbacks);var f=H.getNetwork();f.bind("online",()=>{this.timeline.info({netinfo:"online"}),(this.state==="connecting"||this.state==="unavailable")&&this.retryIn(0)}),f.bind("offline",()=>{this.timeline.info({netinfo:"offline"}),this.connection&&this.sendActivityCheck()}),this.updateStrategy()}switchCluster(i){this.key=i,this.updateStrategy(),this.retryIn(0)}connect(){if(!(this.connection||this.runner)){if(!this.strategy.isSupported()){this.updateState("failed");return}this.updateState("connecting"),this.startConnecting(),this.setUnavailableTimer()}}send(i){return this.connection?this.connection.send(i):!1}send_event(i,a,f){return this.connection?this.connection.send_event(i,a,f):!1}disconnect(){this.disconnectInternally(),this.updateState("disconnected")}isUsingTLS(){return this.usingTLS}startConnecting(){var i=(a,f)=>{a?this.runner=this.strategy.connect(0,i):f.action==="error"?(this.emit("error",{type:"HandshakeError",error:f.error}),this.timeline.error({handshakeError:f.error})):(this.abortConnecting(),this.handshakeCallbacks[f.action](f))};this.runner=this.strategy.connect(0,i)}abortConnecting(){this.runner&&(this.runner.abort(),this.runner=null)}disconnectInternally(){if(this.abortConnecting(),this.clearRetryTimer(),this.clearUnavailableTimer(),this.connection){var i=this.abandonConnection();i.close()}}updateStrategy(){this.strategy=this.options.getStrategy({key:this.key,timeline:this.timeline,useTLS:this.usingTLS})}retryIn(i){this.timeline.info({action:"retry",delay:i}),i>0&&this.emit("connecting_in",Math.round(i/1e3)),this.retryTimer=new ke(i||0,()=>{this.disconnectInternally(),this.connect()})}clearRetryTimer(){this.retryTimer&&(this.retryTimer.ensureAborted(),this.retryTimer=null)}setUnavailableTimer(){this.unavailableTimer=new ke(this.options.unavailableTimeout,()=>{this.updateState("unavailable")})}clearUnavailableTimer(){this.unavailableTimer&&this.unavailableTimer.ensureAborted()}sendActivityCheck(){this.stopActivityCheck(),this.connection.ping(),this.activityTimer=new ke(this.options.pongTimeout,()=>{this.timeline.error({pong_timed_out:this.options.pongTimeout}),this.retryIn(0)})}resetActivityCheck(){this.stopActivityCheck(),this.connection&&!this.connection.handlesActivityChecks()&&(this.activityTimer=new ke(this.activityTimeout,()=>{this.sendActivityCheck()}))}stopActivityCheck(){this.activityTimer&&this.activityTimer.ensureAborted()}buildConnectionCallbacks(i){return we({},i,{message:a=>{this.resetActivityCheck(),this.emit("message",a)},ping:()=>{this.send_event("pusher:pong",{})},activity:()=>{this.resetActivityCheck()},error:a=>{this.emit("error",a)},closed:()=>{this.abandonConnection(),this.shouldRetry()&&this.retryIn(1e3)}})}buildHandshakeCallbacks(i){return we({},i,{connected:a=>{this.activityTimeout=Math.min(this.options.activityTimeout,a.activityTimeout,a.connection.activityTimeout||1/0),this.clearUnavailableTimer(),this.setConnection(a.connection),this.socket_id=this.connection.id,this.updateState("connected",{socket_id:this.socket_id})}})}buildErrorCallbacks(){let i=a=>f=>{f.error&&this.emit("error",{type:"WebSocketError",error:f.error}),a(f)};return{tls_only:i(()=>{this.usingTLS=!0,this.updateStrategy(),this.retryIn(0)}),refused:i(()=>{this.disconnect()}),backoff:i(()=>{this.retryIn(1e3)}),retry:i(()=>{this.retryIn(0)})}}setConnection(i){this.connection=i;for(var a in this.connectionCallbacks)this.connection.bind(a,this.connectionCallbacks[a]);this.resetActivityCheck()}abandonConnection(){if(this.connection){this.stopActivityCheck();for(var i in this.connectionCallbacks)this.connection.unbind(i,this.connectionCallbacks[i]);var a=this.connection;return this.connection=null,a}}updateState(i,a){var f=this.state;if(this.state=i,f!==i){var g=i;g==="connected"&&(g+=" with new socket ID "+a.socket_id),ce.debug("State changed",f+" -> "+g),this.timeline.info({state:i,params:a}),this.emit("state_change",{previous:f,current:i}),this.emit(i,a)}}shouldRetry(){return this.state==="connecting"||this.state==="connected"}}class Qr{constructor(){this.channels={}}add(i,a){return this.channels[i]||(this.channels[i]=eo(i,a)),this.channels[i]}all(){return Rt(this.channels)}find(i){return this.channels[i]}remove(i){var a=this.channels[i];return delete this.channels[i],a}disconnect(){De(this.channels,function(i){i.disconnect()})}}function eo(l,i){if(l.indexOf("private-encrypted-")===0){if(i.config.nacl)return $t.createEncryptedChannel(l,i,i.config.nacl);let a="Tried to subscribe to a private-encrypted- channel but no nacl implementation available",f=R.buildLogSuffix("encryptedChannelSupport");throw new ze(`${a}. ${f}`)}else{if(l.indexOf("private-")===0)return $t.createPrivateChannel(l,i);if(l.indexOf("presence-")===0)return $t.createPresenceChannel(l,i);if(l.indexOf("#")===0)throw new C('Cannot create a channel with name "'+l+'".');return $t.createChannel(l,i)}}var gl={createChannels(){return new Qr},createConnectionManager(l,i){return new Ae(l,i)},createChannel(l,i){return new L(l,i)},createPrivateChannel(l,i){return new ne(l,i)},createPresenceChannel(l,i){return new Me(l,i)},createEncryptedChannel(l,i,a){return new gr(l,i,a)},createTimelineSender(l,i){return new T(l,i)},createHandshake(l,i){return new k(l,i)},createAssistantToTheTransportManager(l,i,a){return new Kr(l,i,a)}};const $t=gl;class us{constructor(i){this.options=i||{},this.livesLeft=this.options.lives||1/0}getAssistant(i){return $t.createAssistantToTheTransportManager(this,i,{minPingDelay:this.options.minPingDelay,maxPingDelay:this.options.maxPingDelay})}isAlive(){return this.livesLeft>0}reportDeath(){this.livesLeft-=1}}class hn{constructor(i,a){this.strategies=i,this.loop=!!a.loop,this.failFast=!!a.failFast,this.timeout=a.timeout,this.timeoutLimit=a.timeoutLimit}isSupported(){return sr(this.strategies,ae.method("isSupported"))}connect(i,a){var f=this.strategies,g=0,y=this.timeout,E=null,$=(q,V)=>{V?a(null,V):(g=g+1,this.loop&&(g=g%f.length),g<f.length?(y&&(y=y*2,this.timeoutLimit&&(y=Math.min(y,this.timeoutLimit))),E=this.tryStrategy(f[g],i,{timeout:y,failFast:this.failFast},$)):a(!0))};return E=this.tryStrategy(f[g],i,{timeout:y,failFast:this.failFast},$),{abort:function(){E.abort()},forceMinPriority:function(q){i=q,E&&E.forceMinPriority(q)}}}tryStrategy(i,a,f,g){var y=null,E=null;return f.timeout>0&&(y=new ke(f.timeout,function(){E.abort(),g(!0)})),E=i.connect(a,function($,q){$&&y&&y.isRunning()&&!f.failFast||(y&&y.ensureAborted(),g($,q))}),{abort:function(){y&&y.ensureAborted(),E.abort()},forceMinPriority:function($){E.forceMinPriority($)}}}}class oi{constructor(i){this.strategies=i}isSupported(){return sr(this.strategies,ae.method("isSupported"))}connect(i,a){return ml(this.strategies,i,function(f,g){return function(y,E){if(g[f].error=y,y){bl(g)&&a(!0);return}Lt(g,function($){$.forceMinPriority(E.transport.priority)}),a(null,E)}})}}function ml(l,i,a){var f=An(l,function(g,y,E,$){return g.connect(i,a(y,$))});return{abort:function(){Lt(f,kl)},forceMinPriority:function(g){Lt(f,function(y){y.forceMinPriority(g)})}}}function bl(l){return Qo(l,function(i){return!!i.error})}function kl(l){!l.error&&!l.aborted&&(l.abort(),l.aborted=!0)}class _l{constructor(i,a,f){this.strategy=i,this.transports=a,this.ttl=f.ttl||18e5,this.usingTLS=f.useTLS,this.timeline=f.timeline}isSupported(){return this.strategy.isSupported()}connect(i,a){var f=this.usingTLS,g=vl(f),y=g&&g.cacheSkipCount?g.cacheSkipCount:0,E=[this.strategy];if(g&&g.timestamp+this.ttl>=ae.now()){var $=this.transports[g.transport];$&&(["ws","wss"].includes(g.transport)||y>3?(this.timeline.info({cached:!0,transport:g.transport,latency:g.latency}),E.push(new hn([$],{timeout:g.latency*2+1e3,failFast:!0}))):y++)}var q=ae.now(),V=E.pop().connect(i,function ee(Se,oo){Se?(ds(f),E.length>0?(q=ae.now(),V=E.pop().connect(i,ee)):a(Se)):(yl(f,oo.transport.name,ae.now()-q,y),a(null,oo))});return{abort:function(){V.abort()},forceMinPriority:function(ee){i=ee,V&&V.forceMinPriority(ee)}}}}function ii(l){return"pusherTransport"+(l?"TLS":"NonTLS")}function vl(l){var i=H.getLocalStorage();if(i)try{var a=i[ii(l)];if(a)return JSON.parse(a)}catch{ds(l)}return null}function yl(l,i,a,f){var g=H.getLocalStorage();if(g)try{g[ii(l)]=Ze({timestamp:ae.now(),transport:i,latency:a,cacheSkipCount:f})}catch{}}function ds(l){var i=H.getLocalStorage();if(i)try{delete i[ii(l)]}catch{}}class to{constructor(i,{delay:a}){this.strategy=i,this.options={delay:a}}isSupported(){return this.strategy.isSupported()}connect(i,a){var f=this.strategy,g,y=new ke(this.options.delay,function(){g=f.connect(i,a)});return{abort:function(){y.ensureAborted(),g&&g.abort()},forceMinPriority:function(E){i=E,g&&g.forceMinPriority(E)}}}}class mr{constructor(i,a,f){this.test=i,this.trueBranch=a,this.falseBranch=f}isSupported(){var i=this.test()?this.trueBranch:this.falseBranch;return i.isSupported()}connect(i,a){var f=this.test()?this.trueBranch:this.falseBranch;return f.connect(i,a)}}class wl{constructor(i){this.strategy=i}isSupported(){return this.strategy.isSupported()}connect(i,a){var f=this.strategy.connect(i,function(g,y){y&&f.abort(),a(g,y)});return f}}function br(l){return function(){return l.isSupported()}}var xl=function(l,i,a){var f={};function g(Ss,vu,yu,wu,xu){var Ts=a(l,Ss,vu,yu,wu,xu);return f[Ss]=Ts,Ts}var y=Object.assign({},i,{hostNonTLS:l.wsHost+":"+l.wsPort,hostTLS:l.wsHost+":"+l.wssPort,httpPath:l.wsPath}),E=Object.assign({},y,{useTLS:!0}),$=Object.assign({},i,{hostNonTLS:l.httpHost+":"+l.httpPort,hostTLS:l.httpHost+":"+l.httpsPort,httpPath:l.httpPath}),q={loop:!0,timeout:15e3,timeoutLimit:6e4},V=new us({minPingDelay:1e4,maxPingDelay:l.activityTimeout}),ee=new us({lives:2,minPingDelay:1e4,maxPingDelay:l.activityTimeout}),Se=g("ws","ws",3,y,V),oo=g("wss","ws",3,E,V),gu=g("sockjs","sockjs",1,$),ks=g("xhr_streaming","xhr_streaming",1,$,ee),mu=g("xdr_streaming","xdr_streaming",1,$,ee),_s=g("xhr_polling","xhr_polling",1,$),bu=g("xdr_polling","xdr_polling",1,$),vs=new hn([Se],q),ku=new hn([oo],q),_u=new hn([gu],q),ys=new hn([new mr(br(ks),ks,mu)],q),ws=new hn([new mr(br(_s),_s,bu)],q),xs=new hn([new mr(br(ys),new oi([ys,new to(ws,{delay:4e3})]),ws)],q),ci=new mr(br(xs),xs,_u),li;return i.useTLS?li=new oi([vs,new to(ci,{delay:2e3})]):li=new oi([vs,new to(ku,{delay:2e3}),new to(ci,{delay:5e3})]),new _l(new wl(new mr(br(Se),li,ci)),f,{ttl:18e5,timeline:i.timeline,useTLS:i.useTLS})};const Sl=xl;function Tl(){var l=this;l.timeline.info(l.buildTimelineMessage({transport:l.name+(l.options.useTLS?"s":"")})),l.hooks.isInitialized()?l.changeState("initialized"):l.hooks.file?(l.changeState("initializing"),P.load(l.hooks.file,{useTLS:l.options.useTLS},function(i,a){l.hooks.isInitialized()?(l.changeState("initialized"),a(!0)):(i&&l.onError(i),l.onClose(),a(!1))})):l.onClose()}var El={getRequest:function(l){var i=new window.XDomainRequest;return i.ontimeout=function(){l.emit("error",new M),l.close()},i.onerror=function(a){l.emit("error",a),l.close()},i.onprogress=function(){i.responseText&&i.responseText.length>0&&l.onChunk(200,i.responseText)},i.onload=function(){i.responseText&&i.responseText.length>0&&l.onChunk(200,i.responseText),l.emit("finished",200),l.close()},i},abortRequest:function(l){l.ontimeout=l.onerror=l.onprogress=l.onload=null,l.abort()}};const Al=El,Cl=256*1024;class Pl extends dt{constructor(i,a,f){super(),this.hooks=i,this.method=a,this.url=f}start(i){this.position=0,this.xhr=this.hooks.getRequest(this),this.unloader=()=>{this.close()},H.addUnloadListener(this.unloader),this.xhr.open(this.method,this.url,!0),this.xhr.setRequestHeader&&this.xhr.setRequestHeader("Content-Type","application/json"),this.xhr.send(i)}close(){this.unloader&&(H.removeUnloadListener(this.unloader),this.unloader=null),this.xhr&&(this.hooks.abortRequest(this.xhr),this.xhr=null)}onChunk(i,a){for(;;){var f=this.advanceBuffer(a);if(f)this.emit("chunk",{status:i,data:f});else break}this.isBufferTooLong(a)&&this.emit("buffer_too_long")}advanceBuffer(i){var a=i.slice(this.position),f=a.indexOf(`
1375
- `);return f!==-1?(this.position+=f+1,a.slice(0,f)):null}isBufferTooLong(i){return this.position===i.length&&i.length>Cl}}var si;(function(l){l[l.CONNECTING=0]="CONNECTING",l[l.OPEN=1]="OPEN",l[l.CLOSED=3]="CLOSED"})(si||(si={}));const fn=si;var Rl=1;class Ll{constructor(i,a){this.hooks=i,this.session=hs(1e3)+"/"+Nl(8),this.location=zl(a),this.readyState=fn.CONNECTING,this.openStream()}send(i){return this.sendRaw(JSON.stringify([i]))}ping(){this.hooks.sendHeartbeat(this)}close(i,a){this.onClose(i,a,!0)}sendRaw(i){if(this.readyState===fn.OPEN)try{return H.createSocketRequest("POST",ps(Il(this.location,this.session))).start(i),!0}catch{return!1}else return!1}reconnect(){this.closeStream(),this.openStream()}onClose(i,a,f){this.closeStream(),this.readyState=fn.CLOSED,this.onclose&&this.onclose({code:i,reason:a,wasClean:f})}onChunk(i){if(i.status===200){this.readyState===fn.OPEN&&this.onActivity();var a,f=i.data.slice(0,1);switch(f){case"o":a=JSON.parse(i.data.slice(1)||"{}"),this.onOpen(a);break;case"a":a=JSON.parse(i.data.slice(1)||"[]");for(var g=0;g<a.length;g++)this.onEvent(a[g]);break;case"m":a=JSON.parse(i.data.slice(1)||"null"),this.onEvent(a);break;case"h":this.hooks.onHeartbeat(this);break;case"c":a=JSON.parse(i.data.slice(1)||"[]"),this.onClose(a[0],a[1],!0);break}}}onOpen(i){this.readyState===fn.CONNECTING?(i&&i.hostname&&(this.location.base=$l(this.location.base,i.hostname)),this.readyState=fn.OPEN,this.onopen&&this.onopen()):this.onClose(1006,"Server lost session",!0)}onEvent(i){this.readyState===fn.OPEN&&this.onmessage&&this.onmessage({data:i})}onActivity(){this.onactivity&&this.onactivity()}onError(i){this.onerror&&this.onerror(i)}openStream(){this.stream=H.createSocketRequest("POST",ps(this.hooks.getReceiveURL(this.location,this.session))),this.stream.bind("chunk",i=>{this.onChunk(i)}),this.stream.bind("finished",i=>{this.hooks.onFinished(this,i)}),this.stream.bind("buffer_too_long",()=>{this.reconnect()});try{this.stream.start()}catch(i){ae.defer(()=>{this.onError(i),this.onClose(1006,"Could not start streaming",!1)})}}closeStream(){this.stream&&(this.stream.unbind_all(),this.stream.close(),this.stream=null)}}function zl(l){var i=/([^\?]*)\/*(\??.*)/.exec(l);return{base:i[1],queryString:i[2]}}function Il(l,i){return l.base+"/"+i+"/xhr_send"}function ps(l){var i=l.indexOf("?")===-1?"?":"&";return l+i+"t="+ +new Date+"&n="+Rl++}function $l(l,i){var a=/(https?:\/\/)([^\/:]+)((\/|:)?.*)/.exec(l);return a[1]+i+a[3]}function hs(l){return H.randomInt(l)}function Nl(l){for(var i=[],a=0;a<l;a++)i.push(hs(32).toString(32));return i.join("")}const Ol=Ll;var Dl={getReceiveURL:function(l,i){return l.base+"/"+i+"/xhr_streaming"+l.queryString},onHeartbeat:function(l){l.sendRaw("[]")},sendHeartbeat:function(l){l.sendRaw("[]")},onFinished:function(l,i){l.onClose(1006,"Connection interrupted ("+i+")",!1)}};const Ml=Dl;var Ul={getReceiveURL:function(l,i){return l.base+"/"+i+"/xhr"+l.queryString},onHeartbeat:function(){},sendHeartbeat:function(l){l.sendRaw("[]")},onFinished:function(l,i){i===200?l.reconnect():l.onClose(1006,"Connection interrupted ("+i+")",!1)}};const jl=Ul;var Zl={getRequest:function(l){var i=H.getXHRAPI(),a=new i;return a.onreadystatechange=a.onprogress=function(){switch(a.readyState){case 3:a.responseText&&a.responseText.length>0&&l.onChunk(a.status,a.responseText);break;case 4:a.responseText&&a.responseText.length>0&&l.onChunk(a.status,a.responseText),l.emit("finished",a.status),l.close();break}},a},abortRequest:function(l){l.onreadystatechange=null,l.abort()}};const ql=Zl;var Hl={createStreamingSocket(l){return this.createSocket(Ml,l)},createPollingSocket(l){return this.createSocket(jl,l)},createSocket(l,i){return new Ol(l,i)},createXHR(l,i){return this.createRequest(ql,l,i)},createRequest(l,i,a){return new Pl(l,i,a)}};const fs=Hl;fs.createXDR=function(l,i){return this.createRequest(Al,l,i)};var Fl={nextAuthCallbackID:1,auth_callbacks:{},ScriptReceivers:h,DependenciesReceivers:w,getDefaultStrategy:Sl,Transports:pt,transportConnectionInitializer:Tl,HTTPFactory:fs,TimelineTransport:Bt,getXHRAPI(){return window.XMLHttpRequest},getWebSocketAPI(){return window.WebSocket||window.MozWebSocket},setup(l){window.Pusher=l;var i=()=>{this.onDocumentBody(l.ready)};window.JSON?i():P.load("json2",{},i)},getDocument(){return document},getProtocol(){return this.getDocument().location.protocol},getAuthorizers(){return{ajax:qt,jsonp:lr}},onDocumentBody(l){document.body?l():setTimeout(()=>{this.onDocumentBody(l)},0)},createJSONPRequest(l,i){return new Cn(l,i)},createScriptRequest(l){return new Br(l)},getLocalStorage(){try{return window.localStorage}catch{return}},createXHR(){return this.getXHRAPI()?this.createXMLHttpRequest():this.createMicrosoftXHR()},createXMLHttpRequest(){var l=this.getXHRAPI();return new l},createMicrosoftXHR(){return new ActiveXObject("Microsoft.XMLHTTP")},getNetwork(){return Yr},createWebSocket(l){var i=this.getWebSocketAPI();return new i(l)},createSocketRequest(l,i){if(this.isXHRSupported())return this.HTTPFactory.createXHR(l,i);if(this.isXDRSupported(i.indexOf("https:")===0))return this.HTTPFactory.createXDR(l,i);throw"Cross-origin HTTP requests are not supported"},isXHRSupported(){var l=this.getXHRAPI();return!!l&&new l().withCredentials!==void 0},isXDRSupported(l){var i=l?"https:":"http:",a=this.getProtocol();return!!window.XDomainRequest&&a===i},addUnloadListener(l){window.addEventListener!==void 0?window.addEventListener("unload",l,!1):window.attachEvent!==void 0&&window.attachEvent("onunload",l)},removeUnloadListener(l){window.addEventListener!==void 0?window.removeEventListener("unload",l,!1):window.detachEvent!==void 0&&window.detachEvent("onunload",l)},randomInt(l){return Math.floor(function(){return(window.crypto||window.msCrypto).getRandomValues(new Uint32Array(1))[0]/Math.pow(2,32)}()*l)}};const H=Fl;var ai;(function(l){l[l.ERROR=3]="ERROR",l[l.INFO=6]="INFO",l[l.DEBUG=7]="DEBUG"})(ai||(ai={}));const no=ai;class Bl{constructor(i,a,f){this.key=i,this.session=a,this.events=[],this.options=f||{},this.sent=0,this.uniqueID=0}log(i,a){i<=this.options.level&&(this.events.push(we({},a,{timestamp:ae.now()})),this.options.limit&&this.events.length>this.options.limit&&this.events.shift())}error(i){this.log(no.ERROR,i)}info(i){this.log(no.INFO,i)}debug(i){this.log(no.DEBUG,i)}isEmpty(){return this.events.length===0}send(i,a){var f=we({session:this.session,bundle:this.sent+1,key:this.key,lib:"js",version:this.options.version,cluster:this.options.cluster,features:this.options.features,timeline:this.events},this.options.params);return this.events=[],i(f,(g,y)=>{g||this.sent++,a&&a(g,y)}),!0}generateUniqueID(){return this.uniqueID++,this.uniqueID}}class Gl{constructor(i,a,f,g){this.name=i,this.priority=a,this.transport=f,this.options=g||{}}isSupported(){return this.transport.isSupported({useTLS:this.options.useTLS})}connect(i,a){if(this.isSupported()){if(this.priority<i)return gs(new se,a)}else return gs(new Y,a);var f=!1,g=this.transport.createConnection(this.name,this.priority,this.options.key,this.options),y=null,E=function(){g.unbind("initialized",E),g.connect()},$=function(){y=$t.createHandshake(g,function(Se){f=!0,ee(),a(null,Se)})},q=function(Se){ee(),a(Se)},V=function(){ee();var Se;Se=Ze(g),a(new ve(Se))},ee=function(){g.unbind("initialized",E),g.unbind("open",$),g.unbind("error",q),g.unbind("closed",V)};return g.bind("initialized",E),g.bind("open",$),g.bind("error",q),g.bind("closed",V),g.initialize(),{abort:()=>{f||(ee(),y?y.close():g.close())},forceMinPriority:Se=>{f||this.priority<Se&&(y?y.close():g.close())}}}}function gs(l,i){return ae.defer(function(){i(l)}),{abort:function(){},forceMinPriority:function(){}}}const{Transports:Wl}=H;var Jl=function(l,i,a,f,g,y){var E=Wl[a];if(!E)throw new Xe(a);var $=(!l.enabledTransports||ir(l.enabledTransports,i)!==-1)&&(!l.disabledTransports||ir(l.disabledTransports,i)===-1),q;return $?(g=Object.assign({ignoreNullOrigin:l.ignoreNullOrigin},g),q=new Gl(i,f,y?y.getAssistant(E):E,g)):q=Xl,q},Xl={isSupported:function(){return!1},connect:function(l,i){var a=ae.defer(function(){i(new Y)});return{abort:function(){a.ensureAborted()},forceMinPriority:function(){}}}};function Vl(l){if(l==null)throw"You must pass an options object";if(l.cluster==null)throw"Options object must provide a cluster";"disableStats"in l&&ce.warn("The disableStats option is deprecated in favor of enableStats")}const Yl=(l,i)=>{var a="socket_id="+encodeURIComponent(l.socketId);for(var f in i.params)a+="&"+encodeURIComponent(f)+"="+encodeURIComponent(i.params[f]);if(i.paramsProvider!=null){let g=i.paramsProvider();for(var f in g)a+="&"+encodeURIComponent(f)+"="+encodeURIComponent(g[f])}return a},Kl=l=>{if(typeof H.getAuthorizers()[l.transport]>"u")throw`'${l.transport}' is not a recognized auth transport`;return(i,a)=>{const f=Yl(i,l);H.getAuthorizers()[l.transport](H,f,l,x.UserAuthentication,a)}},Ql=(l,i)=>{var a="socket_id="+encodeURIComponent(l.socketId);a+="&channel_name="+encodeURIComponent(l.channelName);for(var f in i.params)a+="&"+encodeURIComponent(f)+"="+encodeURIComponent(i.params[f]);if(i.paramsProvider!=null){let g=i.paramsProvider();for(var f in g)a+="&"+encodeURIComponent(f)+"="+encodeURIComponent(g[f])}return a},eu=l=>{if(typeof H.getAuthorizers()[l.transport]>"u")throw`'${l.transport}' is not a recognized auth transport`;return(i,a)=>{const f=Ql(i,l);H.getAuthorizers()[l.transport](H,f,l,x.ChannelAuthorization,a)}},tu=(l,i,a)=>{const f={authTransport:i.transport,authEndpoint:i.endpoint,auth:{params:i.params,headers:i.headers}};return(g,y)=>{const E=l.channel(g.channelName);a(E,f).authorize(g.socketId,y)}};function ms(l,i){let a={activityTimeout:l.activityTimeout||m.activityTimeout,cluster:l.cluster,httpPath:l.httpPath||m.httpPath,httpPort:l.httpPort||m.httpPort,httpsPort:l.httpsPort||m.httpsPort,pongTimeout:l.pongTimeout||m.pongTimeout,statsHost:l.statsHost||m.stats_host,unavailableTimeout:l.unavailableTimeout||m.unavailableTimeout,wsPath:l.wsPath||m.wsPath,wsPort:l.wsPort||m.wsPort,wssPort:l.wssPort||m.wssPort,enableStats:su(l),httpHost:nu(l),useTLS:iu(l),wsHost:ru(l),userAuthenticator:au(l),channelAuthorizer:lu(l,i)};return"disabledTransports"in l&&(a.disabledTransports=l.disabledTransports),"enabledTransports"in l&&(a.enabledTransports=l.enabledTransports),"ignoreNullOrigin"in l&&(a.ignoreNullOrigin=l.ignoreNullOrigin),"timelineParams"in l&&(a.timelineParams=l.timelineParams),"nacl"in l&&(a.nacl=l.nacl),a}function nu(l){return l.httpHost?l.httpHost:l.cluster?`sockjs-${l.cluster}.pusher.com`:m.httpHost}function ru(l){return l.wsHost?l.wsHost:ou(l.cluster)}function ou(l){return`ws-${l}.pusher.com`}function iu(l){return H.getProtocol()==="https:"?!0:l.forceTLS!==!1}function su(l){return"enableStats"in l?l.enableStats:"disableStats"in l?!l.disableStats:!1}const bs=l=>"customHandler"in l&&l.customHandler!=null;function au(l){const i=Object.assign(Object.assign({},m.userAuthentication),l.userAuthentication);return bs(i)?i.customHandler:Kl(i)}function cu(l,i){let a;if("channelAuthorization"in l)a=Object.assign(Object.assign({},m.channelAuthorization),l.channelAuthorization);else if(a={transport:l.authTransport||m.authTransport,endpoint:l.authEndpoint||m.authEndpoint},"auth"in l&&("params"in l.auth&&(a.params=l.auth.params),"headers"in l.auth&&(a.headers=l.auth.headers)),"authorizer"in l)return{customHandler:tu(i,a,l.authorizer)};return a}function lu(l,i){const a=cu(l,i);return bs(a)?a.customHandler:eu(a)}class uu extends dt{constructor(i){super(function(a,f){ce.debug(`No callbacks on watchlist events for ${a}`)}),this.pusher=i,this.bindWatchlistInternalEvent()}handleEvent(i){i.data.events.forEach(a=>{this.emit(a.name,a)})}bindWatchlistInternalEvent(){this.pusher.connection.bind("message",i=>{var a=i.event;a==="pusher_internal:watchlist_events"&&this.handleEvent(i)})}}function du(){let l,i;return{promise:new Promise((f,g)=>{l=f,i=g}),resolve:l,reject:i}}const pu=du;class hu extends dt{constructor(i){super(function(a,f){ce.debug("No callbacks on user for "+a)}),this.signin_requested=!1,this.user_data=null,this.serverToUserChannel=null,this.signinDonePromise=null,this._signinDoneResolve=null,this._onAuthorize=(a,f)=>{if(a){ce.warn(`Error during signin: ${a}`),this._cleanup();return}this.pusher.send_event("pusher:signin",{auth:f.auth,user_data:f.user_data})},this.pusher=i,this.pusher.connection.bind("state_change",({previous:a,current:f})=>{a!=="connected"&&f==="connected"&&this._signin(),a==="connected"&&f!=="connected"&&(this._cleanup(),this._newSigninPromiseIfNeeded())}),this.watchlist=new uu(i),this.pusher.connection.bind("message",a=>{var f=a.event;f==="pusher:signin_success"&&this._onSigninSuccess(a.data),this.serverToUserChannel&&this.serverToUserChannel.name===a.channel&&this.serverToUserChannel.handleEvent(a)})}signin(){this.signin_requested||(this.signin_requested=!0,this._signin())}_signin(){this.signin_requested&&(this._newSigninPromiseIfNeeded(),this.pusher.connection.state==="connected"&&this.pusher.config.userAuthenticator({socketId:this.pusher.connection.socket_id},this._onAuthorize))}_onSigninSuccess(i){try{this.user_data=JSON.parse(i.user_data)}catch{ce.error(`Failed parsing user data after signin: ${i.user_data}`),this._cleanup();return}if(typeof this.user_data.id!="string"||this.user_data.id===""){ce.error(`user_data doesn't contain an id. user_data: ${this.user_data}`),this._cleanup();return}this._signinDoneResolve(),this._subscribeChannels()}_subscribeChannels(){const i=a=>{a.subscriptionPending&&a.subscriptionCancelled?a.reinstateSubscription():!a.subscriptionPending&&this.pusher.connection.state==="connected"&&a.subscribe()};this.serverToUserChannel=new L(`#server-to-user-${this.user_data.id}`,this.pusher),this.serverToUserChannel.bind_global((a,f)=>{a.indexOf("pusher_internal:")===0||a.indexOf("pusher:")===0||this.emit(a,f)}),i(this.serverToUserChannel)}_cleanup(){this.user_data=null,this.serverToUserChannel&&(this.serverToUserChannel.unbind_all(),this.serverToUserChannel.disconnect(),this.serverToUserChannel=null),this.signin_requested&&this._signinDoneResolve()}_newSigninPromiseIfNeeded(){if(!this.signin_requested||this.signinDonePromise&&!this.signinDonePromise.done)return;const{promise:i,resolve:a}=pu();i.done=!1;const f=()=>{i.done=!0};i.then(f).catch(f),this.signinDonePromise=i,this._signinDoneResolve=a}}class $e{static ready(){$e.isReady=!0;for(var i=0,a=$e.instances.length;i<a;i++)$e.instances[i].connect()}static getClientFeatures(){return an(ln({ws:H.Transports.ws},function(i){return i.isSupported({})}))}constructor(i,a){fu(i),Vl(a),this.key=i,this.options=a,this.config=ms(this.options,this),this.channels=$t.createChannels(),this.global_emitter=new dt,this.sessionID=H.randomInt(1e9),this.timeline=new Bl(this.key,this.sessionID,{cluster:this.config.cluster,features:$e.getClientFeatures(),params:this.config.timelineParams||{},limit:50,level:no.INFO,version:m.VERSION}),this.config.enableStats&&(this.timelineSender=$t.createTimelineSender(this.timeline,{host:this.config.statsHost,path:"/timeline/v2/"+H.TimelineTransport.name}));var f=g=>H.getDefaultStrategy(this.config,g,Jl);this.connection=$t.createConnectionManager(this.key,{getStrategy:f,timeline:this.timeline,activityTimeout:this.config.activityTimeout,pongTimeout:this.config.pongTimeout,unavailableTimeout:this.config.unavailableTimeout,useTLS:!!this.config.useTLS}),this.connection.bind("connected",()=>{this.subscribeAll(),this.timelineSender&&this.timelineSender.send(this.connection.isUsingTLS())}),this.connection.bind("message",g=>{var y=g.event,E=y.indexOf("pusher_internal:")===0;if(g.channel){var $=this.channel(g.channel);$&&$.handleEvent(g)}E||this.global_emitter.emit(g.event,g.data)}),this.connection.bind("connecting",()=>{this.channels.disconnect()}),this.connection.bind("disconnected",()=>{this.channels.disconnect()}),this.connection.bind("error",g=>{ce.warn(g)}),$e.instances.push(this),this.timeline.info({instances:$e.instances.length}),this.user=new hu(this),$e.isReady&&this.connect()}switchCluster(i){const{appKey:a,cluster:f}=i;this.key=a,this.options=Object.assign(Object.assign({},this.options),{cluster:f}),this.config=ms(this.options,this),this.connection.switchCluster(this.key)}channel(i){return this.channels.find(i)}allChannels(){return this.channels.all()}connect(){if(this.connection.connect(),this.timelineSender&&!this.timelineSenderTimer){var i=this.connection.isUsingTLS(),a=this.timelineSender;this.timelineSenderTimer=new sn(6e4,function(){a.send(i)})}}disconnect(){this.connection.disconnect(),this.timelineSenderTimer&&(this.timelineSenderTimer.ensureAborted(),this.timelineSenderTimer=null)}bind(i,a,f){return this.global_emitter.bind(i,a,f),this}unbind(i,a,f){return this.global_emitter.unbind(i,a,f),this}bind_global(i){return this.global_emitter.bind_global(i),this}unbind_global(i){return this.global_emitter.unbind_global(i),this}unbind_all(i){return this.global_emitter.unbind_all(),this}subscribeAll(){var i;for(i in this.channels.channels)this.channels.channels.hasOwnProperty(i)&&this.subscribe(i)}subscribe(i){var a=this.channels.add(i,this);return a.subscriptionPending&&a.subscriptionCancelled?a.reinstateSubscription():!a.subscriptionPending&&this.connection.state==="connected"&&a.subscribe(),a}unsubscribe(i){var a=this.channels.find(i);a&&a.subscriptionPending?a.cancelSubscription():(a=this.channels.remove(i),a&&a.subscribed&&a.unsubscribe())}send_event(i,a,f){return this.connection.send_event(i,a,f)}shouldUseTLS(){return this.config.useTLS}signin(){this.user.signin()}}$e.instances=[],$e.isReady=!1,$e.logToConsole=!1,$e.Runtime=H,$e.ScriptReceivers=H.ScriptReceivers,$e.DependenciesReceivers=H.DependenciesReceivers,$e.auth_callbacks=H.auth_callbacks;const ro=$e;function fu(l){if(l==null)throw"You must pass your app key when you instantiate Pusher."}H.setup($e)}},r={};function o(c){var u=r[c];if(u!==void 0)return u.exports;var d=r[c]={exports:{}};return n[c].call(d.exports,d,d.exports,o),d.exports}o.d=(c,u)=>{for(var d in u)o.o(u,d)&&!o.o(c,d)&&Object.defineProperty(c,d,{enumerable:!0,get:u[d]})},o.o=(c,u)=>Object.prototype.hasOwnProperty.call(c,u);var s=o(721);return s})())})(kc);var Xg=kc.exports;const Vg=Jg(Xg),lo={TASK_STATUS_UPDATED:"task:status:updated",TASK_INTERACTION_CREATED:"task:interaction:created",TASK_INTERACTION_ANSWERED:"task:interaction:answered",TASK_BROWSER_COMMAND_CREATED:"task:browser-command:created"};let kt=null,In=null;async function Yg(e){return In||(In=(async()=>{const t=e.backendUrl.replace(/\/+$/,""),n=await fetch(`${t}/api/settings`,{headers:{Authorization:`Bearer ${e.token}`}});if(!n.ok)throw new Error(`Failed to fetch settings: HTTP ${n.status}`);const r=await n.json();kt=new Vg(r.pusher.key,{cluster:r.pusher.cluster||"local",forceTLS:!0,wsHost:r.pusher.wsHost||void 0,wsPort:r.pusher.wssPort,wssPort:r.pusher.wssPort,enabledTransports:r.pusher.wsHost?["ws"]:void 0,channelAuthorization:{customHandler:({socketId:o,channelName:s},c)=>{fetch(`${t}/api/pusher/auth`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e.token}`},body:JSON.stringify({socket_id:o,channel_name:s})}).then(u=>u.json()).then(u=>c(null,u)).catch(u=>c(u instanceof Error?u:new Error(String(u)),null))}}})})(),In.catch(()=>{In=null}),In)}function Kg(e){if(!e||!kt)return null;let t=!1;const n=({current:r})=>{r==="connected"&&t?(t=!1,e()):r!=="connected"&&(t=!0)};return kt.connection.bind("state_change",n),()=>kt==null?void 0:kt.connection.unbind("state_change",n)}async function Qg(e,t,n){if(await Yg(e),!kt)return()=>{};const r=kt.subscribe(`private-task-${t}`);n.onStatusUpdate&&r.bind(lo.TASK_STATUS_UPDATED,n.onStatusUpdate),n.onInteractionCreated&&r.bind(lo.TASK_INTERACTION_CREATED,n.onInteractionCreated),n.onInteractionAnswered&&r.bind(lo.TASK_INTERACTION_ANSWERED,n.onInteractionAnswered),n.onBrowserCommandCreated&&r.bind(lo.TASK_BROWSER_COMMAND_CREATED,n.onBrowserCommandCreated);const o=Kg(n.onReconnect);return()=>{r.unbind_all(),kt==null||kt.unsubscribe(`private-task-${t}`),o==null||o()}}const qi="ap-sdk-active-automation";function em(){try{const e=sessionStorage.getItem(qi);if(!e)return null;const t=JSON.parse(e);return t!=null&&t.taskId&&(t!=null&&t.backendUrl)&&(t!=null&&t.title)?t:null}catch{return null}}function _c(e){try{sessionStorage.setItem(qi,JSON.stringify(e))}catch{}}function vc(){try{sessionStorage.removeItem(qi)}catch{}}async function tm(e){var s;try{(s=e.focus)==null||s.call(e)}catch{}e.scrollIntoView({block:"center",inline:"center",behavior:"instant"});let t=e.getBoundingClientRect();t.width===0&&t.height===0&&(await nm(),t=e.getBoundingClientRect());const n=t.left+t.width/2,r=t.top+t.height/2,o={bubbles:!0,cancelable:!0,clientX:n,clientY:r};typeof PointerEvent=="function"&&e.dispatchEvent(new PointerEvent("pointerdown",o)),e.dispatchEvent(new MouseEvent("mousedown",o)),typeof PointerEvent=="function"&&e.dispatchEvent(new PointerEvent("pointerup",o)),e.dispatchEvent(new MouseEvent("mouseup",o)),e.click()}function nm(){return new Promise(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(()=>e()):setTimeout(e,16)})}const Hi="shared",yc="ap-sdk-panel-size:",ea=280,ta=200;function rm(e){try{const t=sessionStorage.getItem(yc+e);if(!t)return null;const n=JSON.parse(t);return typeof(n==null?void 0:n.width)=="number"&&typeof(n==null?void 0:n.height)=="number"?n:null}catch{return null}}function om(e,t){try{sessionStorage.setItem(yc+e,JSON.stringify(t))}catch{}}function uo(e,t,n){return Math.min(Math.max(e,t),n)}function na(){return window.innerWidth-32}function ra(){return window.innerHeight-64}function Fi(e,t){const n=rm(t);n&&(e.style.width=`${uo(n.width,ea,na())}px`,e.style.height=`${uo(n.height,ta,ra())}px`);const r=document.createElement("div");r.className="ap-sdk-resize-handle",r.setAttribute("data-ap-sdk","1"),e.appendChild(r);let o=!1,s=0,c=0,u=0,d=0,p=0,h=0;const b=_=>{o&&(p=uo(u+(_.clientX-s),ea,na()),h=uo(d+(_.clientY-c),ta,ra()),e.style.width=`${p}px`,e.style.height=`${h}px`)},m=()=>{o&&(o=!1,document.removeEventListener("pointermove",b),document.removeEventListener("pointerup",m),om(t,{width:p,height:h}))};r.addEventListener("pointerdown",_=>{_.preventDefault(),_.stopPropagation(),o=!0,s=_.clientX,c=_.clientY;const w=e.getBoundingClientRect();u=w.width,d=w.height,p=u,h=d,document.addEventListener("pointermove",b),document.addEventListener("pointerup",m)})}function Bi(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var En=Bi();function wc(e){En=e}var mn={exec:()=>null};function $n(e){let t=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),o=t[r];return o||(o=e(r),t[r]=o),o}}function G(e,t=""){let n=typeof e=="string"?e:e.source,r={replace:(o,s)=>{let c=typeof s=="string"?s:s.source;return c=c.replace(Ue.caret,"$1"),n=n.replace(o,c),r},getRegex:()=>new RegExp(n,t)};return r}var im=((e="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+e)}catch{return!1}})(),Ue={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:$n(e=>new RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:$n(e=>new RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:$n(e=>new RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:$n(e=>new RegExp(`^ {0,${e}}#`)),htmlBeginRegex:$n(e=>new RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:$n(e=>new RegExp(`^ {0,${e}}>`))},sm=/^(?:[ \t]*(?:\n|$))+/,am=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,cm=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Zr=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,lm=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Gi=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,xc=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Sc=G(xc).replace(/bull/g,Gi).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),um=G(xc).replace(/bull/g,Gi).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Wi=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,dm=/^[^\n]+/,Ji=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,pm=G(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Ji).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),hm=G(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,Gi).getRegex(),Ko="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Xi=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,fm=G("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Xi).replace("tag",Ko).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Tc=e=>G(Wi).replace("hr",Zr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~~~)[^\\n]*\\n").replace("list",e).replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ko).getRegex(),gm=Tc(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),mm=Tc(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),bm=G(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",mm).getRegex(),Vi={blockquote:bm,code:am,def:pm,fences:cm,heading:lm,hr:Zr,html:fm,lheading:Sc,list:hm,newline:sm,paragraph:gm,table:mn,text:dm},oa=G("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Zr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~~~)[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ko).getRegex(),km={...Vi,lheading:um,table:oa,paragraph:G(Wi).replace("hr",Zr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",oa).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~~~)[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ko).getRegex()},_m={...Vi,html:G(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Xi).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:mn,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:G(Wi).replace("hr",Zr).replace("heading",` *#{1,6} *[^
1376
- ]`).replace("lheading",Sc).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},vm=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,ym=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Ec=/^( {2,}|\\)\n(?!\s*$)/,wm=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Zt=/[\p{P}\p{S}]/u,rr=/[\s\p{P}\p{S}]/u,qr=/[^\s\p{P}\p{S}]/u,xm=G(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,rr).getRegex(),Sm=/[\p{Pi}\p{Ps}"']/u,Ac=/(?!~)[\p{P}\p{S}]/u,Tm=/(?!~)[\s\p{P}\p{S}]/u,Em=/(?:[^\s\p{P}\p{S}]|~)/u,Am=G(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",im?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Cc=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,Cm=G(Cc,"u").replace(/punct/g,Zt).getRegex(),Pm=G(Cc,"u").replace(/punct/g,Ac).getRegex(),Rm=/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,Lm=G(Rm,"u").replace(/openQuote/g,Sm).replace(/punct/g,Zt).getRegex(),Pc="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",zm=G(Pc,"gu").replace(/notPunctSpace/g,qr).replace(/punctSpace/g,rr).replace(/punct/g,Zt).getRegex(),Im=G(Pc,"gu").replace(/notPunctSpace/g,Em).replace(/punctSpace/g,Tm).replace(/punct/g,Ac).getRegex(),$m="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)",Nm=G($m,"gu").replace(/notPunctSpace/g,qr).replace(/punctSpace/g,rr).replace(/punct/g,Zt).getRegex(),Om=G("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,qr).replace(/punctSpace/g,rr).replace(/punct/g,Zt).getRegex(),Dm="^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)",Mm=G(Dm,"gu").replace(/notPunctSpace/g,qr).replace(/punctSpace/g,rr).replace(/punct/g,Zt).getRegex(),Um=G(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Zt).getRegex(),jm="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",Zm=G(jm,"gu").replace(/notPunctSpace/g,qr).replace(/punctSpace/g,rr).replace(/punct/g,Zt).getRegex(),qm=G(/\\(punct)/,"gu").replace(/punct/g,Zt).getRegex(),Hm=G(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),Fm=G(Xi).replace("(?:-->|$)","-->").getRegex(),Bm=G("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",Fm).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Do=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,Gm=G(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",Do).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Rc=G(/^!?\[(label)\]\[(ref)\]/).replace("label",Do).replace("ref",Ji).getRegex(),Lc=G(/^!?\[(ref)\](?:\[\])?/).replace("ref",Ji).getRegex(),Wm=G("reflink|nolink(?!\\()","g").replace("reflink",Rc).replace("nolink",Lc).getRegex(),ia=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Yi={_backpedal:mn,anyPunctuation:qm,autolink:Hm,blockSkip:Am,br:Ec,code:ym,del:mn,delLDelim:mn,delRDelim:mn,emStrongLDelim:Cm,emStrongRDelimAst:zm,emStrongRDelimUnd:Om,escape:vm,link:Gm,nolink:Lc,punctuation:xm,reflink:Rc,reflinkSearch:Wm,tag:Bm,text:wm,url:mn},Jm={...Yi,emStrongLDelim:Lm,emStrongRDelimAst:Nm,emStrongRDelimUnd:Mm,link:G(/^!?\[(label)\]\((.*?)\)/).replace("label",Do).getRegex(),reflink:G(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Do).getRegex()},Ei={...Yi,emStrongRDelimAst:Im,emStrongLDelim:Pm,delLDelim:Um,delRDelim:Zm,url:G(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",ia).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:G(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",ia).getRegex()},Xm={...Ei,br:G(Ec).replace("{2,}","*").getRegex(),text:G(Ei.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},po={normal:Vi,gfm:km,pedantic:_m},_r={normal:Yi,gfm:Ei,breaks:Xm,pedantic:Jm},Vm={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},sa=e=>Vm[e];function yt(e,t){if(t){if(Ue.escapeTest.test(e))return e.replace(Ue.escapeReplace,sa)}else if(Ue.escapeTestNoEncode.test(e))return e.replace(Ue.escapeReplaceNoEncode,sa);return e}function aa(e){try{e=encodeURI(e).replace(Ue.percentDecode,"%")}catch{return null}return e}function ca(e,t){var s;let n=e.replace(Ue.findPipe,(c,u,d)=>{let p=!1,h=u;for(;--h>=0&&d[h]==="\\";)p=!p;return p?"|":" |"}),r=n.split(Ue.splitPipe),o=0;if(r[0].trim()||r.shift(),r.length>0&&!((s=r.at(-1))!=null&&s.trim())&&r.pop(),t)if(r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;o<r.length;o++)r[o]=r[o].trim().replace(Ue.slashPipe,"|");return r}function Wt(e,t,n){let r=e.length;if(r===0)return"";let o=0;for(;o<r&&e.charAt(r-o-1)===t;)o++;return e.slice(0,r-o)}function la(e){let t=e.split(`
1377
- `),n=t.length-1;for(;n>=0&&Ue.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
1378
- `)}function Ym(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]==="\\")r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}function Km(e,t=0){let n=t,r="";for(let o of e)if(o===" "){let s=4-n%4;r+=" ".repeat(s),n+=s}else r+=o,n++;return r}function ua(e,t,n,r,o){let s=t.href,c=t.title||null,u=e[1].replace(o.other.outputLinkReplace,"$1");r.state.inLink=!0;let d={type:e[0].charAt(0)==="!"?"image":"link",raw:n,href:s,title:c,text:u,tokens:r.inlineTokens(u)};return r.state.inLink=!1,d}function Qm(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let o=r[1];return t.split(`
1379
- `).map(s=>{let c=s.match(n.other.beginningSpace);if(c===null)return s;let[u]=c;return u.length>=o.length?s.slice(o.length):s}).join(`
1380
- `)}var Mo=class{constructor(e){re(this,"options");re(this,"rules");re(this,"lexer");this.options=e||En}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let n=this.options.pedantic?t[0]:la(t[0]),r=n.replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:n,codeBlockStyle:"indented",text:r}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],r=Qm(n,t[3]||"",this.rules);return{type:"code",raw:n,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:r}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let n=t[2].trim();if(this.rules.other.endingHash.test(n)){let r=Wt(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:Wt(t[0],`
1381
- `),depth:t[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:Wt(t[0],`
1382
- `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=Wt(t[0],`
1391
+ */(function(e,t){(function(r,o){e.exports=o()})(self,()=>(()=>{var n={594(a,u){var d=this&&this.__extends||function(){var P=function(T,x){return P=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(R,D){R.__proto__=D}||function(R,D){for(var de in D)D.hasOwnProperty(de)&&(R[de]=D[de])},P(T,x)};return function(T,x){P(T,x);function R(){this.constructor=T}T.prototype=x===null?Object.create(x):(R.prototype=x.prototype,new R)}}();Object.defineProperty(u,"__esModule",{value:!0});var h=256,p=function(){function P(T){T===void 0&&(T="="),this._paddingCharacter=T}return P.prototype.encodedLength=function(T){return this._paddingCharacter?(T+2)/3*4|0:(T*8+5)/6|0},P.prototype.encode=function(T){for(var x="",R=0;R<T.length-2;R+=3){var D=T[R]<<16|T[R+1]<<8|T[R+2];x+=this._encodeByte(D>>>3*6&63),x+=this._encodeByte(D>>>2*6&63),x+=this._encodeByte(D>>>1*6&63),x+=this._encodeByte(D>>>0*6&63)}var de=T.length-R;if(de>0){var D=T[R]<<16|(de===2?T[R+1]<<8:0);x+=this._encodeByte(D>>>3*6&63),x+=this._encodeByte(D>>>2*6&63),de===2?x+=this._encodeByte(D>>>1*6&63):x+=this._paddingCharacter||"",x+=this._paddingCharacter||""}return x},P.prototype.maxDecodedLength=function(T){return this._paddingCharacter?T/4*3|0:(T*6+7)/8|0},P.prototype.decodedLength=function(T){return this.maxDecodedLength(T.length-this._getPaddingLength(T))},P.prototype.decode=function(T){if(T.length===0)return new Uint8Array(0);for(var x=this._getPaddingLength(T),R=T.length-x,D=new Uint8Array(this.maxDecodedLength(R)),de=0,_e=0,Ee=0,qe=0,V=0,Ae=0,Me=0;_e<R-4;_e+=4)qe=this._decodeChar(T.charCodeAt(_e+0)),V=this._decodeChar(T.charCodeAt(_e+1)),Ae=this._decodeChar(T.charCodeAt(_e+2)),Me=this._decodeChar(T.charCodeAt(_e+3)),D[de++]=qe<<2|V>>>4,D[de++]=V<<4|Ae>>>2,D[de++]=Ae<<6|Me,Ee|=qe&h,Ee|=V&h,Ee|=Ae&h,Ee|=Me&h;if(_e<R-1&&(qe=this._decodeChar(T.charCodeAt(_e)),V=this._decodeChar(T.charCodeAt(_e+1)),D[de++]=qe<<2|V>>>4,Ee|=qe&h,Ee|=V&h),_e<R-2&&(Ae=this._decodeChar(T.charCodeAt(_e+2)),D[de++]=V<<4|Ae>>>2,Ee|=Ae&h),_e<R-3&&(Me=this._decodeChar(T.charCodeAt(_e+3)),D[de++]=Ae<<6|Me,Ee|=Me&h),Ee!==0)throw new Error("Base64Coder: incorrect characters for decoding");return D},P.prototype._encodeByte=function(T){var x=T;return x+=65,x+=25-T>>>8&6,x+=51-T>>>8&-75,x+=61-T>>>8&-15,x+=62-T>>>8&3,String.fromCharCode(x)},P.prototype._decodeChar=function(T){var x=h;return x+=(42-T&T-44)>>>8&-h+T-43+62,x+=(46-T&T-48)>>>8&-h+T-47+63,x+=(47-T&T-58)>>>8&-h+T-48+52,x+=(64-T&T-91)>>>8&-h+T-65+0,x+=(96-T&T-123)>>>8&-h+T-97+26,x},P.prototype._getPaddingLength=function(T){var x=0;if(this._paddingCharacter){for(var R=T.length-1;R>=0&&T[R]===this._paddingCharacter;R--)x++;if(T.length<4||x>2)throw new Error("Base64Coder: incorrect padding")}return x},P}();u.Coder=p;var b=new p;function m(P){return b.encode(P)}u.encode=m;function _(P){return b.decode(P)}u.decode=_;var w=function(P){d(T,P);function T(){return P!==null&&P.apply(this,arguments)||this}return T.prototype._encodeByte=function(x){var R=x;return R+=65,R+=25-x>>>8&6,R+=51-x>>>8&-75,R+=61-x>>>8&-13,R+=62-x>>>8&49,String.fromCharCode(R)},T.prototype._decodeChar=function(x){var R=h;return R+=(44-x&x-46)>>>8&-h+x-45+62,R+=(94-x&x-96)>>>8&-h+x-95+63,R+=(47-x&x-58)>>>8&-h+x-48+52,R+=(64-x&x-91)>>>8&-h+x-65+0,R+=(96-x&x-123)>>>8&-h+x-97+26,R},T}(p);u.URLSafeCoder=w;var C=new w;function M(P){return C.encode(P)}u.encodeURLSafe=M;function W(P){return C.decode(P)}u.decodeURLSafe=W,u.encodedLength=function(P){return b.encodedLength(P)},u.maxDecodedLength=function(P){return b.maxDecodedLength(P)},u.decodedLength=function(P){return b.decodedLength(P)}},978(a,u){var d="utf8: invalid source encoding";function h(p){for(var b=[],m=0;m<p.length;m++){var _=p[m];if(_&128){var w=void 0;if(_<224){if(m>=p.length)throw new Error(d);var C=p[++m];if((C&192)!==128)throw new Error(d);_=(_&31)<<6|C&63,w=128}else if(_<240){if(m>=p.length-1)throw new Error(d);var C=p[++m],M=p[++m];if((C&192)!==128||(M&192)!==128)throw new Error(d);_=(_&15)<<12|(C&63)<<6|M&63,w=2048}else if(_<248){if(m>=p.length-2)throw new Error(d);var C=p[++m],M=p[++m],W=p[++m];if((C&192)!==128||(M&192)!==128||(W&192)!==128)throw new Error(d);_=(_&15)<<18|(C&63)<<12|(M&63)<<6|W&63,w=65536}else throw new Error(d);if(_<w||_>=55296&&_<=57343)throw new Error(d);if(_>=65536){if(_>1114111)throw new Error(d);_-=65536,b.push(String.fromCharCode(55296|_>>10)),_=56320|_&1023}}b.push(String.fromCharCode(_))}return b.join("")}u.D4=h},721(a,u,d){a.exports=d(207).default},207(a,u,d){d.d(u,{default:()=>eo});class h{constructor(i,c){this.lastId=0,this.prefix=i,this.name=c}create(i){this.lastId++;var c=this.lastId,f=this.prefix+c,g=this.name+"["+c+"]",y=!1,E=function(){y||(i.apply(null,arguments),y=!0)};return this[c]=E,{number:c,id:f,name:g,callback:E}}remove(i){delete this[i.number]}}var p=new h("_pusher_script_","Pusher.ScriptReceivers"),b={VERSION:"8.5.0",PROTOCOL:7,wsPort:80,wssPort:443,wsPath:"",httpHost:"sockjs.pusher.com",httpPort:80,httpsPort:443,httpPath:"/pusher",stats_host:"stats.pusher.com",authEndpoint:"/pusher/auth",authTransport:"ajax",activityTimeout:12e4,pongTimeout:3e4,unavailableTimeout:1e4,userAuthentication:{endpoint:"/pusher/user-auth",transport:"ajax"},channelAuthorization:{endpoint:"/pusher/auth",transport:"ajax"},cdn_http:"http://js.pusher.com",cdn_https:"https://js.pusher.com",dependency_suffix:""};const m=b;class _{constructor(i){this.options=i,this.receivers=i.receivers||p,this.loading={}}load(i,c,f){var g=this;if(g.loading[i]&&g.loading[i].length>0)g.loading[i].push(f);else{g.loading[i]=[f];var y=F.createScriptRequest(g.getPath(i,c)),E=g.receivers.create(function($){if(g.receivers.remove(E),g.loading[i]){var q=g.loading[i];delete g.loading[i];for(var X=function(xe){xe||y.cleanup()},te=0;te<q.length;te++)q[te]($,X)}});y.send(E)}}getRoot(i){var c,f=F.getDocument().location.protocol;return i&&i.useTLS||f==="https:"?c=this.options.cdn_https:c=this.options.cdn_http,c.replace(/\/*$/,"")+"/"+this.options.version}getPath(i,c){return this.getRoot(c)+"/"+i+this.options.suffix+".js"}}var w=new h("_pusher_dependencies","Pusher.DependenciesReceivers"),C=new _({cdn_http:m.cdn_http,cdn_https:m.cdn_https,version:m.VERSION,suffix:m.dependency_suffix,receivers:w});const M={baseUrl:"https://pusher.com",urls:{authenticationEndpoint:{path:"/docs/channels/server_api/authenticating_users"},authorizationEndpoint:{path:"/docs/channels/server_api/authorizing-users/"},javascriptQuickStart:{path:"/docs/javascript_quick_start"},triggeringClientEvents:{path:"/docs/client_api_guide/client_events#trigger-events"},encryptedChannelSupport:{fullUrl:"https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support"}}},P={buildLogSuffix:function(l){const i="See:",c=M.urls[l];if(!c)return"";let f;return c.fullUrl?f=c.fullUrl:c.path&&(f=M.baseUrl+c.path),f?`${i} ${f}`:""}};var T;(function(l){l.UserAuthentication="user-authentication",l.ChannelAuthorization="channel-authorization"})(T||(T={}));class x extends Error{constructor(i){super(i),Object.setPrototypeOf(this,new.target.prototype)}}class R extends Error{constructor(i){super(i),Object.setPrototypeOf(this,new.target.prototype)}}class D extends Error{constructor(i){super(i),Object.setPrototypeOf(this,new.target.prototype)}}class de extends Error{constructor(i){super(i),Object.setPrototypeOf(this,new.target.prototype)}}class _e extends Error{constructor(i){super(i),Object.setPrototypeOf(this,new.target.prototype)}}class Ee extends Error{constructor(i){super(i),Object.setPrototypeOf(this,new.target.prototype)}}class qe extends Error{constructor(i){super(i),Object.setPrototypeOf(this,new.target.prototype)}}class V extends Error{constructor(i){super(i),Object.setPrototypeOf(this,new.target.prototype)}}class Ae extends Error{constructor(i,c){super(c),this.status=i,Object.setPrototypeOf(this,new.target.prototype)}}const pt=function(l,i,c,f,g){const y=F.createXHR();y.open("POST",c.endpoint,!0),y.setRequestHeader("Content-Type","application/x-www-form-urlencoded");for(var E in c.headers)y.setRequestHeader(E,c.headers[E]);if(c.headersProvider!=null){let $=c.headersProvider();for(var E in $)y.setRequestHeader(E,$[E])}return y.onreadystatechange=function(){if(y.readyState===4)if(y.status===200){let $,q=!1;try{$=JSON.parse(y.responseText),q=!0}catch{g(new Ae(200,`JSON returned from ${f.toString()} endpoint was invalid, yet status code was 200. Data was: ${y.responseText}`),null)}q&&g(null,$)}else{let $="";switch(f){case T.UserAuthentication:$=P.buildLogSuffix("authenticationEndpoint");break;case T.ChannelAuthorization:$=`Clients must be authorized to join private or presence channels. ${P.buildLogSuffix("authorizationEndpoint")}`;break}g(new Ae(y.status,`Unable to retrieve auth string from ${f.toString()} endpoint - received status: ${y.status} from ${c.endpoint}. ${$}`),null)}},y.send(i),y};function Bt(l){return J(Y(l))}var tt=String.fromCharCode,zt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",j=function(l){var i=l.charCodeAt(0);return i<128?l:i<2048?tt(192|i>>>6)+tt(128|i&63):tt(224|i>>>12&15)+tt(128|i>>>6&63)+tt(128|i&63)},Y=function(l){return l.replace(/[^\x00-\x7F]/g,j)},$e=function(l){var i=[0,2,1][l.length%3],c=l.charCodeAt(0)<<16|(l.length>1?l.charCodeAt(1):0)<<8|(l.length>2?l.charCodeAt(2):0),f=[zt.charAt(c>>>18),zt.charAt(c>>>12&63),i>=2?"=":zt.charAt(c>>>6&63),i>=1?"=":zt.charAt(c&63)];return f.join("")},J=window.btoa||function(l){return l.replace(/[\s\S]{1,3}/g,$e)};class ht{constructor(i,c,f,g){this.clear=c,this.timer=i(()=>{this.timer&&(this.timer=g(this.timer))},f)}isRunning(){return this.timer!==null}ensureAborted(){this.timer&&(this.clear(this.timer),this.timer=null)}}const ne=ht;function an(l){window.clearTimeout(l)}function ce(l){window.clearInterval(l)}class re extends ne{constructor(i,c){super(setTimeout,an,i,function(f){return c(),null})}}class Ce extends ne{constructor(i,c){super(setInterval,ce,i,function(f){return c(),f})}}var Pe={now(){return Date.now?Date.now():new Date().valueOf()},defer(l){return new re(0,l)},method(l,...i){var c=Array.prototype.slice.call(arguments,1);return function(f){return f[l].apply(f,c.concat(arguments))}}};const ee=Pe;function we(l,...i){for(var c=0;c<i.length;c++){var f=i[c];for(var g in f)f[g]&&f[g].constructor&&f[g].constructor===Object?l[g]=we(l[g]||{},f[g]):l[g]=f[g]}return l}function Ye(){for(var l=["Pusher"],i=0;i<arguments.length;i++)typeof arguments[i]=="string"?l.push(arguments[i]):l.push(He(arguments[i]));return l.join(" : ")}function rt(l,i){var c=Array.prototype.indexOf;if(l===null)return-1;if(c&&l.indexOf===c)return l.indexOf(i);for(var f=0,g=l.length;f<g;f++)if(l[f]===i)return f;return-1}function Re(l,i){for(var c in l)Object.prototype.hasOwnProperty.call(l,c)&&i(l[c],c,l)}function ot(l){var i=[];return Re(l,function(c,f){i.push(f)}),i}function It(l){var i=[];return Re(l,function(c){i.push(c)}),i}function $t(l,i,c){for(var f=0;f<l.length;f++)i.call(c||window,l[f],f,l)}function Cn(l,i){for(var c=[],f=0;f<l.length;f++)c.push(i(l[f],f,l,c));return c}function Gt(l,i){var c={};return Re(l,function(f,g){c[g]=i(f)}),c}function cn(l,i){i=i||function(g){return!!g};for(var c=[],f=0;f<l.length;f++)i(l[f],f,l,c)&&c.push(l[f]);return c}function ln(l,i){var c={};return Re(l,function(f,g){(i&&i(f,g,l,c)||f)&&(c[g]=f)}),c}function jr(l){var i=[];return Re(l,function(c,f){i.push([f,c])}),i}function ir(l,i){for(var c=0;c<l.length;c++)if(i(l[c],c,l))return!0;return!1}function Xo(l,i){for(var c=0;c<l.length;c++)if(!i(l[c],c,l))return!1;return!0}function sr(l){return Gt(l,function(i){return typeof i=="object"&&(i=He(i)),encodeURIComponent(Bt(i.toString()))})}function un(l){var i=ln(l,function(f){return f!==void 0}),c=Cn(jr(sr(i)),ee.method("join","=")).join("&");return c}function Wt(l){var i=[],c=[];return function f(g,y){var E,$,q;switch(typeof g){case"object":if(!g)return null;for(E=0;E<i.length;E+=1)if(i[E]===g)return{$ref:c[E]};if(i.push(g),c.push(y),Object.prototype.toString.apply(g)==="[object Array]")for(q=[],E=0;E<g.length;E+=1)q[E]=f(g[E],y+"["+E+"]");else{q={};for($ in g)Object.prototype.hasOwnProperty.call(g,$)&&(q[$]=f(g[$],y+"["+JSON.stringify($)+"]"))}return q;case"number":case"string":case"boolean":return g}}(l,"$")}function He(l){try{return JSON.stringify(l)}catch{return JSON.stringify(Wt(l))}}class ar{constructor(){this.globalLog=i=>{window.console&&window.console.log&&window.console.log(i)}}debug(...i){this.log(this.globalLog,i)}warn(...i){this.log(this.globalLogWarn,i)}error(...i){this.log(this.globalLogError,i)}globalLogWarn(i){window.console&&window.console.warn?window.console.warn(i):this.globalLog(i)}globalLogError(i){window.console&&window.console.error?window.console.error(i):this.globalLogWarn(i)}log(i,...c){var f=Ye.apply(this,arguments);eo.log?eo.log(f):eo.logToConsole&&i.bind(this)(f)}}const le=new ar;var Zr=function(l,i,c,f,g){(c.headers!==void 0||c.headersProvider!=null)&&le.warn(`To send headers with the ${f.toString()} request, you must use AJAX, rather than JSONP.`);var y=l.nextAuthCallbackID.toString();l.nextAuthCallbackID++;var E=l.getDocument(),$=E.createElement("script");l.auth_callbacks[y]=function(te){g(null,te)};var q="Pusher.auth_callbacks['"+y+"']";$.src=c.endpoint+"?callback="+encodeURIComponent(q)+"&"+i;var X=E.getElementsByTagName("head")[0]||E.documentElement;X.insertBefore($,X.firstChild)};const cr=Zr;class qr{constructor(i){this.src=i}send(i){var c=this,f="Error loading "+c.src;c.script=document.createElement("script"),c.script.id=i.id,c.script.src=c.src,c.script.type="text/javascript",c.script.charset="UTF-8",c.script.addEventListener?(c.script.onerror=function(){i.callback(f)},c.script.onload=function(){i.callback(null)}):c.script.onreadystatechange=function(){(c.script.readyState==="loaded"||c.script.readyState==="complete")&&i.callback(null)},c.script.async===void 0&&document.attachEvent&&/opera/i.test(navigator.userAgent)?(c.errorScript=document.createElement("script"),c.errorScript.id=i.id+"_error",c.errorScript.text=i.name+"('"+f+"');",c.script.async=c.errorScript.async=!1):c.script.async=!0;var g=document.getElementsByTagName("head")[0];g.insertBefore(c.script,g.firstChild),c.errorScript&&g.insertBefore(c.errorScript,c.script.nextSibling)}cleanup(){this.script&&(this.script.onload=this.script.onerror=null,this.script.onreadystatechange=null),this.script&&this.script.parentNode&&this.script.parentNode.removeChild(this.script),this.errorScript&&this.errorScript.parentNode&&this.errorScript.parentNode.removeChild(this.errorScript),this.script=null,this.errorScript=null}}class Pn{constructor(i,c){this.url=i,this.data=c}send(i){if(!this.request){var c=un(this.data),f=this.url+"/"+i.number+"?"+c;this.request=F.createScriptRequest(f),this.request.send(i)}}cleanup(){this.request&&this.request.cleanup()}}var Rn=function(l,i){return function(c,f){var g="http"+(i?"s":"")+"://",y=g+(l.host||l.options.host)+l.options.path,E=F.createJSONPRequest(y,c),$=F.ScriptReceivers.create(function(q,X){p.remove($),E.cleanup(),X&&X.host&&(l.host=X.host),f&&f(q,X)});E.send($)}},ft={name:"jsonp",getAgent:Rn};const Jt=ft;function dn(l,i,c){var f=l+(i.useTLS?"s":""),g=i.useTLS?i.hostTLS:i.hostNonTLS;return f+"://"+g+c}function pn(l,i){var c="/app/"+l,f="?protocol="+m.PROTOCOL+"&client=js&version="+m.VERSION+(i?"&"+i:"");return c+f}var Vo={getInitial:function(l,i){var c=(i.httpPath||"")+pn(l,"flash=false");return dn("ws",i,c)}},Ln={getInitial:function(l,i){var c=(i.httpPath||"/pusher")+pn(l);return dn("http",i,c)}},zn={getInitial:function(l,i){return dn("http",i,i.httpPath||"/pusher")},getPath:function(l,i){return pn(l)}};class Yo{constructor(){this._callbacks={}}get(i){return this._callbacks[Nt(i)]}add(i,c,f){var g=Nt(i);this._callbacks[g]=this._callbacks[g]||[],this._callbacks[g].push({fn:c,context:f})}remove(i,c,f){if(!i&&!c&&!f){this._callbacks={};return}var g=i?[Nt(i)]:ot(this._callbacks);c||f?this.removeCallback(g,c,f):this.removeAllCallbacks(g)}removeCallback(i,c,f){$t(i,function(g){this._callbacks[g]=cn(this._callbacks[g]||[],function(y){return c&&c!==y.fn||f&&f!==y.context}),this._callbacks[g].length===0&&delete this._callbacks[g]},this)}removeAllCallbacks(i){$t(i,function(c){delete this._callbacks[c]},this)}}function Nt(l){return"_"+l}class gt{constructor(i){this.callbacks=new Yo,this.global_callbacks=[],this.failThrough=i}bind(i,c,f){return this.callbacks.add(i,c,f),this}bind_global(i){return this.global_callbacks.push(i),this}unbind(i,c,f){return this.callbacks.remove(i,c,f),this}unbind_global(i){return i?(this.global_callbacks=cn(this.global_callbacks||[],c=>c!==i),this):(this.global_callbacks=[],this)}unbind_all(){return this.unbind(),this.unbind_global(),this}emit(i,c,f){for(var g=0;g<this.global_callbacks.length;g++)this.global_callbacks[g](i,c);var y=this.callbacks.get(i),E=[];if(f?E.push(c,f):c&&E.push(c),y&&y.length>0)for(var g=0;g<y.length;g++)y[g].fn.apply(y[g].context||window,E);else this.failThrough&&this.failThrough(i,c);return this}}class Ko extends gt{constructor(i,c,f,g,y){super(),this.initialize=F.transportConnectionInitializer,this.hooks=i,this.name=c,this.priority=f,this.key=g,this.options=y,this.state="new",this.timeline=y.timeline,this.activityTimeout=y.activityTimeout,this.id=this.timeline.generateUniqueID()}handlesActivityChecks(){return!!this.hooks.handlesActivityChecks}supportsPing(){return!!this.hooks.supportsPing}connect(){if(this.socket||this.state!=="initialized")return!1;var i=this.hooks.urls.getInitial(this.key,this.options);try{this.socket=this.hooks.getSocket(i,this.options)}catch(c){return ee.defer(()=>{this.onError(c),this.changeState("closed")}),!1}return this.bindListeners(),le.debug("Connecting",{transport:this.name,url:i}),this.changeState("connecting"),!0}close(){return this.socket?(this.socket.close(),!0):!1}send(i){return this.state==="open"?(ee.defer(()=>{this.socket&&this.socket.send(i)}),!0):!1}ping(){this.state==="open"&&this.supportsPing()&&this.socket.ping()}onOpen(){this.hooks.beforeOpen&&this.hooks.beforeOpen(this.socket,this.hooks.urls.getPath(this.key,this.options)),this.changeState("open"),this.socket.onopen=void 0}onError(i){this.emit("error",{type:"WebSocketError",error:i}),this.timeline.error(this.buildTimelineMessage({error:i.toString()}))}onClose(i){i?this.changeState("closed",{code:i.code,reason:i.reason,wasClean:i.wasClean}):this.changeState("closed"),this.unbindListeners(),this.socket=void 0}onMessage(i){this.emit("message",i)}onActivity(){this.emit("activity")}bindListeners(){this.socket.onopen=()=>{this.onOpen()},this.socket.onerror=i=>{this.onError(i)},this.socket.onclose=i=>{this.onClose(i)},this.socket.onmessage=i=>{this.onMessage(i)},this.supportsPing()&&(this.socket.onactivity=()=>{this.onActivity()})}unbindListeners(){this.socket&&(this.socket.onopen=void 0,this.socket.onerror=void 0,this.socket.onclose=void 0,this.socket.onmessage=void 0,this.supportsPing()&&(this.socket.onactivity=void 0))}changeState(i,c){this.state=i,this.timeline.info(this.buildTimelineMessage({state:i,params:c})),this.emit(i,c)}buildTimelineMessage(i){return we({cid:this.id},i)}}class ue{constructor(i){this.hooks=i}isSupported(i){return this.hooks.isSupported(i)}createConnection(i,c,f,g){return new Ko(this.hooks,i,c,f,g)}}var Xt=new ue({urls:Vo,handlesActivityChecks:!1,supportsPing:!1,isInitialized:function(){return!!F.getWebSocketAPI()},isSupported:function(){return!!F.getWebSocketAPI()},getSocket:function(l){return F.createWebSocket(l)}}),Hr={urls:Ln,handlesActivityChecks:!1,supportsPing:!0,isInitialized:function(){return!0}},lr=we({getSocket:function(l){return F.HTTPFactory.createStreamingSocket(l)}},Hr),In=we({getSocket:function(l){return F.HTTPFactory.createPollingSocket(l)}},Hr),ur={isSupported:function(){return F.isXHRSupported()}},Fr=new ue(we({},lr,ur)),Qo=new ue(we({},In,ur)),it={ws:Xt,xhr_streaming:Fr,xhr_polling:Qo};const st=it;var Br=new ue({file:"sockjs",urls:zn,handlesActivityChecks:!0,supportsPing:!1,isSupported:function(){return!0},isInitialized:function(){return window.SockJS!==void 0},getSocket:function(l,i){return new window.SockJS(l,null,{js_path:C.getPath("sockjs",{useTLS:i.useTLS}),ignore_null_origin:i.ignoreNullOrigin})},beforeOpen:function(l,i){l.send(JSON.stringify({path:i}))}}),dr={isSupported:function(l){var i=F.isXDRSupported(l.useTLS);return i}},pr=new ue(we({},lr,dr)),Gr=new ue(we({},In,dr));st.xdr_streaming=pr,st.xdr_polling=Gr,st.sockjs=Br;const mt=st;class Wr extends gt{constructor(){super();var i=this;window.addEventListener!==void 0&&(window.addEventListener("online",function(){i.emit("online")},!1),window.addEventListener("offline",function(){i.emit("offline")},!1))}isOnline(){return window.navigator.onLine===void 0?!0:window.navigator.onLine}}var Jr=new Wr;class Xr{constructor(i,c,f){this.manager=i,this.transport=c,this.minPingDelay=f.minPingDelay,this.maxPingDelay=f.maxPingDelay,this.pingDelay=void 0}createConnection(i,c,f,g){g=we({},g,{activityTimeout:this.pingDelay});var y=this.transport.createConnection(i,c,f,g),E=null,$=function(){y.unbind("open",$),y.bind("closed",q),E=ee.now()},q=X=>{if(y.unbind("closed",q),X.code===1002||X.code===1003)this.manager.reportDeath();else if(!X.wasClean&&E){var te=ee.now()-E;te<2*this.maxPingDelay&&(this.manager.reportDeath(),this.pingDelay=Math.max(te/2,this.minPingDelay))}};return y.bind("open",$),y}isSupported(i){return this.manager.isAlive()&&this.transport.isSupported(i)}}const hr={decodeMessage:function(l){try{var i=JSON.parse(l.data),c=i.data;if(typeof c=="string")try{c=JSON.parse(i.data)}catch{}var f={event:i.event,channel:i.channel,data:c};return i.user_id&&(f.user_id=i.user_id),f}catch(g){throw{type:"MessageParseError",error:g,data:l.data}}},encodeMessage:function(l){return JSON.stringify(l)},processHandshake:function(l){var i=hr.decodeMessage(l);if(i.event==="pusher:connection_established"){if(!i.data.activity_timeout)throw"No activity timeout specified in handshake";return{action:"connected",id:i.data.socket_id,activityTimeout:i.data.activity_timeout*1e3}}else{if(i.event==="pusher:error")return{action:this.getCloseAction(i.data),error:this.getCloseError(i.data)};throw"Invalid handshake"}},getCloseAction:function(l){return l.code<4e3?l.code>=1002&&l.code<=1004?"backoff":null:l.code===4e3?"tls_only":l.code<4100?"refused":l.code<4200?"backoff":l.code<4300?"retry":"refused"},getCloseError:function(l){return l.code!==1e3&&l.code!==1001?{type:"PusherError",data:{code:l.code,message:l.reason||l.message}}:null}},Ot=hr;class N extends gt{constructor(i,c){super(),this.id=i,this.transport=c,this.activityTimeout=c.activityTimeout,this.bindListeners()}handlesActivityChecks(){return this.transport.handlesActivityChecks()}send(i){return this.transport.send(i)}send_event(i,c,f){var g={event:i,data:c};return f&&(g.channel=f),le.debug("Event sent",g),this.send(Ot.encodeMessage(g))}ping(){this.transport.supportsPing()?this.transport.ping():this.send_event("pusher:ping",{})}close(){this.transport.close()}bindListeners(){var i={message:f=>{var g;try{g=Ot.decodeMessage(f)}catch(y){this.emit("error",{type:"MessageParseError",error:y,data:f.data})}if(g!==void 0){switch(le.debug("Event recd",g),g.event){case"pusher:error":this.emit("error",{type:"PusherError",data:g.data});break;case"pusher:ping":this.emit("ping");break;case"pusher:pong":this.emit("pong");break}this.emit("message",g)}},activity:()=>{this.emit("activity")},error:f=>{this.emit("error",f)},closed:f=>{c(),f&&f.code&&this.handleCloseEvent(f),this.transport=null,this.emit("closed")}},c=()=>{Re(i,(f,g)=>{this.transport.unbind(g,f)})};Re(i,(f,g)=>{this.transport.bind(g,f)})}handleCloseEvent(i){var c=Ot.getCloseAction(i),f=Ot.getCloseError(i);f&&this.emit("error",f),c&&this.emit(c,{action:c,error:f})}}class k{constructor(i,c){this.transport=i,this.callback=c,this.bindListeners()}close(){this.unbindListeners(),this.transport.close()}bindListeners(){this.onMessage=i=>{this.unbindListeners();var c;try{c=Ot.processHandshake(i)}catch(f){this.finish("error",{error:f}),this.transport.close();return}c.action==="connected"?this.finish("connected",{connection:new N(c.id,this.transport),activityTimeout:c.activityTimeout}):(this.finish(c.action,{error:c.error}),this.transport.close())},this.onClosed=i=>{this.unbindListeners();var c=Ot.getCloseAction(i)||"backoff",f=Ot.getCloseError(i);this.finish(c,{error:f})},this.transport.bind("message",this.onMessage),this.transport.bind("closed",this.onClosed)}unbindListeners(){this.transport.unbind("message",this.onMessage),this.transport.unbind("closed",this.onClosed)}finish(i,c){this.callback(we({transport:this.transport,action:i},c))}}class S{constructor(i,c){this.timeline=i,this.options=c||{}}send(i,c){this.timeline.isEmpty()||this.timeline.send(F.TimelineTransport.getAgent(this,i),c)}}class L extends gt{constructor(i,c){super(function(f,g){le.debug("No callbacks on "+i+" for "+f)}),this.name=i,this.pusher=c,this.subscribed=!1,this.subscriptionPending=!1,this.subscriptionCancelled=!1}authorize(i,c){return c(null,{auth:""})}trigger(i,c){if(i.indexOf("client-")!==0)throw new x("Event '"+i+"' does not start with 'client-'");if(!this.subscribed){var f=P.buildLogSuffix("triggeringClientEvents");le.warn(`Client event triggered before channel 'subscription_succeeded' event . ${f}`)}return this.pusher.send_event(i,c,this.name)}disconnect(){this.subscribed=!1,this.subscriptionPending=!1}handleEvent(i){var c=i.event,f=i.data;if(c==="pusher_internal:subscription_succeeded")this.handleSubscriptionSucceededEvent(i);else if(c==="pusher_internal:subscription_count")this.handleSubscriptionCountEvent(i);else if(c.indexOf("pusher_internal:")!==0){var g={};this.emit(c,f,g)}}handleSubscriptionSucceededEvent(i){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):this.emit("pusher:subscription_succeeded",i.data)}handleSubscriptionCountEvent(i){i.data.subscription_count&&(this.subscriptionCount=i.data.subscription_count),this.emit("pusher:subscription_count",i.data)}subscribe(){this.subscribed||(this.subscriptionPending=!0,this.subscriptionCancelled=!1,this.authorize(this.pusher.connection.socket_id,(i,c)=>{i?(this.subscriptionPending=!1,le.error(i.toString()),this.emit("pusher:subscription_error",Object.assign({},{type:"AuthError",error:i.message},i instanceof Ae?{status:i.status}:{}))):this.pusher.send_event("pusher:subscribe",{auth:c.auth,channel_data:c.channel_data,channel:this.name})}))}unsubscribe(){this.subscribed=!1,this.pusher.send_event("pusher:unsubscribe",{channel:this.name})}cancelSubscription(){this.subscriptionCancelled=!0}reinstateSubscription(){this.subscriptionCancelled=!1}}class oe extends L{authorize(i,c){return this.pusher.config.channelAuthorizer({channelName:this.name,socketId:i},c)}}class Ie{constructor(){this.reset()}get(i){return Object.prototype.hasOwnProperty.call(this.members,i)?{id:i,info:this.members[i]}:null}each(i){Re(this.members,(c,f)=>{i(this.get(f))})}setMyID(i){this.myID=i}onSubscription(i){this.members=i.presence.hash,this.count=i.presence.count,this.me=this.get(this.myID)}addMember(i){return this.get(i.user_id)===null&&this.count++,this.members[i.user_id]=i.user_info,this.get(i.user_id)}removeMember(i){var c=this.get(i.user_id);return c&&(delete this.members[i.user_id],this.count--),c}reset(){this.members={},this.count=0,this.myID=null,this.me=null}}var ve=function(l,i,c,f){function g(y){return y instanceof c?y:new c(function(E){E(y)})}return new(c||(c=Promise))(function(y,E){function $(te){try{X(f.next(te))}catch(xe){E(xe)}}function q(te){try{X(f.throw(te))}catch(xe){E(xe)}}function X(te){te.done?y(te.value):g(te.value).then($,q)}X((f=f.apply(l,i||[])).next())})};class Ue extends oe{constructor(i,c){super(i,c),this.members=new Ie}authorize(i,c){super.authorize(i,(f,g)=>ve(this,void 0,void 0,function*(){if(!f)if(g=g,g.channel_data!=null){var y=JSON.parse(g.channel_data);this.members.setMyID(y.user_id)}else if(yield this.pusher.user.signinDonePromise,this.pusher.user.user_data!=null)this.members.setMyID(this.pusher.user.user_data.id);else{let E=P.buildLogSuffix("authorizationEndpoint");le.error(`Invalid auth response for channel '${this.name}', expected 'channel_data' field. ${E}, or the user should be signed in.`),c("Invalid auth response");return}c(f,g)}))}handleEvent(i){var c=i.event;if(c.indexOf("pusher_internal:")===0)this.handleInternalEvent(i);else{var f=i.data,g={};i.user_id&&(g.user_id=i.user_id),this.emit(c,f,g)}}handleInternalEvent(i){var c=i.event,f=i.data;switch(c){case"pusher_internal:subscription_succeeded":this.handleSubscriptionSucceededEvent(i);break;case"pusher_internal:subscription_count":this.handleSubscriptionCountEvent(i);break;case"pusher_internal:member_added":var g=this.members.addMember(f);this.emit("pusher:member_added",g);break;case"pusher_internal:member_removed":var y=this.members.removeMember(f);y&&this.emit("pusher:member_removed",y);break}}handleSubscriptionSucceededEvent(i){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):(this.members.onSubscription(i.data),this.emit("pusher:subscription_succeeded",this.members))}disconnect(){this.members.reset(),super.disconnect()}}var bt=d(978),xt=d(594);class fr extends oe{constructor(i,c,f){super(i,c),this.key=null,this.nacl=f}authorize(i,c){super.authorize(i,(f,g)=>{if(f){c(f,g);return}let y=g.shared_secret;if(!y){c(new Error(`No shared_secret key in auth payload for encrypted channel: ${this.name}`),null);return}this.key=(0,xt.decode)(y),delete g.shared_secret,c(null,g)})}trigger(i,c){throw new Ee("Client events are not currently supported for encrypted channels")}handleEvent(i){var c=i.event,f=i.data;if(c.indexOf("pusher_internal:")===0||c.indexOf("pusher:")===0){super.handleEvent(i);return}this.handleEncryptedEvent(c,f)}handleEncryptedEvent(i,c){if(!this.key){le.debug("Received encrypted event before key has been retrieved from the authEndpoint");return}if(!c.ciphertext||!c.nonce){le.error("Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: "+c);return}let f=(0,xt.decode)(c.ciphertext);if(f.length<this.nacl.secretbox.overheadLength){le.error(`Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${f.length}`);return}let g=(0,xt.decode)(c.nonce);if(g.length<this.nacl.secretbox.nonceLength){le.error(`Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${g.length}`);return}let y=this.nacl.secretbox.open(f,g,this.key);if(y===null){le.debug("Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint..."),this.authorize(this.pusher.connection.socket_id,(E,$)=>{if(E){le.error(`Failed to make a request to the authEndpoint: ${$}. Unable to fetch new key, so dropping encrypted event`);return}if(y=this.nacl.secretbox.open(f,g,this.key),y===null){le.error("Failed to decrypt event with new key. Dropping encrypted event");return}this.emit(i,this.getDataToEmit(y))});return}this.emit(i,this.getDataToEmit(y))}getDataToEmit(i){let c=(0,bt.D4)(i);try{return JSON.parse(c)}catch{return c}}}class Le extends gt{constructor(i,c){super(),this.state="initialized",this.connection=null,this.key=i,this.options=c,this.timeline=this.options.timeline,this.usingTLS=this.options.useTLS,this.errorCallbacks=this.buildErrorCallbacks(),this.connectionCallbacks=this.buildConnectionCallbacks(this.errorCallbacks),this.handshakeCallbacks=this.buildHandshakeCallbacks(this.errorCallbacks);var f=F.getNetwork();f.bind("online",()=>{this.timeline.info({netinfo:"online"}),(this.state==="connecting"||this.state==="unavailable")&&this.retryIn(0)}),f.bind("offline",()=>{this.timeline.info({netinfo:"offline"}),this.connection&&this.sendActivityCheck()}),this.updateStrategy()}switchCluster(i){this.key=i,this.updateStrategy(),this.retryIn(0)}connect(){if(!(this.connection||this.runner)){if(!this.strategy.isSupported()){this.updateState("failed");return}this.updateState("connecting"),this.startConnecting(),this.setUnavailableTimer()}}send(i){return this.connection?this.connection.send(i):!1}send_event(i,c,f){return this.connection?this.connection.send_event(i,c,f):!1}disconnect(){this.disconnectInternally(),this.updateState("disconnected")}isUsingTLS(){return this.usingTLS}startConnecting(){var i=(c,f)=>{c?this.runner=this.strategy.connect(0,i):f.action==="error"?(this.emit("error",{type:"HandshakeError",error:f.error}),this.timeline.error({handshakeError:f.error})):(this.abortConnecting(),this.handshakeCallbacks[f.action](f))};this.runner=this.strategy.connect(0,i)}abortConnecting(){this.runner&&(this.runner.abort(),this.runner=null)}disconnectInternally(){if(this.abortConnecting(),this.clearRetryTimer(),this.clearUnavailableTimer(),this.connection){var i=this.abandonConnection();i.close()}}updateStrategy(){this.strategy=this.options.getStrategy({key:this.key,timeline:this.timeline,useTLS:this.usingTLS})}retryIn(i){this.timeline.info({action:"retry",delay:i}),i>0&&this.emit("connecting_in",Math.round(i/1e3)),this.retryTimer=new re(i||0,()=>{this.disconnectInternally(),this.connect()})}clearRetryTimer(){this.retryTimer&&(this.retryTimer.ensureAborted(),this.retryTimer=null)}setUnavailableTimer(){this.unavailableTimer=new re(this.options.unavailableTimeout,()=>{this.updateState("unavailable")})}clearUnavailableTimer(){this.unavailableTimer&&this.unavailableTimer.ensureAborted()}sendActivityCheck(){this.stopActivityCheck(),this.connection.ping(),this.activityTimer=new re(this.options.pongTimeout,()=>{this.timeline.error({pong_timed_out:this.options.pongTimeout}),this.retryIn(0)})}resetActivityCheck(){this.stopActivityCheck(),this.connection&&!this.connection.handlesActivityChecks()&&(this.activityTimer=new re(this.activityTimeout,()=>{this.sendActivityCheck()}))}stopActivityCheck(){this.activityTimer&&this.activityTimer.ensureAborted()}buildConnectionCallbacks(i){return we({},i,{message:c=>{this.resetActivityCheck(),this.emit("message",c)},ping:()=>{this.send_event("pusher:pong",{})},activity:()=>{this.resetActivityCheck()},error:c=>{this.emit("error",c)},closed:()=>{this.abandonConnection(),this.shouldRetry()&&this.retryIn(1e3)}})}buildHandshakeCallbacks(i){return we({},i,{connected:c=>{this.activityTimeout=Math.min(this.options.activityTimeout,c.activityTimeout,c.connection.activityTimeout||1/0),this.clearUnavailableTimer(),this.setConnection(c.connection),this.socket_id=this.connection.id,this.updateState("connected",{socket_id:this.socket_id})}})}buildErrorCallbacks(){let i=c=>f=>{f.error&&this.emit("error",{type:"WebSocketError",error:f.error}),c(f)};return{tls_only:i(()=>{this.usingTLS=!0,this.updateStrategy(),this.retryIn(0)}),refused:i(()=>{this.disconnect()}),backoff:i(()=>{this.retryIn(1e3)}),retry:i(()=>{this.retryIn(0)})}}setConnection(i){this.connection=i;for(var c in this.connectionCallbacks)this.connection.bind(c,this.connectionCallbacks[c]);this.resetActivityCheck()}abandonConnection(){if(this.connection){this.stopActivityCheck();for(var i in this.connectionCallbacks)this.connection.unbind(i,this.connectionCallbacks[i]);var c=this.connection;return this.connection=null,c}}updateState(i,c){var f=this.state;if(this.state=i,f!==i){var g=i;g==="connected"&&(g+=" with new socket ID "+c.socket_id),le.debug("State changed",f+" -> "+g),this.timeline.info({state:i,params:c}),this.emit("state_change",{previous:f,current:i}),this.emit(i,c)}}shouldRetry(){return this.state==="connecting"||this.state==="connected"}}class Vr{constructor(){this.channels={}}add(i,c){return this.channels[i]||(this.channels[i]=Yr(i,c)),this.channels[i]}all(){return It(this.channels)}find(i){return this.channels[i]}remove(i){var c=this.channels[i];return delete this.channels[i],c}disconnect(){Re(this.channels,function(i){i.disconnect()})}}function Yr(l,i){if(l.indexOf("private-encrypted-")===0){if(i.config.nacl)return Dt.createEncryptedChannel(l,i,i.config.nacl);let c="Tried to subscribe to a private-encrypted- channel but no nacl implementation available",f=P.buildLogSuffix("encryptedChannelSupport");throw new Ee(`${c}. ${f}`)}else{if(l.indexOf("private-")===0)return Dt.createPrivateChannel(l,i);if(l.indexOf("presence-")===0)return Dt.createPresenceChannel(l,i);if(l.indexOf("#")===0)throw new R('Cannot create a channel with name "'+l+'".');return Dt.createChannel(l,i)}}var dl={createChannels(){return new Vr},createConnectionManager(l,i){return new Le(l,i)},createChannel(l,i){return new L(l,i)},createPrivateChannel(l,i){return new oe(l,i)},createPresenceChannel(l,i){return new Ue(l,i)},createEncryptedChannel(l,i,c){return new fr(l,i,c)},createTimelineSender(l,i){return new S(l,i)},createHandshake(l,i){return new k(l,i)},createAssistantToTheTransportManager(l,i,c){return new Xr(l,i,c)}};const Dt=dl;class as{constructor(i){this.options=i||{},this.livesLeft=this.options.lives||1/0}getAssistant(i){return Dt.createAssistantToTheTransportManager(this,i,{minPingDelay:this.options.minPingDelay,maxPingDelay:this.options.maxPingDelay})}isAlive(){return this.livesLeft>0}reportDeath(){this.livesLeft-=1}}class hn{constructor(i,c){this.strategies=i,this.loop=!!c.loop,this.failFast=!!c.failFast,this.timeout=c.timeout,this.timeoutLimit=c.timeoutLimit}isSupported(){return ir(this.strategies,ee.method("isSupported"))}connect(i,c){var f=this.strategies,g=0,y=this.timeout,E=null,$=(q,X)=>{X?c(null,X):(g=g+1,this.loop&&(g=g%f.length),g<f.length?(y&&(y=y*2,this.timeoutLimit&&(y=Math.min(y,this.timeoutLimit))),E=this.tryStrategy(f[g],i,{timeout:y,failFast:this.failFast},$)):c(!0))};return E=this.tryStrategy(f[g],i,{timeout:y,failFast:this.failFast},$),{abort:function(){E.abort()},forceMinPriority:function(q){i=q,E&&E.forceMinPriority(q)}}}tryStrategy(i,c,f,g){var y=null,E=null;return f.timeout>0&&(y=new re(f.timeout,function(){E.abort(),g(!0)})),E=i.connect(c,function($,q){$&&y&&y.isRunning()&&!f.failFast||(y&&y.ensureAborted(),g($,q))}),{abort:function(){y&&y.ensureAborted(),E.abort()},forceMinPriority:function($){E.forceMinPriority($)}}}}class ei{constructor(i){this.strategies=i}isSupported(){return ir(this.strategies,ee.method("isSupported"))}connect(i,c){return pl(this.strategies,i,function(f,g){return function(y,E){if(g[f].error=y,y){hl(g)&&c(!0);return}$t(g,function($){$.forceMinPriority(E.transport.priority)}),c(null,E)}})}}function pl(l,i,c){var f=Cn(l,function(g,y,E,$){return g.connect(i,c(y,$))});return{abort:function(){$t(f,fl)},forceMinPriority:function(g){$t(f,function(y){y.forceMinPriority(g)})}}}function hl(l){return Xo(l,function(i){return!!i.error})}function fl(l){!l.error&&!l.aborted&&(l.abort(),l.aborted=!0)}class gl{constructor(i,c,f){this.strategy=i,this.transports=c,this.ttl=f.ttl||18e5,this.usingTLS=f.useTLS,this.timeline=f.timeline}isSupported(){return this.strategy.isSupported()}connect(i,c){var f=this.usingTLS,g=ml(f),y=g&&g.cacheSkipCount?g.cacheSkipCount:0,E=[this.strategy];if(g&&g.timestamp+this.ttl>=ee.now()){var $=this.transports[g.transport];$&&(["ws","wss"].includes(g.transport)||y>3?(this.timeline.info({cached:!0,transport:g.transport,latency:g.latency}),E.push(new hn([$],{timeout:g.latency*2+1e3,failFast:!0}))):y++)}var q=ee.now(),X=E.pop().connect(i,function te(xe,to){xe?(cs(f),E.length>0?(q=ee.now(),X=E.pop().connect(i,te)):c(xe)):(bl(f,to.transport.name,ee.now()-q,y),c(null,to))});return{abort:function(){X.abort()},forceMinPriority:function(te){i=te,X&&X.forceMinPriority(te)}}}}function ti(l){return"pusherTransport"+(l?"TLS":"NonTLS")}function ml(l){var i=F.getLocalStorage();if(i)try{var c=i[ti(l)];if(c)return JSON.parse(c)}catch{cs(l)}return null}function bl(l,i,c,f){var g=F.getLocalStorage();if(g)try{g[ti(l)]=He({timestamp:ee.now(),transport:i,latency:c,cacheSkipCount:f})}catch{}}function cs(l){var i=F.getLocalStorage();if(i)try{delete i[ti(l)]}catch{}}class Kr{constructor(i,{delay:c}){this.strategy=i,this.options={delay:c}}isSupported(){return this.strategy.isSupported()}connect(i,c){var f=this.strategy,g,y=new re(this.options.delay,function(){g=f.connect(i,c)});return{abort:function(){y.ensureAborted(),g&&g.abort()},forceMinPriority:function(E){i=E,g&&g.forceMinPriority(E)}}}}class gr{constructor(i,c,f){this.test=i,this.trueBranch=c,this.falseBranch=f}isSupported(){var i=this.test()?this.trueBranch:this.falseBranch;return i.isSupported()}connect(i,c){var f=this.test()?this.trueBranch:this.falseBranch;return f.connect(i,c)}}class kl{constructor(i){this.strategy=i}isSupported(){return this.strategy.isSupported()}connect(i,c){var f=this.strategy.connect(i,function(g,y){y&&f.abort(),c(g,y)});return f}}function mr(l){return function(){return l.isSupported()}}var _l=function(l,i,c){var f={};function g(ys,mu,bu,ku,_u){var ws=c(l,ys,mu,bu,ku,_u);return f[ys]=ws,ws}var y=Object.assign({},i,{hostNonTLS:l.wsHost+":"+l.wsPort,hostTLS:l.wsHost+":"+l.wssPort,httpPath:l.wsPath}),E=Object.assign({},y,{useTLS:!0}),$=Object.assign({},i,{hostNonTLS:l.httpHost+":"+l.httpPort,hostTLS:l.httpHost+":"+l.httpsPort,httpPath:l.httpPath}),q={loop:!0,timeout:15e3,timeoutLimit:6e4},X=new as({minPingDelay:1e4,maxPingDelay:l.activityTimeout}),te=new as({lives:2,minPingDelay:1e4,maxPingDelay:l.activityTimeout}),xe=g("ws","ws",3,y,X),to=g("wss","ws",3,E,X),du=g("sockjs","sockjs",1,$),gs=g("xhr_streaming","xhr_streaming",1,$,te),pu=g("xdr_streaming","xdr_streaming",1,$,te),ms=g("xhr_polling","xhr_polling",1,$),hu=g("xdr_polling","xdr_polling",1,$),bs=new hn([xe],q),fu=new hn([to],q),gu=new hn([du],q),ks=new hn([new gr(mr(gs),gs,pu)],q),_s=new hn([new gr(mr(ms),ms,hu)],q),vs=new hn([new gr(mr(ks),new ei([ks,new Kr(_s,{delay:4e3})]),_s)],q),oi=new gr(mr(vs),vs,gu),ii;return i.useTLS?ii=new ei([bs,new Kr(oi,{delay:2e3})]):ii=new ei([bs,new Kr(fu,{delay:2e3}),new Kr(oi,{delay:5e3})]),new gl(new kl(new gr(mr(xe),ii,oi)),f,{ttl:18e5,timeline:i.timeline,useTLS:i.useTLS})};const vl=_l;function yl(){var l=this;l.timeline.info(l.buildTimelineMessage({transport:l.name+(l.options.useTLS?"s":"")})),l.hooks.isInitialized()?l.changeState("initialized"):l.hooks.file?(l.changeState("initializing"),C.load(l.hooks.file,{useTLS:l.options.useTLS},function(i,c){l.hooks.isInitialized()?(l.changeState("initialized"),c(!0)):(i&&l.onError(i),l.onClose(),c(!1))})):l.onClose()}var wl={getRequest:function(l){var i=new window.XDomainRequest;return i.ontimeout=function(){l.emit("error",new D),l.close()},i.onerror=function(c){l.emit("error",c),l.close()},i.onprogress=function(){i.responseText&&i.responseText.length>0&&l.onChunk(200,i.responseText)},i.onload=function(){i.responseText&&i.responseText.length>0&&l.onChunk(200,i.responseText),l.emit("finished",200),l.close()},i},abortRequest:function(l){l.ontimeout=l.onerror=l.onprogress=l.onload=null,l.abort()}};const xl=wl,Sl=256*1024;class Tl extends gt{constructor(i,c,f){super(),this.hooks=i,this.method=c,this.url=f}start(i){this.position=0,this.xhr=this.hooks.getRequest(this),this.unloader=()=>{this.close()},F.addUnloadListener(this.unloader),this.xhr.open(this.method,this.url,!0),this.xhr.setRequestHeader&&this.xhr.setRequestHeader("Content-Type","application/json"),this.xhr.send(i)}close(){this.unloader&&(F.removeUnloadListener(this.unloader),this.unloader=null),this.xhr&&(this.hooks.abortRequest(this.xhr),this.xhr=null)}onChunk(i,c){for(;;){var f=this.advanceBuffer(c);if(f)this.emit("chunk",{status:i,data:f});else break}this.isBufferTooLong(c)&&this.emit("buffer_too_long")}advanceBuffer(i){var c=i.slice(this.position),f=c.indexOf(`
1392
+ `);return f!==-1?(this.position+=f+1,c.slice(0,f)):null}isBufferTooLong(i){return this.position===i.length&&i.length>Sl}}var ni;(function(l){l[l.CONNECTING=0]="CONNECTING",l[l.OPEN=1]="OPEN",l[l.CLOSED=3]="CLOSED"})(ni||(ni={}));const fn=ni;var El=1;class Al{constructor(i,c){this.hooks=i,this.session=us(1e3)+"/"+Ll(8),this.location=Cl(c),this.readyState=fn.CONNECTING,this.openStream()}send(i){return this.sendRaw(JSON.stringify([i]))}ping(){this.hooks.sendHeartbeat(this)}close(i,c){this.onClose(i,c,!0)}sendRaw(i){if(this.readyState===fn.OPEN)try{return F.createSocketRequest("POST",ls(Pl(this.location,this.session))).start(i),!0}catch{return!1}else return!1}reconnect(){this.closeStream(),this.openStream()}onClose(i,c,f){this.closeStream(),this.readyState=fn.CLOSED,this.onclose&&this.onclose({code:i,reason:c,wasClean:f})}onChunk(i){if(i.status===200){this.readyState===fn.OPEN&&this.onActivity();var c,f=i.data.slice(0,1);switch(f){case"o":c=JSON.parse(i.data.slice(1)||"{}"),this.onOpen(c);break;case"a":c=JSON.parse(i.data.slice(1)||"[]");for(var g=0;g<c.length;g++)this.onEvent(c[g]);break;case"m":c=JSON.parse(i.data.slice(1)||"null"),this.onEvent(c);break;case"h":this.hooks.onHeartbeat(this);break;case"c":c=JSON.parse(i.data.slice(1)||"[]"),this.onClose(c[0],c[1],!0);break}}}onOpen(i){this.readyState===fn.CONNECTING?(i&&i.hostname&&(this.location.base=Rl(this.location.base,i.hostname)),this.readyState=fn.OPEN,this.onopen&&this.onopen()):this.onClose(1006,"Server lost session",!0)}onEvent(i){this.readyState===fn.OPEN&&this.onmessage&&this.onmessage({data:i})}onActivity(){this.onactivity&&this.onactivity()}onError(i){this.onerror&&this.onerror(i)}openStream(){this.stream=F.createSocketRequest("POST",ls(this.hooks.getReceiveURL(this.location,this.session))),this.stream.bind("chunk",i=>{this.onChunk(i)}),this.stream.bind("finished",i=>{this.hooks.onFinished(this,i)}),this.stream.bind("buffer_too_long",()=>{this.reconnect()});try{this.stream.start()}catch(i){ee.defer(()=>{this.onError(i),this.onClose(1006,"Could not start streaming",!1)})}}closeStream(){this.stream&&(this.stream.unbind_all(),this.stream.close(),this.stream=null)}}function Cl(l){var i=/([^\?]*)\/*(\??.*)/.exec(l);return{base:i[1],queryString:i[2]}}function Pl(l,i){return l.base+"/"+i+"/xhr_send"}function ls(l){var i=l.indexOf("?")===-1?"?":"&";return l+i+"t="+ +new Date+"&n="+El++}function Rl(l,i){var c=/(https?:\/\/)([^\/:]+)((\/|:)?.*)/.exec(l);return c[1]+i+c[3]}function us(l){return F.randomInt(l)}function Ll(l){for(var i=[],c=0;c<l;c++)i.push(us(32).toString(32));return i.join("")}const zl=Al;var Il={getReceiveURL:function(l,i){return l.base+"/"+i+"/xhr_streaming"+l.queryString},onHeartbeat:function(l){l.sendRaw("[]")},sendHeartbeat:function(l){l.sendRaw("[]")},onFinished:function(l,i){l.onClose(1006,"Connection interrupted ("+i+")",!1)}};const $l=Il;var Nl={getReceiveURL:function(l,i){return l.base+"/"+i+"/xhr"+l.queryString},onHeartbeat:function(){},sendHeartbeat:function(l){l.sendRaw("[]")},onFinished:function(l,i){i===200?l.reconnect():l.onClose(1006,"Connection interrupted ("+i+")",!1)}};const Ol=Nl;var Dl={getRequest:function(l){var i=F.getXHRAPI(),c=new i;return c.onreadystatechange=c.onprogress=function(){switch(c.readyState){case 3:c.responseText&&c.responseText.length>0&&l.onChunk(c.status,c.responseText);break;case 4:c.responseText&&c.responseText.length>0&&l.onChunk(c.status,c.responseText),l.emit("finished",c.status),l.close();break}},c},abortRequest:function(l){l.onreadystatechange=null,l.abort()}};const Ml=Dl;var Ul={createStreamingSocket(l){return this.createSocket($l,l)},createPollingSocket(l){return this.createSocket(Ol,l)},createSocket(l,i){return new zl(l,i)},createXHR(l,i){return this.createRequest(Ml,l,i)},createRequest(l,i,c){return new Tl(l,i,c)}};const ds=Ul;ds.createXDR=function(l,i){return this.createRequest(xl,l,i)};var jl={nextAuthCallbackID:1,auth_callbacks:{},ScriptReceivers:p,DependenciesReceivers:w,getDefaultStrategy:vl,Transports:mt,transportConnectionInitializer:yl,HTTPFactory:ds,TimelineTransport:Jt,getXHRAPI(){return window.XMLHttpRequest},getWebSocketAPI(){return window.WebSocket||window.MozWebSocket},setup(l){window.Pusher=l;var i=()=>{this.onDocumentBody(l.ready)};window.JSON?i():C.load("json2",{},i)},getDocument(){return document},getProtocol(){return this.getDocument().location.protocol},getAuthorizers(){return{ajax:pt,jsonp:cr}},onDocumentBody(l){document.body?l():setTimeout(()=>{this.onDocumentBody(l)},0)},createJSONPRequest(l,i){return new Pn(l,i)},createScriptRequest(l){return new qr(l)},getLocalStorage(){try{return window.localStorage}catch{return}},createXHR(){return this.getXHRAPI()?this.createXMLHttpRequest():this.createMicrosoftXHR()},createXMLHttpRequest(){var l=this.getXHRAPI();return new l},createMicrosoftXHR(){return new ActiveXObject("Microsoft.XMLHTTP")},getNetwork(){return Jr},createWebSocket(l){var i=this.getWebSocketAPI();return new i(l)},createSocketRequest(l,i){if(this.isXHRSupported())return this.HTTPFactory.createXHR(l,i);if(this.isXDRSupported(i.indexOf("https:")===0))return this.HTTPFactory.createXDR(l,i);throw"Cross-origin HTTP requests are not supported"},isXHRSupported(){var l=this.getXHRAPI();return!!l&&new l().withCredentials!==void 0},isXDRSupported(l){var i=l?"https:":"http:",c=this.getProtocol();return!!window.XDomainRequest&&c===i},addUnloadListener(l){window.addEventListener!==void 0?window.addEventListener("unload",l,!1):window.attachEvent!==void 0&&window.attachEvent("onunload",l)},removeUnloadListener(l){window.addEventListener!==void 0?window.removeEventListener("unload",l,!1):window.detachEvent!==void 0&&window.detachEvent("onunload",l)},randomInt(l){return Math.floor(function(){return(window.crypto||window.msCrypto).getRandomValues(new Uint32Array(1))[0]/Math.pow(2,32)}()*l)}};const F=jl;var ri;(function(l){l[l.ERROR=3]="ERROR",l[l.INFO=6]="INFO",l[l.DEBUG=7]="DEBUG"})(ri||(ri={}));const Qr=ri;class Zl{constructor(i,c,f){this.key=i,this.session=c,this.events=[],this.options=f||{},this.sent=0,this.uniqueID=0}log(i,c){i<=this.options.level&&(this.events.push(we({},c,{timestamp:ee.now()})),this.options.limit&&this.events.length>this.options.limit&&this.events.shift())}error(i){this.log(Qr.ERROR,i)}info(i){this.log(Qr.INFO,i)}debug(i){this.log(Qr.DEBUG,i)}isEmpty(){return this.events.length===0}send(i,c){var f=we({session:this.session,bundle:this.sent+1,key:this.key,lib:"js",version:this.options.version,cluster:this.options.cluster,features:this.options.features,timeline:this.events},this.options.params);return this.events=[],i(f,(g,y)=>{g||this.sent++,c&&c(g,y)}),!0}generateUniqueID(){return this.uniqueID++,this.uniqueID}}class ql{constructor(i,c,f,g){this.name=i,this.priority=c,this.transport=f,this.options=g||{}}isSupported(){return this.transport.isSupported({useTLS:this.options.useTLS})}connect(i,c){if(this.isSupported()){if(this.priority<i)return ps(new de,c)}else return ps(new V,c);var f=!1,g=this.transport.createConnection(this.name,this.priority,this.options.key,this.options),y=null,E=function(){g.unbind("initialized",E),g.connect()},$=function(){y=Dt.createHandshake(g,function(xe){f=!0,te(),c(null,xe)})},q=function(xe){te(),c(xe)},X=function(){te();var xe;xe=He(g),c(new _e(xe))},te=function(){g.unbind("initialized",E),g.unbind("open",$),g.unbind("error",q),g.unbind("closed",X)};return g.bind("initialized",E),g.bind("open",$),g.bind("error",q),g.bind("closed",X),g.initialize(),{abort:()=>{f||(te(),y?y.close():g.close())},forceMinPriority:xe=>{f||this.priority<xe&&(y?y.close():g.close())}}}}function ps(l,i){return ee.defer(function(){i(l)}),{abort:function(){},forceMinPriority:function(){}}}const{Transports:Hl}=F;var Fl=function(l,i,c,f,g,y){var E=Hl[c];if(!E)throw new qe(c);var $=(!l.enabledTransports||rt(l.enabledTransports,i)!==-1)&&(!l.disabledTransports||rt(l.disabledTransports,i)===-1),q;return $?(g=Object.assign({ignoreNullOrigin:l.ignoreNullOrigin},g),q=new ql(i,f,y?y.getAssistant(E):E,g)):q=Bl,q},Bl={isSupported:function(){return!1},connect:function(l,i){var c=ee.defer(function(){i(new V)});return{abort:function(){c.ensureAborted()},forceMinPriority:function(){}}}};function Gl(l){if(l==null)throw"You must pass an options object";if(l.cluster==null)throw"Options object must provide a cluster";"disableStats"in l&&le.warn("The disableStats option is deprecated in favor of enableStats")}const Wl=(l,i)=>{var c="socket_id="+encodeURIComponent(l.socketId);for(var f in i.params)c+="&"+encodeURIComponent(f)+"="+encodeURIComponent(i.params[f]);if(i.paramsProvider!=null){let g=i.paramsProvider();for(var f in g)c+="&"+encodeURIComponent(f)+"="+encodeURIComponent(g[f])}return c},Jl=l=>{if(typeof F.getAuthorizers()[l.transport]>"u")throw`'${l.transport}' is not a recognized auth transport`;return(i,c)=>{const f=Wl(i,l);F.getAuthorizers()[l.transport](F,f,l,T.UserAuthentication,c)}},Xl=(l,i)=>{var c="socket_id="+encodeURIComponent(l.socketId);c+="&channel_name="+encodeURIComponent(l.channelName);for(var f in i.params)c+="&"+encodeURIComponent(f)+"="+encodeURIComponent(i.params[f]);if(i.paramsProvider!=null){let g=i.paramsProvider();for(var f in g)c+="&"+encodeURIComponent(f)+"="+encodeURIComponent(g[f])}return c},Vl=l=>{if(typeof F.getAuthorizers()[l.transport]>"u")throw`'${l.transport}' is not a recognized auth transport`;return(i,c)=>{const f=Xl(i,l);F.getAuthorizers()[l.transport](F,f,l,T.ChannelAuthorization,c)}},Yl=(l,i,c)=>{const f={authTransport:i.transport,authEndpoint:i.endpoint,auth:{params:i.params,headers:i.headers}};return(g,y)=>{const E=l.channel(g.channelName);c(E,f).authorize(g.socketId,y)}};function hs(l,i){let c={activityTimeout:l.activityTimeout||m.activityTimeout,cluster:l.cluster,httpPath:l.httpPath||m.httpPath,httpPort:l.httpPort||m.httpPort,httpsPort:l.httpsPort||m.httpsPort,pongTimeout:l.pongTimeout||m.pongTimeout,statsHost:l.statsHost||m.stats_host,unavailableTimeout:l.unavailableTimeout||m.unavailableTimeout,wsPath:l.wsPath||m.wsPath,wsPort:l.wsPort||m.wsPort,wssPort:l.wssPort||m.wssPort,enableStats:nu(l),httpHost:Kl(l),useTLS:tu(l),wsHost:Ql(l),userAuthenticator:ru(l),channelAuthorizer:iu(l,i)};return"disabledTransports"in l&&(c.disabledTransports=l.disabledTransports),"enabledTransports"in l&&(c.enabledTransports=l.enabledTransports),"ignoreNullOrigin"in l&&(c.ignoreNullOrigin=l.ignoreNullOrigin),"timelineParams"in l&&(c.timelineParams=l.timelineParams),"nacl"in l&&(c.nacl=l.nacl),c}function Kl(l){return l.httpHost?l.httpHost:l.cluster?`sockjs-${l.cluster}.pusher.com`:m.httpHost}function Ql(l){return l.wsHost?l.wsHost:eu(l.cluster)}function eu(l){return`ws-${l}.pusher.com`}function tu(l){return F.getProtocol()==="https:"?!0:l.forceTLS!==!1}function nu(l){return"enableStats"in l?l.enableStats:"disableStats"in l?!l.disableStats:!1}const fs=l=>"customHandler"in l&&l.customHandler!=null;function ru(l){const i=Object.assign(Object.assign({},m.userAuthentication),l.userAuthentication);return fs(i)?i.customHandler:Jl(i)}function ou(l,i){let c;if("channelAuthorization"in l)c=Object.assign(Object.assign({},m.channelAuthorization),l.channelAuthorization);else if(c={transport:l.authTransport||m.authTransport,endpoint:l.authEndpoint||m.authEndpoint},"auth"in l&&("params"in l.auth&&(c.params=l.auth.params),"headers"in l.auth&&(c.headers=l.auth.headers)),"authorizer"in l)return{customHandler:Yl(i,c,l.authorizer)};return c}function iu(l,i){const c=ou(l,i);return fs(c)?c.customHandler:Vl(c)}class su extends gt{constructor(i){super(function(c,f){le.debug(`No callbacks on watchlist events for ${c}`)}),this.pusher=i,this.bindWatchlistInternalEvent()}handleEvent(i){i.data.events.forEach(c=>{this.emit(c.name,c)})}bindWatchlistInternalEvent(){this.pusher.connection.bind("message",i=>{var c=i.event;c==="pusher_internal:watchlist_events"&&this.handleEvent(i)})}}function au(){let l,i;return{promise:new Promise((f,g)=>{l=f,i=g}),resolve:l,reject:i}}const cu=au;class lu extends gt{constructor(i){super(function(c,f){le.debug("No callbacks on user for "+c)}),this.signin_requested=!1,this.user_data=null,this.serverToUserChannel=null,this.signinDonePromise=null,this._signinDoneResolve=null,this._onAuthorize=(c,f)=>{if(c){le.warn(`Error during signin: ${c}`),this._cleanup();return}this.pusher.send_event("pusher:signin",{auth:f.auth,user_data:f.user_data})},this.pusher=i,this.pusher.connection.bind("state_change",({previous:c,current:f})=>{c!=="connected"&&f==="connected"&&this._signin(),c==="connected"&&f!=="connected"&&(this._cleanup(),this._newSigninPromiseIfNeeded())}),this.watchlist=new su(i),this.pusher.connection.bind("message",c=>{var f=c.event;f==="pusher:signin_success"&&this._onSigninSuccess(c.data),this.serverToUserChannel&&this.serverToUserChannel.name===c.channel&&this.serverToUserChannel.handleEvent(c)})}signin(){this.signin_requested||(this.signin_requested=!0,this._signin())}_signin(){this.signin_requested&&(this._newSigninPromiseIfNeeded(),this.pusher.connection.state==="connected"&&this.pusher.config.userAuthenticator({socketId:this.pusher.connection.socket_id},this._onAuthorize))}_onSigninSuccess(i){try{this.user_data=JSON.parse(i.user_data)}catch{le.error(`Failed parsing user data after signin: ${i.user_data}`),this._cleanup();return}if(typeof this.user_data.id!="string"||this.user_data.id===""){le.error(`user_data doesn't contain an id. user_data: ${this.user_data}`),this._cleanup();return}this._signinDoneResolve(),this._subscribeChannels()}_subscribeChannels(){const i=c=>{c.subscriptionPending&&c.subscriptionCancelled?c.reinstateSubscription():!c.subscriptionPending&&this.pusher.connection.state==="connected"&&c.subscribe()};this.serverToUserChannel=new L(`#server-to-user-${this.user_data.id}`,this.pusher),this.serverToUserChannel.bind_global((c,f)=>{c.indexOf("pusher_internal:")===0||c.indexOf("pusher:")===0||this.emit(c,f)}),i(this.serverToUserChannel)}_cleanup(){this.user_data=null,this.serverToUserChannel&&(this.serverToUserChannel.unbind_all(),this.serverToUserChannel.disconnect(),this.serverToUserChannel=null),this.signin_requested&&this._signinDoneResolve()}_newSigninPromiseIfNeeded(){if(!this.signin_requested||this.signinDonePromise&&!this.signinDonePromise.done)return;const{promise:i,resolve:c}=cu();i.done=!1;const f=()=>{i.done=!0};i.then(f).catch(f),this.signinDonePromise=i,this._signinDoneResolve=c}}class Ne{static ready(){Ne.isReady=!0;for(var i=0,c=Ne.instances.length;i<c;i++)Ne.instances[i].connect()}static getClientFeatures(){return ot(ln({ws:F.Transports.ws},function(i){return i.isSupported({})}))}constructor(i,c){uu(i),Gl(c),this.key=i,this.options=c,this.config=hs(this.options,this),this.channels=Dt.createChannels(),this.global_emitter=new gt,this.sessionID=F.randomInt(1e9),this.timeline=new Zl(this.key,this.sessionID,{cluster:this.config.cluster,features:Ne.getClientFeatures(),params:this.config.timelineParams||{},limit:50,level:Qr.INFO,version:m.VERSION}),this.config.enableStats&&(this.timelineSender=Dt.createTimelineSender(this.timeline,{host:this.config.statsHost,path:"/timeline/v2/"+F.TimelineTransport.name}));var f=g=>F.getDefaultStrategy(this.config,g,Fl);this.connection=Dt.createConnectionManager(this.key,{getStrategy:f,timeline:this.timeline,activityTimeout:this.config.activityTimeout,pongTimeout:this.config.pongTimeout,unavailableTimeout:this.config.unavailableTimeout,useTLS:!!this.config.useTLS}),this.connection.bind("connected",()=>{this.subscribeAll(),this.timelineSender&&this.timelineSender.send(this.connection.isUsingTLS())}),this.connection.bind("message",g=>{var y=g.event,E=y.indexOf("pusher_internal:")===0;if(g.channel){var $=this.channel(g.channel);$&&$.handleEvent(g)}E||this.global_emitter.emit(g.event,g.data)}),this.connection.bind("connecting",()=>{this.channels.disconnect()}),this.connection.bind("disconnected",()=>{this.channels.disconnect()}),this.connection.bind("error",g=>{le.warn(g)}),Ne.instances.push(this),this.timeline.info({instances:Ne.instances.length}),this.user=new lu(this),Ne.isReady&&this.connect()}switchCluster(i){const{appKey:c,cluster:f}=i;this.key=c,this.options=Object.assign(Object.assign({},this.options),{cluster:f}),this.config=hs(this.options,this),this.connection.switchCluster(this.key)}channel(i){return this.channels.find(i)}allChannels(){return this.channels.all()}connect(){if(this.connection.connect(),this.timelineSender&&!this.timelineSenderTimer){var i=this.connection.isUsingTLS(),c=this.timelineSender;this.timelineSenderTimer=new Ce(6e4,function(){c.send(i)})}}disconnect(){this.connection.disconnect(),this.timelineSenderTimer&&(this.timelineSenderTimer.ensureAborted(),this.timelineSenderTimer=null)}bind(i,c,f){return this.global_emitter.bind(i,c,f),this}unbind(i,c,f){return this.global_emitter.unbind(i,c,f),this}bind_global(i){return this.global_emitter.bind_global(i),this}unbind_global(i){return this.global_emitter.unbind_global(i),this}unbind_all(i){return this.global_emitter.unbind_all(),this}subscribeAll(){var i;for(i in this.channels.channels)this.channels.channels.hasOwnProperty(i)&&this.subscribe(i)}subscribe(i){var c=this.channels.add(i,this);return c.subscriptionPending&&c.subscriptionCancelled?c.reinstateSubscription():!c.subscriptionPending&&this.connection.state==="connected"&&c.subscribe(),c}unsubscribe(i){var c=this.channels.find(i);c&&c.subscriptionPending?c.cancelSubscription():(c=this.channels.remove(i),c&&c.subscribed&&c.unsubscribe())}send_event(i,c,f){return this.connection.send_event(i,c,f)}shouldUseTLS(){return this.config.useTLS}signin(){this.user.signin()}}Ne.instances=[],Ne.isReady=!1,Ne.logToConsole=!1,Ne.Runtime=F,Ne.ScriptReceivers=F.ScriptReceivers,Ne.DependenciesReceivers=F.DependenciesReceivers,Ne.auth_callbacks=F.auth_callbacks;const eo=Ne;function uu(l){if(l==null)throw"You must pass your app key when you instantiate Pusher."}F.setup(Ne)}},r={};function o(a){var u=r[a];if(u!==void 0)return u.exports;var d=r[a]={exports:{}};return n[a].call(d.exports,d,d.exports,o),d.exports}o.d=(a,u)=>{for(var d in u)o.o(u,d)&&!o.o(a,d)&&Object.defineProperty(a,d,{enumerable:!0,get:u[d]})},o.o=(a,u)=>Object.prototype.hasOwnProperty.call(a,u);var s=o(721);return s})())})(fc);var Bg=fc.exports;const Gg=Fg(Bg),so={TASK_STATUS_UPDATED:"task:status:updated",TASK_INTERACTION_CREATED:"task:interaction:created",TASK_INTERACTION_ANSWERED:"task:interaction:answered",TASK_BROWSER_COMMAND_CREATED:"task:browser-command:created"};let wt=null,$n=null;async function Wg(e){return $n||($n=(async()=>{const t=e.backendUrl.replace(/\/+$/,""),n=await fetch(`${t}/api/settings`,{headers:{Authorization:`Bearer ${e.token}`}});if(!n.ok)throw new Error(`Failed to fetch settings: HTTP ${n.status}`);const r=await n.json();wt=new Gg(r.pusher.key,{cluster:r.pusher.cluster||"local",forceTLS:!0,wsHost:r.pusher.wsHost||void 0,wsPort:r.pusher.wssPort,wssPort:r.pusher.wssPort,enabledTransports:r.pusher.wsHost?["ws"]:void 0,channelAuthorization:{customHandler:({socketId:o,channelName:s},a)=>{fetch(`${t}/api/pusher/auth`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e.token}`},body:JSON.stringify({socket_id:o,channel_name:s})}).then(u=>u.json()).then(u=>a(null,u)).catch(u=>a(u instanceof Error?u:new Error(String(u)),null))}}})})(),$n.catch(()=>{$n=null}),$n)}function Jg(e){if(!e||!wt)return null;let t=!1;const n=({current:r})=>{r==="connected"&&t?(t=!1,e()):r!=="connected"&&(t=!0)};return wt.connection.bind("state_change",n),()=>wt==null?void 0:wt.connection.unbind("state_change",n)}async function Xg(e,t,n){if(await Wg(e),!wt)return()=>{};const r=wt.subscribe(`private-task-${t}`);n.onStatusUpdate&&r.bind(so.TASK_STATUS_UPDATED,n.onStatusUpdate),n.onInteractionCreated&&r.bind(so.TASK_INTERACTION_CREATED,n.onInteractionCreated),n.onInteractionAnswered&&r.bind(so.TASK_INTERACTION_ANSWERED,n.onInteractionAnswered),n.onBrowserCommandCreated&&r.bind(so.TASK_BROWSER_COMMAND_CREATED,n.onBrowserCommandCreated);const o=Jg(n.onReconnect);return()=>{r.unbind_all(),wt==null||wt.unsubscribe(`private-task-${t}`),o==null||o()}}const ji="ap-sdk-active-automation";function Vg(){try{const e=sessionStorage.getItem(ji);if(!e)return null;const t=JSON.parse(e);return t!=null&&t.taskId&&(t!=null&&t.backendUrl)&&(t!=null&&t.title)?t:null}catch{return null}}function gc(e){try{sessionStorage.setItem(ji,JSON.stringify(e))}catch{}}function mc(){try{sessionStorage.removeItem(ji)}catch{}}async function Yg(e){var s;try{(s=e.focus)==null||s.call(e)}catch{}e.scrollIntoView({block:"center",inline:"center",behavior:"instant"});let t=e.getBoundingClientRect();t.width===0&&t.height===0&&(await Kg(),t=e.getBoundingClientRect());const n=t.left+t.width/2,r=t.top+t.height/2,o={bubbles:!0,cancelable:!0,clientX:n,clientY:r};typeof PointerEvent=="function"&&e.dispatchEvent(new PointerEvent("pointerdown",o)),e.dispatchEvent(new MouseEvent("mousedown",o)),typeof PointerEvent=="function"&&e.dispatchEvent(new PointerEvent("pointerup",o)),e.dispatchEvent(new MouseEvent("mouseup",o)),e.click()}function Kg(){return new Promise(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(()=>e()):setTimeout(e,16)})}const Zi="shared",bc="ap-sdk-panel-size:",Vs=280,Ys=200;function Qg(e){try{const t=sessionStorage.getItem(bc+e);if(!t)return null;const n=JSON.parse(t);return typeof(n==null?void 0:n.width)=="number"&&typeof(n==null?void 0:n.height)=="number"?n:null}catch{return null}}function em(e,t){try{sessionStorage.setItem(bc+e,JSON.stringify(t))}catch{}}function ao(e,t,n){return Math.min(Math.max(e,t),n)}function Ks(){return window.innerWidth-32}function Qs(){return window.innerHeight-64}function qi(e,t){const n=Qg(t);n&&(e.style.width=`${ao(n.width,Vs,Ks())}px`,e.style.height=`${ao(n.height,Ys,Qs())}px`);const r=document.createElement("div");r.className="ap-sdk-resize-handle",r.setAttribute("data-ap-sdk","1"),e.appendChild(r);let o=!1,s=0,a=0,u=0,d=0,h=0,p=0;const b=_=>{o&&(h=ao(u+(_.clientX-s),Vs,Ks()),p=ao(d+(_.clientY-a),Ys,Qs()),e.style.width=`${h}px`,e.style.height=`${p}px`)},m=()=>{o&&(o=!1,document.removeEventListener("pointermove",b),document.removeEventListener("pointerup",m),em(t,{width:h,height:p}))};r.addEventListener("pointerdown",_=>{_.preventDefault(),_.stopPropagation(),o=!0,s=_.clientX,a=_.clientY;const w=e.getBoundingClientRect();u=w.width,d=w.height,h=u,p=d,document.addEventListener("pointermove",b),document.addEventListener("pointerup",m)})}function Hi(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var An=Hi();function kc(e){An=e}var mn={exec:()=>null};function Nn(e){let t=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),o=t[r];return o||(o=e(r),t[r]=o),o}}function G(e,t=""){let n=typeof e=="string"?e:e.source,r={replace:(o,s)=>{let a=typeof s=="string"?s:s.source;return a=a.replace(je.caret,"$1"),n=n.replace(o,a),r},getRegex:()=>new RegExp(n,t)};return r}var tm=((e="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+e)}catch{return!1}})(),je={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:Nn(e=>new RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:Nn(e=>new RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:Nn(e=>new RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:Nn(e=>new RegExp(`^ {0,${e}}#`)),htmlBeginRegex:Nn(e=>new RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:Nn(e=>new RegExp(`^ {0,${e}}>`))},nm=/^(?:[ \t]*(?:\n|$))+/,rm=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,om=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Mr=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,im=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Fi=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,_c=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,vc=G(_c).replace(/bull/g,Fi).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),sm=G(_c).replace(/bull/g,Fi).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Bi=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,am=/^[^\n]+/,Gi=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,cm=G(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Gi).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),lm=G(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,Fi).getRegex(),Jo="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Wi=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,um=G("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Wi).replace("tag",Jo).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),yc=e=>G(Bi).replace("hr",Mr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~~~)[^\\n]*\\n").replace("list",e).replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Jo).getRegex(),dm=yc(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),pm=yc(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),hm=G(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",pm).getRegex(),Ji={blockquote:hm,code:rm,def:cm,fences:om,heading:im,hr:Mr,html:um,lheading:vc,list:lm,newline:nm,paragraph:dm,table:mn,text:am},ea=G("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Mr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~~~)[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Jo).getRegex(),fm={...Ji,lheading:sm,table:ea,paragraph:G(Bi).replace("hr",Mr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",ea).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~~~)[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Jo).getRegex()},gm={...Ji,html:G(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Wi).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:mn,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:G(Bi).replace("hr",Mr).replace("heading",` *#{1,6} *[^
1393
+ ]`).replace("lheading",vc).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},mm=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,bm=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,wc=/^( {2,}|\\)\n(?!\s*$)/,km=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Ft=/[\p{P}\p{S}]/u,rr=/[\s\p{P}\p{S}]/u,Ur=/[^\s\p{P}\p{S}]/u,_m=G(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,rr).getRegex(),vm=/[\p{Pi}\p{Ps}"']/u,xc=/(?!~)[\p{P}\p{S}]/u,ym=/(?!~)[\s\p{P}\p{S}]/u,wm=/(?:[^\s\p{P}\p{S}]|~)/u,xm=G(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",tm?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Sc=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,Sm=G(Sc,"u").replace(/punct/g,Ft).getRegex(),Tm=G(Sc,"u").replace(/punct/g,xc).getRegex(),Em=/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,Am=G(Em,"u").replace(/openQuote/g,vm).replace(/punct/g,Ft).getRegex(),Tc="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Cm=G(Tc,"gu").replace(/notPunctSpace/g,Ur).replace(/punctSpace/g,rr).replace(/punct/g,Ft).getRegex(),Pm=G(Tc,"gu").replace(/notPunctSpace/g,wm).replace(/punctSpace/g,ym).replace(/punct/g,xc).getRegex(),Rm="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)",Lm=G(Rm,"gu").replace(/notPunctSpace/g,Ur).replace(/punctSpace/g,rr).replace(/punct/g,Ft).getRegex(),zm=G("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Ur).replace(/punctSpace/g,rr).replace(/punct/g,Ft).getRegex(),Im="^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)",$m=G(Im,"gu").replace(/notPunctSpace/g,Ur).replace(/punctSpace/g,rr).replace(/punct/g,Ft).getRegex(),Nm=G(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Ft).getRegex(),Om="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",Dm=G(Om,"gu").replace(/notPunctSpace/g,Ur).replace(/punctSpace/g,rr).replace(/punct/g,Ft).getRegex(),Mm=G(/\\(punct)/,"gu").replace(/punct/g,Ft).getRegex(),Um=G(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),jm=G(Wi).replace("(?:-->|$)","-->").getRegex(),Zm=G("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",jm).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Io=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,qm=G(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",Io).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Ec=G(/^!?\[(label)\]\[(ref)\]/).replace("label",Io).replace("ref",Gi).getRegex(),Ac=G(/^!?\[(ref)\](?:\[\])?/).replace("ref",Gi).getRegex(),Hm=G("reflink|nolink(?!\\()","g").replace("reflink",Ec).replace("nolink",Ac).getRegex(),ta=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Xi={_backpedal:mn,anyPunctuation:Mm,autolink:Um,blockSkip:xm,br:wc,code:bm,del:mn,delLDelim:mn,delRDelim:mn,emStrongLDelim:Sm,emStrongRDelimAst:Cm,emStrongRDelimUnd:zm,escape:mm,link:qm,nolink:Ac,punctuation:_m,reflink:Ec,reflinkSearch:Hm,tag:Zm,text:km,url:mn},Fm={...Xi,emStrongLDelim:Am,emStrongRDelimAst:Lm,emStrongRDelimUnd:$m,link:G(/^!?\[(label)\]\((.*?)\)/).replace("label",Io).getRegex(),reflink:G(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Io).getRegex()},xi={...Xi,emStrongRDelimAst:Pm,emStrongLDelim:Tm,delLDelim:Nm,delRDelim:Dm,url:G(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",ta).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:G(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",ta).getRegex()},Bm={...xi,br:G(wc).replace("{2,}","*").getRegex(),text:G(xi.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},co={normal:Ji,gfm:fm,pedantic:gm},kr={normal:Xi,gfm:xi,breaks:Bm,pedantic:Fm},Gm={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},na=e=>Gm[e];function St(e,t){if(t){if(je.escapeTest.test(e))return e.replace(je.escapeReplace,na)}else if(je.escapeTestNoEncode.test(e))return e.replace(je.escapeReplaceNoEncode,na);return e}function ra(e){try{e=encodeURI(e).replace(je.percentDecode,"%")}catch{return null}return e}function oa(e,t){var s;let n=e.replace(je.findPipe,(a,u,d)=>{let h=!1,p=u;for(;--p>=0&&d[p]==="\\";)h=!h;return h?"|":" |"}),r=n.split(je.splitPipe),o=0;if(r[0].trim()||r.shift(),r.length>0&&!((s=r.at(-1))!=null&&s.trim())&&r.pop(),t)if(r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;o<r.length;o++)r[o]=r[o].trim().replace(je.slashPipe,"|");return r}function Vt(e,t,n){let r=e.length;if(r===0)return"";let o=0;for(;o<r&&e.charAt(r-o-1)===t;)o++;return e.slice(0,r-o)}function ia(e){let t=e.split(`
1394
+ `),n=t.length-1;for(;n>=0&&je.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
1395
+ `)}function Wm(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]==="\\")r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}function Jm(e,t=0){let n=t,r="";for(let o of e)if(o===" "){let s=4-n%4;r+=" ".repeat(s),n+=s}else r+=o,n++;return r}function sa(e,t,n,r,o){let s=t.href,a=t.title||null,u=e[1].replace(o.other.outputLinkReplace,"$1");r.state.inLink=!0;let d={type:e[0].charAt(0)==="!"?"image":"link",raw:n,href:s,title:a,text:u,tokens:r.inlineTokens(u)};return r.state.inLink=!1,d}function Xm(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let o=r[1];return t.split(`
1396
+ `).map(s=>{let a=s.match(n.other.beginningSpace);if(a===null)return s;let[u]=a;return u.length>=o.length?s.slice(o.length):s}).join(`
1397
+ `)}var $o=class{constructor(e){ie(this,"options");ie(this,"rules");ie(this,"lexer");this.options=e||An}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let n=this.options.pedantic?t[0]:ia(t[0]),r=n.replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:n,codeBlockStyle:"indented",text:r}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],r=Xm(n,t[3]||"",this.rules);return{type:"code",raw:n,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:r}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let n=t[2].trim();if(this.rules.other.endingHash.test(n)){let r=Vt(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:Vt(t[0],`
1398
+ `),depth:t[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:Vt(t[0],`
1399
+ `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=Vt(t[0],`
1383
1400
  `).split(`
1384
- `),r="",o="",s=[];for(;n.length>0;){let c=!1,u=[],d;for(d=0;d<n.length;d++)if(this.rules.other.blockquoteStart.test(n[d]))u.push(n[d]),c=!0;else if(!c)u.push(n[d]);else break;n=n.slice(d);let p=u.join(`
1385
- `),h=p.replace(this.rules.other.blockquoteSetextReplace,`
1401
+ `),r="",o="",s=[];for(;n.length>0;){let a=!1,u=[],d;for(d=0;d<n.length;d++)if(this.rules.other.blockquoteStart.test(n[d]))u.push(n[d]),a=!0;else if(!a)u.push(n[d]);else break;n=n.slice(d);let h=u.join(`
1402
+ `),p=h.replace(this.rules.other.blockquoteSetextReplace,`
1386
1403
  $1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
1387
- ${p}`:p,o=o?`${o}
1388
- ${h}`:h;let b=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(h,s,!0),this.lexer.state.top=b,n.length===0)break;let m=s.at(-1);if((m==null?void 0:m.type)==="code")break;if((m==null?void 0:m.type)==="blockquote"){let _=m,w=n.join(`
1389
- `),P=_.raw+`
1390
- `+w.replace(this.rules.other.blockquoteSetextReplace2,""),N=this.blockquote(P);s[s.length-1]=N,r=`${r}
1391
- ${w}`,o=o.substring(0,o.length-_.text.length)+N.text;break}else if((m==null?void 0:m.type)==="list"){let _=m,w=_.raw+`
1404
+ ${h}`:h,o=o?`${o}
1405
+ ${p}`:p;let b=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(p,s,!0),this.lexer.state.top=b,n.length===0)break;let m=s.at(-1);if((m==null?void 0:m.type)==="code")break;if((m==null?void 0:m.type)==="blockquote"){let _=m,w=n.join(`
1406
+ `),C=_.raw+`
1407
+ `+w.replace(this.rules.other.blockquoteSetextReplace2,""),M=this.blockquote(C);s[s.length-1]=M,r=`${r}
1408
+ ${w}`,o=o.substring(0,o.length-_.text.length)+M.text;break}else if((m==null?void 0:m.type)==="list"){let _=m,w=_.raw+`
1392
1409
  `+n.join(`
1393
- `),P=this.list(w);s[s.length-1]=P,r=r.substring(0,r.length-m.raw.length)+P.raw,o=o.substring(0,o.length-_.raw.length)+P.raw,n=w.substring(s.at(-1).raw.length).split(`
1394
- `);continue}}return{type:"blockquote",raw:r,tokens:s,text:o}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,o={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");let s=this.rules.other.listItemRegex(n),c=!1;for(;e;){let d=!1,p="",h="";if(!(t=s.exec(e))||this.rules.block.hr.test(e))break;p=t[0],e=e.substring(p.length);let b=Km(t[2].split(`
1410
+ `),C=this.list(w);s[s.length-1]=C,r=r.substring(0,r.length-m.raw.length)+C.raw,o=o.substring(0,o.length-_.raw.length)+C.raw,n=w.substring(s.at(-1).raw.length).split(`
1411
+ `);continue}}return{type:"blockquote",raw:r,tokens:s,text:o}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,o={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");let s=this.rules.other.listItemRegex(n),a=!1;for(;e;){let d=!1,h="",p="";if(!(t=s.exec(e))||this.rules.block.hr.test(e))break;h=t[0],e=e.substring(h.length);let b=Jm(t[2].split(`
1395
1412
  `,1)[0],t[1].length),m=e.split(`
1396
- `,1)[0],_=!b.trim(),w=0;if(this.options.pedantic?(w=2,h=b.trimStart()):_?w=t[1].length+1:(w=b.search(this.rules.other.nonSpaceChar),w=w>4?1:w,h=b.slice(w),w+=t[1].length),_&&this.rules.other.blankLine.test(m)&&(p+=m+`
1397
- `,e=e.substring(m.length+1),d=!0),!d){let P=this.rules.other.nextBulletRegex(w),N=this.rules.other.hrRegex(w),te=this.rules.other.fencesBeginRegex(w),R=this.rules.other.headingBeginRegex(w),x=this.rules.other.htmlBeginRegex(w),S=this.rules.other.blockquoteBeginRegex(w);for(;e;){let C=e.split(`
1398
- `,1)[0],M;if(m=C,this.options.pedantic?(m=m.replace(this.rules.other.listReplaceNesting," "),M=m):M=m.replace(this.rules.other.tabCharGlobal," "),te.test(m)||R.test(m)||x.test(m)||S.test(m)||P.test(m)||N.test(m))break;if(M.search(this.rules.other.nonSpaceChar)>=w||!m.trim())h+=`
1399
- `+M.slice(w);else{if(_||b.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||te.test(b)||R.test(b)||N.test(b))break;h+=`
1400
- `+m}_=!m.trim(),p+=C+`
1401
- `,e=e.substring(C.length+1),b=M.slice(w)}}o.loose||(c?o.loose=!0:this.rules.other.doubleBlankLine.test(p)&&(c=!0)),o.items.push({type:"list_item",raw:p,task:!!this.options.gfm&&this.rules.other.listIsTask.test(h),loose:!1,text:h,tokens:[]}),o.raw+=p}let u=o.items.at(-1);if(u)u.raw=u.raw.trimEnd(),u.text=u.text.trimEnd();else return;o.raw=o.raw.trimEnd();for(let d of o.items){this.lexer.state.top=!1,d.tokens=this.lexer.blockTokens(d.text,[]);let p=d.tokens[0];if(d.task&&((p==null?void 0:p.type)==="text"||(p==null?void 0:p.type)==="paragraph")){d.text=d.text.replace(this.rules.other.listReplaceTask,""),p.raw=p.raw.replace(this.rules.other.listReplaceTask,""),p.text=p.text.replace(this.rules.other.listReplaceTask,"");for(let b=this.lexer.inlineQueue.length-1;b>=0;b--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[b].src)){this.lexer.inlineQueue[b].src=this.lexer.inlineQueue[b].src.replace(this.rules.other.listReplaceTask,"");break}let h=this.rules.other.listTaskCheckbox.exec(d.raw);if(h){let b={type:"checkbox",raw:h[0]+" ",checked:h[0]!=="[ ]"};d.checked=b.checked,o.loose?d.tokens[0]&&["paragraph","text"].includes(d.tokens[0].type)&&"tokens"in d.tokens[0]&&d.tokens[0].tokens?(d.tokens[0].raw=b.raw+d.tokens[0].raw,d.tokens[0].text=b.raw+d.tokens[0].text,d.tokens[0].tokens.unshift(b)):d.tokens.unshift({type:"paragraph",raw:b.raw,text:b.raw,tokens:[b]}):d.tokens.unshift(b)}}else d.task&&(d.task=!1);if(!o.loose){let h=d.tokens.filter(m=>m.type==="space"),b=h.length>0&&h.some(m=>this.rules.other.anyLine.test(m.raw));o.loose=b}}if(o.loose)for(let d of o.items){d.loose=!0;for(let p of d.tokens)p.type==="text"&&(p.type="paragraph")}return o}}html(e){let t=this.rules.block.html.exec(e);if(t){let n=la(t[0]);return{type:"html",block:!0,raw:n,pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:n}}}def(e){let t=this.rules.block.def.exec(e);if(t){let n=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",o=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:n,raw:Wt(t[0],`
1402
- `),href:r,title:o}}}table(e){var c;let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=ca(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),o=(c=t[3])!=null&&c.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
1403
- `):[],s={type:"table",raw:Wt(t[0],`
1404
- `),header:[],align:[],rows:[]};if(n.length===r.length){for(let u of r)this.rules.other.tableAlignRight.test(u)?s.align.push("right"):this.rules.other.tableAlignCenter.test(u)?s.align.push("center"):this.rules.other.tableAlignLeft.test(u)?s.align.push("left"):s.align.push(null);for(let u=0;u<n.length;u++)s.header.push({text:n[u],tokens:this.lexer.inline(n[u]),header:!0,align:s.align[u]});for(let u of o)s.rows.push(ca(u,s.header.length).map((d,p)=>({text:d,tokens:this.lexer.inline(d),header:!1,align:s.align[p]})));return s}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let n=t[1].trim();return{type:"heading",raw:Wt(t[0],`
1413
+ `,1)[0],_=!b.trim(),w=0;if(this.options.pedantic?(w=2,p=b.trimStart()):_?w=t[1].length+1:(w=b.search(this.rules.other.nonSpaceChar),w=w>4?1:w,p=b.slice(w),w+=t[1].length),_&&this.rules.other.blankLine.test(m)&&(h+=m+`
1414
+ `,e=e.substring(m.length+1),d=!0),!d){let C=this.rules.other.nextBulletRegex(w),M=this.rules.other.hrRegex(w),W=this.rules.other.fencesBeginRegex(w),P=this.rules.other.headingBeginRegex(w),T=this.rules.other.htmlBeginRegex(w),x=this.rules.other.blockquoteBeginRegex(w);for(;e;){let R=e.split(`
1415
+ `,1)[0],D;if(m=R,this.options.pedantic?(m=m.replace(this.rules.other.listReplaceNesting," "),D=m):D=m.replace(this.rules.other.tabCharGlobal," "),W.test(m)||P.test(m)||T.test(m)||x.test(m)||C.test(m)||M.test(m))break;if(D.search(this.rules.other.nonSpaceChar)>=w||!m.trim())p+=`
1416
+ `+D.slice(w);else{if(_||b.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||W.test(b)||P.test(b)||M.test(b))break;p+=`
1417
+ `+m}_=!m.trim(),h+=R+`
1418
+ `,e=e.substring(R.length+1),b=D.slice(w)}}o.loose||(a?o.loose=!0:this.rules.other.doubleBlankLine.test(h)&&(a=!0)),o.items.push({type:"list_item",raw:h,task:!!this.options.gfm&&this.rules.other.listIsTask.test(p),loose:!1,text:p,tokens:[]}),o.raw+=h}let u=o.items.at(-1);if(u)u.raw=u.raw.trimEnd(),u.text=u.text.trimEnd();else return;o.raw=o.raw.trimEnd();for(let d of o.items){this.lexer.state.top=!1,d.tokens=this.lexer.blockTokens(d.text,[]);let h=d.tokens[0];if(d.task&&((h==null?void 0:h.type)==="text"||(h==null?void 0:h.type)==="paragraph")){d.text=d.text.replace(this.rules.other.listReplaceTask,""),h.raw=h.raw.replace(this.rules.other.listReplaceTask,""),h.text=h.text.replace(this.rules.other.listReplaceTask,"");for(let b=this.lexer.inlineQueue.length-1;b>=0;b--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[b].src)){this.lexer.inlineQueue[b].src=this.lexer.inlineQueue[b].src.replace(this.rules.other.listReplaceTask,"");break}let p=this.rules.other.listTaskCheckbox.exec(d.raw);if(p){let b={type:"checkbox",raw:p[0]+" ",checked:p[0]!=="[ ]"};d.checked=b.checked,o.loose?d.tokens[0]&&["paragraph","text"].includes(d.tokens[0].type)&&"tokens"in d.tokens[0]&&d.tokens[0].tokens?(d.tokens[0].raw=b.raw+d.tokens[0].raw,d.tokens[0].text=b.raw+d.tokens[0].text,d.tokens[0].tokens.unshift(b)):d.tokens.unshift({type:"paragraph",raw:b.raw,text:b.raw,tokens:[b]}):d.tokens.unshift(b)}}else d.task&&(d.task=!1);if(!o.loose){let p=d.tokens.filter(m=>m.type==="space"),b=p.length>0&&p.some(m=>this.rules.other.anyLine.test(m.raw));o.loose=b}}if(o.loose)for(let d of o.items){d.loose=!0;for(let h of d.tokens)h.type==="text"&&(h.type="paragraph")}return o}}html(e){let t=this.rules.block.html.exec(e);if(t){let n=ia(t[0]);return{type:"html",block:!0,raw:n,pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:n}}}def(e){let t=this.rules.block.def.exec(e);if(t){let n=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",o=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:n,raw:Vt(t[0],`
1419
+ `),href:r,title:o}}}table(e){var a;let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=oa(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),o=(a=t[3])!=null&&a.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
1420
+ `):[],s={type:"table",raw:Vt(t[0],`
1421
+ `),header:[],align:[],rows:[]};if(n.length===r.length){for(let u of r)this.rules.other.tableAlignRight.test(u)?s.align.push("right"):this.rules.other.tableAlignCenter.test(u)?s.align.push("center"):this.rules.other.tableAlignLeft.test(u)?s.align.push("left"):s.align.push(null);for(let u=0;u<n.length;u++)s.header.push({text:n[u],tokens:this.lexer.inline(n[u]),header:!0,align:s.align[u]});for(let u of o)s.rows.push(oa(u,s.header.length).map((d,h)=>({text:d,tokens:this.lexer.inline(d),header:!1,align:s.align[h]})));return s}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let n=t[1].trim();return{type:"heading",raw:Vt(t[0],`
1405
1422
  `),depth:t[2].charAt(0)==="="?1:2,text:n,tokens:this.lexer.inline(n)}}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let n=t[1].charAt(t[1].length-1)===`
1406
- `?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:n,tokens:this.lexer.inline(n)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let n=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let s=Wt(n.slice(0,-1),"\\");if((n.length-s.length)%2===0)return}else{let s=Ym(t[2],"()");if(s===-2)return;if(s>-1){let c=(t[0].indexOf("!")===0?5:4)+t[1].length+s;t[2]=t[2].substring(0,s),t[0]=t[0].substring(0,c).trim(),t[3]=""}}let r=t[2],o="";if(this.options.pedantic){let s=this.rules.other.pedanticHrefTitle.exec(r);s&&(r=s[1],o=s[3])}else o=t[3]?t[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?r=r.slice(1):r=r.slice(1,-1)),ua(t,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:o&&o.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let r=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),o=t[r.toLowerCase()];if(!o){let s=n[0].charAt(0);return{type:"text",raw:s,text:s}}return ua(n,o,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!n||this.rules.inline.punctuation.exec(n))){let o=[...r[0]].length-1,s,c,u=o,d=0,p=r[0][0],h=n===p,b=p==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(b.lastIndex=0,t=t.slice(-1*e.length+o);(r=b.exec(t))!==null;){if(s=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!s)continue;if(c=[...s].length,r[3]||r[4]){u+=c;continue}else if(r[5]||r[6]){if(o%3&&!((o+c)%3)){d+=c;continue}if(h)break}if(u-=c,u>0)continue;c=Math.min(c,c+u+d);let m=[...r[0]][0].length,_=e.slice(0,o+r.index+m+c);if(Math.min(o,c)%2){let P=_.slice(1,-1);return{type:"em",raw:_,text:P,tokens:this.lexer.inlineTokens(P)}}let w=_.slice(2,-2);return{type:"strong",raw:_,text:w,tokens:this.lexer.inlineTokens(w)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(n),o=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return r&&o&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:t[0],text:n}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e,t,n=""){let r=this.rules.inline.delLDelim.exec(e);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let o=[...r[0]].length-1,s,c,u=o,d=this.rules.inline.delRDelim;for(d.lastIndex=0,t=t.slice(-1*e.length+o);(r=d.exec(t))!==null;){if(s=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!s||(c=[...s].length,c!==o))continue;if(r[3]||r[4]){u+=c;continue}if(u-=c,u>0)continue;c=Math.min(c,c+u);let p=[...r[0]][0].length,h=e.slice(0,o+r.index+p+c),b=h.slice(o,-o);return{type:"del",raw:h,text:b,tokens:this.lexer.inlineTokens(b)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let n,r;return t[2]==="@"?(n=t[1],r="mailto:"+n):(n=t[1],r=n),{type:"link",raw:t[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}url(e){var n;let t;if(t=this.rules.inline.url.exec(e)){let r,o;if(t[2]==="@")r=t[0],o="mailto:"+r;else{let s;do s=t[0],t[0]=((n=this.rules.inline._backpedal.exec(t[0]))==null?void 0:n[0])??"";while(s!==t[0]);r=t[0],t[1]==="www."?o="http://"+t[0]:o=t[0]}return{type:"link",raw:t[0],text:r,href:o,tokens:[{type:"text",raw:r,text:r}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let n=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:n}}}},mt=class Ai{constructor(t){re(this,"tokens");re(this,"options");re(this,"state");re(this,"inlineQueue");re(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||En,this.options.tokenizer=this.options.tokenizer||new Mo,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={other:Ue,block:po.normal,inline:_r.normal};this.options.pedantic?(n.block=po.pedantic,n.inline=_r.pedantic):this.options.gfm&&(n.block=po.gfm,this.options.breaks?n.inline=_r.breaks:n.inline=_r.gfm),this.tokenizer.rules=n}static get rules(){return{block:po,inline:_r}}static lex(t,n){return new Ai(n).lex(t)}static lexInline(t,n){return new Ai(n).inlineTokens(t)}lex(t){t=t.replace(Ue.carriageReturn,`
1407
- `),this.blockTokens(t,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let r=this.inlineQueue[n];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,n=[],r=!1){var s,c,u;this.tokenizer.lexer=this,this.options.pedantic&&(t=t.replace(Ue.tabCharGlobal," ").replace(Ue.spaceLine,""));let o=1/0;for(;t;){if(t.length<o)o=t.length;else{this.infiniteLoopError(t.charCodeAt(0));break}let d;if((c=(s=this.options.extensions)==null?void 0:s.block)!=null&&c.some(h=>(d=h.call({lexer:this},t,n))?(t=t.substring(d.raw.length),n.push(d),!0):!1))continue;if(d=this.tokenizer.space(t)){t=t.substring(d.raw.length);let h=n.at(-1);d.raw.length===1&&h!==void 0?h.raw+=`
1408
- `:n.push(d);continue}if(d=this.tokenizer.code(t)){t=t.substring(d.raw.length);let h=n.at(-1);(h==null?void 0:h.type)==="paragraph"||(h==null?void 0:h.type)==="text"?(h.raw+=(h.raw.endsWith(`
1423
+ `?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:n,tokens:this.lexer.inline(n)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let n=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let s=Vt(n.slice(0,-1),"\\");if((n.length-s.length)%2===0)return}else{let s=Wm(t[2],"()");if(s===-2)return;if(s>-1){let a=(t[0].indexOf("!")===0?5:4)+t[1].length+s;t[2]=t[2].substring(0,s),t[0]=t[0].substring(0,a).trim(),t[3]=""}}let r=t[2],o="";if(this.options.pedantic){let s=this.rules.other.pedanticHrefTitle.exec(r);s&&(r=s[1],o=s[3])}else o=t[3]?t[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?r=r.slice(1):r=r.slice(1,-1)),sa(t,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:o&&o.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let r=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),o=t[r.toLowerCase()];if(!o){let s=n[0].charAt(0);return{type:"text",raw:s,text:s}}return sa(n,o,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!n||this.rules.inline.punctuation.exec(n))){let o=[...r[0]].length-1,s,a,u=o,d=0,h=r[0][0],p=n===h,b=h==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(b.lastIndex=0,t=t.slice(-1*e.length+o);(r=b.exec(t))!==null;){if(s=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!s)continue;if(a=[...s].length,r[3]||r[4]){u+=a;continue}else if(r[5]||r[6]){if(o%3&&!((o+a)%3)){d+=a;continue}if(p)break}if(u-=a,u>0)continue;a=Math.min(a,a+u+d);let m=[...r[0]][0].length,_=e.slice(0,o+r.index+m+a);if(Math.min(o,a)%2){let C=_.slice(1,-1);return{type:"em",raw:_,text:C,tokens:this.lexer.inlineTokens(C)}}let w=_.slice(2,-2);return{type:"strong",raw:_,text:w,tokens:this.lexer.inlineTokens(w)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(n),o=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return r&&o&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:t[0],text:n}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e,t,n=""){let r=this.rules.inline.delLDelim.exec(e);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let o=[...r[0]].length-1,s,a,u=o,d=this.rules.inline.delRDelim;for(d.lastIndex=0,t=t.slice(-1*e.length+o);(r=d.exec(t))!==null;){if(s=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!s||(a=[...s].length,a!==o))continue;if(r[3]||r[4]){u+=a;continue}if(u-=a,u>0)continue;a=Math.min(a,a+u);let h=[...r[0]][0].length,p=e.slice(0,o+r.index+h+a),b=p.slice(o,-o);return{type:"del",raw:p,text:b,tokens:this.lexer.inlineTokens(b)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let n,r;return t[2]==="@"?(n=t[1],r="mailto:"+n):(n=t[1],r=n),{type:"link",raw:t[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}url(e){var n;let t;if(t=this.rules.inline.url.exec(e)){let r,o;if(t[2]==="@")r=t[0],o="mailto:"+r;else{let s;do s=t[0],t[0]=((n=this.rules.inline._backpedal.exec(t[0]))==null?void 0:n[0])??"";while(s!==t[0]);r=t[0],t[1]==="www."?o="http://"+t[0]:o=t[0]}return{type:"link",raw:t[0],text:r,href:o,tokens:[{type:"text",raw:r,text:r}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let n=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:n}}}},vt=class Si{constructor(t){ie(this,"tokens");ie(this,"options");ie(this,"state");ie(this,"inlineQueue");ie(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||An,this.options.tokenizer=this.options.tokenizer||new $o,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={other:je,block:co.normal,inline:kr.normal};this.options.pedantic?(n.block=co.pedantic,n.inline=kr.pedantic):this.options.gfm&&(n.block=co.gfm,this.options.breaks?n.inline=kr.breaks:n.inline=kr.gfm),this.tokenizer.rules=n}static get rules(){return{block:co,inline:kr}}static lex(t,n){return new Si(n).lex(t)}static lexInline(t,n){return new Si(n).inlineTokens(t)}lex(t){t=t.replace(je.carriageReturn,`
1424
+ `),this.blockTokens(t,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let r=this.inlineQueue[n];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,n=[],r=!1){var s,a,u;this.tokenizer.lexer=this,this.options.pedantic&&(t=t.replace(je.tabCharGlobal," ").replace(je.spaceLine,""));let o=1/0;for(;t;){if(t.length<o)o=t.length;else{this.infiniteLoopError(t.charCodeAt(0));break}let d;if((a=(s=this.options.extensions)==null?void 0:s.block)!=null&&a.some(p=>(d=p.call({lexer:this},t,n))?(t=t.substring(d.raw.length),n.push(d),!0):!1))continue;if(d=this.tokenizer.space(t)){t=t.substring(d.raw.length);let p=n.at(-1);d.raw.length===1&&p!==void 0?p.raw+=`
1425
+ `:n.push(d);continue}if(d=this.tokenizer.code(t)){t=t.substring(d.raw.length);let p=n.at(-1);(p==null?void 0:p.type)==="paragraph"||(p==null?void 0:p.type)==="text"?(p.raw+=(p.raw.endsWith(`
1409
1426
  `)?"":`
1410
- `)+d.raw,h.text+=`
1411
- `+d.text,this.inlineQueue.at(-1).src=h.text):n.push(d);continue}if(d=this.tokenizer.fences(t)){t=t.substring(d.raw.length),n.push(d);continue}if(d=this.tokenizer.heading(t)){t=t.substring(d.raw.length),n.push(d);continue}if(d=this.tokenizer.hr(t)){t=t.substring(d.raw.length),n.push(d);continue}if(d=this.tokenizer.blockquote(t)){t=t.substring(d.raw.length),n.push(d);continue}if(d=this.tokenizer.list(t)){t=t.substring(d.raw.length),n.push(d);continue}if(d=this.tokenizer.html(t)){t=t.substring(d.raw.length),n.push(d);continue}if(d=this.tokenizer.def(t)){t=t.substring(d.raw.length);let h=n.at(-1);(h==null?void 0:h.type)==="paragraph"||(h==null?void 0:h.type)==="text"?(h.raw+=(h.raw.endsWith(`
1427
+ `)+d.raw,p.text+=`
1428
+ `+d.text,this.inlineQueue.at(-1).src=p.text):n.push(d);continue}if(d=this.tokenizer.fences(t)){t=t.substring(d.raw.length),n.push(d);continue}if(d=this.tokenizer.heading(t)){t=t.substring(d.raw.length),n.push(d);continue}if(d=this.tokenizer.hr(t)){t=t.substring(d.raw.length),n.push(d);continue}if(d=this.tokenizer.blockquote(t)){t=t.substring(d.raw.length),n.push(d);continue}if(d=this.tokenizer.list(t)){t=t.substring(d.raw.length),n.push(d);continue}if(d=this.tokenizer.html(t)){t=t.substring(d.raw.length),n.push(d);continue}if(d=this.tokenizer.def(t)){t=t.substring(d.raw.length);let p=n.at(-1);(p==null?void 0:p.type)==="paragraph"||(p==null?void 0:p.type)==="text"?(p.raw+=(p.raw.endsWith(`
1412
1429
  `)?"":`
1413
- `)+d.raw,h.text+=`
1414
- `+d.raw,this.inlineQueue.at(-1).src=h.text):this.tokens.links[d.tag]||(this.tokens.links[d.tag]={href:d.href,title:d.title},n.push(d));continue}if(d=this.tokenizer.table(t)){t=t.substring(d.raw.length),n.push(d);continue}if(d=this.tokenizer.lheading(t)){t=t.substring(d.raw.length),n.push(d);continue}let p=t;if((u=this.options.extensions)!=null&&u.startBlock){let h=1/0,b=t.slice(1),m;this.options.extensions.startBlock.forEach(_=>{m=_.call({lexer:this},b),typeof m=="number"&&m>=0&&(h=Math.min(h,m))}),h<1/0&&h>=0&&(p=t.substring(0,h+1))}if(this.state.top&&(d=this.tokenizer.paragraph(p))){let h=n.at(-1);r&&(h==null?void 0:h.type)==="paragraph"?(h.raw+=(h.raw.endsWith(`
1430
+ `)+d.raw,p.text+=`
1431
+ `+d.raw,this.inlineQueue.at(-1).src=p.text):this.tokens.links[d.tag]||(this.tokens.links[d.tag]={href:d.href,title:d.title},n.push(d));continue}if(d=this.tokenizer.table(t)){t=t.substring(d.raw.length),n.push(d);continue}if(d=this.tokenizer.lheading(t)){t=t.substring(d.raw.length),n.push(d);continue}let h=t;if((u=this.options.extensions)!=null&&u.startBlock){let p=1/0,b=t.slice(1),m;this.options.extensions.startBlock.forEach(_=>{m=_.call({lexer:this},b),typeof m=="number"&&m>=0&&(p=Math.min(p,m))}),p<1/0&&p>=0&&(h=t.substring(0,p+1))}if(this.state.top&&(d=this.tokenizer.paragraph(h))){let p=n.at(-1);r&&(p==null?void 0:p.type)==="paragraph"?(p.raw+=(p.raw.endsWith(`
1415
1432
  `)?"":`
1416
- `)+d.raw,h.text+=`
1417
- `+d.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=h.text):n.push(d),r=p.length!==t.length,t=t.substring(d.raw.length);continue}if(d=this.tokenizer.text(t)){t=t.substring(d.raw.length);let h=n.at(-1);(h==null?void 0:h.type)==="text"?(h.raw+=(h.raw.endsWith(`
1433
+ `)+d.raw,p.text+=`
1434
+ `+d.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=p.text):n.push(d),r=h.length!==t.length,t=t.substring(d.raw.length);continue}if(d=this.tokenizer.text(t)){t=t.substring(d.raw.length);let p=n.at(-1);(p==null?void 0:p.type)==="text"?(p.raw+=(p.raw.endsWith(`
1418
1435
  `)?"":`
1419
- `)+d.raw,h.text+=`
1420
- `+d.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=h.text):n.push(d);continue}if(t){this.infiniteLoopError(t.charCodeAt(0));break}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){var u,d,p,h,b;this.tokenizer.lexer=this;let r=t;if(this.tokens.links){let m=Object.keys(this.tokens.links);m.length>0&&(r=r.replace(this.tokenizer.rules.inline.reflinkSearch,_=>m.includes(_.slice(_.lastIndexOf("[")+1,-1))?"["+"a".repeat(_.length-2)+"]":_))}r=r.replace(this.tokenizer.rules.inline.anyPunctuation,"++"),r=r.replace(this.tokenizer.rules.inline.blockSkip,(m,_,w)=>{let P=w?w.length:0;return m.slice(0,P)+"["+"a".repeat(m.length-P-2)+"]"}),r=((d=(u=this.options.hooks)==null?void 0:u.emStrongMask)==null?void 0:d.call({lexer:this},r))??r;let o=!1,s="",c=1/0;for(;t;){if(t.length<c)c=t.length;else{this.infiniteLoopError(t.charCodeAt(0));break}o||(s=""),o=!1;let m;if((h=(p=this.options.extensions)==null?void 0:p.inline)!=null&&h.some(w=>(m=w.call({lexer:this},t,n))?(t=t.substring(m.raw.length),n.push(m),!0):!1))continue;if(m=this.tokenizer.escape(t)){t=t.substring(m.raw.length),n.push(m);continue}if(m=this.tokenizer.tag(t)){t=t.substring(m.raw.length),n.push(m);continue}if(m=this.tokenizer.link(t)){t=t.substring(m.raw.length),n.push(m);continue}if(m=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(m.raw.length);let w=n.at(-1);m.type==="text"&&(w==null?void 0:w.type)==="text"?(w.raw+=m.raw,w.text+=m.text):n.push(m);continue}if(m=this.tokenizer.emStrong(t,r,s)){t=t.substring(m.raw.length),n.push(m);continue}if(m=this.tokenizer.codespan(t)){t=t.substring(m.raw.length),n.push(m);continue}if(m=this.tokenizer.br(t)){t=t.substring(m.raw.length),n.push(m);continue}if(m=this.tokenizer.del(t,r,s)){t=t.substring(m.raw.length),n.push(m);continue}if(m=this.tokenizer.autolink(t)){t=t.substring(m.raw.length),n.push(m);continue}if(!this.state.inLink&&(m=this.tokenizer.url(t))){t=t.substring(m.raw.length),n.push(m);continue}let _=t;if((b=this.options.extensions)!=null&&b.startInline){let w=1/0,P=t.slice(1),N;this.options.extensions.startInline.forEach(te=>{N=te.call({lexer:this},P),typeof N=="number"&&N>=0&&(w=Math.min(w,N))}),w<1/0&&w>=0&&(_=t.substring(0,w+1))}if(m=this.tokenizer.inlineText(_)){t=t.substring(m.raw.length),m.raw.slice(-1)!=="_"&&(s=m.raw.slice(-1)),o=!0;let w=n.at(-1);(w==null?void 0:w.type)==="text"?(w.raw+=m.raw,w.text+=m.text):n.push(m);continue}if(t){this.infiniteLoopError(t.charCodeAt(0));break}}return n}infiniteLoopError(t){let n="Infinite loop on byte: "+t;if(this.options.silent)console.error(n);else throw new Error(n)}},Uo=class{constructor(e){re(this,"options");re(this,"parser");this.options=e||En}space(e){return""}code({text:e,lang:t,escaped:n}){var s;let r=(s=(t||"").match(Ue.notSpaceStart))==null?void 0:s[0],o=e.replace(Ue.endingNewline,"")+`
1421
- `;return r?'<pre><code class="language-'+yt(r)+'">'+(n?o:yt(o,!0))+`</code></pre>
1422
- `:"<pre><code>"+(n?o:yt(o,!0))+`</code></pre>
1436
+ `)+d.raw,p.text+=`
1437
+ `+d.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=p.text):n.push(d);continue}if(t){this.infiniteLoopError(t.charCodeAt(0));break}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){var u,d,h,p,b;this.tokenizer.lexer=this;let r=t;if(this.tokens.links){let m=Object.keys(this.tokens.links);m.length>0&&(r=r.replace(this.tokenizer.rules.inline.reflinkSearch,_=>m.includes(_.slice(_.lastIndexOf("[")+1,-1))?"["+"a".repeat(_.length-2)+"]":_))}r=r.replace(this.tokenizer.rules.inline.anyPunctuation,"++"),r=r.replace(this.tokenizer.rules.inline.blockSkip,(m,_,w)=>{let C=w?w.length:0;return m.slice(0,C)+"["+"a".repeat(m.length-C-2)+"]"}),r=((d=(u=this.options.hooks)==null?void 0:u.emStrongMask)==null?void 0:d.call({lexer:this},r))??r;let o=!1,s="",a=1/0;for(;t;){if(t.length<a)a=t.length;else{this.infiniteLoopError(t.charCodeAt(0));break}o||(s=""),o=!1;let m;if((p=(h=this.options.extensions)==null?void 0:h.inline)!=null&&p.some(w=>(m=w.call({lexer:this},t,n))?(t=t.substring(m.raw.length),n.push(m),!0):!1))continue;if(m=this.tokenizer.escape(t)){t=t.substring(m.raw.length),n.push(m);continue}if(m=this.tokenizer.tag(t)){t=t.substring(m.raw.length),n.push(m);continue}if(m=this.tokenizer.link(t)){t=t.substring(m.raw.length),n.push(m);continue}if(m=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(m.raw.length);let w=n.at(-1);m.type==="text"&&(w==null?void 0:w.type)==="text"?(w.raw+=m.raw,w.text+=m.text):n.push(m);continue}if(m=this.tokenizer.emStrong(t,r,s)){t=t.substring(m.raw.length),n.push(m);continue}if(m=this.tokenizer.codespan(t)){t=t.substring(m.raw.length),n.push(m);continue}if(m=this.tokenizer.br(t)){t=t.substring(m.raw.length),n.push(m);continue}if(m=this.tokenizer.del(t,r,s)){t=t.substring(m.raw.length),n.push(m);continue}if(m=this.tokenizer.autolink(t)){t=t.substring(m.raw.length),n.push(m);continue}if(!this.state.inLink&&(m=this.tokenizer.url(t))){t=t.substring(m.raw.length),n.push(m);continue}let _=t;if((b=this.options.extensions)!=null&&b.startInline){let w=1/0,C=t.slice(1),M;this.options.extensions.startInline.forEach(W=>{M=W.call({lexer:this},C),typeof M=="number"&&M>=0&&(w=Math.min(w,M))}),w<1/0&&w>=0&&(_=t.substring(0,w+1))}if(m=this.tokenizer.inlineText(_)){t=t.substring(m.raw.length),m.raw.slice(-1)!=="_"&&(s=m.raw.slice(-1)),o=!0;let w=n.at(-1);(w==null?void 0:w.type)==="text"?(w.raw+=m.raw,w.text+=m.text):n.push(m);continue}if(t){this.infiniteLoopError(t.charCodeAt(0));break}}return n}infiniteLoopError(t){let n="Infinite loop on byte: "+t;if(this.options.silent)console.error(n);else throw new Error(n)}},No=class{constructor(e){ie(this,"options");ie(this,"parser");this.options=e||An}space(e){return""}code({text:e,lang:t,escaped:n}){var s;let r=(s=(t||"").match(je.notSpaceStart))==null?void 0:s[0],o=e.replace(je.endingNewline,"")+`
1438
+ `;return r?'<pre><code class="language-'+St(r)+'">'+(n?o:St(o,!0))+`</code></pre>
1439
+ `:"<pre><code>"+(n?o:St(o,!0))+`</code></pre>
1423
1440
  `}blockquote({tokens:e}){return`<blockquote>
1424
1441
  ${this.parser.parse(e)}</blockquote>
1425
1442
  `}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
1426
1443
  `}hr(e){return`<hr>
1427
- `}list(e){let t=e.ordered,n=e.start,r="";for(let c=0;c<e.items.length;c++){let u=e.items[c];r+=this.listitem(u)}let o=t?"ol":"ul",s=t&&n!==1?' start="'+n+'"':"";return"<"+o+s+`>
1444
+ `}list(e){let t=e.ordered,n=e.start,r="";for(let a=0;a<e.items.length;a++){let u=e.items[a];r+=this.listitem(u)}let o=t?"ol":"ul",s=t&&n!==1?' start="'+n+'"':"";return"<"+o+s+`>
1428
1445
  `+r+"</"+o+`>
1429
1446
  `}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
1430
1447
  `}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
1431
- `}table(e){let t="",n="";for(let o=0;o<e.header.length;o++)n+=this.tablecell(e.header[o]);t+=this.tablerow({text:n});let r="";for(let o=0;o<e.rows.length;o++){let s=e.rows[o];n="";for(let c=0;c<s.length;c++)n+=this.tablecell(s[c]);r+=this.tablerow({text:n})}return r&&(r=`<tbody>${r}</tbody>`),`<table>
1448
+ `}table(e){let t="",n="";for(let o=0;o<e.header.length;o++)n+=this.tablecell(e.header[o]);t+=this.tablerow({text:n});let r="";for(let o=0;o<e.rows.length;o++){let s=e.rows[o];n="";for(let a=0;a<s.length;a++)n+=this.tablecell(s[a]);r+=this.tablerow({text:n})}return r&&(r=`<tbody>${r}</tbody>`),`<table>
1432
1449
  <thead>
1433
1450
  `+t+`</thead>
1434
1451
  `+r+`</table>
1435
1452
  `}tablerow({text:e}){return`<tr>
1436
1453
  ${e}</tr>
1437
1454
  `}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
1438
- `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${yt(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),o=aa(e);if(o===null)return r;e=o;let s='<a href="'+e+'"';return t&&(s+=' title="'+yt(t)+'"'),s+=">"+r+"</a>",s}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let o=aa(e);if(o===null)return yt(n);e=o;let s=`<img src="${e}" alt="${yt(n)}"`;return t&&(s+=` title="${yt(t)}"`),s+=">",s}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:yt(e.text)}},Ki=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},bt=class Ci{constructor(t){re(this,"options");re(this,"renderer");re(this,"textRenderer");this.options=t||En,this.options.renderer=this.options.renderer||new Uo,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Ki}static parse(t,n){return new Ci(n).parse(t)}static parseInline(t,n){return new Ci(n).parseInline(t)}parse(t){var r,o;this.renderer.parser=this;let n="";for(let s=0;s<t.length;s++){let c=t[s];if((o=(r=this.options.extensions)==null?void 0:r.renderers)!=null&&o[c.type]){let d=c,p=this.options.extensions.renderers[d.type].call({parser:this},d);if(p!==!1||!["space","hr","heading","code","table","blockquote","list","checkbox","html","def","paragraph","text"].includes(d.type)){n+=p||"";continue}}let u=c;switch(u.type){case"space":{n+=this.renderer.space(u);break}case"hr":{n+=this.renderer.hr(u);break}case"heading":{n+=this.renderer.heading(u);break}case"code":{n+=this.renderer.code(u);break}case"table":{n+=this.renderer.table(u);break}case"blockquote":{n+=this.renderer.blockquote(u);break}case"list":{n+=this.renderer.list(u);break}case"checkbox":{n+=this.renderer.checkbox(u);break}case"html":{n+=this.renderer.html(u);break}case"def":{n+=this.renderer.def(u);break}case"paragraph":{n+=this.renderer.paragraph(u);break}case"text":{n+=this.renderer.text(u);break}default:{let d='Token with "'+u.type+'" type was not found.';if(this.options.silent)return console.error(d),"";throw new Error(d)}}}return n}parseInline(t,n=this.renderer){var o,s;this.renderer.parser=this;let r="";for(let c=0;c<t.length;c++){let u=t[c];if((s=(o=this.options.extensions)==null?void 0:o.renderers)!=null&&s[u.type]){let p=this.options.extensions.renderers[u.type].call({parser:this},u);if(p!==!1||!["escape","html","link","image","checkbox","strong","em","codespan","br","del","text"].includes(u.type)){r+=p||"";continue}}let d=u;switch(d.type){case"escape":{r+=n.text(d);break}case"html":{r+=n.html(d);break}case"link":{r+=n.link(d);break}case"image":{r+=n.image(d);break}case"checkbox":{r+=n.checkbox(d);break}case"strong":{r+=n.strong(d);break}case"em":{r+=n.em(d);break}case"codespan":{r+=n.codespan(d);break}case"br":{r+=n.br(d);break}case"del":{r+=n.del(d);break}case"text":{r+=n.text(d);break}default:{let p='Token with "'+d.type+'" type was not found.';if(this.options.silent)return console.error(p),"";throw new Error(p)}}}return r}},bo,Ar=(bo=class{constructor(e){re(this,"options");re(this,"block");this.options=e||En}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?mt.lex:mt.lexInline}provideParser(e=this.block){return e?bt.parse:bt.parseInline}},re(bo,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),re(bo,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),bo),eb=class{constructor(...e){re(this,"defaults",Bi());re(this,"options",this.setOptions);re(this,"parse",this.parseMarkdown(!0));re(this,"parseInline",this.parseMarkdown(!1));re(this,"Parser",bt);re(this,"Renderer",Uo);re(this,"TextRenderer",Ki);re(this,"Lexer",mt);re(this,"Tokenizer",Mo);re(this,"Hooks",Ar);this.use(...e)}walkTokens(e,t){var r,o;let n=[];for(let s of e)switch(n=n.concat(t.call(this,s)),s.type){case"table":{let c=s;for(let u of c.header)n=n.concat(this.walkTokens(u.tokens,t));for(let u of c.rows)for(let d of u)n=n.concat(this.walkTokens(d.tokens,t));break}case"list":{let c=s;n=n.concat(this.walkTokens(c.items,t));break}default:{let c=s;(o=(r=this.defaults.extensions)==null?void 0:r.childTokens)!=null&&o[c.type]?this.defaults.extensions.childTokens[c.type].forEach(u=>{let d=c[u].flat(1/0);n=n.concat(this.walkTokens(d,t))}):c.tokens&&(n=n.concat(this.walkTokens(c.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{let r={...n};if(r.async=this.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(o=>{if(!o.name)throw new Error("extension name required");if("renderer"in o){let s=t.renderers[o.name];s?t.renderers[o.name]=function(...c){let u=o.renderer.apply(this,c);return u===!1&&(u=s.apply(this,c)),u}:t.renderers[o.name]=o.renderer}if("tokenizer"in o){if(!o.level||o.level!=="block"&&o.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let s=t[o.level];s?s.unshift(o.tokenizer):t[o.level]=[o.tokenizer],o.start&&(o.level==="block"?t.startBlock?t.startBlock.push(o.start):t.startBlock=[o.start]:o.level==="inline"&&(t.startInline?t.startInline.push(o.start):t.startInline=[o.start]))}"childTokens"in o&&o.childTokens&&(t.childTokens[o.name]=o.childTokens)}),r.extensions=t),n.renderer){let o=this.defaults.renderer||new Uo(this.defaults);for(let s in n.renderer){if(!(s in o))throw new Error(`renderer '${s}' does not exist`);if(["options","parser"].includes(s))continue;let c=s,u=n.renderer[c],d=o[c];o[c]=(...p)=>{let h=u.apply(o,p);return h===!1&&(h=d.apply(o,p)),h||""}}r.renderer=o}if(n.tokenizer){let o=this.defaults.tokenizer||new Mo(this.defaults);for(let s in n.tokenizer){if(!(s in o))throw new Error(`tokenizer '${s}' does not exist`);if(["options","rules","lexer"].includes(s))continue;let c=s,u=n.tokenizer[c],d=o[c];o[c]=(...p)=>{let h=u.apply(o,p);return h===!1&&(h=d.apply(o,p)),h}}r.tokenizer=o}if(n.hooks){let o=this.defaults.hooks||new Ar;for(let s in n.hooks){if(!(s in o))throw new Error(`hook '${s}' does not exist`);if(["options","block"].includes(s))continue;let c=s,u=n.hooks[c],d=o[c];Ar.passThroughHooks.has(s)?o[c]=p=>{if(this.defaults.async&&Ar.passThroughHooksRespectAsync.has(s))return(async()=>{let b=await u.call(o,p);return d.call(o,b)})();let h=u.call(o,p);return d.call(o,h)}:o[c]=(...p)=>{if(this.defaults.async)return(async()=>{let b=await u.apply(o,p);return b===!1&&(b=await d.apply(o,p)),b})();let h=u.apply(o,p);return h===!1&&(h=d.apply(o,p)),h}}r.hooks=o}if(n.walkTokens){let o=this.defaults.walkTokens,s=n.walkTokens;r.walkTokens=function(c){let u=[];return u.push(s.call(this,c)),o&&(u=u.concat(o.call(this,c))),u}}this.defaults={...this.defaults,...r}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return mt.lex(e,t??this.defaults)}parser(e,t){return bt.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},o={...this.defaults,...r},s=this.onError(!!o.silent,!!o.async);if(this.defaults.async===!0&&r.async===!1)return s(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||t===null)return s(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return s(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(o.hooks&&(o.hooks.options=o,o.hooks.block=e),o.async)return(async()=>{let c=o.hooks?await o.hooks.preprocess(t):t,u=await(o.hooks?await o.hooks.provideLexer(e):e?mt.lex:mt.lexInline)(c,o),d=o.hooks?await o.hooks.processAllTokens(u):u;o.walkTokens&&await Promise.all(this.walkTokens(d,o.walkTokens));let p=await(o.hooks?await o.hooks.provideParser(e):e?bt.parse:bt.parseInline)(d,o);return o.hooks?await o.hooks.postprocess(p):p})().catch(s);try{o.hooks&&(t=o.hooks.preprocess(t));let c=(o.hooks?o.hooks.provideLexer(e):e?mt.lex:mt.lexInline)(t,o);o.hooks&&(c=o.hooks.processAllTokens(c)),o.walkTokens&&this.walkTokens(c,o.walkTokens);let u=(o.hooks?o.hooks.provideParser(e):e?bt.parse:bt.parseInline)(c,o);return o.hooks&&(u=o.hooks.postprocess(u)),u}catch(c){return s(c)}}}onError(e,t){return n=>{if(n.message+=`
1439
- Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error occurred:</p><pre>"+yt(n.message+"",!0)+"</pre>";return t?Promise.resolve(r):r}if(t)return Promise.reject(n);throw n}}},yn=new eb;function ie(e,t){return yn.parse(e,t)}ie.options=ie.setOptions=function(e){return yn.setOptions(e),ie.defaults=yn.defaults,wc(ie.defaults),ie};ie.getDefaults=Bi;ie.defaults=En;function tb(...e){return yn.use(...e),ie.defaults=yn.defaults,wc(ie.defaults),ie}ie.use=tb;ie.walkTokens=function(e,t){return yn.walkTokens(e,t)};ie.parseInline=yn.parseInline;ie.Parser=bt;ie.parser=bt.parse;ie.Renderer=Uo;ie.TextRenderer=Ki;ie.Lexer=mt;ie.lexer=mt.lex;ie.Tokenizer=Mo;ie.Hooks=Ar;ie.parse=ie;ie.options;ie.setOptions;ie.walkTokens;ie.parseInline;bt.parse;mt.lex;/*! @license DOMPurify 3.3.1 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.1/LICENSE */const{entries:zc,setPrototypeOf:da,isFrozen:nb,getPrototypeOf:rb,getOwnPropertyDescriptor:ob}=Object;let{freeze:We,seal:ct,create:Pi}=Object,{apply:Ri,construct:Li}=typeof Reflect<"u"&&Reflect;We||(We=function(t){return t});ct||(ct=function(t){return t});Ri||(Ri=function(t,n){for(var r=arguments.length,o=new Array(r>2?r-2:0),s=2;s<r;s++)o[s-2]=arguments[s];return t.apply(n,o)});Li||(Li=function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return new t(...r)});const ho=Je(Array.prototype.forEach),ib=Je(Array.prototype.lastIndexOf),pa=Je(Array.prototype.pop),vr=Je(Array.prototype.push),sb=Je(Array.prototype.splice),vo=Je(String.prototype.toLowerCase),hi=Je(String.prototype.toString),fi=Je(String.prototype.match),yr=Je(String.prototype.replace),ab=Je(String.prototype.indexOf),cb=Je(String.prototype.trim),ft=Je(Object.prototype.hasOwnProperty),qe=Je(RegExp.prototype.test),wr=lb(TypeError);function Je(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return Ri(e,t,r)}}function lb(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return Li(e,n)}}function B(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:vo;da&&da(e,null);let r=t.length;for(;r--;){let o=t[r];if(typeof o=="string"){const s=n(o);s!==o&&(nb(t)||(t[r]=s),o=s)}e[o]=!0}return e}function ub(e){for(let t=0;t<e.length;t++)ft(e,t)||(e[t]=null);return e}function wt(e){const t=Pi(null);for(const[n,r]of zc(e))ft(e,n)&&(Array.isArray(r)?t[n]=ub(r):r&&typeof r=="object"&&r.constructor===Object?t[n]=wt(r):t[n]=r);return t}function xr(e,t){for(;e!==null;){const r=ob(e,t);if(r){if(r.get)return Je(r.get);if(typeof r.value=="function")return Je(r.value)}e=rb(e)}function n(){return null}return n}const ha=We(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),gi=We(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),mi=We(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),db=We(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),bi=We(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),pb=We(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),fa=We(["#text"]),ga=We(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),ki=We(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),ma=We(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),fo=We(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),hb=ct(/\{\{[\w\W]*|[\w\W]*\}\}/gm),fb=ct(/<%[\w\W]*|[\w\W]*%>/gm),gb=ct(/\$\{[\w\W]*/gm),mb=ct(/^data-[\-\w.\u00B7-\uFFFF]+$/),bb=ct(/^aria-[\-\w]+$/),Ic=ct(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),kb=ct(/^(?:\w+script|data):/i),_b=ct(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),$c=ct(/^html$/i),vb=ct(/^[a-z][.\w]*(-[.\w]+)+$/i);var ba=Object.freeze({__proto__:null,ARIA_ATTR:bb,ATTR_WHITESPACE:_b,CUSTOM_ELEMENT:vb,DATA_ATTR:mb,DOCTYPE_NAME:$c,ERB_EXPR:fb,IS_ALLOWED_URI:Ic,IS_SCRIPT_OR_DATA:kb,MUSTACHE_EXPR:hb,TMPLIT_EXPR:gb});const Sr={element:1,text:3,progressingInstruction:7,comment:8,document:9},yb=function(){return typeof window>"u"?null:window},wb=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let r=null;const o="data-tt-policy-suffix";n&&n.hasAttribute(o)&&(r=n.getAttribute(o));const s="dompurify"+(r?"#"+r:"");try{return t.createPolicy(s,{createHTML(c){return c},createScriptURL(c){return c}})}catch{return console.warn("TrustedTypes policy "+s+" could not be created."),null}},ka=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Nc(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:yb();const t=O=>Nc(O);if(t.version="3.3.1",t.removed=[],!e||!e.document||e.document.nodeType!==Sr.document||!e.Element)return t.isSupported=!1,t;let{document:n}=e;const r=n,o=r.currentScript,{DocumentFragment:s,HTMLTemplateElement:c,Node:u,Element:d,NodeFilter:p,NamedNodeMap:h=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:b,DOMParser:m,trustedTypes:_}=e,w=d.prototype,P=xr(w,"cloneNode"),N=xr(w,"remove"),te=xr(w,"nextSibling"),R=xr(w,"childNodes"),x=xr(w,"parentNode");if(typeof c=="function"){const O=n.createElement("template");O.content&&O.content.ownerDocument&&(n=O.content.ownerDocument)}let S,C="";const{implementation:M,createNodeIterator:se,createDocumentFragment:ve,getElementsByTagName:ze}=n,{importNode:Xe}=r;let Y=ka();t.isSupported=typeof zc=="function"&&typeof x=="function"&&M&&M.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:me,ERB_EXPR:Ve,TMPLIT_EXPR:qt,DATA_ATTR:Z,ARIA_ATTR:X,IS_SCRIPT_OR_DATA:Ie,ATTR_WHITESPACE:Oe,CUSTOM_ELEMENT:_t}=ba;let{IS_ALLOWED_URI:nt}=ba,be=null;const on=B({},[...ha,...gi,...mi,...bi,...fa]);let W=null;const Ce=B({},[...ga,...ki,...ma,...fo]);let J=Object.seal(Pi(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),ke=null,sn=null;const Pe=Object.seal(Pi(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let ae=!0,we=!0,Pt=!1,ir=!0,De=!1,an=!0,Rt=!1,Lt=!1,An=!1,Ht=!1,cn=!1,ln=!1,Hr=!0,sr=!1;const Qo="user-content-";let ar=!0,un=!1,Ft={},Ze=null;const cr=B({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let ce=null;const Fr=B({},["audio","video","img","source","image","track"]);let lr=null;const Br=B({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Cn="http://www.w3.org/1998/Math/MathML",Pn="http://www.w3.org/2000/svg",ut="http://www.w3.org/1999/xhtml";let Bt=ut,dn=!1,pn=null;const ei=B({},[Cn,Pn,ut],hi);let Rn=B({},["mi","mo","mn","ms","mtext"]),Ln=B({},["annotation-xml"]);const ti=B({},["title","style","font","a","script"]);let zt=null;const dt=["application/xhtml+xml","text/html"],ni="text/html";let le=null,Gt=null;const Gr=n.createElement("form"),ur=function(k){return k instanceof RegExp||k instanceof Function},zn=function(){let k=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Gt&&Gt===k)){if((!k||typeof k!="object")&&(k={}),k=wt(k),zt=dt.indexOf(k.PARSER_MEDIA_TYPE)===-1?ni:k.PARSER_MEDIA_TYPE,le=zt==="application/xhtml+xml"?hi:vo,be=ft(k,"ALLOWED_TAGS")?B({},k.ALLOWED_TAGS,le):on,W=ft(k,"ALLOWED_ATTR")?B({},k.ALLOWED_ATTR,le):Ce,pn=ft(k,"ALLOWED_NAMESPACES")?B({},k.ALLOWED_NAMESPACES,hi):ei,lr=ft(k,"ADD_URI_SAFE_ATTR")?B(wt(Br),k.ADD_URI_SAFE_ATTR,le):Br,ce=ft(k,"ADD_DATA_URI_TAGS")?B(wt(Fr),k.ADD_DATA_URI_TAGS,le):Fr,Ze=ft(k,"FORBID_CONTENTS")?B({},k.FORBID_CONTENTS,le):cr,ke=ft(k,"FORBID_TAGS")?B({},k.FORBID_TAGS,le):wt({}),sn=ft(k,"FORBID_ATTR")?B({},k.FORBID_ATTR,le):wt({}),Ft=ft(k,"USE_PROFILES")?k.USE_PROFILES:!1,ae=k.ALLOW_ARIA_ATTR!==!1,we=k.ALLOW_DATA_ATTR!==!1,Pt=k.ALLOW_UNKNOWN_PROTOCOLS||!1,ir=k.ALLOW_SELF_CLOSE_IN_ATTR!==!1,De=k.SAFE_FOR_TEMPLATES||!1,an=k.SAFE_FOR_XML!==!1,Rt=k.WHOLE_DOCUMENT||!1,Ht=k.RETURN_DOM||!1,cn=k.RETURN_DOM_FRAGMENT||!1,ln=k.RETURN_TRUSTED_TYPE||!1,An=k.FORCE_BODY||!1,Hr=k.SANITIZE_DOM!==!1,sr=k.SANITIZE_NAMED_PROPS||!1,ar=k.KEEP_CONTENT!==!1,un=k.IN_PLACE||!1,nt=k.ALLOWED_URI_REGEXP||Ic,Bt=k.NAMESPACE||ut,Rn=k.MATHML_TEXT_INTEGRATION_POINTS||Rn,Ln=k.HTML_INTEGRATION_POINTS||Ln,J=k.CUSTOM_ELEMENT_HANDLING||{},k.CUSTOM_ELEMENT_HANDLING&&ur(k.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(J.tagNameCheck=k.CUSTOM_ELEMENT_HANDLING.tagNameCheck),k.CUSTOM_ELEMENT_HANDLING&&ur(k.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(J.attributeNameCheck=k.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),k.CUSTOM_ELEMENT_HANDLING&&typeof k.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(J.allowCustomizedBuiltInElements=k.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),De&&(we=!1),cn&&(Ht=!0),Ft&&(be=B({},fa),W=[],Ft.html===!0&&(B(be,ha),B(W,ga)),Ft.svg===!0&&(B(be,gi),B(W,ki),B(W,fo)),Ft.svgFilters===!0&&(B(be,mi),B(W,ki),B(W,fo)),Ft.mathMl===!0&&(B(be,bi),B(W,ma),B(W,fo))),k.ADD_TAGS&&(typeof k.ADD_TAGS=="function"?Pe.tagCheck=k.ADD_TAGS:(be===on&&(be=wt(be)),B(be,k.ADD_TAGS,le))),k.ADD_ATTR&&(typeof k.ADD_ATTR=="function"?Pe.attributeCheck=k.ADD_ATTR:(W===Ce&&(W=wt(W)),B(W,k.ADD_ATTR,le))),k.ADD_URI_SAFE_ATTR&&B(lr,k.ADD_URI_SAFE_ATTR,le),k.FORBID_CONTENTS&&(Ze===cr&&(Ze=wt(Ze)),B(Ze,k.FORBID_CONTENTS,le)),k.ADD_FORBID_CONTENTS&&(Ze===cr&&(Ze=wt(Ze)),B(Ze,k.ADD_FORBID_CONTENTS,le)),ar&&(be["#text"]=!0),Rt&&B(be,["html","head","body"]),be.table&&(B(be,["tbody"]),delete ke.tbody),k.TRUSTED_TYPES_POLICY){if(typeof k.TRUSTED_TYPES_POLICY.createHTML!="function")throw wr('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof k.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw wr('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');S=k.TRUSTED_TYPES_POLICY,C=S.createHTML("")}else S===void 0&&(S=wb(_,o)),S!==null&&typeof C=="string"&&(C=S.createHTML(""));We&&We(k),Gt=k}},dr=B({},[...gi,...mi,...db]),Wr=B({},[...bi,...pb]),ri=function(k){let T=x(k);(!T||!T.tagName)&&(T={namespaceURI:Bt,tagName:"template"});const L=vo(k.tagName),ne=vo(T.tagName);return pn[k.namespaceURI]?k.namespaceURI===Pn?T.namespaceURI===ut?L==="svg":T.namespaceURI===Cn?L==="svg"&&(ne==="annotation-xml"||Rn[ne]):!!dr[L]:k.namespaceURI===Cn?T.namespaceURI===ut?L==="math":T.namespaceURI===Pn?L==="math"&&Ln[ne]:!!Wr[L]:k.namespaceURI===ut?T.namespaceURI===Pn&&!Ln[ne]||T.namespaceURI===Cn&&!Rn[ne]?!1:!Wr[L]&&(ti[L]||!dr[L]):!!(zt==="application/xhtml+xml"&&pn[k.namespaceURI]):!1},rt=function(k){vr(t.removed,{element:k});try{x(k).removeChild(k)}catch{N(k)}},ot=function(k,T){try{vr(t.removed,{attribute:T.getAttributeNode(k),from:T})}catch{vr(t.removed,{attribute:null,from:T})}if(T.removeAttribute(k),k==="is")if(Ht||cn)try{rt(T)}catch{}else try{T.setAttribute(k,"")}catch{}},Jr=function(k){let T=null,L=null;if(An)k="<remove></remove>"+k;else{const ye=fi(k,/^[\r\n\t ]+/);L=ye&&ye[0]}zt==="application/xhtml+xml"&&Bt===ut&&(k='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+k+"</body></html>");const ne=S?S.createHTML(k):k;if(Bt===ut)try{T=new m().parseFromString(ne,zt)}catch{}if(!T||!T.documentElement){T=M.createDocument(Bt,"template",null);try{T.documentElement.innerHTML=dn?C:ne}catch{}}const Re=T.body||T.documentElement;return k&&L&&Re.insertBefore(n.createTextNode(L),Re.childNodes[0]||null),Bt===ut?ze.call(T,Rt?"html":"body")[0]:Rt?T.documentElement:Re},pr=function(k){return se.call(k.ownerDocument||k,k,p.SHOW_ELEMENT|p.SHOW_COMMENT|p.SHOW_TEXT|p.SHOW_PROCESSING_INSTRUCTION|p.SHOW_CDATA_SECTION,null)},hr=function(k){return k instanceof b&&(typeof k.nodeName!="string"||typeof k.textContent!="string"||typeof k.removeChild!="function"||!(k.attributes instanceof h)||typeof k.removeAttribute!="function"||typeof k.setAttribute!="function"||typeof k.namespaceURI!="string"||typeof k.insertBefore!="function"||typeof k.hasChildNodes!="function")},Xr=function(k){return typeof u=="function"&&k instanceof u};function pt(O,k,T){ho(O,L=>{L.call(t,k,T,Gt)})}const Vr=function(k){let T=null;if(pt(Y.beforeSanitizeElements,k,null),hr(k))return rt(k),!0;const L=le(k.nodeName);if(pt(Y.uponSanitizeElement,k,{tagName:L,allowedTags:be}),an&&k.hasChildNodes()&&!Xr(k.firstElementChild)&&qe(/<[/\w!]/g,k.innerHTML)&&qe(/<[/\w!]/g,k.textContent)||k.nodeType===Sr.progressingInstruction||an&&k.nodeType===Sr.comment&&qe(/<[/\w]/g,k.data))return rt(k),!0;if(!(Pe.tagCheck instanceof Function&&Pe.tagCheck(L))&&(!be[L]||ke[L])){if(!ke[L]&&Kr(L)&&(J.tagNameCheck instanceof RegExp&&qe(J.tagNameCheck,L)||J.tagNameCheck instanceof Function&&J.tagNameCheck(L)))return!1;if(ar&&!Ze[L]){const ne=x(k)||k.parentNode,Re=R(k)||k.childNodes;if(Re&&ne){const ye=Re.length;for(let Me=ye-1;Me>=0;--Me){const ht=P(Re[Me],!0);ht.__removalCount=(k.__removalCount||0)+1,ne.insertBefore(ht,te(k))}}}return rt(k),!0}return k instanceof d&&!ri(k)||(L==="noscript"||L==="noembed"||L==="noframes")&&qe(/<\/no(script|embed|frames)/i,k.innerHTML)?(rt(k),!0):(De&&k.nodeType===Sr.text&&(T=k.textContent,ho([me,Ve,qt],ne=>{T=yr(T,ne," ")}),k.textContent!==T&&(vr(t.removed,{element:k.cloneNode()}),k.textContent=T)),pt(Y.afterSanitizeElements,k,null),!1)},Yr=function(k,T,L){if(Hr&&(T==="id"||T==="name")&&(L in n||L in Gr))return!1;if(!(we&&!sn[T]&&qe(Z,T))){if(!(ae&&qe(X,T))){if(!(Pe.attributeCheck instanceof Function&&Pe.attributeCheck(T,k))){if(!W[T]||sn[T]){if(!(Kr(k)&&(J.tagNameCheck instanceof RegExp&&qe(J.tagNameCheck,k)||J.tagNameCheck instanceof Function&&J.tagNameCheck(k))&&(J.attributeNameCheck instanceof RegExp&&qe(J.attributeNameCheck,T)||J.attributeNameCheck instanceof Function&&J.attributeNameCheck(T,k))||T==="is"&&J.allowCustomizedBuiltInElements&&(J.tagNameCheck instanceof RegExp&&qe(J.tagNameCheck,L)||J.tagNameCheck instanceof Function&&J.tagNameCheck(L))))return!1}else if(!lr[T]){if(!qe(nt,yr(L,Oe,""))){if(!((T==="src"||T==="xlink:href"||T==="href")&&k!=="script"&&ab(L,"data:")===0&&ce[k])){if(!(Pt&&!qe(Ie,yr(L,Oe,"")))){if(L)return!1}}}}}}}return!0},Kr=function(k){return k!=="annotation-xml"&&fi(k,_t)},fr=function(k){pt(Y.beforeSanitizeAttributes,k,null);const{attributes:T}=k;if(!T||hr(k))return;const L={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:W,forceKeepAttr:void 0};let ne=T.length;for(;ne--;){const Re=T[ne],{name:ye,namespaceURI:Me,value:ht}=Re,vt=le(ye),gr=ht;let Ae=ye==="value"?gr:cb(gr);if(L.attrName=vt,L.attrValue=Ae,L.keepAttr=!0,L.forceKeepAttr=void 0,pt(Y.uponSanitizeAttribute,k,L),Ae=L.attrValue,sr&&(vt==="id"||vt==="name")&&(ot(ye,k),Ae=Qo+Ae),an&&qe(/((--!?|])>)|<\/(style|title|textarea)/i,Ae)){ot(ye,k);continue}if(vt==="attributename"&&fi(Ae,"href")){ot(ye,k);continue}if(L.forceKeepAttr)continue;if(!L.keepAttr){ot(ye,k);continue}if(!ir&&qe(/\/>/i,Ae)){ot(ye,k);continue}De&&ho([me,Ve,qt],eo=>{Ae=yr(Ae,eo," ")});const Qr=le(k.nodeName);if(!Yr(Qr,vt,Ae)){ot(ye,k);continue}if(S&&typeof _=="object"&&typeof _.getAttributeType=="function"&&!Me)switch(_.getAttributeType(Qr,vt)){case"TrustedHTML":{Ae=S.createHTML(Ae);break}case"TrustedScriptURL":{Ae=S.createScriptURL(Ae);break}}if(Ae!==gr)try{Me?k.setAttributeNS(Me,ye,Ae):k.setAttribute(ye,Ae),hr(k)?rt(k):pa(t.removed)}catch{ot(ye,k)}}pt(Y.afterSanitizeAttributes,k,null)},It=function O(k){let T=null;const L=pr(k);for(pt(Y.beforeSanitizeShadowDOM,k,null);T=L.nextNode();)pt(Y.uponSanitizeShadowNode,T,null),Vr(T),fr(T),T.content instanceof s&&O(T.content);pt(Y.afterSanitizeShadowDOM,k,null)};return t.sanitize=function(O){let k=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},T=null,L=null,ne=null,Re=null;if(dn=!O,dn&&(O="<!-->"),typeof O!="string"&&!Xr(O))if(typeof O.toString=="function"){if(O=O.toString(),typeof O!="string")throw wr("dirty is not a string, aborting")}else throw wr("toString is not a function");if(!t.isSupported)return O;if(Lt||zn(k),t.removed=[],typeof O=="string"&&(un=!1),un){if(O.nodeName){const ht=le(O.nodeName);if(!be[ht]||ke[ht])throw wr("root node is forbidden and cannot be sanitized in-place")}}else if(O instanceof u)T=Jr("<!---->"),L=T.ownerDocument.importNode(O,!0),L.nodeType===Sr.element&&L.nodeName==="BODY"||L.nodeName==="HTML"?T=L:T.appendChild(L);else{if(!Ht&&!De&&!Rt&&O.indexOf("<")===-1)return S&&ln?S.createHTML(O):O;if(T=Jr(O),!T)return Ht?null:ln?C:""}T&&An&&rt(T.firstChild);const ye=pr(un?O:T);for(;ne=ye.nextNode();)Vr(ne),fr(ne),ne.content instanceof s&&It(ne.content);if(un)return O;if(Ht){if(cn)for(Re=ve.call(T.ownerDocument);T.firstChild;)Re.appendChild(T.firstChild);else Re=T;return(W.shadowroot||W.shadowrootmode)&&(Re=Xe.call(r,Re,!0)),Re}let Me=Rt?T.outerHTML:T.innerHTML;return Rt&&be["!doctype"]&&T.ownerDocument&&T.ownerDocument.doctype&&T.ownerDocument.doctype.name&&qe($c,T.ownerDocument.doctype.name)&&(Me="<!DOCTYPE "+T.ownerDocument.doctype.name+`>
1440
- `+Me),De&&ho([me,Ve,qt],ht=>{Me=yr(Me,ht," ")}),S&&ln?S.createHTML(Me):Me},t.setConfig=function(){let O=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};zn(O),Lt=!0},t.clearConfig=function(){Gt=null,Lt=!1},t.isValidAttribute=function(O,k,T){Gt||zn({});const L=le(O),ne=le(k);return Yr(L,ne,T)},t.addHook=function(O,k){typeof k=="function"&&vr(Y[O],k)},t.removeHook=function(O,k){if(k!==void 0){const T=ib(Y[O],k);return T===-1?void 0:sb(Y[O],T,1)[0]}return pa(Y[O])},t.removeHooks=function(O){Y[O]=[]},t.removeAllHooks=function(){Y=ka()},t}var xb=Nc();function Oc(e){const t=ie.parse(e,{gfm:!0,breaks:!0,async:!1});return xb.sanitize(t)}const Dc=1e3,Mc=32,_a=15e3,Sb=new Set(["completed","failed","cancelled"]),Tb=4e3;let I=null,Ct=null,Ne=null,Qi=null,Cr=null,jo=null,zi=!1,yo=null,zr=null,U={kind:"connecting"},Jn=[],Qn=null,pe=null,er=null,Ot=null,Ir=-1,Ge=null,Mt=!1,Dt=null,kn=new Set;function wo(){xo(),vc(),Ct&&clearInterval(Ct),Ct=null,Dt==null||Dt(),Dt=null,Ne==null||Ne.destroy(),Ne=null,Cr==null||Cr(),Cr=null,I&&jt(I),I==null||I.remove(),I=null,Qi=null,U={kind:"connecting"},Jn=[],Qn=null,pe=null,er=null,Ot=null,jo=null,Ir=-1,Ge=null,Mt=!1,kn=new Set}function es(e,t,n,r,o){I&&wo(),Qi=o??null,U={kind:"connecting"},Jn=[],Qn=null,Ir=-1,Ge=null,Mt=!1,kn=new Set,pe=e,er=n,Ot=t,jo=r,_c({taskId:e,backendUrl:n,title:r}),I=document.createElement("div"),I.className="ap-sdk-panel",I.setAttribute("data-ap-sdk","1"),I.setAttribute("role","dialog"),I.setAttribute("aria-modal","true"),I.setAttribute("aria-label","Automation in progress");const s=r.length>55?`${r.slice(0,52)}…`:r;I.innerHTML=`
1455
+ `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${St(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),o=ra(e);if(o===null)return r;e=o;let s='<a href="'+e+'"';return t&&(s+=' title="'+St(t)+'"'),s+=">"+r+"</a>",s}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let o=ra(e);if(o===null)return St(n);e=o;let s=`<img src="${e}" alt="${St(n)}"`;return t&&(s+=` title="${St(t)}"`),s+=">",s}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:St(e.text)}},Vi=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},yt=class Ti{constructor(t){ie(this,"options");ie(this,"renderer");ie(this,"textRenderer");this.options=t||An,this.options.renderer=this.options.renderer||new No,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Vi}static parse(t,n){return new Ti(n).parse(t)}static parseInline(t,n){return new Ti(n).parseInline(t)}parse(t){var r,o;this.renderer.parser=this;let n="";for(let s=0;s<t.length;s++){let a=t[s];if((o=(r=this.options.extensions)==null?void 0:r.renderers)!=null&&o[a.type]){let d=a,h=this.options.extensions.renderers[d.type].call({parser:this},d);if(h!==!1||!["space","hr","heading","code","table","blockquote","list","checkbox","html","def","paragraph","text"].includes(d.type)){n+=h||"";continue}}let u=a;switch(u.type){case"space":{n+=this.renderer.space(u);break}case"hr":{n+=this.renderer.hr(u);break}case"heading":{n+=this.renderer.heading(u);break}case"code":{n+=this.renderer.code(u);break}case"table":{n+=this.renderer.table(u);break}case"blockquote":{n+=this.renderer.blockquote(u);break}case"list":{n+=this.renderer.list(u);break}case"checkbox":{n+=this.renderer.checkbox(u);break}case"html":{n+=this.renderer.html(u);break}case"def":{n+=this.renderer.def(u);break}case"paragraph":{n+=this.renderer.paragraph(u);break}case"text":{n+=this.renderer.text(u);break}default:{let d='Token with "'+u.type+'" type was not found.';if(this.options.silent)return console.error(d),"";throw new Error(d)}}}return n}parseInline(t,n=this.renderer){var o,s;this.renderer.parser=this;let r="";for(let a=0;a<t.length;a++){let u=t[a];if((s=(o=this.options.extensions)==null?void 0:o.renderers)!=null&&s[u.type]){let h=this.options.extensions.renderers[u.type].call({parser:this},u);if(h!==!1||!["escape","html","link","image","checkbox","strong","em","codespan","br","del","text"].includes(u.type)){r+=h||"";continue}}let d=u;switch(d.type){case"escape":{r+=n.text(d);break}case"html":{r+=n.html(d);break}case"link":{r+=n.link(d);break}case"image":{r+=n.image(d);break}case"checkbox":{r+=n.checkbox(d);break}case"strong":{r+=n.strong(d);break}case"em":{r+=n.em(d);break}case"codespan":{r+=n.codespan(d);break}case"br":{r+=n.br(d);break}case"del":{r+=n.del(d);break}case"text":{r+=n.text(d);break}default:{let h='Token with "'+d.type+'" type was not found.';if(this.options.silent)return console.error(h),"";throw new Error(h)}}}return r}},fo,Ar=(fo=class{constructor(e){ie(this,"options");ie(this,"block");this.options=e||An}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?vt.lex:vt.lexInline}provideParser(e=this.block){return e?yt.parse:yt.parseInline}},ie(fo,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),ie(fo,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),fo),Vm=class{constructor(...e){ie(this,"defaults",Hi());ie(this,"options",this.setOptions);ie(this,"parse",this.parseMarkdown(!0));ie(this,"parseInline",this.parseMarkdown(!1));ie(this,"Parser",yt);ie(this,"Renderer",No);ie(this,"TextRenderer",Vi);ie(this,"Lexer",vt);ie(this,"Tokenizer",$o);ie(this,"Hooks",Ar);this.use(...e)}walkTokens(e,t){var r,o;let n=[];for(let s of e)switch(n=n.concat(t.call(this,s)),s.type){case"table":{let a=s;for(let u of a.header)n=n.concat(this.walkTokens(u.tokens,t));for(let u of a.rows)for(let d of u)n=n.concat(this.walkTokens(d.tokens,t));break}case"list":{let a=s;n=n.concat(this.walkTokens(a.items,t));break}default:{let a=s;(o=(r=this.defaults.extensions)==null?void 0:r.childTokens)!=null&&o[a.type]?this.defaults.extensions.childTokens[a.type].forEach(u=>{let d=a[u].flat(1/0);n=n.concat(this.walkTokens(d,t))}):a.tokens&&(n=n.concat(this.walkTokens(a.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{let r={...n};if(r.async=this.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(o=>{if(!o.name)throw new Error("extension name required");if("renderer"in o){let s=t.renderers[o.name];s?t.renderers[o.name]=function(...a){let u=o.renderer.apply(this,a);return u===!1&&(u=s.apply(this,a)),u}:t.renderers[o.name]=o.renderer}if("tokenizer"in o){if(!o.level||o.level!=="block"&&o.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let s=t[o.level];s?s.unshift(o.tokenizer):t[o.level]=[o.tokenizer],o.start&&(o.level==="block"?t.startBlock?t.startBlock.push(o.start):t.startBlock=[o.start]:o.level==="inline"&&(t.startInline?t.startInline.push(o.start):t.startInline=[o.start]))}"childTokens"in o&&o.childTokens&&(t.childTokens[o.name]=o.childTokens)}),r.extensions=t),n.renderer){let o=this.defaults.renderer||new No(this.defaults);for(let s in n.renderer){if(!(s in o))throw new Error(`renderer '${s}' does not exist`);if(["options","parser"].includes(s))continue;let a=s,u=n.renderer[a],d=o[a];o[a]=(...h)=>{let p=u.apply(o,h);return p===!1&&(p=d.apply(o,h)),p||""}}r.renderer=o}if(n.tokenizer){let o=this.defaults.tokenizer||new $o(this.defaults);for(let s in n.tokenizer){if(!(s in o))throw new Error(`tokenizer '${s}' does not exist`);if(["options","rules","lexer"].includes(s))continue;let a=s,u=n.tokenizer[a],d=o[a];o[a]=(...h)=>{let p=u.apply(o,h);return p===!1&&(p=d.apply(o,h)),p}}r.tokenizer=o}if(n.hooks){let o=this.defaults.hooks||new Ar;for(let s in n.hooks){if(!(s in o))throw new Error(`hook '${s}' does not exist`);if(["options","block"].includes(s))continue;let a=s,u=n.hooks[a],d=o[a];Ar.passThroughHooks.has(s)?o[a]=h=>{if(this.defaults.async&&Ar.passThroughHooksRespectAsync.has(s))return(async()=>{let b=await u.call(o,h);return d.call(o,b)})();let p=u.call(o,h);return d.call(o,p)}:o[a]=(...h)=>{if(this.defaults.async)return(async()=>{let b=await u.apply(o,h);return b===!1&&(b=await d.apply(o,h)),b})();let p=u.apply(o,h);return p===!1&&(p=d.apply(o,h)),p}}r.hooks=o}if(n.walkTokens){let o=this.defaults.walkTokens,s=n.walkTokens;r.walkTokens=function(a){let u=[];return u.push(s.call(this,a)),o&&(u=u.concat(o.call(this,a))),u}}this.defaults={...this.defaults,...r}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return vt.lex(e,t??this.defaults)}parser(e,t){return yt.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},o={...this.defaults,...r},s=this.onError(!!o.silent,!!o.async);if(this.defaults.async===!0&&r.async===!1)return s(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||t===null)return s(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return s(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(o.hooks&&(o.hooks.options=o,o.hooks.block=e),o.async)return(async()=>{let a=o.hooks?await o.hooks.preprocess(t):t,u=await(o.hooks?await o.hooks.provideLexer(e):e?vt.lex:vt.lexInline)(a,o),d=o.hooks?await o.hooks.processAllTokens(u):u;o.walkTokens&&await Promise.all(this.walkTokens(d,o.walkTokens));let h=await(o.hooks?await o.hooks.provideParser(e):e?yt.parse:yt.parseInline)(d,o);return o.hooks?await o.hooks.postprocess(h):h})().catch(s);try{o.hooks&&(t=o.hooks.preprocess(t));let a=(o.hooks?o.hooks.provideLexer(e):e?vt.lex:vt.lexInline)(t,o);o.hooks&&(a=o.hooks.processAllTokens(a)),o.walkTokens&&this.walkTokens(a,o.walkTokens);let u=(o.hooks?o.hooks.provideParser(e):e?yt.parse:yt.parseInline)(a,o);return o.hooks&&(u=o.hooks.postprocess(u)),u}catch(a){return s(a)}}}onError(e,t){return n=>{if(n.message+=`
1456
+ Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error occurred:</p><pre>"+St(n.message+"",!0)+"</pre>";return t?Promise.resolve(r):r}if(t)return Promise.reject(n);throw n}}},wn=new Vm;function ae(e,t){return wn.parse(e,t)}ae.options=ae.setOptions=function(e){return wn.setOptions(e),ae.defaults=wn.defaults,kc(ae.defaults),ae};ae.getDefaults=Hi;ae.defaults=An;function Ym(...e){return wn.use(...e),ae.defaults=wn.defaults,kc(ae.defaults),ae}ae.use=Ym;ae.walkTokens=function(e,t){return wn.walkTokens(e,t)};ae.parseInline=wn.parseInline;ae.Parser=yt;ae.parser=yt.parse;ae.Renderer=No;ae.TextRenderer=Vi;ae.Lexer=vt;ae.lexer=vt.lex;ae.Tokenizer=$o;ae.Hooks=Ar;ae.parse=ae;ae.options;ae.setOptions;ae.walkTokens;ae.parseInline;yt.parse;vt.lex;/*! @license DOMPurify 3.3.1 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.1/LICENSE */const{entries:Cc,setPrototypeOf:aa,isFrozen:Km,getPrototypeOf:Qm,getOwnPropertyDescriptor:eb}=Object;let{freeze:Xe,seal:ut,create:Ei}=Object,{apply:Ai,construct:Ci}=typeof Reflect<"u"&&Reflect;Xe||(Xe=function(t){return t});ut||(ut=function(t){return t});Ai||(Ai=function(t,n){for(var r=arguments.length,o=new Array(r>2?r-2:0),s=2;s<r;s++)o[s-2]=arguments[s];return t.apply(n,o)});Ci||(Ci=function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return new t(...r)});const lo=Ve(Array.prototype.forEach),tb=Ve(Array.prototype.lastIndexOf),ca=Ve(Array.prototype.pop),_r=Ve(Array.prototype.push),nb=Ve(Array.prototype.splice),bo=Ve(String.prototype.toLowerCase),ui=Ve(String.prototype.toString),di=Ve(String.prototype.match),vr=Ve(String.prototype.replace),rb=Ve(String.prototype.indexOf),ob=Ve(String.prototype.trim),kt=Ve(Object.prototype.hasOwnProperty),Fe=Ve(RegExp.prototype.test),yr=ib(TypeError);function Ve(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return Ai(e,t,r)}}function ib(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return Ci(e,n)}}function B(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:bo;aa&&aa(e,null);let r=t.length;for(;r--;){let o=t[r];if(typeof o=="string"){const s=n(o);s!==o&&(Km(t)||(t[r]=s),o=s)}e[o]=!0}return e}function sb(e){for(let t=0;t<e.length;t++)kt(e,t)||(e[t]=null);return e}function Tt(e){const t=Ei(null);for(const[n,r]of Cc(e))kt(e,n)&&(Array.isArray(r)?t[n]=sb(r):r&&typeof r=="object"&&r.constructor===Object?t[n]=Tt(r):t[n]=r);return t}function wr(e,t){for(;e!==null;){const r=eb(e,t);if(r){if(r.get)return Ve(r.get);if(typeof r.value=="function")return Ve(r.value)}e=Qm(e)}function n(){return null}return n}const la=Xe(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),pi=Xe(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),hi=Xe(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),ab=Xe(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),fi=Xe(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),cb=Xe(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),ua=Xe(["#text"]),da=Xe(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),gi=Xe(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),pa=Xe(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),uo=Xe(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),lb=ut(/\{\{[\w\W]*|[\w\W]*\}\}/gm),ub=ut(/<%[\w\W]*|[\w\W]*%>/gm),db=ut(/\$\{[\w\W]*/gm),pb=ut(/^data-[\-\w.\u00B7-\uFFFF]+$/),hb=ut(/^aria-[\-\w]+$/),Pc=ut(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),fb=ut(/^(?:\w+script|data):/i),gb=ut(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Rc=ut(/^html$/i),mb=ut(/^[a-z][.\w]*(-[.\w]+)+$/i);var ha=Object.freeze({__proto__:null,ARIA_ATTR:hb,ATTR_WHITESPACE:gb,CUSTOM_ELEMENT:mb,DATA_ATTR:pb,DOCTYPE_NAME:Rc,ERB_EXPR:ub,IS_ALLOWED_URI:Pc,IS_SCRIPT_OR_DATA:fb,MUSTACHE_EXPR:lb,TMPLIT_EXPR:db});const xr={element:1,text:3,progressingInstruction:7,comment:8,document:9},bb=function(){return typeof window>"u"?null:window},kb=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let r=null;const o="data-tt-policy-suffix";n&&n.hasAttribute(o)&&(r=n.getAttribute(o));const s="dompurify"+(r?"#"+r:"");try{return t.createPolicy(s,{createHTML(a){return a},createScriptURL(a){return a}})}catch{return console.warn("TrustedTypes policy "+s+" could not be created."),null}},fa=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Lc(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:bb();const t=N=>Lc(N);if(t.version="3.3.1",t.removed=[],!e||!e.document||e.document.nodeType!==xr.document||!e.Element)return t.isSupported=!1,t;let{document:n}=e;const r=n,o=r.currentScript,{DocumentFragment:s,HTMLTemplateElement:a,Node:u,Element:d,NodeFilter:h,NamedNodeMap:p=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:b,DOMParser:m,trustedTypes:_}=e,w=d.prototype,C=wr(w,"cloneNode"),M=wr(w,"remove"),W=wr(w,"nextSibling"),P=wr(w,"childNodes"),T=wr(w,"parentNode");if(typeof a=="function"){const N=n.createElement("template");N.content&&N.content.ownerDocument&&(n=N.content.ownerDocument)}let x,R="";const{implementation:D,createNodeIterator:de,createDocumentFragment:_e,getElementsByTagName:Ee}=n,{importNode:qe}=r;let V=fa();t.isSupported=typeof Cc=="function"&&typeof T=="function"&&D&&D.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:Ae,ERB_EXPR:Me,TMPLIT_EXPR:pt,DATA_ATTR:Bt,ARIA_ATTR:tt,IS_SCRIPT_OR_DATA:zt,ATTR_WHITESPACE:j,CUSTOM_ELEMENT:Y}=ha;let{IS_ALLOWED_URI:$e}=ha,J=null;const ht=B({},[...la,...pi,...hi,...fi,...ua]);let ne=null;const an=B({},[...da,...gi,...pa,...uo]);let ce=Object.seal(Ei(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),re=null,Ce=null;const Pe=Object.seal(Ei(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let ee=!0,we=!0,Ye=!1,rt=!0,Re=!1,ot=!0,It=!1,$t=!1,Cn=!1,Gt=!1,cn=!1,ln=!1,jr=!0,ir=!1;const Xo="user-content-";let sr=!0,un=!1,Wt={},He=null;const ar=B({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let le=null;const Zr=B({},["audio","video","img","source","image","track"]);let cr=null;const qr=B({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Pn="http://www.w3.org/1998/Math/MathML",Rn="http://www.w3.org/2000/svg",ft="http://www.w3.org/1999/xhtml";let Jt=ft,dn=!1,pn=null;const Vo=B({},[Pn,Rn,ft],ui);let Ln=B({},["mi","mo","mn","ms","mtext"]),zn=B({},["annotation-xml"]);const Yo=B({},["title","style","font","a","script"]);let Nt=null;const gt=["application/xhtml+xml","text/html"],Ko="text/html";let ue=null,Xt=null;const Hr=n.createElement("form"),lr=function(k){return k instanceof RegExp||k instanceof Function},In=function(){let k=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Xt&&Xt===k)){if((!k||typeof k!="object")&&(k={}),k=Tt(k),Nt=gt.indexOf(k.PARSER_MEDIA_TYPE)===-1?Ko:k.PARSER_MEDIA_TYPE,ue=Nt==="application/xhtml+xml"?ui:bo,J=kt(k,"ALLOWED_TAGS")?B({},k.ALLOWED_TAGS,ue):ht,ne=kt(k,"ALLOWED_ATTR")?B({},k.ALLOWED_ATTR,ue):an,pn=kt(k,"ALLOWED_NAMESPACES")?B({},k.ALLOWED_NAMESPACES,ui):Vo,cr=kt(k,"ADD_URI_SAFE_ATTR")?B(Tt(qr),k.ADD_URI_SAFE_ATTR,ue):qr,le=kt(k,"ADD_DATA_URI_TAGS")?B(Tt(Zr),k.ADD_DATA_URI_TAGS,ue):Zr,He=kt(k,"FORBID_CONTENTS")?B({},k.FORBID_CONTENTS,ue):ar,re=kt(k,"FORBID_TAGS")?B({},k.FORBID_TAGS,ue):Tt({}),Ce=kt(k,"FORBID_ATTR")?B({},k.FORBID_ATTR,ue):Tt({}),Wt=kt(k,"USE_PROFILES")?k.USE_PROFILES:!1,ee=k.ALLOW_ARIA_ATTR!==!1,we=k.ALLOW_DATA_ATTR!==!1,Ye=k.ALLOW_UNKNOWN_PROTOCOLS||!1,rt=k.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Re=k.SAFE_FOR_TEMPLATES||!1,ot=k.SAFE_FOR_XML!==!1,It=k.WHOLE_DOCUMENT||!1,Gt=k.RETURN_DOM||!1,cn=k.RETURN_DOM_FRAGMENT||!1,ln=k.RETURN_TRUSTED_TYPE||!1,Cn=k.FORCE_BODY||!1,jr=k.SANITIZE_DOM!==!1,ir=k.SANITIZE_NAMED_PROPS||!1,sr=k.KEEP_CONTENT!==!1,un=k.IN_PLACE||!1,$e=k.ALLOWED_URI_REGEXP||Pc,Jt=k.NAMESPACE||ft,Ln=k.MATHML_TEXT_INTEGRATION_POINTS||Ln,zn=k.HTML_INTEGRATION_POINTS||zn,ce=k.CUSTOM_ELEMENT_HANDLING||{},k.CUSTOM_ELEMENT_HANDLING&&lr(k.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(ce.tagNameCheck=k.CUSTOM_ELEMENT_HANDLING.tagNameCheck),k.CUSTOM_ELEMENT_HANDLING&&lr(k.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(ce.attributeNameCheck=k.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),k.CUSTOM_ELEMENT_HANDLING&&typeof k.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(ce.allowCustomizedBuiltInElements=k.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Re&&(we=!1),cn&&(Gt=!0),Wt&&(J=B({},ua),ne=[],Wt.html===!0&&(B(J,la),B(ne,da)),Wt.svg===!0&&(B(J,pi),B(ne,gi),B(ne,uo)),Wt.svgFilters===!0&&(B(J,hi),B(ne,gi),B(ne,uo)),Wt.mathMl===!0&&(B(J,fi),B(ne,pa),B(ne,uo))),k.ADD_TAGS&&(typeof k.ADD_TAGS=="function"?Pe.tagCheck=k.ADD_TAGS:(J===ht&&(J=Tt(J)),B(J,k.ADD_TAGS,ue))),k.ADD_ATTR&&(typeof k.ADD_ATTR=="function"?Pe.attributeCheck=k.ADD_ATTR:(ne===an&&(ne=Tt(ne)),B(ne,k.ADD_ATTR,ue))),k.ADD_URI_SAFE_ATTR&&B(cr,k.ADD_URI_SAFE_ATTR,ue),k.FORBID_CONTENTS&&(He===ar&&(He=Tt(He)),B(He,k.FORBID_CONTENTS,ue)),k.ADD_FORBID_CONTENTS&&(He===ar&&(He=Tt(He)),B(He,k.ADD_FORBID_CONTENTS,ue)),sr&&(J["#text"]=!0),It&&B(J,["html","head","body"]),J.table&&(B(J,["tbody"]),delete re.tbody),k.TRUSTED_TYPES_POLICY){if(typeof k.TRUSTED_TYPES_POLICY.createHTML!="function")throw yr('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof k.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw yr('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');x=k.TRUSTED_TYPES_POLICY,R=x.createHTML("")}else x===void 0&&(x=kb(_,o)),x!==null&&typeof R=="string"&&(R=x.createHTML(""));Xe&&Xe(k),Xt=k}},ur=B({},[...pi,...hi,...ab]),Fr=B({},[...fi,...cb]),Qo=function(k){let S=T(k);(!S||!S.tagName)&&(S={namespaceURI:Jt,tagName:"template"});const L=bo(k.tagName),oe=bo(S.tagName);return pn[k.namespaceURI]?k.namespaceURI===Rn?S.namespaceURI===ft?L==="svg":S.namespaceURI===Pn?L==="svg"&&(oe==="annotation-xml"||Ln[oe]):!!ur[L]:k.namespaceURI===Pn?S.namespaceURI===ft?L==="math":S.namespaceURI===Rn?L==="math"&&zn[oe]:!!Fr[L]:k.namespaceURI===ft?S.namespaceURI===Rn&&!zn[oe]||S.namespaceURI===Pn&&!Ln[oe]?!1:!Fr[L]&&(Yo[L]||!ur[L]):!!(Nt==="application/xhtml+xml"&&pn[k.namespaceURI]):!1},it=function(k){_r(t.removed,{element:k});try{T(k).removeChild(k)}catch{M(k)}},st=function(k,S){try{_r(t.removed,{attribute:S.getAttributeNode(k),from:S})}catch{_r(t.removed,{attribute:null,from:S})}if(S.removeAttribute(k),k==="is")if(Gt||cn)try{it(S)}catch{}else try{S.setAttribute(k,"")}catch{}},Br=function(k){let S=null,L=null;if(Cn)k="<remove></remove>"+k;else{const ve=di(k,/^[\r\n\t ]+/);L=ve&&ve[0]}Nt==="application/xhtml+xml"&&Jt===ft&&(k='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+k+"</body></html>");const oe=x?x.createHTML(k):k;if(Jt===ft)try{S=new m().parseFromString(oe,Nt)}catch{}if(!S||!S.documentElement){S=D.createDocument(Jt,"template",null);try{S.documentElement.innerHTML=dn?R:oe}catch{}}const Ie=S.body||S.documentElement;return k&&L&&Ie.insertBefore(n.createTextNode(L),Ie.childNodes[0]||null),Jt===ft?Ee.call(S,It?"html":"body")[0]:It?S.documentElement:Ie},dr=function(k){return de.call(k.ownerDocument||k,k,h.SHOW_ELEMENT|h.SHOW_COMMENT|h.SHOW_TEXT|h.SHOW_PROCESSING_INSTRUCTION|h.SHOW_CDATA_SECTION,null)},pr=function(k){return k instanceof b&&(typeof k.nodeName!="string"||typeof k.textContent!="string"||typeof k.removeChild!="function"||!(k.attributes instanceof p)||typeof k.removeAttribute!="function"||typeof k.setAttribute!="function"||typeof k.namespaceURI!="string"||typeof k.insertBefore!="function"||typeof k.hasChildNodes!="function")},Gr=function(k){return typeof u=="function"&&k instanceof u};function mt(N,k,S){lo(N,L=>{L.call(t,k,S,Xt)})}const Wr=function(k){let S=null;if(mt(V.beforeSanitizeElements,k,null),pr(k))return it(k),!0;const L=ue(k.nodeName);if(mt(V.uponSanitizeElement,k,{tagName:L,allowedTags:J}),ot&&k.hasChildNodes()&&!Gr(k.firstElementChild)&&Fe(/<[/\w!]/g,k.innerHTML)&&Fe(/<[/\w!]/g,k.textContent)||k.nodeType===xr.progressingInstruction||ot&&k.nodeType===xr.comment&&Fe(/<[/\w]/g,k.data))return it(k),!0;if(!(Pe.tagCheck instanceof Function&&Pe.tagCheck(L))&&(!J[L]||re[L])){if(!re[L]&&Xr(L)&&(ce.tagNameCheck instanceof RegExp&&Fe(ce.tagNameCheck,L)||ce.tagNameCheck instanceof Function&&ce.tagNameCheck(L)))return!1;if(sr&&!He[L]){const oe=T(k)||k.parentNode,Ie=P(k)||k.childNodes;if(Ie&&oe){const ve=Ie.length;for(let Ue=ve-1;Ue>=0;--Ue){const bt=C(Ie[Ue],!0);bt.__removalCount=(k.__removalCount||0)+1,oe.insertBefore(bt,W(k))}}}return it(k),!0}return k instanceof d&&!Qo(k)||(L==="noscript"||L==="noembed"||L==="noframes")&&Fe(/<\/no(script|embed|frames)/i,k.innerHTML)?(it(k),!0):(Re&&k.nodeType===xr.text&&(S=k.textContent,lo([Ae,Me,pt],oe=>{S=vr(S,oe," ")}),k.textContent!==S&&(_r(t.removed,{element:k.cloneNode()}),k.textContent=S)),mt(V.afterSanitizeElements,k,null),!1)},Jr=function(k,S,L){if(jr&&(S==="id"||S==="name")&&(L in n||L in Hr))return!1;if(!(we&&!Ce[S]&&Fe(Bt,S))){if(!(ee&&Fe(tt,S))){if(!(Pe.attributeCheck instanceof Function&&Pe.attributeCheck(S,k))){if(!ne[S]||Ce[S]){if(!(Xr(k)&&(ce.tagNameCheck instanceof RegExp&&Fe(ce.tagNameCheck,k)||ce.tagNameCheck instanceof Function&&ce.tagNameCheck(k))&&(ce.attributeNameCheck instanceof RegExp&&Fe(ce.attributeNameCheck,S)||ce.attributeNameCheck instanceof Function&&ce.attributeNameCheck(S,k))||S==="is"&&ce.allowCustomizedBuiltInElements&&(ce.tagNameCheck instanceof RegExp&&Fe(ce.tagNameCheck,L)||ce.tagNameCheck instanceof Function&&ce.tagNameCheck(L))))return!1}else if(!cr[S]){if(!Fe($e,vr(L,j,""))){if(!((S==="src"||S==="xlink:href"||S==="href")&&k!=="script"&&rb(L,"data:")===0&&le[k])){if(!(Ye&&!Fe(zt,vr(L,j,"")))){if(L)return!1}}}}}}}return!0},Xr=function(k){return k!=="annotation-xml"&&di(k,Y)},hr=function(k){mt(V.beforeSanitizeAttributes,k,null);const{attributes:S}=k;if(!S||pr(k))return;const L={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:ne,forceKeepAttr:void 0};let oe=S.length;for(;oe--;){const Ie=S[oe],{name:ve,namespaceURI:Ue,value:bt}=Ie,xt=ue(ve),fr=bt;let Le=ve==="value"?fr:ob(fr);if(L.attrName=xt,L.attrValue=Le,L.keepAttr=!0,L.forceKeepAttr=void 0,mt(V.uponSanitizeAttribute,k,L),Le=L.attrValue,ir&&(xt==="id"||xt==="name")&&(st(ve,k),Le=Xo+Le),ot&&Fe(/((--!?|])>)|<\/(style|title|textarea)/i,Le)){st(ve,k);continue}if(xt==="attributename"&&di(Le,"href")){st(ve,k);continue}if(L.forceKeepAttr)continue;if(!L.keepAttr){st(ve,k);continue}if(!rt&&Fe(/\/>/i,Le)){st(ve,k);continue}Re&&lo([Ae,Me,pt],Yr=>{Le=vr(Le,Yr," ")});const Vr=ue(k.nodeName);if(!Jr(Vr,xt,Le)){st(ve,k);continue}if(x&&typeof _=="object"&&typeof _.getAttributeType=="function"&&!Ue)switch(_.getAttributeType(Vr,xt)){case"TrustedHTML":{Le=x.createHTML(Le);break}case"TrustedScriptURL":{Le=x.createScriptURL(Le);break}}if(Le!==fr)try{Ue?k.setAttributeNS(Ue,ve,Le):k.setAttribute(ve,Le),pr(k)?it(k):ca(t.removed)}catch{st(ve,k)}}mt(V.afterSanitizeAttributes,k,null)},Ot=function N(k){let S=null;const L=dr(k);for(mt(V.beforeSanitizeShadowDOM,k,null);S=L.nextNode();)mt(V.uponSanitizeShadowNode,S,null),Wr(S),hr(S),S.content instanceof s&&N(S.content);mt(V.afterSanitizeShadowDOM,k,null)};return t.sanitize=function(N){let k=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},S=null,L=null,oe=null,Ie=null;if(dn=!N,dn&&(N="<!-->"),typeof N!="string"&&!Gr(N))if(typeof N.toString=="function"){if(N=N.toString(),typeof N!="string")throw yr("dirty is not a string, aborting")}else throw yr("toString is not a function");if(!t.isSupported)return N;if($t||In(k),t.removed=[],typeof N=="string"&&(un=!1),un){if(N.nodeName){const bt=ue(N.nodeName);if(!J[bt]||re[bt])throw yr("root node is forbidden and cannot be sanitized in-place")}}else if(N instanceof u)S=Br("<!---->"),L=S.ownerDocument.importNode(N,!0),L.nodeType===xr.element&&L.nodeName==="BODY"||L.nodeName==="HTML"?S=L:S.appendChild(L);else{if(!Gt&&!Re&&!It&&N.indexOf("<")===-1)return x&&ln?x.createHTML(N):N;if(S=Br(N),!S)return Gt?null:ln?R:""}S&&Cn&&it(S.firstChild);const ve=dr(un?N:S);for(;oe=ve.nextNode();)Wr(oe),hr(oe),oe.content instanceof s&&Ot(oe.content);if(un)return N;if(Gt){if(cn)for(Ie=_e.call(S.ownerDocument);S.firstChild;)Ie.appendChild(S.firstChild);else Ie=S;return(ne.shadowroot||ne.shadowrootmode)&&(Ie=qe.call(r,Ie,!0)),Ie}let Ue=It?S.outerHTML:S.innerHTML;return It&&J["!doctype"]&&S.ownerDocument&&S.ownerDocument.doctype&&S.ownerDocument.doctype.name&&Fe(Rc,S.ownerDocument.doctype.name)&&(Ue="<!DOCTYPE "+S.ownerDocument.doctype.name+`>
1457
+ `+Ue),Re&&lo([Ae,Me,pt],bt=>{Ue=vr(Ue,bt," ")}),x&&ln?x.createHTML(Ue):Ue},t.setConfig=function(){let N=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};In(N),$t=!0},t.clearConfig=function(){Xt=null,$t=!1},t.isValidAttribute=function(N,k,S){Xt||In({});const L=ue(N),oe=ue(k);return Jr(L,oe,S)},t.addHook=function(N,k){typeof k=="function"&&_r(V[N],k)},t.removeHook=function(N,k){if(k!==void 0){const S=tb(V[N],k);return S===-1?void 0:nb(V[N],S,1)[0]}return ca(V[N])},t.removeHooks=function(N){V[N]=[]},t.removeAllHooks=function(){V=fa()},t}var _b=Lc();function zc(e){const t=ae.parse(e,{gfm:!0,breaks:!0,async:!1});return _b.sanitize(t)}const Ic=1e3,$c=32,ga=15e3,vb=new Set(["completed","failed","cancelled"]),yb=4e3;let I=null,Lt=null,De=null,Yi=null,Oo=null,Pi=!1,ko=null,Pr=null,U={kind:"connecting"},Jn=[],Qn=null,fe=null,er=null,Ut=null,Rr=-1,Je=null,Zt=!1,jt=null,kn=new Set;function Ri(){_o(),mc(),Lt&&clearInterval(Lt),Lt=null,jt==null||jt(),jt=null,De==null||De.destroy(),De=null,I&&Ht(I),I==null||I.remove(),I=null,Yi=null,U={kind:"connecting"},Jn=[],Qn=null,fe=null,er=null,Ut=null,Oo=null,Rr=-1,Je=null,Zt=!1,kn=new Set}function Ki(e,t,n,r,o){I&&Ri(),Yi=o??null,U={kind:"connecting"},Jn=[],Qn=null,Rr=-1,Je=null,Zt=!1,kn=new Set,fe=e,er=n,Ut=t,Oo=r,gc({taskId:e,backendUrl:n,title:r}),I=document.createElement("div"),I.className="ap-sdk-panel",I.setAttribute("data-ap-sdk","1"),I.setAttribute("role","dialog"),I.setAttribute("aria-modal","true"),I.setAttribute("aria-label","Automation in progress");const s=r.length>55?`${r.slice(0,52)}…`:r;I.innerHTML=`
1441
1458
  <div class="ap-sdk-panel__header">
1442
1459
  <span class="ap-sdk-panel__title">
1443
1460
  <span class="ap-sdk-panel__logo">AP</span>
@@ -1450,7 +1467,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error
1450
1467
  <div class="ap-sdk-runner__meta">
1451
1468
  <div class="ap-sdk-runner__meta-row">
1452
1469
  <span class="ap-sdk-list-item__badge ap-sdk-list-item__badge--automate">Automate</span>
1453
- <span class="ap-sdk-runner__title" title="${Db(r)}">${ns(s)}</span>
1470
+ <span class="ap-sdk-runner__title" title="${Ib(r)}">${es(s)}</span>
1454
1471
  </div>
1455
1472
  <div class="ap-sdk-runner__meta-row ap-sdk-runner__meta-row--controls">
1456
1473
  <span class="ap-sdk-runner__counter" data-ap-runner-counter>0 actions</span>
@@ -1476,17 +1493,17 @@ Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error
1476
1493
  </div>
1477
1494
  <div class="ap-sdk-runner__hint" data-ap-runner-hint>Closing keeps the task running — resume anytime from My Captures.</div>
1478
1495
  <div class="ap-sdk-panel__status" data-ap-runner-summary style="display:none"></div>
1479
- `,I.addEventListener("wheel",u=>{u.stopPropagation()},{passive:!0}),I.addEventListener("touchmove",u=>{u.stopPropagation()},{passive:!0}),document.body.appendChild(I),Ne=$i(),Ut(I),Fi(I,Hi),I.querySelector("[data-ap-close]").addEventListener("click",()=>{wo(),o==null||o()}),I.querySelector("[data-ap-runner-chat-form]").addEventListener("submit",u=>{u.preventDefault(),Cb(t,e)}),I.querySelector("[data-ap-runner-cancel]").addEventListener("click",u=>{u.stopPropagation();const d=u.currentTarget;if(!zi){zi=!0,d.textContent="Cancel",yo=setTimeout(xo,Tb),zr=p=>{p.target!==d&&xo()},document.addEventListener("click",zr,!0);return}xo(),Eb(t,e)});const c=u=>{u.key==="Escape"&&(wo(),o==null||o())};document.addEventListener("keydown",c),Cr=()=>document.removeEventListener("keydown",c),ts(),Uc(e,t)}function Uc(e,t){const n=async u=>{if(pe!==e||!I||U.kind!=="idle"&&U.kind!=="connecting"||kn.has(u.commandId))return;kn.add(u.commandId);const d={id:u.commandId,taskId:u.taskId,action:u.action,selector:u.selector,value:u.value,description:u.description,status:"pending",createdAt:new Date().toISOString()};bn({kind:"executing",command:d,actionsRun:U.kind==="idle"?U.actionsRun:0}),await va(d,t,e)},r=u=>{if(!(pe!==e||!I)&&Sb.has(u)){if(U.kind==="executing")bn({kind:"finishing",status:u,actionsRun:U.actionsRun});else if(U.kind==="connecting"||U.kind==="idle"){const d=U.kind==="idle"?U.actionsRun:0;bn({kind:"finished",status:u,actionsRun:d})}}},o=u=>{pe!==e||!I||(u.outputChunk&&ya([u.outputChunk]),r(u.status))},s=async()=>{if(!(pe!==e||!I))try{const u=await Oo(t,e);pe===e&&I&&(Ge=u[0]??null,wn())}catch{}},c=async()=>{try{const[u,d,p,h]=await Promise.all([gc(t,e),jg(t,e),Oo(t,e),Mg(t,e)]);if(pe!==e||!I)return;ya(d),Ge=p[0]??null,wn(),r(u.status),h&&h.status==="pending"&&(U.kind==="idle"||U.kind==="connecting")&&!kn.has(h.id)?(kn.add(h.id),bn({kind:"executing",command:h,actionsRun:U.kind==="idle"?U.actionsRun:0}),await va(h,t,e)):U.kind==="connecting"&&bn({kind:"idle",actionsRun:0})}catch{}};c(),Qg(t,e,{onStatusUpdate:o,onInteractionCreated:s,onInteractionAnswered:s,onBrowserCommandCreated:n,onReconnect:()=>{c()}}).then(u=>{if(pe!==e||U.kind==="finished"){u();return}Dt=u})}function bn(e){U=e,U.kind==="idle"&&Qn===null&&(Qn=Date.now(),Zo(),Ct=setInterval(Zo,Dc)),U.kind==="finished"&&(Ct&&(clearInterval(Ct),Ct=null),Dt==null||Dt(),Dt=null,Ne==null||Ne.hide(),vc()),ts()}function xo(){zi=!1,yo&&(clearTimeout(yo),yo=null),zr&&(document.removeEventListener("click",zr,!0),zr=null);const e=I==null?void 0:I.querySelector("[data-ap-runner-cancel]");e&&(e.textContent="Cancel task")}async function Eb(e,t){if(pe!==t||!I)return;const n=I.querySelector("[data-ap-runner-cancel]");n&&(n.disabled=!0);try{await qg(e,t)}catch{n&&(n.disabled=!1)}}function jc(){if(!pe||!Ot||!er||!jo)return;const e=pe,t=Ot;_c({taskId:e,backendUrl:er,title:jo}),Ct&&clearInterval(Ct),Zo(),Ct=setInterval(Zo,Dc);const n=U.kind==="finished"?U.actionsRun:0;kn=new Set,U={kind:"idle",actionsRun:n},ts(),Uc(e,t)}function ts(){if(!I)return;const e=I.querySelector("[data-ap-runner-status]"),t=I.querySelector("[data-ap-runner-counter]"),n=I.querySelector("[data-ap-runner-log]"),r=I.querySelector("[data-ap-runner-hint]");if(!e||!t||!n||!r)return;const o="actionsRun"in U?U.actionsRun:0;t.textContent=`${o} action${o===1?"":"s"}`,U.kind==="finished"?(e.textContent=U.status.replace(/_/g," "),e.className=`ap-sdk-status-badge ap-sdk-status-badge--${U.status.replace(/_/g,"-")}`,r.style.display="none",Nb(U.status)):(e.textContent="running",e.className="ap-sdk-status-badge ap-sdk-status-badge--in-progress",r.style.display="block");const s=n.querySelector("[data-ap-runner-placeholder]");if(Jn.length===0&&(U.kind==="connecting"||U.kind==="idle")){if(!s){const h=document.createElement("div");h.className="ap-sdk-runner__placeholder",h.setAttribute("data-ap-runner-placeholder","1"),h.textContent="Waiting for the agent's first action…",n.appendChild(h)}}else s==null||s.remove();wn();const c=I.querySelector("[data-ap-runner-chat-input]"),u=I.querySelector("[data-ap-runner-chat-send]");if(c&&u){const h=U.kind==="finished"&&U.status==="failed";c.disabled=h,u.disabled=h||Mt,h&&(c.placeholder="This task failed — start a new automation to continue.")}const d=I.querySelector("[data-ap-runner-cancel]");d&&(d.style.display=U.kind==="finished"?"none":"");const p=I.querySelector("[data-ap-runner-summary]");p&&U.kind!=="finished"&&(p.style.display="none",p.innerHTML="")}function wn(){if(!I)return;const e=I.querySelector("[data-ap-runner-question]"),t=I.querySelector("[data-ap-runner-chat-input]");if(!e||!t)return;if(!Ge){e.style.display="none",e.innerHTML="",t.placeholder="Send a message to the agent…";return}const n=Ge.questionMetadata,r=(n==null?void 0:n.options)??[];if(t.placeholder="Type your answer…",e.style.display="block",e.innerHTML=`
1480
- <div class="ap-sdk-runner__question-label">${ns((n==null?void 0:n.header)||"The agent has a question")}</div>
1481
- <div class="ap-sdk-runner__question-text ap-sdk-markdown">${Oc((n==null?void 0:n.question)||Ge.question)}</div>
1496
+ `,I.addEventListener("wheel",a=>{a.stopPropagation()},{passive:!0}),I.addEventListener("touchmove",a=>{a.stopPropagation()},{passive:!0}),document.body.appendChild(I),De=zi(),qt(I),qi(I,Zi),I.querySelector("[data-ap-close]").addEventListener("click",()=>{Ri(),o==null||o()}),I.querySelector("[data-ap-runner-chat-form]").addEventListener("submit",a=>{a.preventDefault(),Sb(t,e)}),I.querySelector("[data-ap-runner-cancel]").addEventListener("click",a=>{a.stopPropagation();const u=a.currentTarget;if(!Pi){Pi=!0,u.textContent="Confirm",ko=setTimeout(_o,yb),Pr=d=>{d.target!==u&&_o()},document.addEventListener("click",Pr,!0);return}_o(),wb(t,e)}),Qi(),Nc(e,t)}function Nc(e,t){const n=async u=>{if(fe!==e||!I||U.kind!=="idle"&&U.kind!=="connecting"||kn.has(u.commandId))return;kn.add(u.commandId);const d={id:u.commandId,taskId:u.taskId,action:u.action,selector:u.selector,value:u.value,description:u.description,status:"pending",createdAt:new Date().toISOString()};bn({kind:"executing",command:d,actionsRun:U.kind==="idle"?U.actionsRun:0}),await ma(d,t,e)},r=u=>{if(!(fe!==e||!I)&&vb.has(u)){if(U.kind==="executing")bn({kind:"finishing",status:u,actionsRun:U.actionsRun});else if(U.kind==="connecting"||U.kind==="idle"){const d=U.kind==="idle"?U.actionsRun:0;bn({kind:"finished",status:u,actionsRun:d})}}},o=u=>{fe!==e||!I||(u.outputChunk&&ba([u.outputChunk]),r(u.status))},s=async()=>{if(!(fe!==e||!I))try{const u=await zo(t,e);fe===e&&I&&(Je=u[0]??null,xn())}catch{}},a=async()=>{try{const[u,d,h,p]=await Promise.all([dc(t,e),Og(t,e),zo(t,e),$g(t,e)]);if(fe!==e||!I)return;ba(d),Je=h[0]??null,xn(),r(u.status),p&&p.status==="pending"&&(U.kind==="idle"||U.kind==="connecting")&&!kn.has(p.id)?(kn.add(p.id),bn({kind:"executing",command:p,actionsRun:U.kind==="idle"?U.actionsRun:0}),await ma(p,t,e)):U.kind==="connecting"&&bn({kind:"idle",actionsRun:0})}catch{}};a(),Xg(t,e,{onStatusUpdate:o,onInteractionCreated:s,onInteractionAnswered:s,onBrowserCommandCreated:n,onReconnect:()=>{a()}}).then(u=>{if(fe!==e||U.kind==="finished"){u();return}jt=u})}function bn(e){U=e,U.kind==="idle"&&Qn===null&&(Qn=Date.now(),Do(),Lt=setInterval(Do,Ic)),U.kind==="finished"&&(Lt&&(clearInterval(Lt),Lt=null),jt==null||jt(),jt=null,De==null||De.hide(),mc()),Qi()}function _o(){Pi=!1,ko&&(clearTimeout(ko),ko=null),Pr&&(document.removeEventListener("click",Pr,!0),Pr=null);const e=I==null?void 0:I.querySelector("[data-ap-runner-cancel]");e&&(e.textContent="Cancel task")}async function wb(e,t){if(fe!==t||!I)return;const n=I.querySelector("[data-ap-runner-cancel]");n&&(n.disabled=!0);try{await Mg(e,t)}catch{n&&(n.disabled=!1)}}function Oc(){if(!fe||!Ut||!er||!Oo)return;const e=fe,t=Ut;gc({taskId:e,backendUrl:er,title:Oo}),Lt&&clearInterval(Lt),Do(),Lt=setInterval(Do,Ic);const n=U.kind==="finished"?U.actionsRun:0;kn=new Set,U={kind:"idle",actionsRun:n},Qi(),Nc(e,t)}function Qi(){if(!I)return;const e=I.querySelector("[data-ap-runner-status]"),t=I.querySelector("[data-ap-runner-counter]"),n=I.querySelector("[data-ap-runner-log]"),r=I.querySelector("[data-ap-runner-hint]");if(!e||!t||!n||!r)return;const o="actionsRun"in U?U.actionsRun:0;t.textContent=`${o} action${o===1?"":"s"}`,U.kind==="finished"?(e.textContent=U.status.replace(/_/g," "),e.className=`ap-sdk-status-badge ap-sdk-status-badge--${U.status.replace(/_/g,"-")}`,r.style.display="none",Lb(U.status)):(e.textContent="running",e.className="ap-sdk-status-badge ap-sdk-status-badge--in-progress",r.style.display="block");const s=n.querySelector("[data-ap-runner-placeholder]");if(Jn.length===0&&(U.kind==="connecting"||U.kind==="idle")){if(!s){const p=document.createElement("div");p.className="ap-sdk-runner__placeholder",p.setAttribute("data-ap-runner-placeholder","1"),p.textContent="Waiting for the agent's first action…",n.appendChild(p)}}else s==null||s.remove();xn();const a=I.querySelector("[data-ap-runner-chat-input]"),u=I.querySelector("[data-ap-runner-chat-send]");if(a&&u){const p=U.kind==="finished"&&U.status==="failed";a.disabled=p,u.disabled=p||Zt,p&&(a.placeholder="This task failed — start a new automation to continue.")}const d=I.querySelector("[data-ap-runner-cancel]");d&&(d.style.display=U.kind==="finished"?"none":"");const h=I.querySelector("[data-ap-runner-summary]");h&&U.kind!=="finished"&&(h.style.display="none",h.innerHTML="")}function xn(){if(!I)return;const e=I.querySelector("[data-ap-runner-question]"),t=I.querySelector("[data-ap-runner-chat-input]");if(!e||!t)return;if(!Je){e.style.display="none",e.innerHTML="",t.placeholder="Send a message to the agent…";return}const n=Je.questionMetadata,r=(n==null?void 0:n.options)??[];if(t.placeholder="Type your answer…",e.style.display="block",e.innerHTML=`
1497
+ <div class="ap-sdk-runner__question-label">${es((n==null?void 0:n.header)||"The agent has a question")}</div>
1498
+ <div class="ap-sdk-runner__question-text ap-sdk-markdown">${zc((n==null?void 0:n.question)||Je.question)}</div>
1482
1499
  ${r.length>0?'<div class="ap-sdk-runner__question-options" data-ap-runner-question-options></div>':""}
1483
- `,r.length>0){const o=e.querySelector("[data-ap-runner-question-options]");for(const s of r){const c=document.createElement("button");c.type="button",c.className="ap-sdk-panel__btn ap-sdk-panel__btn--ghost ap-sdk-runner__question-option",c.textContent=s.label,c.addEventListener("click",()=>void Ab(s.label)),o.appendChild(c)}}}async function Ab(e){if(!I||!Ge||!pe||Mt)return;const t=pe,n=Ot;if(n){Mt=!0;try{const r={selectedOption:e};await mc(n,t,Ge.id,r),Ge=null,wn();const o=await Oo(n,t);pe===t&&I&&(Ge=o[0]??null,wn())}catch{const r=I.querySelector("[data-ap-runner-chat-error]");r&&(r.textContent="Failed to send your answer — try again.",r.style.display="block")}finally{Mt=!1}}}function Zo(){if(!I||Qn===null)return;const e=I.querySelector("[data-ap-runner-timer]");if(!e)return;const t=Math.max(0,Math.floor((Date.now()-Qn)/1e3)),n=String(Math.floor(t/60)).padStart(2,"0"),r=String(t%60).padStart(2,"0");e.textContent=`${n}:${r}`}async function va(e,t,n){let r="done",o;try{if(e.action==="getContext"){const c=e.selector?document.querySelector(e.selector):document.body;if(!c)throw new Error(`element not found (${e.selector})`);Ne==null||Ne.update(c),o=Rb(c)}else{if(!e.selector)throw new Error(`${e.action} command is missing a selector`);const c=document.querySelector(e.selector);if(!c)throw new Error(`element not found (${e.selector})`);if(Ne==null||Ne.update(c),e.action==="click")await tm(c),o="Clicked";else{if(e.value===void 0)throw new Error("inputText command is missing a value");Lb(c,e.value),o="Entered text"}}}catch(c){r="error",o=c instanceof Error?c.message:"Unknown error executing command"}if(pe===n&&I&&zb(r,e,o),await Pb(t,n,e.id,r,o),pe!==n||!I)return;Ne==null||Ne.hide();const s=(U.kind==="executing"||U.kind==="finishing"?U.actionsRun:0)+1;U.kind==="finishing"?bn({kind:"finished",status:U.status,actionsRun:s}):U.kind==="executing"&&bn({kind:"idle",actionsRun:s})}async function Cb(e,t){if(!I||Mt||U.kind==="finished"&&U.status==="failed")return;const n=I.querySelector("[data-ap-runner-chat-input]"),r=I.querySelector("[data-ap-runner-chat-error]"),o=I.querySelector("[data-ap-runner-chat-send]");if(!n||!r||!o)return;const s=n.value.trim();if(s){Mt=!0,o.disabled=!0,r.style.display="none";try{if(Ge){await mc(e,t,Ge.id,s),Ge=null,wn();try{const c=await Oo(e,t);pe===t&&I&&(Ge=c[0]??null,wn())}catch{}}else await Zg(e,t,s),U.kind==="finished"&&jc();n.value=""}catch(c){r.textContent=c instanceof Error?c.message:"Failed to send — try again.",r.style.display="block"}finally{Mt=!1,o.disabled=!1}}}async function Pb(e,t,n,r,o){try{await Ug(e,t,n,r,o)}catch{}}function Rb(e){const t=e.cloneNode(!0);t.querySelectorAll("script, style, noscript").forEach(o=>o.remove()),Wg(t);let n=t.outerHTML,r=!1;return n.length>_a&&(n=n.slice(0,_a),r=!0),`URL: ${location.href}
1500
+ `,r.length>0){const o=e.querySelector("[data-ap-runner-question-options]");for(const s of r){const a=document.createElement("button");a.type="button",a.className="ap-sdk-panel__btn ap-sdk-panel__btn--ghost ap-sdk-runner__question-option",a.textContent=s.label,a.addEventListener("click",()=>void xb(s.label)),o.appendChild(a)}}}async function xb(e){if(!I||!Je||!fe||Zt)return;const t=fe,n=Ut;if(n){Zt=!0;try{const r={selectedOption:e};await pc(n,t,Je.id,r),Je=null,xn();const o=await zo(n,t);fe===t&&I&&(Je=o[0]??null,xn())}catch{const r=I.querySelector("[data-ap-runner-chat-error]");r&&(r.textContent="Failed to send your answer — try again.",r.style.display="block")}finally{Zt=!1}}}function Do(){if(!I||Qn===null)return;const e=I.querySelector("[data-ap-runner-timer]");if(!e)return;const t=Math.max(0,Math.floor((Date.now()-Qn)/1e3)),n=String(Math.floor(t/60)).padStart(2,"0"),r=String(t%60).padStart(2,"0");e.textContent=`${n}:${r}`}async function ma(e,t,n){let r="done",o;try{if(e.action==="getContext"){const a=e.selector?document.querySelector(e.selector):document.body;if(!a)throw new Error(`element not found (${e.selector})`);De==null||De.update(a),o=Eb(a)}else{if(!e.selector)throw new Error(`${e.action} command is missing a selector`);const a=document.querySelector(e.selector);if(!a)throw new Error(`element not found (${e.selector})`);if(De==null||De.update(a),e.action==="click")await Yg(a),o="Clicked";else{if(e.value===void 0)throw new Error("inputText command is missing a value");Ab(a,e.value),o="Entered text"}}}catch(a){r="error",o=a instanceof Error?a.message:"Unknown error executing command"}if(fe===n&&I&&Cb(r,e,o),await Tb(t,n,e.id,r,o),fe!==n||!I)return;De==null||De.hide();const s=(U.kind==="executing"||U.kind==="finishing"?U.actionsRun:0)+1;U.kind==="finishing"?bn({kind:"finished",status:U.status,actionsRun:s}):U.kind==="executing"&&bn({kind:"idle",actionsRun:s})}async function Sb(e,t){if(!I||Zt||U.kind==="finished"&&U.status==="failed")return;const n=I.querySelector("[data-ap-runner-chat-input]"),r=I.querySelector("[data-ap-runner-chat-error]"),o=I.querySelector("[data-ap-runner-chat-send]");if(!n||!r||!o)return;const s=n.value.trim();if(s){Zt=!0,o.disabled=!0,r.style.display="none";try{if(Je){await pc(e,t,Je.id,s),Je=null,xn();try{const a=await zo(e,t);fe===t&&I&&(Je=a[0]??null,xn())}catch{}}else await Dg(e,t,s),U.kind==="finished"&&Oc();n.value=""}catch(a){r.textContent=a instanceof Error?a.message:"Failed to send — try again.",r.style.display="block"}finally{Zt=!1,o.disabled=!1}}}async function Tb(e,t,n,r,o){try{await Ng(e,t,n,r,o)}catch{}}function Eb(e){const t=e.cloneNode(!0);t.querySelectorAll("script, style, noscript").forEach(o=>o.remove()),Hg(t);let n=t.outerHTML,r=!1;return n.length>ga&&(n=n.slice(0,ga),r=!0),`URL: ${location.href}
1484
1501
  Title: ${document.title}
1485
1502
 
1486
1503
  ${n}${r?`
1487
- … (truncated)`:""}`}function Lb(e,t){var s;const r=e instanceof HTMLTextAreaElement?HTMLTextAreaElement.prototype:HTMLInputElement.prototype,o=(s=Object.getOwnPropertyDescriptor(r,"value"))==null?void 0:s.set;if(!o)throw new Error("target element does not accept text input");o.call(e,t),e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0}))}function zb(e,t,n){var b;const r=e==="done"?"✓":"✗",o=t.selector?` \`${t.selector}\``:"",s=t.description||`${t.action}${o}`,c=e==="done"&&t.action==="getContext"?`read context (${(n==null?void 0:n.length)??0} chars)`:n,u=c?` — ${c}`:"";if(Jn.push({status:e,text:`${r} ${s}${u}`}),!I)return;const d=I.querySelector("[data-ap-runner-log]");if(!d)return;(b=d.querySelector("[data-ap-runner-placeholder]"))==null||b.remove();const p=d.scrollHeight-d.scrollTop-d.clientHeight<=Mc,h=document.createElement("div");h.className=`ap-sdk-runner__log-entry ap-sdk-runner__log-entry--${e}`,h.textContent=Jn[Jn.length-1].text,d.appendChild(h),p&&(d.scrollTop=d.scrollHeight)}function Ib(e){var t;return((t=e.display)==null?void 0:t.variant)??e.sdkEventType}function $b(e){const t=Ib(e);return(e.stream==="stdout"||e.stream==="stderr"||e.stream==="sdk_event"&&(t==="text"||t==="thinking"))&&e.data.trim()||null}function ya(e){var r;const t=e.filter(o=>o.sequence>Ir).sort((o,s)=>o.sequence-s.sequence);if(t.length===0||(Ir=Math.max(Ir,...t.map(o=>o.sequence)),!I))return;const n=I.querySelector("[data-ap-runner-log]");if(n)for(const o of t){const s=$b(o);if(!s)continue;(r=n.querySelector("[data-ap-runner-placeholder]"))==null||r.remove();const c=n.scrollHeight-n.scrollTop-n.clientHeight<=Mc,u=document.createElement("div");u.className=`ap-sdk-runner__log-entry ap-sdk-runner__log-entry--output ap-sdk-runner__log-entry--${o.stream}`,o.stream==="sdk_event"?(u.classList.add("ap-sdk-markdown"),u.innerHTML=Oc(s)):u.textContent=s,n.appendChild(u),c&&(n.scrollTop=n.scrollHeight)}}function Nb(e){if(!I||!pe||!er)return;const t=I.querySelector("[data-ap-runner-summary]");if(!t)return;const n=`${er.replace(/\/+$/,"")}/tasks/${pe}`,r=e==="completed"?"Automation complete!":"Automation ended",o=e==="completed";t.style.display="block",t.innerHTML=`
1504
+ … (truncated)`:""}`}function Ab(e,t){var s;const r=e instanceof HTMLTextAreaElement?HTMLTextAreaElement.prototype:HTMLInputElement.prototype,o=(s=Object.getOwnPropertyDescriptor(r,"value"))==null?void 0:s.set;if(!o)throw new Error("target element does not accept text input");o.call(e,t),e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0}))}function Cb(e,t,n){var b;const r=e==="done"?"✓":"✗",o=t.selector?` \`${t.selector}\``:"",s=t.description||`${t.action}${o}`,a=e==="done"&&t.action==="getContext"?`read context (${(n==null?void 0:n.length)??0} chars)`:n,u=a?` — ${a}`:"";if(Jn.push({status:e,text:`${r} ${s}${u}`}),!I)return;const d=I.querySelector("[data-ap-runner-log]");if(!d)return;(b=d.querySelector("[data-ap-runner-placeholder]"))==null||b.remove();const h=d.scrollHeight-d.scrollTop-d.clientHeight<=$c,p=document.createElement("div");p.className=`ap-sdk-runner__log-entry ap-sdk-runner__log-entry--${e}`,p.textContent=Jn[Jn.length-1].text,d.appendChild(p),h&&(d.scrollTop=d.scrollHeight)}function Pb(e){var t;return((t=e.display)==null?void 0:t.variant)??e.sdkEventType}function Rb(e){const t=Pb(e);return(e.stream==="stdout"||e.stream==="stderr"||e.stream==="sdk_event"&&(t==="text"||t==="thinking"))&&e.data.trim()||null}function ba(e){var r;const t=e.filter(o=>o.sequence>Rr).sort((o,s)=>o.sequence-s.sequence);if(t.length===0||(Rr=Math.max(Rr,...t.map(o=>o.sequence)),!I))return;const n=I.querySelector("[data-ap-runner-log]");if(n)for(const o of t){const s=Rb(o);if(!s)continue;(r=n.querySelector("[data-ap-runner-placeholder]"))==null||r.remove();const a=n.scrollHeight-n.scrollTop-n.clientHeight<=$c,u=document.createElement("div");u.className=`ap-sdk-runner__log-entry ap-sdk-runner__log-entry--output ap-sdk-runner__log-entry--${o.stream}`,o.stream==="sdk_event"?(u.classList.add("ap-sdk-markdown"),u.innerHTML=zc(s)):u.textContent=s,n.appendChild(u),a&&(n.scrollTop=n.scrollHeight)}}function Lb(e){if(!I||!fe||!er)return;const t=I.querySelector("[data-ap-runner-summary]");if(!t)return;const n=`${er.replace(/\/+$/,"")}/tasks/${fe}`,r=e==="completed"?"Automation complete!":"Automation ended",o=e==="completed";t.style.display="block",t.innerHTML=`
1488
1505
  <div class="ap-sdk-success-card">
1489
- <p class="ap-sdk-success-headline">${ns(r)}</p>
1506
+ <p class="ap-sdk-success-headline">${es(r)}</p>
1490
1507
  ${o?`
1491
1508
  <div class="ap-sdk-runner__approval" data-ap-runner-approval>
1492
1509
  <div class="ap-sdk-runner__approval-actions">
@@ -1504,7 +1521,7 @@ ${n}${r?`
1504
1521
  <button class="ap-sdk-panel__btn ap-sdk-panel__btn--ghost" data-ap-runner-close>Close</button>
1505
1522
  </div>
1506
1523
  </div>
1507
- `,t.querySelector("[data-ap-runner-view]").addEventListener("click",()=>window.open(n,"_blank","noopener,noreferrer")),t.querySelector("[data-ap-runner-close]").addEventListener("click",()=>{const s=Qi;wo(),s==null||s()}),o&&Ob(t)}function Ob(e){const t=e.querySelector("[data-ap-runner-approve]"),n=e.querySelector("[data-ap-runner-reject]"),r=e.querySelector("[data-ap-runner-reject-form]"),o=e.querySelector("[data-ap-runner-reject-feedback]"),s=e.querySelector("[data-ap-runner-reject-submit]"),c=e.querySelector("[data-ap-runner-approval-error]"),u=e.querySelector(".ap-sdk-runner__approval-actions"),d=h=>{c.textContent=h,c.style.display="block"};t.addEventListener("click",async()=>{if(!pe||!Ot)return;const h=pe,b=Ot;t.disabled=!0,n.disabled=!0,c.style.display="none";try{await Hg(b,h),u.innerHTML='<span class="ap-sdk-status-badge ap-sdk-status-badge--approved">Approved</span>',r.style.display="none"}catch(m){t.disabled=!1,n.disabled=!1,d(m instanceof Error?m.message:"Failed to approve — try again.")}}),n.addEventListener("click",()=>{r.style.display=r.style.display==="none"?"block":"none",r.style.display==="block"&&o.focus()});const p=()=>{s.textContent=o.value.trim()?"Reject & Continue":"Reject Permanently"};o.addEventListener("input",p),s.addEventListener("click",async()=>{if(!pe||!Ot)return;const h=pe,b=Ot,m=o.value.trim();s.disabled=!0,t.disabled=!0,c.style.display="none",s.textContent="Rejecting…";try{await Fg(b,h,m),m?jc():(u.innerHTML='<span class="ap-sdk-status-badge ap-sdk-status-badge--rejected">Rejected</span>',r.style.display="none")}catch(_){s.disabled=!1,t.disabled=!1,p(),d(_ instanceof Error?_.message:"Failed to reject — try again.")}})}function Db(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function ns(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Mb(e,t,n){const r=!!(t.backendUrl&&t.token),o=document.createElement("div");o.className="ap-sdk-advanced",o.innerHTML=`
1524
+ `,t.querySelector("[data-ap-runner-view]").addEventListener("click",()=>window.open(n,"_blank","noopener,noreferrer")),t.querySelector("[data-ap-runner-close]").addEventListener("click",()=>{const s=Yi;Ri(),s==null||s()}),o&&zb(t)}function zb(e){const t=e.querySelector("[data-ap-runner-approve]"),n=e.querySelector("[data-ap-runner-reject]"),r=e.querySelector("[data-ap-runner-reject-form]"),o=e.querySelector("[data-ap-runner-reject-feedback]"),s=e.querySelector("[data-ap-runner-reject-submit]"),a=e.querySelector("[data-ap-runner-approval-error]"),u=e.querySelector(".ap-sdk-runner__approval-actions"),d=p=>{a.textContent=p,a.style.display="block"};t.addEventListener("click",async()=>{if(!fe||!Ut)return;const p=fe,b=Ut;t.disabled=!0,n.disabled=!0,a.style.display="none";try{await Ug(b,p),u.innerHTML='<span class="ap-sdk-status-badge ap-sdk-status-badge--approved">Approved</span>',r.style.display="none"}catch(m){t.disabled=!1,n.disabled=!1,d(m instanceof Error?m.message:"Failed to approve — try again.")}}),n.addEventListener("click",()=>{r.style.display=r.style.display==="none"?"block":"none",r.style.display==="block"&&o.focus()});const h=()=>{s.textContent=o.value.trim()?"Reject & Continue":"Reject Permanently"};o.addEventListener("input",h),s.addEventListener("click",async()=>{if(!fe||!Ut)return;const p=fe,b=Ut,m=o.value.trim();s.disabled=!0,t.disabled=!0,a.style.display="none",s.textContent="Rejecting…";try{await jg(b,p,m),m?Oc():(u.innerHTML='<span class="ap-sdk-status-badge ap-sdk-status-badge--rejected">Rejected</span>',r.style.display="none")}catch(_){s.disabled=!1,t.disabled=!1,h(),d(_ instanceof Error?_.message:"Failed to reject — try again.")}})}function Ib(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function es(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function $b(e,t,n){const r=!!(t.backendUrl&&t.token),o=document.createElement("div");o.className="ap-sdk-advanced",o.innerHTML=`
1508
1525
  <details class="ap-sdk-advanced__details">
1509
1526
  <summary class="ap-sdk-advanced__summary">Advanced options</summary>
1510
1527
  <div class="ap-sdk-advanced__body">
@@ -1523,12 +1540,12 @@ ${n}${r?`
1523
1540
  </div>
1524
1541
  </div>
1525
1542
  </details>
1526
- `,e.appendChild(o);const s=o.querySelector("[data-ap-adv-template-field]"),c=o.querySelector("[data-ap-template]"),u=o.querySelector("[data-ap-quickmode]");let d=[];if(r){const p={backendUrl:t.backendUrl,token:t.token};Ng(p,n??void 0).then(h=>{if(d=h,h.length===0){s.style.display="none";return}const b=h.find(m=>m.isDefault&&m.scope==="project")??h.find(m=>m.isDefault&&m.scope==="global");c.innerHTML='<option value="">None (use default)</option>'+h.map(m=>`<option value="${Ub(m.id)}">${jb(m.name)}${m.isDefault?" (Default)":""}</option>`).join(""),c.value=(b==null?void 0:b.id)??""}).catch(()=>{s.style.display="none"})}else{c.innerHTML='<option value="">None</option>',c.disabled=!0;const p=document.createElement("span");p.className="ap-sdk-advanced__hint",p.textContent="Connect credentials to enable template selection",s.appendChild(p)}return{getOptions(){var b,m,_,w,P,N,te;const p=c.value||null,h=p?((b=d.find(R=>R.id===p))==null?void 0:b.templateData)??{}:{};return{claudeTemplateId:p,quickMode:u.checked,...h.modelOverride!=null?{modelOverride:h.modelOverride}:{},...h.claudeProfileId!=null?{claudeProfileId:h.claudeProfileId}:{},...h.effort!=null?{effort:h.effort}:{},...h.executionMode!=null?{executionMode:h.executionMode}:{},...(m=h.selectedPluginIds)!=null&&m.length?{selectedPluginIds:h.selectedPluginIds}:{},...(_=h.selectedSkillIds)!=null&&_.length?{selectedSkillIds:h.selectedSkillIds}:{},...(w=h.selectedPluginSkillIds)!=null&&w.length?{selectedPluginSkillIds:h.selectedPluginSkillIds}:{},...(P=h.selectedMcpServerIds)!=null&&P.length?{selectedMcpServerIds:h.selectedMcpServerIds}:{},...(N=h.selectedSlashCommandIds)!=null&&N.length?{selectedSlashCommandIds:h.selectedSlashCommandIds}:{},...(te=h.selectedRemoteContextProviderIds)!=null&&te.length?{selectedRemoteContextProviderIds:h.selectedRemoteContextProviderIds}:{}}}}}function Ub(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function jb(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}const rs="ap-sdk-captures",Zb=50;function or(){try{const e=localStorage.getItem(rs);return e?JSON.parse(e):[]}catch{return[]}}function qb(e){const t=or(),n=[e,...t].slice(0,Zb);try{localStorage.setItem(rs,JSON.stringify(n))}catch{}}function Hb(){try{localStorage.removeItem(rs)}catch{}}function Zc(e){var c,u,d,p,h;if(e.id){const b=document.querySelector(`label[for="${CSS.escape(e.id)}"]`),m=(c=b==null?void 0:b.textContent)==null?void 0:c.trim();if(m)return m}const t=e.closest("label"),n=(u=t==null?void 0:t.textContent)==null?void 0:u.trim();if(n)return n;const r=(d=e.getAttribute("aria-label"))==null?void 0:d.trim();if(r)return r;const o=(p=e.placeholder)==null?void 0:p.trim();if(o)return o;const s=(h=e.getAttribute("name"))==null?void 0:h.trim();return s||e.tagName.toLowerCase()}function Fb(e,t){return`Click "${e}" ${t.toLowerCase()}`}function qc(e,t,n){return n?`Typed [redacted] into ${e}`:`Typed "${t}" into ${e}`}function wa(e,t){return`Scrolled to (${e}, ${t})`}function Bb(e,t){return t?`Pressed "${e}" in ${t}`:`Pressed "${e}"`}function Hc(e){return e.map((t,n)=>`${n+1}. ${t.description}`).join(`
1527
- `)}const Gb=400,Wb=new Set(["Enter","Tab","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End","PageUp","PageDown"]),Jb=new Set(["Control","Meta","Alt","Shift"]);function Xb(e){if(Jb.has(e.key))return null;const t=[];return e.ctrlKey&&t.push("Ctrl"),e.metaKey&&t.push("Cmd"),e.altKey&&t.push("Alt"),t.length>0?(t.push(e.key.length===1?e.key.toUpperCase():e.key),t.join("+")):Wb.has(e.key)?e.key:null}function Vb(e){return e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement?Zc(e):Lo(e)||e.tagName.toLowerCase()}let tr=[],He=null,qo=null,Ke=null,Tt=null,Et=null;function Fc(){qo&&(qo.textContent=`● Recording — ${tr.length} step${tr.length===1?"":"s"}`)}function Ii(){Et&&(clearTimeout(Et),Et=null),Tt&&(tr.push(Tt),Tt=null,Fc())}function _i(e){Ii(),tr.push(e),Fc()}function Yb(e){var t,n;return e instanceof HTMLSelectElement?((n=(t=e.selectedOptions[0])==null?void 0:t.textContent)==null?void 0:n.trim())??e.value:e.value}function Kb(e,t){Ke&&Ke(),tr=[],Tt=null,He=document.createElement("div"),He.className="ap-sdk-recorder-bar",He.setAttribute("data-ap-sdk","1"),He.innerHTML=`
1543
+ `,e.appendChild(o);const s=o.querySelector("[data-ap-adv-template-field]"),a=o.querySelector("[data-ap-template]"),u=o.querySelector("[data-ap-quickmode]");let d=[];if(r){const h={backendUrl:t.backendUrl,token:t.token};Lg(h,n??void 0).then(p=>{if(d=p,p.length===0){s.style.display="none";return}const b=p.find(m=>m.isDefault&&m.scope==="project")??p.find(m=>m.isDefault&&m.scope==="global");a.innerHTML='<option value="">None (use default)</option>'+p.map(m=>`<option value="${Nb(m.id)}">${Ob(m.name)}${m.isDefault?" (Default)":""}</option>`).join(""),a.value=(b==null?void 0:b.id)??""}).catch(()=>{s.style.display="none"})}else{a.innerHTML='<option value="">None</option>',a.disabled=!0;const h=document.createElement("span");h.className="ap-sdk-advanced__hint",h.textContent="Connect credentials to enable template selection",s.appendChild(h)}return{getOptions(){var b,m,_,w,C,M,W;const h=a.value||null,p=h?((b=d.find(P=>P.id===h))==null?void 0:b.templateData)??{}:{};return{claudeTemplateId:h,quickMode:u.checked,...p.modelOverride!=null?{modelOverride:p.modelOverride}:{},...p.claudeProfileId!=null?{claudeProfileId:p.claudeProfileId}:{},...p.effort!=null?{effort:p.effort}:{},...p.executionMode!=null?{executionMode:p.executionMode}:{},...(m=p.selectedPluginIds)!=null&&m.length?{selectedPluginIds:p.selectedPluginIds}:{},...(_=p.selectedSkillIds)!=null&&_.length?{selectedSkillIds:p.selectedSkillIds}:{},...(w=p.selectedPluginSkillIds)!=null&&w.length?{selectedPluginSkillIds:p.selectedPluginSkillIds}:{},...(C=p.selectedMcpServerIds)!=null&&C.length?{selectedMcpServerIds:p.selectedMcpServerIds}:{},...(M=p.selectedSlashCommandIds)!=null&&M.length?{selectedSlashCommandIds:p.selectedSlashCommandIds}:{},...(W=p.selectedRemoteContextProviderIds)!=null&&W.length?{selectedRemoteContextProviderIds:p.selectedRemoteContextProviderIds}:{}}}}}function Nb(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Ob(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}const ts="ap-sdk-captures",Db=50;function or(){try{const e=localStorage.getItem(ts);return e?JSON.parse(e):[]}catch{return[]}}function Mb(e){const t=or(),n=[e,...t].slice(0,Db);try{localStorage.setItem(ts,JSON.stringify(n))}catch{}}function Ub(){try{localStorage.removeItem(ts)}catch{}}function Dc(e){var a,u,d,h,p;if(e.id){const b=document.querySelector(`label[for="${CSS.escape(e.id)}"]`),m=(a=b==null?void 0:b.textContent)==null?void 0:a.trim();if(m)return m}const t=e.closest("label"),n=(u=t==null?void 0:t.textContent)==null?void 0:u.trim();if(n)return n;const r=(d=e.getAttribute("aria-label"))==null?void 0:d.trim();if(r)return r;const o=(h=e.placeholder)==null?void 0:h.trim();if(o)return o;const s=(p=e.getAttribute("name"))==null?void 0:p.trim();return s||e.tagName.toLowerCase()}function jb(e,t){return`Click "${e}" ${t.toLowerCase()}`}function Mc(e,t,n){return n?`Typed [redacted] into ${e}`:`Typed "${t}" into ${e}`}function ka(e,t){return`Scrolled to (${e}, ${t})`}function Zb(e,t){return t?`Pressed "${e}" in ${t}`:`Pressed "${e}"`}function Uc(e){return e.map((t,n)=>`${n+1}. ${t.description}`).join(`
1544
+ `)}const qb=400,Hb=new Set(["Enter","Tab","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End","PageUp","PageDown"]),Fb=new Set(["Control","Meta","Alt","Shift"]);function Bb(e){if(Fb.has(e.key))return null;const t=[];return e.ctrlKey&&t.push("Ctrl"),e.metaKey&&t.push("Cmd"),e.altKey&&t.push("Alt"),t.length>0?(t.push(e.key.length===1?e.key.toUpperCase():e.key),t.join("+")):Hb.has(e.key)?e.key:null}function Gb(e){return e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement?Dc(e):Ao(e)||e.tagName.toLowerCase()}let tr=[],Be=null,Mo=null,Ke=null,Ct=null,Pt=null;function jc(){Mo&&(Mo.textContent=`● Recording — ${tr.length} step${tr.length===1?"":"s"}`)}function Li(){Pt&&(clearTimeout(Pt),Pt=null),Ct&&(tr.push(Ct),Ct=null,jc())}function mi(e){Li(),tr.push(e),jc()}function Wb(e){var t,n;return e instanceof HTMLSelectElement?((n=(t=e.selectedOptions[0])==null?void 0:t.textContent)==null?void 0:n.trim())??e.value:e.value}function Jb(e,t){Ke&&Ke(),tr=[],Ct=null,Be=document.createElement("div"),Be.className="ap-sdk-recorder-bar",Be.setAttribute("data-ap-sdk","1"),Be.innerHTML=`
1528
1545
  <span class="ap-sdk-recorder-bar__counter" data-ap-recorder-counter>● Recording — 0 steps</span>
1529
1546
  <button class="ap-sdk-recorder-bar__btn ap-sdk-recorder-bar__btn--stop" data-ap-recorder-stop type="button">Stop</button>
1530
1547
  <button class="ap-sdk-recorder-bar__btn ap-sdk-recorder-bar__btn--discard" data-ap-recorder-discard type="button">Discard</button>
1531
- `,document.body.appendChild(He),Ut(He),qo=He.querySelector("[data-ap-recorder-counter]");const n=()=>{Ii();const d=tr;Ke==null||Ke(),e(d)},r=()=>{Ke==null||Ke()};He.querySelector("[data-ap-recorder-stop]").addEventListener("click",n),He.querySelector("[data-ap-recorder-discard]").addEventListener("click",r);const o=d=>{if(Lr(d.target))return;const p=d.target;_i({action:"click",cssSelector:ko(p),elementText:Lo(p),description:Fb(Lo(p),p.tagName),capturedAt:new Date().toISOString()})},s=d=>{if(Lr(d.target))return;const p=d.target;if(!(p instanceof HTMLInputElement)&&!(p instanceof HTMLTextAreaElement)&&!(p instanceof HTMLSelectElement))return;const h=Zc(p),b=Gg(p),m=b?"[redacted]":Yb(p);_i({action:"inputText",cssSelector:ko(p),elementText:h,value:m,...b?{redacted:!0}:{},description:qc(h,m,b),capturedAt:new Date().toISOString()})},c=()=>{const d=Math.round(window.scrollX),p=Math.round(window.scrollY);Tt?(Tt.scrollX=d,Tt.scrollY=p,Tt.description=wa(d,p)):Tt={action:"scroll",scrollX:d,scrollY:p,description:wa(d,p),capturedAt:new Date().toISOString()},Et&&clearTimeout(Et),Et=setTimeout(()=>{Et=null,Ii()},Gb)},u=d=>{if(d.key==="Escape"){r();return}if(Lr(d.target))return;const p=Xb(d);if(!p)return;const h=d.target instanceof Element?d.target:document.body,b=Vb(h);_i({action:"keypress",cssSelector:ko(h),elementText:b,key:p,description:Bb(p,b),capturedAt:new Date().toISOString()})};document.addEventListener("click",o,{capture:!0}),document.addEventListener("change",s,{capture:!0}),window.addEventListener("scroll",c,{capture:!0,passive:!0}),document.addEventListener("keydown",u,{capture:!0}),Ke=()=>{document.removeEventListener("click",o,{capture:!0}),document.removeEventListener("change",s,{capture:!0}),window.removeEventListener("scroll",c,{capture:!0}),document.removeEventListener("keydown",u,{capture:!0}),Et&&(clearTimeout(Et),Et=null),Tt=null,He&&jt(He),He==null||He.remove(),He=null,qo=null,Ke=null}}function Qb(){Ke==null||Ke()}function So(){return Ke!==null}const ek="data-ap-sdk",tk="ap-sdk-fab",xa="ap-sdk-fab--dragging",os="ap-sdk-fab--open",Bc="ap-sdk-fab-pos",Ho="ap-sdk-fab--left-edge",nk='<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 8V4H8"/><rect width="16" height="12" x="4" y="8" rx="2"/><path d="M2 14h2"/><path d="M20 14h2"/><path d="M15 13v2"/><path d="M9 13v2"/></svg>',rk='<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m3 3 7.07 16.97 2.51-7.39 7.39-2.51L3 3z"/><path d="m13 13 6 6"/></svg>',ok='<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor"><circle cx="12" cy="12" r="8"/></svg>',ik='<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="8" y1="6" x2="21" y2="6"/><line x1="8" y1="12" x2="21" y2="12"/><line x1="8" y1="18" x2="21" y2="18"/><line x1="3" y1="6" x2="3.01" y2="6"/><line x1="3" y1="12" x2="3.01" y2="12"/><line x1="3" y1="18" x2="3.01" y2="18"/></svg>';let z=null,Qe=null,Jt=null,Xt=null,Vt=null,Dn=null,Mn=null,Un=null,To=null,$r=null,Xn=null,Eo=null,Ao=null,Co=null,Gc=0,Wc=0,Jc=0,Xc=0,qn=!1,gt=!1,Nr=null,_n=null;function sk(){Nr=e=>{if(!z){Po();return}if(!qn){if(Math.hypot(e.clientX-Jc,e.clientY-Xc)<5)return;qn=!0,gt=!0,z.classList.add(xa)}ak(e.clientX-Gc,e.clientY-Wc)},_n=()=>{if(!z){Po();return}qn?(qn=!1,z.classList.remove(xa),z.style.transition="",ck(z.getBoundingClientRect())):z.style.transition="",Po()},window.addEventListener("pointermove",Nr),window.addEventListener("pointerup",_n),window.addEventListener("pointercancel",_n)}function Po(){Nr&&(window.removeEventListener("pointermove",Nr),Nr=null),_n&&(window.removeEventListener("pointerup",_n),window.removeEventListener("pointercancel",_n),_n=null)}function ak(e,t){if(!z)return;const n=z.offsetWidth||52,r=z.offsetHeight||52;z.style.top=`${Math.max(0,Math.min(t,window.innerHeight-r))}px`,z.style.left=`${Math.max(0,Math.min(e,window.innerWidth-n))}px`,z.style.bottom="auto",z.style.right="auto"}function ck(e){if(!z)return;const n=Math.max(16,Math.min(window.innerHeight-e.bottom,window.innerHeight-52-16)),r=e.left+e.width/2<window.innerWidth/2?"left":"right";z.style.top="auto",z.style.bottom=`${n}px`,r==="left"?(z.style.right="auto",z.style.left="16px",z.classList.add(Ho)):(z.style.left="auto",z.style.right="16px",z.classList.remove(Ho));try{localStorage.setItem(Bc,JSON.stringify({edge:r,bottom:n}))}catch{}}function lk(){if(z)try{const e=localStorage.getItem(Bc);if(!e)return;const t=JSON.parse(e);if(typeof t.bottom!="number"||t.edge!=="left"&&t.edge!=="right")return;const r=Math.max(16,Math.min(t.bottom,window.innerHeight-52-16));z.style.top="auto",z.style.bottom=`${r}px`,t.edge==="left"?(z.style.right="auto",z.style.left="16px",z.classList.add(Ho)):(z.style.left="auto",z.style.right="16px",z.classList.remove(Ho))}catch{}}function Hn(){z==null||z.classList.remove(os),Xn&&(window.removeEventListener("pointerdown",Xn,{capture:!0}),Xn=null)}function uk(){z&&(z.classList.add(os),Xn=e=>{!z||z.contains(e.target)||Hn()},requestAnimationFrame(()=>{Xn&&window.addEventListener("pointerdown",Xn,{capture:!0})}))}function go(e){return new DOMParser().parseFromString(e,"text/html").body.firstElementChild}function Vc(e,t,n){if(Eo=e,Ao=t,Co=n,z)return;z=document.createElement("div"),z.className=tk,z.setAttribute(ek,"1"),Dn=document.createElement("div"),Dn.className="ap-sdk-fab__row";const r=document.createElement("span");r.className="ap-sdk-fab__label",r.textContent="View captures",Vt=document.createElement("button"),Vt.className="ap-sdk-fab__list ap-sdk-fab__sub",Vt.setAttribute("aria-label","My captures"),Vt.setAttribute("title","View my captures"),Vt.appendChild(go(ik)),Dn.appendChild(r),Dn.appendChild(Vt),Mn=document.createElement("div"),Mn.className="ap-sdk-fab__row";const o=document.createElement("span");o.className="ap-sdk-fab__label",o.textContent="Capture element",Jt=document.createElement("button"),Jt.className="ap-sdk-fab__capture ap-sdk-fab__sub",Jt.setAttribute("aria-label","Capture element"),Jt.setAttribute("title","Capture element to Agent Platform"),Jt.appendChild(go(rk)),Mn.appendChild(o),Mn.appendChild(Jt),Un=document.createElement("div"),Un.className="ap-sdk-fab__row";const s=document.createElement("span");s.className="ap-sdk-fab__label",s.textContent="Record interaction",Xt=document.createElement("button"),Xt.className="ap-sdk-fab__record ap-sdk-fab__sub",Xt.setAttribute("aria-label","Record interaction"),Xt.setAttribute("title","Record a sequence of interactions"),Xt.appendChild(go(ok)),Un.appendChild(s),Un.appendChild(Xt),Qe=document.createElement("button"),Qe.className="ap-sdk-fab__main",Qe.setAttribute("aria-label","Agent Platform"),Qe.setAttribute("title","Agent Platform"),Qe.appendChild(go(nk));const c=document.createElement("span");c.className="ap-sdk-fab__badge",c.setAttribute("data-ap-badge",""),c.style.display="none",Qe.appendChild(c),z.appendChild(Dn),z.appendChild(Mn),z.appendChild(Un),z.appendChild(Qe),Qe.addEventListener("click",u=>{if(gt){gt=!1;return}u.preventDefault(),u.stopPropagation(),z!=null&&z.classList.contains(os)?Hn():uk()}),Jt.addEventListener("click",u=>{if(gt){gt=!1;return}u.preventDefault(),u.stopPropagation(),Hn(),!Gn()&&!So()&&Eo&&Eo()}),Xt.addEventListener("click",u=>{if(gt){gt=!1;return}u.preventDefault(),u.stopPropagation(),Hn(),!Gn()&&!So()&&Ao&&Ao()}),Vt.addEventListener("click",u=>{if(gt){gt=!1;return}u.preventDefault(),u.stopPropagation(),Hn(),Co&&Co()}),$r=u=>{if(!z||!(z===u.target||z.contains(u.target)))return;const d=z.getBoundingClientRect();Gc=u.clientX-d.left,Wc=u.clientY-d.top,Jc=u.clientX,Xc=u.clientY,qn=!1,gt=!1,z.style.transition="none",u.stopPropagation(),sk()},window.addEventListener("pointerdown",$r,{capture:!0}),(document.body??document.documentElement).appendChild(z),Ut(z),lk(),To=setInterval(()=>{Qe&&Qe.classList.toggle("ap-sdk-fab__main--active",Gn()||So())},200)}function xn(e){const t=Qe==null?void 0:Qe.querySelector("[data-ap-badge]");t&&(e>0?(t.textContent=String(e),t.style.display=""):t.style.display="none")}function Yc(){qn=!1,gt=!1,Po(),Hn(),To&&(clearInterval(To),To=null),$r&&(window.removeEventListener("pointerdown",$r,{capture:!0}),$r=null),z&&jt(z),z==null||z.remove(),z=null,Qe=null,Jt=null,Xt=null,Vt=null,Dn=null,Mn=null,Un=null,Eo=null,Ao=null,Co=null}async function Kc(e,t){try{if(e.type==="planning"){const r=await Og(t,e.id);return{capture:e,status:r.status,approved:r.status==="approved"}}const n=await gc(t,e.id);return{capture:e,status:n.status,approved:n.approved===!0}}catch{return{capture:e,status:"unavailable",approved:!1}}}function Qc(e){return e.filter(t=>!t.approved).length}async function el(e){const t=or();if(!e||t.length===0){xn(t.length);return}const n=await Promise.all(t.map(r=>Kc(r,e)));xn(Qc(n))}let F=null,Pr=null,Be=null,Nt=null;function is(){return F!==null}function Ur(){F&&jt(F),F==null||F.remove(),F=null,Pr==null||Pr(),Pr=null,Nt==null||Nt(),Nt=null,Be==null||Be.destroy(),Be=null}function tl(e,t,n,r,o,s,c,u,d){F&&Ur();const p={captureType:"task",submitting:!1,completedPicks:[],currentCtx:e,currentPickedEl:t,awaitingPick:!1},h=!n.backendUrl||!n.token;F=document.createElement("div"),F.className="ap-sdk-panel",F.setAttribute("data-ap-sdk","1"),F.setAttribute("role","dialog"),F.setAttribute("aria-modal","true"),F.setAttribute("aria-label","Capture to Agent Platform"),F.innerHTML=`
1548
+ `,document.body.appendChild(Be),qt(Be),Mo=Be.querySelector("[data-ap-recorder-counter]");const n=()=>{Li();const d=tr;Ke==null||Ke(),e(d)},r=()=>{Ke==null||Ke()};Be.querySelector("[data-ap-recorder-stop]").addEventListener("click",n),Be.querySelector("[data-ap-recorder-discard]").addEventListener("click",r);const o=d=>{if(Cr(d.target))return;const h=d.target;mi({action:"click",cssSelector:go(h),elementText:Ao(h),description:jb(Ao(h),h.tagName),capturedAt:new Date().toISOString()})},s=d=>{if(Cr(d.target))return;const h=d.target;if(!(h instanceof HTMLInputElement)&&!(h instanceof HTMLTextAreaElement)&&!(h instanceof HTMLSelectElement))return;const p=Dc(h),b=qg(h),m=b?"[redacted]":Wb(h);mi({action:"inputText",cssSelector:go(h),elementText:p,value:m,...b?{redacted:!0}:{},description:Mc(p,m,b),capturedAt:new Date().toISOString()})},a=()=>{const d=Math.round(window.scrollX),h=Math.round(window.scrollY);Ct?(Ct.scrollX=d,Ct.scrollY=h,Ct.description=ka(d,h)):Ct={action:"scroll",scrollX:d,scrollY:h,description:ka(d,h),capturedAt:new Date().toISOString()},Pt&&clearTimeout(Pt),Pt=setTimeout(()=>{Pt=null,Li()},qb)},u=d=>{if(d.key==="Escape"){r();return}if(Cr(d.target))return;const h=Bb(d);if(!h)return;const p=d.target instanceof Element?d.target:document.body,b=Gb(p);mi({action:"keypress",cssSelector:go(p),elementText:b,key:h,description:Zb(h,b),capturedAt:new Date().toISOString()})};document.addEventListener("click",o,{capture:!0}),document.addEventListener("change",s,{capture:!0}),window.addEventListener("scroll",a,{capture:!0,passive:!0}),document.addEventListener("keydown",u,{capture:!0}),Ke=()=>{document.removeEventListener("click",o,{capture:!0}),document.removeEventListener("change",s,{capture:!0}),window.removeEventListener("scroll",a,{capture:!0}),document.removeEventListener("keydown",u,{capture:!0}),Pt&&(clearTimeout(Pt),Pt=null),Ct=null,Be&&Ht(Be),Be==null||Be.remove(),Be=null,Mo=null,Ke=null}}function Xb(){Ke==null||Ke()}function vo(){return Ke!==null}const Vb="data-ap-sdk",Yb="ap-sdk-fab",_a="ap-sdk-fab--dragging",ns="ap-sdk-fab--open",Zc="ap-sdk-fab-pos",Uo="ap-sdk-fab--left-edge",Kb='<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 8V4H8"/><rect width="16" height="12" x="4" y="8" rx="2"/><path d="M2 14h2"/><path d="M20 14h2"/><path d="M15 13v2"/><path d="M9 13v2"/></svg>',Qb='<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m3 3 7.07 16.97 2.51-7.39 7.39-2.51L3 3z"/><path d="m13 13 6 6"/></svg>',ek='<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor"><circle cx="12" cy="12" r="8"/></svg>',tk='<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="8" y1="6" x2="21" y2="6"/><line x1="8" y1="12" x2="21" y2="12"/><line x1="8" y1="18" x2="21" y2="18"/><line x1="3" y1="6" x2="3.01" y2="6"/><line x1="3" y1="12" x2="3.01" y2="12"/><line x1="3" y1="18" x2="3.01" y2="18"/></svg>';let z=null,Qe=null,Yt=null,Kt=null,Qt=null,Dn=null,Mn=null,Un=null,yo=null,Lr=null,Xn=null,wo=null,xo=null,So=null,qc=0,Hc=0,Fc=0,Bc=0,qn=!1,_t=!1,zr=null,_n=null;function nk(){zr=e=>{if(!z){To();return}if(!qn){if(Math.hypot(e.clientX-Fc,e.clientY-Bc)<5)return;qn=!0,_t=!0,z.classList.add(_a)}rk(e.clientX-qc,e.clientY-Hc)},_n=()=>{if(!z){To();return}qn?(qn=!1,z.classList.remove(_a),z.style.transition="",ok(z.getBoundingClientRect())):z.style.transition="",To()},window.addEventListener("pointermove",zr),window.addEventListener("pointerup",_n),window.addEventListener("pointercancel",_n)}function To(){zr&&(window.removeEventListener("pointermove",zr),zr=null),_n&&(window.removeEventListener("pointerup",_n),window.removeEventListener("pointercancel",_n),_n=null)}function rk(e,t){if(!z)return;const n=z.offsetWidth||52,r=z.offsetHeight||52;z.style.top=`${Math.max(0,Math.min(t,window.innerHeight-r))}px`,z.style.left=`${Math.max(0,Math.min(e,window.innerWidth-n))}px`,z.style.bottom="auto",z.style.right="auto"}function ok(e){if(!z)return;const n=Math.max(16,Math.min(window.innerHeight-e.bottom,window.innerHeight-52-16)),r=e.left+e.width/2<window.innerWidth/2?"left":"right";z.style.top="auto",z.style.bottom=`${n}px`,r==="left"?(z.style.right="auto",z.style.left="16px",z.classList.add(Uo)):(z.style.left="auto",z.style.right="16px",z.classList.remove(Uo));try{localStorage.setItem(Zc,JSON.stringify({edge:r,bottom:n}))}catch{}}function ik(){if(z)try{const e=localStorage.getItem(Zc);if(!e)return;const t=JSON.parse(e);if(typeof t.bottom!="number"||t.edge!=="left"&&t.edge!=="right")return;const r=Math.max(16,Math.min(t.bottom,window.innerHeight-52-16));z.style.top="auto",z.style.bottom=`${r}px`,t.edge==="left"?(z.style.right="auto",z.style.left="16px",z.classList.add(Uo)):(z.style.left="auto",z.style.right="16px",z.classList.remove(Uo))}catch{}}function Hn(){z==null||z.classList.remove(ns),Xn&&(window.removeEventListener("pointerdown",Xn,{capture:!0}),Xn=null)}function sk(){z&&(z.classList.add(ns),Xn=e=>{!z||z.contains(e.target)||Hn()},requestAnimationFrame(()=>{Xn&&window.addEventListener("pointerdown",Xn,{capture:!0})}))}function po(e){return new DOMParser().parseFromString(e,"text/html").body.firstElementChild}function Gc(e,t,n){if(wo=e,xo=t,So=n,z)return;z=document.createElement("div"),z.className=Yb,z.setAttribute(Vb,"1"),Dn=document.createElement("div"),Dn.className="ap-sdk-fab__row";const r=document.createElement("span");r.className="ap-sdk-fab__label",r.textContent="View captures",Qt=document.createElement("button"),Qt.className="ap-sdk-fab__list ap-sdk-fab__sub",Qt.setAttribute("aria-label","My captures"),Qt.setAttribute("title","View my captures"),Qt.appendChild(po(tk)),Dn.appendChild(r),Dn.appendChild(Qt),Mn=document.createElement("div"),Mn.className="ap-sdk-fab__row";const o=document.createElement("span");o.className="ap-sdk-fab__label",o.textContent="Capture element",Yt=document.createElement("button"),Yt.className="ap-sdk-fab__capture ap-sdk-fab__sub",Yt.setAttribute("aria-label","Capture element"),Yt.setAttribute("title","Capture element to Agent Platform"),Yt.appendChild(po(Qb)),Mn.appendChild(o),Mn.appendChild(Yt),Un=document.createElement("div"),Un.className="ap-sdk-fab__row";const s=document.createElement("span");s.className="ap-sdk-fab__label",s.textContent="Record interaction",Kt=document.createElement("button"),Kt.className="ap-sdk-fab__record ap-sdk-fab__sub",Kt.setAttribute("aria-label","Record interaction"),Kt.setAttribute("title","Record a sequence of interactions"),Kt.appendChild(po(ek)),Un.appendChild(s),Un.appendChild(Kt),Qe=document.createElement("button"),Qe.className="ap-sdk-fab__main",Qe.setAttribute("aria-label","Agent Platform"),Qe.setAttribute("title","Agent Platform"),Qe.appendChild(po(Kb));const a=document.createElement("span");a.className="ap-sdk-fab__badge",a.setAttribute("data-ap-badge",""),a.style.display="none",Qe.appendChild(a),z.appendChild(Dn),z.appendChild(Mn),z.appendChild(Un),z.appendChild(Qe),Qe.addEventListener("click",u=>{if(_t){_t=!1;return}u.preventDefault(),u.stopPropagation(),z!=null&&z.classList.contains(ns)?Hn():sk()}),Yt.addEventListener("click",u=>{if(_t){_t=!1;return}u.preventDefault(),u.stopPropagation(),Hn(),!Gn()&&!vo()&&wo&&wo()}),Kt.addEventListener("click",u=>{if(_t){_t=!1;return}u.preventDefault(),u.stopPropagation(),Hn(),!Gn()&&!vo()&&xo&&xo()}),Qt.addEventListener("click",u=>{if(_t){_t=!1;return}u.preventDefault(),u.stopPropagation(),Hn(),So&&So()}),Lr=u=>{if(!z||!(z===u.target||z.contains(u.target)))return;const d=z.getBoundingClientRect();qc=u.clientX-d.left,Hc=u.clientY-d.top,Fc=u.clientX,Bc=u.clientY,qn=!1,_t=!1,z.style.transition="none",u.stopPropagation(),nk()},window.addEventListener("pointerdown",Lr,{capture:!0}),(document.body??document.documentElement).appendChild(z),qt(z),ik(),yo=setInterval(()=>{Qe&&Qe.classList.toggle("ap-sdk-fab__main--active",Gn()||vo())},200)}function Sn(e){const t=Qe==null?void 0:Qe.querySelector("[data-ap-badge]");t&&(e>0?(t.textContent=String(e),t.style.display=""):t.style.display="none")}function Wc(){qn=!1,_t=!1,To(),Hn(),yo&&(clearInterval(yo),yo=null),Lr&&(window.removeEventListener("pointerdown",Lr,{capture:!0}),Lr=null),z&&Ht(z),z==null||z.remove(),z=null,Qe=null,Yt=null,Kt=null,Qt=null,Dn=null,Mn=null,Un=null,wo=null,xo=null,So=null}async function Jc(e,t){try{if(e.type==="planning"){const r=await zg(t,e.id);return{capture:e,status:r.status,approved:r.status==="approved"}}const n=await dc(t,e.id);return{capture:e,status:n.status,approved:n.approved===!0}}catch{return{capture:e,status:"unavailable",approved:!1}}}function Xc(e){return e.filter(t=>!t.approved).length}async function Vc(e){const t=or();if(!e||t.length===0){Sn(t.length);return}const n=await Promise.all(t.map(r=>Jc(r,e)));Sn(Xc(n))}let H=null,We=null,Mt=null;function Ir(){return H!==null}function Or(){H&&Ht(H),H==null||H.remove(),H=null,Mt==null||Mt(),Mt=null,We==null||We.destroy(),We=null}function Yc(e,t,n,r,o,s,a,u,d,h){H&&Or();const p={captureType:"task",submitting:!1,completedPicks:[],currentCtx:e,currentPickedEl:t,awaitingPick:!1},b=!n.backendUrl||!n.token;H=document.createElement("div"),H.className="ap-sdk-panel",H.setAttribute("data-ap-sdk","1"),H.setAttribute("role","dialog"),H.setAttribute("aria-modal","true"),H.setAttribute("aria-label","Capture to Agent Platform"),H.innerHTML=`
1532
1549
  <div class="ap-sdk-panel__header">
1533
1550
  <span class="ap-sdk-panel__title">
1534
1551
  <span class="ap-sdk-panel__logo">AP</span>
@@ -1541,12 +1558,18 @@ ${n}${r?`
1541
1558
  </div>
1542
1559
  <div class="ap-sdk-pick-list" data-ap-pick-list style="display:none"></div>
1543
1560
  <div class="ap-sdk-panel__context" data-ap-context>
1544
- ${Sa(e)}
1561
+ ${va(e)}
1562
+ </div>
1563
+ <div class="ap-sdk-panel__pick-actions" data-ap-pick-actions>
1564
+ <button class="ap-sdk-panel__btn ap-sdk-panel__btn--ghost ap-sdk-panel__btn--select-parent" data-ap-select-parent type="button">
1565
+ ⬆ Select parent
1566
+ </button>
1567
+ ${d?`
1568
+ <button class="ap-sdk-panel__btn ap-sdk-panel__btn--ghost ap-sdk-panel__btn--reselect" data-ap-reselect type="button">
1569
+ ↻ Re-select
1570
+ </button>`:""}
1545
1571
  </div>
1546
- <button class="ap-sdk-panel__btn ap-sdk-panel__btn--ghost ap-sdk-panel__btn--select-parent" data-ap-select-parent type="button">
1547
- ⬆ Select parent
1548
- </button>
1549
- ${h?`
1572
+ ${b?`
1550
1573
  <div class="ap-sdk-credentials-section" data-ap-credentials>
1551
1574
  <p class="ap-sdk-credentials-heading">Credentials required</p>
1552
1575
  ${n.backendUrl?"":`
@@ -1586,41 +1609,41 @@ ${n}${r?`
1586
1609
  <button class="ap-sdk-panel__btn ap-sdk-panel__btn--primary" data-ap-submit>Submit</button>
1587
1610
  <button class="ap-sdk-panel__btn ap-sdk-panel__btn--ghost" data-ap-cancel>Cancel</button>
1588
1611
  </div>
1589
- `,F.addEventListener("wheel",Z=>{Z.stopPropagation()},{passive:!0}),F.addEventListener("touchmove",Z=>{Z.stopPropagation()},{passive:!0});const b=F.querySelector(".ap-sdk-panel__body"),m=Mb(b,n,(r==null?void 0:r.id)??null);document.body.appendChild(F),Be=$i(),p.currentPickedEl&&Be.update(p.currentPickedEl),Ut(F),Fi(F,Hi);const _=F.querySelector("[data-ap-close]"),w=F.querySelector("[data-ap-cancel]"),P=F.querySelector("[data-ap-submit]"),N=F.querySelector("[data-ap-note]"),te=F.querySelector("[data-ap-status]"),R=F.querySelectorAll("[data-ap-type]"),x=F.querySelector("[data-ap-pick-list]"),S=F.querySelector("[data-ap-context]"),C=F.querySelector("[data-ap-add-another]"),M=F.querySelector("[data-ap-select-parent]"),se=()=>{p.currentPickedEl&&(Be==null||Be.update(p.currentPickedEl))};window.addEventListener("scroll",se,{capture:!0,passive:!0}),window.addEventListener("resize",se),Nt=()=>{window.removeEventListener("scroll",se,!0),window.removeEventListener("resize",se)};const ve=Z=>{Z?(S.innerHTML=Sa(Z),N.disabled=!1,N.placeholder="Describe the task or planning session…",setTimeout(()=>N.focus(),50)):(S.innerHTML=`
1612
+ `,H.addEventListener("wheel",j=>{j.stopPropagation()},{passive:!0}),H.addEventListener("touchmove",j=>{j.stopPropagation()},{passive:!0});const m=H.querySelector(".ap-sdk-panel__body"),_=$b(m,n,(r==null?void 0:r.id)??null);document.body.appendChild(H),We=zi(),p.currentPickedEl&&We.update(p.currentPickedEl),qt(H),qi(H,Zi);const w=H.querySelector("[data-ap-close]"),C=H.querySelector("[data-ap-cancel]"),M=H.querySelector("[data-ap-submit]"),W=H.querySelector("[data-ap-note]"),P=H.querySelector("[data-ap-status]"),T=H.querySelectorAll("[data-ap-type]"),x=H.querySelector("[data-ap-pick-list]"),R=H.querySelector("[data-ap-context]"),D=H.querySelector("[data-ap-add-another]"),de=H.querySelector("[data-ap-pick-actions]"),_e=H.querySelector("[data-ap-select-parent]"),Ee=H.querySelector("[data-ap-reselect]"),qe=()=>{p.currentPickedEl&&(We==null||We.update(p.currentPickedEl))};window.addEventListener("scroll",qe,{capture:!0,passive:!0}),window.addEventListener("resize",qe),Mt=()=>{window.removeEventListener("scroll",qe,!0),window.removeEventListener("resize",qe)};const V=j=>{j?(R.innerHTML=va(j),W.disabled=!1,W.placeholder="Describe the task or planning session…",setTimeout(()=>W.focus(),50)):(R.innerHTML=`
1590
1613
  <div class="ap-sdk-panel__context-label">Next element</div>
1591
1614
  <div class="ap-sdk-panel__context-text ap-sdk-awaiting-pick">👆 Hover and click any element on the page</div>
1592
- `,N.disabled=!0,N.placeholder="Pick an element to continue…")},ze=()=>{if(p.completedPicks.length===0){x.style.display="none",x.innerHTML="";return}x.style.display="block",x.innerHTML=p.completedPicks.map((Z,X)=>`
1593
- <div class="ap-sdk-pick-entry" data-pick-index="${X}">
1615
+ `,W.disabled=!0,W.placeholder="Pick an element to continue…")},Ae=()=>{if(p.completedPicks.length===0){x.style.display="none",x.innerHTML="";return}x.style.display="block",x.innerHTML=p.completedPicks.map((j,Y)=>`
1616
+ <div class="ap-sdk-pick-entry" data-pick-index="${Y}">
1594
1617
  <div class="ap-sdk-pick-entry__header">
1595
- <span class="ap-sdk-pick-entry__number">${X+1}</span>
1596
- <span class="ap-sdk-pick-entry__element" title="${tt(Z.ctx.elementText??"")}">${tt(Z.ctx.elementText||"(no text)")}</span>
1597
- <button class="ap-sdk-pick-entry__remove" data-ap-remove="${X}" aria-label="Remove pick ${X+1}">×</button>
1618
+ <span class="ap-sdk-pick-entry__number">${Y+1}</span>
1619
+ <span class="ap-sdk-pick-entry__element" title="${nt(j.ctx.elementText??"")}">${nt(j.ctx.elementText||"(no text)")}</span>
1620
+ <button class="ap-sdk-pick-entry__remove" data-ap-remove="${Y}" aria-label="Remove pick ${Y+1}">×</button>
1598
1621
  </div>
1599
- <div class="ap-sdk-pick-entry__instruction">${tt(Z.instruction)}</div>
1622
+ <div class="ap-sdk-pick-entry__instruction">${nt(j.instruction)}</div>
1600
1623
  </div>
1601
- `).join(""),x.querySelectorAll("[data-ap-remove]").forEach(Z=>{Z.addEventListener("click",()=>{const X=parseInt(Z.dataset.apRemove,10);p.completedPicks.splice(X,1),ze()})})},Xe=()=>{if(!p.currentPickedEl){M.style.display="none";return}M.style.display="",M.disabled=!p.currentPickedEl.parentElement||p.awaitingPick},Y=(Z,X)=>{p.currentCtx=Z,p.currentPickedEl=X,ve(Z),Be==null||Be.update(X),Xe()};Xe(),M.addEventListener("click",()=>{var X;const Z=(X=p.currentPickedEl)==null?void 0:X.parentElement;Z&&Y(za(Z),Z)});const me=()=>{Ur(),d==null||d()};_.addEventListener("click",me),w.addEventListener("click",me),R.forEach(Z=>{Z.addEventListener("click",()=>{p.captureType=Z.dataset.apType,R.forEach(X=>X.classList.toggle("ap-sdk-active",X===Z))})});const Ve=Z=>{Z.key==="Escape"&&me()};document.addEventListener("keydown",Ve),Pr=()=>document.removeEventListener("keydown",Ve);const qt=F.querySelector("[data-ap-reconfigure]");if(c?qt.addEventListener("click",()=>{me(),c()}):qt.style.display="none",C&&u){const Z=()=>{C.disabled=!N.value.trim()||p.submitting||p.awaitingPick};N.addEventListener("input",Z),C.addEventListener("click",()=>{const X=N.value.trim();!X||p.awaitingPick||(p.completedPicks.push({ctx:p.currentCtx,instruction:X}),ze(),N.value="",p.awaitingPick=!0,C.disabled=!0,Xe(),ve(null),u((Ie,Oe)=>{p.awaitingPick=!1,Y(Ie,Oe),Z()}))})}P.addEventListener("click",async()=>{var be,on;if(p.submitting)return;let Z=n.backendUrl??"",X=n.token??"";if(h){const W=F==null?void 0:F.querySelector("[data-ap-backend-url]"),Ce=F==null?void 0:F.querySelector("[data-ap-token]");if(W&&(Z=W.value.trim()),Ce&&(X=Ce.value.trim()),!Z){Tr(te,"error","Backend URL is required.");return}if(!X){Tr(te,"error","API Token is required.");return}}const Ie=N.value.trim();if(!Ie){Tr(te,"error","Please enter an instruction.");return}p.submitting=!0,Ta(F,!0),Tr(te,null,""),P.textContent="Submitting…";const Oe={backendUrl:Z,token:X},_t=m.getOptions(),nt=[...p.completedPicks,{ctx:p.currentCtx,instruction:Ie}];try{let W=r;W||(W=await fc(Oe,o),s({backendUrl:Z,token:X}));let Ce,J,ke;if(nt.length===1)if(p.captureType==="task")Ce=(await Ti(Oe,W.id,Ie,p.currentCtx,_t)).id,J="task",ke=Ie.slice(0,120)||p.currentCtx.pageTitle||"Browser capture";else if(p.captureType==="planning"){let Pe=Du(Ie,{...p.currentCtx,ancestry:p.currentCtx.outerTree||p.currentCtx.ancestry});(be=p.currentCtx.innerTree)!=null&&be.trim()&&(Pe+=`
1624
+ `).join(""),x.querySelectorAll("[data-ap-remove]").forEach(j=>{j.addEventListener("click",()=>{const Y=parseInt(j.dataset.apRemove,10);p.completedPicks.splice(Y,1),Ae()})})},Me=()=>{if(!p.currentPickedEl){de.style.display="none";return}de.style.display="",_e.disabled=!p.currentPickedEl.parentElement||p.awaitingPick,Ee&&(Ee.disabled=p.awaitingPick)},pt=()=>{D&&(D.disabled=!W.value.trim()||p.submitting||p.awaitingPick)},Bt=(j,Y)=>{p.currentCtx=j,p.currentPickedEl=Y,V(j),We==null||We.update(Y),Me()};Me(),_e.addEventListener("click",()=>{var Y;const j=(Y=p.currentPickedEl)==null?void 0:Y.parentElement;j&&Bt(Ca(j),j)}),Ee&&d&&Ee.addEventListener("click",()=>{if(p.awaitingPick)return;const j=p.currentCtx,Y=p.currentPickedEl;p.awaitingPick=!0,Me(),pt(),V(null),d(($e,J)=>{p.awaitingPick=!1,Bt($e,J),pt()},()=>{p.awaitingPick=!1,Y&&Bt(j,Y),pt()})});const tt=()=>{Or(),h==null||h()};w.addEventListener("click",tt),C.addEventListener("click",tt),T.forEach(j=>{j.addEventListener("click",()=>{p.captureType=j.dataset.apType,T.forEach(Y=>Y.classList.toggle("ap-sdk-active",Y===j))})});const zt=H.querySelector("[data-ap-reconfigure]");a?zt.addEventListener("click",()=>{tt(),a()}):zt.style.display="none",D&&u&&(W.addEventListener("input",pt),D.addEventListener("click",()=>{const j=W.value.trim();!j||p.awaitingPick||(p.completedPicks.push({ctx:p.currentCtx,instruction:j}),Ae(),W.value="",p.awaitingPick=!0,D.disabled=!0,Me(),V(null),u((Y,$e)=>{p.awaitingPick=!1,Bt(Y,$e),pt()}))})),M.addEventListener("click",async()=>{var an,ce;if(p.submitting)return;let j=n.backendUrl??"",Y=n.token??"";if(b){const re=H==null?void 0:H.querySelector("[data-ap-backend-url]"),Ce=H==null?void 0:H.querySelector("[data-ap-token]");if(re&&(j=re.value.trim()),Ce&&(Y=Ce.value.trim()),!j){Sr(P,"error","Backend URL is required.");return}if(!Y){Sr(P,"error","API Token is required.");return}}const $e=W.value.trim();if(!$e){Sr(P,"error","Please enter an instruction.");return}p.submitting=!0,ya(H,!0),Sr(P,null,""),M.textContent="Submitting…";const J={backendUrl:j,token:Y},ht=_.getOptions(),ne=[...p.completedPicks,{ctx:p.currentCtx,instruction:$e}];try{let re=r;re||(re=await uc(J,o),s({backendUrl:j,token:Y}));let Ce,Pe,ee;if(ne.length===1)if(p.captureType==="task")Ce=(await wi(J,re.id,$e,p.currentCtx,ht)).id,Pe="task",ee=$e.slice(0,120)||p.currentCtx.pageTitle||"Browser capture";else if(p.captureType==="planning"){let Ye=Iu($e,{...p.currentCtx,ancestry:p.currentCtx.outerTree||p.currentCtx.ancestry});(an=p.currentCtx.innerTree)!=null&&an.trim()&&(Ye+=`
1602
1625
 
1603
1626
  Element tree:
1604
- ${p.currentCtx.innerTree}`),(on=p.currentCtx.interactionSteps)!=null&&on.length&&(Pe+=`
1627
+ ${p.currentCtx.innerTree}`),(ce=p.currentCtx.interactionSteps)!=null&&ce.length&&(Ye+=`
1605
1628
 
1606
1629
  Recorded steps:
1607
- ${Hc(p.currentCtx.interactionSteps)}`),Ce=(await Qs(Oe,W.id,Pe,_t)).id,J="planning",ke=Ie.slice(0,120)||p.currentCtx.pageTitle||"Planning session"}else Ce=(await Ks(Oe,W.id,Ie,p.currentCtx,_t)).id,J="automate",ke=Ie.slice(0,120)||p.currentCtx.pageTitle||"Browser automation";else{const Pe=pk(nt),ae=nt[0].instruction.slice(0,120)||nt[0].ctx.pageTitle||"Multi-element capture",we=nt.map(Pt=>Pt.instruction).filter(Boolean).join(`
1630
+ ${Uc(p.currentCtx.interactionSteps)}`),Ce=(await Xs(J,re.id,Ye,ht)).id,Pe="planning",ee=$e.slice(0,120)||p.currentCtx.pageTitle||"Planning session"}else Ce=(await Js(J,re.id,$e,p.currentCtx,ht)).id,Pe="automate",ee=$e.slice(0,120)||p.currentCtx.pageTitle||"Browser automation";else{const Ye=ck(ne),rt=ne[0].instruction.slice(0,120)||ne[0].ctx.pageTitle||"Multi-element capture",Re=ne.map(ot=>ot.instruction).filter(Boolean).join(`
1608
1631
 
1609
- `);p.captureType==="task"?(Ce=(await Ti(Oe,W.id,Pe,nt[0].ctx,_t,ae,hc,we)).id,J="task",ke=ae):p.captureType==="planning"?(Ce=(await Qs(Oe,W.id,Pe,_t)).id,J="planning",ke=ae):(Ce=(await Ks(Oe,W.id,Pe,nt[0].ctx,_t,ae,we)).id,J="automate",ke=ae)}if(qb({id:Ce,type:J,title:ke,backendUrl:Z,createdAt:new Date().toISOString()}),el(Oe).catch(()=>{}),h&&s({backendUrl:Z,token:X}),J==="automate"){me(),es(Ce,Oe,Z,ke,d);return}const sn=J==="task"?`${Z.replace(/\/+$/,"")}/tasks/${Ce}`:`${Z.replace(/\/+$/,"")}/planning/${Ce}`;hk(te,J,ke,sn,me),F.classList.add("ap-sdk-panel--success"),Nt==null||Nt(),Nt=null,Be==null||Be.hide(),p.submitting=!1}catch(W){Tr(te,"error",W instanceof Error?W.message:"An unexpected error occurred."),p.submitting=!1,Ta(F,!1),P.textContent="Submit"}}),setTimeout(()=>N.focus(),50)}const dk={click:"🖱",inputText:"⌨",scroll:"↕",keypress:"⌤"};function Sa(e){var t;return(t=e.interactionSteps)!=null&&t.length?`
1632
+ `);p.captureType==="task"?(Ce=(await wi(J,re.id,Ye,ne[0].ctx,ht,rt,lc,Re)).id,Pe="task",ee=rt):p.captureType==="planning"?(Ce=(await Xs(J,re.id,Ye,ht)).id,Pe="planning",ee=rt):(Ce=(await Js(J,re.id,Ye,ne[0].ctx,ht,rt,Re)).id,Pe="automate",ee=rt)}if(Mb({id:Ce,type:Pe,title:ee,backendUrl:j,createdAt:new Date().toISOString()}),Vc(J).catch(()=>{}),b&&s({backendUrl:j,token:Y}),Pe==="automate"){tt(),Ki(Ce,J,j,ee,h);return}const we=Pe==="task"?`${j.replace(/\/+$/,"")}/tasks/${Ce}`:`${j.replace(/\/+$/,"")}/planning/${Ce}`;lk(P,Pe,ee,we,tt),H.classList.add("ap-sdk-panel--success"),Mt==null||Mt(),Mt=null,We==null||We.hide(),p.submitting=!1}catch(re){Sr(P,"error",re instanceof Error?re.message:"An unexpected error occurred."),p.submitting=!1,ya(H,!1),M.textContent="Submit"}}),setTimeout(()=>W.focus(),50)}const ak={click:"🖱",inputText:"⌨",scroll:"↕",keypress:"⌤"};function va(e){var t;return(t=e.interactionSteps)!=null&&t.length?`
1610
1633
  <div class="ap-sdk-panel__context-label">Recorded steps (${e.interactionSteps.length})</div>
1611
1634
  <div class="ap-sdk-panel__context-steps">
1612
1635
  ${e.interactionSteps.map(n=>`
1613
1636
  <div class="ap-sdk-panel__context-step">
1614
- <span class="ap-sdk-panel__context-step-icon">${dk[n.action]}</span>
1615
- <span class="ap-sdk-panel__context-step-text">${tt(n.description)}</span>
1637
+ <span class="ap-sdk-panel__context-step-icon">${ak[n.action]}</span>
1638
+ <span class="ap-sdk-panel__context-step-text">${nt(n.description)}</span>
1616
1639
  </div>
1617
1640
  `).join("")}
1618
1641
  </div>
1619
1642
  `:`
1620
1643
  <div class="ap-sdk-panel__context-label">Captured element</div>
1621
- <div class="ap-sdk-panel__context-text" title="${tt(e.elementText??"")}">${tt(e.elementText||"(no text)")}</div>
1622
- ${e.cssSelector?`<div class="ap-sdk-panel__context-selector" title="${tt(e.cssSelector)}">${tt(e.cssSelector)}</div>`:""}
1623
- `}function pk(e){return e.map((t,n)=>{var o,s;const r=[`## Pick ${n+1}`,""];return(o=t.ctx.interactionSteps)!=null&&o.length?r.push("Recorded steps:",Hc(t.ctx.interactionSteps)):(r.push(`Element: ${t.ctx.elementText||"(no text)"}`),t.ctx.cssSelector&&r.push(`Selector: ${t.ctx.cssSelector}`),t.ctx.ancestry&&r.push(`Ancestry: ${t.ctx.ancestry}`)),r.push(`Page: ${t.ctx.pageTitle} (${t.ctx.pageUrl})`),(s=t.ctx.innerTree)!=null&&s.trim()&&r.push(`
1644
+ <div class="ap-sdk-panel__context-text" title="${nt(e.elementText??"")}">${nt(e.elementText||"(no text)")}</div>
1645
+ ${e.cssSelector?`<div class="ap-sdk-panel__context-selector" title="${nt(e.cssSelector)}">${nt(e.cssSelector)}</div>`:""}
1646
+ `}function ck(e){return e.map((t,n)=>{var o,s;const r=[`## Pick ${n+1}`,""];return(o=t.ctx.interactionSteps)!=null&&o.length?r.push("Recorded steps:",Uc(t.ctx.interactionSteps)):(r.push(`Element: ${t.ctx.elementText||"(no text)"}`),t.ctx.cssSelector&&r.push(`Selector: ${t.ctx.cssSelector}`),t.ctx.ancestry&&r.push(`Ancestry: ${t.ctx.ancestry}`)),r.push(`Page: ${t.ctx.pageTitle} (${t.ctx.pageUrl})`),(s=t.ctx.innerTree)!=null&&s.trim()&&r.push(`
1624
1647
  Element tree:
1625
1648
  ${t.ctx.innerTree}`),r.push("",`Instruction:
1626
1649
  ${t.instruction}`),r.join(`
@@ -1628,23 +1651,23 @@ ${t.instruction}`),r.join(`
1628
1651
 
1629
1652
  ---
1630
1653
 
1631
- `)}function Tr(e,t,n){if(!t){e.style.display="none",e.textContent="",e.innerHTML="";return}e.style.display="block",e.className=`ap-sdk-panel__status ap-sdk-panel__status--${t}`,e.textContent=n}function hk(e,t,n,r,o){const s=t==="task"?"Task":"Planning",c=t==="task"?"Task created successfully!":"Planning session created!",u=t==="task"?"View task →":"View planning session →",d=n.length>55?`${n.slice(0,52)}…`:n;e.style.display="block",e.className="ap-sdk-panel__status",e.innerHTML=`
1654
+ `)}function Sr(e,t,n){if(!t){e.style.display="none",e.textContent="",e.innerHTML="";return}e.style.display="block",e.className=`ap-sdk-panel__status ap-sdk-panel__status--${t}`,e.textContent=n}function lk(e,t,n,r,o){const s=t==="task"?"Task":"Planning",a=t==="task"?"Task created successfully!":"Planning session created!",u=t==="task"?"View task →":"View planning session →",d=n.length>55?`${n.slice(0,52)}…`:n;e.style.display="block",e.className="ap-sdk-panel__status",e.innerHTML=`
1632
1655
  <div class="ap-sdk-success-card">
1633
1656
  <svg class="ap-sdk-success-check" viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
1634
1657
  <circle class="ap-sdk-success-check__circle" cx="24" cy="24" r="22"/>
1635
1658
  <path class="ap-sdk-success-check__tick" d="M14 24l7 7 13-14"/>
1636
1659
  </svg>
1637
- <p class="ap-sdk-success-headline">${tt(c)}</p>
1660
+ <p class="ap-sdk-success-headline">${nt(a)}</p>
1638
1661
  <div class="ap-sdk-success-meta">
1639
- <span class="ap-sdk-list-item__badge ap-sdk-list-item__badge--${t}">${tt(s)}</span>
1640
- <span class="ap-sdk-success-title" title="${tt(n)}">${tt(d)}</span>
1662
+ <span class="ap-sdk-list-item__badge ap-sdk-list-item__badge--${t}">${nt(s)}</span>
1663
+ <span class="ap-sdk-success-title" title="${nt(n)}">${nt(d)}</span>
1641
1664
  </div>
1642
1665
  <div class="ap-sdk-success-actions">
1643
- <button class="ap-sdk-panel__btn ap-sdk-panel__btn--primary" data-ap-success-view>${tt(u)}</button>
1666
+ <button class="ap-sdk-panel__btn ap-sdk-panel__btn--primary" data-ap-success-view>${nt(u)}</button>
1644
1667
  <button class="ap-sdk-panel__btn ap-sdk-panel__btn--ghost" data-ap-success-close>Close</button>
1645
1668
  </div>
1646
1669
  </div>
1647
- `,e.querySelector("[data-ap-success-view]").addEventListener("click",()=>window.open(r,"_blank","noopener,noreferrer")),e.querySelector("[data-ap-success-close]").addEventListener("click",o)}function Ta(e,t){e.querySelectorAll("button, input, textarea, select").forEach(n=>{n.disabled=t})}function tt(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}let oe=null,Or=null;function nl(){return oe!==null}function Qt(){Or&&(document.removeEventListener("keydown",Or),Or=null),oe&&jt(oe),oe==null||oe.remove(),oe=null}function fk(e){return e==="task"?"Task":e==="planning"?"Planning":"Automate"}function gk(e){if(oe){Qt();return}oe=document.createElement("div"),oe.className="ap-sdk-panel",oe.setAttribute("data-ap-sdk","1"),oe.setAttribute("role","dialog"),oe.setAttribute("aria-modal","true"),oe.setAttribute("aria-label","My captures"),oe.addEventListener("wheel",t=>{t.stopPropagation()},{passive:!0}),oe.addEventListener("touchmove",t=>{t.stopPropagation()},{passive:!0}),oe.innerHTML=`
1670
+ `,e.querySelector("[data-ap-success-view]").addEventListener("click",()=>window.open(r,"_blank","noopener,noreferrer")),e.querySelector("[data-ap-success-close]").addEventListener("click",o)}function ya(e,t){e.querySelectorAll("button, input, textarea, select").forEach(n=>{n.disabled=t})}function nt(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}let se=null;function Kc(){return se!==null}function yn(){se&&Ht(se),se==null||se.remove(),se=null}function uk(e){return e==="task"?"Task":e==="planning"?"Planning":"Automate"}function dk(e){if(se){yn();return}se=document.createElement("div"),se.className="ap-sdk-panel",se.setAttribute("data-ap-sdk","1"),se.setAttribute("role","dialog"),se.setAttribute("aria-modal","true"),se.setAttribute("aria-label","My captures"),se.addEventListener("wheel",t=>{t.stopPropagation()},{passive:!0}),se.addEventListener("touchmove",t=>{t.stopPropagation()},{passive:!0}),se.innerHTML=`
1648
1671
  <div class="ap-sdk-panel__header">
1649
1672
  <span class="ap-sdk-panel__title">
1650
1673
  <span class="ap-sdk-panel__logo">AP</span>
@@ -1657,18 +1680,18 @@ ${t.instruction}`),r.join(`
1657
1680
  <button class="ap-sdk-panel__btn ap-sdk-panel__btn--secondary" data-ap-clear-history>Clear history</button>
1658
1681
  <button class="ap-sdk-panel__btn ap-sdk-panel__btn--secondary" data-ap-close-list>Close</button>
1659
1682
  </div>
1660
- `,document.body.appendChild(oe),Ut(oe),Fi(oe,Hi),Or=t=>{t.key==="Escape"&&Qt()},document.addEventListener("keydown",Or),oe.querySelector("[data-ap-close]").addEventListener("click",()=>{Qt()}),oe.querySelector("[data-ap-close-list]").addEventListener("click",()=>{Qt()}),oe.querySelector("[data-ap-clear-history]").addEventListener("click",()=>{Hb(),xn(0),Ea(e)}),Ea(e)}function Ea(e){if(!oe)return;const t=oe.querySelector("[data-ap-list-body]"),n=or();if(n.length===0){t.innerHTML='<p class="ap-sdk-list-empty">No captures yet. Use the capture button to get started.</p>';return}if(t.innerHTML=n.map(r=>`
1683
+ `,document.body.appendChild(se),qt(se),qi(se,Zi),se.querySelector("[data-ap-close]").addEventListener("click",()=>{yn()}),se.querySelector("[data-ap-close-list]").addEventListener("click",()=>{yn()}),se.querySelector("[data-ap-clear-history]").addEventListener("click",()=>{Ub(),Sn(0),wa(e)}),wa(e)}function wa(e){if(!se)return;const t=se.querySelector("[data-ap-list-body]"),n=or();if(n.length===0){t.innerHTML='<p class="ap-sdk-list-empty">No captures yet. Use the capture button to get started.</p>';return}if(t.innerHTML=n.map(r=>`
1661
1684
  <div class="ap-sdk-list-item">
1662
1685
  <div class="ap-sdk-list-item__row">
1663
- <span class="ap-sdk-list-item__badge ap-sdk-list-item__badge--${r.type}">${fk(r.type)}</span>
1664
- <span class="ap-sdk-list-item__title" title="${mo(r.title)}">${kk(r.title)}</span>
1686
+ <span class="ap-sdk-list-item__badge ap-sdk-list-item__badge--${r.type}">${uk(r.type)}</span>
1687
+ <span class="ap-sdk-list-item__title" title="${ho(r.title)}">${fk(r.title)}</span>
1665
1688
  </div>
1666
1689
  <div class="ap-sdk-list-item__row">
1667
- <span class="ap-sdk-status-badge" data-ap-status="${mo(r.id)}">${e?"…":"—"}</span>
1668
- ${r.type==="automate"&&e?`<button class="ap-sdk-list-item__link" data-ap-resume="${mo(r.id)}">Resume →</button>`:`<a class="ap-sdk-list-item__link" href="${mo(bk(r))}" target="_blank" rel="noopener noreferrer">View →</a>`}
1690
+ <span class="ap-sdk-status-badge" data-ap-status="${ho(r.id)}">${e?"…":"—"}</span>
1691
+ ${r.type==="automate"&&e?`<button class="ap-sdk-list-item__link" data-ap-resume="${ho(r.id)}">Resume →</button>`:`<a class="ap-sdk-list-item__link" href="${ho(hk(r))}" target="_blank" rel="noopener noreferrer">View →</a>`}
1669
1692
  </div>
1670
1693
  </div>
1671
- `).join(""),e){const r=e;Promise.all(n.map(o=>mk(o,r))).then(o=>{xn(Qc(o))}),t.querySelectorAll("[data-ap-resume]").forEach(o=>{o.addEventListener("click",()=>{const s=o.dataset.apResume,c=n.find(u=>u.id===s);c&&(Qt(),es(c.id,r,c.backendUrl,c.title,()=>{}))})})}}async function mk(e,t){const n=await Kc(e,t),r=oe==null?void 0:oe.querySelector(`[data-ap-status="${CSS.escape(e.id)}"]`);return r&&(r.textContent=n.status.replace(/_/g," "),r.className=`ap-sdk-status-badge ap-sdk-status-badge--${n.status.replace(/_/g,"-")}`),n}function bk(e){const t=e.backendUrl.replace(/\/+$/,"");return e.type==="planning"?`${t}/planning/${e.id}`:`${t}/tasks/${e.id}`}function mo(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function kk(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}const ss="ap-sdk-config";function _k(){try{const e=localStorage.getItem(ss);if(!e)return null;const t=JSON.parse(e);return t!=null&&t.backendUrl&&(t!=null&&t.token)&&(t!=null&&t.projectCode)?t:null}catch{return null}}function vk(e){localStorage.setItem(ss,JSON.stringify(e))}function yk(){localStorage.removeItem(ss)}let K=null;function Nn(){K&&jt(K),K==null||K.remove(),K=null}function wk(e){K&&Nn(),K=document.createElement("div"),K.className="ap-sdk-panel",K.setAttribute("data-ap-sdk","1"),K.setAttribute("role","dialog"),K.setAttribute("aria-modal","true"),K.setAttribute("aria-label","Connect to Agent Platform");const t=o=>{o.key==="Escape"&&(document.removeEventListener("keydown",t),Nn())};document.addEventListener("keydown",t),n("",""),document.body.appendChild(K),Ut(K);function n(o,s){if(!K)return;K.innerHTML=`
1694
+ `).join(""),e){const r=e;Promise.all(n.map(o=>pk(o,r))).then(o=>{Sn(Xc(o))}),t.querySelectorAll("[data-ap-resume]").forEach(o=>{o.addEventListener("click",()=>{const s=o.dataset.apResume,a=n.find(u=>u.id===s);a&&(yn(),Ki(a.id,r,a.backendUrl,a.title,()=>{}))})})}}async function pk(e,t){const n=await Jc(e,t),r=se==null?void 0:se.querySelector(`[data-ap-status="${CSS.escape(e.id)}"]`);return r&&(r.textContent=n.status.replace(/_/g," "),r.className=`ap-sdk-status-badge ap-sdk-status-badge--${n.status.replace(/_/g,"-")}`),n}function hk(e){const t=e.backendUrl.replace(/\/+$/,"");return e.type==="planning"?`${t}/planning/${e.id}`:`${t}/tasks/${e.id}`}function ho(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function fk(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}const rs="ap-sdk-config";function gk(){try{const e=localStorage.getItem(rs);if(!e)return null;const t=JSON.parse(e);return t!=null&&t.backendUrl&&(t!=null&&t.token)&&(t!=null&&t.projectCode)?t:null}catch{return null}}function mk(e){localStorage.setItem(rs,JSON.stringify(e))}function bk(){localStorage.removeItem(rs)}let K=null;function Tr(){K&&Ht(K),K==null||K.remove(),K=null}function kk(e){K&&Tr(),K=document.createElement("div"),K.className="ap-sdk-panel",K.setAttribute("data-ap-sdk","1"),K.setAttribute("role","dialog"),K.setAttribute("aria-modal","true"),K.setAttribute("aria-label","Connect to Agent Platform"),t("",""),document.body.appendChild(K),qt(K);function t(r,o){if(!K)return;K.innerHTML=`
1672
1695
  <div class="ap-sdk-panel__header">
1673
1696
  <span class="ap-sdk-panel__title">
1674
1697
  <span class="ap-sdk-panel__logo">AP</span>
@@ -1681,13 +1704,13 @@ ${t.instruction}`),r.join(`
1681
1704
  <label class="ap-sdk-panel__label" for="ap-sdk-cfg-url">Backend URL</label>
1682
1705
  <input id="ap-sdk-cfg-url" class="ap-sdk-panel__input" type="url"
1683
1706
  placeholder="https://your-platform.example.com"
1684
- value="${vi(o)}" autocomplete="off" data-ap-cfg-url />
1707
+ value="${bi(r)}" autocomplete="off" data-ap-cfg-url />
1685
1708
  </div>
1686
1709
  <div class="ap-sdk-panel__field">
1687
1710
  <label class="ap-sdk-panel__label" for="ap-sdk-cfg-token">API Token</label>
1688
1711
  <input id="ap-sdk-cfg-token" class="ap-sdk-panel__input" type="password"
1689
1712
  placeholder="Paste your personal API token"
1690
- value="${vi(s)}" autocomplete="off" data-ap-cfg-token />
1713
+ value="${bi(o)}" autocomplete="off" data-ap-cfg-token />
1691
1714
  </div>
1692
1715
  <p class="ap-sdk-config-hint">
1693
1716
  Create a token at <strong>Settings &rsaquo; API Tokens</strong> in Agent Platform.
@@ -1698,7 +1721,7 @@ ${t.instruction}`),r.join(`
1698
1721
  <button class="ap-sdk-panel__btn ap-sdk-panel__btn--primary" data-ap-connect>Connect</button>
1699
1722
  <button class="ap-sdk-panel__btn ap-sdk-panel__btn--secondary" data-ap-cancel>Cancel</button>
1700
1723
  </div>
1701
- `;const c=K.querySelector("[data-ap-cfg-url]"),u=K.querySelector("[data-ap-cfg-token]"),d=K.querySelector("[data-ap-cfg-status]"),p=K.querySelector("[data-ap-connect]");K.querySelector("[data-ap-close]").addEventListener("click",()=>{document.removeEventListener("keydown",t),Nn()}),K.querySelector("[data-ap-cancel]").addEventListener("click",()=>{document.removeEventListener("keydown",t),Nn()}),p.addEventListener("click",async()=>{const h=c.value.trim(),b=u.value.trim();if(!h){On(d,"error","Backend URL is required.");return}if(!b){On(d,"error","API Token is required.");return}p.disabled=!0,p.textContent="Connecting…",On(d,null,"");try{const _=await Dg({backendUrl:h,token:b});if(_.length===0){On(d,"error","No projects found — check your token permissions."),p.disabled=!1,p.textContent="Connect";return}r(h,b,_)}catch(m){On(d,"error",`Could not connect — ${m instanceof Error?m.message:"check URL and token"}`),p.disabled=!1,p.textContent="Connect"}}),setTimeout(()=>c.focus(),50)}function r(o,s,c){if(!K)return;const u=c.map(h=>`<option value="${vi(h.key)}">${Aa(h.name)} (${Aa(h.key)})</option>`).join("");K.innerHTML=`
1724
+ `;const s=K.querySelector("[data-ap-cfg-url]"),a=K.querySelector("[data-ap-cfg-token]"),u=K.querySelector("[data-ap-cfg-status]"),d=K.querySelector("[data-ap-connect]");K.querySelector("[data-ap-close]").addEventListener("click",()=>{Tr()}),K.querySelector("[data-ap-cancel]").addEventListener("click",()=>{Tr()}),d.addEventListener("click",async()=>{const h=s.value.trim(),p=a.value.trim();if(!h){On(u,"error","Backend URL is required.");return}if(!p){On(u,"error","API Token is required.");return}d.disabled=!0,d.textContent="Connecting…",On(u,null,"");try{const m=await Ig({backendUrl:h,token:p});if(m.length===0){On(u,"error","No projects found — check your token permissions."),d.disabled=!1,d.textContent="Connect";return}n(h,p,m)}catch(b){On(u,"error",`Could not connect — ${b instanceof Error?b.message:"check URL and token"}`),d.disabled=!1,d.textContent="Connect"}}),setTimeout(()=>s.focus(),50)}function n(r,o,s){if(!K)return;const a=s.map(h=>`<option value="${bi(h.key)}">${xa(h.name)} (${xa(h.key)})</option>`).join("");K.innerHTML=`
1702
1725
  <div class="ap-sdk-panel__header">
1703
1726
  <span class="ap-sdk-panel__title">
1704
1727
  <span class="ap-sdk-panel__logo">AP</span>
@@ -1711,7 +1734,7 @@ ${t.instruction}`),r.join(`
1711
1734
  <label class="ap-sdk-panel__label" for="ap-sdk-cfg-project">Project</label>
1712
1735
  <select id="ap-sdk-cfg-project" class="ap-sdk-panel__input" data-ap-cfg-project>
1713
1736
  <option value="">Select a project…</option>
1714
- ${u}
1737
+ ${a}
1715
1738
  </select>
1716
1739
  </div>
1717
1740
  </div>
@@ -1720,7 +1743,7 @@ ${t.instruction}`),r.join(`
1720
1743
  <button class="ap-sdk-panel__btn ap-sdk-panel__btn--primary" data-ap-save>Save</button>
1721
1744
  <button class="ap-sdk-panel__btn ap-sdk-panel__btn--secondary" data-ap-back>Back</button>
1722
1745
  </div>
1723
- `;const d=K.querySelector("[data-ap-cfg-project]"),p=K.querySelector("[data-ap-cfg-status]");K.querySelector("[data-ap-close]").addEventListener("click",()=>{document.removeEventListener("keydown",t),Nn()}),K.querySelector("[data-ap-back]").addEventListener("click",()=>n(o,s)),K.querySelector("[data-ap-save]").addEventListener("click",()=>{const h=d.value;if(!h){On(p,"error","Please select a project.");return}document.removeEventListener("keydown",t),Nn(),e({backendUrl:o,token:s,projectCode:h})})}}function On(e,t,n){if(!t){e.style.display="none",e.textContent="";return}e.style.display="block",e.className=`ap-sdk-panel__status ap-sdk-panel__status--${t}`,e.textContent=n}function vi(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Aa(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}let at=null,Fo=!1;function xk(){at==null||at.disconnect(),Array.from(document.body.querySelectorAll(':scope > [data-ap-sdk="1"]')).forEach(e=>document.body.appendChild(e)),at&&at.observe(document.body,{childList:!0}),Fo=!1}function rl(){at||(at=new MutationObserver(e=>{!e.some(n=>Array.from(n.addedNodes).some(r=>r instanceof Element&&r.getAttribute("data-ap-sdk")!=="1"))||Fo||(Fo=!0,queueMicrotask(xk))}),at.observe(document.body,{childList:!0}))}function Sk(){at==null||at.disconnect(),at=null,Fo=!1}const Tk={click:"🖱",inputText:"⌨",scroll:"↕",keypress:"⌤"};let Te=null,Rr=null,Yt=[];function Ro(){Te&&jt(Te),Te==null||Te.remove(),Te=null,Rr==null||Rr(),Rr=null,Yt=[]}function Ek(e,t,n){Te&&Ro(),Yt=[...e],Te=document.createElement("div"),Te.className="ap-sdk-panel ap-sdk-record-review",Te.setAttribute("data-ap-sdk","1"),Te.setAttribute("role","dialog"),Te.setAttribute("aria-modal","true"),Te.setAttribute("aria-label","Review recorded steps"),Te.innerHTML=`
1746
+ `;const u=K.querySelector("[data-ap-cfg-project]"),d=K.querySelector("[data-ap-cfg-status]");K.querySelector("[data-ap-close]").addEventListener("click",()=>{Tr()}),K.querySelector("[data-ap-back]").addEventListener("click",()=>t(r,o)),K.querySelector("[data-ap-save]").addEventListener("click",()=>{const h=u.value;if(!h){On(d,"error","Please select a project.");return}Tr(),e({backendUrl:r,token:o,projectCode:h})})}}function On(e,t,n){if(!t){e.style.display="none",e.textContent="";return}e.style.display="block",e.className=`ap-sdk-panel__status ap-sdk-panel__status--${t}`,e.textContent=n}function bi(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function xa(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}let lt=null,jo=!1;function _k(){lt==null||lt.disconnect(),Array.from(document.body.querySelectorAll(':scope > [data-ap-sdk="1"]')).forEach(e=>document.body.appendChild(e)),lt&&lt.observe(document.body,{childList:!0}),jo=!1}function Qc(){lt||(lt=new MutationObserver(e=>{!e.some(n=>Array.from(n.addedNodes).some(r=>r instanceof Element&&r.getAttribute("data-ap-sdk")!=="1"))||jo||(jo=!0,queueMicrotask(_k))}),lt.observe(document.body,{childList:!0}))}function vk(){lt==null||lt.disconnect(),lt=null,jo=!1}const yk={click:"🖱",inputText:"⌨",scroll:"↕",keypress:"⌤"};let Se=null,en=[];function Eo(){Se&&Ht(Se),Se==null||Se.remove(),Se=null,en=[]}function wk(e,t,n){Se&&Eo(),en=[...e],Se=document.createElement("div"),Se.className="ap-sdk-panel ap-sdk-record-review",Se.setAttribute("data-ap-sdk","1"),Se.setAttribute("role","dialog"),Se.setAttribute("aria-modal","true"),Se.setAttribute("aria-label","Review recorded steps"),Se.innerHTML=`
1724
1747
  <div class="ap-sdk-panel__header">
1725
1748
  <span class="ap-sdk-panel__title">
1726
1749
  <span class="ap-sdk-panel__logo">AP</span>
@@ -1735,11 +1758,11 @@ ${t.instruction}`),r.join(`
1735
1758
  <button class="ap-sdk-panel__btn ap-sdk-panel__btn--primary" data-ap-review-continue>Continue</button>
1736
1759
  <button class="ap-sdk-panel__btn ap-sdk-panel__btn--ghost" data-ap-review-cancel>Cancel</button>
1737
1760
  </div>
1738
- `,document.body.appendChild(Te),Ut(Te);const r=Te.querySelector("[data-ap-review-list]"),o=Te.querySelector("[data-ap-review-continue]"),s=()=>{if(Yt.length===0){r.innerHTML='<p class="ap-sdk-list-empty">No steps recorded.</p>',o.disabled=!0;return}o.disabled=!1,r.innerHTML=Yt.map((d,p)=>`
1739
- <div class="ap-sdk-record-step" data-step-index="${p}">
1740
- <span class="ap-sdk-record-step__icon">${Tk[d.action]}</span>
1741
- ${d.action==="inputText"&&!d.redacted?`<input class="ap-sdk-record-step__input" type="text" value="${Ak(d.value??"")}" data-ap-step-value />`:`<span class="ap-sdk-record-step__description">${ol(d.description)}</span>`}
1742
- <button class="ap-sdk-record-step__remove" data-ap-step-remove="${p}" aria-label="Remove step ${p+1}">✕</button>
1761
+ `,document.body.appendChild(Se),qt(Se);const r=Se.querySelector("[data-ap-review-list]"),o=Se.querySelector("[data-ap-review-continue]"),s=()=>{if(en.length===0){r.innerHTML='<p class="ap-sdk-list-empty">No steps recorded.</p>',o.disabled=!0;return}o.disabled=!1,r.innerHTML=en.map((u,d)=>`
1762
+ <div class="ap-sdk-record-step" data-step-index="${d}">
1763
+ <span class="ap-sdk-record-step__icon">${yk[u.action]}</span>
1764
+ ${u.action==="inputText"&&!u.redacted?`<input class="ap-sdk-record-step__input" type="text" value="${xk(u.value??"")}" data-ap-step-value />`:`<span class="ap-sdk-record-step__description">${el(u.description)}</span>`}
1765
+ <button class="ap-sdk-record-step__remove" data-ap-step-remove="${d}" aria-label="Remove step ${d+1}">✕</button>
1743
1766
  </div>
1744
- `).join(""),r.querySelectorAll("[data-ap-step-remove]").forEach(d=>{d.addEventListener("click",()=>{const p=parseInt(d.dataset.apStepRemove,10);Yt.splice(p,1),s()})}),r.querySelectorAll("[data-ap-step-value]").forEach(d=>{const p=d.closest("[data-step-index]"),h=parseInt(p.dataset.stepIndex,10);d.addEventListener("input",()=>{const b=Yt[h];b.value=d.value,b.description=qc(b.elementText??"",d.value,!1)})})};s();const c=()=>{Ro()};Te.querySelector("[data-ap-review-close]").addEventListener("click",c),Te.querySelector("[data-ap-review-cancel]").addEventListener("click",c),o.addEventListener("click",()=>{if(Yt.length===0)return;const d=Yt,p={...Ra(),pageUrl:window.location.href,pageTitle:document.title,interactionSteps:d};Ro(),t(p)});const u=d=>{d.key==="Escape"&&c()};document.addEventListener("keydown",u),Rr=()=>document.removeEventListener("keydown",u)}function ol(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Ak(e){return ol(e)}let j=null,Bo=null,Go=null,Wo=null;function as(e,t,n){Bo=e,Go=t,Wo=n,Vc(e,t,n)}const il="#agent-platform-web-sdk",sl="ap-sdk-fab-unlocked";let vn=null;function al(){try{if(localStorage.getItem(sl)==="1")return!0}catch{}return window.location.hash===il}function Ca(){try{localStorage.setItem(sl,"1")}catch{}}async function cl(e){if(jr(),!(j&&j.projectCode===e.projectCode&&j.backendUrl===(e.backendUrl??null)&&j.token===(e.token??null))){if(j={projectCode:e.projectCode,backendUrl:e.backendUrl??null,token:e.token??null,project:null,resolvingProject:!1},as(()=>ll(),()=>Pk(),()=>ls()),xn(or().length),j.backendUrl&&j.token){const t=j.backendUrl,n=j.token;await fl(),el({backendUrl:t,token:n}).catch(()=>{});const r=em();r&&es(r.taskId,{backendUrl:t,token:n},r.backendUrl,r.title,()=>{})}rl()}}async function cs(e,t){if(!j)throw new Error("AgentPlatformSDK: call init() first.");j.backendUrl=e,j.token=t,j.project=null,await fl()}function ll(){if(!j)throw new Error("AgentPlatformSDK: call init() first.");Gn()||(jr(),Ps(async(e,t)=>{nl()&&Qt(),tl(e,t,{backendUrl:j.backendUrl,token:j.token},j.project,j.projectCode,async n=>{await cs(n.backendUrl,n.token)},Sn,n=>{Ps((r,o)=>{is()&&n(r,o)},()=>{ul()})},()=>{Gn()&&Ni()})},()=>{}))}function Ck(){Ni()}function Pk(){if(!j)throw new Error("AgentPlatformSDK: call init() first.");So()||(jr(),Kb(e=>{Ek(e,t=>{tl(t,null,{backendUrl:j.backendUrl,token:j.token},j.project,j.projectCode,async n=>{await cs(n.backendUrl,n.token)},Sn,void 0,()=>{})})}))}function ul(){is()&&Ur()}function Rk(){return Gn()}function dl(){Sk(),vn&&(window.removeEventListener("hashchange",vn),vn=null),Ni(),Qb(),Ro(),Ur(),Qt(),Yc(),Bo=null,Go=null,Wo=null,j=null}function pl(){if(typeof window>"u"||typeof document>"u")return;jr();const e=_k(),t=()=>{e?hl(e).catch(console.error):(as(()=>Sn(),()=>Sn(),()=>ls()),xn(or().length),rl())};if(al()){Ca(),t();return}vn=()=>{window.location.hash===il&&(Ca(),window.removeEventListener("hashchange",vn),vn=null,t())},window.addEventListener("hashchange",vn)}function Lk(){Bo&&Go&&Wo&&Vc(Bo,Go,Wo)}function zk(){Yc()}function Sn(){wk(e=>{vk(e),hl(e).catch(console.error)})}function Ik(){yk(),dl(),jr(),al()&&(as(()=>Sn(),()=>Sn(),()=>ls()),xn(or().length))}async function hl(e){await cl({projectCode:e.projectCode,backendUrl:e.backendUrl,token:e.token})}function ls(){if(nl()){Qt();return}is()&&Ur();const e=j!=null&&j.backendUrl&&(j!=null&&j.token)?{backendUrl:j.backendUrl,token:j.token}:null;gk(e)}async function fl(){if(!(!j||!j.backendUrl||!j.token||j.project||j.resolvingProject)){j.resolvingProject=!0;try{j.project=await fc({backendUrl:j.backendUrl,token:j.token},j.projectCode)}catch{}finally{j&&(j.resolvingProject=!1)}}}pl();exports.activateElementPicker=ll;exports.autoInit=pl;exports.clearConfig=Ik;exports.closePanelIfOpen=ul;exports.configure=Sn;exports.deactivateElementPicker=Ck;exports.destroy=dl;exports.hideFab=zk;exports.init=cl;exports.isPickerRunning=Rk;exports.showFab=Lk;exports.updateCredentials=cs;
1767
+ `).join(""),r.querySelectorAll("[data-ap-step-remove]").forEach(u=>{u.addEventListener("click",()=>{const d=parseInt(u.dataset.apStepRemove,10);en.splice(d,1),s()})}),r.querySelectorAll("[data-ap-step-value]").forEach(u=>{const d=u.closest("[data-step-index]"),h=parseInt(d.dataset.stepIndex,10);u.addEventListener("input",()=>{const p=en[h];p.value=u.value,p.description=Mc(p.elementText??"",u.value,!1)})})};s();const a=()=>{Eo()};Se.querySelector("[data-ap-review-close]").addEventListener("click",a),Se.querySelector("[data-ap-review-cancel]").addEventListener("click",a),o.addEventListener("click",()=>{if(en.length===0)return;const u=en,d={...Ea(),pageUrl:window.location.href,pageTitle:document.title,interactionSteps:u};Eo(),t(d)})}function el(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function xk(e){return el(e)}let Z=null,Zo=null,qo=null,Ho=null;function os(e,t,n){Zo=e,qo=t,Ho=n,Gc(e,t,n)}const tl="#agent-platform-web-sdk",nl="ap-sdk-fab-unlocked";let vn=null;function rl(){try{if(localStorage.getItem(nl)==="1")return!0}catch{}return window.location.hash===tl}function Sa(){try{localStorage.setItem(nl,"1")}catch{}}async function ol(e){if(Dr(),!(Z&&Z.projectCode===e.projectCode&&Z.backendUrl===(e.backendUrl??null)&&Z.token===(e.token??null))){if(Z={projectCode:e.projectCode,backendUrl:e.backendUrl??null,token:e.token??null,project:null,resolvingProject:!1},os(()=>il(),()=>Tk(),()=>ss()),Sn(or().length),Z.backendUrl&&Z.token){const t=Z.backendUrl,n=Z.token;await ul(),Vc({backendUrl:t,token:n}).catch(()=>{});const r=Vg();r&&Ki(r.taskId,{backendUrl:t,token:n},r.backendUrl,r.title,()=>{})}Qc()}}async function is(e,t){if(!Z)throw new Error("AgentPlatformSDK: call init() first.");Z.backendUrl=e,Z.token=t,Z.project=null,await ul()}function il(){if(!Z)throw new Error("AgentPlatformSDK: call init() first.");Gn()||(Dr(),si(async(e,t)=>{Kc()&&yn(),Yc(e,t,{backendUrl:Z.backendUrl,token:Z.token},Z.project,Z.projectCode,async n=>{await is(n.backendUrl,n.token)},Tn,n=>{si((r,o)=>{Ir()&&n(r,o)},()=>{sl()})},(n,r)=>{si((o,s)=>{Ir()&&n(o,s)},()=>{Ir()&&r()})},()=>{Gn()&&Ii()})},()=>{}))}function Sk(){Ii()}function Tk(){if(!Z)throw new Error("AgentPlatformSDK: call init() first.");vo()||(Dr(),Jb(e=>{wk(e,t=>{Yc(t,null,{backendUrl:Z.backendUrl,token:Z.token},Z.project,Z.projectCode,async n=>{await is(n.backendUrl,n.token)},Tn,void 0,void 0,()=>{})})}))}function sl(){Ir()&&Or()}function Ek(){return Gn()}function al(){vk(),vn&&(window.removeEventListener("hashchange",vn),vn=null),Ii(),Xb(),Eo(),Or(),yn(),Wc(),Zo=null,qo=null,Ho=null,Z=null}function cl(){if(typeof window>"u"||typeof document>"u")return;Dr();const e=gk(),t=()=>{e?ll(e).catch(console.error):(os(()=>Tn(),()=>Tn(),()=>ss()),Sn(or().length),Qc())};if(rl()){Sa(),t();return}vn=()=>{window.location.hash===tl&&(Sa(),window.removeEventListener("hashchange",vn),vn=null,t())},window.addEventListener("hashchange",vn)}function Ak(){Zo&&qo&&Ho&&Gc(Zo,qo,Ho)}function Ck(){Wc()}function Tn(){kk(e=>{mk(e),ll(e).catch(console.error)})}function Pk(){bk(),al(),Dr(),rl()&&(os(()=>Tn(),()=>Tn(),()=>ss()),Sn(or().length))}async function ll(e){await ol({projectCode:e.projectCode,backendUrl:e.backendUrl,token:e.token})}function ss(){if(Kc()){yn();return}Ir()&&Or();const e=Z!=null&&Z.backendUrl&&(Z!=null&&Z.token)?{backendUrl:Z.backendUrl,token:Z.token}:null;dk(e)}async function ul(){if(!(!Z||!Z.backendUrl||!Z.token||Z.project||Z.resolvingProject)){Z.resolvingProject=!0;try{Z.project=await uc({backendUrl:Z.backendUrl,token:Z.token},Z.projectCode)}catch{}finally{Z&&(Z.resolvingProject=!1)}}}cl();exports.activateElementPicker=il;exports.autoInit=cl;exports.clearConfig=Pk;exports.closePanelIfOpen=sl;exports.configure=Tn;exports.deactivateElementPicker=Sk;exports.destroy=al;exports.hideFab=Ck;exports.init=ol;exports.isPickerRunning=Ek;exports.showFab=Ak;exports.updateCredentials=is;
1745
1768
  //# sourceMappingURL=web-sdk.cjs.map