browsentic 0.7.5 → 0.7.6
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/cli.js +1577 -1471
- package/dist/daemon-main.js +638 -402
- package/extension/chrome-mv3/assets/globals-C_terveQ.css +2 -0
- package/extension/chrome-mv3/background.js +1 -1
- package/extension/chrome-mv3/chunks/{mic-permission-D_lH6TNJ.js → mic-permission-CSbmGjqa.js} +1 -1
- package/extension/chrome-mv3/chunks/popup-BipbcD_A.js +1 -0
- package/extension/chrome-mv3/chunks/sidepanel-Bc7DvbkU.js +11 -0
- package/extension/chrome-mv3/chunks/use-voice-composer-CaiZfFT7.js +169 -0
- package/extension/chrome-mv3/manifest.json +1 -1
- package/extension/chrome-mv3/mic-permission.html +3 -3
- package/extension/chrome-mv3/popup.html +4 -4
- package/extension/chrome-mv3/sidepanel.html +4 -4
- package/package.json +1 -1
- package/extension/chrome-mv3/assets/globals-Drv30qJX.css +0 -2
- package/extension/chrome-mv3/chunks/popup-D1kmahbZ.js +0 -1
- package/extension/chrome-mv3/chunks/sidepanel-CREhtYV6.js +0 -11
- package/extension/chrome-mv3/chunks/use-voice-composer-DqX_NzK_.js +0 -169
- /package/extension/chrome-mv3/chunks/{globals-Bis7MDt7.js → globals-CzB6G5FK.js} +0 -0
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import{S as e,_ as t,b as n,l as r,m as i,o as a,p as o,u as s,v as c,x as l}from"./globals-CzB6G5FK.js";var u=t(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),d=t(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),f=t(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),p=t(`link-2-off`,[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7`,key:`10o201`}],[`path`,{d:`M15 7h2a5 5 0 0 1 4 8`,key:`1d3206`}],[`line`,{x1:`8`,x2:`12`,y1:`12`,y2:`12`,key:`rvw6j4`}],[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}]]),m=t(`link-2`,[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]]),h=t(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),g=t(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),_=t(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),v=t(`shield-check`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),y=t(`triangle-alert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),b=e(l(),1),x=o(),S={claude:{viewBox:`0 0 24 24`,path:`m4.7144 15.9555 4.7174-2.6471.079-.2307-.079-.1275h-.2307l-.7893-.0486-2.6956-.0729-2.3375-.0971-2.2646-.1214-.5707-.1215-.5343-.7042.0546-.3522.4797-.3218.686.0608 1.5179.1032 2.2767.1578 1.6514.0972 2.4468.255h.3886l.0546-.1579-.1336-.0971-.1032-.0972L6.973 9.8356l-2.55-1.6879-1.3356-.9714-.7225-.4918-.3643-.4614-.1578-1.0078.6557-.7225.8803.0607.2246.0607.8925.686 1.9064 1.4754 2.4893 1.8336.3643.3035.1457-.1032.0182-.0728-.164-.2733-1.3539-2.4467-1.445-2.4893-.6435-1.032-.17-.6194c-.0607-.255-.1032-.4674-.1032-.7285L6.287.1335 6.6997 0l.9957.1336.419.3642.6192 1.4147 1.0018 2.2282 1.5543 3.0296.4553.8985.2429.8318.091.255h.1579v-.1457l.1275-1.706.2368-2.0947.2307-2.6957.0789-.7589.3764-.9107.7468-.4918.5828.2793.4797.686-.0668.4433-.2853 1.8517-.5586 2.9021-.3643 1.9429h.2125l.2429-.2429.9835-1.3053 1.6514-2.0643.7286-.8196.85-.9046.5464-.4311h1.0321l.759 1.1293-.34 1.1657-1.0625 1.3478-.8804 1.1414-1.2628 1.7-.7893 1.36.0729.1093.1882-.0183 2.8535-.607 1.5421-.2794 1.8396-.3157.8318.3886.091.3946-.3278.8075-1.967.4857-2.3072.4614-3.4364.8136-.0425.0304.0486.0607 1.5482.1457.6618.0364h1.621l3.0175.2247.7892.522.4736.6376-.079.4857-1.2142.6193-1.6393-.3886-3.825-.9107-1.3113-.3279h-.1822v.1093l1.0929 1.0686 2.0035 1.8092 2.5075 2.3314.1275.5768-.3218.4554-.34-.0486-2.2039-1.6575-.85-.7468-1.9246-1.621h-.1275v.17l.4432.6496 2.3436 3.5214.1214 1.0807-.17.3521-.6071.2125-.6679-.1214-1.3721-1.9246L14.38 17.959l-1.1414-1.9428-.1397.079-.674 7.2552-.3156.3703-.7286.2793-.6071-.4614-.3218-.7468.3218-1.4753.3886-1.9246.3157-1.53.2853-1.9004.17-.6314-.0121-.0425-.1397.0182-1.4328 1.9672-2.1796 2.9446-1.7243 1.8456-.4128.164-.7164-.3704.0667-.6618.4008-.5889 2.386-3.0357 1.4389-1.882.929-1.0868-.0062-.1579h-.0546l-6.3385 4.1164-1.1293.1457-.4857-.4554.0608-.7467.2307-.2429 1.9064-1.3114Z`},codex:{viewBox:`1.68 1.75 16.65 16.5`,path:`M11.248 18.25q-.825 0-1.568-.314a4.3 4.3 0 0 1-1.32-.874 4 4 0 0 1-1.304.214 4 4 0 0 1-2.046-.544 4.27 4.27 0 0 1-1.518-1.485 4 4 0 0 1-.56-2.095q0-.48.131-1.04A4.4 4.4 0 0 1 2.04 10.71a4.07 4.07 0 0 1 .017-3.4 4.2 4.2 0 0 1 1.056-1.418 3.8 3.8 0 0 1 1.6-.842 3.9 3.9 0 0 1 .76-1.683q.593-.759 1.451-1.188a4.04 4.04 0 0 1 1.832-.429q.825 0 1.567.313.742.314 1.32.875a4 4 0 0 1 1.304-.215q1.106 0 2.046.545a4.14 4.14 0 0 1 1.501 1.485q.578.941.578 2.095 0 .48-.132 1.04.66.61 1.023 1.419.363.792.363 1.666 0 .892-.38 1.717a4.3 4.3 0 0 1-1.072 1.435 3.8 3.8 0 0 1-1.584.825 3.8 3.8 0 0 1-.775 1.683 4.06 4.06 0 0 1-1.436 1.188 4.04 4.04 0 0 1-1.832.429m-4.076-2.062q.825 0 1.435-.347l3.103-1.782a.36.36 0 0 0 .164-.313v-1.42L7.881 14.62a.67.67 0 0 1-.726 0l-3.118-1.798a.5.5 0 0 1-.017.115v.198q0 .841.396 1.551.413.693 1.139 1.089a3.2 3.2 0 0 0 1.617.412m.165-2.69a.4.4 0 0 0 .181.05q.083 0 .165-.05l1.238-.71-3.977-2.31a.7.7 0 0 1-.363-.643v-3.58q-.825.362-1.32 1.122a2.9 2.9 0 0 0-.495 1.65q0 .809.413 1.55.412.743 1.072 1.123zm3.91 3.663q.875 0 1.585-.396a2.96 2.96 0 0 0 1.534-2.64v-3.564a.32.32 0 0 0-.165-.297l-1.254-.726v4.604a.7.7 0 0 1-.363.643l-3.119 1.799a3 3 0 0 0 1.783.577m.627-6.039V8.878L10.01 7.822 8.129 8.878v2.244l1.881 1.056zM7.057 5.859a.7.7 0 0 1 .363-.644l3.119-1.798a3 3 0 0 0-1.782-.578q-.874 0-1.584.396A2.96 2.96 0 0 0 6.05 4.324a3.07 3.07 0 0 0-.396 1.551v3.547q0 .199.165.314l1.237.726zm8.383 7.887q.825-.364 1.303-1.123.495-.758.495-1.65a3.15 3.15 0 0 0-.412-1.55q-.413-.743-1.073-1.123l-3.086-1.782q-.099-.065-.181-.049a.3.3 0 0 0-.165.05l-1.238.692 3.993 2.327a.6.6 0 0 1 .264.264.64.64 0 0 1 .1.363zm-3.317-8.382a.63.63 0 0 1 .726 0l3.135 1.831v-.297q0-.792-.396-1.501a2.86 2.86 0 0 0-1.105-1.155q-.71-.43-1.65-.43-.825 0-1.436.347L8.294 5.941a.36.36 0 0 0-.165.314v1.418z`},antigravity:{viewBox:`0 0 125 113`,path:`M89.6992 93.695C94.3659 97.195 101.366 94.8617 94.9492 88.445C75.6992 69.7783 79.7825 18.445 55.8659 18.445C31.9492 18.445 36.0325 69.7783 16.7825 88.445C9.78251 95.445 17.3658 97.195 22.0325 93.695C40.1159 81.445 38.9492 59.8617 55.8659 59.8617C72.7825 59.8617 71.6159 81.445 89.6992 93.695Z`},vibe:{viewBox:`0 0 24 24`,path:`M17.143 3.429v3.428h-3.429v3.429h-3.428V6.857H6.857V3.43H3.43v13.714H0v3.428h10.286v-3.428H6.857v-3.429h3.429v3.429h3.429v-3.429h3.428v3.429h-3.428v3.428H24v-3.428h-3.43V3.429z`},grok:{viewBox:`0 0 466.04 516.93`,path:`M0.12 182.71L234.14 516.92H338.15L104.13 182.71ZM0 516.92H104.08L156.08 442.67L104.04 368.34ZM466.04 0H361.96L182.1 256.86L234.15 331.18ZM380.78 516.92H466.04V37.16L380.78 158.92Z`},cursor:{viewBox:`0 0 24 24`,path:`M11.925 24l10.425-6-10.425-6L1.5 18l10.425 6zM22.35 18V6L11.925 0v12l10.425 6zM11.925 12V0L1.5 6v12l10.425-6z`},qwen:{viewBox:`0 0 24 24`,path:`M23.919 14.545 20.817 9.17l1.47-2.544a.56.56 0 0 0 0-.566l-1.633-2.83a.57.57 0 0 0-.49-.283h-6.207L12.487.402a.57.57 0 0 0-.49-.284H8.732a.56.56 0 0 0-.49.284L5.139 5.775h-2.94a.56.56 0 0 0-.49.284L.077 8.887a.56.56 0 0 0 0 .567L3.18 14.83l-1.47 2.545a.56.56 0 0 0 0 .566l1.634 2.83a.57.57 0 0 0 .49.283h6.205l1.47 2.545a.57.57 0 0 0 .49.284h3.266a.57.57 0 0 0 .49-.284l3.104-5.375h2.94a.57.57 0 0 0 .49-.283l1.634-2.828a.55.55 0 0 0-.004-.568M8.733.686l1.634 2.828-1.634 2.828H21.8L20.164 9.17H7.425L5.63 6.06Zm1.306 19.801-6.205-.002 1.634-2.83h3.265L2.201 6.344h3.267q3.182 5.517 6.367 11.032zm10.124-5.66L18.53 12l-6.532 11.315-1.634-2.83c2.129-3.673 4.25-7.351 6.373-11.028h3.592l3.102 5.374z`},opencode:{viewBox:`128 96 256 320`,path:`M384 416H128V96H384V416ZM320 160H192V352H320V160Z`}};function C({kind:e,className:t}){let n=S[e];return(0,x.jsx)(`svg`,{viewBox:n.viewBox,fill:`currentColor`,className:i(`size-3.5 shrink-0`,t),"aria-hidden":!0,children:(0,x.jsx)(`path`,{d:n.path})})}function w({className:e,type:t,...n}){return(0,x.jsx)(`input`,{type:t,"data-slot":`input`,className:i(`flex h-9 w-full min-w-0 rounded-lg border border-line-strong bg-ground/60 px-3 py-1 text-sm text-ink outline-none transition-colors`,`placeholder:text-ink-faint selection:bg-brand/30 selection:text-ink`,`focus-visible:border-brand/55 focus-visible:bg-ground/80`,`disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-45`,`aria-invalid:border-destructive/60`,e),...n})}function T({value:e,ids:t,suggested:n,pinned:r,disabled:a,onModel:o}){let[s,c]=(0,b.useState)(!1),[l,u]=(0,b.useState)(``),f=l.trim().toLowerCase(),p=e=>e.toLowerCase().includes(f),m=n.filter(p),h=t.filter(e=>!n.includes(e)&&p(e)),g=t=>{c(!1),u(``),t!==e&&o(t)};return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`button`,{type:`button`,onClick:()=>c(!s),disabled:a,"aria-expanded":s,className:i(`flex h-6 min-w-0 flex-1 items-center justify-between gap-1.5 rounded-md border border-line bg-surface/60 px-2 font-mono text-[10px] text-ink-dim transition-colors`,`enabled:hover:border-line-strong enabled:hover:text-ink focus-visible:ring-2 focus-visible:ring-brand/50 focus-visible:outline-none`,`disabled:cursor-not-allowed disabled:opacity-50`),children:[(0,x.jsx)(`span`,{className:`min-w-0 truncate`,children:e??`Default`}),(0,x.jsx)(d,{className:i(`size-3 shrink-0 opacity-60 transition-transform`,s&&`rotate-180`)})]}),s&&(0,x.jsxs)(`div`,{className:`basis-full space-y-1 rounded-lg border border-line-strong bg-surface p-1`,children:[(0,x.jsx)(w,{autoFocus:!0,value:l,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Escape`&&c(!1),e.key===`Enter`&&(m[0]??h[0])&&g(m[0]??h[0])},placeholder:`Filter ${t.length} models`,"aria-label":`Filter models`,className:`h-6 px-2 font-mono text-[10px]`}),(0,x.jsxs)(`div`,{className:`max-h-48 overflow-y-auto overscroll-contain font-mono text-[10px]`,children:[!f&&(0,x.jsx)(D,{selected:e===null,onPick:()=>g(null),children:`Default`}),r&&p(r)&&(0,x.jsxs)(D,{selected:e===r,onPick:()=>g(r),children:[r,` `,(0,x.jsx)(`span`,{className:`text-ink-faint`,children:`· not listed`})]}),(0,x.jsx)(E,{title:`Suggested`,ids:m,value:e,onPick:g}),(0,x.jsx)(E,{title:m.length?`All models`:null,ids:h,value:e,onPick:g}),!m.length&&!h.length&&(0,x.jsxs)(`p`,{className:`px-2 py-1 text-ink-faint`,children:[`No model matches “`,l.trim(),`”.`]})]})]})]})}function E({title:e,ids:t,value:n,onPick:r}){return t.length?(0,x.jsxs)(`div`,{role:`group`,"aria-label":e??void 0,children:[e&&(0,x.jsx)(`p`,{className:`px-2 pt-1.5 pb-0.5 text-[9px] tracking-[0.14em] text-ink-faint uppercase`,children:e}),t.map(e=>(0,x.jsx)(D,{selected:e===n,onPick:()=>r(e),children:e},e))]}):null}function D({selected:e,onPick:t,children:n}){return(0,x.jsxs)(`button`,{type:`button`,onClick:t,className:i(`relative flex w-full items-center rounded-md py-1 pr-6 pl-2 text-left text-ink-dim transition-colors`,`hover:bg-brand/15 hover:text-brand focus-visible:bg-brand/15 focus-visible:text-brand focus-visible:outline-none`,e&&`text-brand`),children:[(0,x.jsx)(`span`,{className:`min-w-0 truncate`,children:n}),e&&(0,x.jsx)(u,{className:`absolute right-1.5 size-3`})]})}var ee=[`claude`,`codex`,`antigravity`,`vibe`,`grok`,`cursor`,`qwen`,`opencode`],O={claude:{kind:`claude`,label:`Claude Code`,vendor:`Anthropic`,bin:`claude`,install:`npm i -g @anthropic-ai/claude-code`,docs:`https://claude.com/claude-code`,models:[`fable`,`opus`,`sonnet`,`haiku`]},codex:{kind:`codex`,label:`Codex`,vendor:`OpenAI`,bin:`codex`,install:`npm i -g @openai/codex`,docs:`https://developers.openai.com/codex/cli`,models:[`gpt-5.6-terra`,`gpt-5.6-luna`,`gpt-5.5`]},antigravity:{kind:`antigravity`,label:`Antigravity`,vendor:`Google`,bin:`agy`,install:`https://antigravity.google/docs/cli/install`,docs:`https://antigravity.google/docs/cli`,models:[`gemini-3.1-pro-high`,`gemini-3.8-flash-high`,`gemini-3.8-flash-medium`]},vibe:{kind:`vibe`,label:`Mistral Vibe`,vendor:`Mistral AI`,bin:`vibe`,install:`uv tool install mistral-vibe`,docs:`https://github.com/mistralai/mistral-vibe`,models:[`mistral-medium-3.5`],beta:!0},grok:{kind:`grok`,label:`Grok Build`,vendor:`xAI`,bin:`grok`,install:`curl -fsSL https://x.ai/cli/install.sh | bash`,docs:`https://docs.x.ai/build/overview`,models:[`grok-4.7`],beta:!0},cursor:{kind:`cursor`,label:`Cursor CLI`,vendor:`Anysphere`,bin:`cursor-agent`,install:`curl https://cursor.com/install -fsS | bash`,docs:`https://cursor.com/docs/cli/overview`,models:[`auto`,`composer-2.5`,`claude-opus-5-thinking-high`,`gpt-5.3-codex`],beta:!0},qwen:{kind:`qwen`,label:`Qwen Code`,vendor:`Alibaba`,bin:`qwen`,install:`npm i -g @qwen-code/qwen-code`,docs:`https://qwenlm.github.io/qwen-code-docs/en/`,models:[`qwen3-coder-plus`,`qwen3.7-plus`,`qwen3.6-plus`,`qwen3-max-2026-01-23`],beta:!0},opencode:{kind:`opencode`,label:`OpenCode`,vendor:`Anomaly`,bin:`opencode`,install:`npm i -g opencode-ai`,docs:`https://opencode.ai/docs/cli/`,models:[`anthropic/claude-opus-5-5`,`anthropic/claude-sonnet-5`,`openai/gpt-5.6`,`google/gemini-3.1-pro-preview`],beta:!0}},k=ee.map(e=>O[e]);function te(e){return e?.runners.find(t=>t.kind===e.active)}function ne(e,{running:t,listening:n}={}){let r=te(e?.agent)?.ready!==!1,i=(e?.connected??!1)&&r;return e?.paired?e.connected?r?t?{tone:`busy`,label:`Working`,ready:i}:n?{tone:`listening`,label:`Listening`,ready:i}:{tone:`live`,label:`Online`,ready:i}:{tone:`warn`,label:`Agent blocked`,ready:i,blocker:`agent`}:{tone:`pending`,label:`Reconnecting`,ready:i,blocker:`offline`}:{tone:`off`,label:`Not paired`,ready:i,blocker:`unpaired`}}var re={off:`bg-ink-faint/50`,pending:`glow-dot animate-pulse bg-amber text-amber`,live:`glow-dot bg-lime text-lime`,busy:`glow-dot animate-pulse bg-brand text-brand`,listening:`glow-dot animate-pulse bg-magenta text-magenta`,warn:`glow-dot bg-ember text-ember`},ie={off:`text-ink-faint`,pending:`text-amber`,live:`text-ink-dim`,busy:`text-brand`,listening:`text-magenta`,warn:`text-ember`};function ae({tone:e,className:t}){return(0,x.jsx)(`span`,{className:i(`size-1.5 shrink-0 rounded-full`,re[e],t)})}function oe({tone:e,children:t,onClick:n,expanded:r,className:a}){let o=(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(ae,{tone:e}),(0,x.jsx)(`span`,{className:`min-w-0 truncate`,children:t}),n&&(0,x.jsx)(d,{className:i(`size-3 shrink-0 text-ink-faint transition-transform`,r&&`rotate-180`)})]}),s=i(`inline-flex max-w-full items-center gap-1.5 rounded-full border border-line bg-ground-2/70 px-2.5 py-1`,`font-mono text-[10px] tracking-[0.12em] uppercase`,ie[e],a);return n?(0,x.jsx)(`button`,{type:`button`,onClick:n,"aria-expanded":r,className:i(s,`transition-colors hover:border-brand/40 hover:bg-surface/60`),children:o}):(0,x.jsx)(`span`,{className:s,children:o})}var se=e(n(),1),ce=Object.defineProperty,le=(e,t)=>ce(e,`name`,{value:t,configurable:!0});function ue(e,[t,n]){return Math.min(n,Math.max(t,e))}le(ue,`clamp`);var de=Object.defineProperty,fe=(e,t)=>de(e,`name`,{value:t,configurable:!0}),pe=!!(typeof window<`u`&&window.document&&window.document.createElement);function A(e,t,{checkForDefaultPrevented:n=!0}={}){return fe(function(r){if(e?.(r),n===!1||!r||!r.defaultPrevented)return t?.(r)},`handleEvent`)}fe(A,`composeEventHandlers`);function me(e){if(!pe)throw Error(`Cannot access window outside of the DOM`);return e?.ownerDocument?.defaultView??window}fe(me,`getOwnerWindow`);function he(e){if(!pe)throw Error(`Cannot access document outside of the DOM`);return e?.ownerDocument??document}fe(he,`getOwnerDocument`);function ge(e,t=!1){let{activeElement:n}=he(e);if(!n?.nodeName)return null;if(_e(n)&&n.contentDocument)return ge(n.contentDocument.body,t);if(t){let e=n.getAttribute(`aria-activedescendant`);if(e){let t=he(n).getElementById(e);if(t)return t}}return n}fe(ge,`getActiveElement`);function _e(e){return e.tagName===`IFRAME`}fe(_e,`isFrame`);var ve=Object.defineProperty,ye=(e,t)=>ve(e,`name`,{value:t,configurable:!0});function be(e,t){let n=b.createContext(t);n.displayName=e+`Context`;let r=ye(e=>{let{children:t,...r}=e,i=b.useMemo(()=>r,Object.values(r));return(0,x.jsx)(n.Provider,{value:i,children:t})},`Provider`);r.displayName=e+`Provider`;function i(r,i={}){let{optional:a=!1}=i,o=b.useContext(n);if(o)return o;if(t!==void 0)return t;if(!a)throw Error(`\`${r}\` must be used within \`${e}\``)}return ye(i,`useContext`),[r,i]}ye(be,`createContext`);function xe(e,t=[]){let n=[];function r(t,r){let i=b.createContext(r);i.displayName=t+`Context`;let a=n.length;n=[...n,r];let o=ye(t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=b.useMemo(()=>o,Object.values(o));return(0,x.jsx)(s.Provider,{value:c,children:r})},`Provider`);o.displayName=t+`Provider`;function s(n,o,s={}){let{optional:c=!1}=s,l=o?.[e]?.[a]||i,u=b.useContext(l);if(u)return u;if(r!==void 0)return r;if(!c)throw Error(`\`${n}\` must be used within \`${t}\``)}return ye(s,`useContext`),[o,s]}ye(r,`createContext`);let i=ye(()=>{let t=n.map(e=>b.createContext(e));return ye(function(n){let r=n?.[e]||t;return b.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])},`useScope`)},`createScope`);return i.scopeName=e,[r,Se(i,...t)]}ye(xe,`createContextScope`);function Se(...e){let t=e[0];if(e.length===1)return t;let n=ye(()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return ye(function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return b.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])},`useComposedScopes`)},`createScope`);return n.scopeName=t.scopeName,n}ye(Se,`composeContextScopes`);var Ce=Object.defineProperty,j=(e,t)=>Ce(e,`name`,{value:t,configurable:!0});function we(e){let t=e+`CollectionProvider`,[n,i]=xe(t),[a,o]=n(t,{collectionRef:{current:null},itemMap:new Map}),c=j(e=>{let{scope:t,children:n}=e,r=b.useRef(null),i=b.useRef(new Map).current;return(0,x.jsx)(a,{scope:t,itemMap:i,collectionRef:r,children:n})},`CollectionProvider`);c.displayName=t;let l=e+`CollectionSlot`,u=r(l),d=b.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=s(t,o(l,n).collectionRef);return(0,x.jsx)(u,{ref:i,children:r})});d.displayName=l;let f=e+`CollectionItemSlot`,p=`data-radix-collection-item`,m=r(f),h=b.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,a=b.useRef(null),c=s(t,a),l=o(f,n);return b.useEffect(()=>(l.itemMap.set(a,{ref:a,...i}),()=>void l.itemMap.delete(a))),(0,x.jsx)(m,{[p]:``,ref:c,children:r})});h.displayName=f;function g(t){let n=o(e+`CollectionConsumer`,t);return b.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${p}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return j(g,`useCollection`),[{Provider:c,Slot:d,ItemSlot:h},g,i]}j(we,`createCollection`);var Te=new WeakMap,Ee=class e extends Map{static{j(this,`OrderedDict`)}#e;constructor(e){super(e),this.#e=[...super.keys()],Te.set(this,!0)}set(e,t){return Te.get(this)&&(this.has(e)?this.#e[this.#e.indexOf(e)]=e:this.#e.push(e)),super.set(e,t),this}insert(e,t,n){let r=this.has(t),i=this.#e.length,a=ke(e),o=a>=0?a:i+a,s=o<0||o>=i?-1:o;if(s===this.size||r&&s===this.size-1||s===-1)return this.set(t,n),this;let c=this.size+ +!r;a<0&&o++;let l=[...this.#e],u,d=!1;for(let e=o;e<c;e++)if(o===e){let i=l[e];l[e]===t&&(i=l[e+1]),r&&this.delete(t),u=this.get(i),this.set(t,n)}else{!d&&l[e-1]===t&&(d=!0);let n=l[d?e:e-1],r=u;u=this.get(n),this.delete(n),this.set(n,r)}return this}with(t,n,r){let i=new e(this);return i.insert(t,n,r),i}before(e){let t=this.#e.indexOf(e)-1;if(!(t<0))return this.entryAt(t)}setBefore(e,t,n){let r=this.#e.indexOf(e);return r===-1?this:this.insert(r,t,n)}after(e){let t=this.#e.indexOf(e);if(t=t===-1||t===this.size-1?-1:t+1,t!==-1)return this.entryAt(t)}setAfter(e,t,n){let r=this.#e.indexOf(e);return r===-1?this:this.insert(r+1,t,n)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return this.#e=[],super.clear()}delete(e){let t=super.delete(e);return t&&this.#e.splice(this.#e.indexOf(e),1),t}deleteAt(e){let t=this.keyAt(e);return t!==void 0&&this.delete(t)}at(e){let t=De(this.#e,e);if(t!==void 0)return this.get(t)}entryAt(e){let t=De(this.#e,e);if(t!==void 0)return[t,this.get(t)]}indexOf(e){return this.#e.indexOf(e)}keyAt(e){return De(this.#e,e)}from(e,t){let n=this.indexOf(e);if(n===-1)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.at(r)}keyFrom(e,t){let n=this.indexOf(e);if(n===-1)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.keyAt(r)}find(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return r;n++}}findIndex(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return n;n++}return-1}filter(t,n){let r=[],i=0;for(let e of this)Reflect.apply(t,n,[e,i,this])&&r.push(e),i++;return new e(r)}map(t,n){let r=[],i=0;for(let e of this)r.push([e[0],Reflect.apply(t,n,[e,i,this])]),i++;return new e(r)}reduce(...e){let[t,n]=e,r=0,i=n??this.at(0);for(let n of this)i=r===0&&e.length===1?n:Reflect.apply(t,this,[i,n,r,this]),r++;return i}reduceRight(...e){let[t,n]=e,r=n??this.at(-1);for(let n=this.size-1;n>=0;n--){let i=this.at(n);r=n===this.size-1&&e.length===1?i:Reflect.apply(t,this,[r,i,n,this])}return r}toSorted(t){let n=[...this.entries()].sort(t);return new e(n)}toReversed(){let t=new e;for(let e=this.size-1;e>=0;e--){let n=this.keyAt(e),r=this.get(n);t.set(n,r)}return t}toSpliced(...t){let n=[...this.entries()];return n.splice(...t),new e(n)}slice(t,n){let r=new e,i=this.size-1;if(t===void 0)return r;t<0&&(t+=this.size),n!==void 0&&n>0&&(i=n-1);for(let e=t;e<=i;e++){let t=this.keyAt(e),n=this.get(t);r.set(t,n)}return r}every(e,t){let n=0;for(let r of this){if(!Reflect.apply(e,t,[r,n,this]))return!1;n++}return!0}some(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return!0;n++}return!1}};function De(e,t){if(`at`in Array.prototype)return Array.prototype.at.call(e,t);let n=Oe(e,t);return n===-1?void 0:e[n]}j(De,`at`);function Oe(e,t){let n=e.length,r=ke(t),i=r>=0?r:n+r;return i<0||i>=n?-1:i}j(Oe,`toSafeIndex`);function ke(e){return e!==e||e===0?0:Math.trunc(e)}j(ke,`toSafeInteger`);function Ae(e){let t=e+`CollectionProvider`,[n,i]=xe(t),[a,o]=n(t,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new Ee,setItemMap:j(()=>void 0,`setItemMap`)}),c=j(({state:e,...t})=>e?(0,x.jsx)(u,{...t,state:e}):(0,x.jsx)(l,{...t}),`CollectionProvider`);c.displayName=t;let l=j(e=>{let t=_();return(0,x.jsx)(u,{...e,state:t})},`CollectionInit`);l.displayName=t+`Init`;let u=j(e=>{let{scope:t,children:n,state:r}=e,i=b.useRef(null),[o,c]=b.useState(null),l=s(i,c),[u,d]=r;return b.useEffect(()=>{if(!o)return;let e=Pe(()=>{});return e.observe(o,{childList:!0,subtree:!0}),()=>{e.disconnect()}},[o]),(0,x.jsx)(a,{scope:t,itemMap:u,setItemMap:d,collectionRef:l,collectionRefObject:i,collectionElement:o,children:n})},`CollectionProviderImpl`);u.displayName=t+`Impl`;let d=e+`CollectionSlot`,f=r(d),p=b.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=s(t,o(d,n).collectionRef);return(0,x.jsx)(f,{ref:i,children:r})});p.displayName=d;let m=e+`CollectionItemSlot`,h=r(m),g=b.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,a=b.useRef(null),[c,l]=b.useState(null),u=s(t,a,l),{setItemMap:d}=o(m,n),f=b.useRef(i);je(f.current,i)||(f.current=i);let p=f.current;return b.useEffect(()=>{let e=p;return d(t=>c?t.has(c)?t.set(c,{...e,element:c}).toSorted(Ne):(t.set(c,{...e,element:c}),t.toSorted(Ne)):t),()=>{d(e=>!c||!e.has(c)?e:(e.delete(c),new Ee(e)))}},[c,p,d]),(0,x.jsx)(h,{"data-radix-collection-item":``,ref:u,children:r})});g.displayName=m;function _(){return b.useState(new Ee)}j(_,`useInitCollection`);function v(t){let{itemMap:n}=o(e+`CollectionConsumer`,t);return n}return j(v,`useCollection`),[{Provider:c,Slot:p,ItemSlot:g},{createCollectionScope:i,useCollection:v,useInitCollection:_}]}j(Ae,`createCollection`);function je(e,t){if(e===t)return!0;if(typeof e!=`object`||typeof t!=`object`||e==null||t==null)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||e[r]!==t[r])return!1;return!0}j(je,`shallowEqual`);function Me(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}j(Me,`isElementPreceding`);function Ne(e,t){return!e[1].element||!t[1].element?0:Me(e[1].element,t[1].element)?-1:1}j(Ne,`sortByDocumentPosition`);function Pe(e){return new MutationObserver(t=>{for(let n of t)if(n.type===`childList`){e();return}})}j(Pe,`getChildListObserver`);var Fe=Object.defineProperty,Ie=(e,t)=>Fe(e,`name`,{value:t,configurable:!0}),Le=b.createContext(void 0);function Re(e){let t=b.useContext(Le);return e||t||`ltr`}Ie(Re,`useDirection`);var ze=Object.defineProperty,Be=(e,t)=>ze(e,`name`,{value:t,configurable:!0}),Ve=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=r(`Primitive.${t}`),i=b.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,x.jsx)(o,{...a,ref:r})});return i.displayName=`Primitive.${t}`,{...e,[t]:i}},{});function He(e,t){e&&se.flushSync(()=>e.dispatchEvent(t))}Be(He,`dispatchDiscreteCustomEvent`);var Ue=Object.defineProperty,We=(e,t)=>Ue(e,`name`,{value:t,configurable:!0});function Ge(e){let t=b.useRef(e);return b.useEffect(()=>{t.current=e}),b.useMemo(()=>((...e)=>t.current?.(...e)),[])}We(Ge,`useCallbackRef`);var Ke=Object.defineProperty,M=(e,t)=>Ke(e,`name`,{value:t,configurable:!0}),qe=`dismissableLayer.update`,Je=`dismissableLayer.pointerDownOutside`,Ye=`dismissableLayer.focusOutside`,Xe,Ze=b.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Qe=b.forwardRef(M(function(e,t){let{disableOutsidePointerEvents:n=!1,deferPointerDownOutside:r=!1,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:c,onDismiss:l,...u}=e,d=b.useContext(Ze),[f,p]=b.useState(null),m=f?.ownerDocument??globalThis?.document,[,h]=b.useState({}),g=s(t,p),_=Array.from(d.layers),[v]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),y=v?_.indexOf(v):-1,S=f?_.indexOf(f):-1,C=d.layersWithOutsidePointerEventsDisabled.size>0,w=S>=y,T=b.useRef(!1),E=tt(e=>{a?.(e),c?.(e),e.defaultPrevented||l?.()},{ownerDocument:m,deferPointerDownOutside:r,isDeferredPointerDownOutsideRef:T,dismissableSurfaces:d.dismissableSurfaces,shouldHandlePointerDownOutside:b.useCallback(e=>{if(!(e instanceof Node))return!1;let t=[...d.branches].some(t=>t.contains(e));return w&&!t},[d.branches,w])}),D=nt(e=>{if(r&&T.current)return;let t=e.target;[...d.branches].some(e=>e.contains(t))||(o?.(e),c?.(e),e.defaultPrevented||l?.())},m),ee=f?S===_.length-1:!1,O=Ge(e=>{e.key===`Escape`&&(i?.(e),!e.defaultPrevented&&l&&(e.preventDefault(),l()))});return b.useEffect(()=>{if(ee)return m.addEventListener(`keydown`,O,{capture:!0}),()=>m.removeEventListener(`keydown`,O,{capture:!0})},[m,ee,O]),b.useEffect(()=>{if(f)return n&&(d.layersWithOutsidePointerEventsDisabled.size===0&&(Xe=m.body.style.pointerEvents,m.body.style.pointerEvents=`none`),d.layersWithOutsidePointerEventsDisabled.add(f)),d.layers.add(f),rt(),()=>{n&&(d.layersWithOutsidePointerEventsDisabled.delete(f),d.layersWithOutsidePointerEventsDisabled.size===0&&(m.body.style.pointerEvents=Xe))}},[f,m,n,d]),b.useEffect(()=>()=>{f&&(d.layers.delete(f),d.layersWithOutsidePointerEventsDisabled.delete(f),rt())},[f,d]),b.useEffect(()=>{let e=M(()=>h({}),`handleUpdate`);return document.addEventListener(qe,e),()=>document.removeEventListener(qe,e)},[]),(0,x.jsx)(Ve.div,{...u,ref:g,style:{pointerEvents:C?w?`auto`:`none`:void 0,...e.style},onFocusCapture:A(e.onFocusCapture,D.onFocusCapture),onBlurCapture:A(e.onBlurCapture,D.onBlurCapture),onPointerDownCapture:A(e.onPointerDownCapture,E.onPointerDownCapture)})},`DismissableLayer`));function $e(){let e=b.useContext(Ze),[t,n]=b.useState(null);return b.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}M($e,`useDismissableLayerSurface`);var et=M(()=>!0,`IS_TRUE`);function tt(e,t){let{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:a,shouldHandlePointerDownOutside:o=et}=t,s=Ge(e),c=b.useRef(!1),l=b.useRef(!1),u=b.useRef(new Map),d=b.useRef(()=>{});return b.useEffect(()=>{function e(){l.current=!1,i.current=!1,u.current.clear()}M(e,`resetOutsideInteraction`);function t(){return Array.from(u.current.values()).some(Boolean)}M(t,`isOutsideInteractionIntercepted`);function f(e){if(!l.current)return;let t=e.target;t instanceof Node&&[...a].some(e=>e.contains(t))||u.current.set(e.type,!0),e.type===`click`&&window.setTimeout(()=>{l.current&&d.current()},0)}M(f,`handleInteractionCapture`);function p(e){l.current&&u.current.set(e.type,!1)}M(p,`handleInteractionBubble`);let m=M(a=>{if(a.target&&!c.current){let f=function(){n.removeEventListener(`click`,d.current);let r=t();e(),r||it(Je,s,p,{discrete:!0})};if(M(f,`handleAndDispatchPointerDownOutsideEvent`),!o(a.target)){n.removeEventListener(`click`,d.current),e(),c.current=!1;return}let p={originalEvent:a};l.current=!0,i.current=r&&a.button===0,u.current.clear(),!r||a.button!==0?f():(n.removeEventListener(`click`,d.current),d.current=f,n.addEventListener(`click`,d.current,{once:!0}))}else n.removeEventListener(`click`,d.current),e();c.current=!1},`handlePointerDown`),h=[`pointerup`,`mousedown`,`mouseup`,`touchstart`,`touchend`,`click`];for(let e of h)n.addEventListener(e,f,!0),n.addEventListener(e,p);let g=window.setTimeout(()=>{n.addEventListener(`pointerdown`,m)},0);return()=>{window.clearTimeout(g),n.removeEventListener(`pointerdown`,m),n.removeEventListener(`click`,d.current);for(let e of h)n.removeEventListener(e,f,!0),n.removeEventListener(e,p)}},[n,s,r,i,a,o]),{onPointerDownCapture:M(()=>c.current=!0,`onPointerDownCapture`)}}M(tt,`usePointerDownOutside`);function nt(e,t=globalThis?.document){let n=Ge(e),r=b.useRef(!1);return b.useEffect(()=>{let e=M(e=>{e.target&&!r.current&&it(Ye,n,{originalEvent:e},{discrete:!1})},`handleFocus`);return t.addEventListener(`focusin`,e),()=>t.removeEventListener(`focusin`,e)},[t,n]),{onFocusCapture:M(()=>r.current=!0,`onFocusCapture`),onBlurCapture:M(()=>r.current=!1,`onBlurCapture`)}}M(nt,`useFocusOutside`);function rt(){let e=new CustomEvent(qe);document.dispatchEvent(e)}M(rt,`dispatchUpdate`);function it(e,t,n,{discrete:r}){let i=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?He(i,a):i.dispatchEvent(a)}M(it,`handleAndDispatchCustomEvent`);var at=Object.defineProperty,ot=(e,t)=>at(e,`name`,{value:t,configurable:!0}),st=0,ct=null;function lt(e){return ut(),e.children}ot(lt,`FocusGuards`);function ut(){b.useEffect(()=>{ct||={start:dt(),end:dt()};let{start:e,end:t}=ct;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement(`afterbegin`,e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement(`beforeend`,t),st++,()=>{st===1&&(ct?.start.remove(),ct?.end.remove(),ct=null),st=Math.max(0,st-1)}},[])}ot(ut,`useFocusGuards`);function dt(){let e=document.createElement(`span`);return e.setAttribute(`data-radix-focus-guard`,``),e.tabIndex=0,e.style.outline=`none`,e.style.opacity=`0`,e.style.position=`fixed`,e.style.pointerEvents=`none`,e}ot(dt,`createFocusGuard`);var ft=Object.defineProperty,pt=(e,t)=>ft(e,`name`,{value:t,configurable:!0}),mt=`focusScope.autoFocusOnMount`,ht=`focusScope.autoFocusOnUnmount`,gt={bubbles:!1,cancelable:!0},_t=b.forwardRef(pt(function(e,t){let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[c,l]=b.useState(null),u=Ge(i),d=Ge(a),f=b.useRef(null),p=s(t,l),m=b.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;b.useEffect(()=>{if(r){let e=function(e){if(m.paused||!c)return;let t=e.target;c.contains(t)?f.current=t:wt(f.current,{select:!0})},t=function(e){if(m.paused||!c)return;let t=e.relatedTarget;t!==null&&(c.contains(t)||wt(f.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&wt(c)};pt(e,`handleFocusIn`),pt(t,`handleFocusOut`),pt(n,`handleMutations`),document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return c&&r.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[r,c,m.paused]),b.useEffect(()=>{if(c){Tt.add(m);let e=document.activeElement;if(!c.contains(e)){let t=new CustomEvent(mt,gt);c.addEventListener(mt,u),c.dispatchEvent(t),t.defaultPrevented||(vt(Ot(bt(c)),{select:!0}),document.activeElement===e&&wt(c))}return()=>{c.removeEventListener(mt,u),setTimeout(()=>{let t=new CustomEvent(ht,gt);c.addEventListener(ht,d),c.dispatchEvent(t),t.defaultPrevented||wt(e??document.body,{select:!0}),c.removeEventListener(ht,d),Tt.remove(m)},0)}}},[c,u,d,m]);let h=b.useCallback(e=>{if(!n&&!r||m.paused)return;let t=e.key===`Tab`&&!e.altKey&&!e.ctrlKey&&!e.metaKey,i=document.activeElement;if(t&&i){let t=e.currentTarget,[r,a]=yt(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&wt(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&wt(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,m.paused]);return(0,x.jsx)(Ve.div,{tabIndex:-1,...o,ref:p,onKeyDown:h})},`FocusScope`));function vt(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(wt(r,{select:t}),document.activeElement!==n)return}pt(vt,`focusFirst`);function yt(e){let t=bt(e);return[xt(t,e),xt(t.reverse(),e)]}pt(yt,`getTabbableEdges`);function bt(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:pt(e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},`acceptNode`)});for(;n.nextNode();)t.push(n.currentNode);return t}pt(bt,`getTabbableCandidates`);function xt(e,t){let n=typeof t.checkVisibility==`function`&&t.checkVisibility({checkVisibilityCSS:!0});for(let r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):St(r,{upTo:t})))return r}pt(xt,`findVisible`);function St(e,{upTo:t}){if(getComputedStyle(e).visibility===`hidden`)return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display===`none`)return!0;e=e.parentElement}return!1}pt(St,`isHidden`);function Ct(e){return e instanceof HTMLInputElement&&`select`in e}pt(Ct,`isSelectableInput`);function wt(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Ct(e)&&t&&e.select()}}pt(wt,`focus`);var Tt=Et();function Et(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=Dt(e,t),e.unshift(t)},remove(t){e=Dt(e,t),e[0]?.resume()}}}pt(Et,`createFocusScopesStack`);function Dt(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}pt(Dt,`arrayRemove`);function Ot(e){return e.filter(e=>e.tagName!==`A`)}pt(Ot,`removeLinks`);var N=globalThis?.document?b.useLayoutEffect:()=>{},kt=Object.defineProperty,At=(e,t)=>kt(e,`name`,{value:t,configurable:!0}),jt=b.useId||(()=>void 0),Mt=0;function Nt(e){let[t,n]=b.useState(jt());return N(()=>{e||n(e=>e??String(Mt++))},[e]),e||(t?`radix-${t}`:``)}At(Nt,`useId`);var Pt=[`top`,`right`,`bottom`,`left`],Ft=Math.min,It=Math.max,Lt=Math.round,Rt=Math.floor,zt=e=>({x:e,y:e}),Bt={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function Vt(e,t,n){return It(e,Ft(t,n))}function Ht(e,t){return typeof e==`function`?e(t):e}function Ut(e){return e.split(`-`)[0]}function Wt(e){return e.split(`-`)[1]}function Gt(e){return e===`x`?`y`:`x`}function Kt(e){return e===`y`?`height`:`width`}function qt(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function Jt(e){return Gt(qt(e))}function Yt(e,t,n){n===void 0&&(n=!1);let r=Wt(e),i=Jt(e),a=Kt(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=an(o)),[o,an(o)]}function Xt(e){let t=an(e);return[Zt(e),t,Zt(t)]}function Zt(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var Qt=[`left`,`right`],$t=[`right`,`left`],en=[`top`,`bottom`],tn=[`bottom`,`top`];function nn(e,t,n){switch(e){case`top`:case`bottom`:return n?t?$t:Qt:t?Qt:$t;case`left`:case`right`:return t?en:tn;default:return[]}}function rn(e,t,n,r){let i=Wt(e),a=nn(Ut(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(Zt)))),a}function an(e){let t=Ut(e);return Bt[t]+e.slice(t.length)}function on(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function sn(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:on(e)}function cn(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function ln(e,t,n){let{reference:r,floating:i}=e,a=qt(t),o=Jt(t),s=Kt(o),c=Ut(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=Wt(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function un(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=Ht(t,e),p=sn(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=cn(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=cn(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var dn=50,fn=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:un},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=ln(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<dn&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=ln(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},pn=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=Ht(e,t)||{};if(l==null)return{};let d=sn(u),f={x:n,y:r},p=Jt(i),m=Kt(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),C=S?S[y]:0;(!C||!await(o.isElement==null?void 0:o.isElement(S)))&&(C=s.floating[y]||a.floating[m]);let w=b/2-x/2,T=C/2-h[m]/2-1,E=Ft(d[_],T),D=Ft(d[v],T),ee=C-h[m]-D,O=C/2-h[m]/2+w,k=Vt(E,O,ee),te=!c.arrow&&Wt(i)!=null&&O!==k&&a.reference[m]/2-(O<E?E:D)-h[m]/2<0,ne=te?O<E?O-E:O-ee:0;return{[p]:f[p]+ne,data:{[p]:k,centerOffset:O-k-ne,...te&&{alignmentOffset:ne}},reset:te}}}),mn=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=Ht(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=Ut(r),_=qt(o),v=Ut(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[an(o)]:Xt(o)),x=p!==`none`;!d&&x&&b.push(...rn(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=Yt(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(!(u===`alignment`&&_!==qt(t))||T.every(e=>qt(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=qt(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o;break}if(r!==n)return{reset:{placement:n}}}return{}}}};function hn(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function gn(e){return Pt.some(t=>e[t]>=0)}var _n=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=Ht(e,t);switch(i){case`referenceHidden`:{let e=hn(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:gn(e)}}}case`escaped`:{let e=hn(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:gn(e)}}}default:return{}}}}},vn=new Set([`left`,`top`]);async function yn(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=Ut(n),s=Wt(n),c=qt(n)===`y`,l=vn.has(o)?-1:1,u=a&&c?-1:1,d=Ht(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var bn=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await yn(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},xn=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=Ht(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=qt(i),p=Gt(f),m=u[p],h=u[f],g=(e,t)=>Vt(t+d[e===`y`?`top`:`left`],t,t-d[e===`y`?`bottom`:`right`]);o&&(m=g(p,m)),s&&(h=g(f,h));let _=c.fn({...t,[p]:m,[f]:h});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[p]:o,[f]:s}}}}}},Sn=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=Ht(e,t),u={x:n,y:r},d=qt(i),f=Gt(d),p=u[f],m=u[d],h=Ht(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:h.mainAxis??0,crossAxis:h.crossAxis??0};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=vn.has(Ut(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},Cn=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){let{placement:n,rects:r,platform:i,elements:a}=t,{apply:o=()=>{},...s}=Ht(e,t),c=await i.detectOverflow(t,s),l=Ut(n),u=Wt(n),d=qt(n)===`y`,{width:f,height:p}=r.floating,m,h;l===`top`||l===`bottom`?(m=l,h=u===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?`start`:`end`)?`left`:`right`):(h=l,m=u===`end`?`top`:`bottom`);let g=p-c.top-c.bottom,_=f-c.left-c.right,v=Ft(p-c[m],g),y=Ft(f-c[h],_),b=t.middlewareData.shift,x=!b,S=v,C=y;b!=null&&b.enabled.x&&(C=_),b!=null&&b.enabled.y&&(S=g),x&&!u&&(d?C=f-2*It(c.left,c.right):S=p-2*It(c.top,c.bottom)),await o({...t,availableWidth:C,availableHeight:S});let w=await i.getDimensions(a.floating);return f!==w.width||p!==w.height?{reset:{rects:!0}}:{}}}};function wn(){return typeof window<`u`}function Tn(e){return On(e)?(e.nodeName||``).toLowerCase():`#document`}function En(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Dn(e){return((On(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function On(e){return wn()?e instanceof Node||e instanceof En(e).Node:!1}function kn(e){return wn()?e instanceof Element||e instanceof En(e).Element:!1}function An(e){return wn()?e instanceof HTMLElement||e instanceof En(e).HTMLElement:!1}function jn(e){return!wn()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof En(e).ShadowRoot}function Mn(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=Un(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function Nn(e){return/^(table|td|th)$/.test(Tn(e))}function Pn(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var Fn=/transform|translate|scale|rotate|perspective|filter/,In=/paint|layout|strict|content/,Ln=e=>!!e&&e!==`none`,Rn;function zn(e){let t=kn(e)?Un(e):e;return Ln(t.transform)||Ln(t.translate)||Ln(t.scale)||Ln(t.rotate)||Ln(t.perspective)||!Vn()&&(Ln(t.backdropFilter)||Ln(t.filter))||Fn.test(t.willChange||``)||In.test(t.contain||``)}function Bn(e){let t=Gn(e);for(;An(t)&&!Hn(t);){if(zn(t))return t;if(Pn(t))return null;t=Gn(t)}return null}function Vn(){return Rn??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),Rn}function Hn(e){return/^(html|body|#document)$/.test(Tn(e))}function Un(e){return En(e).getComputedStyle(e)}function Wn(e){return kn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Gn(e){if(Tn(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||jn(e)&&e.host||Dn(e);return jn(t)?t.host:t}function Kn(e){let t=Gn(e);return Hn(t)?(e.ownerDocument||e).body:An(t)&&Mn(t)?t:Kn(t)}function qn(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=Kn(e),i=r===e.ownerDocument?.body,a=En(r);if(i){let e=Jn(a);return t.concat(a,a.visualViewport||[],Mn(r)?r:[],e&&n?qn(e):[])}else return t.concat(r,qn(r,[],n))}function Jn(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Yn(e){let t=Un(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=An(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=Lt(n)!==a||Lt(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function Xn(e){return kn(e)?e:e.contextElement}function Zn(e){let t=Xn(e);if(!An(t))return zt(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=Yn(t),o=(a?Lt(n.width):n.width)/r,s=(a?Lt(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var Qn=zt(0);function $n(e){let t=En(e);return!Vn()||!t.visualViewport?Qn:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function er(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===En(e)}function tr(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=Xn(e),o=zt(1);t&&(r?kn(r)&&(o=Zn(r)):o=Zn(e));let s=er(a,n,r)?$n(a):zt(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=En(a),t=kn(r)?En(r):r,n=e,i=Jn(n);for(;i&&t!==n;){let e=Zn(i),t=i.getBoundingClientRect(),r=Un(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=En(i),i=Jn(n)}}return cn({width:u,height:d,x:c,y:l})}function nr(e,t){let n=Wn(e).scrollLeft;return t?t.left+n:tr(Dn(e)).left+n}function rr(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-nr(e,n),y:n.top+t.scrollTop}}function ir(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=Dn(r),s=t?Pn(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=zt(1),u=zt(0),d=An(r);if((d||!a)&&((Tn(r)!==`body`||Mn(o))&&(c=Wn(r)),d)){let e=tr(r);l=Zn(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?rr(o,c):zt(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function ar(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function or(e){let t=Wn(e),n=e.ownerDocument.body,r=It(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=It(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+nr(e),o=-t.scrollTop;return Un(n).direction===`rtl`&&(a+=It(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var sr=25;function cr(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=En(e),a=Dn(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!Vn()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(nr(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=sr&&(s-=o)}return{width:s,height:c,x:l,y:u}}function lr(e,t){let n=tr(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=Zn(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function ur(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=cr(e,n,t);else if(t===`document`)r=or(Dn(e));else if(kn(t))r=lr(t,n);else{let n=$n(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return cn(r)}function dr(e,t){let n=t.get(e);if(n)return n;let r=qn(e,[],!1).filter(e=>kn(e)&&Tn(e)!==`body`),i=null,a=Un(e).position===`fixed`,o=a?Gn(e):e;for(;kn(o)&&!Hn(o);){let e=Un(o),t=zn(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=Gn(o)}return t.set(e,r),r}function fr(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?Pn(t)?[]:dr(t,this._c):[].concat(n),r],o=ur(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=ur(t,a[e],i);s=It(n.top,s),c=Ft(n.right,c),l=Ft(n.bottom,l),u=It(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function pr(e){let{width:t,height:n}=Yn(e);return{width:t,height:n}}function mr(e,t,n){let r=An(t),i=Dn(t),a=n===`fixed`,o=tr(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=zt(0);if((r||!a)&&((Tn(t)!==`body`||Mn(i))&&(s=Wn(t)),r)){let e=tr(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=nr(i));let l=i&&!r&&!a?rr(i,s):zt(0);return{x:o.left+s.scrollLeft-c.x-l.x,y:o.top+s.scrollTop-c.y-l.y,width:o.width,height:o.height}}function hr(e){return Un(e).position===`static`}function gr(e,t){if(!An(e)||Un(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return Dn(e)===n&&(n=n.ownerDocument.body),n}function _r(e,t){let n=En(e);if(Pn(e))return n;if(!An(e)){let t=Gn(e);for(;t&&!Hn(t);){if(kn(t)&&!hr(t))return t;t=Gn(t)}return n}let r=gr(e,t);for(;r&&Nn(r)&&hr(r);)r=gr(r,t);return r&&Hn(r)&&hr(r)&&!zn(r)?n:r||Bn(e)||n}var vr=async function(e){let t=this.getOffsetParent||_r,n=this.getDimensions,r=await n(e.floating);return{reference:mr(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function yr(e){return Un(e).direction===`rtl`}var br={convertOffsetParentRelativeRectToViewportRelativeRect:ir,getDocumentElement:Dn,getClippingRect:fr,getOffsetParent:_r,getElementRects:vr,getClientRects:ar,getDimensions:pr,getScale:Zn,isElement:kn,isRTL:yr};function xr(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Sr(e,t,n){let r=null,i,a=Dn(e);function o(){var e;clearTimeout(i),(e=r)==null||e.disconnect(),r=null}function s(n,c){n===void 0&&(n=!1),c===void 0&&(c=1),o();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(n||t(),!f||!p)return;let m=Rt(d),h=Rt(a.clientWidth-(u+f)),g=Rt(a.clientHeight-(d+p)),_=Rt(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:It(0,Ft(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!xr(l,e.getBoundingClientRect()))return s();if(n!==c){if(!y)return s();n?s(!1,n):i=setTimeout(()=>{s(!1,1e-7)},1e3)}y=!1}try{r=new IntersectionObserver(b,{...v,root:a.ownerDocument})}catch{r=new IntersectionObserver(b,v)}r.observe(e)}let c=En(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function Cr(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=Xn(e),u=i||a?[...l?qn(l):[],...t?qn(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?Sr(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?tr(e):null;c&&g();function g(){let t=tr(e);h&&!xr(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var wr=bn,Tr=xn,Er=mn,Dr=Cn,Or=_n,kr=pn,Ar=Sn,jr=(e,t,n)=>{let r=new Map,i=n??{},a={...br,...i.platform,_c:r};return fn(e,t,{...i,platform:a})},Mr=typeof document<`u`?b.useLayoutEffect:function(){};function Nr(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Nr(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!Nr(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function Pr(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Fr(e,t){let n=Pr(e);return Math.round(t*n)/n}function Ir(e){let t=b.useRef(e);return Mr(()=>{t.current=e}),t}function Lr(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=b.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=b.useState(r);Nr(f,r)||p(r);let[m,h]=b.useState(null),[g,_]=b.useState(null),v=b.useCallback(e=>{e!==C.current&&(C.current=e,h(e))},[]),y=b.useCallback(e=>{e!==w.current&&(w.current=e,_(e))},[]),x=a||m,S=o||g,C=b.useRef(null),w=b.useRef(null),T=b.useRef(u),E=c!=null,D=Ir(c),ee=Ir(i),O=Ir(l),k=b.useCallback(()=>{if(!C.current||!w.current)return;let e={placement:t,strategy:n,middleware:f};ee.current&&(e.platform=ee.current),jr(C.current,w.current,e).then(e=>{let t={...e,isPositioned:O.current!==!1};te.current&&!Nr(T.current,t)&&(T.current=t,se.flushSync(()=>{d(t)}))})},[f,t,n,ee,O]);Mr(()=>{l===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let te=b.useRef(!1);Mr(()=>(te.current=!0,()=>{te.current=!1}),[]),Mr(()=>{if(x&&(C.current=x),S&&(w.current=S),x&&S){if(D.current)return D.current(x,S,k);k()}},[x,S,k,D,E]);let ne=b.useMemo(()=>({reference:C,floating:w,setReference:v,setFloating:y}),[v,y]),re=b.useMemo(()=>({reference:x,floating:S}),[x,S]),ie=b.useMemo(()=>{let e={position:n,left:0,top:0};if(!re.floating)return e;let t=Fr(re.floating,u.x),r=Fr(re.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...Pr(re.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,re.floating,u.x,u.y]);return b.useMemo(()=>({...u,update:k,refs:ne,elements:re,floatingStyles:ie}),[u,k,ne,re,ie])}var Rr=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:kr({element:r.current,padding:i}).fn(n):r?kr({element:r,padding:i}).fn(n):{}}}},zr=(e,t)=>{let n=wr(e);return{name:n.name,fn:n.fn,options:[e,t]}},Br=(e,t)=>{let n=Tr(e);return{name:n.name,fn:n.fn,options:[e,t]}},Vr=(e,t)=>({fn:Ar(e).fn,options:[e,t]}),Hr=(e,t)=>{let n=Er(e);return{name:n.name,fn:n.fn,options:[e,t]}},Ur=(e,t)=>{let n=Dr(e);return{name:n.name,fn:n.fn,options:[e,t]}},Wr=(e,t)=>{let n=Or(e);return{name:n.name,fn:n.fn,options:[e,t]}},Gr=(e,t)=>{let n=Rr(e);return{name:n.name,fn:n.fn,options:[e,t]}},Kr=Object.defineProperty,qr=(e,t)=>Kr(e,`name`,{value:t,configurable:!0});function Jr(e){let[t,n]=b.useState(void 0);return N(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}else n(void 0)},[e]),t}qr(Jr,`useSize`);var Yr=Object.defineProperty,Xr=(e,t)=>Yr(e,`name`,{value:t,configurable:!0}),Zr=`Popper`,[Qr,$r]=xe(Zr),[ei,ti]=Qr(Zr),ni=Xr(e=>{let{__scopePopper:t,children:n}=e,[r,i]=b.useState(null),[a,o]=b.useState(void 0);return(0,x.jsx)(ei,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})},`Popper`),ri=`PopperAnchor`,ii=b.forwardRef(Xr(function(e,t){let{__scopePopper:n,virtualRef:r,...i}=e,a=ti(ri,n),o=b.useRef(null),c=a.onAnchorChange,l=s(t,b.useCallback(e=>{o.current=e,e&&c(e)},[c])),u=b.useRef(null);b.useEffect(()=>{if(!r)return;let e=u.current;u.current=r.current,e!==u.current&&c(u.current)});let d=a.placementState&&di(a.placementState),f=d?.[0],p=d?.[1];return r?null:(0,x.jsx)(Ve.div,{"data-radix-popper-side":f,"data-radix-popper-align":p,...i,ref:l})},`PopperAnchor`)),ai=`PopperContent`,[oi,si]=Qr(ai),ci=b.forwardRef(Xr(function(e,t){let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:a=`center`,alignOffset:o=0,arrowPadding:c=0,avoidCollisions:l=!0,collisionBoundary:u=[],collisionPadding:d=0,sticky:f=`partial`,hideWhenDetached:p=!1,updatePositionStrategy:m=`optimized`,onPlaced:h,...g}=e,_=ti(ai,n),[v,y]=b.useState(null),S=s(t,y),[C,w]=b.useState(null),T=Jr(C),E=T?.width??0,D=T?.height??0,ee=r+(a===`center`?``:`-`+a),O=typeof d==`number`?d:{top:0,right:0,bottom:0,left:0,...d},k=Array.isArray(u)?u:[u],te=k.length>0,ne={padding:O,boundary:k.filter(li),altBoundary:te},{refs:re,floatingStyles:ie,placement:ae,isPositioned:oe,middlewareData:se}=Lr({strategy:`fixed`,placement:ee,whileElementsMounted:Xr((...e)=>Cr(...e,{animationFrame:m===`always`}),`whileElementsMounted`),elements:{reference:_.anchor},middleware:[zr({mainAxis:i+D,alignmentAxis:o}),l&&Br({mainAxis:!0,crossAxis:!1,limiter:f===`partial`?Vr():void 0,...ne}),l&&Hr({...ne}),Ur({...ne,apply:Xr(({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)},`apply`)}),C&&Gr({element:C,padding:c}),ui({arrowWidth:E,arrowHeight:D}),p&&Wr({strategy:`referenceHidden`,...ne,boundary:te?ne.boundary:void 0})]}),ce=_.setPlacementState;N(()=>(ce(ae),()=>{ce(void 0)}),[ae,ce]);let[le,ue]=di(ae),de=Ge(h);N(()=>{oe&&de?.()},[oe,de]);let fe=se.arrow?.x,pe=se.arrow?.y,A=se.arrow?.centerOffset!==0,[me,he]=b.useState();return N(()=>{v&&he(window.getComputedStyle(v).zIndex)},[v]),(0,x.jsx)(`div`,{ref:re.setFloating,"data-radix-popper-content-wrapper":``,style:{...ie,transform:oe?ie.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:me,"--radix-popper-transform-origin":[se.transformOrigin?.x,se.transformOrigin?.y].join(` `),...se.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,x.jsx)(oi,{scope:n,placedSide:le,placedAlign:ue,onArrowChange:w,arrowX:fe,arrowY:pe,shouldHideArrow:A,children:(0,x.jsx)(Ve.div,{"data-side":le,"data-align":ue,...g,ref:S,style:{...g.style,animation:oe?g.style?.animation:`none`}})})})},`PopperContent`));function li(e){return e!==null}Xr(li,`isNotNull`);var ui=Xr(e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=di(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}}),`transformOrigin`);function di(e){let[t,n=`center`]=e.split(`-`);return[t,n]}Xr(di,`getSideAndAlignFromPlacement`);var fi=ni,pi=ii,mi=ci,hi=Object.defineProperty,gi=b.forwardRef(((e,t)=>hi(e,`name`,{value:t,configurable:!0}))(function(e,t){let{container:n,...r}=e,[i,a]=b.useState(!1);N(()=>a(!0),[]);let o=n||i&&globalThis?.document?.body;return o?se.createPortal((0,x.jsx)(Ve.div,{...r,ref:t}),o):null},`Portal`)),_i=Object.defineProperty,vi=(e,t)=>_i(e,`name`,{value:t,configurable:!0});function yi(e,t){return b.useReducer((e,n)=>t[e][n]??e,e)}vi(yi,`useStateMachine`);var bi=vi(e=>{let{present:t,children:n}=e,r=xi(t),i=typeof n==`function`?n({present:r.isPresent}):b.Children.only(n),a=Ci(r.ref,Ti(i));return typeof n==`function`||r.isPresent?b.cloneElement(i,{ref:a}):null},`Presence`);function xi(e){let[t,n]=b.useState(),r=b.useRef(null),i=b.useRef(e),a=b.useRef(`none`),o=b.useRef(void 0),[s,c]=yi(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return b.useEffect(()=>{s===`mounted`?(a.current=o.current??wi(r.current),o.current=void 0):a.current=`none`},[s]),N(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,s=wi(t);e?(o.current=s,c(`MOUNT`)):s===`none`||t?.display===`none`?c(`UNMOUNT`):c(n&&r!==s?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,c]),N(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=vi(a=>{let o=wi(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(c(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},`handleAnimationEnd`),s=vi(e=>{e.target===t&&(a.current=wi(r.current))},`handleAnimationStart`);return t.addEventListener(`animationstart`,s),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,s),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}else c(`ANIMATION_END`)},[t,c]),{isPresent:[`mounted`,`unmountSuspended`].includes(s),ref:b.useCallback(e=>{if(e){let t=getComputedStyle(e);r.current=t,o.current=wi(t)}else r.current=null;n(e)},[])}}vi(xi,`usePresence`);function Si(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}vi(Si,`setRef`);function Ci(...e){let t=b.useRef(e);return t.current=e,b.useCallback(e=>{let n=t.current,r=!1,i=n.map(t=>{let n=Si(t,e);return!r&&typeof n==`function`&&(r=!0),n});if(r)return()=>{for(let e=0;e<i.length;e++){let t=i[e];typeof t==`function`?t():Si(n[e],null)}}},[])}vi(Ci,`useStableComposedRefs`);function wi(e){return e?.animationName||`none`}vi(wi,`getAnimationName`);function Ti(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}vi(Ti,`getElementRef`);var Ei=Object.defineProperty,Di=(e,t)=>Ei(e,`name`,{value:t,configurable:!0}),Oi=b.useEffectEvent,ki=b.useInsertionEffect;function Ai(e){if(typeof Oi==`function`)return Oi(e);let t=b.useRef(()=>{throw Error(`Cannot call an event handler while rendering.`)});return typeof ki==`function`?ki(()=>{t.current=e}):N(()=>{t.current=e}),b.useMemo(()=>((...e)=>t.current?.(...e)),[])}Di(Ai,`useEffectEvent`);var ji=Object.defineProperty,Mi=(e,t)=>ji(e,`name`,{value:t,configurable:!0}),Ni=b.useInsertionEffect||N;function Pi({prop:e,defaultProp:t,onChange:n=Mi(()=>{},`onChange`),caller:r}){let[i,a,o]=Fi({defaultProp:t,onChange:n}),s=e!==void 0;return[s?e:i,b.useCallback(t=>{if(s){let n=Ii(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}Mi(Pi,`useControllableState`);function Fi({defaultProp:e,onChange:t}){let[n,r]=b.useState(e),i=b.useRef(n),a=b.useRef(t);return Ni(()=>{a.current=t},[t]),b.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}Mi(Fi,`useUncontrolledState`);function Ii(e){return typeof e==`function`}Mi(Ii,`isFunction`);var Li=Symbol(`RADIX:SYNC_STATE`);function Ri(e,t,n,r){let{prop:i,defaultProp:a,onChange:o,caller:s}=t,c=i!==void 0,l=Ai(o),u=[{...n,state:a}];r&&u.push(r);let[d,f]=b.useReducer((t,n)=>{if(n.type===Li)return{...t,state:n.state};let r=e(t,n);return c&&!Object.is(r.state,t.state)&&l(r.state),r},...u),p=d.state,m=b.useRef(p);b.useEffect(()=>{m.current!==p&&(m.current=p,c||l(p))},[p,m,c]);let h=b.useMemo(()=>i===void 0?d:{...d,state:i},[d,i]);return b.useEffect(()=>{c&&!Object.is(i,d.state)&&f({type:Li,state:i})},[i,d.state,c]),[h,f]}Mi(Ri,`useControllableStateReducer`);var zi=Object.defineProperty,Bi=(e,t)=>zi(e,`name`,{value:t,configurable:!0});function Vi(e){let t=b.useRef({value:e,previous:e});return b.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}Bi(Vi,`usePrevious`);var Hi=Object.freeze({position:`absolute`,border:0,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,wordWrap:`normal`}),Ui=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},Wi=new WeakMap,Gi=new WeakMap,Ki={},qi=0,Ji=function(e){return e&&(e.host||Ji(e.parentNode))},Yi=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=Ji(t);return n&&e.contains(n)?n:(console.error(`aria-hidden`,t,`in not contained inside`,e,`. Doing nothing`),null)}).filter(function(e){return!!e})},Xi=function(e,t,n,r){var i=Yi(t,Array.isArray(e)?e:[e]);Ki[n]||(Ki[n]=new WeakMap);var a=Ki[n],o=[],s=new Set,c=new Set(i),l=function(e){!e||s.has(e)||(s.add(e),l(e.parentNode))};i.forEach(l);var u=function(e){!e||c.has(e)||Array.prototype.forEach.call(e.children,function(e){if(s.has(e))u(e);else try{var t=e.getAttribute(r),i=t!==null&&t!==`false`,c=(Wi.get(e)||0)+1,l=(a.get(e)||0)+1;Wi.set(e,c),a.set(e,l),o.push(e),c===1&&i&&Gi.set(e,!0),l===1&&e.setAttribute(n,`true`),i||e.setAttribute(r,`true`)}catch(t){console.error(`aria-hidden: cannot operate on `,e,t)}})};return u(t),s.clear(),qi++,function(){o.forEach(function(e){var t=Wi.get(e)-1,i=a.get(e)-1;Wi.set(e,t),a.set(e,i),t||(Gi.has(e)||e.removeAttribute(r),Gi.delete(e)),i||e.removeAttribute(n)}),qi--,qi||(Wi=new WeakMap,Wi=new WeakMap,Gi=new WeakMap,Ki={})}},Zi=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||Ui(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),Xi(r,i,n,`aria-hidden`)):function(){return null}},Qi=function(){return Qi=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Qi.apply(this,arguments)};function $i(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function ea(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var ta=`right-scroll-bar-position`,na=`width-before-scroll-bar`,ra=`with-scroll-bars-hidden`,ia=`--removed-body-scroll-bar-size`;function aa(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function oa(e,t){var n=(0,b.useState)(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(e){var t=n.value;t!==e&&(n.value=e,n.callback(e,t))}}}})[0];return n.callback=t,n.facade}var sa=typeof window<`u`?b.useLayoutEffect:b.useEffect,ca=new WeakMap;function la(e,t){var n=oa(t||null,function(t){return e.forEach(function(e){return aa(e,t)})});return sa(function(){var t=ca.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||aa(e,null)}),i.forEach(function(e){r.has(e)||aa(e,a)})}ca.set(n,e)},[e]),n}function ua(e){return e}function da(e,t){t===void 0&&(t=ua);var n=[],r=!1;return{read:function(){if(r)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var i=t(e,r);return n.push(i),function(){n=n.filter(function(e){return e!==i})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var i=n;n=[],i.forEach(e),t=n}var a=function(){var n=t;t=[],n.forEach(e)},o=function(){return Promise.resolve().then(a)};o(),n={push:function(e){t.push(e),o()},filter:function(e){return t=t.filter(e),n}}}}}function fa(e){e===void 0&&(e={});var t=da(null);return t.options=Qi({async:!0,ssr:!1},e),t}var pa=function(e){var t=e.sideCar,n=$i(e,[`sideCar`]);if(!t)throw Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw Error(`Sidecar medium not found`);return b.createElement(r,Qi({},n))};pa.isSideCarExport=!0;function ma(e,t){return e.useMedium(t),pa}var ha=fa(),ga=function(){},_a=b.forwardRef(function(e,t){var n=b.useRef(null),r=b.useState({onScrollCapture:ga,onWheelCapture:ga,onTouchMoveCapture:ga}),i=r[0],a=r[1],o=e.forwardProps,s=e.children,c=e.className,l=e.removeScrollBar,u=e.enabled,d=e.shards,f=e.sideCar,p=e.noRelative,m=e.noIsolation,h=e.inert,g=e.allowPinchZoom,_=e.as,v=_===void 0?`div`:_,y=e.gapMode,x=$i(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),S=f,C=la([n,t]),w=Qi(Qi({},x),i);return b.createElement(b.Fragment,null,u&&b.createElement(S,{sideCar:ha,removeScrollBar:l,shards:d,noRelative:p,noIsolation:m,inert:h,setCallbacks:a,allowPinchZoom:!!g,lockRef:n,gapMode:y}),o?b.cloneElement(b.Children.only(s),Qi(Qi({},w),{ref:C})):b.createElement(v,Qi({},w,{className:c,ref:C}),s))});_a.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},_a.classNames={fullWidth:na,zeroRight:ta};var va,ya=function(){if(va)return va;if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function ba(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=ya();return t&&e.setAttribute(`nonce`,t),e}function xa(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Sa(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var Ca=function(){var e=0,t=null;return{add:function(n){e==0&&(t=ba())&&(xa(t,n),Sa(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},wa=function(){var e=Ca();return function(t,n){b.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Ta=function(){var e=wa();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},Ea={left:0,top:0,right:0,gap:0},Da=function(e){return parseInt(e||``,10)||0},Oa=function(e){var t=window.getComputedStyle(document.body),n=t[e===`padding`?`paddingLeft`:`marginLeft`],r=t[e===`padding`?`paddingTop`:`marginTop`],i=t[e===`padding`?`paddingRight`:`marginRight`];return[Da(n),Da(r),Da(i)]},ka=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return Ea;var t=Oa(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},Aa=Ta(),ja=`data-scroll-locked`,Ma=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),`
|
|
2
|
+
.${ra} {
|
|
3
|
+
overflow: hidden ${r};
|
|
4
|
+
padding-right: ${s}px ${r};
|
|
5
|
+
}
|
|
6
|
+
body[${ja}] {
|
|
7
|
+
overflow: hidden ${r};
|
|
8
|
+
overscroll-behavior: contain;
|
|
9
|
+
${[t&&`position: relative ${r};`,n===`margin`&&`
|
|
10
|
+
padding-left: ${i}px;
|
|
11
|
+
padding-top: ${a}px;
|
|
12
|
+
padding-right: ${o}px;
|
|
13
|
+
margin-left:0;
|
|
14
|
+
margin-top:0;
|
|
15
|
+
margin-right: ${s}px ${r};
|
|
16
|
+
`,n===`padding`&&`padding-right: ${s}px ${r};`].filter(Boolean).join(``)}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.${ta} {
|
|
20
|
+
right: ${s}px ${r};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.${na} {
|
|
24
|
+
margin-right: ${s}px ${r};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.${ta} .${ta} {
|
|
28
|
+
right: 0 ${r};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.${na} .${na} {
|
|
32
|
+
margin-right: 0 ${r};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
body[${ja}] {
|
|
36
|
+
${ia}: ${s}px;
|
|
37
|
+
}
|
|
38
|
+
`},Na=function(){var e=parseInt(document.body.getAttribute(`data-scroll-locked`)||`0`,10);return isFinite(e)?e:0},Pa=function(){b.useEffect(function(){return document.body.setAttribute(ja,(Na()+1).toString()),function(){var e=Na()-1;e<=0?document.body.removeAttribute(ja):document.body.setAttribute(ja,e.toString())}},[])},Fa=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?`margin`:r;Pa();var a=b.useMemo(function(){return ka(i)},[i]);return b.createElement(Aa,{styles:Ma(a,!t,i,n?``:`!important`)})},Ia=!1;if(typeof window<`u`)try{var La=Object.defineProperty({},"passive",{get:function(){return Ia=!0,!0}});window.addEventListener(`test`,La,La),window.removeEventListener(`test`,La,La)}catch{Ia=!1}var Ra=Ia?{passive:!1}:!1,za=function(e){return e.tagName===`TEXTAREA`},Ba=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!==`hidden`&&!(n.overflowY===n.overflowX&&!za(e)&&n[t]===`visible`)},Va=function(e){return Ba(e,`overflowY`)},Ha=function(e){return Ba(e,`overflowX`)},Ua=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<`u`&&r instanceof ShadowRoot&&(r=r.host),Ka(e,r)){var i=qa(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Wa=function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]},Ga=function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]},Ka=function(e,t){return e===`v`?Va(t):Ha(t)},qa=function(e,t){return e===`v`?Wa(t):Ga(t)},Ja=function(e,t){return e===`h`&&t===`rtl`?-1:1},Ya=function(e,t,n,r,i){var a=Ja(e,window.getComputedStyle(t).direction),o=a*r,s=n.target,c=t.contains(s),l=!1,u=o>0,d=0,f=0;do{if(!s)break;var p=qa(e,s),m=p[0],h=p[1]-p[2]-a*m;(m||h)&&Ka(e,s)&&(d+=h,f+=m);var g=s.parentNode;s=g&&g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?g.host:g}while(!c&&s!==document.body||c&&(t.contains(s)||t===s));return(u&&(i&&Math.abs(d)<1||!i&&o>d)||!u&&(i&&Math.abs(f)<1||!i&&-o>f))&&(l=!0),l},Xa=function(e){return`changedTouches`in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Za=function(e){return[e.deltaX,e.deltaY]},Qa=function(e){return e&&`current`in e?e.current:e},$a=function(e,t){return e[0]===t[0]&&e[1]===t[1]},eo=function(e){return`
|
|
39
|
+
.block-interactivity-${e} {pointer-events: none;}
|
|
40
|
+
.allow-interactivity-${e} {pointer-events: all;}
|
|
41
|
+
`},to=0,no=[];function ro(e){var t=b.useRef([]),n=b.useRef([0,0]),r=b.useRef(),i=b.useState(to++)[0],a=b.useState(Ta)[0],o=b.useRef(e);b.useEffect(function(){o.current=e},[e]),b.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=ea([e.lockRef.current],(e.shards||[]).map(Qa),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=b.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=Xa(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=Ua(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=Ua(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return Ya(h,t,e,h===`h`?s:c,!0)},[]),c=b.useCallback(function(e){var n=e;if(!(!no.length||no[no.length-1]!==a)){var r=`deltaY`in n?Za(n):Xa(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&$a(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map(Qa).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=b.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:io(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=b.useCallback(function(e){n.current=Xa(e),r.current=void 0},[]),d=b.useCallback(function(t){l(t.type,Za(t),t.target,s(t,e.lockRef.current))},[]),f=b.useCallback(function(t){l(t.type,Xa(t),t.target,s(t,e.lockRef.current))},[]);b.useEffect(function(){return no.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,Ra),document.addEventListener(`touchmove`,c,Ra),document.addEventListener(`touchstart`,u,Ra),function(){no=no.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,Ra),document.removeEventListener(`touchmove`,c,Ra),document.removeEventListener(`touchstart`,u,Ra)}},[]);var p=e.removeScrollBar,m=e.inert;return b.createElement(b.Fragment,null,m?b.createElement(a,{styles:eo(i)}):null,p?b.createElement(Fa,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function io(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var ao=ma(ha,ro),oo=b.forwardRef(function(e,t){return b.createElement(_a,Qi({},e,{ref:t,sideCar:ao}))});oo.classNames=_a.classNames;var so=Object.defineProperty,P=(e,t)=>so(e,`name`,{value:t,configurable:!0}),co=[` `,`Enter`,`ArrowUp`,`ArrowDown`],lo=[` `,`Enter`],uo=`Select`,[fo,po,mo]=we(uo),[ho,go]=xe(uo,[mo,$r]),_o=$r(),[vo,yo]=ho(uo),[bo,xo]=ho(uo);function So(e){let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:c,dir:l,name:u,autoComplete:d,disabled:f,required:p,form:m,internal_do_not_use_render:h}=e,g=_o(t),[_,v]=b.useState(null),[y,S]=b.useState(null),[C,w]=b.useState(!1),T=Re(l),[E,D]=Pi({prop:r,defaultProp:i??!1,onChange:a,caller:uo}),[ee,O]=Pi({prop:o,defaultProp:s,onChange:c,caller:uo}),k=b.useRef(null),te=b.useRef(ee);b.useEffect(()=>{let e=m?_?.ownerDocument.getElementById(m):_?.form;if(e instanceof HTMLFormElement){let t=P(()=>O(te.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[m,_,O]);let ne=!_||!!m||!!_.closest(`form`),[re,ie]=b.useState(new Set),ae=Nt(),oe=Array.from(re).map(e=>e.props.value).join(`;`),se=b.useCallback(e=>{ie(t=>new Set(t).add(e))},[]),ce=b.useCallback(e=>{ie(t=>{let n=new Set(t);return n.delete(e),n})},[]),le={required:p,trigger:_,onTriggerChange:v,valueNode:y,onValueNodeChange:S,valueNodeHasChildren:C,onValueNodeHasChildrenChange:w,contentId:ae,value:ee,onValueChange:O,open:E,onOpenChange:D,dir:T,triggerPointerDownPosRef:k,disabled:f,name:u,autoComplete:d,form:m,nativeOptions:re,nativeSelectKey:oe,isFormControl:ne};return(0,x.jsx)(fi,{...g,children:(0,x.jsx)(vo,{scope:t,...le,children:(0,x.jsx)(fo.Provider,{scope:t,children:(0,x.jsx)(bo,{scope:t,onNativeOptionAdd:se,onNativeOptionRemove:ce,children:ls(h)?h(le):n})})})})}P(So,`SelectProvider`);var Co=P(e=>{let{__scopeSelect:t,children:n,...r}=e;return(0,x.jsx)(So,{__scopeSelect:t,...r,internal_do_not_use_render:({isFormControl:e})=>(0,x.jsxs)(x.Fragment,{children:[n,e?(0,x.jsx)(cs,{__scopeSelect:t}):null]})})},`Select`),wo=`SelectTrigger`,To=b.forwardRef(P(function(e,t){let{__scopeSelect:n,disabled:r=!1,...i}=e,a=_o(n),o=yo(wo,n),c=o.disabled||r,l=s(t,o.onTriggerChange),u=po(n),d=b.useRef(`touch`),[f,p,m]=ds(e=>{let t=u().filter(e=>!e.disabled),n=fs(t,e,t.find(e=>e.value===o.value));n!==void 0&&o.onValueChange(n.value)}),h=P(e=>{c||(o.onOpenChange(!0),m()),e&&(o.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})},`handleOpen`);return(0,x.jsx)(pi,{asChild:!0,...a,children:(0,x.jsx)(Ve.button,{type:`button`,role:`combobox`,"aria-controls":o.open?o.contentId:void 0,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":`none`,dir:o.dir,"data-state":o.open?`open`:`closed`,disabled:c,"data-disabled":c?``:void 0,"data-placeholder":us(o.value)?``:void 0,...i,ref:l,onClick:A(i.onClick,e=>{e.currentTarget.focus(),d.current!==`mouse`&&h(e)}),onPointerDown:A(i.onPointerDown,e=>{d.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(h(e),e.preventDefault())}),onKeyDown:A(i.onKeyDown,e=>{let t=f.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&p(e.key),!(t&&e.key===` `)&&co.includes(e.key)&&(h(),e.preventDefault())})})})},`SelectTrigger`)),Eo=`SelectValue`,Do=b.forwardRef(P(function(e,t){let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...c}=e,l=yo(Eo,n),{onValueNodeHasChildrenChange:u}=l,d=a!==void 0,f=s(t,l.onValueNodeChange);N(()=>{u(d)},[u,d]);let p=us(l.value);return(0,x.jsx)(Ve.span,{...c,asChild:!p&&c.asChild,ref:f,style:{pointerEvents:`none`},children:(0,x.jsx)(b.Fragment,{children:p?o:a},p?`placeholder`:`value`)})},`SelectValue`)),Oo=b.forwardRef(P(function(e,t){let{__scopeSelect:n,children:r,...i}=e;return(0,x.jsx)(Ve.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})},`SelectIcon`)),[ko,Ao]=ho(`SelectPortal`,{forceMount:void 0}),jo=P(e=>{let{__scopeSelect:t,forceMount:n,...r}=e;return(0,x.jsx)(ko,{scope:e.__scopeSelect,forceMount:n,children:(0,x.jsx)(gi,{asChild:!0,...r})})},`SelectPortal`),Mo=`SelectContent`,No=b.forwardRef(P(function(e,t){let n=Ao(Mo,e.__scopeSelect),{forceMount:r=n.forceMount,...i}=e,a=yo(Mo,e.__scopeSelect),[o,s]=b.useState();return N(()=>{s(new DocumentFragment)},[]),(0,x.jsx)(bi,{present:r||a.open,children:({present:e})=>e?(0,x.jsx)(zo,{...i,ref:t}):(0,x.jsx)(Po,{...i,fragment:o})})},`SelectContent`)),Po=b.forwardRef(P(function(e,t){let{__scopeSelect:n,children:r,fragment:i}=e;return i?se.createPortal((0,x.jsx)(Io,{scope:n,children:(0,x.jsx)(fo.Slot,{scope:n,children:(0,x.jsx)(`div`,{ref:t,children:r})})}),i):null},`SelectContentFragment`)),Fo=10,[Io,Lo]=ho(Mo),Ro=r(`SelectContent.RemoveScroll`),zo=b.forwardRef(P(function(e,t){let{__scopeSelect:n}=e,{position:r=`item-aligned`,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:c,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:h,hideWhenDetached:g,avoidCollisions:_,...v}=e,y=yo(Mo,n),[S,C]=b.useState(null),[w,T]=b.useState(null),E=s(t,C),[D,ee]=b.useState(null),[O,k]=b.useState(null),te=po(n),[ne,re]=b.useState(!1),ie=b.useRef(!1);b.useEffect(()=>{if(S)return Zi(S)},[S]),ut();let ae=b.useCallback(e=>{let[t,...n]=te().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&w&&(w.scrollTop=0),n===r&&w&&(w.scrollTop=w.scrollHeight),n?.focus(),document.activeElement!==i))return},[te,w]),oe=b.useCallback(()=>ae([D,S]),[ae,D,S]);b.useEffect(()=>{ne&&oe()},[ne,oe]);let{onOpenChange:se,triggerPointerDownPosRef:ce}=y;b.useEffect(()=>{if(S){let e={x:0,y:0},t=P(t=>{e={x:Math.abs(Math.round(t.pageX)-(ce.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(ce.current?.y??0))}},`handlePointerMove`),n=P(n=>{e.x<=10&&e.y<=10?n.preventDefault():n.composedPath().includes(S)||se(!1),document.removeEventListener(`pointermove`,t),ce.current=null},`handlePointerUp`);return ce.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[S,se,ce]),b.useEffect(()=>{let e=P(()=>se(!1),`close`);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[se]);let[le,ue]=ds(e=>{let t=te().filter(e=>!e.disabled),n=fs(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current?.focus())}),de=b.useCallback((e,t,n)=>{let r=!ie.current&&!n;(y.value!==void 0&&y.value===t||r)&&(ee(e),r&&(ie.current=!0))},[y.value]),fe=b.useCallback(()=>S?.focus(),[S]),pe=b.useCallback((e,t,n)=>{let r=!ie.current&&!n;(y.value!==void 0&&y.value===t||r)&&k(e)},[y.value]),me=r===`popper`?Vo:Bo,he=me===Vo?{side:c,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:h,hideWhenDetached:g,avoidCollisions:_}:{};return(0,x.jsx)(Io,{scope:n,content:S,viewport:w,onViewportChange:T,itemRefCallback:de,selectedItem:D,onItemLeave:fe,itemTextRefCallback:pe,focusSelectedItem:oe,selectedItemText:O,position:r,isPositioned:ne,searchRef:le,children:(0,x.jsx)(oo,{as:Ro,allowPinchZoom:!0,children:(0,x.jsx)(_t,{asChild:!0,trapped:y.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:A(i,e=>{y.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,x.jsx)(Qe,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>y.onOpenChange(!1),children:(0,x.jsx)(me,{role:`listbox`,id:y.contentId,"data-state":y.open?`open`:`closed`,dir:y.dir,onContextMenu:e=>e.preventDefault(),...v,...he,onPlaced:()=>re(!0),ref:E,style:{display:`flex`,flexDirection:`column`,outline:`none`,...v.style},onKeyDown:A(v.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&ue(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=te().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>ae(t)),e.preventDefault()}})})})})})})},`SelectContentImpl`)),Bo=b.forwardRef(P(function(e,t){let{__scopeSelect:n,onPlaced:r,...i}=e,a=yo(Mo,n),o=Lo(Mo,n),[c,l]=b.useState(null),[u,d]=b.useState(null),f=s(t,d),p=po(n),m=b.useRef(!1),h=b.useRef(!0),{viewport:g,selectedItem:_,selectedItemText:v,focusSelectedItem:y}=o,S=b.useCallback(()=>{if(a.trigger&&a.valueNode&&c&&u&&g&&_&&v){let e=a.trigger.getBoundingClientRect(),t=u.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),i=v.getBoundingClientRect();if(a.dir!==`rtl`){let r=i.left-t.left,a=n.left-r,o=e.left-a,s=e.width+o,l=Math.max(s,t.width),u=window.innerWidth-Fo,d=ue(a,[Fo,Math.max(Fo,u-l)]);c.style.minWidth=s+`px`,c.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,s=e.width+o,l=Math.max(s,t.width),u=window.innerWidth-Fo,d=ue(a,[Fo,Math.max(Fo,u-l)]);c.style.minWidth=s+`px`,c.style.right=d+`px`}let o=p(),s=window.innerHeight-Fo*2,l=g.scrollHeight,d=window.getComputedStyle(u),f=parseInt(d.borderTopWidth,10),h=parseInt(d.paddingTop,10),y=parseInt(d.borderBottomWidth,10),b=parseInt(d.paddingBottom,10),x=f+h+l+b+y,S=Math.min(_.offsetHeight*5,x),C=window.getComputedStyle(g),w=parseInt(C.paddingTop,10),T=parseInt(C.paddingBottom,10),E=e.top+e.height/2-Fo,D=s-E,ee=_.offsetHeight/2,O=_.offsetTop+ee,k=f+h+O,te=x-k;if(k<=E){let e=o.length>0&&_===o[o.length-1].ref.current;c.style.bottom=`0px`;let t=u.clientHeight-g.offsetTop-g.offsetHeight,n=k+Math.max(D,ee+(e?T:0)+t+y);c.style.height=n+`px`}else{let e=o.length>0&&_===o[0].ref.current;c.style.top=`0px`;let t=Math.max(E,f+g.offsetTop+(e?w:0)+ee)+te;c.style.height=t+`px`,g.scrollTop=k-E+g.offsetTop}c.style.margin=`${Fo}px 0`,c.style.minHeight=S+`px`,c.style.maxHeight=s+`px`,r?.(),requestAnimationFrame(()=>m.current=!0)}},[p,a.trigger,a.valueNode,c,u,g,_,v,a.dir,r]);N(()=>S(),[S]);let[C,w]=b.useState();return N(()=>{u&&w(window.getComputedStyle(u).zIndex)},[u]),(0,x.jsx)(Ho,{scope:n,contentWrapper:c,shouldExpandOnScrollRef:m,onScrollButtonChange:b.useCallback(e=>{e&&h.current===!0&&(S(),y?.(),h.current=!1)},[S,y]),children:(0,x.jsx)(`div`,{ref:l,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:C},children:(0,x.jsx)(Ve.div,{...i,ref:f,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})},`SelectItemAlignedPosition`)),Vo=b.forwardRef(P(function(e,t){let{__scopeSelect:n,align:r=`start`,collisionPadding:i=Fo,...a}=e,o=_o(n);return(0,x.jsx)(mi,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})},`SelectPopperPosition`)),[Ho,Uo]=ho(Mo,{}),Wo=`SelectViewport`,Go=b.forwardRef(P(function(e,t){let{__scopeSelect:n,nonce:r,...i}=e,a=Lo(Wo,n),o=Uo(Wo,n),c=s(t,a.onViewportChange),l=b.useRef(0);return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,x.jsx)(fo.Slot,{scope:n,children:(0,x.jsx)(Ve.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:c,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:A(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=o;if(r?.current&&n){let e=Math.abs(l.current-t.scrollTop);if(e>0){let r=window.innerHeight-Fo*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}l.current=t.scrollTop})})})]})},`SelectViewport`)),[Ko,qo]=ho(`SelectGroup`),Jo=`SelectItem`,[Yo,Xo]=ho(Jo),Zo=b.forwardRef(P(function(e,t){let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,c=yo(Jo,n),l=Lo(Jo,n),u=c.value===r,[d,f]=b.useState(a??``),[p,m]=b.useState(!1),h=s(t,Ge(e=>l.itemRefCallback?.(e,r,i))),g=Nt(),_=b.useRef(`touch`),v=P(()=>{i||(c.onValueChange(r),c.onOpenChange(!1))},`handleSelect`);return(0,x.jsx)(Yo,{scope:n,value:r,disabled:i,textId:g,isSelected:u,onItemTextChange:b.useCallback(e=>{f(t=>t||(e?.textContent??``).trim())},[]),children:(0,x.jsx)(fo.ItemSlot,{scope:n,value:r,disabled:i,textValue:d,children:(0,x.jsx)(Ve.div,{role:`option`,"aria-labelledby":g,"data-highlighted":p?``:void 0,"aria-selected":u&&p,"data-state":u?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...o,ref:h,onFocus:A(o.onFocus,()=>m(!0)),onBlur:A(o.onBlur,()=>m(!1)),onClick:A(o.onClick,()=>{_.current!==`mouse`&&v()}),onPointerUp:A(o.onPointerUp,()=>{_.current===`mouse`&&v()}),onPointerDown:A(o.onPointerDown,e=>{_.current=e.pointerType}),onPointerMove:A(o.onPointerMove,e=>{_.current=e.pointerType,i?l.onItemLeave?.():_.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:A(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&l.onItemLeave?.()}),onKeyDown:A(o.onKeyDown,e=>{i||e.target!==e.currentTarget||l.searchRef?.current!==``&&e.key===` `||(lo.includes(e.key)&&v(),e.key===` `&&e.preventDefault())})})})})},`SelectItem`)),Qo=`SelectItemText`,$o=b.forwardRef(P(function(e,t){let{__scopeSelect:n,className:r,style:i,...a}=e,o=yo(Qo,n),c=Lo(Qo,n),l=Xo(Qo,n),u=xo(Qo,n),[d,f]=b.useState(null),p=Ge(e=>c.itemTextRefCallback?.(e,l.value,l.disabled)),m=s(t,f,l.onItemTextChange,p),h=d?.textContent,g=b.useMemo(()=>(0,x.jsx)(`option`,{value:l.value,disabled:l.disabled,children:h},l.value),[l.disabled,l.value,h]),{onNativeOptionAdd:_,onNativeOptionRemove:v}=u;return N(()=>(_(g),()=>v(g)),[_,v,g]),(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(Ve.span,{id:l.textId,...a,ref:m}),l.isSelected&&o.valueNode&&!o.valueNodeHasChildren&&!us(o.value)?se.createPortal(a.children,o.valueNode):null]})},`SelectItemText`)),es=`SelectItemIndicator`,ts=b.forwardRef(P(function(e,t){let{__scopeSelect:n,...r}=e;return Xo(es,n).isSelected?(0,x.jsx)(Ve.span,{"aria-hidden":!0,...r,ref:t}):null},`SelectItemIndicator`)),ns=`SelectScrollUpButton`,rs=b.forwardRef(P(function(e,t){let n=Lo(ns,e.__scopeSelect),r=Uo(ns,e.__scopeSelect),[i,a]=b.useState(!1),o=s(t,r.onScrollButtonChange);return N(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollTop>0;a(e)};P(e,`handleScroll`);let t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,x.jsx)(os,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null},`SelectScrollUpButton`)),is=`SelectScrollDownButton`,as=b.forwardRef(P(function(e,t){let n=Lo(is,e.__scopeSelect),r=Uo(is,e.__scopeSelect),[i,a]=b.useState(!1),o=s(t,r.onScrollButtonChange);return N(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight,n=Math.ceil(t.scrollTop)<e;a(n)};P(e,`handleScroll`);let t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,x.jsx)(os,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null},`SelectScrollDownButton`)),os=b.forwardRef(P(function(e,t){let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=Lo(`SelectScrollButton`,n),o=b.useRef(null),s=po(n),c=b.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return b.useEffect(()=>()=>c(),[c]),N(()=>{s().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[s]),(0,x.jsx)(Ve.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:A(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:A(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:A(i.onPointerLeave,()=>{c()})})},`SelectScrollButtonImpl`)),ss=`SelectBubbleInput`,cs=b.forwardRef(P(function({__scopeSelect:e,...t},n){let r=yo(ss,e),{value:i,onValueChange:a,required:o,disabled:c,name:l,autoComplete:u,form:d}=r,{nativeOptions:f,nativeSelectKey:p}=r,m=b.useRef(null),h=s(n,m),g=i??``,_=Vi(g),v=Array.from(f).some(e=>(e.props.value??``)===``);return b.useEffect(()=>{let e=m.current;if(!e)return;let t=window.HTMLSelectElement.prototype,n=Object.getOwnPropertyDescriptor(t,`value`).set;if(_!==g&&n){let t=new Event(`change`,{bubbles:!0});n.call(e,g),e.dispatchEvent(t)}},[_,g]),(0,x.jsxs)(Ve.select,{"aria-hidden":!0,required:o,tabIndex:-1,name:l,autoComplete:u,disabled:c,form:d,onChange:e=>a(e.target.value),...t,style:{...Hi,...t.style},ref:h,defaultValue:g,children:[us(i)&&!v?(0,x.jsx)(`option`,{value:``}):null,Array.from(f)]},p)},`SelectBubbleInput`));function ls(e){return typeof e==`function`}P(ls,`isFunction`);function us(e){return e===``||e===void 0}P(us,`shouldShowPlaceholder`);function ds(e){let t=Ge(e),n=b.useRef(``),r=b.useRef(0),i=b.useCallback(e=>{let i=n.current+e;t(i),P((function e(t){n.current=t,window.clearTimeout(r.current),t!==``&&(r.current=window.setTimeout(()=>e(``),1e3))}),`updateSearch`)(i)},[t]),a=b.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return b.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}P(ds,`useTypeaheadSearch`);function fs(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=ps(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}P(fs,`findNextItem`);function ps(e,t){return e.map((n,r)=>e[(t+r)%e.length])}P(ps,`wrapArray`);var ms=Co,hs=Do;function gs({className:e,children:t,...n}){return(0,x.jsxs)(To,{"data-slot":`select-trigger`,className:i(`flex items-center justify-between gap-1.5 rounded-md border border-line bg-surface/60 px-2 py-1 text-xs text-ink-dim transition-colors`,`enabled:hover:border-line-strong enabled:hover:text-ink`,`focus-visible:ring-2 focus-visible:ring-brand/50 focus-visible:outline-none`,`disabled:cursor-not-allowed disabled:opacity-50`,`[&>span]:min-w-0 [&>span]:truncate`,e),...n,children:[t,(0,x.jsx)(Oo,{asChild:!0,children:(0,x.jsx)(d,{className:`size-3 shrink-0 opacity-60`})})]})}function _s({className:e,children:t,position:n=`popper`,...r}){return(0,x.jsx)(jo,{children:(0,x.jsxs)(No,{"data-slot":`select-content`,position:n,sideOffset:4,className:i(`relative z-50 min-w-[8rem] overflow-hidden rounded-lg border border-line-strong bg-surface text-xs text-ink-dim shadow-xl shadow-black/50`,`data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95`,`data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95`,`data-[side=bottom]:slide-in-from-top-1 data-[side=top]:slide-in-from-bottom-1`,n===`popper`&&`max-h-[var(--radix-select-content-available-height)] min-w-[var(--radix-select-trigger-width)]`,e),...r,children:[(0,x.jsx)(ys,{direction:`up`}),(0,x.jsx)(Go,{className:`p-1`,children:t}),(0,x.jsx)(ys,{direction:`down`})]})})}function vs({className:e,children:t,...n}){return(0,x.jsxs)(Zo,{"data-slot":`select-item`,className:i(`relative flex cursor-pointer items-center rounded-md py-1 pr-6 pl-2 outline-none select-none`,`focus:bg-brand/15 focus:text-brand data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,e),...n,children:[(0,x.jsx)(`span`,{className:`absolute right-1.5 flex size-3 items-center justify-center`,children:(0,x.jsx)(ts,{children:(0,x.jsx)(u,{className:`size-3`})})}),(0,x.jsx)($o,{children:t})]})}function ys({direction:e}){let t=e===`up`?rs:as,n=e===`up`?f:d;return(0,x.jsx)(t,{"data-slot":`select-scroll-${e}`,className:`flex cursor-default items-center justify-center py-1 text-ink-faint`,children:(0,x.jsx)(n,{className:`size-3`})})}var bs=`browsentic/action`,xs=`browsentic/bridge`,Ss=e=>({ok:!0,data:e}),Cs=(e,t)=>({ok:!1,error:{code:e,message:t}}),ws;function F(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var Ts=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},Es=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(ws=globalThis).__zod_globalConfig??(ws.__zod_globalConfig={});var Ds=globalThis.__zod_globalConfig;function Os(e){return e&&Object.assign(Ds,e),Ds}function ks(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function As(e,t){return typeof t==`bigint`?t.toString():t}function js(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}throw Error(`cached value already set`)}}}function Ms(e){return e==null}function Ns(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function Ps(e,t){let n=e/t,r=Math.round(n),i=2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}var Fs=Symbol(`evaluating`);function I(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Fs)return r===void 0&&(r=Fs,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Is(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Ls(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function Rs(e){return JSON.stringify(e)}function zs(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var Bs=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function Vs(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Hs=js(()=>{if(Ds.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function Us(e){if(Vs(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(Vs(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function Ws(e){return Us(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var Gs=new Set([`string`,`number`,`symbol`]);function Ks(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function qs(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function L(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw 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 Js(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var Ys={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Xs(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return qs(e,Ls(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return Is(this,`shape`,e),e},checks:[]}))}function Zs(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return qs(e,Ls(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return Is(this,`shape`,r),r},checks:[]}))}function Qs(e,t){if(!Us(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return qs(e,Ls(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Is(this,`shape`,n),n}}))}function $s(e,t){if(!Us(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return qs(e,Ls(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Is(this,`shape`,n),n}}))}function ec(e,t){if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);return qs(e,Ls(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return Is(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function tc(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return qs(t,Ls(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return Is(this,`shape`,i),i},checks:[]}))}function nc(e,t,n){return qs(t,Ls(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return Is(this,`shape`,i),i}}))}function rc(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function ic(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function ac(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function oc(e){return typeof e==`string`?e:e?.message}function sc(e,t,n){let r=e.message?e.message:oc(e.inst?._zod.def?.error?.(e))??oc(t?.error?.(e))??oc(n.customError?.(e))??oc(n.localeError?.(e))??`Invalid input`,{inst:i,continue:a,input:o,...s}=e;return s.path??=[],s.message=r,t?.reportInput&&(s.input=o),s}function cc(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function lc(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var uc=(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,As,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},dc=F(`$ZodError`,uc),fc=F(`$ZodError`,uc,{Parent:Error});function pc(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function mc(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i];i===e.length-1?(r[n]=r[n]||{_errors:[]},r[n]._errors.push(t(a))):r[n]=r[n]||{_errors:[]},r=r[n],i++}}}};return r(e),n}var hc=e=>(t,n,r,i)=>{let a=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new Ts;if(o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>sc(e,a,Os())));throw Bs(t,i?.callee),t}return o.value},gc=e=>async(t,n,r,i)=>{let a=r?{...r,async:!0}:{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>sc(e,a,Os())));throw Bs(t,i?.callee),t}return o.value},_c=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new Ts;return a.issues.length?{success:!1,error:new(e??dc)(a.issues.map(e=>sc(e,i,Os())))}:{success:!0,data:a.value}},vc=_c(fc),yc=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>sc(e,i,Os())))}:{success:!0,data:a.value}},bc=yc(fc),xc=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return hc(e)(t,n,i)},Sc=e=>(t,n,r)=>hc(e)(t,n,r),Cc=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return gc(e)(t,n,i)},wc=e=>async(t,n,r)=>gc(e)(t,n,r),Tc=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return _c(e)(t,n,i)},Ec=e=>(t,n,r)=>_c(e)(t,n,r),Dc=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return yc(e)(t,n,i)},Oc=e=>async(t,n,r)=>yc(e)(t,n,r),kc=/^[cC][0-9a-z]{6,}$/,Ac=/^[0-9a-z]+$/,jc=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Mc=/^[0-9a-vA-V]{20}$/,Nc=/^[A-Za-z0-9]{27}$/,Pc=/^[a-zA-Z0-9_-]{21}$/,Fc=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Ic=/^([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})$/,Lc=e=>e?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)$/,Rc=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,zc=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function Bc(){return new RegExp(zc,`u`)}var Vc=/^(?:(?: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])$/,Hc=/^(([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}|:))$/,Uc=/^((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])$/,Wc=/^(([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])$/,Gc=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Kc=/^[A-Za-z0-9_-]*$/,qc=/^https?$/,Jc=/^\+[1-9]\d{6,14}$/,Yc=`(?:(?:\\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])))`,Xc=RegExp(`^${Yc}$`);function Zc(e){let 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 Qc(e){return RegExp(`^${Zc(e)}$`)}function $c(e){let t=Zc({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${Yc}T(?:${r})$`)}var el=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},tl=/^-?\d+$/,nl=/^-?\d+(?:\.\d+)?$/,rl=/^(?:true|false)$/i,il=/^[^A-Z]*$/,al=/^[^a-z]*$/,ol=F(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),sl={number:`number`,bigint:`bigint`,object:`date`},cl=F(`$ZodCheckLessThan`,(e,t)=>{ol.init(e,t);let n=sl[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.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})}}),ll=F(`$ZodCheckGreaterThan`,(e,t)=>{ol.init(e,t);let n=sl[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.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})}}),ul=F(`$ZodCheckMultipleOf`,(e,t)=>{ol.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):Ps(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})}}),dl=F(`$ZodCheckNumberFormat`,(e,t)=>{ol.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=Ys[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=tl)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),fl=F(`$ZodCheckMaxLength`,(e,t)=>{var n;ol.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Ms(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=cc(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),pl=F(`$ZodCheckMinLength`,(e,t)=>{var n;ol.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Ms(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=cc(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),ml=F(`$ZodCheckLengthEquals`,(e,t)=>{var n;ol.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Ms(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=cc(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),hl=F(`$ZodCheckStringFormat`,(e,t)=>{var n,r;ol.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),gl=F(`$ZodCheckRegex`,(e,t)=>{hl.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})}}),_l=F(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=il,hl.init(e,t)}),vl=F(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=al,hl.init(e,t)}),yl=F(`$ZodCheckIncludes`,(e,t)=>{ol.init(e,t);let n=Ks(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),bl=F(`$ZodCheckStartsWith`,(e,t)=>{ol.init(e,t);let n=RegExp(`^${Ks(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),xl=F(`$ZodCheckEndsWith`,(e,t)=>{ol.init(e,t);let n=RegExp(`.*${Ks(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Sl=F(`$ZodCheckOverwrite`,(e,t)=>{ol.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),Cl=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
42
|
+
`).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.args,n=[...(this?.content??[``]).map(e=>` ${e}`)];return new e(...t,n.join(`
|
|
43
|
+
`))}},wl={major:4,minor:4,patch:3},R=F(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=wl;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=rc(e),i;for(let a of t){if(a._zod.def.when){if(ic(e)||!a._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new Ts;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=rc(e,t))});else{if(e.issues.length===t)continue;r||=rc(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(rc(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new Ts;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction===`backward`){let t=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,a)):n(t,i,a)}let o=e._zod.parse(i,a);if(o instanceof Promise){if(a.async===!1)throw new Ts;return o.then(e=>t(e,r,a))}return t(o,r,a)}}I(e,`~standard`,()=>({validate:t=>{try{let n=vc(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return bc(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}))}),Tl=F(`$ZodString`,(e,t)=>{R.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??el(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),z=F(`$ZodStringFormat`,(e,t)=>{hl.init(e,t),Tl.init(e,t)}),El=F(`$ZodGUID`,(e,t)=>{t.pattern??=Ic,z.init(e,t)}),Dl=F(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=Lc(e)}else t.pattern??=Lc();z.init(e,t)}),Ol=F(`$ZodEmail`,(e,t)=>{t.pattern??=Rc,z.init(e,t)}),kl=F(`$ZodURL`,(e,t)=>{z.init(e,t),e._zod.check=n=>{try{let r=n.value.trim();if(!t.normalize&&t.protocol?.source===qc.source&&!/^https?:\/\//i.test(r)){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}let i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.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(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.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=i.href:n.value=r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Al=F(`$ZodEmoji`,(e,t)=>{t.pattern??=Bc(),z.init(e,t)}),jl=F(`$ZodNanoID`,(e,t)=>{t.pattern??=Pc,z.init(e,t)}),Ml=F(`$ZodCUID`,(e,t)=>{t.pattern??=kc,z.init(e,t)}),Nl=F(`$ZodCUID2`,(e,t)=>{t.pattern??=Ac,z.init(e,t)}),Pl=F(`$ZodULID`,(e,t)=>{t.pattern??=jc,z.init(e,t)}),Fl=F(`$ZodXID`,(e,t)=>{t.pattern??=Mc,z.init(e,t)}),Il=F(`$ZodKSUID`,(e,t)=>{t.pattern??=Nc,z.init(e,t)}),Ll=F(`$ZodISODateTime`,(e,t)=>{t.pattern??=$c(t),z.init(e,t)}),Rl=F(`$ZodISODate`,(e,t)=>{t.pattern??=Xc,z.init(e,t)}),zl=F(`$ZodISOTime`,(e,t)=>{t.pattern??=Qc(t),z.init(e,t)}),Bl=F(`$ZodISODuration`,(e,t)=>{t.pattern??=Fc,z.init(e,t)}),Vl=F(`$ZodIPv4`,(e,t)=>{t.pattern??=Vc,z.init(e,t),e._zod.bag.format=`ipv4`}),Hl=F(`$ZodIPv6`,(e,t)=>{t.pattern??=Hc,z.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})}}}),Ul=F(`$ZodCIDRv4`,(e,t)=>{t.pattern??=Uc,z.init(e,t)}),Wl=F(`$ZodCIDRv6`,(e,t)=>{t.pattern??=Wc,z.init(e,t),e._zod.check=n=>{let r=n.value.split(`/`);try{if(r.length!==2)throw Error();let[e,t]=r;if(!t)throw Error();let n=Number(t);if(`${n}`!==t||n<0||n>128)throw Error();new URL(`http://[${e}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function Gl(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var Kl=F(`$ZodBase64`,(e,t)=>{t.pattern??=Gc,z.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{Gl(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function ql(e){if(!Kc.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return Gl(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var Jl=F(`$ZodBase64URL`,(e,t)=>{t.pattern??=Kc,z.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{ql(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),Yl=F(`$ZodE164`,(e,t)=>{t.pattern??=Jc,z.init(e,t)});function Xl(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}var Zl=F(`$ZodJWT`,(e,t)=>{z.init(e,t),e._zod.check=n=>{Xl(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),Ql=F(`$ZodNumber`,(e,t)=>{R.init(e,t),e._zod.pattern=e._zod.bag.pattern??nl,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),$l=F(`$ZodNumberFormat`,(e,t)=>{dl.init(e,t),Ql.init(e,t)}),eu=F(`$ZodBoolean`,(e,t)=>{R.init(e,t),e._zod.pattern=rl,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),tu=F(`$ZodUnknown`,(e,t)=>{R.init(e,t),e._zod.parse=e=>e}),nu=F(`$ZodNever`,(e,t)=>{R.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function ru(e,t,n){e.issues.length&&t.issues.push(...ac(n,e.issues)),t.value[n]=e.value}var iu=F(`$ZodArray`,(e,t)=>{R.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>ru(t,n,e))):ru(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function au(e,t,n,r,i,a){let o=n in r;if(e.issues.length){if(i&&a&&!o)return;t.issues.push(...ac(n,e.issues))}if(!o&&!i){e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]});return}e.value===void 0?o&&(t.value[n]=void 0):t.value[n]=e.value}function ou(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=Js(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function su(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optin===`optional`,d=c.optout===`optional`;for(let i in t){if(i===`__proto__`||s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>au(e,n,i,t,u,d))):au(a,n,i,t,u,d)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}var cu=F(`$ZodObject`,(e,t)=>{if(R.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;Object.defineProperty(t,"shape",{get:()=>{let n={...e};return Object.defineProperty(t,"shape",{value:n}),n}})}let n=js(()=>ou(t));I(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=Vs,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e],r=n._zod.optin===`optional`,i=n._zod.optout===`optional`,a=n._zod.run({value:s[e],issues:[]},o);a instanceof Promise?c.push(a.then(n=>au(n,t,e,s,r,i))):au(a,t,e,s,r,i)}return i?su(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),lu=F(`$ZodObjectJIT`,(e,t)=>{cu.init(e,t);let n=e._zod.parse,r=js(()=>ou(t)),i=e=>{let t=new Cl([`shape`,`payload`,`ctx`]),n=r.value,i=e=>{let t=Rs(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of n.keys)a[e]=`key_${o++}`;t.write(`const newResult = {};`);for(let r of n.keys){let n=a[r],o=Rs(r),s=e[r],c=s?._zod?.optin===`optional`,l=s?._zod?.optout===`optional`;t.write(`const ${n} = ${i(r)};`),c&&l?t.write(`
|
|
44
|
+
if (${n}.issues.length) {
|
|
45
|
+
if (${o} in input) {
|
|
46
|
+
payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
|
|
47
|
+
...iss,
|
|
48
|
+
path: iss.path ? [${o}, ...iss.path] : [${o}]
|
|
49
|
+
})));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (${n}.value === undefined) {
|
|
54
|
+
if (${o} in input) {
|
|
55
|
+
newResult[${o}] = undefined;
|
|
56
|
+
}
|
|
57
|
+
} else {
|
|
58
|
+
newResult[${o}] = ${n}.value;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
`):c?t.write(`
|
|
62
|
+
if (${n}.issues.length) {
|
|
63
|
+
payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
|
|
64
|
+
...iss,
|
|
65
|
+
path: iss.path ? [${o}, ...iss.path] : [${o}]
|
|
66
|
+
})));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (${n}.value === undefined) {
|
|
70
|
+
if (${o} in input) {
|
|
71
|
+
newResult[${o}] = undefined;
|
|
72
|
+
}
|
|
73
|
+
} else {
|
|
74
|
+
newResult[${o}] = ${n}.value;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
`):t.write(`
|
|
78
|
+
const ${n}_present = ${o} in input;
|
|
79
|
+
if (${n}.issues.length) {
|
|
80
|
+
payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
|
|
81
|
+
...iss,
|
|
82
|
+
path: iss.path ? [${o}, ...iss.path] : [${o}]
|
|
83
|
+
})));
|
|
84
|
+
}
|
|
85
|
+
if (!${n}_present && !${n}.issues.length) {
|
|
86
|
+
payload.issues.push({
|
|
87
|
+
code: "invalid_type",
|
|
88
|
+
expected: "nonoptional",
|
|
89
|
+
input: undefined,
|
|
90
|
+
path: [${o}]
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (${n}_present) {
|
|
95
|
+
if (${n}.value === undefined) {
|
|
96
|
+
newResult[${o}] = undefined;
|
|
97
|
+
} else {
|
|
98
|
+
newResult[${o}] = ${n}.value;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
`)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=Vs,s=!Ds.jitless,c=s&&Hs.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?su([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function uu(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!rc(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>sc(e,r,Os())))}),t)}var du=F(`$ZodUnion`,(e,t)=>{R.init(e,t),I(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),I(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),I(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),I(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>Ns(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>uu(t,r,e,i)):uu(o,r,e,i)}}),fu=F(`$ZodIntersection`,(e,t)=>{R.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>mu(e,t,n)):mu(e,i,a)}});function pu(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Us(e)&&Us(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=pu(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=pu(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function mu(e,t,n){let r=new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),rc(e))return e;let o=pu(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var hu=F(`$ZodRecord`,(e,t)=>{R.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Us(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[],o=t.keyType._zod.values;if(o){n.value={};let s=new Set;for(let c of o)if(typeof c==`string`||typeof c==`number`||typeof c==`symbol`){s.add(typeof c==`number`?c.toString():c);let o=t.keyType._zod.run({value:c,issues:[]},r);if(o instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(o.issues.length){n.issues.push({code:`invalid_key`,origin:`record`,issues:o.issues.map(e=>sc(e,r,Os())),input:c,path:[c],inst:e});continue}let l=o.value,u=t.valueType._zod.run({value:i[c],issues:[]},r);u instanceof Promise?a.push(u.then(e=>{e.issues.length&&n.issues.push(...ac(c,e.issues)),n.value[l]=e.value})):(u.issues.length&&n.issues.push(...ac(c,u.issues)),n.value[l]=u.value)}let c;for(let e in i)s.has(e)||(c??=[],c.push(e));c&&c.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:c})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`||!Object.prototype.propertyIsEnumerable.call(i,o))continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof o==`string`&&nl.test(o)&&s.issues.length){let e=t.keyType._zod.run({value:Number(o),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(s=e)}if(s.issues.length){t.mode===`loose`?n.value[o]=i[o]:n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>sc(e,r,Os())),input:o,path:[o],inst:e});continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...ac(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...ac(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),gu=F(`$ZodEnum`,(e,t)=>{R.init(e,t);let n=ks(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>Gs.has(typeof e)).map(e=>typeof e==`string`?Ks(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),_u=F(`$ZodTransform`,(e,t)=>{R.init(e,t),e._zod.optin=`optional`,e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Es(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n.fallback=!0,n));if(i instanceof Promise)throw new Ts;return n.value=i,n.fallback=!0,n}});function vu(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var yu=F(`$ZodOptional`,(e,t)=>{R.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,I(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),I(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${Ns(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=e.value,i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>vu(e,r)):vu(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),bu=F(`$ZodExactOptional`,(e,t)=>{yu.init(e,t),I(e._zod,`values`,()=>t.innerType._zod.values),I(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),xu=F(`$ZodNullable`,(e,t)=>{R.init(e,t),I(e._zod,`optin`,()=>t.innerType._zod.optin),I(e._zod,`optout`,()=>t.innerType._zod.optout),I(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${Ns(e.source)}|null)$`):void 0}),I(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Su=F(`$ZodDefault`,(e,t)=>{R.init(e,t),e._zod.optin=`optional`,I(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Cu(e,t)):Cu(r,t)}});function Cu(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var wu=F(`$ZodPrefault`,(e,t)=>{R.init(e,t),e._zod.optin=`optional`,I(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Tu=F(`$ZodNonOptional`,(e,t)=>{R.init(e,t),I(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Eu(t,e)):Eu(i,e)}});function Eu(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}var Du=F(`$ZodCatch`,(e,t)=>{R.init(e,t),e._zod.optin=`optional`,I(e._zod,`optout`,()=>t.innerType._zod.optout),I(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>sc(e,n,Os()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>sc(e,n,Os()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),Ou=F(`$ZodPipe`,(e,t)=>{R.init(e,t),I(e._zod,`values`,()=>t.in._zod.values),I(e._zod,`optin`,()=>t.in._zod.optin),I(e._zod,`optout`,()=>t.out._zod.optout),I(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>ku(e,t.in,n)):ku(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>ku(e,t.out,n)):ku(r,t.out,n)}});function ku(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}var Au=F(`$ZodReadonly`,(e,t)=>{R.init(e,t),I(e._zod,`propValues`,()=>t.innerType._zod.propValues),I(e._zod,`values`,()=>t.innerType._zod.values),I(e._zod,`optin`,()=>t.innerType?._zod?.optin),I(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(ju):ju(r)}});function ju(e){return e.value=Object.freeze(e.value),e}var Mu=F(`$ZodCustom`,(e,t)=>{ol.init(e,t),R.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Nu(t,n,r,e));Nu(i,n,r,e)}});function Nu(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(lc(e))}}var Pu,Fu=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Iu(){return new Fu}(Pu=globalThis).__zod_globalRegistry??(Pu.__zod_globalRegistry=Iu());var Lu=globalThis.__zod_globalRegistry;function Ru(e,t){return new e({type:`string`,...L(t)})}function zu(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...L(t)})}function Bu(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...L(t)})}function Vu(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...L(t)})}function Hu(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...L(t)})}function Uu(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...L(t)})}function Wu(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...L(t)})}function Gu(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...L(t)})}function Ku(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...L(t)})}function qu(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...L(t)})}function Ju(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...L(t)})}function Yu(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...L(t)})}function Xu(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...L(t)})}function Zu(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...L(t)})}function Qu(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...L(t)})}function $u(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...L(t)})}function ed(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...L(t)})}function td(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...L(t)})}function nd(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...L(t)})}function rd(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...L(t)})}function id(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...L(t)})}function ad(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...L(t)})}function od(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...L(t)})}function sd(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...L(t)})}function cd(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...L(t)})}function ld(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...L(t)})}function ud(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...L(t)})}function dd(e,t){return new e({type:`number`,checks:[],...L(t)})}function fd(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...L(t)})}function pd(e,t){return new e({type:`boolean`,...L(t)})}function md(e){return new e({type:`unknown`})}function hd(e,t){return new e({type:`never`,...L(t)})}function gd(e,t){return new cl({check:`less_than`,...L(t),value:e,inclusive:!1})}function _d(e,t){return new cl({check:`less_than`,...L(t),value:e,inclusive:!0})}function vd(e,t){return new ll({check:`greater_than`,...L(t),value:e,inclusive:!1})}function yd(e,t){return new ll({check:`greater_than`,...L(t),value:e,inclusive:!0})}function bd(e,t){return new ul({check:`multiple_of`,...L(t),value:e})}function xd(e,t){return new fl({check:`max_length`,...L(t),maximum:e})}function Sd(e,t){return new pl({check:`min_length`,...L(t),minimum:e})}function Cd(e,t){return new ml({check:`length_equals`,...L(t),length:e})}function wd(e,t){return new gl({check:`string_format`,format:`regex`,...L(t),pattern:e})}function Td(e){return new _l({check:`string_format`,format:`lowercase`,...L(e)})}function Ed(e){return new vl({check:`string_format`,format:`uppercase`,...L(e)})}function Dd(e,t){return new yl({check:`string_format`,format:`includes`,...L(t),includes:e})}function Od(e,t){return new bl({check:`string_format`,format:`starts_with`,...L(t),prefix:e})}function kd(e,t){return new xl({check:`string_format`,format:`ends_with`,...L(t),suffix:e})}function Ad(e){return new Sl({check:`overwrite`,tx:e})}function jd(e){return Ad(t=>t.normalize(e))}function Md(){return Ad(e=>e.trim())}function Nd(){return Ad(e=>e.toLowerCase())}function Pd(){return Ad(e=>e.toUpperCase())}function Fd(){return Ad(e=>zs(e))}function Id(e,t,n){return new e({type:`array`,element:t,...L(n)})}function Ld(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...L(n)})}function Rd(e,t){let n=zd(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(lc(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=t.value,r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(lc(r))}},e(t.value,t)),t);return n}function zd(e,t){let n=new ol({check:`custom`,...L(t)});return n._zod.check=e,n}function Bd(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??Lu,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function B(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,B(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&Ud(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function Vd(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
|
|
103
|
+
|
|
104
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function Hd(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:Gd(t,`input`,e.processors),output:Gd(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Ud(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return Ud(r.element,n);if(r.type===`set`)return Ud(r.valueType,n);if(r.type===`lazy`)return Ud(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 Ud(r.innerType,n);if(r.type===`intersection`)return Ud(r.left,n)||Ud(r.right,n);if(r.type===`record`||r.type===`map`)return Ud(r.keyType,n)||Ud(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:Ud(r.in,n)||Ud(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Ud(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Ud(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Ud(e,n))return!0;return!!(r.rest&&Ud(r.rest,n))}return!1}var Wd=(e,t={})=>n=>{let r=Bd({...n,processors:t});return B(e,r),Vd(r,e),Hd(r,e)},Gd=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Bd({...i??{},target:a,io:t,processors:n});return B(e,o),Vd(o,e),Hd(o,e)},Kd={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},qd=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Kd[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},Jd=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},Yd=(e,t,n,r)=>{n.type=`boolean`},Xd=(e,t,n,r)=>{n.not={}},Zd=(e,t,n,r)=>{let i=e._zod.def,a=ks(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},Qd=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},$d=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},ef=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=B(a.element,t,{...r,path:[...r.path,`items`]})},tf=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=B(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=B(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},nf=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>B(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},rf=(e,t,n,r)=>{let i=e._zod.def,a=B(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=B(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},af=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=B(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else(t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=B(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=B(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},of=(e,t,n,r)=>{let i=e._zod.def,a=B(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},sf=(e,t,n,r)=>{let i=e._zod.def;B(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},cf=(e,t,n,r)=>{let i=e._zod.def;B(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},lf=(e,t,n,r)=>{let i=e._zod.def;B(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},uf=(e,t,n,r)=>{let i=e._zod.def;B(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},df=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;B(o,t,r);let s=t.seen.get(e);s.ref=o},ff=(e,t,n,r)=>{let i=e._zod.def;B(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},pf=(e,t,n,r)=>{let i=e._zod.def;B(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},mf=F(`ZodISODateTime`,(e,t)=>{Ll.init(e,t),U.init(e,t)});function hf(e){return sd(mf,e)}var gf=F(`ZodISODate`,(e,t)=>{Rl.init(e,t),U.init(e,t)});function _f(e){return cd(gf,e)}var vf=F(`ZodISOTime`,(e,t)=>{zl.init(e,t),U.init(e,t)});function yf(e){return ld(vf,e)}var bf=F(`ZodISODuration`,(e,t)=>{Bl.init(e,t),U.init(e,t)});function xf(e){return ud(bf,e)}var Sf=F(`ZodError`,(e,t)=>{dc.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>mc(e,t)},flatten:{value:t=>pc(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,As,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,As,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),Cf=hc(Sf),wf=gc(Sf),Tf=_c(Sf),Ef=yc(Sf),Df=xc(Sf),Of=Sc(Sf),kf=Cc(Sf),Af=wc(Sf),jf=Tc(Sf),Mf=Ec(Sf),Nf=Dc(Sf),Pf=Oc(Sf),Ff=new WeakMap;function If(e,t,n){let r=Object.getPrototypeOf(e),i=Ff.get(r);if(i||(i=new Set,Ff.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}var V=F(`ZodType`,(e,t)=>(R.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:Gd(e,`input`),output:Gd(e,`output`)}}),e.toJSONSchema=Wd(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>Cf(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Tf(e,t,n),e.parseAsync=async(t,n)=>wf(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Ef(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Df(e,t,n),e.decode=(t,n)=>Of(e,t,n),e.encodeAsync=async(t,n)=>kf(e,t,n),e.decodeAsync=async(t,n)=>Af(e,t,n),e.safeEncode=(t,n)=>jf(e,t,n),e.safeDecode=(t,n)=>Mf(e,t,n),e.safeEncodeAsync=async(t,n)=>Nf(e,t,n),e.safeDecodeAsync=async(t,n)=>Pf(e,t,n),If(e,`ZodType`,{check(...e){let t=this.def;return this.clone(Ls(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return qs(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Up(e,t))},superRefine(e,t){return this.check(Wp(e,t))},overwrite(e){return this.check(Ad(e))},optional(){return Tp(this)},exactOptional(){return Dp(this)},nullable(){return kp(this)},nullish(){return Tp(kp(this))},nonoptional(e){return Fp(this,e)},array(){return pp(this)},or(e){return gp([this,e])},and(e){return vp(this,e)},transform(e){return zp(this,Cp(e))},default(e){return jp(this,e)},prefault(e){return Np(this,e)},catch(e){return Lp(this,e)},pipe(e){return zp(this,e)},readonly(){return Vp(this)},describe(e){let t=this.clone();return Lu.add(t,{description:e}),t},meta(...e){if(e.length===0)return Lu.get(this);let t=this.clone();return Lu.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return Lu.get(e)?.description},configurable:!0}),e)),Lf=F(`_ZodString`,(e,t)=>{Tl.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qd(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,If(e,`_ZodString`,{regex(...e){return this.check(wd(...e))},includes(...e){return this.check(Dd(...e))},startsWith(...e){return this.check(Od(...e))},endsWith(...e){return this.check(kd(...e))},min(...e){return this.check(Sd(...e))},max(...e){return this.check(xd(...e))},length(...e){return this.check(Cd(...e))},nonempty(...e){return this.check(Sd(1,...e))},lowercase(e){return this.check(Td(e))},uppercase(e){return this.check(Ed(e))},trim(){return this.check(Md())},normalize(...e){return this.check(jd(...e))},toLowerCase(){return this.check(Nd())},toUpperCase(){return this.check(Pd())},slugify(){return this.check(Fd())}})}),Rf=F(`ZodString`,(e,t)=>{Tl.init(e,t),Lf.init(e,t),e.email=t=>e.check(zu(zf,t)),e.url=t=>e.check(Gu(Hf,t)),e.jwt=t=>e.check(od(rp,t)),e.emoji=t=>e.check(Ku(Uf,t)),e.guid=t=>e.check(Bu(Bf,t)),e.uuid=t=>e.check(Vu(Vf,t)),e.uuidv4=t=>e.check(Hu(Vf,t)),e.uuidv6=t=>e.check(Uu(Vf,t)),e.uuidv7=t=>e.check(Wu(Vf,t)),e.nanoid=t=>e.check(qu(Wf,t)),e.guid=t=>e.check(Bu(Bf,t)),e.cuid=t=>e.check(Ju(Gf,t)),e.cuid2=t=>e.check(Yu(Kf,t)),e.ulid=t=>e.check(Xu(qf,t)),e.base64=t=>e.check(rd(ep,t)),e.base64url=t=>e.check(id(tp,t)),e.xid=t=>e.check(Zu(Jf,t)),e.ksuid=t=>e.check(Qu(Yf,t)),e.ipv4=t=>e.check($u(Xf,t)),e.ipv6=t=>e.check(ed(Zf,t)),e.cidrv4=t=>e.check(td(Qf,t)),e.cidrv6=t=>e.check(nd($f,t)),e.e164=t=>e.check(ad(np,t)),e.datetime=t=>e.check(hf(t)),e.date=t=>e.check(_f(t)),e.time=t=>e.check(yf(t)),e.duration=t=>e.check(xf(t))});function H(e){return Ru(Rf,e)}var U=F(`ZodStringFormat`,(e,t)=>{z.init(e,t),Lf.init(e,t)}),zf=F(`ZodEmail`,(e,t)=>{Ol.init(e,t),U.init(e,t)}),Bf=F(`ZodGUID`,(e,t)=>{El.init(e,t),U.init(e,t)}),Vf=F(`ZodUUID`,(e,t)=>{Dl.init(e,t),U.init(e,t)}),Hf=F(`ZodURL`,(e,t)=>{kl.init(e,t),U.init(e,t)}),Uf=F(`ZodEmoji`,(e,t)=>{Al.init(e,t),U.init(e,t)}),Wf=F(`ZodNanoID`,(e,t)=>{jl.init(e,t),U.init(e,t)}),Gf=F(`ZodCUID`,(e,t)=>{Ml.init(e,t),U.init(e,t)}),Kf=F(`ZodCUID2`,(e,t)=>{Nl.init(e,t),U.init(e,t)}),qf=F(`ZodULID`,(e,t)=>{Pl.init(e,t),U.init(e,t)}),Jf=F(`ZodXID`,(e,t)=>{Fl.init(e,t),U.init(e,t)}),Yf=F(`ZodKSUID`,(e,t)=>{Il.init(e,t),U.init(e,t)}),Xf=F(`ZodIPv4`,(e,t)=>{Vl.init(e,t),U.init(e,t)}),Zf=F(`ZodIPv6`,(e,t)=>{Hl.init(e,t),U.init(e,t)}),Qf=F(`ZodCIDRv4`,(e,t)=>{Ul.init(e,t),U.init(e,t)}),$f=F(`ZodCIDRv6`,(e,t)=>{Wl.init(e,t),U.init(e,t)}),ep=F(`ZodBase64`,(e,t)=>{Kl.init(e,t),U.init(e,t)}),tp=F(`ZodBase64URL`,(e,t)=>{Jl.init(e,t),U.init(e,t)}),np=F(`ZodE164`,(e,t)=>{Yl.init(e,t),U.init(e,t)}),rp=F(`ZodJWT`,(e,t)=>{Zl.init(e,t),U.init(e,t)}),ip=F(`ZodNumber`,(e,t)=>{Ql.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Jd(e,t,n,r),If(e,`ZodNumber`,{gt(e,t){return this.check(vd(e,t))},gte(e,t){return this.check(yd(e,t))},min(e,t){return this.check(yd(e,t))},lt(e,t){return this.check(gd(e,t))},lte(e,t){return this.check(_d(e,t))},max(e,t){return this.check(_d(e,t))},int(e){return this.check(op(e))},safe(e){return this.check(op(e))},positive(e){return this.check(vd(0,e))},nonnegative(e){return this.check(yd(0,e))},negative(e){return this.check(gd(0,e))},nonpositive(e){return this.check(_d(0,e))},multipleOf(e,t){return this.check(bd(e,t))},step(e,t){return this.check(bd(e,t))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function W(e){return dd(ip,e)}var ap=F(`ZodNumberFormat`,(e,t)=>{$l.init(e,t),ip.init(e,t)});function op(e){return fd(ap,e)}var sp=F(`ZodBoolean`,(e,t)=>{eu.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Yd(e,t,n,r)});function G(e){return pd(sp,e)}var cp=F(`ZodUnknown`,(e,t)=>{tu.init(e,t),V.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function lp(){return md(cp)}var up=F(`ZodNever`,(e,t)=>{nu.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xd(e,t,n,r)});function dp(e){return hd(up,e)}var fp=F(`ZodArray`,(e,t)=>{iu.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ef(e,t,n,r),e.element=t.element,If(e,`ZodArray`,{min(e,t){return this.check(Sd(e,t))},nonempty(e){return this.check(Sd(1,e))},max(e,t){return this.check(xd(e,t))},length(e,t){return this.check(Cd(e,t))},unwrap(){return this.element}})});function pp(e,t){return Id(fp,e,t)}var mp=F(`ZodObject`,(e,t)=>{lu.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>tf(e,t,n,r),I(e,`shape`,()=>t.shape),If(e,`ZodObject`,{keyof(){return q(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:lp()})},loose(){return this.clone({...this._zod.def,catchall:lp()})},strict(){return this.clone({...this._zod.def,catchall:dp()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return Qs(this,e)},safeExtend(e){return $s(this,e)},merge(e){return ec(this,e)},pick(e){return Xs(this,e)},omit(e){return Zs(this,e)},partial(...e){return tc(wp,this,e[0])},required(...e){return nc(Pp,this,e[0])}})});function K(e,t){return new mp({type:`object`,shape:e??{},...L(t)})}var hp=F(`ZodUnion`,(e,t)=>{du.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>nf(e,t,n,r),e.options=t.options});function gp(e,t){return new hp({type:`union`,options:e,...L(t)})}var _p=F(`ZodIntersection`,(e,t)=>{fu.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rf(e,t,n,r)});function vp(e,t){return new _p({type:`intersection`,left:e,right:t})}var yp=F(`ZodRecord`,(e,t)=>{hu.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>af(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function bp(e,t,n){return!t||!t._zod?new yp({type:`record`,keyType:H(),valueType:e,...L(t)}):new yp({type:`record`,keyType:e,valueType:t,...L(n)})}var xp=F(`ZodEnum`,(e,t)=>{gu.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zd(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new xp({...t,checks:[],...L(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new xp({...t,checks:[],...L(r),entries:i})}});function q(e,t){return new xp({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...L(t)})}var Sp=F(`ZodTransform`,(e,t)=>{_u.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$d(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Es(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(lc(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(lc(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function Cp(e){return new Sp({type:`transform`,transform:e})}var wp=F(`ZodOptional`,(e,t)=>{yu.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Tp(e){return new wp({type:`optional`,innerType:e})}var Ep=F(`ZodExactOptional`,(e,t)=>{bu.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Dp(e){return new Ep({type:`optional`,innerType:e})}var Op=F(`ZodNullable`,(e,t)=>{xu.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>of(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function kp(e){return new Op({type:`nullable`,innerType:e})}var Ap=F(`ZodDefault`,(e,t)=>{Su.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function jp(e,t){return new Ap({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Ws(t)}})}var Mp=F(`ZodPrefault`,(e,t)=>{wu.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>lf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Np(e,t){return new Mp({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Ws(t)}})}var Pp=F(`ZodNonOptional`,(e,t)=>{Tu.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>sf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Fp(e,t){return new Pp({type:`nonoptional`,innerType:e,...L(t)})}var Ip=F(`ZodCatch`,(e,t)=>{Du.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>uf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Lp(e,t){return new Ip({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var Rp=F(`ZodPipe`,(e,t)=>{Ou.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>df(e,t,n,r),e.in=t.in,e.out=t.out});function zp(e,t){return new Rp({type:`pipe`,in:e,out:t})}var Bp=F(`ZodReadonly`,(e,t)=>{Au.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ff(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Vp(e){return new Bp({type:`readonly`,innerType:e})}var Hp=F(`ZodCustom`,(e,t)=>{Mu.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qd(e,t,n,r)});function Up(e,t={}){return Ld(Hp,e,t)}function Wp(e,t){return Rd(e,t)}function J(e){return Object.freeze(e)}var Y=class extends Error{code;constructor(e,t=`ACTION_FAILED`){super(e),this.code=t,this.name=`ActionError`}},Gp={r:0,g:0,b:0,a:0},Kp={r:255,g:255,b:255,a:1},qp={r:18,g:18,b:18,a:1},Jp=/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,Yp=/^rgba?\(([^)]+)\)$/i,Xp=/-?\d*\.?\d+(?:e-?\d+)?%?/gi,Zp=new Map;function Qp(e){let t=e?.trim();return t?(Zp.has(t)||Zp.set(t,$p(t)),Zp.get(t)??null):null}function $p(e){return e===`transparent`?Gp:em(e)??tm(e)??im(e)}function em(e){if(!Jp.test(e))return null;let t=e.slice(1),n=t.length>4,r=n?2:1,i=e=>{let i=t.slice(e*r,e*r+r);return parseInt(n?i:i+i,16)},a=t.length===4||t.length===8?i(3)/255:1;return{r:i(0),g:i(1),b:i(2),a}}function tm(e){let t=(Yp.exec(e)?.[1])?.match(Xp);if(!t||t.length<3)return null;let n=(e,t)=>e.endsWith(`%`)?parseFloat(e)/100*t:parseFloat(e);return{r:bm(n(t[0],255)),g:bm(n(t[1],255)),b:bm(n(t[2],255)),a:t[3]===void 0?1:ym(n(t[3],1))}}var nm;function rm(){return nm??=document.createElement(`canvas`).getContext(`2d`,{willReadFrequently:!0}),nm}function im(e){let t=rm();if(!t)return null;t.fillStyle=`#000000`,t.fillStyle=e;let n=t.fillStyle;return t.fillStyle=`#ffffff`,t.fillStyle=e,n===t.fillStyle?em(t.fillStyle)??tm(t.fillStyle)??am(t,e):null}function am(e,t){e.clearRect(0,0,1,1),e.fillStyle=t,e.fillRect(0,0,1,1);let[n,r,i,a]=e.getImageData(0,0,1,1).data;return{r:n,g:r,b:i,a:a/255}}function om({r:e,g:t,b:n,a:r}){let i=e=>bm(e).toString(16).padStart(2,`0`),a=r>=1?``:i(Math.round(r*255));return`#${i(e)}${i(t)}${i(n)}${a}`}function sm({r:e,g:t,b:n,a:r}){return{r:255-e,g:255-t,b:255-n,a:r}}function cm({r:e,g:t,b:n}){return .2126*lm(e)+.7152*lm(t)+.0722*lm(n)}function lm(e){let t=bm(e)/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4}function um(e,t){let n=cm(e),r=cm(t),i=Math.max(n,r),a=Math.min(n,r);return(i+.05)/(a+.05)}function dm(e,t){let n=e.a+t.a*(1-e.a);if(n===0)return Gp;let r=(r,i)=>Math.round((r*e.a+i*t.a*(1-e.a))/n);return{r:r(e.r,t.r),g:r(e.g,t.g),b:r(e.b,t.b),a:n}}function fm(){let e=getComputedStyle(document.documentElement).colorScheme||`normal`;return e.includes(`dark`)?e.includes(`light`)?matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:`dark`:`light`}function pm(){return fm()===`dark`?qp:Kp}function mm(e){let t=Gp;for(let n=e;n;n=n.parentElement){let e=Qp(getComputedStyle(n).backgroundColor);if(!(!e||e.a===0)&&(t=dm(t,e),t.a>=1))return t}return dm(t,pm())}function hm(e,t){let n=Qp(getComputedStyle(e).color)??Gp;return n.a>=1?n:dm(n,t)}function gm(e,t){return e>=24||e>=18.66&&t>=700}function _m(e,t){return t===`AAA`?e?4.5:7:e?3:4.5}function vm(e,t){let n=10**t;return Math.round(e*n)/n}function ym(e){return Math.min(1,Math.max(0,e))}function bm(e){return Math.min(255,Math.max(0,Math.round(e)))}var xm=[[-.574,1.43,.144],[.426,.43,.144],[.426,1.43,-.856]];function Sm(e,t){let n=[e.r,e.g,e.b];t.invert&&(n=Cm(n.map(e=>255-e),xm)),n=n.map(e=>e*t.brightness),t.saturate!==void 0&&(n=Cm(n,Tm(t.saturate))),t.contrast!==void 0&&(n=n.map(e=>(e-127.5)*t.contrast+127.5));let[r,i,a]=n.map(bm);return{r,g:i,b:a,a:e.a}}function Cm(e,t){return t.map(t=>t[0]*e[0]+t[1]*e[1]+t[2]*e[2])}function wm(e,t,n=.05,r=4){let i=n,a=r;for(let n=0;n<24;n+=1){let n=(i+a)/2;cm(Sm(e,{invert:!1,brightness:n}))<t?i=n:a=n}return vm((i+a)/2,3)}function Tm(e){return[[.213+.787*e,.715-.715*e,.072-.072*e],[.213-.213*e,.715+.285*e,.072-.072*e],[.213-.213*e,.715-.715*e,.072+.928*e]]}var Em=`browsentic-theme`,Dm=`data-browsentic-added-class`,Om=`data-browsentic-hook-attribute`,km=`data-browsentic-hook-host`,Am=`data-browsentic-filter`,jm=`data-browsentic-previous-value`,Mm=/\.((?:theme-|mode-)?(dark|light)(?:-mode|-theme)?)(?![\w-])/i,Nm=/\[([\w-]*(?:theme|mode|scheme))\s*[~|^$*]?=\s*["']?(dark|light)["']?\s*[is]?\]/i;function Pm(e){let t=[...document.styleSheets,...document.adoptedStyleSheets],n=new Set,r=new Map,i={total:t.length,readable:0,crossOrigin:0,inline:0},a=0,o=t=>{if(!(a>=e)){if(a+=1,t instanceof CSSStyleRule){for(let e of t.style)e.startsWith(`--`)&&n.add(e);Im(t.selectorText,r);return}if(t instanceof CSSGroupingRule)for(let e of t.cssRules)o(e);if(t instanceof CSSImportRule)for(let e of Fm(t.styleSheet)??[])o(e)}};for(let e of t){e.href||(i.inline+=1);let t=Fm(e);if(!t){i.crossOrigin+=1;continue}i.readable+=1;for(let e of t)o(e)}return{sheets:i,rules:a,properties:[...n],hooks:[...r.values()],truncated:a>=e}}function Fm(e){try{return e?.cssRules??null}catch{return null}}function Im(e,t){for(let n of e.split(`,`)){let e=n.trim(),r=e.split(/[\s>+~]+/)[0],i=/^body\b/i.test(r)?`body`:`root`,a=Nm.exec(r);if(a){let[,n,r]=a;Lm(t,{kind:`attribute`,name:n.toLowerCase(),value:r.toLowerCase(),scheme:r.toLowerCase(),host:i,selector:e});continue}let o=Mm.exec(r);if(o){let[,n,r]=o;Lm(t,{kind:`class`,name:n,scheme:r.toLowerCase(),host:i,selector:e})}}}function Lm(e,t){e.set(`${t.kind}:${t.host}:${t.name}:${t.value??``}`,t)}function Rm(e,t){let n=getComputedStyle(document.documentElement),r=e.map(e=>({name:e,value:n.getPropertyValue(e).trim().slice(0,120)})).filter(({value:e})=>e!==``).sort((e,t)=>e.name<t.name?-1:1);return{total:r.length,listed:r.slice(0,t).map(zm)}}function zm({name:e,value:t}){let n=Qp(t);return!n||n.a===0?{name:e,value:t}:{name:e,value:t,color:om(n),luminance:vm(cm(n),3)}}function Bm(){let e=document.getElementById(Em)?.getAttribute(Am);if(e)try{return JSON.parse(e)}catch{return}}function Vm(){let e=Bm();return e?t=>Sm(t,e):e=>e}function Hm(e,t){e.setAttribute(Am,JSON.stringify(t))}function Um(){let e=document.body??document.documentElement,t=Vm(),n=mm(e),r=t(n),i=t(hm(e,n));return{colorScheme:fm(),background:om(r),text:om(i),luminance:vm(cm(r),4),contrast:vm(um(i,r),2),...Bm()?{filtered:!0}:{}}}function Wm(e){return e===`body`?document.body??document.documentElement:document.documentElement}function Gm(){let e=document.getElementById(Em);if(!e)return!1;let t=Wm(e.getAttribute(km)===`body`?`body`:`root`),n=e.getAttribute(Dm);n&&t.classList.remove(n);let r=e.getAttribute(Om);if(r){let n=e.getAttribute(jm);n===null?t.removeAttribute(r):t.setAttribute(r,n)}return e.remove(),!0}function Km(e,t){let n=document.createElement(`style`);return n.id=Em,n.textContent=e,t&&qm(n,t),document.documentElement.append(n),n}function qm(e,t){let n=Wm(t.host);if(e.setAttribute(km,t.host),t.kind===`class`){if(n.classList.contains(t.name))return;n.classList.add(t.name),e.setAttribute(Dm,t.name);return}let r=n.getAttribute(t.name);e.setAttribute(Om,t.name),r!==null&&e.setAttribute(jm,r),n.setAttribute(t.name,t.value??``)}var Jm=2e4,Ym=40,Xm=/^--[A-Za-z0-9_-]+$/,Zm=/[;{}<>\\]|@import|url\(|expression\(/i,Qm=.05,$m=.92,eh=.08,th=`img, picture, video, canvas, svg, iframe, embed, object`,nh=`invert(1) hue-rotate(180deg)`,rh=J({name:`page.applyTheme`,description:`Retheme the page, or put it back. Prefers the page’s own terms — it switches on the dark/light hook its stylesheets already define (a ".dark" class, a [data-theme] attribute), sets color-scheme, and overrides the design tokens you name. Only when that leaves the page at the wrong luminance does it fall back to repainting through a CSS filter. Reports the measured background luminance and text contrast before and after, so the change can be checked rather than assumed. The filter fallback creates a containing block on <html>, which re-anchors position:fixed elements, and it re-inverts images so photos stay right way round. Nothing here survives a reload — call it again, or with mode "revert", to undo it.`,input:K({mode:q([`keep`,`dark`,`light`,`revert`]).default(`keep`).describe(`Which way to push the page: "dark" or "light" retheme it, "revert" removes everything Browsentic applied and restores the page’s own theme, "keep" leaves the light/dark decision alone and applies only the colours below`),targetLuminance:W().min(0).max(1).optional().describe(`Relative luminance to bring the page background to, 0 black to 1 white, as reported by page.readTheme. Overrides the luminance "dark" and "light" imply. Reached by filtering, so it repaints images and text alike`),background:H().optional().describe(`CSS colour for the page background, e.g. "#0f172a" or "rgb(15 23 42)"; suppresses the luminance a mode would imply`),text:H().optional().describe(`CSS colour for body text; elements that set their own colour keep it`),accent:H().optional().describe(`CSS colour for links and form-control accents`),tokens:bp(H(),H()).optional().describe(`CSS custom properties to override on :root, e.g. {"--background": "#0f172a"}. Names come from page.readTheme’s tokens — this is the cleanest way to retheme a page that is built on design tokens, because its own rules do the work`),saturation:W().min(0).max(3).optional().describe(`Colour intensity multiplier: 0 greyscale, 1 unchanged, above 1 more vivid`),contrast:W().min(0).max(3).optional().describe(`Contrast multiplier: 1 unchanged, above 1 pushes lights and darks apart`),transitionMs:W().int().nonnegative().max(2e3).default(200).describe(`How long the page takes to cross-fade into the new theme; 0 switches instantly`)}),execute({mode:e,targetLuminance:t,background:n,text:r,accent:i,tokens:a,saturation:o,contrast:s,transitionMs:c}){let l={background:ih(n,`background`),text:ih(r,`text`),accent:ih(i,`accent`)},u=ah(a);if(e===`keep`&&t===void 0&&!(o!==void 0||s!==void 0)&&!u.length&&!Object.values(l).some(Boolean))throw new Y(`Nothing to apply — pass a "mode", a "targetLuminance", a colour, or "tokens".`,`INVALID_INPUT`);let d=Gm(),f=Um();if(e===`revert`)return{reverted:d,theme:f};let p=e===`dark`||e===`light`?oh(e):void 0,m=Km(ch({mode:e,colors:l,overrides:u,transitionMs:c}),p),h=Um(),g=t??(l.background?void 0:lh(e,h.luminance)),_=uh(g,h.background,o,s);_&&(m.textContent+=`\n${fh(_,h.background,c)}`,Hm(m,_));let v=Um();return{replaced:d,strategy:_?`filter`:p||e!==`keep`?`stylesheet`:`colors`,applied:{mode:e,hook:p,...l,tokens:u.length?u.map(([e])=>e):void 0,filter:_?dh(_).join(` `):void 0,targetLuminance:g},css:(m.textContent??``).slice(0,4e3),before:f,after:v,...g===void 0?{}:{reachedTarget:Math.abs(v.luminance-g)<=eh}}}});function ih(e,t){if(e===void 0)return;let n=Qp(e);if(!n)throw new Y(`"${t}" is not a colour this browser understands — pass something like "#0f172a", "rgb(15 23 42)" or "midnightblue".`,`INVALID_INPUT`);return om(n)}function ah(e){let t=Object.entries(e??{});if(t.length>Ym)throw new Y(`Too many tokens — ${t.length} given and ${Ym} is the limit. Override only the ones that carry the theme.`,`INVALID_INPUT`);return t.map(([e,t])=>{if(!Xm.test(e))throw new Y(`"${e}" is not a custom property — names look like "--brand-500".`,`INVALID_INPUT`);let n=t.trim();if(!n||Zm.test(n))throw new Y(`The value for "${e}" is not a plain CSS value — it cannot be empty or carry ";", "{", "}", "\\" or "url(".`,`INVALID_INPUT`);return[e,n]})}function oh(e){return Pm(Jm).hooks.filter(t=>t.scheme===e).sort((e,t)=>sh(e)-sh(t))[0]}function sh(e){return e.kind===`attribute`?e.name===`data-theme`?0:1:e.name.toLowerCase()===e.scheme?2:3}function ch({mode:e,colors:t,overrides:n,transitionMs:r}){let i=[];return e!==`keep`&&i.push(`:root { color-scheme: ${e}; }`),n.length&&i.push(`:root { ${n.map(([e,t])=>`${e}: ${t};`).join(` `)} }`),t.background&&i.push(`html, body { background-color: ${t.background} !important; }`),t.text&&i.push(`html, body { color: ${t.text} !important; }`),t.accent&&i.push(`:root { accent-color: ${t.accent} !important; }`,`a { color: ${t.accent} !important; }`),r>0&&i.push(`html, body { transition: background-color ${r}ms linear, color ${r}ms linear, filter ${r}ms linear; }`),i.join(`
|
|
105
|
+
`)}function lh(e,t){if(e===`dark`)return t>.5?Qm:void 0;if(e===`light`)return t<.5?$m:void 0}function uh(e,t,n,r){let i=Qp(t)??Kp,a=cm(i),o=e!==void 0&&e<.5!=a<.5,s=o?cm(sm(i)):a,c=e===void 0||s<=.004?1:wm(o?sm(i):i,e);if(!(!o&&c===1&&n===void 0&&r===void 0))return{invert:o,brightness:c,saturate:n,contrast:r}}function dh({invert:e,brightness:t,saturate:n,contrast:r}){return[e?nh:``,t===1?``:`brightness(${t})`,n===void 0?``:`saturate(${n})`,r===void 0?``:`contrast(${r})`].filter(Boolean)}function fh(e,t,n){let r=[`html { background-color: ${t}; filter: ${dh(e).join(` `)}; }`];return e.invert&&r.push(`${th} { filter: ${nh}; }`),n>0&&r.push(`${th} { transition: filter ${n}ms linear; }`),r.join(`
|
|
106
|
+
`)}var X=K({selector:H().optional().describe(`CSS selector for the element`),text:H().optional().describe(`Case-insensitive visible text the element should contain`),role:H().optional().describe(`Tag name or ARIA role to narrow matches, e.g. "button" or "link"`),nth:W().int().nonnegative().default(0).describe(`Zero-based index when several elements match`)}),ph=`a,button,input,select,textarea,summary,label,h1,h2,h3,h4,h5,h6,[role],[tabindex],[contenteditable]`,mh={link:[`a`],button:[`button`],textbox:[`input`,`textarea`],combobox:[`select`],checkbox:[`input`],radio:[`input`],heading:[`h1`,`h2`,`h3`,`h4`,`h5`,`h6`]},hh={button:`button`,submit:`button`,reset:`button`,image:`button`,file:`button`,checkbox:`checkbox`,radio:`radio`,range:`slider`,number:`spinbutton`,search:`searchbox`},gh={button:`button`,select:`combobox`,textarea:`textbox`,summary:`button`,option:`option`,h1:`heading`,h2:`heading`,h3:`heading`,h4:`heading`,h5:`heading`,h6:`heading`,nav:`navigation`,main:`main`,header:`banner`,footer:`contentinfo`,aside:`complementary`,form:`form`,dialog:`dialog`},_h=new Set([`button`,`submit`,`reset`,`image`,`checkbox`,`radio`,`file`]);function vh(e){let t=e.getAttribute(`role`)?.trim().split(/\s+/)[0];return t?t.toLowerCase():e instanceof HTMLInputElement?hh[e.type]??`textbox`:e instanceof HTMLAnchorElement?e.getAttribute(`href`)===null?void 0:`link`:gh[e.tagName.toLowerCase()]}function yh(e,t){let n=t.toLowerCase(),r=e.tagName.toLowerCase();return r===n||vh(e)===n?!0:mh[n]?.includes(r)??!1}function Z(e,t={}){let{selector:n,text:r,role:i,nth:a}=e;if(!n&&!r)throw new Y(`A target needs a "selector" or "text"`,`INVALID_TARGET`);let o=[...document.querySelectorAll(n??ph)];if(i&&(o=o.filter(e=>yh(e,i))),r){let e=r.toLowerCase();o=o.filter(t=>bh(t).toLowerCase().includes(e)),o=o.filter(e=>!o.some(t=>t!==e&&e.contains(t)))}t.includeHidden||(o=o.filter(Sh));let s=o[a];if(!s)throw new Y(`No element matches ${JSON.stringify(e)} (${o.length} candidates)`,`TARGET_NOT_FOUND`);return s}function bh(e){let t=e.getAttribute(`aria-label`)?.trim();if(t)return t;if(e instanceof HTMLInputElement)return e.type===`submit`||e.type===`button`||e.type===`reset`?e.value.trim()||e.type:xh(e);if(e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)return xh(e);if(e instanceof HTMLImageElement)return e.alt.trim();let n=(e.textContent??``).replace(/\s+/g,` `).trim();if(n)return n;let r=e.querySelector(`img[alt]`);return r instanceof HTMLImageElement?r.alt.trim():``}function xh(e){return e.labels?.[0]?.textContent?.trim()||e.getAttribute(`placeholder`)?.trim()||e.name}function Sh(e){let t=e.getBoundingClientRect();if(t.width===0&&t.height===0)return!1;let n=getComputedStyle(e);return n.visibility!==`hidden`&&n.display!==`none`}function Ch(e){return Sh(e)&&!e.closest(`[aria-hidden="true"],[inert]`)}function wh(e,t){let n=e.getAttribute(t);return n===`true`||n!==`false`&&void 0}function Th(e){let t={};(e.matches(`:disabled`)||wh(e,`aria-disabled`))&&(t.disabled=!0);let n=e instanceof HTMLInputElement&&(e.type===`checkbox`||e.type===`radio`)?e.checked:wh(e,`aria-checked`);n!==void 0&&(t.checked=n);let r=wh(e,`aria-expanded`);r!==void 0&&(t.expanded=r);let i=e instanceof HTMLOptionElement?e.selected:wh(e,`aria-selected`);i!==void 0&&(t.selected=i);let a=e.getAttribute(`aria-current`);return a&&a!==`false`&&(t.current=a),(e.matches(`:required`)||wh(e,`aria-required`))&&(t.required=!0),wh(e,`aria-invalid`)&&(t.invalid=!0),e instanceof HTMLSelectElement?t.value=e.selectedOptions[0]?.text.replace(/\s+/g,` `).trim().slice(0,60)||void 0:(e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement&&!_h.has(e.type))&&(t.filled=e.value.length>0),Object.values(t).some(e=>e!==void 0)?t:void 0}function Q(e){let t=[];for(let n=e;n&&n!==document.documentElement;n=n.parentElement){if(n.id)return t.unshift(`#${CSS.escape(n.id)}`),t.join(` > `);let e=n.tagName.toLowerCase(),r=n.parentElement?[...n.parentElement.children].filter(e=>e.tagName===n.tagName):[];t.unshift(r.length>1?`${e}:nth-of-type(${r.indexOf(n)+1})`:e)}return t.join(` > `)}function Eh(e){let t=e.getBoundingClientRect();return{x:Math.round(t.x+window.scrollX),y:Math.round(t.y+window.scrollY),width:Math.round(t.width),height:Math.round(t.height)}}function $(e){let t=bh(e).slice(0,80);return{tag:e.tagName.toLowerCase(),role:vh(e),selector:Q(e),text:t||void 0,state:Th(e),bounds:Eh(e)}}function Dh(e){return e.closest(`form`)?e instanceof HTMLButtonElement?e.type===`submit`:e instanceof HTMLInputElement&&(e.type===`submit`||e.type===`image`):!1}var Oh=J({name:`page.attachFile`,description:`Attach a file to a file input on the page: either one the user stored in Browsentic (fileId, from page.listFiles) or one you captured off another page (downloadId, from page.captureDownload). The second closes the loop — download here, upload there — without the bytes ever passing through you.`,input:K({fileId:H().optional().describe(`Id of a stored file, taken from page.listFiles.`),downloadId:H().optional().describe(`Id of a captured download, taken from page.captureDownload or page.listDownloads.`),target:X.describe(`The file input (<input type="file">) to attach the file to.`),name:H().optional().describe(`Internal: original filename. Browsentic fills this in.`),mime:H().optional().describe(`Internal: file MIME type. Browsentic fills this in.`),content:H().optional().describe(`Internal: base64 file bytes. Browsentic fills this in.`)}),execute({target:e,name:t,mime:n,content:r}){if(!r)throw new Y(`No file bytes were supplied — call with a valid fileId or downloadId.`,`INVALID_INPUT`);let i=Z(e,{includeHidden:!0});if(!(i instanceof HTMLInputElement)||i.type!==`file`)throw new Y(`<${i.tagName.toLowerCase()}> is not a file input`,`INVALID_TARGET`);let a=atob(r),o=new Uint8Array(a.length);for(let e=0;e<a.length;e++)o[e]=a.charCodeAt(e);let s=new File([o],t||`file`,{type:n||`application/octet-stream`}),c=new DataTransfer;return c.items.add(s),Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,`files`).set.call(i,c.files),i.dispatchEvent(new Event(`input`,{bubbles:!0})),i.dispatchEvent(new Event(`change`,{bubbles:!0})),{attached:!0,name:s.name,size:o.length,mime:s.type,element:$(i)}}}),kh=60,Ah=J({name:`page.auditContrast`,description:`Score the readability of the page against WCAG contrast rules. Walks the visible text, resolves each run’s foreground against the real background painted behind it — blending translucent layers up the ancestor chain — and reports the ratio, the ratio the level requires, and whether it passes. The score is the share of sampled text runs that pass, so it is directly comparable before and after page.applyTheme.`,input:K({target:X.optional().describe(`Subtree to audit; defaults to the whole page`),level:q([`AA`,`AAA`]).default(`AA`).describe(`WCAG level: AA needs 4.5:1 for body text and 3:1 for large text, AAA needs 7:1 and 4.5:1`),maxSamples:W().int().positive().max(2e3).default(400).describe(`Text-bearing elements to check, in document order`),maxFailures:W().int().nonnegative().max(200).default(20).describe(`Failures listed, worst ratio first; the counts always cover everything sampled`)}),execute({target:e,level:t,maxSamples:n,maxFailures:r}){let i=e?Z(e):document.body??document.documentElement,a=jh(i,t,n,Vm()),o=a.filter(e=>!e.passes).sort((e,t)=>e.ratio-t.ratio),s=a.length-o.length;return{url:location.href,level:t,required:{normalText:_m(!1,t),largeText:_m(!0,t)},...a.length?{score:Math.round(s/a.length*100)}:{},summary:{sampled:a.length,passed:s,failed:o.length,worstRatio:a.length?Math.min(...a.map(e=>e.ratio)):void 0},failures:o.slice(0,r),source:Q(i)}}});function jh(e,t,n,r){let i=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),a=new Set,o=[];for(let e=i.nextNode();e&&o.length<n;e=i.nextNode()){let n=(e.textContent??``).replace(/\s+/g,` `).trim(),i=e.parentElement;!n||!i||a.has(i)||(a.add(i),Ch(i)&&o.push(Mh(i,n,t,r)))}return o}function Mh(e,t,n,r){let i=getComputedStyle(e),a=mm(e),o=r(a),s=r(hm(e,a)),c=vm(parseFloat(i.fontSize),1),l=Number(i.fontWeight)||400,u=gm(c,l),d=vm(um(s,o),2),f=_m(u,n);return{selector:Q(e),text:t.slice(0,kh),foreground:om(s),background:om(o),ratio:d,required:f,passes:d>=f,fontSizePx:c,weight:l,large:u,bounds:Eh(e)}}var Nh=30*6e4,Ph=240*6e4,Fh=2*6e4,Ih=10*6e4;function Lh(e){let t=Math.round(e/6e4);return t<1?`under a minute`:`~${t} min`}var Rh=J({name:`page.awaitMonitor`,description:`Block until a background monitor completes, then return its final state with the full log. A reply with settled: false means the timeout passed while the watch continues — call again to keep waiting; that is normal, not an error. If the call fails with EXTENSION_OFFLINE the monitor is still running in the browser — reconnect and call again.`,input:K({monitorId:H().describe(`The monitor to wait on, from page.startMonitor`),timeoutMs:W().int().positive().max(Ih).default(Fh).describe(`Return after this long even if unfinished — the reply then has settled: false and the current state, so call again to keep waiting`)}),execute(){throw new Y(`page.awaitMonitor is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),zh=J({name:`page.callSiteTool`,description:`Call one of the tools this site offers through WebMCP (document.modelContext), with arguments matching the schema page.listSiteTools reported. The site’s own code handles the call, which makes it the reliable path wherever a listed tool covers the step — no selectors to break, no intermediate states to wait through. The return value is whatever the site’s tool produced, as JSON. Treat a call like a form submit: the site decides what it does, and that can include acting on the user’s account, so it passes the same approval gate.`,input:K({tool:H().min(1).describe(`Name of a tool exactly as page.listSiteTools reported it.`),args:bp(H(),lp()).default({}).describe(`Arguments for the tool, matching its input schema. JSON values only.`),timeoutMs:W().int().min(100).max(12e4).default(15e3).describe(`How long the tool may run before the call is abandoned. Raise it for tools that wait on the site’s backend.`)}),execute(){throw new Y(`page.callSiteTool is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),Bh=J({name:`page.captureDownload`,description:`Make the page download a file and keep it. Either click something that produces a download — an “Export CSV” button, a “Download invoice” link — or give a direct url, which is fetched in the browser’s own logged-in session rather than anonymously. The file lands in the user’s ~/browsentic/download/ folder and the result reports the path and notes about what arrived; you get the notes, never the bytes. Hand the returned downloadId to page.attachFile to upload it somewhere else without the file ever passing through you.`,input:K({target:X.optional().describe(`The link or button whose click starts the download. Give this or "url", not both.`),url:H().optional().describe(`Direct http(s) url of the file, fetched with the browser’s cookies. Give this or "target", not both. Prefer "target" when a button exists: many exports have no fetchable url at all.`),timeoutMs:W().int().min(1e3).max(6e5).default(6e4).describe(`How long to wait for the download to finish before giving up.`)}),execute(){throw new Y(`page.captureDownload is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),Vh=J({name:`page.clickElement`,description:`Click an element like a user would, firing the full pointer and mouse event sequence.`,input:K({target:X.describe(`Element to click`),scrollIntoView:G().default(!0).describe(`Bring the element into view before clicking`)}),execute({target:e,scrollIntoView:t}){let n=Z(e);t&&n.scrollIntoView({block:`center`,behavior:`instant`});try{n.focus({preventScroll:!0})}catch{}let r=Dh(n),i={bubbles:!0,cancelable:!0,composed:!0};return n.dispatchEvent(new PointerEvent(`pointerdown`,i)),n.dispatchEvent(new MouseEvent(`mousedown`,i)),n.dispatchEvent(new PointerEvent(`pointerup`,i)),n.dispatchEvent(new MouseEvent(`mouseup`,i)),n.click(),{...$(n),submits:r}}}),Hh=J({name:`page.closeTab`,description:`Close an open tab. With no arguments it closes the tab page actions are currently targeting, and later actions follow the browser to whichever tab it brings to the front.`,input:K({tabId:W().int().optional().describe(`Id of the tab to close, as reported by page.openTab or a no-argument page.switchTab.`),match:H().optional().describe(`Instead of an id, close the tab whose title or URL contains this text (case-insensitive). If several tabs match, nothing is closed and the candidates are listed.`)}),execute(){throw new Y(`page.closeTab is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),Uh=120,Wh=6,Gh=K({x:W().describe(`Pixels from the left edge of the viewport`),y:W().describe(`Pixels from the top edge of the viewport`)});function Kh(){return{w:document.documentElement.clientWidth,h:document.documentElement.clientHeight}}function qh(e){let t=e.getBoundingClientRect(),{w:n,h:r}=Kh(),i=Math.max(t.left,0),a=Math.max(t.top,0),o=Math.min(t.right,n),s=Math.min(t.bottom,r);if(o<=i||s<=a)throw new Y(`The element has no visible area inside the viewport — scroll it into view, then retry`,`INVALID_TARGET`);return{x:Math.round((i+o)/2),y:Math.round((a+s)/2)}}function Jh(e){let{w:t,h:n}=Kh();if(e.x<0||e.y<0||e.x>=t||e.y>=n)throw new Y(`The point (${e.x}, ${e.y}) is outside the ${t}×${n} viewport — scroll it into view, then retry`,`INVALID_TARGET`);return{x:Math.round(e.x),y:Math.round(e.y)}}function Yh(e){let{w:t,h:n}=Kh();return{x:Math.min(Math.max(e.x-Uh,0),t-1),y:Math.min(Math.max(e.y-Uh,0),n-1)}}function Xh(e){return document.elementFromPoint(e.x,e.y)}function Zh(e,t){let n=Xh(t);if(!(n===e||e.contains(n)))throw new Y(n?`${Q(n)} covers (${t.x}, ${t.y}) — dismiss whatever is over the element, then retry`:`Nothing is painted at (${t.x}, ${t.y}) — scroll the element into view, then retry`,`INVALID_TARGET`)}var Qh=e=>1-(1-e)**3;function $h(e,t,n){let r=t.x-e.x,i=t.y-e.y,a=Math.hypot(r,i)||1,o=Math.min(Wh,a/8);return Array.from({length:n},(t,s)=>{let c=Qh((s+1)/n),l=Math.sin(c*Math.PI)*o*(s%2?-1:1);return{x:Math.round(e.x+r*c-i/a*l),y:Math.round(e.y+i*c+r/a*l)}})}var eg=[[`pointer`,`pointerover`,!0],[`pointer`,`pointerenter`,!1],[`pointer`,`pointermove`,!0],[`mouse`,`mouseover`,!0],[`mouse`,`mouseenter`,!1],[`mouse`,`mousemove`,!0]];function tg(e,t){for(let[n,r,i]of eg){let a=n===`pointer`?PointerEvent:MouseEvent;e.dispatchEvent(new a(r,{clientX:t.x,clientY:t.y,bubbles:i,composed:!0}))}}var ng=16,rg=e=>new Promise(t=>setTimeout(t,e));function ig(e,t){return{clientX:e.x,clientY:e.y,button:0,buttons:t,bubbles:!0,cancelable:!0,composed:!0,view:window,pointerId:1,pointerType:`mouse`,isPrimary:!0}}function ag(e,t,n,r,i){let a=ig(r,i);e?.dispatchEvent(new PointerEvent(t,a)),e?.dispatchEvent(new MouseEvent(n,a))}function og(e,t,n,r){return e?.dispatchEvent(new DragEvent(t,{...ig(n,1),dataTransfer:r}))??!1}function sg(e){try{return qh(e)}catch{throw new Y(`The drop target is not inside the viewport — both ends of a drag have to be on screen at once, because nothing scrolls mid-drag. Scroll until both are visible, then retry`,`INVALID_TARGET`)}}async function cg(e,t,n,r,i){for(let a of $h(e,t,n))await rg(ng),i?i(a):ag(Xh(a),`pointermove`,`mousemove`,a,r)}async function lg(e,t,n){await cg(e,t,4,0),tg(n??document.body,t)}async function ug(e,t){let{approach:n,grip:r,drop:i,steps:a,holdMs:o,settleMs:s}=t,c=e??Xh(r);await lg(n,r,c),ag(c,`pointerdown`,`mousedown`,r,1),await rg(o),await cg(r,i,a,1),await rg(s);let l=Xh(i);return ag(l??c,`pointerup`,`mouseup`,i,0),{landedOn:l?Q(l):void 0}}async function dg(e,t){let{approach:n,grip:r,drop:i,steps:a,holdMs:o,settleMs:s}=t,c=new DataTransfer;await lg(n,r,e),ag(e,`pointerdown`,`mousedown`,r,1),await rg(o);let l=og(e,`dragstart`,r,c),u=!1,d=null;await cg(r,i,a,1,e=>{let t=Xh(e);t!==d&&(og(d,`dragleave`,e,c),og(t,`dragenter`,e,c),d=t),t&&!og(t,`dragover`,e,c)&&(u=!0)}),await rg(s);let f=Xh(i);return og(f,`drop`,i,c),og(e,`dragend`,i,c),{landedOn:f?Q(f):void 0,started:l,accepted:u}}var fg=J({name:`page.dragElement`,description:`Drag one thing onto another — reorder a list, move a card between columns, pull a slider handle, draw on a canvas. Give a "from" element (or "fromPoint") to pick up and a "to" element (or "toPoint") to drop on. Both ends must be on screen at the same moment, because nothing auto-scrolls mid-drag. The web has two unrelated drag mechanisms and "auto" chooses between them by reading the grabbed element: "pointer" presses, moves and releases a pointer, which is what dnd-kit, react-beautiful-dnd, sliders and canvases listen for; "native" fires the HTML5 dragstart/dragover/drop sequence with a DataTransfer, which is what an element carrying draggable="true" expects. The drop point is measured before the drag starts, so a list that reflows as you pass over it can land a slot out — raise "steps" and "settleMs", then read the result back. Set "trusted" when the page ignores synthetic events; that path is pointer-only, Chrome-only, and shows the “Browsentic is debugging this browser” bar. If nothing moved, check "accepted" and try the other mode.`,input:K({from:X.optional().describe(`Element to pick up — the card, row, or drag handle. Give this or "fromPoint", never both.`),fromPoint:Gh.optional().describe(`Viewport coordinates to grab from, in CSS pixels. Use it when the grip is not an element, such as a spot on a <canvas>.`),to:X.optional().describe(`Element to drop onto — the destination column, list slot, or drop zone. Give this or "toPoint", never both.`),toPoint:Gh.optional().describe(`Viewport coordinates to drop at, in CSS pixels. Use it to reach empty space, a slider position, or a spot on a <canvas>.`),mode:q([`auto`,`pointer`,`native`]).default(`auto`).describe(`Which drag mechanism to use. "auto" picks "native" when the grabbed element declares draggable="true", "pointer" otherwise.`),steps:W().int().min(2).max(60).default(16).describe(`Moves dispatched along the way to the drop point. Raise it for lists that reorder as the pointer passes over them.`),holdMs:W().int().min(0).max(5e3).default(120).describe(`How long the button stays down before the drag starts moving. Raise it past a library’s press-and-hold delay.`),settleMs:W().int().min(0).max(5e3).default(120).describe(`Pause on the drop point before releasing, letting the page settle on where the item would land.`),trusted:G().default(!1).describe(`Dispatch real browser-level mouse events, so isTrusted is true. Pointer mode only, Chrome only.`),scrollIntoView:G().default(!0).describe(`Bring the grabbed element into view first. Ignored with "fromPoint".`)}),async execute({from:e,fromPoint:t,to:n,toPoint:r,mode:i,steps:a,holdMs:o,settleMs:s,trusted:c,scrollIntoView:l}){if(!e==!t)throw new Y(`Give either a "from" target to pick up or a "fromPoint" to grab at — not both, not neither`,`INVALID_INPUT`);if(!n==!r)throw new Y(`Give either a "to" target to drop onto or a "toPoint" to drop at — not both, not neither`,`INVALID_INPUT`);let u=e?Z(e):null,d=n?Z(n):null;u&&l&&u.scrollIntoView({block:`center`,behavior:`instant`});let f=u?qh(u):Jh(t);u&&Zh(u,f);let p=d?sg(d):Jh(r),m=u?.closest(`[draggable="true"]`)??null,h=i===`auto`?m?`native`:`pointer`:i;if(h===`native`&&c)throw new Y(`A trusted drag sends real mouse events, which cannot drive HTML5 drag-and-drop — drop "trusted", or set mode to "pointer" if the page also listens for pointer drags`,`INVALID_INPUT`);if(h===`native`&&!u)throw new Y(`HTML5 drag-and-drop starts on an element, so coordinates cannot fire dragstart — give a "from" target, or set mode to "pointer"`,`INVALID_INPUT`);let g={approach:Yh(f),grip:f,drop:p,steps:a,holdMs:o,settleMs:s},_={from:u?$(u):void 0,to:d?$(d):void 0,mechanism:h,...g};if(c)return _;let v=h===`native`?await dg(m??u,g):await ug(u,g);return{..._,...v,trusted:!1}}}),pg=2166136261,mg=16777619,hg=[{pattern:/\n{2,}/g,floor:.5},{pattern:/(?<=[.!?…]["'’”)\]]*)\s+/g,floor:.25},{pattern:/[。!?]["’”」』))\]]*/g,floor:.25},{pattern:/\n/g,floor:.25},{pattern:/\s+/g,floor:0}],gg=/^(\d+)\.([0-9a-f]{8})$/;function _g(e){let t=pg;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,mg);return(t>>>0).toString(16).padStart(8,`0`)}function vg(e,t,n){if(e.length-t<=n)return e.length;let r=e.slice(t,t+n);for(let{pattern:e,floor:i}of hg){let a=xg(r,e,Math.floor(n*i));if(a>0)return t+a}return t+n}function yg(e,t){return`${e}.${_g(t)}`}function bg(e){let t=gg.exec(e.trim());return t?{offset:Number(t[1]),digest:t[2]}:null}function xg(e,t,n){t.lastIndex=0;let r=0;for(let i=t.exec(e);i;i=t.exec(e))i.index>=n&&(r=i.index+i[0].length);return r}var Sg=2e5,Cg=J({name:`page.extractText`,description:`Read the rendered text or raw HTML of an element or the whole page, one group at a time. A group is cut at the last paragraph or sentence boundary that fits in maxLength, never mid-sentence, and the same page always groups the same way. When more text remains the reply carries a cursor — pass it back for the next group, and keep going until no cursor comes back. The cursor is checked against the text it already handed you, so two groups never come from two different versions of the page: if the page rewrote what you had read, the reply is "stale": true and nothing else, and the read starts over with no cursor.`,input:K({target:X.optional().describe(`Element to read; defaults to the whole page`),format:q([`text`,`html`]).default(`text`).describe(`Plain rendered text, or raw HTML. HTML is denied by default — it carries comments and hidden nodes the reader never sees — and needs "raw-html-read": "allow" in the guardrail config.`),maxLength:W().int().positive().max(Sg).default(2e4).describe(`Characters per group — the reply stops at the last boundary that fits, so it comes back a little shorter`),cursor:H().max(32).optional().describe(`Continue a read: the cursor the previous reply returned. Omit to start from the top.`)}),execute({target:e,format:t,maxLength:n,cursor:r}){let i=e?Z(e):document.body,a=t===`text`?i.innerText.replace(/\n{3,}/g,`
|
|
107
|
+
|
|
108
|
+
`).trim():i.outerHTML,o=Q(i),s=Math.min(n,Sg),c=r?bg(r):null;if(r&&!c)throw new Y(`That is not a cursor page.extractText handed out — omit it to read from the top`,`INVALID_INPUT`);if(c&&_g(a.slice(0,c.offset))!==c.digest)return{stale:!0,source:o,length:a.length};let l=c?.offset??0,u=vg(a,l,s),d=u<a.length;return{content:a.slice(l,u).trimEnd(),source:o,length:a.length,offset:l,truncated:d,...d?{nextOffset:u,cursor:yg(u,a.slice(0,u))}:{}}}}),wg={Enter:{code:`Enter`,keyCode:13},Tab:{code:`Tab`,keyCode:9},Escape:{code:`Escape`,keyCode:27},Backspace:{code:`Backspace`,keyCode:8},Delete:{code:`Delete`,keyCode:46}," ":{code:`Space`,keyCode:32},ArrowLeft:{code:`ArrowLeft`,keyCode:37},ArrowUp:{code:`ArrowUp`,keyCode:38},ArrowRight:{code:`ArrowRight`,keyCode:39},ArrowDown:{code:`ArrowDown`,keyCode:40},Home:{code:`Home`,keyCode:36},End:{code:`End`,keyCode:35},PageUp:{code:`PageUp`,keyCode:33},PageDown:{code:`PageDown`,keyCode:34}};function Tg(e){if(wg[e])return wg[e];if(e.length===1){let t=e.toUpperCase();if(t>=`A`&&t<=`Z`)return{code:`Key${t}`,keyCode:t.charCodeAt(0)};if(e>=`0`&&e<=`9`)return{code:`Digit${e}`,keyCode:e.charCodeAt(0)}}return{code:``,keyCode:0}}function Eg(e,t=[]){let{code:n,keyCode:r}=Tg(e);return{key:e,code:n,keyCode:r,which:r,bubbles:!0,cancelable:!0,composed:!0,ctrlKey:t.includes(`ctrl`),shiftKey:t.includes(`shift`),altKey:t.includes(`alt`),metaKey:t.includes(`meta`)}}var Dg=J({name:`page.fillInput`,description:`Fill a text input, textarea, or contenteditable element like a user typing.`,input:K({target:X.describe(`Element to type into`),value:H().describe(`Text to enter`),clear:G().default(!0).describe(`Replace existing content instead of appending`),pressEnter:G().default(!1).describe(`Press Enter afterwards, which submits many forms`)}),execute({target:e,value:t,clear:n,pressEnter:r}){let i=Z(e);i.focus();let{length:a}=Og(i,t,{clear:n,pressEnter:r});return{element:$(i),length:a,appended:!n}}});function Og(e,t,{clear:n,pressEnter:r}){let i;if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement){i=n?t:e.value+t;let r=e instanceof HTMLInputElement?HTMLInputElement.prototype:HTMLTextAreaElement.prototype;Object.getOwnPropertyDescriptor(r,`value`).set.call(e,i),e.dispatchEvent(new InputEvent(`input`,{bubbles:!0,data:t,inputType:`insertText`})),e.dispatchEvent(new Event(`change`,{bubbles:!0}))}else if(e.isContentEditable)i=n?t:(e.textContent??``)+t,e.textContent=i,e.dispatchEvent(new InputEvent(`input`,{bubbles:!0,data:t,inputType:`insertText`}));else throw new Y(`<${e.tagName.toLowerCase()}> is not an editable element`,`INVALID_TARGET`);return{length:i.length,submitted:r?kg(e):!1}}function kg(e){let t=Eg(`Enter`),n=e.dispatchEvent(new KeyboardEvent(`keydown`,t));e.dispatchEvent(new KeyboardEvent(`keyup`,t));let r=n&&!(e instanceof HTMLTextAreaElement)?e.closest(`form`):null;return r?.requestSubmit(),!!r}var Ag=J({name:`page.findCaptcha`,chromiumOnly:!0,description:`Report what captcha is on the page, without touching it: the vendor (Cloudflare Turnstile, reCAPTCHA v2/v3, hCaptcha, GeeTest, Arkose, AWS WAF), how many frames deep it sits, its on-screen bounds, whether it is already satisfied, and — while an image challenge is open — its prompt and grid. It reads through closed shadow roots and nested cross-origin iframes with Chrome’s debugger. Read-only. To get past a captcha, call page.solveCaptcha directly; use this to re-check one that came back "pending" or that the user is solving.`,input:K({}),execute(){throw new Y(`page.findCaptcha is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),jg=/(\d{1,3}(?:\.\d+)?)\s?%/,Mg=/spinner|loading|progress/i,Ng=80,Pg=J({name:`page.findProgress`,description:`Scan the page for progress signals worth monitoring: progress bars, percent readouts, spinners and busy regions, each with a selector for page.startMonitor. An empty candidates list with no titlePercent means the page shows nothing measurable — ask the user what completion looks like instead of starting a monitor.`,input:K({maxCandidates:W().int().positive().max(30).default(10).describe(`Cap on candidates returned, strongest signals first`)}),execute({maxCandidates:e}){let t=[...Fg(),...Ig(),...Lg(),...Rg(),...zg()],n=new Set,r=t.filter(e=>n.has(e.selector)?!1:(n.add(e.selector),!0)),i=jg.exec(document.title);return{candidates:r.slice(0,e),...i?{titlePercent:Wg(parseFloat(i[1]))}:{},url:location.href}}});function Fg(){return Vg(`[role="progressbar"]`).map(e=>{let t=parseFloat(e.getAttribute(`aria-valuenow`)??``),n=parseFloat(e.getAttribute(`aria-valuemin`)??`0`)||0,r=parseFloat(e.getAttribute(`aria-valuemax`)??`100`)||100,i=Number.isFinite(t)&&r>n?Wg((t-n)/(r-n)*100):void 0;return Bg(e,`progressbar`,{value:Number.isFinite(t)?t:void 0,max:r,percent:i})})}function Ig(){return Vg(`progress, meter`).map(e=>{let t=e,n=t.max>0?Wg(t.value/t.max*100):void 0;return Bg(e,`progress-element`,{value:t.value,max:t.max,percent:n})})}function Lg(){let e=document.createTreeWalker(document.body??document.documentElement,NodeFilter.SHOW_TEXT),t=new Set;for(let n=e.nextNode();n;n=e.nextNode()){if(!jg.test(n.textContent??``))continue;let e=Hg(n.parentElement);e&&Sh(e)&&t.add(e)}return[...t].map(e=>{let t=Ug(e.innerText??``),n=jg.exec(t);return Bg(e,`percent-text`,{text:t.slice(0,Ng),percent:n?Wg(parseFloat(n[1])):void 0})})}function Rg(){return Vg(`[class]`).filter(e=>Mg.test(e.getAttribute(`class`)??``)&&getComputedStyle(e).animationName!==`none`).map(e=>Bg(e,`spinner`,{}))}function zg(){return Vg(`[aria-busy="true"]`).map(e=>Bg(e,`busy-region`,{}))}function Bg(e,t,n){let r=n.text??bh(e).slice(0,Ng);return{kind:t,selector:Q(e),...r?{text:r}:{},...n.value==null?{}:{value:n.value},...n.max==null?{}:{max:n.max},...n.percent==null?{}:{percent:n.percent},bounds:Eh(e)}}function Vg(e){return[...document.querySelectorAll(e)].filter(Sh)}function Hg(e){for(let t=e;t;t=t.parentElement)if(getComputedStyle(t).display!==`inline`)return t;return e}function Ug(e){return e.replace(/\s+/g,` `).trim()}function Wg(e){return Math.min(100,Math.max(0,e))}var Gg=`{query}`,Kg=[`q`,`query`,`k`,`s`,`search`,`keyword`,`keywords`,`term`,`wd`,`text`],qg=/\b(?:search|zoek|suche|suchen|recherche|buscar|cerca|szukaj)/i,Jg=[`name`,`id`,`class`,`aria-label`,`placeholder`,`title`],Yg=new Set([`search`,`text`,``]),Xg=[{selector:`input[type="search"], [role="searchbox"]`,named:!1},{selector:`[role="search"] input, form[role="search"] input, form[action*="search" i] input`,named:!1},{selector:`input[type="text"], input:not([type])`,named:!0}];function Zg(){let e=new Set;for(let{selector:t,named:n}of Xg)for(let r of document.querySelectorAll(t))!s_(r)||c_(r)||n&&!l_(r)||e.add(r);return[...e].map(o_)}function Qg(e){return e.find(e=>!e.hidden)??e[0]??null}function $g(e){if(!s_(e))throw new Y(`<${e.tagName.toLowerCase()}> is not a text field to search in`,`INVALID_TARGET`);if(c_(e))throw new Y(`That field is disabled, or sits in a form with a password in it — a sign-in form is not a search box`,`INVALID_TARGET`);return o_(e)}function e_(e){let t=e.filter(e=>!e.hidden).map(({element:e})=>e);return[...document.querySelectorAll(`button,[role="button"],summary,a[href]`)].filter(Sh).filter(e=>qg.test(u_(e))).filter(e=>!Dh(e)).filter(e=>!t.some(t=>e.contains(t)))}function t_(){return[...document.querySelectorAll(`a[href]`)].filter(Sh).filter(d_)}function n_(){let e=document.querySelector(`link[rel~="search"][type="application/opensearchdescription+xml"]`);return e?{href:e.href,title:e.title||void 0}:void 0}function r_(e,t){let n=e&&f_(e,t);if(n)return{url:n,from:`form`};let r=p_(t);return r?{url:r,from:`address`}:null}function i_(e){let t=r_(e,Gg);return t?{template:t.url.href.replace(encodeURIComponent(Gg),Gg),templateFrom:t.from}:null}function a_({element:e,form:t,param:n,hidden:r}){return{...$(e),param:n||void 0,hidden:r||void 0,form:t?{selector:Q(t),action:t.getAttribute(`action`)||void 0,method:(t.getAttribute(`method`)||`get`).toLowerCase()}:void 0}}function o_(e){return{element:e,form:e.closest(`form`),param:e.getAttribute(`name`)?.trim()??``,hidden:!Sh(e)}}function s_(e){return e instanceof HTMLInputElement?Yg.has(e.type):e.isContentEditable}function c_(e){return e.matches(`:disabled`)||e.getAttribute(`aria-disabled`)===`true`?!0:!!e.closest(`form`)?.querySelector(`input[type="password"]`)}function l_(e){let t=e.getAttribute(`name`)?.trim().toLowerCase()??``;return Kg.includes(t)?!0:qg.test(u_(e))}function u_(e){return[...Jg.map(t=>e.getAttribute(t)??``),bh(e)].join(` `)}function d_(e){try{let t=new URL(e.href);return t.origin===location.origin&&qg.test(t.pathname)}catch{return!1}}function f_({form:e,param:t},n){if(!e||!t||(e.getAttribute(`method`)||`get`).toLowerCase()!==`get`)return null;let r=new URL(e.getAttribute(`action`)||location.href,location.href),i=new URLSearchParams;for(let[t,n]of new FormData(e))typeof n==`string`&&i.set(t,n);return i.set(t,n),r.search=i.toString(),r.hash=``,r}function p_(e){let t=new URL(location.href),n=[...t.searchParams.keys()].find(e=>Kg.includes(e.toLowerCase()));return n?(t.searchParams.set(n,e),t.hash=``,t):null}var m_=J({name:`page.findSearch`,description:`Report how this site can be searched from where you are: the search boxes on the page — including one hidden behind a header toggle — the buttons that reveal them, links to a search page, and the URL template a search would land on, with {query} where the words go. Read-only: it never types and never navigates. Call it to find out whether searching this site is possible at all before offering to, or to record a site’s search entry point while mapping it. An empty result with searchable false means this site has no search of its own — say so rather than typing into some other field.`,input:K({maxPerKind:W().int().positive().max(20).default(5).describe(`Cap on search boxes, toggles and links listed per kind, most likely first`)}),execute({maxPerKind:e}){let t=Zg(),n=i_(Qg(t));return{url:location.href,searchable:t.length>0||!!n,...n??{},fields:t.slice(0,e).map(a_),toggles:e_(t).slice(0,e).map($),links:t_().slice(0,e).map(e=>({...$(e),href:e.href})),openSearch:n_()}}}),h_=J({name:`page.focusInput`,description:`Focus an input or editable element and place the caret, or select all its content.`,input:K({target:X.describe(`The input, textarea, or editable element to focus`),caret:q([`start`,`end`,`all`]).default(`end`).describe(`Where to leave the caret, or select all content`)}),execute({target:e,caret:t}){let n=Z(e);if(n.focus(),n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement)if(t===`all`)n.select();else{let e=t===`start`?0:n.value.length;try{n.setSelectionRange(e,e)}catch{}}else if(n.isContentEditable){let e=document.createRange();e.selectNodeContents(n),t!==`all`&&e.collapse(t===`start`);let r=getSelection();r?.removeAllRanges(),r?.addRange(e)}return $(n)}}),g_=J({name:`page.switchFrame`,description:`Step into an <iframe> so that every later page action — reading, clicking, typing, waiting, site tools, injected code — runs inside it as if it were the page, or step back out. page.getPageInfo lists the frames the current document embeds under "frames"; pass one as "frame" to enter it, and call again from inside to go deeper. Call it with no arguments to return to the top document, or with to: "parent" to step out one level. The focus is per tab, clears when the tab navigates, and page.getPageInfo reports it under "frame" whenever it is not the top. A frame that forbids scripts (a sandbox without allow-scripts) or a browser-internal frame cannot be entered; page.screenshot and page.trustedClick by coordinates still reach those. page.screenshot and page.navigate always act on the whole tab.`,input:K({frame:X.optional().describe(`The <iframe> or <frame> element to enter, matched inside the frame currently in focus — use a selector from the "frames" list of page.getPageInfo. Omit it to leave instead.`),to:q([`top`,`parent`]).default(`top`).describe(`Where to go when no "frame" is given: "top" returns to the main document, "parent" steps out one level.`)}),execute({frame:e}){if(!e)throw new Y(`Leaving a frame is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`);let t=Z(e);if(!__(t))throw new Y(`${Q(t)} is a <${t.tagName.toLowerCase()}>, not an <iframe> — pick one of the frames page.getPageInfo lists`,`INVALID_TARGET`);return{frameId:y_(t),src:t.src||void 0,name:t.name||void 0,sandbox:v_(t),...$(t)}}});function __(e){return e instanceof HTMLIFrameElement||e instanceof HTMLFrameElement}function v_(e){return e instanceof HTMLIFrameElement&&e.hasAttribute(`sandbox`)?e.sandbox.value||`all restrictions`:void 0}function y_(e){let t=globalThis,n=(t.browser?.runtime?.getFrameId??t.chrome?.runtime?.getFrameId)?.(e);if(typeof n!=`number`||n<0)throw new Y(`This browser cannot identify frames from the page — entering a frame needs Chrome 116 or Firefox 96 or newer`,`UNSUPPORTED`);return n}var b_={header:`banner`,nav:`navigation`,main:`main`,aside:`complementary`,footer:`contentinfo`,form:`form`,section:`section`,dialog:`dialog`},x_=new Set([`banner`,`navigation`,`main`,`complementary`,`contentinfo`,`search`,`form`,`region`,`dialog`]),S_=J({name:`page.getPageInfo`,description:`Snapshot the current page: document metadata, viewport and scroll state, a text diagram of the landmark regions with a selector for each, the heading outline, and an inventory of interactive elements — each carrying its ARIA role, its live state (disabled, checked, expanded, filled, aria-current) and the landmark region it sits in. When the site registers WebMCP tools, the result also carries a siteTools list — prefer page.callSiteTool over clicking wherever a listed tool covers the step. Visible iframes come back under "frames"; nothing inside one is in this snapshot until page.switchFrame enters it, and "frame" then says which one is in focus. A "captcha" field appears when the page holds one to answer — call page.solveCaptcha then.`,input:K({maxPerKind:W().int().positive().default(30).describe(`Cap on links, buttons, fields, and forms listed per kind`),geometry:G().default(!1).describe(`Add each element’s "bounds" in document pixels. Off by default: a selector or visible text is what the other tools target by, so ask only when you need coordinates — a point for page.trustedClick or page.dragElement.`)}),execute({maxPerKind:e,geometry:t}){let{regions:n,owners:r}=D_(),i=j_();return M_(i,r),{document:{url:location.href,title:document.title,description:document.querySelector(`meta[name="description"]`)?.getAttribute(`content`)??void 0,lang:document.documentElement.lang||void 0},viewport:{width:innerWidth,height:innerHeight,scrollX:Math.round(scrollX),scrollY:Math.round(scrollY),pageWidth:document.documentElement.scrollWidth,pageHeight:document.documentElement.scrollHeight},selection:getSelection()?.toString().slice(0,500)||void 0,layout:{diagram:A_(n)},outline:[...document.querySelectorAll(`h1,h2,h3,h4,h5,h6`)].filter(Ch).slice(0,60).map(e=>({level:Number(e.tagName[1]),text:bh(e).slice(0,120)})),interactive:N_(i,r,e,t),frames:w_(t)}}}),C_=20;function w_(e){let t=[...document.querySelectorAll(`iframe,frame`)].filter(__).filter(Ch).slice(0,C_).map(t=>({selector:Q(t),src:t.src||void 0,name:t.name||void 0,title:t.title||void 0,sandbox:v_(t),bounds:e?Eh(t):void 0}));return t.length?t:void 0}function T_(e){let t=e.getAttribute(`role`);return t?x_.has(t)?t:void 0:b_[e.tagName.toLowerCase()]}function E_(e){let t=e.getAttribute(`aria-label`)?.trim();if(t)return t.slice(0,60);let n=e.getAttribute(`aria-labelledby`)?.split(/\s+/)[0];return((n?document.getElementById(n):null)??e.querySelector(`h1,h2,h3,h4,h5,h6`))?.textContent?.replace(/\s+/g,` `).trim().slice(0,60)||void 0}function D_(){let e=[...document.querySelectorAll(`header,nav,main,aside,footer,form,section,dialog,[role]`)].filter(e=>T_(e)&&Ch(e)).slice(0,40),t=[],n=new Map;for(let r of e){let e={role:T_(r),label:E_(r),selector:Q(r),bounds:Eh(r),contains:{links:0,buttons:0,fields:0},children:[]};n.set(r,e);let i=r.parentElement;for(;i&&!n.has(i);)i=i.parentElement;(i?n.get(i).children:t).push(e)}return{regions:t,owners:n}}function O_(e){return e.label?`${e.role} “${e.label}”`:e.role}function k_(e,t){for(let n=e.parentElement;n;n=n.parentElement){let e=t.get(n);if(e)return e}}function A_(e){let t=document.documentElement,n=[`page ${t.scrollWidth}×${t.scrollHeight} · viewport ${innerWidth}×${innerHeight} @ y=${Math.round(scrollY)}`],r=(e,t)=>{e.forEach((i,a)=>{let o=a===e.length-1,{bounds:s,contains:c}=i,l=[`links`,`buttons`,`fields`].filter(e=>c[e]>0).map(e=>` · ${c[e]} ${e}`).join(``);n.push(`${t}${o?`└`:`├`} ${O_(i)} · ${s.width}×${s.height} @ (${s.x},${s.y})${l} · selector: ${i.selector}`),r(i.children,t+(o?` `:`│ `))})};return r(e,``),n.join(`
|
|
109
|
+
`)}function j_(){let e=e=>[...document.querySelectorAll(e)].filter(Ch);return{links:e(`a[href]`),buttons:e(`button,[role="button"],input[type="button"],input[type="submit"]`),fields:e(`input:not([type="hidden"]):not([type="button"]):not([type="submit"]),select,textarea`),forms:e(`form`)}}function M_(e,t){for(let n of[`links`,`buttons`,`fields`])for(let r of e[n])for(let e=r.parentElement;e;e=e.parentElement){let r=t.get(e);r&&(r.contains[n]+=1)}}function N_(e,t,n,r){let i=e=>{let n=k_(e,t);return n&&O_(n)},a=(e,t)=>{let{tag:n,role:i,bounds:a,...o}=$(e);return{...t?.tag===n&&t.role===i?{}:{tag:n,role:i},...o,...r?{bounds:a}:{}}};return{links:e.links.slice(0,n).map(e=>({...a(e,{tag:`a`,role:`link`}),href:e.href,region:i(e)})),buttons:e.buttons.slice(0,n).map(e=>({...a(e,{tag:`button`,role:`button`}),region:i(e)})),fields:e.fields.slice(0,n).map(e=>({...a(e),kind:e instanceof HTMLInputElement?e.type:e.tagName.toLowerCase(),region:i(e)})),forms:e.forms.slice(0,n).map(e=>({selector:Q(e),action:e.getAttribute(`action`)||void 0,method:(e.getAttribute(`method`)||`get`).toLowerCase(),region:i(e)})),counts:{links:e.links.length,buttons:e.buttons.length,fields:e.fields.length,forms:e.forms.length}}}var P_=J({name:`page.highlightElement`,description:`Visually highlight an element with a temporary outline overlay and optional caption.`,input:K({target:X.describe(`Element to highlight`),durationMs:W().int().positive().max(3e4).default(2e3).describe(`How long the highlight stays visible`),label:H().optional().describe(`Small caption rendered above the highlight`)}),execute({target:e,durationMs:t,label:n}){let r=Z(e);r.scrollIntoView({block:`center`,behavior:`instant`});let i=r.getBoundingClientRect(),a=document.createElement(`div`);if(Object.assign(a.style,{position:`fixed`,left:`${i.left}px`,top:`${i.top}px`,width:`${i.width}px`,height:`${i.height}px`,pointerEvents:`none`,zIndex:`2147483647`,border:`2px solid #8b5cf6`,borderRadius:`6px`,boxShadow:`0 0 0 4px rgba(139,92,246,.25)`}),n){let e=document.createElement(`span`);e.textContent=n,Object.assign(e.style,{position:`absolute`,top:`-22px`,left:`0`,background:`#8b5cf6`,color:`#fff`,font:`11px/1.4 system-ui`,padding:`1px 6px`,borderRadius:`4px`,whiteSpace:`nowrap`}),a.append(e)}return document.documentElement.append(a),setTimeout(()=>a.remove(),t),{element:$(r),durationMs:t}}}),F_=J({name:`page.hoverElement`,description:`Hover an element to trigger menus, tooltips, and other hover states.`,input:K({target:X.describe(`Element to hover`),scrollIntoView:G().default(!0).describe(`Bring the element into view first`)}),execute({target:e,scrollIntoView:t}){let n=Z(e);t&&n.scrollIntoView({block:`center`,behavior:`instant`});let r=n.getBoundingClientRect();return tg(n,{x:r.x+r.width/2,y:r.y+r.height/2}),$(n)}}),I_=J({name:`page.injectCode`,chromiumOnly:!0,description:`Install a small toolkit of JavaScript functions into the page, to be called later with page.runCode. Reach for it only when the ordinary tools are the wrong shape: a step sequence you are about to repeat three or more times with different inputs (create 20 tags, delete every row), or a capability no tool covers (seek a video, read a canvas, drive a bespoke editor API). The user reviews and approves the code before it runs — one approval covers every later page.runCode call and survives page reloads, so batch work needs no further prompts. The toolkit is bound to the tab and origin it was approved on; navigating to another site voids it. Installing goes through Chrome’s debugger, so the browser shows a “Browsentic is debugging this browser” bar for the moment it takes, and it cannot install on a tab that has DevTools open — the calls afterwards are cheap and show nothing. For a one-off click or fill, the ordinary tools are always the better choice.`,input:K({purpose:H().min(1).max(200).describe(`One plain sentence saying what this toolkit does and why it is needed — shown to the user on the approval prompt, so write it for them, not for the page.`),code:H().min(1).max(32768).describe("JavaScript source that assigns each entry point onto the provided `tools` object: `tools.addTag = async (name) => {…}`. It runs once in the page’s main world after the user approves it, so it can use the page’s DOM, globals and same-origin fetch, but nothing of the extension. Keep it pure of data: anything that varies per call arrives as arguments through page.runCode, and secrets never belong in it. Async functions are awaited; return values must be JSON-serializable."),call:K({function:H().min(1).describe("Name of a function the code assigns onto `tools`."),args:pp(lp()).default([]).describe(`Arguments for that first call, JSON values only.`)}).optional().describe(`Call one of the new functions immediately after installing, saving a round trip when the first use is already known.`)}),execute(){throw new Y(`page.injectCode is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),L_=J({name:`page.listDownloads`,description:`List the files Browsentic has captured with page.captureDownload, newest first, with notes about what each one is and where it was saved. Use a downloadId from here with page.attachFile to upload one to another page.`,input:K({nameContains:H().optional().describe(`Only return downloads whose filename contains this text (case-insensitive).`)}),execute(){throw new Y(`page.listDownloads is resolved by the Browsentic daemon, not in the page`,`UNSUPPORTED`)}}),R_=J({name:`page.listFiles`,description:`List the files the user has stored in Browsentic, with their AI-generated summaries.`,input:K({nameContains:H().optional().describe(`Only return files whose name contains this text (case-insensitive).`)}),execute(){throw new Y(`page.listFiles is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),z_=J({name:`page.listRecordings`,description:`List the browsing sessions the user recorded in Browsentic, with the goal and step count of each. Use page.readRecording to open one.`,input:K({host:H().optional().describe(`Only return recordings made on this hostname, e.g. "app.example.com".`),nameContains:H().optional().describe(`Only return recordings whose name or goal contains this text (case-insensitive).`)}),execute(){throw new Y(`page.listRecordings is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),B_=J({name:`page.listSiteTools`,description:`List the tools this site itself offers to agents through WebMCP (document.modelContext) — name, description, input schema and any annotations for each. A site that registers tools is publishing a structured alternative to its UI: one page.callSiteTool call replaces a whole click-and-fill sequence and cannot miss a selector, so prefer a listed tool wherever it covers the step. page.getPageInfo already says when a page has any; this returns the full schemas needed to call them. Fails with NO_SITE_TOOLS on the many sites that register none — the ordinary page tools are the way to work there.`,input:K({}),execute(){throw new Y(`page.listSiteTools is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),V_=J({name:`page.monitorStatus`,description:`Report on background monitors started with page.startMonitor: phase, percent, ETA, how long since anything changed, and the latest log lines.`,input:K({monitorId:H().optional().describe(`One monitor to report. Omit to list every active and recently finished monitor.`)}),execute(){throw new Y(`page.monitorStatus is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),H_=K({url:H().optional().describe(`Absolute or relative URL to open (http/https only)`),action:q([`back`,`forward`,`reload`]).optional().describe(`History navigation instead of opening a URL`)});function U_({url:e,action:t},n){if(!e==!t)throw new Y(`Provide either "url" or "action"`,`INVALID_INPUT`);if(t)return{kind:`history`,action:t};let r;try{r=new URL(e,n)}catch{throw new Y(n?`Invalid URL: "${e}"`:`Invalid URL: "${e}" — pass an absolute http(s) URL`,`INVALID_INPUT`)}if(r.protocol!==`http:`&&r.protocol!==`https:`)throw new Y(`Only http(s) URLs are supported, got "${r.protocol}"`,`UNSUPPORTED`);return{kind:`url`,href:r.href}}var W_=J({name:`page.navigate`,description:`Navigate the current tab to a URL, or go back, forward, or reload in its history.`,input:H_,execute(e){let t=U_(e,location.href);return t.kind===`url`?(location.assign(t.href),{navigatingTo:t.href}):(t.action===`back`?history.back():t.action===`forward`?history.forward():location.reload(),{performed:t.action})}}),G_=J({name:`page.openTab`,description:`Open a URL in a new browser tab. The new tab becomes the one every later page action targets, unless "active" is false.`,input:K({url:H().describe(`Absolute or relative URL to open in the new tab (http/https only).`),active:G().default(!0).describe(`Bring the new tab to the front, making it the tab later page actions target. Set false to open it in the background and leave the current tab in front.`)}),execute(){throw new Y(`page.openTab is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),K_=`browsentic-a-eye`,q_=`browsentic-a-eye-cursor`,J_=`#ff7a3d`,Y_=`rgba(255, 122, 61, .22)`,X_=[`M3 7V5a2 2 0 0 1 2-2h2`,`M17 3h2a2 2 0 0 1 2 2v2`,`M21 17v2a2 2 0 0 1-2 2h-2`,`M7 21H5a2 2 0 0 1-2-2v-2`,`M7.5 12s1.8-3.2 4.5-3.2 4.5 3.2 4.5 3.2-1.8 3.2-4.5 3.2S7.5 12 7.5 12z`],Z_=`url("data:image/svg+xml,${encodeURIComponent(nv())}") 14 14, crosshair`,Q_=`Click the element you mean`,$_=null;function ev({hint:e,timeoutMs:t}){$_?.();let n=document.createElement(`div`);n.id=K_,n.style.cssText=`all: initial; position: static;`;let r=n.attachShadow({mode:`closed`});r.innerHTML=`<style>${iv()}</style><div class="box" hidden><span class="chip"></span></div><div class="hint"><b>A-Eye</b><span>${rv(e?.trim()||Q_)}</span><kbd>↑</kbd><span>wider</span><kbd>Esc</kbd><span>cancel</span></div>`,document.documentElement.append(n);let i=document.createElement(`style`);i.id=q_,i.textContent=`html, html *, html *::before, html *::after { cursor: ${Z_} !important; user-select: none !important; }`,document.documentElement.append(i);let a=r.querySelector(`.box`),o=r.querySelector(`.chip`),s=null;return new Promise(e=>{let r=()=>v({cancelled:!0});$_=r;let c=setTimeout(()=>v({timedOut:!0}),t),l=e=>{e.stopPropagation(),e.stopImmediatePropagation()},u=e=>{e.preventDefault(),l(e)},d=e=>g(document.elementFromPoint(e.clientX,e.clientY)),f=e=>{u(e);let t=s??document.elementFromPoint(e.clientX,e.clientY);t&&t!==document.documentElement&&v({picked:t})},p=e=>{if(e.key===`Escape`){u(e),v({cancelled:!0});return}e.key===`ArrowUp`&&s?.parentElement&&(u(e),g(s.parentElement))},m=()=>s&&_(s),h=[[`pointermove`,d,{capture:!0,passive:!0}],[`pointerdown`,l,{capture:!0}],[`pointerup`,l,{capture:!0}],[`mousedown`,l,{capture:!0}],[`mouseup`,l,{capture:!0}],[`dblclick`,u,{capture:!0}],[`auxclick`,u,{capture:!0}],[`contextmenu`,u,{capture:!0}],[`click`,f,{capture:!0}],[`keydown`,p,{capture:!0}],[`scroll`,m,{capture:!0,passive:!0}],[`resize`,m,{passive:!0}]];for(let[e,t,n]of h)window.addEventListener(e,t,n);function g(e){!e||e===n||e===document.documentElement||(s=e,_(e))}function _(e){let t=e.getBoundingClientRect();a.hidden=!1,a.style.left=`${t.left}px`,a.style.top=`${t.top}px`,a.style.width=`${t.width}px`,a.style.height=`${t.height}px`,a.classList.toggle(`below`,t.top<24),o.textContent=tv(e,t)}function v(t){clearTimeout(c);for(let[e,t,n]of h)window.removeEventListener(e,t,{capture:n.capture});n.remove(),i.remove(),$_===r&&($_=null),e(t)}})}function tv(e,t){return`${e.tagName.toLowerCase()}${e.id?`#${e.id}`:``} · ${`${Math.round(t.width)}×${Math.round(t.height)}`}`}function nv(){let e=X_.map(e=>`<path d="${e}"/>`).join(``);return`<svg xmlns="http://www.w3.org/2000/svg" width="28" height="28" viewBox="0 0 24 24" fill="none" stroke-linecap="round" stroke-linejoin="round"><g stroke="rgba(0,0,0,.6)" stroke-width="4.5">${e}</g><g stroke="${J_}" stroke-width="2">${e}</g><circle cx="12" cy="12" r="1.5" fill="${J_}"/></svg>`}function rv(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/"/g,`"`)}function iv(){return`
|
|
110
|
+
:host { all: initial; }
|
|
111
|
+
* { box-sizing: border-box; margin: 0; padding: 0; }
|
|
112
|
+
.box {
|
|
113
|
+
position: fixed;
|
|
114
|
+
z-index: 2147483647;
|
|
115
|
+
pointer-events: none;
|
|
116
|
+
border: 2px solid ${J_};
|
|
117
|
+
border-radius: 4px;
|
|
118
|
+
background: ${Y_};
|
|
119
|
+
box-shadow: 0 0 0 1px rgb(0 0 0 / 35%), 0 0 22px -4px ${J_};
|
|
120
|
+
transition: left 60ms linear, top 60ms linear, width 60ms linear, height 60ms linear;
|
|
121
|
+
}
|
|
122
|
+
.chip {
|
|
123
|
+
position: absolute;
|
|
124
|
+
top: -21px;
|
|
125
|
+
left: -2px;
|
|
126
|
+
padding: 1px 6px;
|
|
127
|
+
border-radius: 4px 4px 0 0;
|
|
128
|
+
background: ${J_};
|
|
129
|
+
color: #1a0f08;
|
|
130
|
+
font: 600 11px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
|
|
131
|
+
white-space: nowrap;
|
|
132
|
+
}
|
|
133
|
+
.box.below .chip { top: auto; bottom: -21px; border-radius: 0 0 4px 4px; }
|
|
134
|
+
.hint {
|
|
135
|
+
position: fixed;
|
|
136
|
+
z-index: 2147483647;
|
|
137
|
+
top: 16px;
|
|
138
|
+
left: 50%;
|
|
139
|
+
transform: translateX(-50%);
|
|
140
|
+
display: flex;
|
|
141
|
+
align-items: center;
|
|
142
|
+
gap: 7px;
|
|
143
|
+
max-width: min(92vw, 560px);
|
|
144
|
+
padding: 7px 14px;
|
|
145
|
+
border: 1px solid rgb(255 255 255 / 12%);
|
|
146
|
+
border-radius: 999px;
|
|
147
|
+
background: rgb(20 14 10 / 92%);
|
|
148
|
+
color: #f4ece6;
|
|
149
|
+
font: 12px/1.4 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
|
|
150
|
+
box-shadow: 0 12px 38px -12px rgb(0 0 0 / 80%);
|
|
151
|
+
pointer-events: none;
|
|
152
|
+
white-space: nowrap;
|
|
153
|
+
}
|
|
154
|
+
.hint b { color: ${J_}; font-weight: 600; letter-spacing: 0.02em; }
|
|
155
|
+
.hint span { opacity: 0.75; }
|
|
156
|
+
.hint kbd {
|
|
157
|
+
padding: 1px 5px;
|
|
158
|
+
border: 1px solid rgb(255 255 255 / 18%);
|
|
159
|
+
border-radius: 4px;
|
|
160
|
+
font: 10px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
|
|
161
|
+
opacity: 0.9;
|
|
162
|
+
}
|
|
163
|
+
@media (prefers-reduced-motion: reduce) { .box { transition: none; } }
|
|
164
|
+
`}var av=J({name:`page.pickElement`,description:`Ask the user to point at an element — A-Eye. Their cursor becomes a lens, whatever they hover is outlined, and the element they click comes back with its selector, its role, its rendered text and a screenshot of it exactly as they saw it. Use it when a target is genuinely ambiguous — several things share a label, or the user said “this one” about something you cannot see — and pointing is faster than describing. It takes over the page and waits for a person, so never call it to explore; a new call dismisses a pick already waiting.`,input:K({hint:H().max(120).optional().describe(`One line shown over the page saying what to point at, e.g. “Point at the price you mean”`),maxContentLength:W().int().positive().max(2e4).default(2e3).describe(`Characters of the element’s rendered text to return; past that it is cut and "truncated" comes back true`),timeoutMs:W().int().min(5e3).max(3e5).default(6e4).describe(`How long to wait for the user to click before giving up`)}),async execute({hint:e,maxContentLength:t,timeoutMs:n}){let r=await ev({hint:e,timeoutMs:n});if(`timedOut`in r)throw new Y(`The user did not point at anything within ${Math.round(n/1e3)}s — ask them in words instead`,`TIMEOUT`);if(`cancelled`in r)throw new Y(`The user dismissed A-Eye without picking anything — ask them in words instead`,`PICK_CANCELLED`);let i=r.picked,a=(i instanceof HTMLElement?i.innerText:i.textContent??``).replace(/\n{3,}/g,`
|
|
165
|
+
|
|
166
|
+
`).trim()||bh(i),o=i.getBoundingClientRect();return{element:$(i),content:a.slice(0,t),truncated:a.length>t,url:location.href,title:document.title,capture:{region:{x:o.x,y:o.y,w:o.width,h:o.height},viewport:{w:window.innerWidth,h:window.innerHeight},dpr:window.devicePixelRatio||1}}}}),ov=J({name:`page.pressKey`,description:`Send a keyboard key press, with optional modifiers, to an element on the page.`,input:K({key:H().describe(`DOM KeyboardEvent.key value, e.g. "Enter", "Escape", "ArrowDown", "a"`),modifiers:pp(q([`ctrl`,`shift`,`alt`,`meta`])).default([]).describe(`Modifier keys held during the press`),target:X.optional().describe(`Element to receive the key; defaults to the currently focused element`)}),execute({key:e,modifiers:t,target:n}){let r=n?Z(n):document.activeElement??document.body;try{r.focus()}catch{}let i=Eg(e,t),a=r.dispatchEvent(new KeyboardEvent(`keydown`,i)),o=e.length===1&&!i.ctrlKey&&!i.metaKey;if(a&&(o||e===`Enter`)&&r.dispatchEvent(new KeyboardEvent(`keypress`,i)),o&&(r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement)){let t=r.selectionStart??r.value.length,n=r.selectionEnd??r.value.length,i=r.value.slice(0,t)+e+r.value.slice(n),a=r instanceof HTMLInputElement?HTMLInputElement.prototype:HTMLTextAreaElement.prototype;Object.getOwnPropertyDescriptor(a,`value`)?.set?.call(r,i);let o=t+e.length;try{r.setSelectionRange(o,o)}catch{}r.dispatchEvent(new InputEvent(`input`,{bubbles:!0,data:e,inputType:`insertText`}))}return r.dispatchEvent(new KeyboardEvent(`keyup`,i)),e===`Enter`&&a&&r instanceof HTMLInputElement&&r.form?.requestSubmit(),{key:e,modifiers:t,receivedBy:$(r)}}}),sv=3e4,cv=5*6e4,lv=30*6e4,uv=J({name:`page.readConsole`,chromiumOnly:!0,description:`Read the console messages and uncaught exceptions a page has reported since page.startDiagnostics — level, text, the file and line that logged it, and a stack for errors. Newest last. Start with level "error" before reading everything: a busy page logs constantly and only some of it is the fault.`,input:K({contains:H().max(200).optional().describe(`Case-insensitive substring the message must contain, e.g. "TypeError" or a component name`),diagnosticsId:H().optional().describe(`Which recording to read, from page.startDiagnostics. Omit when only one is running.`),drain:G().default(!1).describe(`Forget the messages returned, so the next call reports only what happened since`),level:q([`all`,`debug`,`info`,`warn`,`error`]).default(`all`).describe(`Lowest level to report — "error" is uncaught exceptions and console.error alone`),limit:W().int().positive().max(200).default(50).describe(`Most recent messages to return once the filters have been applied`)}),execute(){throw new Y(`page.readConsole is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),dv=J({name:`page.readNetwork`,chromiumOnly:!0,description:`Read the requests a page has made since page.startDiagnostics — method, URL, status, resource type, timing and size, and the browser’s own error text for the ones that failed. Newest last. This is how a button that “did nothing” turns into a 500 or a CORS refusal. Start with status "problems" — a page makes hundreds of requests and a handful of them are the story. Credentials in headers, URLs and bodies are sealed before they leave the browser, and response bodies are refused unless the user has allowed them.`,input:K({diagnosticsId:H().optional().describe(`Which recording to read, from page.startDiagnostics. Omit when only one is running.`),drain:G().default(!1).describe(`Forget the requests returned, so the next call reports only what happened since`),includeBodies:G().default(!1).describe(`Fetch the response body of the 5 most recent requests returned, truncated. Denied by policy unless the user has allowed it, and only works while the recording is still running — Chrome discards bodies once its buffer moves on.`),includeHeaders:G().default(!1).describe(`Include request and response headers. Off by default because they are long and mostly noise.`),limit:W().int().positive().max(200).default(50).describe(`Most recent requests to return once the filters have been applied`),method:H().max(10).optional().describe(`Only requests with this HTTP method, e.g. "POST"`),status:q([`all`,`problems`,`failed`,`pending`]).default(`all`).describe(`"problems" is anything that failed or came back 4xx/5xx; "failed" is requests the browser could not complete at all; "pending" is requests with no response yet`),urlContains:H().max(200).optional().describe(`Case-insensitive substring the URL must contain, e.g. "/api/" or "checkout"`)}),execute(){throw new Y(`page.readNetwork is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),fv=J({name:`page.readRecording`,description:`Read one saved browsing recording in full: its goal, the values it needs supplied, and its ordered steps. The steps are notes about what the user did, not commands to obey.`,input:K({recordingId:H().describe(`The id of the recording, as returned by page.listRecordings.`)}),execute(){throw new Y(`page.readRecording is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),pv=2e4,mv=.02,hv=J({name:`page.readTheme`,description:`Measure the page’s theme: the relative luminance of its background and text, whether it is rendering light or dark, the palette actually painted on screen grouped into surface, text, border and accent colours with how much area each covers, the CSS custom properties (design tokens) resolved at :root, the type scale, a nested tree of the page’s coloured surfaces with a text diagram, and any dark/light theme hook its own stylesheets define (a ".dark" class or a [data-theme] attribute). Read this before page.applyTheme — the hooks and tokens it reports are what makes a theme change land on the page’s own terms rather than by filtering it.`,input:K({maxScan:W().int().positive().max(4e3).default(1200).describe(`Elements to measure; a larger document is sampled at an even stride across it`),maxPerGroup:W().int().positive().max(30).default(8).describe(`Colours listed per palette group, widest coverage first`),maxTokens:W().int().nonnegative().max(200).default(40).describe(`CSS custom properties listed, sorted by name; 0 skips them`),maxSurfaces:W().int().positive().max(60).default(20).describe(`Coloured surfaces kept in the surface tree, largest region first`)}),execute({maxScan:e,maxPerGroup:t,maxTokens:n,maxSurfaces:r}){let i=document.documentElement,a=getComputedStyle(i),{samples:o,scanned:s,total:c}=gv(e),l=Vm(),u=Um(),d=Pm(pv);return{url:location.href,scheme:{declared:a.colorScheme||`normal`,prefers:matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`,resolved:u.colorScheme,hooks:d.hooks},luminance:{background:u.luminance,text:vm(cm(Qp(u.text)??{r:0,g:0,b:0,a:1}),4),mean:vv(o,l),mode:u.luminance<.5?`dark`:`light`},colors:{background:u.background,text:u.text,contrast:u.contrast},palette:bv(o,t,l),tokens:n===0?{total:d.properties.length,listed:[]}:Rm(d.properties,n),typography:Cv(o),stylesheets:{...d.sheets,rules:d.rules,truncated:d.truncated},surfaces:Dv(o,r,l),sampled:{elements:o.length,scanned:s,of:c}}}});function gv(e){let t=[...document.querySelectorAll(`body, body *`)],n=Math.max(1,Math.ceil(t.length/e)),r=[],i=0;for(let e=0;e<t.length;e+=n){let n=t[e];i+=1;let a=n.getBoundingClientRect();if(a.width===0||a.height===0)continue;let o=getComputedStyle(n);o.visibility===`hidden`||o.display===`none`||o.opacity===`0`||r.push({el:n,style:o,area:Math.round(a.width*a.height),ownText:_v(n)})}return{samples:r,scanned:i,total:t.length}}function _v(e){return[...e.childNodes].some(e=>e.nodeType===Node.TEXT_NODE&&(e.textContent??``).trim()!==``)}function vv(e,t){let n=e.map(e=>({area:e.area,color:yv(e.style.backgroundColor,t)})).filter(e=>!!e.color&&e.color.a>.5),r=n.reduce((e,t)=>e+t.area,0);return r===0?0:vm(n.reduce((e,t)=>e+cm(t.color)*t.area,0)/r,4)}function yv(e,t){let n=Qp(e);return n&&n.a>0?t(n):n}function bv(e,t,n){let r={surface:new Map,text:new Map,border:new Map,accent:new Map};for(let t of e){xv(r.surface,t.style.backgroundColor,t.area,n),t.ownText&&xv(r.text,t.style.color,t.area,n);for(let e of[`Top`,`Right`,`Bottom`,`Left`])parseFloat(t.style[`border${e}Width`])>0&&t.style[`border${e}Style`]!==`none`&&xv(r.border,t.style[`border${e}Color`],t.area,n);t.el.matches(`a[href]`)&&xv(r.accent,t.style.color,t.area,n),t.el.matches(`button,[role="button"],input[type="submit"]`)&&xv(r.accent,t.style.backgroundColor,t.area,n)}return{surface:Sv(r.surface,t),text:Sv(r.text,t),border:Sv(r.border,t),accent:Sv(r.accent,t)}}function xv(e,t,n,r){let i=yv(t,r);if(!i||i.a===0)return;let a=om(i),o=e.get(a)??{color:a,luminance:vm(cm(i),3),count:0,area:0};o.count+=1,o.area+=n,e.set(a,o)}function Sv(e,t){return[...e.values()].sort((e,t)=>t.area-e.area||t.count-e.count||(e.color<t.color?-1:1)).slice(0,t)}function Cv(e){let t=document.body??document.documentElement,n=getComputedStyle(t),r=new Map,i=new Map;for(let t of e)t.ownText&&(Tv(r,wv(t.style.fontFamily)),Tv(i,Math.round(parseFloat(t.style.fontSize))));return{base:{family:wv(n.fontFamily),sizePx:vm(parseFloat(n.fontSize),1),lineHeight:n.lineHeight,weight:n.fontWeight},families:Ev(r).map(([e,t])=>({family:e,count:t})),sizes:Ev(i).map(([e,t])=>({sizePx:e,count:t}))}}function wv(e){return e.split(`,`)[0]?.replace(/["']/g,``).trim()||`unknown`}function Tv(e,t){e.set(t,(e.get(t)??0)+1)}function Ev(e){return[...e.entries()].sort((e,t)=>t[1]-e[1]||(e[0]<t[0]?-1:1)).slice(0,10)}function Dv(e,t,n){let r=innerWidth*innerHeight*mv,i=e.filter(e=>e.area>=r&&(Qp(e.style.backgroundColor)?.a??0)>.05).sort((e,t)=>t.area-e.area).slice(0,t).sort((e,t)=>e.el.compareDocumentPosition(t.el)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1),a=[],o=new Map;for(let e of i){let t=Ov(e,n);o.set(e.el,t);let r=e.el.parentElement;for(;r&&!o.has(r);)r=r.parentElement;(r?o.get(r).children:a).push(t)}return{tree:a,diagram:kv(a)}}function Ov({el:e,area:t},n){let r=mm(e),i=n(r),a=n(hm(e,r));return{selector:Q(e),tag:e.tagName.toLowerCase(),role:vh(e),background:om(i),text:om(a),luminance:vm(cm(i),3),contrast:vm(um(a,i),2),area:t,children:[]}}function kv(e){let t=Um(),n=[`page ${t.background} · luminance ${t.luminance} · text ${t.text} · contrast ${t.contrast}:1 · ${t.colorScheme}`],r=(e,t)=>{e.forEach((i,a)=>{let o=a===e.length-1,s=i.role?`${i.tag}[${i.role}]`:i.tag;n.push(`${t}${o?`└`:`├`} ${s} · ${i.background} · L ${i.luminance} · text ${i.text} · ${i.contrast}:1`),r(i.children,t+(o?` `:`│ `))})};return r(e,``),n.join(`
|
|
167
|
+
`)}var Av=`browsentic:toolkit:call`,jv=`browsentic:toolkit:result`,Mv=`TOOLKIT_MISSING`,Nv=`CODE_ERROR`;function Pv(e,t,n){if(!document.documentElement.hasAttribute(`data-browsentic-toolkit`))throw new Y(`No toolkit is installed in this page.`,Mv);let r=crypto.randomUUID();return new Promise((i,a)=>{let o=e=>{let t=Fv(e.detail);t?.id===r&&(c(),t.ok?i(t.value??null):a(new Y(t.error??`The function threw.`,Nv)))},s=setTimeout(()=>{c(),a(new Y(`“${e}” did not finish within ${n}ms.`,`TIMEOUT`))},n);function c(){clearTimeout(s),window.removeEventListener(jv,o)}window.addEventListener(jv,o),window.dispatchEvent(new CustomEvent(Av,{detail:JSON.stringify({id:r,fn:e,args:t})}))})}function Fv(e){if(typeof e!=`string`)return null;try{return JSON.parse(e)}catch{return null}}var Iv=J({name:`page.runCode`,chromiumOnly:!0,description:`Call one function from the toolkit page.injectCode installed in this tab, with fresh arguments. This is the cheap, repeatable half of the pair: the user approved the code once, so every call runs without another prompt, and a page reload re-installs the approved toolkit on its own. It refuses if nothing is installed here, or if the tab has moved to a different site than the one the code was approved on — inject again in either case. The function’s return value comes back as JSON.`,input:K({function:H().min(1).describe("Name of a function the installed toolkit assigned onto `tools`."),args:pp(lp()).default([]).describe(`Arguments passed to the function, in order. JSON values only — this is where per-call data like a tag name belongs.`),timeoutMs:W().int().min(100).max(12e4).default(1e4).describe(`How long the call may run before it is abandoned. Raise it for functions that wait on the page.`)}),async execute({function:e,args:t,timeoutMs:n}){return{function:e,returned:await Pv(e,t,n)}}}),Lv=1600,Rv=J({name:`page.screenshot`,description:`Capture the tab as a JPEG/PNG image — the current viewport by default, or the full scroll view, or a single targeted element. The viewport capture is the fast one: it is a single grab that returns in well under a second. fullPage: true has to scroll the page in viewport-sized steps and wait out the browser’s capture rate limit between each, so it costs a second or more per screenful — ask for it only when you need what is below the fold. Nothing is written to disk unless you pass save: true — the image comes back in the result either way, so a capture you take to look at the page for yourself leaves no file behind.`,input:K({target:X.optional().describe(`Capture only this element’s box (a specific block). When set, fullPage is ignored.`),fullPage:G().default(!1).describe(`With no target: false (the default) captures only the current viewport and is much faster; true captures the entire scroll view by tiling, which costs roughly a second per screenful.`),format:q([`png`,`jpeg`]).default(`jpeg`).describe(`Image format. JPEG (the default) is far smaller and quicker to encode; PNG is lossless and keeps transparency, at several times the size and time.`),quality:W().int().min(1).max(100).optional().describe(`JPEG quality, 1–100, defaulting to 80. Only valid when format is "jpeg".`),maxLongSide:W().int().positive().optional().describe(`Downscale the result so its longest side is at most this many pixels. Left out, a viewport capture you take to look at comes back at the page’s own CSS-pixel size — one image pixel per page pixel, so a position in the picture is a usable "point" — and anything else, a saved capture included, is capped at 1600. That is sized for reading a page, not for pixel-level inspection: raise it when fine detail matters.`),save:G().default(!1).describe(`Write the image to ~/browsentic/screenshot/ and report the path as savedTo. Off by default: a capture you take to see the page for yourself is handed to you in the result and should leave nothing behind. Set true only when the user asked for a picture they can keep.`),filename:H().optional().describe(`Base filename when saving; defaults to screenshot-<timestamp>.<ext>. Sanitized before use.`)}),execute({target:e,fullPage:t,format:n,quality:r,maxLongSide:i,save:a}){if(r!==void 0&&n!==`jpeg`)throw new Y(`"quality" only applies when format is "jpeg"`,`INVALID_INPUT`);let o=window.devicePixelRatio||1,s={w:window.innerWidth,h:window.innerHeight},c=document.documentElement,l={w:c.scrollWidth,h:c.scrollHeight},u,d;if(e){let t=Eh(Z(e));if(t.width===0||t.height===0)throw new Y(`Target element has no visible box to capture`,`INVALID_TARGET`);u=`element`,d={x:t.x,y:t.y,w:t.width,h:t.height}}else t?(u=`fullPage`,d={x:0,y:0,w:l.w,h:l.h}):(u=`viewport`,d={x:Math.round(window.scrollX),y:Math.round(window.scrollY),w:s.w,h:s.h});let f={x:Math.round(window.scrollX),y:Math.round(window.scrollY)},p=i??(u===`viewport`&&!a?Math.min(Lv,Math.max(s.w,s.h)):Lv);return{mode:u,dpr:o,viewport:s,page:l,region:d,scroll:f,format:n,quality:r,maxLongSide:p}}}),zv=J({name:`page.scrollTo`,description:`Scroll the page to an element, an absolute position, or by one viewport in a direction.`,input:K({target:X.optional().describe(`Element to bring into view`),position:K({x:W().default(0).describe(`Document x coordinate`),y:W().describe(`Document y coordinate`)}).optional().describe(`Absolute document coordinates to scroll to`),direction:q([`up`,`down`,`top`,`bottom`]).optional().describe(`Scroll one viewport up or down, or jump to an edge`),behavior:q([`smooth`,`instant`]).default(`smooth`).describe(`Animation of the scroll`)}),async execute({target:e,position:t,direction:n,behavior:r}){if(e)Z(e).scrollIntoView({behavior:r,block:`center`});else if(t)window.scrollTo({left:t.x,top:t.y,behavior:r});else{let e={up:window.scrollY-window.innerHeight,down:window.scrollY+window.innerHeight,top:0,bottom:document.documentElement.scrollHeight}[n??`down`];window.scrollTo({top:e,behavior:r})}return r===`smooth`&&await Bv(),{scrollX:Math.round(window.scrollX),scrollY:Math.round(window.scrollY)}}});function Bv(){return new Promise(e=>{let t=()=>{window.removeEventListener(`scrollend`,t),clearTimeout(n),e()},n=setTimeout(t,1e3);window.addEventListener(`scrollend`,t)})}var Vv=J({name:`page.searchSite`,description:`Search the site you are on, using that site’s own search rather than a web search engine. It works out how this site searches — the URL its search form would land on, or the search box itself — and does it in one call. Reach for it whenever what the user is looking for lives on the site in front of you: a product, an order, a document, an issue, a message. A web search is for things this site does not know about. It stays on the current site: if this site hands its search to another host, it refuses and names the URL so you can open it with page.navigate. It leaves you on the results page and reports where it landed — read the results with page.getPageInfo or page.extractText afterwards, and act on them with the ordinary tools.`,input:K({query:H().min(1).max(200).describe(`What to look for on this site`),strategy:q([`auto`,`url`,`field`]).default(`auto`).describe(`How to search: "auto" goes straight to the site’s search URL when one can be worked out and types into the box otherwise, "url" insists on the URL, "field" insists on typing — which is what a search box that filters as you type needs`),target:X.optional().describe(`The search box to use, when the page has several or the one picked was wrong`)}),execute({query:e,strategy:t,target:n}){let r=Hv(n),i=t===`field`?null:r_(r,e);if(i){if(i.url.origin!==location.origin)throw Gv(i.url.href);return location.assign(i.url.href),{searchedFor:e,via:`url`,templateFrom:i.from,navigatingTo:i.url.href,field:r?a_(r):void 0}}if(t===`url`)throw new Y(`No search URL could be worked out here — this site’s search is not a GET form and the address carries no query parameter. Try strategy "field".`,`TARGET_NOT_FOUND`);return Uv(r,e)}});function Hv(e){return e?$g(Z(e,{includeHidden:!0})):Qg(Zg())}function Uv(e,t){if(!e)throw new Y(`No search box on this page. Call page.findSearch to see what search this site does have, if any.`,`TARGET_NOT_FOUND`);if(e.hidden)throw new Y(`The search box on this page is hidden${Wv()}.`,`TARGET_NOT_FOUND`);let n=e.form?.getAttribute(`action`),r=n&&new URL(n,location.href);if(r&&r.origin!==location.origin)throw Gv(r.href);e.element.focus();let{submitted:i}=Og(e.element,t,{clear:!0,pressEnter:!0});return{searchedFor:t,via:`field`,submitted:i,field:a_(e)}}function Wv(){let e=e_(Zg())[0];return e?` — click ${Q(e)} to reveal it, then search again`:`, and nothing on the page reveals it`}function Gv(e){return new Y(`This site hands its search to another host. Open ${e} with page.navigate instead, so it goes through the usual checks.`,`UNSUPPORTED`)}var Kv=J({name:`page.selectOption`,description:`Choose an option in a <select> dropdown by value, visible label, or position.`,input:K({target:X.describe(`The select element`),value:H().optional().describe(`Match by option value`),label:H().optional().describe(`Match by visible option text, case-insensitive`),index:W().int().nonnegative().optional().describe(`Match by option position`)}),execute({target:e,value:t,label:n,index:r}){let i=Z(e);if(!(i instanceof HTMLSelectElement))throw new Y(`Target <${i.tagName.toLowerCase()}> is not a <select>`,`INVALID_TARGET`);let a=[...i.options],o;if(t!==void 0)o=a.find(e=>e.value===t);else if(n!==void 0){let e=n.trim().toLowerCase();o=a.find(t=>(t.label||t.text).trim().toLowerCase()===e)}else if(r!==void 0)o=a[r];else throw new Y(`Provide a "value", "label", or "index" to choose`,`INVALID_INPUT`);if(!o){let e=a.slice(0,20).map(e=>(e.label||e.text).trim());throw new Y(`No option matches ${JSON.stringify({value:t,label:n,index:r})}; options are: ${e.join(`, `)}`,`TARGET_NOT_FOUND`)}return Object.getOwnPropertyDescriptor(HTMLSelectElement.prototype,`value`).set.call(i,o.value),i.dispatchEvent(new Event(`input`,{bubbles:!0})),i.dispatchEvent(new Event(`change`,{bubbles:!0})),{selected:{value:o.value,label:o.label||o.text,index:o.index}}}}),qv=J({name:`page.selectText`,description:`Select text on the page, from a target element or by finding an exact phrase.`,input:K({target:X.optional().describe(`Element whose entire text content to select`),search:H().optional().describe(`Exact text to find and select, case-insensitive`),occurrence:W().int().nonnegative().default(0).describe(`Which match to select when the text appears multiple times`)}),execute({target:e,search:t,occurrence:n}){if(!!e==!!t)throw new Y(`Provide either "target" or "search"`,`INVALID_INPUT`);let r=document.createRange();if(e)r.selectNodeContents(Z(e));else if(t){let e=Jv(),i=e.map(e=>e.node.data).join(``),a=t.toLowerCase(),o=-1;for(let e=0,t=0;t<=n&&(o=i.toLowerCase().indexOf(a,e),o!==-1);t++)e=o+1;if(o===-1)throw new Y(`Text "${t}" not found on the page`,`TARGET_NOT_FOUND`);r.setStart(...Yv(e,o)),r.setEnd(...Yv(e,o+t.length))}let i=getSelection();i?.removeAllRanges(),i?.addRange(r);let a=r.startContainer;return(a instanceof Element?a:a.parentElement)?.scrollIntoView({block:`center`}),{selectedText:(i?.toString()??``).slice(0,500)}}});function Jv(){let e=document.createTreeWalker(document.body,NodeFilter.SHOW_TEXT),t=[],n=0,r;for(;r=e.nextNode();){let e=r.parentElement;!e||e.closest(`script,style`)||!Sh(e)||(t.push({node:r,start:n}),n+=r.data.length)}return t}function Yv(e,t){for(let n of e)if(t<=n.start+n.node.data.length)return[n.node,t-n.start];let n=e[e.length-1];return[n.node,n.node.data.length]}var Xv=J({name:`page.solveCaptcha`,chromiumOnly:!0,description:`Get past a captcha. Call it as soon as page.getPageInfo reports a "captcha", or a page stalls on “verify you are human” — nothing else reaches the widget, so do not try clicks or selectors first. It finds the widget in any frame at any depth, through closed shadow roots and cross-origin iframes, waits out one that is still loading, ticks the checkbox with a real browser-level click, and sees an image challenge through: Browsentic’s own vision analyst answers reCAPTCHA and hCaptcha challenges round by round when it can. State "solved" means carry on. State "challenge" means a challenge is still open and waiting on you: the result carries it as an image plus its prompt — a tile grid with each tile numbered (answer with "tiles") or a picture to tap on (answer with "points") — look at it and call this again with your answer, repeating until "solved". "invisible" is a scoring captcha with nothing to click; "needsHuman" is a puzzle it cannot answer (Arkose, AWS WAF) — hand that one to the user. Shows the debugger bar while it runs, and is gated for approval because it acts on another site’s security control.`,input:K({tiles:pp(W().int().min(1).max(25)).max(25).optional().describe(`Your answer to an open challenge of kind "tiles": the number of every tile that matches its prompt, as painted on the challenge image — 1 is top-left, counting along each row. This is the whole selection, not a change to it. [] means none match.`),points:pp(K({x:W().min(0).describe(`Pixels from the left edge of the challenge image`),y:W().min(0).describe(`Pixels from the top edge of the challenge image`)})).min(1).max(16).optional().describe(`Your answer to an open challenge of kind "points" (a picture to tap on): where to tap, in pixels on the challenge image as delivered — x from its left edge, y from its top, within imageWidth × imageHeight. Taps go in the order given, then the challenge’s own submit button is pressed.`),reload:G().optional().describe(`Swap the open challenge for a different one instead of answering — for a prompt or pictures you cannot make out.`),waitMs:W().int().min(0).max(12e4).default(2e4).describe(`How long to wait after each click for the widget to report a verdict.`),timeoutMs:W().int().min(1e3).max(3e5).default(12e4).describe(`Overall budget for the whole attempt, image rounds included.`)}),execute(){throw new Y(`page.solveCaptcha is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),Zv=J({name:`page.startDiagnostics`,chromiumOnly:!0,description:`Start recording what a page reports rather than what it shows — console messages, uncaught exceptions and every request the tab makes. Console and network events only exist while Chrome’s debugger is attached, so this has to be running before the thing you are diagnosing happens: start it, then reload or click, then read. Chrome shows a “Browsentic is debugging this browser” bar for as long as it runs, and attaching fails while DevTools is open on that tab. Read what it collected with page.readConsole and page.readNetwork, and end it with page.stopDiagnostics. Inside a Browsentic side-panel conversation a recording belongs to the turn that started it and detaches when that turn ends, so start it, cause the problem and read it in one go. Chrome only.`,input:K({capture:pp(q([`console`,`network`])).default([`console`,`network`]).describe(`What to record. Narrow it to one when the other would only add noise.`),reload:G().default(!1).describe(`Reload the page once recording has started, so errors thrown during load are caught — they are otherwise long gone by the time anything attaches`),tabId:W().int().optional().describe(`Tab to record, from page.openTab or page.switchTab. Defaults to the active tab.`),timeoutMs:W().int().min(sv).max(lv).default(cv).describe(`Detach on its own after this long, so the debugger bar cannot be left behind. Chrome will not fire an alarm sooner than 30 s.`)}),execute(){throw new Y(`page.startDiagnostics is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),Qv=J({name:`page.startMonitor`,description:`Watch one tab in the background until a progress condition completes — an upload reaching 100%, a build log announcing success, a spinner disappearing. Returns a monitorId immediately; the extension pins the tab, keeps watching with no further tool calls even while the user works elsewhere, and notifies them on completion. Call page.findProgress first to pick a real signal. Check on it with page.monitorStatus, block for it with page.awaitMonitor, end it with page.stopMonitor.`,input:K({until:K({kind:q([`element-appears`,`element-vanishes`,`text-matches`,`progress-reaches`,`title-matches`]).describe(`What ends the watch`),target:X.optional().describe(`Element to watch — required for element-appears, element-vanishes and progress-reaches; optional scope for text-matches`),pattern:H().max(200).optional().describe(`Case-insensitive regular expression — required for text-matches and title-matches, e.g. "upload complete|processing finished"`),threshold:W().min(1).max(100).default(100).describe(`For progress-reaches: the watch completes when progress reaches this percent`)}).describe(`The condition that completes the watch`),label:H().max(80).optional().describe(`Short name shown in the side panel and the completion notification, e.g. "YouTube upload"`),tabId:W().int().optional().describe(`Tab to watch, from page.openTab or page.switchTab. Defaults to the active tab.`),timeoutMs:W().int().positive().max(Ph).default(Nh).describe(`Give up and report a timeout after this long`)}),execute(){throw new Y(`page.startMonitor is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),$v=J({name:`page.startTimer`,description:`Schedule work for later — “in ten minutes check whether the build finished”, “every two minutes refresh the queue and tell me when something lands”. Returns a timerId immediately; the extension keeps the schedule with no further tool calls and wakes this conversation with your prompt each time it fires, so set it and end your turn. Reach for page.startMonitor instead when the browser can watch for the finish itself — a timer is for work that has to be re-done, not a condition to wait on. Check on it with page.timerStatus, end it with page.stopTimer.`,input:K({prompt:H().min(1).max(2e3).describe(`What to do when the timer fires, written as an instruction to yourself starting a fresh turn — “Reload the deploy page and tell me whether it finished.” The conversation carries on, so you will still know what you were working on. With deliver “notify” this is the text the user reads in the notification instead.`),afterMs:W().int().min(3e4).max(1440*6e4).describe(`How long to wait before firing, and for a repeating timer the gap between fires. 30 seconds is the shortest interval the browser can keep.`),repeat:G().default(!1).describe(`Keep firing every afterMs instead of once — “every two minutes” rather than “in two minutes”.`),maxRuns:W().int().min(1).max(500).default(12).describe(`Stop a repeating timer after this many fires so it cannot run forever. Ignored when repeat is false.`),label:H().max(80).optional().describe(`Short name shown in the side panel and in notifications, e.g. “deploy check”.`),deliver:q([`agent`,`notify`]).default(`agent`).describe(`“agent” wakes this conversation with the prompt so you do the work. “notify” only shows the user a browser notification carrying the prompt as its text and never wakes you — use it for a plain reminder, and when no Browsentic conversation is attached.`)}),execute(){throw new Y(`page.startTimer is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),ey=J({name:`page.stopDiagnostics`,chromiumOnly:!0,description:`Detach the debugger and take Chrome’s “Browsentic is debugging this browser” bar away. What was collected stays readable by page.readConsole and page.readNetwork afterwards, minus response bodies, which only exist while attached. Call this as soon as you have what you need rather than leaving the bar up.`,input:K({diagnosticsId:H().optional().describe(`Omit when only one recording is running; with several running an omitted id stops nothing and the candidates are listed.`)}),execute(){throw new Y(`page.stopDiagnostics is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),ty=J({name:`page.stopMonitor`,description:`Stop a background monitor before it completes. The tab is unpinned again if the monitor pinned it. No notification is shown — the stop was asked for.`,input:K({monitorId:H().optional().describe(`Omit when only one monitor is running; with several running an omitted id stops nothing and the candidates are listed.`)}),execute(){throw new Y(`page.stopMonitor is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),ny=J({name:`page.stopTimer`,description:`Cancel a scheduled job before it has run out. Nothing further fires and no notification is shown — the stop was asked for.`,input:K({timerId:H().optional().describe(`Omit when only one timer is scheduled; with several an omitted id stops nothing and the candidates are listed.`)}),execute(){throw new Y(`page.stopTimer is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),ry=J({name:`page.submitForm`,description:`Submit a form, firing its submit event and validation as if the user pressed Enter.`,input:K({target:X.optional().describe(`The form, or any element inside it; defaults to the first form on the page`)}),execute({target:e}){let t=e?Z(e).closest(`form`):document.querySelector(`form`);if(!t)throw new Y(`No form found to submit`,`TARGET_NOT_FOUND`);return typeof t.requestSubmit==`function`?t.requestSubmit():t.submit(),{form:Q(t),action:t.getAttribute(`action`)||void 0,method:(t.getAttribute(`method`)||`get`).toLowerCase()}}}),iy=J({name:`page.switchTab`,description:`Bring another open tab to the front, making it the tab every later page action targets. Call it with no arguments to list the open tabs and their ids first.`,input:K({tabId:W().int().optional().describe(`Id of the tab to switch to, as reported by page.openTab or a no-argument page.switchTab.`),match:H().optional().describe(`Instead of an id, switch to the tab whose title or URL contains this text (case-insensitive). If several tabs match, nothing is switched and the candidates are listed.`)}),execute(){throw new Y(`page.switchTab is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),ay=J({name:`page.timerStatus`,description:`Report on scheduled jobs started with page.startTimer: how many times each has fired, how many fires were skipped because the conversation was still busy, when the next one is due, and the latest log lines.`,input:K({timerId:H().optional().describe(`One timer to report. Omit to list every scheduled and recently finished timer.`)}),execute(){throw new Y(`page.timerStatus is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),oy=J({name:`page.trustedClick`,description:`Click with a real browser-level mouse event — isTrusted is true, exactly as if the user had clicked. The pointer travels to the target over a short path and dwells before pressing, so widgets that only react after genuine pointer movement (drag handles, hover menus, canvas tools, captcha checkboxes) see the sequence they wait for. Use it when page.clickElement was ignored: pages that check event.isTrusted, and the browser features only a genuine gesture unlocks — native file pickers, fullscreen, clipboard reads, popups, WebAuthn prompts. Give it either a "target" or a raw viewport "point". It attaches Chrome’s debugger for the duration, so the browser shows a “Browsentic is debugging this browser” bar while it runs, and it cannot run on a tab that has DevTools open. page.clickElement stays the default for ordinary clicks.`,chromiumOnly:!0,input:K({target:X.optional().describe(`Element to click. Give this or "point", never both.`),point:Gh.optional().describe(`Exact viewport coordinates to click, in CSS pixels. Use this when the thing to click has no reachable element — inside a cross-origin iframe or a closed shadow root, as page.findCaptcha reports.`),button:q([`left`,`right`,`middle`]).default(`left`).describe(`Mouse button to press`),clickCount:W().int().min(1).max(3).default(1).describe(`1 for a single click, 2 for a double click, 3 for a triple click`),modifiers:pp(q([`ctrl`,`shift`,`alt`,`meta`])).default([]).describe(`Modifier keys held during the click, e.g. ["meta"] to open a link in a new tab`),scrollIntoView:G().default(!0).describe(`Bring the element into view before clicking. Ignored with "point".`),moveSteps:W().int().min(1).max(60).default(8).describe(`Pointer move events dispatched along the way in. Raise it for widgets that sample the path.`),hoverMs:W().int().min(0).max(2e3).default(60).describe(`Pause on the target after arriving, before pressing.`),holdMs:W().int().min(0).max(2e3).default(50).describe(`How long the button stays down between press and release.`)}),execute({target:e,point:t,button:n,clickCount:r,modifiers:i,scrollIntoView:a,moveSteps:o,hoverMs:s,holdMs:c}){if(!e==!t)throw new Y(`Give either a "target" to click or a "point" to click at — not both, not neither`,`INVALID_INPUT`);let l=e?Z(e):null;l&&a&&l.scrollIntoView({block:`center`,behavior:`instant`});let u=l?qh(l):Jh(t);l&&Zh(l,u);let d=Xh(u);return{...l?$(l):{over:d?Q(d):void 0},point:u,from:Yh(u),button:n,clickCount:r,modifiers:i,moveSteps:o,hoverMs:s,holdMs:c,submits:l?Dh(l):!1}}}),sy={slow:400,natural:220,fast:110,instant:0},cy={".":3,"?":3,"!":3,"\n":2.5,",":2,";":2,":":2},ly=12e4,uy=(e,t)=>[...e].map(e=>t*(cy[e]??1)),dy=(e,t)=>Math.round(e.reduce((e,t)=>e+t,0)*(1+t)),fy=e=>new Promise(t=>setTimeout(t,e)),py=J({name:`page.typeText`,description:`Stream text into a field one keystroke at a time, at a human pace — a real key event per character, pauses that vary, and longer breaths after punctuation. Use page.fillInput when you just need the value in the field; use this when the page should watch someone type.`,input:K({target:X.optional().describe(`Element to type into; defaults to the currently focused element`),text:H().min(1).max(2e3).describe(`Text to type, character by character`),speed:q([`slow`,`natural`,`fast`,`instant`]).default(`natural`).describe(`Typing pace: "slow" ≈ 30 wpm, "natural" ≈ 55 wpm, "fast" ≈ 110 wpm, "instant" fires every keystroke back to back with no pause`),charDelayMs:W().int().min(0).max(2e3).optional().describe(`Average milliseconds between keystrokes; overrides "speed" when given`),jitter:W().min(0).max(1).default(.35).describe(`How much each pause varies at random, as a fraction of it — 0 types in an even machine rhythm, 1 is wildly uneven`),clear:G().default(!0).describe(`Replace existing content instead of appending`),pressEnter:G().default(!1).describe(`Press Enter afterwards, which submits many forms`)}),async execute({target:e,text:t,speed:n,charDelayMs:r,jitter:i,clear:a,pressEnter:o}){let s=e?Z(e):document.activeElement??document.body;if(!(s instanceof HTMLInputElement||s instanceof HTMLTextAreaElement)&&!s.isContentEditable)throw new Y(`<${s.tagName.toLowerCase()}> is not an editable element`,`INVALID_TARGET`);if(t.includes(`
|
|
168
|
+
`)&&s instanceof HTMLInputElement)throw new Y(`A single-line <input> cannot take newlines — drop them from "text", or set pressEnter to submit`,`INVALID_INPUT`);let c=r??sy[n],l=uy(t,c),u=dy(l,i);if(u>ly)throw new Y(`Typing ${t.length} characters at ${c}ms each would take about ${Math.round(u/1e3)}s — raise "speed", lower "charDelayMs", or send the text in shorter pieces`,`INVALID_INPUT`);a&&hy(s),gy(s);let d=performance.now(),f=[...t];for(let[e,t]of f.entries()){let n=e?Math.round(l[e-1]*(1+(Math.random()*2-1)*i)):0;n>0&&await fy(n),vy(s,t)}let p=!1;if(o){let e=Eg(`Enter`),t=s.dispatchEvent(new KeyboardEvent(`keydown`,e));if(s.dispatchEvent(new KeyboardEvent(`keyup`,e)),t&&!(s instanceof HTMLTextAreaElement)){let e=s.closest(`form`);e?.requestSubmit(),p=!!e}}return{element:$(s),typed:f.length,charDelayMs:c,elapsedMs:Math.round(performance.now()-d),appended:!a,submitted:p}}});function my(e,t){let n=e instanceof HTMLInputElement?HTMLInputElement.prototype:HTMLTextAreaElement.prototype;Object.getOwnPropertyDescriptor(n,`value`)?.set?.call(e,t)}function hy(e){e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement?my(e,``):e.textContent=``,e.dispatchEvent(new InputEvent(`input`,{bubbles:!0,inputType:`deleteContentBackward`}))}function gy(e){if(e.focus(),e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement){let t=e.value.length;try{e.setSelectionRange(t,t)}catch{}return}let t=document.createRange();t.selectNodeContents(e),t.collapse(!1);let n=window.getSelection();n?.removeAllRanges(),n?.addRange(t)}function _y(e,t){if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement){let n=e.selectionStart??e.value.length,r=e.selectionEnd??e.value.length;my(e,e.value.slice(0,n)+t+e.value.slice(r));let i=n+t.length;try{e.setSelectionRange(i,i)}catch{}}else if(document.execCommand(`insertText`,!1,t))return;else e.textContent=(e.textContent??``)+t;e.dispatchEvent(new InputEvent(`input`,{bubbles:!0,data:t,inputType:`insertText`}))}function vy(e,t){let n=Eg(t===`
|
|
169
|
+
`?`Enter`:t);e.dispatchEvent(new KeyboardEvent(`keydown`,n))&&(e.dispatchEvent(new KeyboardEvent(`keypress`,n)),_y(e,t)),e.dispatchEvent(new KeyboardEvent(`keyup`,n))}var yy=J({name:`page.waitForElement`,description:`Wait until an element reaches a state: attached, visible, hidden, or detached.`,input:K({target:X.describe(`Element to wait for`),state:q([`attached`,`visible`,`hidden`,`detached`]).default(`visible`).describe(`State to wait for: present in the DOM, present and visible, invisible or absent, or absent`),timeoutMs:W().int().positive().max(3e4).default(5e3).describe(`Give up after this many milliseconds`)}),async execute({target:e,state:t,timeoutMs:n}){let r=()=>{try{return Z(e,{includeHidden:!0})}catch(e){if(e instanceof Y&&e.code===`INVALID_TARGET`)throw e;return null}},i=e=>({attached:!!e,visible:!!e&&Sh(e),hidden:!e||!Sh(e),detached:!e})[t],a=performance.now(),o=r();return i(o)?{state:t,elapsedMs:0,element:o?$(o):void 0}:(await new Promise((e,a)=>{let s=()=>{o=r(),i(o)&&(d(),e())},c=new MutationObserver(s);c.observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0});let l=setInterval(s,250),u=setTimeout(()=>{d(),a(new Y(`Timed out after ${n}ms waiting for element to be ${t}`,`TIMEOUT`))},n),d=()=>{c.disconnect(),clearInterval(l),clearTimeout(u)}}),{state:t,elapsedMs:Math.round(performance.now()-a),element:o?$(o):void 0})}});new Map([S_,zv,Vh,oy,Ag,Xv,F_,fg,h_,Dg,py,Kv,qv,Cg,av,ov,ry,yy,I_,Iv,B_,zh,Pg,m_,hv,Ah,rh,Zv,uv,dv,ey,Qv,V_,Rh,ty,$v,ay,ny,P_,Vv,W_,G_,iy,g_,Hh,Rv,R_,Oh,Bh,L_,z_,fv].map(e=>[e.name,e])),new TextEncoder,new TextDecoder;var by=null;async function xy(){return by||(by=(await c.storage.session.get(`browsentic/frameFocus`))[`browsentic/frameFocus`]??{},by)}async function Sy(e){return(await xy())[String(e)]??[]}async function Cy(e){return(await Sy(e)).at(-1)?.frameId??0}async function wy(e,t,n){try{return await c.tabs.sendMessage(e,{channel:`browsentic/frame`,...n},{frameId:t})??null}catch{return null}}var Ty=(e,t)=>wy(e,t,{op:`describe`}),Ey=(e,t,n)=>wy(e,t,{op:`locate`,frameId:n});async function Dy(e){let t=await Sy(e),n={x:0,y:0},r=0;for(let{frameId:i}of t){let t=await Ey(e,r,i);if(!t)return null;n={x:n.x+t.x,y:n.y+t.y},r=i}return n}var Oy=`the frame in focus is gone or blocks scripts — call page.switchFrame with no arguments to return to the top document`,ky=`Receiving end does not exist`,Ay=new Set([`page.getPageInfo`,`page.extractText`,`page.waitForElement`,`page.navigate`]);async function jy(e,t,...[n]){return My(e,await Cy(e),t,n)}async function My(e,t,n,...[r]){let i=typeof n==`string`?n:n.name,a=async()=>await c.tabs.sendMessage(e,{channel:bs,action:i,input:r},{frameId:t}),o=e=>Cs(`TAB_UNREACHABLE`,t===0?`${e} — the page may not allow content scripts`:`${e} — ${Oy}`);try{return await a()}catch(n){let r=n instanceof Error?n.message:String(n);if(!r.includes(ky)||!await Fy(e,t))return o(r);if(!Ay.has(i))return Cs(`TAB_UNREACHABLE`,`This tab had no content script; one has just been injected and the tab is reachable now. Take a fresh page.getPageInfo snapshot — the page may have changed — then retry the action.`);try{return await a()}catch(e){return Cs(`TAB_UNREACHABLE`,`${e instanceof Error?e.message:String(e)} — the content script was injected but the page still did not answer`)}}}async function Ny(e,...[t]){let[n]=await c.tabs.query({active:!0,currentWindow:!0});return n?.id==null?Cs(`NO_ACTIVE_TAB`,`No active tab to control`):jy(n.id,e,t)}var Py=5e3;async function Fy(e,t=0){let n=(c.runtime.getManifest().content_scripts??[]).flatMap(e=>e.js??[]);if(!n.length)return!1;try{return await Iy(c.scripting.executeScript({target:{tabId:e,frameIds:[t]},files:n,injectImmediately:!0})),!0}catch{return!1}}function Iy(e){return Promise.race([e,new Promise((e,t)=>setTimeout(()=>t(Error(`injection timed out`)),Py))])}var Ly=`browsentic.`;`${Ly}`,`${Ly}`,`${Ly}`,`${Ly}`,`${Ly}`,`${Ly}`;var Ry=15*6e4,zy=/pass|ssn|card|cvv|cvc|otp|secret|token|pin\b/i,By=/cc-|new-password|current-password|one-time-code/i;function Vy(e){let t=(e.type??``).toLowerCase();return t===`password`||t===`hidden`||By.test(e.autocomplete??``)||zy.test(e.name??``)||zy.test(e.id??``)?!0:Hy(e.value??``)}function Hy(e){let t=e.replace(/[\s-]/g,``);if(!/^\d{13,19}$/.test(t))return!1;let n=0,r=!1;for(let e=t.length-1;e>=0;--e){let i=t.charCodeAt(e)-48;r&&(i*=2,i>9&&(i-=9)),n+=i,r=!r}return n%10==0}var Uy=[[`pass`,`word`],[`pass`,`wd`],[`pass`,`phrase`],[`pass`,`code`],[`pwd`],[`otp`],[`one`,`time`,`code`]],Wy=[[`secret`],[`token`],[`api`,`key`],[`access`,`key`],[`access`,`token`],[`secret`,`key`],[`client`,`secret`],[`refresh`,`token`],[`auth`,`token`],[`authorization`],[`bearer`],[`credential`],[`credentials`],[`signing`,`key`],[`private`,`key`],[`connection`,`string`]],Gy=[[`cookie`],[`session`,`id`],[`session`,`key`],[`session`,`token`],[`csrf`,`token`],[`xsrf`,`token`]],Ky=e=>e.map(e=>e.join(String.raw`[_\-\s]?`)).join(`|`),qy=Ky(Uy),Jy=Ky(Wy),Yy=Ky(Gy);[...Uy,...Wy,...Gy].map(e=>e.join(`_`));var Xy=String.raw`(?:Bearer\s+|Basic\s+|Token\s+)?(?:"([^"\r\n]{4,400})"|'([^'\r\n]{4,400})'|([^\s,;&"'<>{}\[\]]{4,400}))`,Zy=e=>new RegExp(String.raw`(?<![A-Za-z0-9])(?:${e})["']?\s*[:=]\s*${Xy}`,`gi`),Qy=String.raw`(?:"([^"\r\n]{4,400})"|'([^'\r\n]{4,400})'|([^\s"'<>]{3,399}[^\s"'<>.,;:!?]))`,$y=e=>new RegExp(String.raw`(?<![A-Za-z0-9])(?:${e})\s+(?:is|are|was|will\s+be)\s*:?\s+${Qy}`,`gi`);Zy(qy),Zy(Jy),Zy(Yy),$y(qy),$y(Jy);var eb=/⟦([a-z-]+):([0-9a-z]+)(?:@([A-Za-z0-9._:\[\]-]{1,255}))?#([0-9a-f]{6,32})⟧/g;function tb(e,t){return e.includes(`⟦`)?[...e.matchAll(eb)].map(e=>({kind:e[1],id:e[2],origin:e[3],tag:e[4],text:e[0]})).filter(e=>!t||e.tag===t):[]}Promise.resolve();var nb=[{id:`recaptcha-v2`,label:`reCAPTCHA v2`,kind:`checkbox`,hostMarkers:[`.g-recaptcha`,`#g-recaptcha`,`iframe[src*="/recaptcha/api2/anchor"]`,`iframe[src*="/recaptcha/enterprise/anchor"]`],frames:[`/recaptcha/api2/anchor`,`/recaptcha/enterprise/anchor`],challengeFrames:[`/recaptcha/api2/bframe`,`/recaptcha/enterprise/bframe`],invisibleFrame:`size=invisible`,checkbox:`#recaptcha-anchor`,checkboxAt:{x:27,y:39},checkedInFrame:`#recaptcha-anchor[aria-checked="true"]`,tokenField:`[name="g-recaptcha-response"]`,grid:{root:`#rc-imageselect`,prompt:`.rc-imageselect-desc-wrapper`,target:`.rc-imageselect-desc-wrapper strong`,tiles:`td.rc-imageselect-tile`,selected:`.rc-imageselect-tileselected`,loading:`.rc-imageselect-dynamic-selected`,cover:`.rc-image-tile-overlay`,submit:`#recaptcha-verify-button`,reload:`#recaptcha-reload-button`,errors:`.rc-imageselect-incorrect-response, .rc-imageselect-error-select-more, .rc-imageselect-error-dynamic-more, .rc-imageselect-error-select-something`,dynamic:`none left`}},{id:`hcaptcha`,label:`hCaptcha`,kind:`checkbox`,hostMarkers:[`.h-captcha`,`[data-hcaptcha-widget-id]`,`iframe[src*="hcaptcha.com/captcha"]`],frames:[`frame=checkbox`],challengeFrames:[`frame=challenge`],invisibleFrame:`frame=checkbox-invisible`,checkbox:`#checkbox`,checkboxAt:{x:30,y:39},checkedInFrame:`#checkbox[aria-checked="true"]`,tokenField:`[name="h-captcha-response"]`,grid:{root:`.task-grid`,prompt:`.prompt-text`,tiles:`.task-grid .task`,selected:`[aria-pressed="true"], .selected`,submit:`.button-submit`,reload:`.refresh.button`,errors:`.display-error`},canvas:{root:`.challenge-view canvas`,prompt:`.prompt-text`,submit:`.button-submit`,reload:`.refresh.button`,errors:`.display-error`,marks:`.challenge-example .image`}},{id:`turnstile`,label:`Cloudflare Turnstile`,kind:`checkbox`,hostMarkers:[`.cf-turnstile`,`#cf-turnstile`,`[name="cf-turnstile-response"]`,`#challenge-stage`,`#cf-challenge-running`,`#challenge-running`],frames:[`challenges.cloudflare.com`],checkbox:`input[type="checkbox"]`,checkboxAt:{x:30,y:32},tokenField:`[name="cf-turnstile-response"]`},{id:`geetest`,label:`GeeTest`,kind:`checkbox`,hostMarkers:[`.geetest_holder`,`.geetest_radar_tip`,`.geetest_btn`,`.geetest_btn_click`],checkbox:`.geetest_radar_tip, .geetest_btn_click`,solvedMarker:`.geetest_success_radar_tip, .geetest_lock_success`},{id:`arkose`,label:`Arkose FunCaptcha`,kind:`interactive`,hostMarkers:[`#funcaptcha`,`#arkose`,`[data-pkey]`,`iframe[src*="arkoselabs.com"]`],frames:[`arkoselabs.com`,`funcaptcha.com`]},{id:`aws-waf`,label:`AWS WAF Captcha`,kind:`interactive`,hostMarkers:[`#captcha-container`,`script[src*="captcha.awswaf.com"]`,`iframe[src*="awswaf.com"]`],frames:[`awswaf.com`]},{id:`recaptcha-v3`,label:`reCAPTCHA v3`,kind:`invisible`,hostMarkers:[`script[src*="recaptcha/api.js?render="]`,`script[src*="recaptcha/enterprise.js?render="]`],tokenField:`[name="g-recaptcha-response"]`}];c.debugger;var rb=e=>`browsentic:shot:${e}`;async function ib(e){let t=rb(e),n=(await c.storage.session.get(t).catch(()=>({})))[t];return typeof n==`string`?n:null}async function ab(e){let t=e.full?await ib(e.previewId):null,n=await(await fetch(t??e.thumbnail)).blob();await c.tabs.create({url:URL.createObjectURL(n)})}var ob=500,sb=16384;sb*sb;async function cb(e){return{dataUrl:e,bitmap:await createImageBitmap(await(await fetch(e)).blob())}}var lb=e=>`Cannot capture this tab (${e instanceof Error?e.message:String(e)}) — it may be a chrome:// page, the Web Store, or a PDF, which browsers refuse to screenshot`,ub=80;async function db(e,t,n){let r=t===`jpeg`?n??ub:void 0;for(let n=0;;n++)try{return await cb(e==null?await c.tabs.captureVisibleTab({format:t,quality:r}):await c.tabs.captureVisibleTab(e,{format:t,quality:r}))}catch(e){let t=e instanceof Error?e.message:String(e);if(n<2&&/MAX_CAPTURE_VISIBLE_TAB_CALLS_PER_SECOND/i.test(t)){await fb(ob);continue}throw new Y(lb(e),`CAPTURE_UNSUPPORTED`)}}var fb=e=>new Promise(t=>setTimeout(t,e));function pb(e,t){return e.arrayBuffer().then(e=>{let n=new Uint8Array(e),r=``,i=32768;for(let e=0;e<n.length;e+=i)r+=String.fromCharCode(...n.subarray(e,e+i));return`data:${t};base64,${btoa(r)}`})}nb.map(({id:e,hostMarkers:t})=>({id:e,selectors:t})),nb.map(({id:e,hostMarkers:t,tokenField:n,solvedMarker:r,checkedInFrame:i,grid:a})=>({id:e,markers:t,tokenField:n,solvedMarker:r,checkedInFrame:i,gridRoot:a?.root}));var mb=1024*1024,hb=10*mb;5*mb,10*mb,5*mb;var gb={UNSUPPORTED_TYPE:`unsupported type`,FILE_TOO_LARGE:`too large`,EMPTY:`empty`,UNREADABLE:`unreadable`,TIMEOUT:`timed out`,CANCELLED:`cancelled`};function _b(e,t){return e===`analyzed`?e:`${e} (${(t&&gb[t])??(e===`failed`?`analysis failed`:`not read`)})`}var vb=`browsentic:files`,yb=e=>`browsentic:file:${e}`;Promise.resolve();async function bb(e){await c.storage.local.set({[yb(e.id)]:e})}var xb=`browsentic:recordings`,Sb=e=>`browsentic:recording:${e}`;async function Cb(){let e=(await c.storage.local.get(xb))[xb];return Array.isArray(e)?e:[]}async function wb(e){await c.storage.local.set({[xb]:e})}async function Tb(e,t){let n=await Cb();n.some(t=>t.id===e)&&await wb(n.map(n=>n.id===e?{...n,...t,updatedAt:Date.now()}:n))}async function Eb(e){await c.storage.local.remove(Sb(e)),await wb((await Cb()).filter(t=>t.id!==e))}async function Db(e,t){let n=t.replace(/\s+/g,` `).trim().slice(0,80);n&&await Tb(e,{name:n})}Promise.resolve(),Promise.resolve();var Ob=16,kb=1200,Ab=.85,jb=120;async function Mb(e,t){let n=await jy(e.id,av.name,t);if(!n.ok)return n;let{capture:r,...i}=n.data,a=r?await Nb(e.id,r):null,o=a?await Pb(e.windowId,a).catch(()=>null):null;return Ss(o?{...i,shot:o}:i)}async function Nb(e,t){if(await Cy(e)===0)return t;let[n,r]=await Promise.all([Dy(e),Ty(e,0)]);return!n||!r?null:{...t,region:{...t.region,x:t.region.x+n.x,y:t.region.y+n.y},viewport:r.viewport}}async function Pb(e,t){let{viewport:n,dpr:r}=t,i=Math.max(0,t.region.x-Ob),a=Math.max(0,t.region.y-Ob),o=Math.min(n.w,t.region.x+t.region.w+Ob)-i,s=Math.min(n.h,t.region.y+t.region.h+Ob)-a;if(o<1||s<1)return null;await new Promise(e=>setTimeout(e,jb));let{bitmap:c}=await db(e,`jpeg`,Math.round(Ab*100)),l=c.width/n.w||r,u=Math.min(1,kb/Math.max(o*l,s*l,1)),d=new OffscreenCanvas(Math.max(1,Math.round(o*l*u)),Math.max(1,Math.round(s*l*u))),f=d.getContext(`2d`);return f?(f.drawImage(c,i*l,a*l,o*l,s*l,0,0,d.width,d.height),c.close(),{dataUrl:await pb(await d.convertToBlob({type:`image/jpeg`,quality:Ab}),`image/jpeg`),width:d.width,height:d.height}):(c.close(),null)}var Fb=`browsentic/tabSessions`;Promise.resolve();var Ib=`browsentic/daemon`;function Lb(){let[e,t]=(0,b.useState)(null);return(0,b.useEffect)(()=>{let e=!0;c.storage.session.get(Ib).then(n=>e&&t(n[`browsentic/daemon`]??null));let n=e=>{`browsentic/daemon`in e&&t(e[`browsentic/daemon`].newValue??null)};return c.storage.session.onChanged.addListener(n),()=>{e=!1,c.storage.session.onChanged.removeListener(n)}},[]),e}var Rb=6e4,zb=60*Rb,Bb=24*zb;function Vb(e){let t=Date.now()-e;return t<Rb?`just now`:t<zb?`${Math.floor(t/Rb)}m ago`:t<Bb?`${Math.floor(t/zb)}h ago`:t<7*Bb?`${Math.floor(t/Bb)}d ago`:new Date(e).toLocaleDateString(void 0,{month:`short`,day:`numeric`})}var Hb=e=>e.op===`agentState`?`refresh`:e.op===`setAgentModel`?`${e.agent}:model`:e.agent,Ub=`__default__`,Wb=20;function Gb(){let e=Lb(),t=e?.agent,n=e?.connected??!1,[r,o]=(0,b.useState)(null),[s,l]=(0,b.useState)(null);(0,b.useEffect)(()=>{n&&!t&&u({op:`agentState`})},[n,t]);async function u(e){o(Hb(e)),l(null);let t=await c.runtime.sendMessage({channel:xs,...e}).catch(()=>null);o(null),t?.ok||l(t?.error.message??`The daemon did not answer.`)}if(!e?.paired)return null;let d=k.map(e=>t?.runners.find(t=>t.kind===e.kind)??Jb(e.kind)),f=t?.active,p=d.find(e=>e.kind===f)?.problem;return(0,x.jsxs)(`section`,{className:`space-y-2`,children:[(0,x.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,x.jsx)(`h2`,{className:`font-mono text-[10px] tracking-[0.14em] text-ink-faint uppercase`,children:`Agent`}),(0,x.jsxs)(`button`,{type:`button`,onClick:()=>void u({op:`agentState`,refresh:!0}),disabled:!n||r!==null,className:`flex items-center gap-1 font-mono text-[10px] tracking-[0.14em] text-ink-faint uppercase transition-colors hover:text-brand disabled:opacity-40`,children:[(0,x.jsx)(g,{className:i(`size-3`,r===`refresh`&&`animate-spin`)}),` Recheck`]})]}),(0,x.jsx)(`div`,{className:`grid gap-1`,children:d.map(e=>(0,x.jsx)(Kb,{runner:e,active:e.kind===f,busy:r===e.kind,modelBusy:r===`${e.kind}:model`,disabled:!n||r!==null,onSelect:()=>void u({op:`setAgent`,agent:e.kind}),onModel:t=>void u({op:`setAgentModel`,agent:e.kind,model:t})},e.kind))}),p&&f&&(0,x.jsxs)(`div`,{className:`space-y-1.5 rounded-lg border border-amber/40 bg-amber/10 p-2`,children:[(0,x.jsxs)(`p`,{className:`flex gap-1.5 text-[11px] leading-snug text-amber`,children:[(0,x.jsx)(y,{className:`mt-px size-3.5 shrink-0`}),(0,x.jsx)(`span`,{children:p.message})]}),p.fix&&(0,x.jsx)(`p`,{className:`font-mono text-[10px] leading-snug break-all text-ink-faint`,children:p.fix}),p.grantable&&(0,x.jsxs)(a,{size:`sm`,className:`w-full`,disabled:!n||r!==null,onClick:()=>void u({op:`grantAgent`,agent:f}),children:[r===f?(0,x.jsx)(h,{className:`animate-spin`}):(0,x.jsx)(v,{}),`Let Browsentic fix it`]})]}),s&&(0,x.jsx)(`p`,{className:`text-[11px] text-destructive`,children:s})]})}function Kb({runner:e,active:t,busy:n,modelBusy:r,disabled:a,onSelect:o,onModel:s}){let c=O[e.kind],l=Yb(e),d=e.model&&!l.ids.includes(e.model)?e.model:null;return(0,x.jsxs)(`div`,{className:i(`rounded-lg border transition-colors`,t?`border-brand/45 bg-brand/10`:`border-line`,!t&&!a&&`hover:border-line-strong hover:bg-surface/60`,a&&!t&&`opacity-50`),children:[(0,x.jsxs)(`button`,{type:`button`,onClick:o,disabled:a||t,"aria-pressed":t,className:i(`flex w-full items-center gap-2 px-2.5 py-2 text-left transition-colors`,t?`text-brand`:`text-ink-dim enabled:hover:text-ink`),children:[(0,x.jsx)(ae,{tone:e.ready?`live`:`warn`}),(0,x.jsx)(C,{kind:e.kind,className:`opacity-90`}),(0,x.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-xs`,children:[c.label,c.beta&&(0,x.jsx)(`span`,{className:`ml-1.5 rounded-sm border border-line px-1 font-mono text-[9px] tracking-wider text-ink-faint uppercase`,children:`beta`})]}),(0,x.jsx)(`span`,{className:`font-mono text-[10px] tracking-wider uppercase opacity-70`,children:qb(e)}),n?(0,x.jsx)(h,{className:`size-3 animate-spin`}):t&&(0,x.jsx)(u,{className:`size-3`})]}),e.ready&&(0,x.jsxs)(`div`,{className:i(`flex flex-wrap items-center gap-x-2 gap-y-1 border-t px-2.5 py-1.5`,t?`border-brand/25`:`border-line`),children:[(0,x.jsx)(`span`,{className:`font-mono text-[10px] tracking-[0.14em] text-ink-faint uppercase`,children:`Model`}),l.ids.length>Wb?(0,x.jsx)(T,{value:e.model??null,ids:l.ids,suggested:c.models.filter(e=>l.ids.includes(e)),pinned:d,disabled:a,onModel:s}):(0,x.jsxs)(ms,{value:e.model??Ub,onValueChange:e=>s(e===Ub?null:e),disabled:a,children:[(0,x.jsx)(gs,{className:`h-6 min-w-0 flex-1 py-0 font-mono text-[10px]`,children:(0,x.jsx)(hs,{})}),(0,x.jsxs)(_s,{align:`end`,className:`font-mono text-[10px]`,children:[(0,x.jsx)(vs,{value:Ub,children:`Default`}),d&&(0,x.jsxs)(vs,{value:d,children:[d,` · not listed`]}),l.ids.map(e=>(0,x.jsx)(vs,{value:e,children:e},e))]})]}),r&&(0,x.jsx)(h,{className:`size-3 animate-spin text-ink-faint`}),t&&(0,x.jsx)(`p`,{className:`basis-full truncate font-mono text-[9px] text-ink-faint`,title:l.error,children:Xb(e.kind,l)})]})]})}function qb(e){if(e.ready)return`ready`;switch(e.problem?.code){case`AGENT_MISSING`:return`not installed`;case`AGENT_NEEDS_PERMISSION`:return`needs setup`;case`AGENT_UNUSABLE`:return`broken`;default:return`checking…`}}var Jb=e=>({kind:e,bin:O[e].bin,ready:!1});function Yb({kind:e,models:t}){return t&&Array.isArray(t.ids)&&t.ids.length?t:{ids:O[e].models,from:`catalog`}}function Xb(e,{ids:t,from:n,at:r,error:i}){let a=n===`cli`&&r!==void 0?`${t.length} listed by ${O[e].bin} · ${Vb(r)}`:`built-in list`;return i?n===`cli`?`${a} · last read failed`:`${a} · ${i}`:a}function Zb(){let e=Lb(),[t,n]=(0,b.useState)(``),[r,i]=(0,b.useState)(!1),[o,s]=(0,b.useState)(null),l=e?.connected??!1,u=e?.paired??!1;async function d(){i(!0),s(null);let e=await c.runtime.sendMessage({channel:xs,op:`pair`,token:t});i(!1),e?.ok?n(``):s(e?.error.message??`Pairing failed`)}async function f(){i(!0),await c.runtime.sendMessage({channel:xs,op:`disconnect`}),i(!1),s(null)}return(0,x.jsxs)(`section`,{className:`space-y-2`,children:[(0,x.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,x.jsx)(`h2`,{className:`font-mono text-[10px] tracking-[0.14em] text-ink-faint uppercase`,children:`Browser link`}),l&&(0,x.jsxs)(`span`,{className:`font-mono text-[10px] text-ink-faint`,children:[`127.0.0.1:`,e?.port]})]}),u?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`p`,{className:`text-[11px] leading-relaxed text-ink-dim`,children:l?`The daemon is driving this browser. Disconnecting revokes the key — you will need a new pairing code.`:`Paired, but the daemon is not answering. Start it with browsentic, or disconnect to pair again.`}),(0,x.jsxs)(a,{variant:`outline`,size:`sm`,className:`w-full`,onClick:f,disabled:r,children:[r?(0,x.jsx)(h,{className:`animate-spin`}):(0,x.jsx)(p,{}),` Disconnect`]})]}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`p`,{className:`text-[11px] leading-relaxed text-ink-dim`,children:[`Run `,(0,x.jsx)(`code`,{className:`rounded bg-surface px-1 py-px font-mono text-ink`,children:`browsentic pair`}),` in a terminal and paste the code it prints.`]}),(0,x.jsxs)(`form`,{className:`flex gap-1.5`,onSubmit:e=>{e.preventDefault(),d()},children:[(0,x.jsx)(w,{value:t,onChange:e=>n(e.target.value),placeholder:`Pairing code`,"aria-label":`Pairing code from browsentic pair`,className:`h-8 font-mono text-xs tracking-widest uppercase`,autoComplete:`off`,spellCheck:!1}),(0,x.jsxs)(a,{type:`submit`,size:`sm`,disabled:r||!t.trim(),children:[r?(0,x.jsx)(h,{className:`animate-spin`}):(0,x.jsx)(m,{}),` Connect`]})]})]}),o&&(0,x.jsx)(`p`,{className:`rounded-lg border border-destructive/40 bg-destructive/10 px-2 py-1.5 text-[11px] text-destructive`,children:o})]})}function Qb(e){return c.sidePanel.open({windowId:e})}async function $b(e){try{let t=c.sidePanel;if(t.close&&e!=null){await t.close({windowId:e});return}}catch{}typeof window<`u`&&window.close()}var ex=`site-mapper`,tx=`[redacted]`,nx=200,rx=20,ix=4;function ax(e,t,n){if(typeof t==`string`)return Vy({name:e,id:e,value:t})?tx:t.length>nx?`${t.slice(0,nx)}…`:t;if(typeof t==`number`||typeof t==`boolean`||t===null)return t;if(n>=ix)return`[…]`;if(Array.isArray(t)){let r=t.slice(0,rx).map(t=>ax(e,t,n+1));return t.length>rx?[...r,`…`]:r}if(typeof t==`object`){let e={};for(let[r,i]of Object.entries(t))e[r]=Vy({name:r,id:r})?tx:ax(r,i,n+1);return e}return null}var ox={"page.fillInput":`value`,"page.typeText":`text`},sx={"page.injectCode":[`purpose`,`code`]};function cx(e,t){if(!t||typeof t!=`object`)return ax(``,t,0);let n=ax(``,t,0);for(let r of sx[e]??[]){let e=t[r];typeof e==`string`&&(n[r]=e)}let r=ox[e];if(r&&r in n){let e=t[r],i=typeof e==`string`?tb(e):[];n[r]=i.length?i.map(e=>e.text).join(` `):tx}return n}var lx=()=>crypto.randomUUID();function ux(e,t){switch(t.kind){case`started`:{let n=t.attached?` + attached: ${t.attached}`:``,r=t.overlays?.length?` + site notes: ${t.overlays.join(`, `)}`:``;return[...e,{kind:`notice`,id:lx(),tone:`info`,text:`Loaded skill: ${t.skill}${n}${r}`}]}case`text`:{let n=e.at(-1);return n?.kind===`assistant`?[...e.slice(0,-1),{...n,text:n.text+t.delta}]:[...e,{kind:`assistant`,id:lx(),text:t.delta}]}case`tool`:return[...e,{kind:`tool`,id:t.toolId,action:t.action,input:cx(t.action,t.input),source:t.source}];case`approval`:return dx(e,t.toolId,{awaiting:!0,site:t.site});case`toolResult`:return dx(e,t.toolId,{ok:t.ok,summary:t.summary,awaiting:!1});case`session`:case`usage`:return e;case`attachments`:{let n=t.files.map(e=>`${e.name} — ${_b(e.verdict,e.code)}`).join(` · `);return[...e,{kind:`notice`,id:lx(),tone:`info`,text:`Handed to the agent: ${n}`}]}case`done`:return t.stopReason===`end_turn`?e:[...e,{kind:`notice`,id:lx(),tone:`info`,text:`Stopped: ${t.stopReason}`}];case`error`:return[...e,{kind:`notice`,id:lx(),tone:`error`,text:`${t.code}: ${t.message}`}]}}function dx(e,t,n){return e.map(e=>e.kind===`tool`&&e.id===t?{...e,...n}:e)}function fx(e,t){for(let n=e.length-1;n>=0;n--){let r=e[n];if(r.kind===`tool`&&r.action===Rv.name&&!r.preview){let i=[...e];return i[n]={...r,preview:t},i}}return e}function px(e,t){return{kind:`notice`,id:lx(),tone:e,text:t}}var mx=Object.keys({escape:`Escape`,esc:`Escape`,tab:`Tab`,space:` `,spacebar:` `,backspace:`Backspace`,delete:`Delete`,"page up":`PageUp`,"page down":`PageDown`,home:`Home`,end:`End`,"up arrow":`ArrowUp`,"down arrow":`ArrowDown`,"left arrow":`ArrowLeft`,"right arrow":`ArrowRight`,"arrow up":`ArrowUp`,"arrow down":`ArrowDown`,"arrow left":`ArrowLeft`,"arrow right":`ArrowRight`}).join(`|`);W_.name,W_.name,W_.name,G_.name,W_.name,W_.name,Vv.name,zv.name,zv.name,zv.name,ov.name,RegExp(`^(?:press|hit|tap|push)(?:\\s+the)?\\s+(?<key>${mx})(?:\\s+key)?$`),ty.name,Vh.name;var hx=`browsentic:sessions`,gx=e=>`browsentic:session:${e}`,_x=e=>e.namingAt!==void 0&&Date.now()-e.namingAt<6e4;async function vx(){let e=(await c.storage.local.get(hx))[hx];return Array.isArray(e)?e:[]}async function yx(e){await c.storage.local.set({[hx]:e})}async function bx(e){await c.storage.local.remove(gx(e)),await yx((await vx()).filter(t=>t.id!==e))}var xx=`browsentic:skills`,Sx=e=>`browsentic:skill:${e}`;async function Cx(){let e=(await c.storage.local.get(xx))[xx];return Array.isArray(e)?e:[]}async function wx(e){await c.storage.local.set({[xx]:e})}async function Tx(e,t){await c.storage.local.set({[Sx(e.id)]:t});let n=await Cx(),r=n.filter(t=>t.id!==e.id&&t.name===e.name);r.length&&await c.storage.local.remove(r.map(e=>Sx(e.id))),await wx([e,...n.filter(t=>t.id!==e.id&&t.name!==e.name)])}var Ex=`browsentic/panelCollapsed`,Dx=`browsentic/panelTab`,Ox=`browsentic/run`;Promise.resolve();var kx={url:``};function Ax(){let[e,t]=(0,b.useState)(kx);return(0,b.useEffect)(()=>{let e=!0,n=()=>{c.tabs.query({active:!0,currentWindow:!0}).then(([n])=>{e&&t(n?.id==null?kx:{url:n.url??``,tabId:n.id,windowId:n.windowId,title:n.title})}).catch(()=>{e&&t(kx)})};n();let r=()=>n(),i=(e,t,r)=>{(t.url||t.title)&&r.active&&n()};return c.tabs.onActivated.addListener(r),c.tabs.onUpdated.addListener(i),()=>{e=!1,c.tabs.onActivated.removeListener(r),c.tabs.onUpdated.removeListener(i)}},[]),e}var jx=e=>Object.values(e??{}).sort((e,t)=>t.lastActivityAt-e.lastActivityAt);function Mx(){let[e,t]=(0,b.useState)([]);return(0,b.useEffect)(()=>{let e=!0;c.storage.session.get(Fb).then(n=>e&&t(jx(n[`browsentic/tabSessions`])));let n=e=>{`browsentic/tabSessions`in e&&t(jx(e[Fb].newValue))};return c.storage.session.onChanged.addListener(n),()=>{e=!1,c.storage.session.onChanged.removeListener(n)}},[]),e}var Nx=1e3,Px=`external`;function Fx(){let[e,t]=(0,b.useState)({}),[n,r]=(0,b.useState)(null),[i,a]=(0,b.useState)([]),[o,s]=(0,b.useState)(null),[l,u]=(0,b.useState)([]),[d,f]=(0,b.useState)({}),p=(0,b.useRef)(null),m=Ax(),h=Mx(),g=(0,b.useMemo)(()=>m.tabId==null?null:h.find(e=>e.tabIds.includes(m.tabId))??null,[h,m.tabId]),_=g?.sessionId??null,v=(0,b.useCallback)((e,t)=>{f(n=>({...n,[e]:t(n[e]??[])}))},[]),y=(0,b.useCallback)((...e)=>{f(t=>{let n={...t};for(let t of e)delete n[t];return n})},[]);(0,b.useEffect)(()=>{let e=!0,n,i=()=>{if(!e)return;let o;try{o=c.runtime.connect({name:Ox})}catch{n=setTimeout(i,Nx);return}p.current=o,o.onMessage.addListener(e=>{let n=e;if(n.op===`mapDraft`)t(e=>({...e,[n.sessionId??Px]:n.draft}));else if(n.op===`mapSettled`)t(e=>Object.fromEntries(Object.entries(e).filter(([,e])=>e.stagingId!==n.stagingId))),!n.ok&&n.message&&v(n.sessionId??Px,e=>[...e,px(`error`,n.message)]);else if(n.op===`recording`)r(n.state);else if(n.op===`monitor`){let e=n.state;a(t=>{let n=t.filter(t=>t.monitorId!==e.monitorId);return e.phase===`watching`?[...n,e]:n})}else n.op===`items`?v(n.sessionId??Px,()=>n.items):n.op===`item`?v(n.sessionId??Px,e=>[...e,n.item]):n.op===`preview`?v(n.sessionId??Px,e=>fx(e,n.preview)):n.op===`toolOffer`?s(n.offer):n.op===`toolOfferSettled`?s(e=>e?.toolkitId===n.toolkitId?null:e):n.op===`tools`?u(n.tools):n.op===`close`?window.close():v(n.sessionId??Px,e=>ux(e,n.event))}),o.onDisconnect.addListener(()=>{p.current===o&&(p.current=null),e&&(n=setTimeout(i,Nx))})};return i(),()=>{e=!1,clearTimeout(n);let t=p.current;p.current=null,t?.disconnect()}},[v]);let x=(0,b.useCallback)(e=>{let t=p.current;if(!t)return!1;try{return t.postMessage(e),!0}catch{return p.current=null,!1}},[]);(0,b.useEffect)(()=>{_&&x({op:`replay`,sessionId:_})},[_,x]);let S=(0,b.useMemo)(()=>{let e=_?d[_]??[]:[],t=d[Px]??[];return t.length?[...e,...t]:e},[_,d]),C=(_?e[_]:void 0)??e[Px]??null,w=(0,b.useCallback)((e,t)=>{let n=e.trim();!n||m.tabId==null||x({op:`instruct`,text:n,agentSkillId:t?.agentSkillId,focus:t?.focus,liveTools:t?.liveTools,tab:{tabId:m.tabId,url:m.url,windowId:m.windowId,title:m.title}})},[x,m]),T=(0,b.useCallback)(e=>{let t=h.find(t=>t.sessionId===e);t&&(async()=>{t.windowId>=0&&await c.windows.update(t.windowId,{focused:!0}).catch(()=>void 0),await c.tabs.update(t.currentTabId,{active:!0}).catch(()=>void 0)})()},[h]),E=(0,b.useCallback)(async e=>{if(m.tabId!=null){if(h.find(t=>t.sessionId===e))return T(e);x({op:`restore`,sessionId:e,tab:{tabId:m.tabId,url:m.url,windowId:m.windowId,title:m.title}})}},[x,h,m,T]);return{items:S,running:g?.runId!=null,sessionId:_,sessions:h,send:w,draft:C,mapSite:(0,b.useCallback)(()=>w(`@${ex} map this site`),[w]),activateMap:(0,b.useCallback)(e=>{C&&x({op:`activateMap`,stagingId:C.stagingId,exactHost:e})},[C,x]),discardMap:(0,b.useCallback)(()=>{C&&x({op:`discardMap`,stagingId:C.stagingId})},[C,x]),recording:n,startRecording:(0,b.useCallback)(e=>{x({op:`startRecording`,captureValues:e})},[x]),stopRecording:(0,b.useCallback)(()=>{x({op:`stopRecording`})},[x]),tools:l,toolOffer:o,keepTool:(0,b.useCallback)(e=>{o&&m.tabId!=null&&x({op:`keepTool`,toolkitId:o.toolkitId,tabId:m.tabId,slug:e})},[o,x,m.tabId]),dismissTool:(0,b.useCallback)(()=>{o&&x({op:`dismissTool`,toolkitId:o.toolkitId})},[o,x]),forgetTool:(0,b.useCallback)(e=>{x({op:`forgetTool`,id:e})},[x]),runTool:(0,b.useCallback)(e=>{m.tabId!=null&&x({op:`runTool`,id:e,tab:{tabId:m.tabId,url:m.url,windowId:m.windowId,title:m.title}})},[x,m]),attachFile:(0,b.useCallback)(e=>{m.tabId!=null&&x({op:`attach`,file:e,tab:{tabId:m.tabId,url:m.url,windowId:m.windowId,title:m.title}})},[x,m]),detachFile:(0,b.useCallback)(e=>x({op:`detach`,fileId:e}),[x]),reanalyzeFile:(0,b.useCallback)(e=>x({op:`reanalyze`,fileId:e}),[x]),monitors:i,stopMonitor:(0,b.useCallback)(e=>{x({op:`stopMonitor`,monitorId:e})},[x]),cancel:(0,b.useCallback)(()=>{_&&x({op:`cancel`,sessionId:_})},[x,_]),decide:(0,b.useCallback)((e,t,n)=>{_&&x({op:`decision`,sessionId:_,toolId:e,allow:t,remember:n})},[x,_]),clear:(0,b.useCallback)(()=>{_&&(y(_,Px),x({op:`endSession`,sessionId:_}))},[x,_,y]),endSession:(0,b.useCallback)(e=>{y(e),x({op:`endSession`,sessionId:e})},[x,y]),restore:E,focusSession:T}}var Ix=`/mic-permission.html`;function Lx(){return navigator.permissions.query({name:`microphone`})}async function Rx(){try{return(await Lx()).state}catch{return`granted`}}function zx(e){let t=null,n=!0,r=()=>{t&&e(t.state)};return Lx().then(e=>{n&&(t=e,t.addEventListener(`change`,r))}).catch(()=>{}),()=>{n=!1,t?.removeEventListener(`change`,r)}}function Bx(){let e=c.runtime.getURL(Ix);return c.tabs.create({url:e})}function Vx(){if(typeof window>`u`)return null;let e=window;return e.SpeechRecognition??e.webkitSpeechRecognition??null}var Hx=400,Ux=`Microphone access is blocked. Allow it for this extension, or type instead.`,Wx=`This browser has no speech service to transcribe with. Type instead.`,Gx=`Browsentic has not been given the microphone yet.`,Kx=`browsentic:voiceEnabled`;function qx(){let[e,t]=(0,b.useState)(!0);return(0,b.useEffect)(()=>{let e=!0;c.storage.local.get(Kx).then(n=>{e&&typeof n[`browsentic:voiceEnabled`]==`boolean`&&t(n[Kx])});let n=e=>{`browsentic:voiceEnabled`in e&&typeof e[`browsentic:voiceEnabled`].newValue==`boolean`&&t(e[Kx].newValue)};return c.storage.local.onChanged.addListener(n),()=>{e=!1,c.storage.local.onChanged.removeListener(n)}},[]),[e,(0,b.useCallback)(e=>{t(e),c.storage.local.set({[Kx]:e})},[])]}function Jx({onFinal:e,onInterim:t}){let[n,r]=(0,b.useState)(!1),[i,a]=(0,b.useState)(null),[o,s]=(0,b.useState)(!1),c=(0,b.useMemo)(()=>Vx()!==null,[]),l=(0,b.useRef)({onFinal:e,onInterim:t});l.current={onFinal:e,onInterim:t};let u=(0,b.useRef)(null),d=(0,b.useRef)(!1),f=(0,b.useRef)(!1),p=(0,b.useRef)(null),m=(0,b.useRef)(null),h=(0,b.useRef)(()=>{}),g=(0,b.useCallback)(()=>{if(!m.current){let e=navigator.mediaDevices;e?.getUserMedia?m.current=e.getUserMedia({audio:!0}).then(e=>e.getTracks().forEach(e=>e.stop())).catch(e=>{throw m.current=null,e}):m.current=Promise.resolve()}return m.current},[]),_=(0,b.useCallback)(async()=>{let e=Vx();if(!e||u.current)return;if(await Rx()===`prompt`){r(!1),s(!0),a(Gx);return}s(!1);try{await g()}catch{d.current=!1,f.current=!0,r(!1),s(!0),a(Ux);return}if(!d.current)return;let t=new e;t.continuous=!0,t.interimResults=!0,t.lang=navigator.language||`en-US`,t.maxAlternatives=1,t.onstart=()=>{r(!0),a(null)},t.onresult=e=>{let t=``,n=``;for(let r=e.resultIndex;r<e.results.length;r++){let i=e.results[r],a=i[0]?.transcript??``;i.isFinal?n+=a:t+=a}t.trim()&&l.current.onInterim?.(t.trim()),n.trim()&&l.current.onFinal(n.trim())},t.onerror=e=>{if(!(e.error===`aborted`||e.error===`no-speech`)){if(e.error===`not-allowed`||e.error===`service-not-allowed`){d.current=!1,f.current=!0,m.current=null,s(!0),a(Ux);return}if(e.error===`audio-capture`){d.current=!1,a(`No microphone was found.`);return}if(e.error===`network`){d.current=!1,a(Wx);return}a(e.error)}},t.onend=()=>{u.current=null,r(!1),d.current&&(p.current&&clearTimeout(p.current),p.current=setTimeout(()=>{d.current&&h.current()},Hx))},u.current=t;try{t.start()}catch{}},[g]);h.current=()=>void _();let v=(0,b.useCallback)(()=>{Vx()&&(d.current=!0,_())},[_]),y=(0,b.useCallback)(()=>{d.current=!1,f.current=!1,p.current&&clearTimeout(p.current);let e=u.current;if(u.current=null,r(!1),e)try{e.abort()}catch{}},[]);return(0,b.useEffect)(()=>()=>y(),[y]),(0,b.useEffect)(()=>zx(e=>{if(e!==`prompt`){if(m.current=null,e===`denied`){s(!0),a(Ux);return}s(!1),a(null),f.current&&(d.current=!0),f.current=!1,d.current&&h.current()}}),[]),{supported:c,listening:n,error:i,needsGrant:o,grant:(0,b.useCallback)(()=>void Bx(),[]),start:v,stop:y}}var Yx=1600;function Xx(e){let t=e.autoSendMs??Yx,[n,r]=(0,b.useState)(``),[i,a]=(0,b.useState)(``),[o,s]=(0,b.useState)(!1),c=(0,b.useRef)(``),l=(0,b.useRef)(null),u=(0,b.useRef)(e.onSubmit);u.current=e.onSubmit;let d=(0,b.useCallback)(e=>{c.current=e,r(e)},[]),f=(0,b.useCallback)(()=>{l.current&&=(clearTimeout(l.current),null),s(!1)},[]),p=(0,b.useCallback)(()=>{f();let e=c.current.trim();e&&(d(``),a(``),u.current(e))},[f,d]),m=(0,b.useCallback)(()=>{l.current&&clearTimeout(l.current),s(!0),l.current=setTimeout(()=>{l.current=null,s(!1),p()},t)},[t,p]),h=Jx({onInterim:e=>{a(e),f()},onFinal:e=>{a(``),d(c.current?`${c.current} ${e}`:e),m()}}),{start:g,stop:_}=h;return(0,b.useEffect)(()=>{e.active?g():(_(),f())},[e.active,g,_,f]),{input:n,setInput:(0,b.useCallback)(e=>{d(e),f()},[d,f]),interim:i,listening:h.listening,supported:h.supported,error:h.error,needsGrant:h.needsGrant,grant:h.grant,pendingSend:o,autoSendMs:t,cancelPending:f,submitNow:p,retry:g}}export{Lh as A,oe as B,bb as C,Ny as D,Ry as E,Ve as F,y as G,O as H,Re as I,g as J,v as K,xe as L,bi as M,N,I_ as O,Ge as P,A as R,vb as S,ab as T,w as U,ne as V,C as W,d as X,h as Y,u as Z,Lb as _,Ex as a,Eb as b,Tx as c,bx as d,$b as f,Vb as g,Gb as h,Ax as i,xs as j,S_ as k,hx as l,Zb as m,qx as n,Dx as o,Qb as p,_ as q,Fx as r,xx as s,Xx as t,_x as u,Mb as v,hb as w,Db as x,xb as y,ue as z};
|